diff --git a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java index b8e78ad68..62c591c92 100644 --- a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java +++ b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java @@ -181,7 +181,7 @@ public class FluidReplicatorRecipeCrafter extends RecipeCrafter { return; } if (hasAllInputs(currentRecipe)) { - inventory.decrStackSize(inputSlots[0], currentRecipe.getInput()); + inventory.shrinkSlot(inputSlots[0], currentRecipe.getInput()); } } diff --git a/src/main/java/techreborn/client/container/ContainerDestructoPack.java b/src/main/java/techreborn/client/container/ContainerDestructoPack.java index 09f0dd257..4a7eed87c 100644 --- a/src/main/java/techreborn/client/container/ContainerDestructoPack.java +++ b/src/main/java/techreborn/client/container/ContainerDestructoPack.java @@ -25,8 +25,8 @@ package techreborn.client.container; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import reborncore.client.gui.slots.BaseSlot; import reborncore.client.gui.slots.SlotFilteredVoid; import reborncore.common.container.RebornContainer; import reborncore.common.util.Inventory; @@ -56,12 +56,12 @@ public class ContainerDestructoPack extends RebornContainer { for (i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); } } } diff --git a/src/main/java/techreborn/client/container/builder/BuiltContainer.java b/src/main/java/techreborn/client/container/builder/BuiltContainer.java index 0af8f0c69..ce65c54b8 100644 --- a/src/main/java/techreborn/client/container/builder/BuiltContainer.java +++ b/src/main/java/techreborn/client/container/builder/BuiltContainer.java @@ -100,7 +100,7 @@ public class BuiltContainer extends Container { @Override public boolean canInteractWith(final EntityPlayer playerIn) { if(this.tile != null) { - return tile.isUsableByPlayer(playerIn); + return playerIn.getDistanceSq((double) tile.getPos().getX() + 0.5D, (double) tile.getPos().getY() + 0.5D, (double) tile.getPos().getZ() + 0.5D) <= 64.0D; } else { return this.canInteract.test(playerIn); // < } diff --git a/src/main/java/techreborn/client/container/builder/ContainerBuilder.java b/src/main/java/techreborn/client/container/builder/ContainerBuilder.java index 8de49a3d5..dd37decd8 100644 --- a/src/main/java/techreborn/client/container/builder/ContainerBuilder.java +++ b/src/main/java/techreborn/client/container/builder/ContainerBuilder.java @@ -26,11 +26,13 @@ package techreborn.client.container.builder; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; +import net.minecraftforge.items.IItemHandler; import org.apache.commons.lang3.Range; import org.apache.commons.lang3.tuple.Pair; +import reborncore.api.tile.ItemHandlerProvider; +import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.tile.TileLegacyMachineBase; import java.util.ArrayList; @@ -77,7 +79,7 @@ public class ContainerBuilder { return new ContainerPlayerInventoryBuilder(this, player); } - public ContainerTileInventoryBuilder tile(final IInventory tile) { + public ContainerTileInventoryBuilder tile(final TileLegacyMachineBase tile) { return new ContainerTileInventoryBuilder(this, tile); } diff --git a/src/main/java/techreborn/client/container/builder/ContainerPlayerInventoryBuilder.java b/src/main/java/techreborn/client/container/builder/ContainerPlayerInventoryBuilder.java index 945bae58c..c84acda5b 100644 --- a/src/main/java/techreborn/client/container/builder/ContainerPlayerInventoryBuilder.java +++ b/src/main/java/techreborn/client/container/builder/ContainerPlayerInventoryBuilder.java @@ -26,8 +26,9 @@ package techreborn.client.container.builder; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.inventory.Slot; +import net.minecraftforge.items.wrapper.InvWrapper; import org.apache.commons.lang3.Range; -import reborncore.client.gui.slots.BaseSlot; import techreborn.client.IconSupplier; import techreborn.client.container.builder.slot.SpriteSlot; @@ -48,7 +49,7 @@ public final class ContainerPlayerInventoryBuilder { final int startIndex = this.parent.slots.size(); for (int i = 0; i < 3; ++i) for (int j = 0; j < 9; ++j) - this.parent.slots.add(new BaseSlot(this.player, j + i * 9 + 9, xStart + j * 18, yStart + i * 18)); + this.parent.slots.add(new Slot(this.player, j + i * 9 + 9, xStart + j * 18, yStart + i * 18)); this.main = Range.between(startIndex, this.parent.slots.size() - 1); return this; } @@ -56,7 +57,7 @@ public final class ContainerPlayerInventoryBuilder { public ContainerPlayerInventoryBuilder hotbar(final int xStart, final int yStart) { final int startIndex = this.parent.slots.size(); for (int i = 0; i < 9; ++i) - this.parent.slots.add(new BaseSlot(this.player, i, xStart + i * 18, yStart)); + this.parent.slots.add(new Slot(this.player, i, xStart + i * 18, yStart)); this.hotbar = Range.between(startIndex, this.parent.slots.size() - 1); return this; } @@ -95,7 +96,7 @@ public final class ContainerPlayerInventoryBuilder { private ContainerPlayerArmorInventoryBuilder armor(final int index, final int xStart, final int yStart, final EntityEquipmentSlot slotType, final String sprite) { - this.parent.parent.slots.add(new SpriteSlot(this.parent.player, index, xStart, yStart, sprite, 1) + this.parent.parent.slots.add(new SpriteSlot(new InvWrapper(this.parent.player), index, xStart, yStart, sprite, 1) .setFilter(stack -> stack.getItem().isValidArmor(stack, slotType, this.parent.player.player))); return this; } diff --git a/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java b/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java index d0e618cb0..d00d68fcc 100644 --- a/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java +++ b/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java @@ -24,14 +24,14 @@ package techreborn.client.container.builder; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.inventory.SlotFurnaceFuel; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.items.IItemHandler; import org.apache.commons.lang3.Range; +import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.tuple.Pair; import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.tile.IUpgradeable; @@ -39,8 +39,10 @@ import reborncore.client.gui.slots.BaseSlot; import reborncore.client.gui.slots.SlotFake; import reborncore.client.gui.slots.SlotOutput; import reborncore.common.powerSystem.TilePowerAcceptor; +import reborncore.common.tile.TileLegacyMachineBase; import techreborn.Core; import techreborn.client.container.builder.slot.FilteredSlot; +import techreborn.client.container.builder.slot.FurnaceFuelSlot; import techreborn.client.container.builder.slot.UpgradeSlot; import java.util.function.Consumer; @@ -50,54 +52,56 @@ import java.util.function.Predicate; public class ContainerTileInventoryBuilder { - private final IInventory tile; + private final TileLegacyMachineBase tile; private final ContainerBuilder parent; private final int rangeStart; - ContainerTileInventoryBuilder(final ContainerBuilder parent, final IInventory tile) { + ContainerTileInventoryBuilder(final ContainerBuilder parent, final TileLegacyMachineBase tile) { this.tile = tile; this.parent = parent; this.rangeStart = parent.slots.size(); - if (tile instanceof IUpgradeable) { - upgradeSlots((IUpgradeable) tile); + //Ensure that the tile has an inv + Validate.isTrue(tile.getInventoryForTile().isPresent()); + if (tile.canBeUpgraded()) { + upgradeSlots(tile); } } public ContainerTileInventoryBuilder slot(final int index, final int x, final int y) { - this.parent.slots.add(new BaseSlot(this.tile, index, x, y)); + this.parent.slots.add(new BaseSlot(this.tile.getInventoryForTile().get(), index, x, y)); return this; } public ContainerTileInventoryBuilder outputSlot(final int index, final int x, final int y) { - this.parent.slots.add(new SlotOutput(this.tile, index, x, y)); + this.parent.slots.add(new SlotOutput(this.tile.getInventoryForTile().get(), index, x, y)); return this; } public ContainerTileInventoryBuilder fakeSlot(final int index, final int x, final int y) { - this.parent.slots.add(new SlotFake(this.tile, index, x, y, false, false, Integer.MAX_VALUE)); + this.parent.slots.add(new SlotFake(this.tile.getInventoryForTile().get(), index, x, y, false, false, Integer.MAX_VALUE)); return this; } public ContainerTileInventoryBuilder filterSlot(final int index, final int x, final int y, final Predicate filter) { - this.parent.slots.add(new FilteredSlot(this.tile, index, x, y).setFilter(filter)); + this.parent.slots.add(new FilteredSlot(this.tile.getInventoryForTile().get(), index, x, y).setFilter(filter)); return this; } public ContainerTileInventoryBuilder energySlot(final int index, final int x, final int y) { - this.parent.slots.add(new FilteredSlot(this.tile, index, x, y) + this.parent.slots.add(new FilteredSlot(this.tile.getInventoryForTile().get(), index, x, y) .setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP))); return this; } public ContainerTileInventoryBuilder fluidSlot(final int index, final int x, final int y) { - this.parent.slots.add(new FilteredSlot(this.tile, index, x, y).setFilter( + this.parent.slots.add(new FilteredSlot(this.tile.getInventoryForTile().get(), index, x, y).setFilter( stack -> stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.UP))); return this; } public ContainerTileInventoryBuilder fuelSlot(final int index, final int x, final int y) { - this.parent.slots.add(new SlotFurnaceFuel(this.tile, index, x, y)); + this.parent.slots.add(new FurnaceFuelSlot(this.tile.getInventoryForTile().get(), index, x, y)); return this; } diff --git a/src/main/java/techreborn/client/container/builder/slot/FilteredSlot.java b/src/main/java/techreborn/client/container/builder/slot/FilteredSlot.java index ae5f71f2f..7df050f9a 100644 --- a/src/main/java/techreborn/client/container/builder/slot/FilteredSlot.java +++ b/src/main/java/techreborn/client/container/builder/slot/FilteredSlot.java @@ -24,22 +24,22 @@ package techreborn.client.container.builder.slot; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import net.minecraftforge.items.IItemHandler; +import reborncore.client.gui.slots.BaseSlot; import java.util.function.Predicate; -public class FilteredSlot extends Slot { +public class FilteredSlot extends BaseSlot { private Predicate filter; private int stackLimit = 64; - public FilteredSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition) { + public FilteredSlot(final IItemHandler inventory, final int index, final int xPosition, final int yPosition) { super(inventory, index, xPosition, yPosition); } - public FilteredSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, int stackLimit) { + public FilteredSlot(final IItemHandler inventory, final int index, final int xPosition, final int yPosition, int stackLimit) { super(inventory, index, xPosition, yPosition); this.stackLimit = stackLimit; } diff --git a/src/main/java/techreborn/client/container/builder/slot/FurnaceFuelSlot.java b/src/main/java/techreborn/client/container/builder/slot/FurnaceFuelSlot.java new file mode 100644 index 000000000..e2b6c543e --- /dev/null +++ b/src/main/java/techreborn/client/container/builder/slot/FurnaceFuelSlot.java @@ -0,0 +1,31 @@ +package techreborn.client.container.builder.slot; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.items.IItemHandler; +import reborncore.client.gui.slots.BaseSlot; + +public class FurnaceFuelSlot extends BaseSlot { + + public FurnaceFuelSlot(IItemHandler inventoryIn, int index, int xPosition, int yPosition) { + super(inventoryIn, index, xPosition, yPosition); + } + + @Override + public boolean isItemValid(ItemStack stack) + { + return TileEntityFurnace.isItemFuel(stack) || isBucket(stack); + } + + @Override + public int getItemStackLimit(ItemStack stack) + { + return isBucket(stack) ? 1 : super.getItemStackLimit(stack); + } + + public static boolean isBucket(ItemStack stack) + { + return stack.getItem() == Items.BUCKET; + } +} diff --git a/src/main/java/techreborn/client/container/builder/slot/SpriteSlot.java b/src/main/java/techreborn/client/container/builder/slot/SpriteSlot.java index 5b6d828d5..75e9c9cd1 100644 --- a/src/main/java/techreborn/client/container/builder/slot/SpriteSlot.java +++ b/src/main/java/techreborn/client/container/builder/slot/SpriteSlot.java @@ -24,9 +24,9 @@ package techreborn.client.container.builder.slot; -import net.minecraft.inventory.IInventory; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.items.IItemHandler; import javax.annotation.Nullable; @@ -35,13 +35,13 @@ public class SpriteSlot extends FilteredSlot { private final String spriteName; int stacksize; - public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, final String sprite, final int stacksize) { + public SpriteSlot(final IItemHandler inventory, final int index, final int xPosition, final int yPosition, final String sprite, final int stacksize) { super(inventory, index, xPosition, yPosition); this.spriteName = sprite; this.stacksize = stacksize; } - public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, final String sprite) { + public SpriteSlot(final IItemHandler inventory, final int index, final int xPosition, final int yPosition, final String sprite) { this(inventory, index, xPosition, yPosition, sprite, 64); } diff --git a/src/main/java/techreborn/client/container/builder/slot/UpgradeSlot.java b/src/main/java/techreborn/client/container/builder/slot/UpgradeSlot.java index 6c285bffc..a26ed2635 100644 --- a/src/main/java/techreborn/client/container/builder/slot/UpgradeSlot.java +++ b/src/main/java/techreborn/client/container/builder/slot/UpgradeSlot.java @@ -25,19 +25,19 @@ package techreborn.client.container.builder.slot; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.items.IItemHandler; import reborncore.api.tile.IUpgrade; import reborncore.api.tile.IUpgradeable; +import reborncore.client.gui.slots.BaseSlot; import reborncore.common.util.Inventory; import techreborn.client.container.IRightClickHandler; import techreborn.client.container.builder.BuiltContainer; -public class UpgradeSlot extends Slot implements IRightClickHandler { +public class UpgradeSlot extends BaseSlot implements IRightClickHandler { - public UpgradeSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition) { + public UpgradeSlot(final IItemHandler inventory, final int index, final int xPosition, final int yPosition) { super(inventory, index, xPosition, yPosition); } diff --git a/src/main/java/techreborn/client/gui/GuiDigitalChest.java b/src/main/java/techreborn/client/gui/GuiDigitalChest.java index 138655ee6..de13f0d50 100644 --- a/src/main/java/techreborn/client/gui/GuiDigitalChest.java +++ b/src/main/java/techreborn/client/gui/GuiDigitalChest.java @@ -50,13 +50,13 @@ public class GuiDigitalChest extends GuiBase { super.drawGuiContainerForegroundLayer(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; - if (!this.digitalChest.storedItem.isEmpty() && this.digitalChest.getStackInSlot(1) != null) { + if (!this.digitalChest.storedItem.isEmpty() && !this.digitalChest.inventory.getStackInSlot(1).isEmpty()) { this.builder.drawBigBlueBar(this, 31, 43, - this.digitalChest.storedItem.getCount() + this.digitalChest.getStackInSlot(1).getCount(), + this.digitalChest.storedItem.getCount() + this.digitalChest.inventory.getStackInSlot(1).getCount(), this.digitalChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); } - if (this.digitalChest.storedItem.isEmpty() && this.digitalChest.getStackInSlot(1) != null) { - this.builder.drawBigBlueBar(this, 31, 43, this.digitalChest.getStackInSlot(1).getCount(), + if (this.digitalChest.storedItem.isEmpty() && !this.digitalChest.inventory.getStackInSlot(1).isEmpty()) { + this.builder.drawBigBlueBar(this, 31, 43, this.digitalChest.inventory.getStackInSlot(1).getCount(), this.digitalChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiQuantumChest.java b/src/main/java/techreborn/client/gui/GuiQuantumChest.java index 61f2269ff..5bc10e48f 100644 --- a/src/main/java/techreborn/client/gui/GuiQuantumChest.java +++ b/src/main/java/techreborn/client/gui/GuiQuantumChest.java @@ -50,11 +50,11 @@ public class GuiQuantumChest extends GuiBase { super.drawGuiContainerForegroundLayer(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; - if (!this.quantumChest.storedItem.isEmpty() && this.quantumChest.getStackInSlot(1) != null) { - this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.storedItem.getCount() + this.quantumChest.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); + if (!this.quantumChest.storedItem.isEmpty() && !this.quantumChest.inventory.getStackInSlot(1).isEmpty()) { + this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.storedItem.getCount() + this.quantumChest.inventory.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); } - if (this.quantumChest.storedItem.isEmpty() && this.quantumChest.getStackInSlot(1) != null) { - this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); + if (this.quantumChest.storedItem.isEmpty() && !this.quantumChest.inventory.getStackInSlot(1).isEmpty()) { + this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.inventory.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); } } } diff --git a/src/main/java/techreborn/client/gui/slot/GuiSlotConfiguration.java b/src/main/java/techreborn/client/gui/slot/GuiSlotConfiguration.java index d922415e0..388172007 100644 --- a/src/main/java/techreborn/client/gui/slot/GuiSlotConfiguration.java +++ b/src/main/java/techreborn/client/gui/slot/GuiSlotConfiguration.java @@ -70,7 +70,7 @@ public class GuiSlotConfiguration { if (guiBase.tile != slot.inventory) { continue; } - ConfigSlotElement slotElement = new ConfigSlotElement(guiBase.getMachine(), slot.getSlotIndex(), SlotType.NORMAL, slot.xPos - guiBase.guiLeft + 50, slot.yPos - guiBase.guiTop - 25, guiBase); + ConfigSlotElement slotElement = new ConfigSlotElement(guiBase.getMachine().getInventoryForTile().get(), slot.getSlotIndex(), SlotType.NORMAL, slot.xPos - guiBase.guiLeft + 50, slot.yPos - guiBase.guiTop - 25, guiBase); slotElementMap.put(slot.getSlotIndex(), slotElement); } diff --git a/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java b/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java index 6a95ec9c3..cdd18f109 100644 --- a/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java +++ b/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java @@ -28,8 +28,8 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderItem; -import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import net.minecraftforge.items.IItemHandler; import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.common.recipes.RecipeCrafter; import techreborn.client.gui.GuiBase; @@ -41,13 +41,13 @@ import java.util.List; public class ConfigSlotElement extends ElementBase { SlotType type; - IInventory inventory; + IItemHandler inventory; int id; public List elements = new ArrayList<>(); boolean filter = false; - public ConfigSlotElement(IInventory slotInventory, int slotId, SlotType type, int x, int y, GuiBase gui) { + public ConfigSlotElement(IItemHandler slotInventory, int slotId, SlotType type, int x, int y, GuiBase gui) { super(x, y, type.getButtonSprite()); this.type = type; this.inventory = slotInventory; diff --git a/src/main/java/techreborn/tiles/TileChargeOMat.java b/src/main/java/techreborn/tiles/TileChargeOMat.java index 0330cab5a..1701050fa 100644 --- a/src/main/java/techreborn/tiles/TileChargeOMat.java +++ b/src/main/java/techreborn/tiles/TileChargeOMat.java @@ -30,7 +30,7 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.RebornCoreConfig; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; @@ -44,7 +44,7 @@ import techreborn.lib.ModInfo; @RebornRegistry(modID = ModInfo.MOD_ID) public class TileChargeOMat extends TilePowerAcceptor - implements IToolDrop, IInventoryProvider, IContainerProvider { + implements IToolDrop, ItemHandlerProvider, IContainerProvider { @ConfigRegistry(config = "machines", category = "charge_bench", key = "ChargeBenchMaxInput", comment = "Charge Bench Max Input (Value in EU)") public static int maxInput = 512; @@ -117,7 +117,7 @@ public class TileChargeOMat extends TilePowerAcceptor return new ItemStack(ModBlocks.CHARGE_O_MAT, 1); } - // IInventoryProvider + // ItemHandlerProvider @Override public Inventory getInventory() { return inventory; diff --git a/src/main/java/techreborn/tiles/TileChunkLoader.java b/src/main/java/techreborn/tiles/TileChunkLoader.java index ab71e3d38..af5c0ec03 100644 --- a/src/main/java/techreborn/tiles/TileChunkLoader.java +++ b/src/main/java/techreborn/tiles/TileChunkLoader.java @@ -28,7 +28,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.impl.ConfigRegistry; @@ -40,7 +40,7 @@ import techreborn.init.ModBlocks; import techreborn.lib.ModInfo; @RebornRegistry(modID = ModInfo.MOD_ID) -public class TileChunkLoader extends TilePowerAcceptor implements IToolDrop, IInventoryProvider, IContainerProvider { +public class TileChunkLoader extends TilePowerAcceptor implements IToolDrop, ItemHandlerProvider, IContainerProvider { @ConfigRegistry(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxInput", comment = "Chunk Loader Max Input (Value in EU)") public static int maxInput = 32; diff --git a/src/main/java/techreborn/tiles/TileCreativeQuantumChest.java b/src/main/java/techreborn/tiles/TileCreativeQuantumChest.java index 30ff4c65b..662c7fcb4 100644 --- a/src/main/java/techreborn/tiles/TileCreativeQuantumChest.java +++ b/src/main/java/techreborn/tiles/TileCreativeQuantumChest.java @@ -31,7 +31,7 @@ public class TileCreativeQuantumChest extends TileQuantumChest { @Override public void update() { super.update(); - ItemStack stack = getStackInSlot(1); + ItemStack stack = inventory.getStackInSlot(1); if (!stack.isEmpty() && storedItem.isEmpty()) { stack.setCount(stack.getMaxStackSize()); storedItem = stack.copy(); diff --git a/src/main/java/techreborn/tiles/TileGenericMachine.java b/src/main/java/techreborn/tiles/TileGenericMachine.java index ae634523c..54b4d9f69 100644 --- a/src/main/java/techreborn/tiles/TileGenericMachine.java +++ b/src/main/java/techreborn/tiles/TileGenericMachine.java @@ -30,7 +30,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import reborncore.api.IToolDrop; import reborncore.api.recipe.IRecipeCrafterProvider; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; @@ -40,7 +40,7 @@ import reborncore.common.util.Inventory; * */ public abstract class TileGenericMachine extends TilePowerAcceptor - implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider{ + implements IToolDrop, ItemHandlerProvider, IRecipeCrafterProvider{ public String name; public int maxInput; @@ -113,7 +113,7 @@ public abstract class TileGenericMachine extends TilePowerAcceptor return new ItemStack(toolDrop, 1); } - // IInventoryProvider + // ItemHandlerProvider @Override public Inventory getInventory() { return inventory; diff --git a/src/main/java/techreborn/tiles/TileMatterFabricator.java b/src/main/java/techreborn/tiles/TileMatterFabricator.java index eb8e55924..08cfb019f 100644 --- a/src/main/java/techreborn/tiles/TileMatterFabricator.java +++ b/src/main/java/techreborn/tiles/TileMatterFabricator.java @@ -28,7 +28,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.impl.ConfigRegistry; @@ -38,13 +38,13 @@ import techreborn.client.container.IContainerProvider; import techreborn.client.container.builder.BuiltContainer; import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -import techreborn.init.TRItems; import techreborn.init.TRIngredients; +import techreborn.init.TRItems; import techreborn.lib.ModInfo; @RebornRegistry(modID = ModInfo.MOD_ID) public class TileMatterFabricator extends TilePowerAcceptor - implements IToolDrop, IInventoryProvider, IContainerProvider { + implements IToolDrop, ItemHandlerProvider, IContainerProvider { @ConfigRegistry(config = "machines", category = "matter_fabricator", key = "MatterFabricatorMaxInput", comment = "Matter Fabricator Max Input (Value in EU)") public static int maxInput = 8192; @@ -88,7 +88,7 @@ public class TileMatterFabricator extends TilePowerAcceptor private void addOutputProducts(int slot) { if (inventory.getStackInSlot(slot).isEmpty()) { - inventory.setInventorySlotContents(slot, TRIngredients.Parts.UU_MATTER.getStack()); + inventory.setStackInSlot(slot, TRIngredients.Parts.UU_MATTER.getStack()); } else if (ItemUtils.isItemEqual(this.inventory.getStackInSlot(slot), TRIngredients.Parts.UU_MATTER.getStack(), true, true)) { inventory.getStackInSlot(slot).setCount((Math.min(64, 1 + inventory.getStackInSlot(slot).getCount()))); @@ -151,7 +151,7 @@ public class TileMatterFabricator extends TilePowerAcceptor if (amp != 0 && this.canUseEnergy(euNeeded)) { useEnergy(euNeeded); amplifier += amp; - inventory.decrStackSize(i, 1); + inventory.shrinkSlot(i, 1); } } } @@ -201,7 +201,7 @@ public class TileMatterFabricator extends TilePowerAcceptor return new ItemStack(ModBlocks.MATTER_FABRICATOR, 1); } - // IInventoryProvider + // ItemHandlerProvider @Override public Inventory getInventory() { return inventory; diff --git a/src/main/java/techreborn/tiles/TileQuantumTank.java b/src/main/java/techreborn/tiles/TileQuantumTank.java index 9742e00c8..70b99d673 100644 --- a/src/main/java/techreborn/tiles/TileQuantumTank.java +++ b/src/main/java/techreborn/tiles/TileQuantumTank.java @@ -31,7 +31,7 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import reborncore.api.IListInfoProvider; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.impl.ConfigRegistry; import reborncore.common.tile.TileLegacyMachineBase; @@ -49,7 +49,7 @@ import java.util.List; @RebornRegistry(modID = ModInfo.MOD_ID) public class TileQuantumTank extends TileLegacyMachineBase - implements IInventoryProvider, IToolDrop, IListInfoProvider, IContainerProvider { + implements ItemHandlerProvider, IToolDrop, IListInfoProvider, IContainerProvider { @ConfigRegistry(config = "machines", category = "quantum_tank", key = "QuantumTankMaxStorage", comment = "Maximum amount of millibuckets a Quantum Tank can store") public static int maxStorage = Integer.MAX_VALUE; @@ -111,7 +111,7 @@ public class TileQuantumTank extends TileLegacyMachineBase readFromNBT(packet.getNbtCompound()); } - // IInventoryProvider + // ItemHandlerProvider @Override public Inventory getInventory() { return this.inventory; diff --git a/src/main/java/techreborn/tiles/TileTechStorageBase.java b/src/main/java/techreborn/tiles/TileTechStorageBase.java index 9f7f8b830..38ffd1f2d 100644 --- a/src/main/java/techreborn/tiles/TileTechStorageBase.java +++ b/src/main/java/techreborn/tiles/TileTechStorageBase.java @@ -32,10 +32,9 @@ import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.wrapper.InvWrapper; import reborncore.api.IListInfoProvider; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.tile.TileLegacyMachineBase; import reborncore.common.util.Inventory; import reborncore.common.util.ItemUtils; @@ -45,11 +44,10 @@ import java.util.ArrayList; import java.util.List; public class TileTechStorageBase extends TileLegacyMachineBase - implements IInventoryProvider, IToolDrop, IListInfoProvider { + implements ItemHandlerProvider, IToolDrop, IListInfoProvider { public final int maxCapacity; public final Inventory inventory; - public InvWrapper invWrapper; public ItemStack storedItem; public TileTechStorageBase(String name, int maxCapacity) { @@ -95,18 +93,12 @@ public class TileTechStorageBase extends TileLegacyMachineBase dropStack.setTagCompound(new NBTTagCompound()); dropStack.getTagCompound().setTag("tileEntity", tileEntity); storedItem.setCount(0); - setInventorySlotContents(1, ItemStack.EMPTY); + inventory.setStackInSlot(1, ItemStack.EMPTY); syncWithAll(); return dropStack; } - public InvWrapper getInvWrapper() { - if (invWrapper == null) - invWrapper = new InvWrapper(this); - return invWrapper; - } - public int getStoredCount() { return storedItem.getCount(); } @@ -115,8 +107,8 @@ public class TileTechStorageBase extends TileLegacyMachineBase ArrayList stacks = new ArrayList<>(); if (!getStoredItemType().isEmpty()) { - if (!getStackInSlot(1).isEmpty()) { - stacks.add(getStackInSlot(1)); + if (!inventory.getStackInSlot(1).isEmpty()) { + stacks.add(inventory.getStackInSlot(1)); } int size = storedItem.getMaxStackSize(); for (int i = 0; i < getStoredCount() / size; i++) { @@ -140,25 +132,25 @@ public class TileTechStorageBase extends TileLegacyMachineBase super.update(); if (!world.isRemote) { ItemStack outputStack = ItemStack.EMPTY; - if (!getStackInSlot(1).isEmpty()) { - outputStack = getStackInSlot(1); + if (!inventory.getStackInSlot(1).isEmpty()) { + outputStack = inventory.getStackInSlot(1); } - if (!getStackInSlot(0).isEmpty() + if (!inventory.getStackInSlot(0).isEmpty() && (storedItem.getCount() + outputStack.getCount()) < maxCapacity) { - ItemStack inputStack = getStackInSlot(0); + ItemStack inputStack = inventory.getStackInSlot(0); if (getStoredItemType().isEmpty() || (storedItem.isEmpty() && ItemUtils.isItemEqual(inputStack, outputStack, true, true))) { storedItem = inputStack; - setInventorySlotContents(0, ItemStack.EMPTY); + inventory.setStackInSlot(0, ItemStack.EMPTY); } else if (ItemUtils.isItemEqual(getStoredItemType(), inputStack, true, true)) { int reminder = maxCapacity - storedItem.getCount() - outputStack.getCount(); if (inputStack.getCount() <= reminder) { setStoredItemCount(inputStack.getCount()); - setInventorySlotContents(0, ItemStack.EMPTY); + inventory.setStackInSlot(0, ItemStack.EMPTY); } else { setStoredItemCount(maxCapacity - outputStack.getCount()); - getStackInSlot(0).shrink(reminder); + inventory.getStackInSlot(0).shrink(reminder); } } markDirty(); @@ -176,7 +168,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase storedItem = ItemStack.EMPTY; } - setInventorySlotContents(1, delivered); + inventory.setStackInSlot(1, delivered); markDirty(); syncWithAll(); } else if (ItemUtils.isItemEqual(storedItem, outputStack, true, true) @@ -224,7 +216,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase @Override public T getCapability(Capability capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { - return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getInvWrapper()); + return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inventory); } return super.getCapability(capability, facing); } @@ -234,7 +226,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } - // IInventoryProvider + // ItemHandlerProvider @Override public Inventory getInventory() { return inventory; @@ -256,16 +248,16 @@ public class TileTechStorageBase extends TileLegacyMachineBase name = storedItem.getDisplayName(); size += storedItem.getCount(); } - if (!getStackInSlot(1).isEmpty()) { - name = getStackInSlot(1).getDisplayName(); - size += getStackInSlot(1).getCount(); + if (!inventory.getStackInSlot(1).isEmpty()) { + name = inventory.getStackInSlot(1).getDisplayName(); + size += inventory.getStackInSlot(1).getCount(); } info.add(size + " " + name); } } public ItemStack getStoredItemType() { - return storedItem.isEmpty() ? getStackInSlot(1) : storedItem; + return storedItem.isEmpty() ? inventory.getStackInSlot(1) : storedItem; } diff --git a/src/main/java/techreborn/tiles/fusionReactor/TileFusionControlComputer.java b/src/main/java/techreborn/tiles/fusionReactor/TileFusionControlComputer.java index 5c0b865be..5afdd1282 100644 --- a/src/main/java/techreborn/tiles/fusionReactor/TileFusionControlComputer.java +++ b/src/main/java/techreborn/tiles/fusionReactor/TileFusionControlComputer.java @@ -30,7 +30,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.RebornCoreConfig; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; @@ -50,7 +50,7 @@ import java.util.List; @RebornRegistry(modID = ModInfo.MOD_ID) public class TileFusionControlComputer extends TilePowerAcceptor - implements IToolDrop, IInventoryProvider, IContainerProvider { + implements IToolDrop, ItemHandlerProvider, IContainerProvider { @ConfigRegistry(config = "machines", category = "fusion_reactor", key = "FusionReactorMaxInput", comment = "Fusion Reactor Max Input (Value in EU)") public static int maxInput = 8192; @@ -180,7 +180,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor * @return boolean True if reactor can execute recipe provided */ private boolean validateReactorRecipe(FusionReactorRecipe recipe) { - return validateReactorRecipeInputs(recipe, getStackInSlot(topStackSlot), getStackInSlot(bottomStackSlot)) || validateReactorRecipeInputs(recipe, getStackInSlot(bottomStackSlot), getStackInSlot(topStackSlot)); + return validateReactorRecipeInputs(recipe, inventory.getStackInSlot(topStackSlot), inventory.getStackInSlot(bottomStackSlot)) || validateReactorRecipeInputs(recipe, inventory.getStackInSlot(bottomStackSlot), inventory.getStackInSlot(topStackSlot)); } private boolean validateReactorRecipeInputs(FusionReactorRecipe recipe, ItemStack slot1, ItemStack slot2) { @@ -209,7 +209,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor // Force check every second if (world.getTotalWorldTime() % 20 == 0) { checkCoils(); - inventory.hasChanged = true; + inventory.setChanged(); } if (coilCount == 0) { @@ -217,12 +217,12 @@ public class TileFusionControlComputer extends TilePowerAcceptor return; } - if (currentRecipe == null && inventory.hasChanged == true) { + if (currentRecipe == null && inventory.hasChanged()) { updateCurrentRecipe(); } if (currentRecipe != null) { - if (!hasStartedCrafting && inventory.hasChanged && !validateReactorRecipe(currentRecipe)) { + if (!hasStartedCrafting && inventory.hasChanged() && !validateReactorRecipe(currentRecipe)) { resetCrafter(); return; } @@ -232,9 +232,9 @@ public class TileFusionControlComputer extends TilePowerAcceptor if (canUseEnergy(currentRecipe.getStartEU())) { useEnergy(currentRecipe.getStartEU()); hasStartedCrafting = true; - decrStackSize(topStackSlot, currentRecipe.getTopInput().getCount()); + inventory.shrinkSlot(topStackSlot, currentRecipe.getTopInput().getCount()); if (!currentRecipe.getBottomInput().isEmpty()) { - decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().getCount()); + inventory.shrinkSlot(bottomStackSlot, currentRecipe.getBottomInput().getCount()); } } } @@ -252,16 +252,16 @@ public class TileFusionControlComputer extends TilePowerAcceptor } } else if (crafingTickTime >= finalTickTime) { if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) { - if (getStackInSlot(outputStackSlot).isEmpty()) { - setInventorySlotContents(outputStackSlot, currentRecipe.getOutput().copy()); + if (inventory.getStackInSlot(outputStackSlot).isEmpty()) { + inventory.setStackInSlot(outputStackSlot, currentRecipe.getOutput().copy()); } else { - decrStackSize(outputStackSlot, -currentRecipe.getOutput().getCount()); + inventory.shrinkSlot(outputStackSlot, -currentRecipe.getOutput().getCount()); } if (validateReactorRecipe(this.currentRecipe)) { crafingTickTime = 0; - decrStackSize(topStackSlot, currentRecipe.getTopInput().getCount()); + inventory.shrinkSlot(topStackSlot, currentRecipe.getTopInput().getCount()); if (!currentRecipe.getBottomInput().isEmpty()) { - decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().getCount()); + inventory.shrinkSlot(bottomStackSlot, currentRecipe.getBottomInput().getCount()); } } else { resetCrafter(); @@ -271,9 +271,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor markDirty(); } - if (inventory.hasChanged) { - inventory.hasChanged = false; - } + inventory.resetChanged(); } @@ -364,7 +362,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor return new ItemStack(ModBlocks.FUSION_CONTROL_COMPUTER, 1); } - // IInventoryProvider + // ItemHandlerProvider @Override public Inventory getInventory() { return inventory; diff --git a/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java b/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java index 52c536354..6b5a8c031 100644 --- a/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java +++ b/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java @@ -28,7 +28,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraftforge.fluids.FluidStack; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.FluidUtils; @@ -41,7 +41,7 @@ import techreborn.api.generator.GeneratorRecipeHelper; import javax.annotation.Nullable; -public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implements IToolDrop, IInventoryProvider { +public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implements IToolDrop, ItemHandlerProvider { private final FluidGeneratorRecipeList recipes; private final int euTick; @@ -135,8 +135,8 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement } protected boolean acceptFluid() { - if (!getStackInSlot(0).isEmpty()) { - FluidStack stack = FluidUtils.getFluidStackInContainer(getStackInSlot(0)); + if (!inventory.getStackInSlot(0).isEmpty()) { + FluidStack stack = FluidUtils.getFluidStackInContainer(inventory.getStackInSlot(0)); if (stack != null) return recipes.getRecipeForFluid(stack.getFluid()).isPresent(); } diff --git a/src/main/java/techreborn/tiles/generator/TileDragonEggSyphon.java b/src/main/java/techreborn/tiles/generator/TileDragonEggSyphon.java index 11a9099d9..64e728a8f 100644 --- a/src/main/java/techreborn/tiles/generator/TileDragonEggSyphon.java +++ b/src/main/java/techreborn/tiles/generator/TileDragonEggSyphon.java @@ -30,7 +30,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; @@ -41,7 +41,7 @@ import techreborn.lib.ModInfo; @RebornRegistry(modID = ModInfo.MOD_ID) public class TileDragonEggSyphon extends TilePowerAcceptor - implements IToolDrop, IInventoryProvider { + implements IToolDrop, ItemHandlerProvider { @ConfigRegistry(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxOutput", comment = "Dragon Egg Siphoner Max Output (Value in EU)") public static int maxOutput = 128; @@ -119,7 +119,7 @@ public class TileDragonEggSyphon extends TilePowerAcceptor return new ItemStack(ModBlocks.DRAGON_EGG_SYPHON, 1); } - // IInventoryProvider + // ItemHandlerProvider @Override public Inventory getInventory() { return inventory; diff --git a/src/main/java/techreborn/tiles/generator/TileSolidFuelGenerator.java b/src/main/java/techreborn/tiles/generator/TileSolidFuelGenerator.java index 1a8ab2272..f57b62116 100644 --- a/src/main/java/techreborn/tiles/generator/TileSolidFuelGenerator.java +++ b/src/main/java/techreborn/tiles/generator/TileSolidFuelGenerator.java @@ -32,7 +32,7 @@ import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.ForgeModContainer; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; @@ -45,7 +45,7 @@ import techreborn.init.ModBlocks; import techreborn.lib.ModInfo; @RebornRegistry(modID = ModInfo.MOD_ID) -public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDrop, IInventoryProvider, IContainerProvider { +public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDrop, ItemHandlerProvider, IContainerProvider { @ConfigRegistry(config = "generators", category = "generator", key = "GeneratorMaxOutput", comment = "Solid Fuel Generator Max Output (Value in EU)") public static int maxOutput = 32; @@ -90,19 +90,19 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr if (burnTime == 0) { updateState(); - burnTime = totalBurnTime = TileSolidFuelGenerator.getItemBurnTime(getStackInSlot(fuelSlot)); + burnTime = totalBurnTime = TileSolidFuelGenerator.getItemBurnTime(inventory.getStackInSlot(fuelSlot)); if (burnTime > 0) { updateState(); - burnItem = getStackInSlot(fuelSlot); - if (getStackInSlot(fuelSlot).getCount() == 1) { - if (getStackInSlot(fuelSlot).getItem() == Items.LAVA_BUCKET || getStackInSlot(fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket) { - setInventorySlotContents(fuelSlot, new ItemStack(Items.BUCKET)); + burnItem = inventory.getStackInSlot(fuelSlot); + if (inventory.getStackInSlot(fuelSlot).getCount() == 1) { + if (inventory.getStackInSlot(fuelSlot).getItem() == Items.LAVA_BUCKET || inventory.getStackInSlot(fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket) { + inventory.setStackInSlot(fuelSlot, new ItemStack(Items.BUCKET)); } else { - setInventorySlotContents(fuelSlot, ItemStack.EMPTY); + inventory.setStackInSlot(fuelSlot, ItemStack.EMPTY); } } else { - decrStackSize(fuelSlot, 1); + inventory.shrinkSlot(fuelSlot, 1); } } } diff --git a/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java b/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java index de4b55aab..8e1b4fa85 100644 --- a/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java +++ b/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java @@ -32,7 +32,7 @@ import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; import reborncore.api.IToolDrop; import reborncore.api.power.EnumPowerTier; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.RebornCoreConfig; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.Inventory; @@ -42,7 +42,7 @@ import techreborn.blocks.storage.BlockEnergyStorage; * Created by Rushmead */ public class TileEnergyStorage extends TilePowerAcceptor - implements IToolDrop, IInventoryProvider { + implements IToolDrop, ItemHandlerProvider { public Inventory inventory; public String name; @@ -139,7 +139,7 @@ public class TileEnergyStorage extends TilePowerAcceptor return new ItemStack(wrenchDrop); } - // IInventoryProvider + // ItemHandlerProvider @Override public Inventory getInventory() { return inventory; diff --git a/src/main/java/techreborn/tiles/tier0/TileIronAlloyFurnace.java b/src/main/java/techreborn/tiles/tier0/TileIronAlloyFurnace.java index 29f1bdbfe..33a1836d3 100644 --- a/src/main/java/techreborn/tiles/tier0/TileIronAlloyFurnace.java +++ b/src/main/java/techreborn/tiles/tier0/TileIronAlloyFurnace.java @@ -34,7 +34,7 @@ import net.minecraft.util.EnumFacing; import reborncore.api.IToolDrop; import reborncore.api.recipe.IBaseRecipeType; import reborncore.api.recipe.RecipeHandler; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.recipes.RecipeTranslator; import reborncore.common.registration.RebornRegistry; import reborncore.common.tile.TileLegacyMachineBase; @@ -50,7 +50,7 @@ import techreborn.lib.ModInfo; @RebornRegistry(modID = ModInfo.MOD_ID) public class TileIronAlloyFurnace extends TileLegacyMachineBase - implements IToolDrop, IInventoryProvider, IContainerProvider { + implements IToolDrop, ItemHandlerProvider, IContainerProvider { public int tickTime; public Inventory inventory = new Inventory(4, "TileIronAlloyFurnace", 64, this); @@ -136,13 +136,13 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase --this.burnTime; } if (!this.world.isRemote) { - if (this.burnTime != 0 || !this.getStackInSlot(this.input1).isEmpty()&& !this.getStackInSlot(this.fuel).isEmpty()) { + if (this.burnTime != 0 || !inventory.getStackInSlot(this.input1).isEmpty()&& !inventory.getStackInSlot(this.fuel).isEmpty()) { if (this.burnTime == 0 && this.canSmelt()) { - this.currentItemBurnTime = this.burnTime = TileIronAlloyFurnace.getItemBurnTime(this.getStackInSlot(this.fuel)); + this.currentItemBurnTime = this.burnTime = TileIronAlloyFurnace.getItemBurnTime(inventory.getStackInSlot(this.fuel)); if (this.burnTime > 0) { flag1 = true; - if (!this.getStackInSlot(this.fuel).isEmpty()) { - this.decrStackSize(this.fuel, 1); + if (!inventory.getStackInSlot(this.fuel).isEmpty()) { + inventory.shrinkSlot(this.fuel, 1); } } } @@ -191,7 +191,7 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase } private boolean canSmelt() { - if (this.getStackInSlot(this.input1).isEmpty() || this.getStackInSlot(this.input2).isEmpty()) { + if (inventory.getStackInSlot(this.input1).isEmpty() || inventory.getStackInSlot(this.input2).isEmpty()) { return false; } else { ItemStack itemstack = null; @@ -204,12 +204,12 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase if (itemstack == null) return false; - if (this.getStackInSlot(this.output).isEmpty()) + if (inventory.getStackInSlot(this.output).isEmpty()) return true; - if (!this.getStackInSlot(this.output).isItemEqual(itemstack)) + if (!inventory.getStackInSlot(this.output).isItemEqual(itemstack)) return false; - final int result = this.getStackInSlot(this.output).getCount() + itemstack.getCount(); - return result <= this.getInventoryStackLimit() && result <= this.getStackInSlot(this.output).getMaxStackSize(); // Forge + final int result = inventory.getStackInSlot(this.output).getCount() + itemstack.getCount(); + return result <= inventory.getStackLimit() && result <= inventory.getStackInSlot(this.output).getMaxStackSize(); // Forge // BugFix: // Make // it @@ -237,10 +237,10 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase } } - if (this.getStackInSlot(this.output).isEmpty()) { - this.setInventorySlotContents(this.output, itemstack.copy()); - } else if (this.getStackInSlot(this.output).getItem() == itemstack.getItem()) { - this.decrStackSize(this.output, -itemstack.getCount()); + if (inventory.getStackInSlot(this.output).isEmpty()) { + inventory.setStackInSlot(this.output, itemstack.copy()); + } else if (inventory.getStackInSlot(this.output).getItem() == itemstack.getItem()) { + inventory.shrinkSlot(this.output, -itemstack.getCount()); } for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.ALLOY_SMELTER_RECIPE)) { @@ -259,7 +259,7 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase if (input instanceof ItemStack) { count = RecipeTranslator.getStackFromObject(input).getCount(); } - inventory.decrStackSize(inputSlot, count); + inventory.shrinkSlot(inputSlot, count); break; } } diff --git a/src/main/java/techreborn/tiles/tier0/TileIronFurnace.java b/src/main/java/techreborn/tiles/tier0/TileIronFurnace.java index 8bdba0f36..ad27fa468 100644 --- a/src/main/java/techreborn/tiles/tier0/TileIronFurnace.java +++ b/src/main/java/techreborn/tiles/tier0/TileIronFurnace.java @@ -29,7 +29,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.tileentity.TileEntityFurnace; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.tile.TileLegacyMachineBase; import reborncore.common.util.Inventory; @@ -39,7 +39,7 @@ import techreborn.client.container.builder.BuiltContainer; import techreborn.client.container.builder.ContainerBuilder; public class TileIronFurnace extends TileLegacyMachineBase - implements IInventoryProvider, IContainerProvider { + implements ItemHandlerProvider, IContainerProvider { public int tickTime; public Inventory inventory = new Inventory(3, "TileIronFurnace", 64, this); @@ -79,16 +79,16 @@ public class TileIronFurnace extends TileLegacyMachineBase this.updateState(); } if (this.fuel <= 0 && this.canSmelt()) { - this.fuel = this.fuelGague = (int) (TileEntityFurnace.getItemBurnTime(this.getStackInSlot(this.fuelslot)) * 1.25); + this.fuel = this.fuelGague = (int) (TileEntityFurnace.getItemBurnTime(inventory.getStackInSlot(this.fuelslot)) * 1.25); if (this.fuel > 0) { // Fuel slot - ItemStack fuelStack = this.getStackInSlot(this.fuelslot); + ItemStack fuelStack = inventory.getStackInSlot(this.fuelslot); if (fuelStack.getItem().hasContainerItem(fuelStack)) { - this.setInventorySlotContents(this.fuelslot, new ItemStack(fuelStack.getItem().getContainerItem())); + inventory.setStackInSlot(this.fuelslot, new ItemStack(fuelStack.getItem().getContainerItem())); } else if (fuelStack.getCount() > 1) { - this.decrStackSize(this.fuelslot, 1); + inventory.shrinkSlot(this.fuelslot, 1); } else if (fuelStack.getCount() == 1) { - this.setInventorySlotContents(this.fuelslot, ItemStack.EMPTY); + inventory.setStackInSlot(this.fuelslot, ItemStack.EMPTY); } updateInventory = true; } @@ -113,33 +113,33 @@ public class TileIronFurnace extends TileLegacyMachineBase public void cookItems() { if (this.canSmelt()) { - final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1)); + final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(inventory.getStackInSlot(this.input1)); - if (this.getStackInSlot(this.output).isEmpty()) { - this.setInventorySlotContents(this.output, itemstack.copy()); - } else if (this.getStackInSlot(this.output).isItemEqual(itemstack)) { - this.getStackInSlot(this.output).grow(itemstack.getCount()); + if (inventory.getStackInSlot(this.output).isEmpty()) { + inventory.setStackInSlot(this.output, itemstack.copy()); + } else if (inventory.getStackInSlot(this.output).isItemEqual(itemstack)) { + inventory.getStackInSlot(this.output).grow(itemstack.getCount()); } - if (this.getStackInSlot(this.input1).getCount() > 1) { - this.decrStackSize(this.input1, 1); + if (inventory.getStackInSlot(this.input1).getCount() > 1) { + inventory.shrinkSlot(this.input1, 1); } else { - this.setInventorySlotContents(this.input1, ItemStack.EMPTY); + inventory.setStackInSlot(this.input1, ItemStack.EMPTY); } } } public boolean canSmelt() { - if (this.getStackInSlot(this.input1).isEmpty()) + if (inventory.getStackInSlot(this.input1).isEmpty()) return false; - final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1)); + final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(inventory.getStackInSlot(this.input1)); if (itemstack.isEmpty()) return false; - if (this.getStackInSlot(this.output).isEmpty()) + if (inventory.getStackInSlot(this.output).isEmpty()) return true; - if (!this.getStackInSlot(this.output).isItemEqual(itemstack)) + if (!inventory.getStackInSlot(this.output).isItemEqual(itemstack)) return false; - final int result = this.getStackInSlot(this.output).getCount() + itemstack.getCount(); - return result <= this.getInventoryStackLimit() && result <= itemstack.getMaxStackSize(); + final int result = inventory.getStackInSlot(this.output).getCount() + itemstack.getCount(); + return result <= inventory.getStackLimit() && result <= itemstack.getMaxStackSize(); } public boolean isBurning() { @@ -172,7 +172,7 @@ public class TileIronFurnace extends TileLegacyMachineBase public boolean isItemValidForSlot(int index, ItemStack stack) { boolean isFuel = TileEntityFurnace.isItemFuel(stack); if(isFuel){ - ItemStack fuelSlotStack = getStackInSlot(fuelslot); + ItemStack fuelSlotStack = inventory.getStackInSlot(fuelslot); if(fuelSlotStack.isEmpty() || ItemUtils.isItemEqual(stack, fuelSlotStack, true, true) && fuelSlotStack.getMaxStackSize() != fuelSlotStack.getCount()){ return index == fuelslot; } diff --git a/src/main/java/techreborn/tiles/tier1/TileAutoCraftingTable.java b/src/main/java/techreborn/tiles/tier1/TileAutoCraftingTable.java index 3f32b95cf..86c37d432 100644 --- a/src/main/java/techreborn/tiles/tier1/TileAutoCraftingTable.java +++ b/src/main/java/techreborn/tiles/tier1/TileAutoCraftingTable.java @@ -26,7 +26,6 @@ package techreborn.tiles.tier1; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; @@ -35,9 +34,10 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.SoundCategory; +import net.minecraftforge.items.IItemHandler; import org.apache.commons.lang3.tuple.Pair; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.impl.ConfigRegistry; @@ -59,7 +59,7 @@ import java.util.List; */ @RebornRegistry(modID = ModInfo.MOD_ID) public class TileAutoCraftingTable extends TilePowerAcceptor - implements IToolDrop, IInventoryProvider, IContainerProvider { + implements IToolDrop, ItemHandlerProvider, IContainerProvider { @ConfigRegistry(config = "machines", category = "autocrafter", key = "AutoCrafterInput", comment = "AutoCrafting Table Max Input (Value in EU)") public static int maxInput = 32; @@ -160,7 +160,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor } boolean hasRoomForExtraItem(ItemStack stack) { - ItemStack extraOutputSlot = getStackInSlot(10); + ItemStack extraOutputSlot = inventory.getStackInSlot(10); if (extraOutputSlot.isEmpty()) { return true; } @@ -208,7 +208,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor // TODO fire forge recipe event ItemStack ouputStack = recipe.getCraftingResult(getCraftingInventory()); if (output.isEmpty()) { - inventory.setInventorySlotContents(9, ouputStack.copy()); + inventory.setStackInSlot(9, ouputStack.copy()); } else { // TODO use ouputStack in someway? output.grow(recipe.getRecipeOutput().getCount()); @@ -219,10 +219,10 @@ public class TileAutoCraftingTable extends TilePowerAcceptor private void handleContainerItem(ItemStack stack) { if (stack.getItem().hasContainerItem(stack)) { ItemStack containerItem = stack.getItem().getContainerItem(stack); - ItemStack extraOutputSlot = getStackInSlot(10); + ItemStack extraOutputSlot = inventory.getStackInSlot(10); if (hasOutputSpace(containerItem, 10)) { if (extraOutputSlot.isEmpty()) { - setInventorySlotContents(10, containerItem.copy()); + inventory.setStackInSlot(10, containerItem.copy()); } else if (ItemUtils.isItemEqual(extraOutputSlot, containerItem, true, true) && extraOutputSlot.getMaxStackSize() < extraOutputSlot.getCount() + containerItem.getCount()) { extraOutputSlot.grow(1); @@ -442,9 +442,9 @@ public class TileAutoCraftingTable extends TilePowerAcceptor return new ItemStack(ModBlocks.AUTO_CRAFTING_TABLE, 1); } - // IInventoryProvider + // ItemHandlerProvider @Override - public IInventory getInventory() { + public IItemHandler getInventory() { return inventory; } diff --git a/src/main/java/techreborn/tiles/tier1/TileElectricFurnace.java b/src/main/java/techreborn/tiles/tier1/TileElectricFurnace.java index ea76f3d33..a34bc3747 100644 --- a/src/main/java/techreborn/tiles/tier1/TileElectricFurnace.java +++ b/src/main/java/techreborn/tiles/tier1/TileElectricFurnace.java @@ -30,7 +30,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.util.EnumFacing; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; @@ -44,7 +44,7 @@ import techreborn.lib.ModInfo; @RebornRegistry(modID = ModInfo.MOD_ID) public class TileElectricFurnace extends TilePowerAcceptor - implements IToolDrop, IInventoryProvider, IContainerProvider { + implements IToolDrop, ItemHandlerProvider, IContainerProvider { @ConfigRegistry(config = "machines", category = "electric_furnace", key = "ElectricFurnaceInput", comment = "Electric Furnace Max Input (Value in EU)") public static int maxInput = 32; @@ -69,37 +69,37 @@ public class TileElectricFurnace extends TilePowerAcceptor public void cookItems() { if (canSmelt()) { - final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1)); + final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(inventory.getStackInSlot(input1)); - if (getStackInSlot(output).isEmpty()) { - setInventorySlotContents(output, itemstack.copy()); - } else if (getStackInSlot(output).isItemEqual(itemstack)) { - getStackInSlot(output).grow(itemstack.getCount()); + if (inventory.getStackInSlot(output).isEmpty()) { + inventory.setStackInSlot(output, itemstack.copy()); + } else if (inventory.getStackInSlot(output).isItemEqual(itemstack)) { + inventory.getStackInSlot(output).grow(itemstack.getCount()); } - if (getStackInSlot(input1).getCount() > 1) { - decrStackSize(input1, 1); + if (inventory.getStackInSlot(input1).getCount() > 1) { + inventory.shrinkSlot(input1, 1); } else { - setInventorySlotContents(input1, ItemStack.EMPTY); + inventory.setStackInSlot(input1, ItemStack.EMPTY); } } } public boolean canSmelt() { - if (getStackInSlot(input1).isEmpty()) { + if (inventory.getStackInSlot(input1).isEmpty()) { return false; } - final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1)); + final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(inventory.getStackInSlot(input1)); if (itemstack.isEmpty()) { return false; } - if (getStackInSlot(output).isEmpty()) { + if (inventory.getStackInSlot(output).isEmpty()) { return true; } - if (!getStackInSlot(output).isItemEqual(itemstack)) { + if (!inventory.getStackInSlot(output).isItemEqual(itemstack)) { return false; } - final int result = getStackInSlot(output).getCount() + itemstack.getCount(); - return result <= this.getInventoryStackLimit() && result <= itemstack.getMaxStackSize(); + final int result = inventory.getStackInSlot(output).getCount() + itemstack.getCount(); + return result <= this.inventory.getStackLimit() && result <= itemstack.getMaxStackSize(); } public boolean isBurning() { @@ -207,7 +207,7 @@ public class TileElectricFurnace extends TilePowerAcceptor return new ItemStack(ModBlocks.ELECTRIC_FURNACE, 1); } - // IInventoryProvider + // ItemHandlerProvider @Override public Inventory getInventory() { return inventory; diff --git a/src/main/java/techreborn/tiles/tier1/TileRecycler.java b/src/main/java/techreborn/tiles/tier1/TileRecycler.java index 52453e40e..acfd333d2 100644 --- a/src/main/java/techreborn/tiles/tier1/TileRecycler.java +++ b/src/main/java/techreborn/tiles/tier1/TileRecycler.java @@ -29,7 +29,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; @@ -44,7 +44,7 @@ import techreborn.lib.ModInfo; @RebornRegistry(modID = ModInfo.MOD_ID) public class TileRecycler extends TilePowerAcceptor - implements IToolDrop, IInventoryProvider, IContainerProvider { + implements IToolDrop, ItemHandlerProvider, IContainerProvider { @ConfigRegistry(config = "machines", category = "recycler", key = "RecyclerInput", comment = "Recycler Max Input (Value in EU)") public static int maxInput = 32; @@ -79,24 +79,24 @@ public class TileRecycler extends TilePowerAcceptor final int randomchance = this.world.rand.nextInt(chance); if (randomchance == 1) { - if (getStackInSlot(1).isEmpty()) { - setInventorySlotContents(1, itemstack.copy()); + if (inventory.getStackInSlot(1).isEmpty()) { + inventory.setStackInSlot(1, itemstack.copy()); } else { - this.getStackInSlot(1).grow(itemstack.getCount()); + inventory.getStackInSlot(1).grow(itemstack.getCount()); } } - decrStackSize(0, 1); + inventory.shrinkSlot(0, 1); } public boolean canRecycle() { - return !getStackInSlot(0) .isEmpty() && hasSlotGotSpace(1); + return !inventory.getStackInSlot(0) .isEmpty() && hasSlotGotSpace(1); } public boolean hasSlotGotSpace(int slot) { - if (getStackInSlot(slot).isEmpty()) { + if (inventory.getStackInSlot(slot).isEmpty()) { return true; - } else if (getStackInSlot(slot).getCount() < getStackInSlot(slot).getMaxStackSize()) { + } else if (inventory.getStackInSlot(slot).getCount() < inventory.getStackInSlot(slot).getMaxStackSize()) { return true; } return false; @@ -191,7 +191,7 @@ public class TileRecycler extends TilePowerAcceptor return new ItemStack(ModBlocks.RECYCLER, 1); } - // IInventoryProvider + // ItemHandlerProvider @Override public Inventory getInventory() { return this.inventory; diff --git a/src/main/java/techreborn/tiles/tier1/TileRollingMachine.java b/src/main/java/techreborn/tiles/tier1/TileRollingMachine.java index aca4708a1..f656f2bb5 100644 --- a/src/main/java/techreborn/tiles/tier1/TileRollingMachine.java +++ b/src/main/java/techreborn/tiles/tier1/TileRollingMachine.java @@ -34,7 +34,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import org.apache.commons.lang3.tuple.Pair; import reborncore.api.IToolDrop; -import reborncore.api.tile.IInventoryProvider; +import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.impl.ConfigRegistry; @@ -56,7 +56,7 @@ import java.util.Optional; @RebornRegistry(modID = ModInfo.MOD_ID) public class TileRollingMachine extends TilePowerAcceptor - implements IToolDrop, IInventoryProvider, IContainerProvider { + implements IToolDrop, ItemHandlerProvider, IContainerProvider { @ConfigRegistry(config = "machines", category = "rolling_machine", key = "RollingMachineMaxInput", comment = "Rolling Machine Max Input (Value in EU)") public static int maxInput = 32; @@ -137,7 +137,7 @@ public class TileRollingMachine extends TilePowerAcceptor if (!currentRecipeOutput.isEmpty()) { boolean hasCrafted = false; if (inventory.getStackInSlot(outputSlot).isEmpty()) { - inventory.setInventorySlotContents(outputSlot, currentRecipeOutput); + inventory.setStackInSlot(outputSlot, currentRecipeOutput); tickTime = 0; hasCrafted = true; } else { @@ -145,14 +145,14 @@ public class TileRollingMachine extends TilePowerAcceptor + currentRecipeOutput.getCount() <= currentRecipeOutput.getMaxStackSize()) { final ItemStack stack = inventory.getStackInSlot(outputSlot); stack.setCount(stack.getCount() + currentRecipeOutput.getCount()); - inventory.setInventorySlotContents(outputSlot, stack); + inventory.setStackInSlot(outputSlot, stack); tickTime = 0; hasCrafted = true; } } if (hasCrafted) { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { - inventory.decrStackSize(i, 1); + inventory.shrinkSlot(i, 1); } currentRecipeOutput = ItemStack.EMPTY; currentRecipe = null; @@ -234,7 +234,7 @@ public class TileRollingMachine extends TilePowerAcceptor } sourceStack.shrink(1); inventory.getStackInSlot(bestSlot.getLeft()).grow(1); - inventory.hasChanged = true; + inventory.setChanged(); return Optional.of(getCraftingMatrix()); } @@ -243,11 +243,11 @@ public class TileRollingMachine extends TilePowerAcceptor if (craftCache == null) { craftCache = new InventoryCrafting(new RollingTileContainer(), 3, 3); } - if (inventory.hasChanged) { + if (inventory.hasChanged()) { for (int i = 0; i < 9; i++) { craftCache.setInventorySlotContents(i, inventory.getStackInSlot(i).copy()); } - inventory.hasChanged = false; + inventory.resetChanged(); } return craftCache; } @@ -265,7 +265,7 @@ public class TileRollingMachine extends TilePowerAcceptor if (stack.isEmpty()) { return false; } - ItemStack output = getStackInSlot(outputSlot); + ItemStack output = inventory.getStackInSlot(outputSlot); if (output.isEmpty()) { return true; } @@ -322,7 +322,7 @@ public class TileRollingMachine extends TilePowerAcceptor .slot(0, 30, 22).slot(1, 48, 22).slot(2, 66, 22) .slot(3, 30, 40).slot(4, 48, 40).slot(5, 66, 40) .slot(6, 30, 58).slot(7, 48, 58).slot(8, 66, 58) - .onCraft(inv -> this.inventory.setInventorySlotContents(1, RollingMachineRecipe.instance.findMatchingRecipeOutput(getCraftingMatrix(), this.world))) + .onCraft(inv -> this.inventory.setStackInSlot(1, RollingMachineRecipe.instance.findMatchingRecipeOutput(getCraftingMatrix(), this.world))) .outputSlot(9, 124, 40) .energySlot(10, 8, 70) .syncEnergyValue().syncIntegerValue(this::getBurnTime, this::setBurnTime).syncIntegerValue(this::getLockedInt, this::setLockedInt).addInventory().create(this);