mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Added performance improvements for Block States
This commit is contained in:
parent
ae780a69bb
commit
045cdf1090
@ -9,6 +9,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.data.type.Dispenser;
|
import org.bukkit.block.data.type.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -22,6 +23,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -153,7 +155,10 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace
|
|||||||
|
|
||||||
if (id != null && id.equals("OUTPUT_CHEST")) {
|
if (id != null && id.equals("OUTPUT_CHEST")) {
|
||||||
// Found the output chest! Now, let's check if we can fit the product in it.
|
// Found the output chest! Now, let's check if we can fit the product in it.
|
||||||
Inventory inv = ((Chest) potentialOutput.getState()).getInventory();
|
BlockState state = PaperLib.getBlockState(potentialOutput, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Chest) {
|
||||||
|
Inventory inv = ((Chest) state).getInventory();
|
||||||
|
|
||||||
if (InvUtils.fits(inv, output)) {
|
if (InvUtils.fits(inv, output)) {
|
||||||
return inv;
|
return inv;
|
||||||
@ -161,6 +166,7 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
|
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
@ -93,7 +94,7 @@ final class CargoUtils {
|
|||||||
return withdrawFromVanillaInventory(node, template, inventory);
|
return withdrawFromVanillaInventory(node, template, inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState state = target.getState();
|
BlockState state = PaperLib.getBlockState(target, false).getState();
|
||||||
|
|
||||||
if (state instanceof InventoryHolder) {
|
if (state instanceof InventoryHolder) {
|
||||||
inventory = ((InventoryHolder) state).getInventory();
|
inventory = ((InventoryHolder) state).getInventory();
|
||||||
@ -181,7 +182,7 @@ final class CargoUtils {
|
|||||||
return withdrawFromVanillaInventory(node, inventory);
|
return withdrawFromVanillaInventory(node, inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState state = target.getState();
|
BlockState state = PaperLib.getBlockState(target, false).getState();
|
||||||
|
|
||||||
if (state instanceof InventoryHolder) {
|
if (state instanceof InventoryHolder) {
|
||||||
inventory = ((InventoryHolder) state).getInventory();
|
inventory = ((InventoryHolder) state).getInventory();
|
||||||
@ -233,7 +234,7 @@ final class CargoUtils {
|
|||||||
return insertIntoVanillaInventory(stack, inventory);
|
return insertIntoVanillaInventory(stack, inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState state = target.getState();
|
BlockState state = PaperLib.getBlockState(target, false).getState();
|
||||||
|
|
||||||
if (state instanceof InventoryHolder) {
|
if (state instanceof InventoryHolder) {
|
||||||
inventory = ((InventoryHolder) state).getInventory();
|
inventory = ((InventoryHolder) state).getInventory();
|
||||||
|
@ -32,6 +32,7 @@ import io.github.thebusybiscuit.slimefun4.api.network.Network;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -382,7 +383,7 @@ abstract class ChestTerminalNetwork extends Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (CargoUtils.hasInventory(target)) {
|
else if (CargoUtils.hasInventory(target)) {
|
||||||
BlockState state = target.getState();
|
BlockState state = PaperLib.getBlockState(target, false).getState();
|
||||||
|
|
||||||
if (state instanceof InventoryHolder) {
|
if (state instanceof InventoryHolder) {
|
||||||
Inventory inv = ((InventoryHolder) state).getInventory();
|
Inventory inv = ((InventoryHolder) state).getInventory();
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.Tag;
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.Rotatable;
|
import org.bukkit.block.data.Rotatable;
|
||||||
@ -36,6 +37,7 @@ import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
|||||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||||
@ -689,7 +691,10 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
|
|
||||||
protected void depositItems(BlockMenu menu, Block facedBlock) {
|
protected void depositItems(BlockMenu menu, Block facedBlock) {
|
||||||
if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_ITEMS")) {
|
if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_ITEMS")) {
|
||||||
Dispenser d = (Dispenser) facedBlock.getState();
|
BlockState state = PaperLib.getBlockState(facedBlock, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser d = (Dispenser) state;
|
||||||
|
|
||||||
for (int slot : getOutputSlots()) {
|
for (int slot : getOutputSlots()) {
|
||||||
ItemStack stack = menu.getItemInSlot(slot);
|
ItemStack stack = menu.getItemInSlot(slot);
|
||||||
@ -707,10 +712,14 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void refuel(BlockMenu menu, Block facedBlock) {
|
protected void refuel(BlockMenu menu, Block facedBlock) {
|
||||||
if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_FUEL")) {
|
if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_FUEL")) {
|
||||||
Dispenser d = (Dispenser) facedBlock.getState();
|
BlockState state = PaperLib.getBlockState(facedBlock, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser d = (Dispenser) state;
|
||||||
|
|
||||||
for (int slot = 0; slot < 9; slot++) {
|
for (int slot = 0; slot < 9; slot++) {
|
||||||
ItemStack item = d.getInventory().getItem(slot);
|
ItemStack item = d.getInventory().getItem(slot);
|
||||||
@ -721,6 +730,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean insertFuel(BlockMenu menu, Inventory dispenser, int slot, ItemStack currentFuel, ItemStack newFuel) {
|
private boolean insertFuel(BlockMenu menu, Inventory dispenser, int slot, ItemStack currentFuel, ItemStack newFuel) {
|
||||||
if (currentFuel == null) {
|
if (currentFuel == null) {
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -24,6 +25,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -129,7 +131,10 @@ public class Composter extends SimpleSlimefunItem<BlockUseHandler> implements Re
|
|||||||
|
|
||||||
if (id != null && id.equals("OUTPUT_CHEST")) {
|
if (id != null && id.equals("OUTPUT_CHEST")) {
|
||||||
// Found the output chest! Now, let's check if we can fit the product in it.
|
// Found the output chest! Now, let's check if we can fit the product in it.
|
||||||
Inventory inv = ((Chest) potentialOutput.getState()).getInventory();
|
BlockState state = PaperLib.getBlockState(potentialOutput, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Chest) {
|
||||||
|
Inventory inv = ((Chest) state).getInventory();
|
||||||
|
|
||||||
if (InvUtils.fits(inv, output)) {
|
if (InvUtils.fits(inv, output)) {
|
||||||
return Optional.of(inv);
|
return Optional.of(inv);
|
||||||
@ -137,6 +142,7 @@ public class Composter extends SimpleSlimefunItem<BlockUseHandler> implements Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Effect;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -15,6 +16,7 @@ import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
@ -35,7 +37,10 @@ abstract class AbstractSmeltery extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
||||||
|
|
||||||
@ -60,6 +65,7 @@ abstract class AbstractSmeltery extends MultiBlockMachine {
|
|||||||
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean canCraft(Inventory inv, List<ItemStack[]> inputs, int i) {
|
private boolean canCraft(Inventory inv, List<ItemStack[]> inputs, int i) {
|
||||||
for (ItemStack expectedInput : inputs.get(i)) {
|
for (ItemStack expectedInput : inputs.get(i)) {
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -16,6 +17,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
@ -24,17 +26,16 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
public class ArmorForge extends MultiBlockMachine {
|
public class ArmorForge extends MultiBlockMachine {
|
||||||
|
|
||||||
public ArmorForge(Category category, SlimefunItemStack item) {
|
public ArmorForge(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] {
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.ANVIL), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, new ItemStack[0], BlockFace.SELF);
|
||||||
null, null, null,
|
|
||||||
null, new ItemStack(Material.ANVIL), null,
|
|
||||||
null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null
|
|
||||||
}, new ItemStack[0], BlockFace.SELF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ public class ArmorForge extends MultiBlockMachine {
|
|||||||
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isCraftable(Inventory inv, ItemStack[] recipe) {
|
private boolean isCraftable(Inventory inv, ItemStack[] recipe) {
|
||||||
for (int j = 0; j < inv.getContents().length; j++) {
|
for (int j = 0; j < inv.getContents().length; j++) {
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -17,6 +18,7 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
@ -25,14 +27,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
public class Compressor extends MultiBlockMachine {
|
public class Compressor extends MultiBlockMachine {
|
||||||
|
|
||||||
public Compressor(Category category, SlimefunItemStack item) {
|
public Compressor(Category category, SlimefunItemStack item) {
|
||||||
super(category, item,
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON) }, new ItemStack[] { new CustomItem(SlimefunItems.STONE_CHUNK, 4), new ItemStack(Material.COBBLESTONE), new ItemStack(Material.FLINT, 8), new ItemStack(Material.COBBLESTONE) }, BlockFace.SELF);
|
||||||
new ItemStack[] {null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON)},
|
|
||||||
new ItemStack[] {
|
|
||||||
new CustomItem(SlimefunItems.STONE_CHUNK, 4), new ItemStack(Material.COBBLESTONE),
|
|
||||||
new ItemStack(Material.FLINT, 8), new ItemStack(Material.COBBLESTONE)
|
|
||||||
},
|
|
||||||
BlockFace.SELF
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -43,7 +38,10 @@ public class Compressor extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
|
|
||||||
for (ItemStack item : inv.getContents()) {
|
for (ItemStack item : inv.getContents()) {
|
||||||
@ -70,6 +68,7 @@ public class Compressor extends MultiBlockMachine {
|
|||||||
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void craft(Player p, ItemStack output, Inventory outputInv) {
|
private void craft(Player p, ItemStack output, Inventory outputInv) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -15,6 +16,7 @@ import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -30,7 +32,10 @@ public class EnhancedCraftingTable extends BackpackCrafter {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispenser = b.getRelative(BlockFace.DOWN);
|
Block dispenser = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispenser.getState();
|
BlockState state = PaperLib.getBlockState(dispenser, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
|
|
||||||
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
||||||
@ -47,6 +52,7 @@ public class EnhancedCraftingTable extends BackpackCrafter {
|
|||||||
}
|
}
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack output) {
|
private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack output) {
|
||||||
Inventory fakeInv = createVirtualInventory(inv);
|
Inventory fakeInv = createVirtualInventory(inv);
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -17,6 +18,7 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -24,25 +26,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
public class GrindStone extends MultiBlockMachine {
|
public class GrindStone extends MultiBlockMachine {
|
||||||
|
|
||||||
public GrindStone(Category category, SlimefunItemStack item) {
|
public GrindStone(Category category, SlimefunItemStack item) {
|
||||||
super(category, item,
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, new ItemStack[] { new ItemStack(Material.BLAZE_ROD), new ItemStack(Material.BLAZE_POWDER, 4), new ItemStack(Material.BONE), new ItemStack(Material.BONE_MEAL, 4), new ItemStack(Material.GRAVEL), new ItemStack(Material.FLINT), new ItemStack(Material.ENDER_EYE), new CustomItem(SlimefunItems.ENDER_LUMP_1, 2), new ItemStack(Material.COBBLESTONE), new ItemStack(Material.GRAVEL), new ItemStack(Material.ANDESITE), new ItemStack(Material.GRAVEL), new ItemStack(Material.DIORITE), new ItemStack(Material.GRAVEL), new ItemStack(Material.GRANITE), new ItemStack(Material.GRAVEL), new ItemStack(Material.DIRT), SlimefunItems.STONE_CHUNK, new ItemStack(Material.SANDSTONE), new ItemStack(Material.SAND, 4), new ItemStack(Material.RED_SANDSTONE), new ItemStack(Material.RED_SAND, 4), new ItemStack(Material.PRISMARINE_BRICKS), new ItemStack(Material.PRISMARINE, 2), new ItemStack(Material.PRISMARINE), new ItemStack(Material.PRISMARINE_SHARD, 4) }, BlockFace.SELF);
|
||||||
new ItemStack[] {null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null},
|
|
||||||
new ItemStack[] {
|
|
||||||
new ItemStack(Material.BLAZE_ROD), new ItemStack(Material.BLAZE_POWDER, 4),
|
|
||||||
new ItemStack(Material.BONE), new ItemStack(Material.BONE_MEAL, 4),
|
|
||||||
new ItemStack(Material.GRAVEL), new ItemStack(Material.FLINT),
|
|
||||||
new ItemStack(Material.ENDER_EYE), new CustomItem(SlimefunItems.ENDER_LUMP_1, 2),
|
|
||||||
new ItemStack(Material.COBBLESTONE), new ItemStack(Material.GRAVEL),
|
|
||||||
new ItemStack(Material.ANDESITE), new ItemStack(Material.GRAVEL),
|
|
||||||
new ItemStack(Material.DIORITE), new ItemStack(Material.GRAVEL),
|
|
||||||
new ItemStack(Material.GRANITE), new ItemStack(Material.GRAVEL),
|
|
||||||
new ItemStack(Material.DIRT), SlimefunItems.STONE_CHUNK,
|
|
||||||
new ItemStack(Material.SANDSTONE), new ItemStack(Material.SAND, 4),
|
|
||||||
new ItemStack(Material.RED_SANDSTONE), new ItemStack(Material.RED_SAND, 4),
|
|
||||||
new ItemStack(Material.PRISMARINE_BRICKS), new ItemStack(Material.PRISMARINE, 2),
|
|
||||||
new ItemStack(Material.PRISMARINE), new ItemStack(Material.PRISMARINE_SHARD, 4)
|
|
||||||
},
|
|
||||||
BlockFace.SELF
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,7 +37,10 @@ public class GrindStone extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
|
|
||||||
for (ItemStack current : inv.getContents()) {
|
for (ItemStack current : inv.getContents()) {
|
||||||
@ -79,5 +66,6 @@ public class GrindStone extends MultiBlockMachine {
|
|||||||
}
|
}
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -17,6 +18,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -24,11 +26,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
public class Juicer extends MultiBlockMachine {
|
public class Juicer extends MultiBlockMachine {
|
||||||
|
|
||||||
public Juicer(Category category, SlimefunItemStack item) {
|
public Juicer(Category category, SlimefunItemStack item) {
|
||||||
super(category, item,
|
super(category, item, new ItemStack[] { null, new ItemStack(Material.GLASS), null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, new ItemStack[0], BlockFace.SELF);
|
||||||
new ItemStack[] {null, new ItemStack(Material.GLASS), null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null},
|
|
||||||
new ItemStack[0],
|
|
||||||
BlockFace.SELF
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -39,7 +37,10 @@ public class Juicer extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
|
|
||||||
for (ItemStack current : inv.getContents()) {
|
for (ItemStack current : inv.getContents()) {
|
||||||
@ -56,7 +57,9 @@ public class Juicer extends MultiBlockMachine {
|
|||||||
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.HAY_BLOCK);
|
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.HAY_BLOCK);
|
||||||
}
|
}
|
||||||
else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -65,5 +68,6 @@ public class Juicer extends MultiBlockMachine {
|
|||||||
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -17,6 +17,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -38,7 +39,11 @@ public class MagicWorkbench extends BackpackCrafter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Inventory inv = ((Dispenser) dispenser.getState()).getInventory();
|
BlockState state = PaperLib.getBlockState(dispenser, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
|
Inventory inv = disp.getInventory();
|
||||||
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
||||||
|
|
||||||
for (int i = 0; i < inputs.size(); i++) {
|
for (int i = 0; i < inputs.size(); i++) {
|
||||||
@ -52,8 +57,10 @@ public class MagicWorkbench extends BackpackCrafter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack output) {
|
private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack output) {
|
||||||
Inventory fakeInv = createVirtualInventory(inv);
|
Inventory fakeInv = createVirtualInventory(inv);
|
||||||
@ -68,20 +75,26 @@ public class MagicWorkbench extends BackpackCrafter {
|
|||||||
|
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
if (inv.getContents()[j] != null && inv.getContents()[j].getType() != Material.AIR) {
|
if (inv.getContents()[j] != null && inv.getContents()[j].getType() != Material.AIR) {
|
||||||
if (inv.getContents()[j].getAmount() > 1) inv.setItem(j, new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1));
|
if (inv.getContents()[j].getAmount() > 1) {
|
||||||
else inv.setItem(j, null);
|
inv.setItem(j, new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inv.setItem(j, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startAnimation(p, b, outputInv, output);
|
startAnimation(p, b, outputInv, output);
|
||||||
}
|
}
|
||||||
else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startAnimation(Player p, Block b, Inventory inv, ItemStack output) {
|
private void startAnimation(Player p, Block b, Inventory inv, ItemStack output) {
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
int current = j;
|
int current = j;
|
||||||
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance(), () -> {
|
Slimefun.runSync(() -> {
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
|
p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1);
|
p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1);
|
||||||
|
|
||||||
@ -99,10 +112,18 @@ public class MagicWorkbench extends BackpackCrafter {
|
|||||||
private Block locateDispenser(Block b) {
|
private Block locateDispenser(Block b) {
|
||||||
Block block = null;
|
Block block = null;
|
||||||
|
|
||||||
if (b.getRelative(1, 0, 0).getType() == Material.DISPENSER) block = b.getRelative(1, 0, 0);
|
if (b.getRelative(1, 0, 0).getType() == Material.DISPENSER) {
|
||||||
else if (b.getRelative(0, 0, 1).getType() == Material.DISPENSER) block = b.getRelative(0, 0, 1);
|
block = b.getRelative(1, 0, 0);
|
||||||
else if (b.getRelative(-1, 0, 0).getType() == Material.DISPENSER) block = b.getRelative(-1, 0, 0);
|
}
|
||||||
else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) block = b.getRelative(0, 0, -1);
|
else if (b.getRelative(0, 0, 1).getType() == Material.DISPENSER) {
|
||||||
|
block = b.getRelative(0, 0, 1);
|
||||||
|
}
|
||||||
|
else if (b.getRelative(-1, 0, 0).getType() == Material.DISPENSER) {
|
||||||
|
block = b.getRelative(-1, 0, 0);
|
||||||
|
}
|
||||||
|
else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) {
|
||||||
|
block = b.getRelative(0, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.Effect;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -20,6 +21,7 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -62,7 +64,10 @@ public class OreCrusher extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
|
|
||||||
for (ItemStack current : inv.getContents()) {
|
for (ItemStack current : inv.getContents()) {
|
||||||
@ -77,7 +82,9 @@ public class OreCrusher extends MultiBlockMachine {
|
|||||||
outputInv.addItem(adding);
|
outputInv.addItem(adding);
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, 1);
|
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, 1);
|
||||||
}
|
}
|
||||||
else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -86,6 +93,7 @@ public class OreCrusher extends MultiBlockMachine {
|
|||||||
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class DoubleOreSetting extends ItemSetting<Boolean> {
|
private class DoubleOreSetting extends ItemSetting<Boolean> {
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -18,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
@ -41,7 +43,10 @@ public class OreWasher extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.UP);
|
Block dispBlock = b.getRelative(BlockFace.UP);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
|
|
||||||
for (ItemStack input : inv.getContents()) {
|
for (ItemStack input : inv.getContents()) {
|
||||||
@ -53,7 +58,8 @@ public class OreWasher extends MultiBlockMachine {
|
|||||||
if (!legacyMode) {
|
if (!legacyMode) {
|
||||||
// This is a fancy way of checking if there is empty space in the inv; by checking if an
|
// This is a fancy way of checking if there is empty space in the inv; by checking if an
|
||||||
// unobtainable item could fit in it.
|
// unobtainable item could fit in it.
|
||||||
// However, due to the way the method findValidOutputInv() functions, the dummyAdding will never
|
// However, due to the way the method findValidOutputInv() functions, the dummyAdding will
|
||||||
|
// never
|
||||||
// actually be added to the real inventory,
|
// actually be added to the real inventory,
|
||||||
// so it really doesn't matter what item the ItemStack is made by. SlimefunItems.DEBUG_FISH
|
// so it really doesn't matter what item the ItemStack is made by. SlimefunItems.DEBUG_FISH
|
||||||
// however, signals that it's
|
// however, signals that it's
|
||||||
@ -93,6 +99,7 @@ public class OreWasher extends MultiBlockMachine {
|
|||||||
}
|
}
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void removeItem(Player p, Block b, Inventory inputInv, Inventory outputInv, ItemStack input, ItemStack output, int amount) {
|
private void removeItem(Player p, Block b, Inventory inputInv, Inventory outputInv, ItemStack input, ItemStack output, int amount) {
|
||||||
if (outputInv != null) {
|
if (outputInv != null) {
|
||||||
|
@ -3,12 +3,12 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -19,18 +19,17 @@ import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
public class PressureChamber extends MultiBlockMachine {
|
public class PressureChamber extends MultiBlockMachine {
|
||||||
|
|
||||||
public PressureChamber(Category category, SlimefunItemStack item) {
|
public PressureChamber(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] {
|
super(category, item, new ItemStack[] { SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new CustomItem(Material.DISPENSER, "Dispenser (Facing down)"), SlimefunPlugin.getMinecraftVersion()
|
||||||
SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new CustomItem(Material.DISPENSER, "Dispenser (Facing down)"), SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB),
|
.isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) }, new ItemStack[0], BlockFace.UP);
|
||||||
new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON),
|
|
||||||
new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON)
|
|
||||||
}, new ItemStack[0], BlockFace.UP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,7 +40,10 @@ public class PressureChamber extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.UP).getRelative(BlockFace.UP);
|
Block dispBlock = b.getRelative(BlockFace.UP).getRelative(BlockFace.UP);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
|
|
||||||
for (ItemStack current : inv.getContents()) {
|
for (ItemStack current : inv.getContents()) {
|
||||||
@ -57,7 +59,9 @@ public class PressureChamber extends MultiBlockMachine {
|
|||||||
|
|
||||||
craft(p, b, output, outputInv);
|
craft(p, b, output, outputInv);
|
||||||
}
|
}
|
||||||
else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -65,12 +69,13 @@ public class PressureChamber extends MultiBlockMachine {
|
|||||||
}
|
}
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void craft(Player p, Block b, ItemStack output, Inventory outputInv) {
|
private void craft(Player p, Block b, ItemStack output, Inventory outputInv) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int j = i;
|
int j = i;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance(), () -> {
|
Slimefun.runSync(() -> {
|
||||||
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
|
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
|
||||||
p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
|
p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
|
||||||
p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
|
p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dropper;
|
import org.bukkit.block.Dropper;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -22,6 +23,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -97,7 +99,11 @@ public class Smeltery extends AbstractSmeltery {
|
|||||||
private Inventory findIgnitionChamber(Block b) {
|
private Inventory findIgnitionChamber(Block b) {
|
||||||
for (BlockFace face : faces) {
|
for (BlockFace face : faces) {
|
||||||
if (b.getRelative(face).getType() == Material.DROPPER && BlockStorage.check(b.getRelative(face), "IGNITION_CHAMBER")) {
|
if (b.getRelative(face).getType() == Material.DROPPER && BlockStorage.check(b.getRelative(face), "IGNITION_CHAMBER")) {
|
||||||
return ((Dropper) b.getRelative(face).getState()).getInventory();
|
BlockState state = PaperLib.getBlockState(b.getRelative(face), false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dropper) {
|
||||||
|
return ((Dropper) state).getInventory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.Particle;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.data.type.Piston;
|
import org.bukkit.block.data.type.Piston;
|
||||||
import org.bukkit.block.data.type.PistonHead;
|
import org.bukkit.block.data.type.PistonHead;
|
||||||
@ -24,6 +25,7 @@ import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
|||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
import io.github.thebusybiscuit.cscorelib2.scheduling.TaskQueue;
|
import io.github.thebusybiscuit.cscorelib2.scheduling.TaskQueue;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
|
|
||||||
@ -251,7 +253,10 @@ class ActiveMiner implements Runnable {
|
|||||||
// Check if there is enough fuel to run
|
// Check if there is enough fuel to run
|
||||||
if (fuel > 0) {
|
if (fuel > 0) {
|
||||||
if (chest.getType() == Material.CHEST) {
|
if (chest.getType() == Material.CHEST) {
|
||||||
Inventory inv = ((Chest) chest.getState()).getBlockInventory();
|
BlockState state = PaperLib.getBlockState(chest, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Chest) {
|
||||||
|
Inventory inv = ((Chest) state).getBlockInventory();
|
||||||
|
|
||||||
if (InvUtils.fits(inv, item)) {
|
if (InvUtils.fits(inv, item)) {
|
||||||
inv.addItem(item);
|
inv.addItem(item);
|
||||||
@ -261,6 +266,11 @@ class ActiveMiner implements Runnable {
|
|||||||
stop("machines.INDUSTRIAL_MINER.chest-full");
|
stop("machines.INDUSTRIAL_MINER.chest-full");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// I won't question how this happened...
|
||||||
|
stop("machines.INDUSTRIAL_MINER.destroyed");
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// The chest has been destroyed
|
// The chest has been destroyed
|
||||||
stop("machines.INDUSTRIAL_MINER.destroyed");
|
stop("machines.INDUSTRIAL_MINER.destroyed");
|
||||||
@ -280,7 +290,10 @@ class ActiveMiner implements Runnable {
|
|||||||
*/
|
*/
|
||||||
private int consumeFuel() {
|
private int consumeFuel() {
|
||||||
if (chest.getType() == Material.CHEST) {
|
if (chest.getType() == Material.CHEST) {
|
||||||
Inventory inv = ((Chest) chest.getState()).getBlockInventory();
|
BlockState state = PaperLib.getBlockState(chest, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Chest) {
|
||||||
|
Inventory inv = ((Chest) state).getBlockInventory();
|
||||||
|
|
||||||
for (int i = 0; i < inv.getSize(); i++) {
|
for (int i = 0; i < inv.getSize(); i++) {
|
||||||
for (MachineFuel fuelType : miner.fuelTypes) {
|
for (MachineFuel fuelType : miner.fuelTypes) {
|
||||||
@ -298,6 +311,7 @@ class ActiveMiner implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
@ -15,6 +17,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunIte
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BrokenSpawner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BrokenSpawner;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSpawner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSpawner;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -65,7 +68,10 @@ public class PickaxeOfContainment extends SimpleSlimefunItem<BlockBreakHandler>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (e.getBlock().getType() == Material.SPAWNER) e.setDropItems(false);
|
if (e.getBlock().getType() == Material.SPAWNER) {
|
||||||
|
e.setDropItems(false);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,9 +90,15 @@ public class PickaxeOfContainment extends SimpleSlimefunItem<BlockBreakHandler>
|
|||||||
ItemMeta im = spawner.getItemMeta();
|
ItemMeta im = spawner.getItemMeta();
|
||||||
List<String> lore = im.getLore();
|
List<String> lore = im.getLore();
|
||||||
|
|
||||||
|
BlockState state = PaperLib.getBlockState(b, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof CreatureSpawner) {
|
||||||
|
EntityType entityType = ((CreatureSpawner) state).getSpawnedType();
|
||||||
|
|
||||||
for (int i = 0; i < lore.size(); i++) {
|
for (int i = 0; i < lore.size(); i++) {
|
||||||
if (lore.get(i).contains("<Type>")) {
|
if (lore.get(i).contains("<Type>")) {
|
||||||
lore.set(i, lore.get(i).replace("<Type>", ChatUtils.humanize(((CreatureSpawner) b.getState()).getSpawnedType().toString())));
|
lore.set(i, lore.get(i).replace("<Type>", ChatUtils.humanize(entityType.name())));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,4 +107,7 @@ public class PickaxeOfContainment extends SimpleSlimefunItem<BlockBreakHandler>
|
|||||||
return spawner;
|
return spawner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new ItemStack(Material.SPAWNER);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.block.data.Directional;
|
import org.bukkit.block.data.Directional;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -11,6 +12,7 @@ import org.bukkit.event.block.BlockDispenseEvent;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
|
|
||||||
@ -39,10 +41,14 @@ public class DispenserListener implements Listener {
|
|||||||
|
|
||||||
if (machine != null) {
|
if (machine != null) {
|
||||||
machine.callItemHandler(BlockDispenseHandler.class, handler -> {
|
machine.callItemHandler(BlockDispenseHandler.class, handler -> {
|
||||||
Dispenser dispenser = (Dispenser) b.getState();
|
BlockState state = PaperLib.getBlockState(b, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser dispenser = (Dispenser) state;
|
||||||
BlockFace face = ((Directional) b.getBlockData()).getFacing();
|
BlockFace face = ((Directional) b.getBlockData()).getFacing();
|
||||||
Block block = b.getRelative(face);
|
Block block = b.getRelative(face);
|
||||||
handler.onBlockDispense(e, dispenser, block, machine);
|
handler.onBlockDispense(e, dispenser, block, machine);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user