-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
6,522 additions
and
6,013 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/me/matl114/logitech/Listeners/Listeners/SuperSpongeDryListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package me.matl114.logitech.Listeners.Listeners; | ||
|
||
import me.matl114.logitech.SlimefunItem.AddItem; | ||
import me.matl114.logitech.Utils.CraftUtils; | ||
import me.matl114.logitech.Utils.Debug; | ||
import org.bukkit.Material; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.block.BlockState; | ||
import org.bukkit.block.Container; | ||
import org.bukkit.block.data.BlockData; | ||
import org.bukkit.block.data.type.Furnace; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.inventory.FurnaceBurnEvent; | ||
import org.bukkit.event.inventory.FurnaceSmeltEvent; | ||
import org.bukkit.inventory.FurnaceInventory; | ||
import org.bukkit.inventory.Inventory; | ||
import org.bukkit.inventory.InventoryHolder; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
public class SuperSpongeDryListener implements Listener { | ||
@EventHandler | ||
public void onFurnaceDryFinish(FurnaceSmeltEvent event){ | ||
ItemStack stack=event.getSource(); | ||
if(stack.getType()== Material.WET_SPONGE&& CraftUtils.matchItemStack(stack,AddItem.SUPERSPONGE_USED,false)){ | ||
Block block=event.getBlock(); | ||
BlockState blockData=block.getState(); | ||
if(blockData instanceof Container ih){ | ||
Inventory inventory=ih.getInventory(); | ||
if(inventory instanceof FurnaceInventory fi){ | ||
ItemStack fuelSlot=fi.getFuel(); | ||
ItemStack outputSlot=fi.getResult(); | ||
if(outputSlot==null||outputSlot.getType()==Material.AIR){ | ||
//槽位是空的,直接输入该输出就行 | ||
event.setResult(AddItem.SUPERSPONGE.clone()); | ||
if(fuelSlot!=null&&fuelSlot.getType()== Material.BUCKET){ | ||
//燃料修改 | ||
fuelSlot.setType(Material.POWDER_SNOW_BUCKET); | ||
} | ||
} | ||
else if( CraftUtils.matchItemStack(outputSlot,AddItem.SUPERSPONGE,false)){ | ||
//由于bukkit特性,需要我们自己设置数量 | ||
ItemStack source=fi.getSmelting(); | ||
if(CraftUtils.matchItemStack(source,AddItem.SUPERSPONGE_USED,false)){ | ||
outputSlot.setAmount(outputSlot.getAmount()+1); | ||
source.setAmount(source.getAmount()-1); | ||
if(fuelSlot!=null&&fuelSlot.getType()== Material.BUCKET){ | ||
//燃料修改 | ||
fuelSlot.setType(Material.POWDER_SNOW_BUCKET); | ||
} | ||
event.setCancelled(true); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.