IInventory > IItemHandler
Most things should work, but havent been tested Slot config will not work just yet
This commit is contained in:
parent
8cac9a9315
commit
3444c05c40
32 changed files with 241 additions and 213 deletions
|
@ -181,7 +181,7 @@ public class FluidReplicatorRecipeCrafter extends RecipeCrafter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasAllInputs(currentRecipe)) {
|
if (hasAllInputs(currentRecipe)) {
|
||||||
inventory.decrStackSize(inputSlots[0], currentRecipe.getInput());
|
inventory.shrinkSlot(inputSlots[0], currentRecipe.getInput());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
package techreborn.client.container;
|
package techreborn.client.container;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import reborncore.client.gui.slots.BaseSlot;
|
|
||||||
import reborncore.client.gui.slots.SlotFilteredVoid;
|
import reborncore.client.gui.slots.SlotFilteredVoid;
|
||||||
import reborncore.common.container.RebornContainer;
|
import reborncore.common.container.RebornContainer;
|
||||||
import reborncore.common.util.Inventory;
|
import reborncore.common.util.Inventory;
|
||||||
|
@ -56,12 +56,12 @@ public class ContainerDestructoPack extends RebornContainer {
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
for (int j = 0; j < 9; ++j) {
|
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) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class BuiltContainer extends Container {
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(final EntityPlayer playerIn) {
|
public boolean canInteractWith(final EntityPlayer playerIn) {
|
||||||
if(this.tile != null) {
|
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 {
|
} else {
|
||||||
return this.canInteract.test(playerIn); // <
|
return this.canInteract.test(playerIn); // <
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,13 @@ package techreborn.client.container.builder;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import org.apache.commons.lang3.Range;
|
import org.apache.commons.lang3.Range;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.tile.TileLegacyMachineBase;
|
import reborncore.common.tile.TileLegacyMachineBase;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -77,7 +79,7 @@ public class ContainerBuilder {
|
||||||
return new ContainerPlayerInventoryBuilder(this, player);
|
return new ContainerPlayerInventoryBuilder(this, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerTileInventoryBuilder tile(final IInventory tile) {
|
public ContainerTileInventoryBuilder tile(final TileLegacyMachineBase tile) {
|
||||||
return new ContainerTileInventoryBuilder(this, tile);
|
return new ContainerTileInventoryBuilder(this, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,9 @@ package techreborn.client.container.builder;
|
||||||
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||||
import org.apache.commons.lang3.Range;
|
import org.apache.commons.lang3.Range;
|
||||||
import reborncore.client.gui.slots.BaseSlot;
|
|
||||||
import techreborn.client.IconSupplier;
|
import techreborn.client.IconSupplier;
|
||||||
import techreborn.client.container.builder.slot.SpriteSlot;
|
import techreborn.client.container.builder.slot.SpriteSlot;
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ public final class ContainerPlayerInventoryBuilder {
|
||||||
final int startIndex = this.parent.slots.size();
|
final int startIndex = this.parent.slots.size();
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
for (int j = 0; j < 9; ++j)
|
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);
|
this.main = Range.between(startIndex, this.parent.slots.size() - 1);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +57,7 @@ public final class ContainerPlayerInventoryBuilder {
|
||||||
public ContainerPlayerInventoryBuilder hotbar(final int xStart, final int yStart) {
|
public ContainerPlayerInventoryBuilder hotbar(final int xStart, final int yStart) {
|
||||||
final int startIndex = this.parent.slots.size();
|
final int startIndex = this.parent.slots.size();
|
||||||
for (int i = 0; i < 9; ++i)
|
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);
|
this.hotbar = Range.between(startIndex, this.parent.slots.size() - 1);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +96,7 @@ public final class ContainerPlayerInventoryBuilder {
|
||||||
|
|
||||||
private ContainerPlayerArmorInventoryBuilder armor(final int index, final int xStart, final int yStart,
|
private ContainerPlayerArmorInventoryBuilder armor(final int index, final int xStart, final int yStart,
|
||||||
final EntityEquipmentSlot slotType, final String sprite) {
|
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)));
|
.setFilter(stack -> stack.getItem().isValidArmor(stack, slotType, this.parent.player.player)));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,14 @@
|
||||||
|
|
||||||
package techreborn.client.container.builder;
|
package techreborn.client.container.builder;
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
import net.minecraft.inventory.SlotFurnaceFuel;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import org.apache.commons.lang3.Range;
|
import org.apache.commons.lang3.Range;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||||
import reborncore.api.tile.IUpgradeable;
|
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.SlotFake;
|
||||||
import reborncore.client.gui.slots.SlotOutput;
|
import reborncore.client.gui.slots.SlotOutput;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
|
import reborncore.common.tile.TileLegacyMachineBase;
|
||||||
import techreborn.Core;
|
import techreborn.Core;
|
||||||
import techreborn.client.container.builder.slot.FilteredSlot;
|
import techreborn.client.container.builder.slot.FilteredSlot;
|
||||||
|
import techreborn.client.container.builder.slot.FurnaceFuelSlot;
|
||||||
import techreborn.client.container.builder.slot.UpgradeSlot;
|
import techreborn.client.container.builder.slot.UpgradeSlot;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -50,54 +52,56 @@ import java.util.function.Predicate;
|
||||||
|
|
||||||
public class ContainerTileInventoryBuilder {
|
public class ContainerTileInventoryBuilder {
|
||||||
|
|
||||||
private final IInventory tile;
|
private final TileLegacyMachineBase tile;
|
||||||
private final ContainerBuilder parent;
|
private final ContainerBuilder parent;
|
||||||
private final int rangeStart;
|
private final int rangeStart;
|
||||||
|
|
||||||
ContainerTileInventoryBuilder(final ContainerBuilder parent, final IInventory tile) {
|
ContainerTileInventoryBuilder(final ContainerBuilder parent, final TileLegacyMachineBase tile) {
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.rangeStart = parent.slots.size();
|
this.rangeStart = parent.slots.size();
|
||||||
if (tile instanceof IUpgradeable) {
|
//Ensure that the tile has an inv
|
||||||
upgradeSlots((IUpgradeable) tile);
|
Validate.isTrue(tile.getInventoryForTile().isPresent());
|
||||||
|
if (tile.canBeUpgraded()) {
|
||||||
|
upgradeSlots(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerTileInventoryBuilder slot(final int index, final int x, final int y) {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerTileInventoryBuilder outputSlot(final int index, final int x, final int y) {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerTileInventoryBuilder fakeSlot(final int index, final int x, final int y) {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerTileInventoryBuilder filterSlot(final int index, final int x, final int y,
|
public ContainerTileInventoryBuilder filterSlot(final int index, final int x, final int y,
|
||||||
final Predicate<ItemStack> filter) {
|
final Predicate<ItemStack> 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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerTileInventoryBuilder energySlot(final int index, final int x, final int y) {
|
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)));
|
.setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP)));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerTileInventoryBuilder fluidSlot(final int index, final int x, final int y) {
|
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)));
|
stack -> stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.UP)));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerTileInventoryBuilder fuelSlot(final int index, final int x, final int y) {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,22 +24,22 @@
|
||||||
|
|
||||||
package techreborn.client.container.builder.slot;
|
package techreborn.client.container.builder.slot;
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import reborncore.client.gui.slots.BaseSlot;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class FilteredSlot extends Slot {
|
public class FilteredSlot extends BaseSlot {
|
||||||
|
|
||||||
private Predicate<ItemStack> filter;
|
private Predicate<ItemStack> filter;
|
||||||
private int stackLimit = 64;
|
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);
|
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);
|
super(inventory, index, xPosition, yPosition);
|
||||||
this.stackLimit = stackLimit;
|
this.stackLimit = stackLimit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,9 +24,9 @@
|
||||||
|
|
||||||
package techreborn.client.container.builder.slot;
|
package techreborn.client.container.builder.slot;
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -35,13 +35,13 @@ public class SpriteSlot extends FilteredSlot {
|
||||||
private final String spriteName;
|
private final String spriteName;
|
||||||
int stacksize;
|
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);
|
super(inventory, index, xPosition, yPosition);
|
||||||
this.spriteName = sprite;
|
this.spriteName = sprite;
|
||||||
this.stacksize = stacksize;
|
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);
|
this(inventory, index, xPosition, yPosition, sprite, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,19 +25,19 @@
|
||||||
package techreborn.client.container.builder.slot;
|
package techreborn.client.container.builder.slot;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import reborncore.api.tile.IUpgrade;
|
import reborncore.api.tile.IUpgrade;
|
||||||
import reborncore.api.tile.IUpgradeable;
|
import reborncore.api.tile.IUpgradeable;
|
||||||
|
import reborncore.client.gui.slots.BaseSlot;
|
||||||
import reborncore.common.util.Inventory;
|
import reborncore.common.util.Inventory;
|
||||||
import techreborn.client.container.IRightClickHandler;
|
import techreborn.client.container.IRightClickHandler;
|
||||||
import techreborn.client.container.builder.BuiltContainer;
|
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);
|
super(inventory, index, xPosition, yPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,13 +50,13 @@ public class GuiDigitalChest extends GuiBase {
|
||||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
final Layer layer = Layer.FOREGROUND;
|
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.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);
|
this.digitalChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
|
||||||
}
|
}
|
||||||
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.getStackInSlot(1).getCount(),
|
this.builder.drawBigBlueBar(this, 31, 43, this.digitalChest.inventory.getStackInSlot(1).getCount(),
|
||||||
this.digitalChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
|
this.digitalChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,11 +50,11 @@ public class GuiQuantumChest extends GuiBase {
|
||||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
final Layer layer = Layer.FOREGROUND;
|
final Layer layer = Layer.FOREGROUND;
|
||||||
|
|
||||||
if (!this.quantumChest.storedItem.isEmpty() && this.quantumChest.getStackInSlot(1) != null) {
|
if (!this.quantumChest.storedItem.isEmpty() && !this.quantumChest.inventory.getStackInSlot(1).isEmpty()) {
|
||||||
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);
|
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) {
|
if (this.quantumChest.storedItem.isEmpty() && !this.quantumChest.inventory.getStackInSlot(1).isEmpty()) {
|
||||||
this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
|
this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.inventory.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class GuiSlotConfiguration {
|
||||||
if (guiBase.tile != slot.inventory) {
|
if (guiBase.tile != slot.inventory) {
|
||||||
continue;
|
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);
|
slotElementMap.put(slot.getSlotIndex(), slotElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
import net.minecraft.client.renderer.RenderItem;
|
import net.minecraft.client.renderer.RenderItem;
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import techreborn.client.gui.GuiBase;
|
import techreborn.client.gui.GuiBase;
|
||||||
|
@ -41,13 +41,13 @@ import java.util.List;
|
||||||
|
|
||||||
public class ConfigSlotElement extends ElementBase {
|
public class ConfigSlotElement extends ElementBase {
|
||||||
SlotType type;
|
SlotType type;
|
||||||
IInventory inventory;
|
IItemHandler inventory;
|
||||||
int id;
|
int id;
|
||||||
public List<ElementBase> elements = new ArrayList<>();
|
public List<ElementBase> elements = new ArrayList<>();
|
||||||
boolean filter = false;
|
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());
|
super(x, y, type.getButtonSprite());
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.inventory = slotInventory;
|
this.inventory = slotInventory;
|
||||||
|
|
|
@ -30,7 +30,7 @@ import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.RebornCoreConfig;
|
import reborncore.common.RebornCoreConfig;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
|
@ -44,7 +44,7 @@ import techreborn.lib.ModInfo;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class TileChargeOMat extends TilePowerAcceptor
|
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)")
|
@ConfigRegistry(config = "machines", category = "charge_bench", key = "ChargeBenchMaxInput", comment = "Charge Bench Max Input (Value in EU)")
|
||||||
public static int maxInput = 512;
|
public static int maxInput = 512;
|
||||||
|
@ -117,7 +117,7 @@ public class TileChargeOMat extends TilePowerAcceptor
|
||||||
return new ItemStack(ModBlocks.CHARGE_O_MAT, 1);
|
return new ItemStack(ModBlocks.CHARGE_O_MAT, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
|
|
|
@ -28,7 +28,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
import reborncore.common.registration.impl.ConfigRegistry;
|
import reborncore.common.registration.impl.ConfigRegistry;
|
||||||
|
@ -40,7 +40,7 @@ import techreborn.init.ModBlocks;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@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)")
|
@ConfigRegistry(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxInput", comment = "Chunk Loader Max Input (Value in EU)")
|
||||||
public static int maxInput = 32;
|
public static int maxInput = 32;
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class TileCreativeQuantumChest extends TileQuantumChest {
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
ItemStack stack = getStackInSlot(1);
|
ItemStack stack = inventory.getStackInSlot(1);
|
||||||
if (!stack.isEmpty() && storedItem.isEmpty()) {
|
if (!stack.isEmpty() && storedItem.isEmpty()) {
|
||||||
stack.setCount(stack.getMaxStackSize());
|
stack.setCount(stack.getMaxStackSize());
|
||||||
storedItem = stack.copy();
|
storedItem = stack.copy();
|
||||||
|
|
|
@ -30,7 +30,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.Inventory;
|
import reborncore.common.util.Inventory;
|
||||||
|
@ -40,7 +40,7 @@ import reborncore.common.util.Inventory;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class TileGenericMachine extends TilePowerAcceptor
|
public abstract class TileGenericMachine extends TilePowerAcceptor
|
||||||
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider{
|
implements IToolDrop, ItemHandlerProvider, IRecipeCrafterProvider{
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public int maxInput;
|
public int maxInput;
|
||||||
|
@ -113,7 +113,7 @@ public abstract class TileGenericMachine extends TilePowerAcceptor
|
||||||
return new ItemStack(toolDrop, 1);
|
return new ItemStack(toolDrop, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
|
|
|
@ -28,7 +28,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
import reborncore.common.registration.impl.ConfigRegistry;
|
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.BuiltContainer;
|
||||||
import techreborn.client.container.builder.ContainerBuilder;
|
import techreborn.client.container.builder.ContainerBuilder;
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
import techreborn.init.TRItems;
|
|
||||||
import techreborn.init.TRIngredients;
|
import techreborn.init.TRIngredients;
|
||||||
|
import techreborn.init.TRItems;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class TileMatterFabricator extends TilePowerAcceptor
|
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)")
|
@ConfigRegistry(config = "machines", category = "matter_fabricator", key = "MatterFabricatorMaxInput", comment = "Matter Fabricator Max Input (Value in EU)")
|
||||||
public static int maxInput = 8192;
|
public static int maxInput = 8192;
|
||||||
|
@ -88,7 +88,7 @@ public class TileMatterFabricator extends TilePowerAcceptor
|
||||||
|
|
||||||
private void addOutputProducts(int slot) {
|
private void addOutputProducts(int slot) {
|
||||||
if (inventory.getStackInSlot(slot).isEmpty()) {
|
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)) {
|
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())));
|
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)) {
|
if (amp != 0 && this.canUseEnergy(euNeeded)) {
|
||||||
useEnergy(euNeeded);
|
useEnergy(euNeeded);
|
||||||
amplifier += amp;
|
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);
|
return new ItemStack(ModBlocks.MATTER_FABRICATOR, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||||
import reborncore.api.IListInfoProvider;
|
import reborncore.api.IListInfoProvider;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
import reborncore.common.registration.impl.ConfigRegistry;
|
import reborncore.common.registration.impl.ConfigRegistry;
|
||||||
import reborncore.common.tile.TileLegacyMachineBase;
|
import reborncore.common.tile.TileLegacyMachineBase;
|
||||||
|
@ -49,7 +49,7 @@ import java.util.List;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class TileQuantumTank extends TileLegacyMachineBase
|
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")
|
@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;
|
public static int maxStorage = Integer.MAX_VALUE;
|
||||||
|
@ -111,7 +111,7 @@ public class TileQuantumTank extends TileLegacyMachineBase
|
||||||
readFromNBT(packet.getNbtCompound());
|
readFromNBT(packet.getNbtCompound());
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return this.inventory;
|
return this.inventory;
|
||||||
|
|
|
@ -32,10 +32,9 @@ import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
|
||||||
import reborncore.api.IListInfoProvider;
|
import reborncore.api.IListInfoProvider;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.tile.TileLegacyMachineBase;
|
import reborncore.common.tile.TileLegacyMachineBase;
|
||||||
import reborncore.common.util.Inventory;
|
import reborncore.common.util.Inventory;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
|
@ -45,11 +44,10 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileTechStorageBase extends TileLegacyMachineBase
|
public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
implements IInventoryProvider, IToolDrop, IListInfoProvider {
|
implements ItemHandlerProvider, IToolDrop, IListInfoProvider {
|
||||||
|
|
||||||
public final int maxCapacity;
|
public final int maxCapacity;
|
||||||
public final Inventory inventory;
|
public final Inventory inventory;
|
||||||
public InvWrapper invWrapper;
|
|
||||||
public ItemStack storedItem;
|
public ItemStack storedItem;
|
||||||
|
|
||||||
public TileTechStorageBase(String name, int maxCapacity) {
|
public TileTechStorageBase(String name, int maxCapacity) {
|
||||||
|
@ -95,18 +93,12 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
dropStack.setTagCompound(new NBTTagCompound());
|
dropStack.setTagCompound(new NBTTagCompound());
|
||||||
dropStack.getTagCompound().setTag("tileEntity", tileEntity);
|
dropStack.getTagCompound().setTag("tileEntity", tileEntity);
|
||||||
storedItem.setCount(0);
|
storedItem.setCount(0);
|
||||||
setInventorySlotContents(1, ItemStack.EMPTY);
|
inventory.setStackInSlot(1, ItemStack.EMPTY);
|
||||||
syncWithAll();
|
syncWithAll();
|
||||||
|
|
||||||
return dropStack;
|
return dropStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvWrapper getInvWrapper() {
|
|
||||||
if (invWrapper == null)
|
|
||||||
invWrapper = new InvWrapper(this);
|
|
||||||
return invWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStoredCount() {
|
public int getStoredCount() {
|
||||||
return storedItem.getCount();
|
return storedItem.getCount();
|
||||||
}
|
}
|
||||||
|
@ -115,8 +107,8 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
ArrayList<ItemStack> stacks = new ArrayList<>();
|
ArrayList<ItemStack> stacks = new ArrayList<>();
|
||||||
|
|
||||||
if (!getStoredItemType().isEmpty()) {
|
if (!getStoredItemType().isEmpty()) {
|
||||||
if (!getStackInSlot(1).isEmpty()) {
|
if (!inventory.getStackInSlot(1).isEmpty()) {
|
||||||
stacks.add(getStackInSlot(1));
|
stacks.add(inventory.getStackInSlot(1));
|
||||||
}
|
}
|
||||||
int size = storedItem.getMaxStackSize();
|
int size = storedItem.getMaxStackSize();
|
||||||
for (int i = 0; i < getStoredCount() / size; i++) {
|
for (int i = 0; i < getStoredCount() / size; i++) {
|
||||||
|
@ -140,25 +132,25 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
super.update();
|
super.update();
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
ItemStack outputStack = ItemStack.EMPTY;
|
ItemStack outputStack = ItemStack.EMPTY;
|
||||||
if (!getStackInSlot(1).isEmpty()) {
|
if (!inventory.getStackInSlot(1).isEmpty()) {
|
||||||
outputStack = getStackInSlot(1);
|
outputStack = inventory.getStackInSlot(1);
|
||||||
}
|
}
|
||||||
if (!getStackInSlot(0).isEmpty()
|
if (!inventory.getStackInSlot(0).isEmpty()
|
||||||
&& (storedItem.getCount() + outputStack.getCount()) < maxCapacity) {
|
&& (storedItem.getCount() + outputStack.getCount()) < maxCapacity) {
|
||||||
ItemStack inputStack = getStackInSlot(0);
|
ItemStack inputStack = inventory.getStackInSlot(0);
|
||||||
if (getStoredItemType().isEmpty()
|
if (getStoredItemType().isEmpty()
|
||||||
|| (storedItem.isEmpty() && ItemUtils.isItemEqual(inputStack, outputStack, true, true))) {
|
|| (storedItem.isEmpty() && ItemUtils.isItemEqual(inputStack, outputStack, true, true))) {
|
||||||
|
|
||||||
storedItem = inputStack;
|
storedItem = inputStack;
|
||||||
setInventorySlotContents(0, ItemStack.EMPTY);
|
inventory.setStackInSlot(0, ItemStack.EMPTY);
|
||||||
} else if (ItemUtils.isItemEqual(getStoredItemType(), inputStack, true, true)) {
|
} else if (ItemUtils.isItemEqual(getStoredItemType(), inputStack, true, true)) {
|
||||||
int reminder = maxCapacity - storedItem.getCount() - outputStack.getCount();
|
int reminder = maxCapacity - storedItem.getCount() - outputStack.getCount();
|
||||||
if (inputStack.getCount() <= reminder) {
|
if (inputStack.getCount() <= reminder) {
|
||||||
setStoredItemCount(inputStack.getCount());
|
setStoredItemCount(inputStack.getCount());
|
||||||
setInventorySlotContents(0, ItemStack.EMPTY);
|
inventory.setStackInSlot(0, ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
setStoredItemCount(maxCapacity - outputStack.getCount());
|
setStoredItemCount(maxCapacity - outputStack.getCount());
|
||||||
getStackInSlot(0).shrink(reminder);
|
inventory.getStackInSlot(0).shrink(reminder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
markDirty();
|
markDirty();
|
||||||
|
@ -176,7 +168,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
storedItem = ItemStack.EMPTY;
|
storedItem = ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInventorySlotContents(1, delivered);
|
inventory.setStackInSlot(1, delivered);
|
||||||
markDirty();
|
markDirty();
|
||||||
syncWithAll();
|
syncWithAll();
|
||||||
} else if (ItemUtils.isItemEqual(storedItem, outputStack, true, true)
|
} else if (ItemUtils.isItemEqual(storedItem, outputStack, true, true)
|
||||||
|
@ -224,7 +216,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
@Override
|
@Override
|
||||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
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);
|
return super.getCapability(capability, facing);
|
||||||
}
|
}
|
||||||
|
@ -234,7 +226,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
|
@ -256,16 +248,16 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
name = storedItem.getDisplayName();
|
name = storedItem.getDisplayName();
|
||||||
size += storedItem.getCount();
|
size += storedItem.getCount();
|
||||||
}
|
}
|
||||||
if (!getStackInSlot(1).isEmpty()) {
|
if (!inventory.getStackInSlot(1).isEmpty()) {
|
||||||
name = getStackInSlot(1).getDisplayName();
|
name = inventory.getStackInSlot(1).getDisplayName();
|
||||||
size += getStackInSlot(1).getCount();
|
size += inventory.getStackInSlot(1).getCount();
|
||||||
}
|
}
|
||||||
info.add(size + " " + name);
|
info.add(size + " " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getStoredItemType() {
|
public ItemStack getStoredItemType() {
|
||||||
return storedItem.isEmpty() ? getStackInSlot(1) : storedItem;
|
return storedItem.isEmpty() ? inventory.getStackInSlot(1) : storedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.RebornCoreConfig;
|
import reborncore.common.RebornCoreConfig;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
|
@ -50,7 +50,7 @@ import java.util.List;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class TileFusionControlComputer extends TilePowerAcceptor
|
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)")
|
@ConfigRegistry(config = "machines", category = "fusion_reactor", key = "FusionReactorMaxInput", comment = "Fusion Reactor Max Input (Value in EU)")
|
||||||
public static int maxInput = 8192;
|
public static int maxInput = 8192;
|
||||||
|
@ -180,7 +180,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
* @return boolean True if reactor can execute recipe provided
|
* @return boolean True if reactor can execute recipe provided
|
||||||
*/
|
*/
|
||||||
private boolean validateReactorRecipe(FusionReactorRecipe recipe) {
|
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) {
|
private boolean validateReactorRecipeInputs(FusionReactorRecipe recipe, ItemStack slot1, ItemStack slot2) {
|
||||||
|
@ -209,7 +209,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
// Force check every second
|
// Force check every second
|
||||||
if (world.getTotalWorldTime() % 20 == 0) {
|
if (world.getTotalWorldTime() % 20 == 0) {
|
||||||
checkCoils();
|
checkCoils();
|
||||||
inventory.hasChanged = true;
|
inventory.setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coilCount == 0) {
|
if (coilCount == 0) {
|
||||||
|
@ -217,12 +217,12 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRecipe == null && inventory.hasChanged == true) {
|
if (currentRecipe == null && inventory.hasChanged()) {
|
||||||
updateCurrentRecipe();
|
updateCurrentRecipe();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRecipe != null) {
|
if (currentRecipe != null) {
|
||||||
if (!hasStartedCrafting && inventory.hasChanged && !validateReactorRecipe(currentRecipe)) {
|
if (!hasStartedCrafting && inventory.hasChanged() && !validateReactorRecipe(currentRecipe)) {
|
||||||
resetCrafter();
|
resetCrafter();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -232,9 +232,9 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
if (canUseEnergy(currentRecipe.getStartEU())) {
|
if (canUseEnergy(currentRecipe.getStartEU())) {
|
||||||
useEnergy(currentRecipe.getStartEU());
|
useEnergy(currentRecipe.getStartEU());
|
||||||
hasStartedCrafting = true;
|
hasStartedCrafting = true;
|
||||||
decrStackSize(topStackSlot, currentRecipe.getTopInput().getCount());
|
inventory.shrinkSlot(topStackSlot, currentRecipe.getTopInput().getCount());
|
||||||
if (!currentRecipe.getBottomInput().isEmpty()) {
|
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) {
|
} else if (crafingTickTime >= finalTickTime) {
|
||||||
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) {
|
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) {
|
||||||
if (getStackInSlot(outputStackSlot).isEmpty()) {
|
if (inventory.getStackInSlot(outputStackSlot).isEmpty()) {
|
||||||
setInventorySlotContents(outputStackSlot, currentRecipe.getOutput().copy());
|
inventory.setStackInSlot(outputStackSlot, currentRecipe.getOutput().copy());
|
||||||
} else {
|
} else {
|
||||||
decrStackSize(outputStackSlot, -currentRecipe.getOutput().getCount());
|
inventory.shrinkSlot(outputStackSlot, -currentRecipe.getOutput().getCount());
|
||||||
}
|
}
|
||||||
if (validateReactorRecipe(this.currentRecipe)) {
|
if (validateReactorRecipe(this.currentRecipe)) {
|
||||||
crafingTickTime = 0;
|
crafingTickTime = 0;
|
||||||
decrStackSize(topStackSlot, currentRecipe.getTopInput().getCount());
|
inventory.shrinkSlot(topStackSlot, currentRecipe.getTopInput().getCount());
|
||||||
if (!currentRecipe.getBottomInput().isEmpty()) {
|
if (!currentRecipe.getBottomInput().isEmpty()) {
|
||||||
decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().getCount());
|
inventory.shrinkSlot(bottomStackSlot, currentRecipe.getBottomInput().getCount());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resetCrafter();
|
resetCrafter();
|
||||||
|
@ -271,9 +271,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inventory.hasChanged) {
|
inventory.resetChanged();
|
||||||
inventory.hasChanged = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -364,7 +362,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
return new ItemStack(ModBlocks.FUSION_CONTROL_COMPUTER, 1);
|
return new ItemStack(ModBlocks.FUSION_CONTROL_COMPUTER, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
|
|
|
@ -28,7 +28,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.util.FluidUtils;
|
import reborncore.common.util.FluidUtils;
|
||||||
|
@ -41,7 +41,7 @@ import techreborn.api.generator.GeneratorRecipeHelper;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
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 FluidGeneratorRecipeList recipes;
|
||||||
private final int euTick;
|
private final int euTick;
|
||||||
|
@ -135,8 +135,8 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean acceptFluid() {
|
protected boolean acceptFluid() {
|
||||||
if (!getStackInSlot(0).isEmpty()) {
|
if (!inventory.getStackInSlot(0).isEmpty()) {
|
||||||
FluidStack stack = FluidUtils.getFluidStackInContainer(getStackInSlot(0));
|
FluidStack stack = FluidUtils.getFluidStackInContainer(inventory.getStackInSlot(0));
|
||||||
if (stack != null)
|
if (stack != null)
|
||||||
return recipes.getRecipeForFluid(stack.getFluid()).isPresent();
|
return recipes.getRecipeForFluid(stack.getFluid()).isPresent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
|
@ -41,7 +41,7 @@ import techreborn.lib.ModInfo;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class TileDragonEggSyphon extends TilePowerAcceptor
|
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)")
|
@ConfigRegistry(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxOutput", comment = "Dragon Egg Siphoner Max Output (Value in EU)")
|
||||||
public static int maxOutput = 128;
|
public static int maxOutput = 128;
|
||||||
|
@ -119,7 +119,7 @@ public class TileDragonEggSyphon extends TilePowerAcceptor
|
||||||
return new ItemStack(ModBlocks.DRAGON_EGG_SYPHON, 1);
|
return new ItemStack(ModBlocks.DRAGON_EGG_SYPHON, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
|
|
|
@ -32,7 +32,7 @@ import net.minecraft.tileentity.TileEntityFurnace;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.common.ForgeModContainer;
|
import net.minecraftforge.common.ForgeModContainer;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
|
@ -45,7 +45,7 @@ import techreborn.init.ModBlocks;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@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)")
|
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorMaxOutput", comment = "Solid Fuel Generator Max Output (Value in EU)")
|
||||||
public static int maxOutput = 32;
|
public static int maxOutput = 32;
|
||||||
|
@ -90,19 +90,19 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
|
||||||
|
|
||||||
if (burnTime == 0) {
|
if (burnTime == 0) {
|
||||||
updateState();
|
updateState();
|
||||||
burnTime = totalBurnTime = TileSolidFuelGenerator.getItemBurnTime(getStackInSlot(fuelSlot));
|
burnTime = totalBurnTime = TileSolidFuelGenerator.getItemBurnTime(inventory.getStackInSlot(fuelSlot));
|
||||||
if (burnTime > 0) {
|
if (burnTime > 0) {
|
||||||
updateState();
|
updateState();
|
||||||
burnItem = getStackInSlot(fuelSlot);
|
burnItem = inventory.getStackInSlot(fuelSlot);
|
||||||
if (getStackInSlot(fuelSlot).getCount() == 1) {
|
if (inventory.getStackInSlot(fuelSlot).getCount() == 1) {
|
||||||
if (getStackInSlot(fuelSlot).getItem() == Items.LAVA_BUCKET || getStackInSlot(fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket) {
|
if (inventory.getStackInSlot(fuelSlot).getItem() == Items.LAVA_BUCKET || inventory.getStackInSlot(fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket) {
|
||||||
setInventorySlotContents(fuelSlot, new ItemStack(Items.BUCKET));
|
inventory.setStackInSlot(fuelSlot, new ItemStack(Items.BUCKET));
|
||||||
} else {
|
} else {
|
||||||
setInventorySlotContents(fuelSlot, ItemStack.EMPTY);
|
inventory.setStackInSlot(fuelSlot, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
decrStackSize(fuelSlot, 1);
|
inventory.shrinkSlot(fuelSlot, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.power.EnumPowerTier;
|
import reborncore.api.power.EnumPowerTier;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.RebornCoreConfig;
|
import reborncore.common.RebornCoreConfig;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.util.Inventory;
|
import reborncore.common.util.Inventory;
|
||||||
|
@ -42,7 +42,7 @@ import techreborn.blocks.storage.BlockEnergyStorage;
|
||||||
* Created by Rushmead
|
* Created by Rushmead
|
||||||
*/
|
*/
|
||||||
public class TileEnergyStorage extends TilePowerAcceptor
|
public class TileEnergyStorage extends TilePowerAcceptor
|
||||||
implements IToolDrop, IInventoryProvider {
|
implements IToolDrop, ItemHandlerProvider {
|
||||||
|
|
||||||
public Inventory inventory;
|
public Inventory inventory;
|
||||||
public String name;
|
public String name;
|
||||||
|
@ -139,7 +139,7 @@ public class TileEnergyStorage extends TilePowerAcceptor
|
||||||
return new ItemStack(wrenchDrop);
|
return new ItemStack(wrenchDrop);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
|
|
|
@ -34,7 +34,7 @@ import net.minecraft.util.EnumFacing;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.recipe.IBaseRecipeType;
|
import reborncore.api.recipe.IBaseRecipeType;
|
||||||
import reborncore.api.recipe.RecipeHandler;
|
import reborncore.api.recipe.RecipeHandler;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.recipes.RecipeTranslator;
|
import reborncore.common.recipes.RecipeTranslator;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
import reborncore.common.tile.TileLegacyMachineBase;
|
import reborncore.common.tile.TileLegacyMachineBase;
|
||||||
|
@ -50,7 +50,7 @@ import techreborn.lib.ModInfo;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
||||||
implements IToolDrop, IInventoryProvider, IContainerProvider {
|
implements IToolDrop, ItemHandlerProvider, IContainerProvider {
|
||||||
|
|
||||||
public int tickTime;
|
public int tickTime;
|
||||||
public Inventory inventory = new Inventory(4, "TileIronAlloyFurnace", 64, this);
|
public Inventory inventory = new Inventory(4, "TileIronAlloyFurnace", 64, this);
|
||||||
|
@ -136,13 +136,13 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
||||||
--this.burnTime;
|
--this.burnTime;
|
||||||
}
|
}
|
||||||
if (!this.world.isRemote) {
|
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()) {
|
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) {
|
if (this.burnTime > 0) {
|
||||||
flag1 = true;
|
flag1 = true;
|
||||||
if (!this.getStackInSlot(this.fuel).isEmpty()) {
|
if (!inventory.getStackInSlot(this.fuel).isEmpty()) {
|
||||||
this.decrStackSize(this.fuel, 1);
|
inventory.shrinkSlot(this.fuel, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSmelt() {
|
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;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
ItemStack itemstack = null;
|
ItemStack itemstack = null;
|
||||||
|
@ -204,12 +204,12 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
||||||
|
|
||||||
if (itemstack == null)
|
if (itemstack == null)
|
||||||
return false;
|
return false;
|
||||||
if (this.getStackInSlot(this.output).isEmpty())
|
if (inventory.getStackInSlot(this.output).isEmpty())
|
||||||
return true;
|
return true;
|
||||||
if (!this.getStackInSlot(this.output).isItemEqual(itemstack))
|
if (!inventory.getStackInSlot(this.output).isItemEqual(itemstack))
|
||||||
return false;
|
return false;
|
||||||
final int result = this.getStackInSlot(this.output).getCount() + itemstack.getCount();
|
final int result = inventory.getStackInSlot(this.output).getCount() + itemstack.getCount();
|
||||||
return result <= this.getInventoryStackLimit() && result <= this.getStackInSlot(this.output).getMaxStackSize(); // Forge
|
return result <= inventory.getStackLimit() && result <= inventory.getStackInSlot(this.output).getMaxStackSize(); // Forge
|
||||||
// BugFix:
|
// BugFix:
|
||||||
// Make
|
// Make
|
||||||
// it
|
// it
|
||||||
|
@ -237,10 +237,10 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getStackInSlot(this.output).isEmpty()) {
|
if (inventory.getStackInSlot(this.output).isEmpty()) {
|
||||||
this.setInventorySlotContents(this.output, itemstack.copy());
|
inventory.setStackInSlot(this.output, itemstack.copy());
|
||||||
} else if (this.getStackInSlot(this.output).getItem() == itemstack.getItem()) {
|
} else if (inventory.getStackInSlot(this.output).getItem() == itemstack.getItem()) {
|
||||||
this.decrStackSize(this.output, -itemstack.getCount());
|
inventory.shrinkSlot(this.output, -itemstack.getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.ALLOY_SMELTER_RECIPE)) {
|
for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.ALLOY_SMELTER_RECIPE)) {
|
||||||
|
@ -259,7 +259,7 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
||||||
if (input instanceof ItemStack) {
|
if (input instanceof ItemStack) {
|
||||||
count = RecipeTranslator.getStackFromObject(input).getCount();
|
count = RecipeTranslator.getStackFromObject(input).getCount();
|
||||||
}
|
}
|
||||||
inventory.decrStackSize(inputSlot, count);
|
inventory.shrinkSlot(inputSlot, count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||||
import net.minecraft.tileentity.TileEntityFurnace;
|
import net.minecraft.tileentity.TileEntityFurnace;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.tile.TileLegacyMachineBase;
|
import reborncore.common.tile.TileLegacyMachineBase;
|
||||||
import reborncore.common.util.Inventory;
|
import reborncore.common.util.Inventory;
|
||||||
|
@ -39,7 +39,7 @@ import techreborn.client.container.builder.BuiltContainer;
|
||||||
import techreborn.client.container.builder.ContainerBuilder;
|
import techreborn.client.container.builder.ContainerBuilder;
|
||||||
|
|
||||||
public class TileIronFurnace extends TileLegacyMachineBase
|
public class TileIronFurnace extends TileLegacyMachineBase
|
||||||
implements IInventoryProvider, IContainerProvider {
|
implements ItemHandlerProvider, IContainerProvider {
|
||||||
|
|
||||||
public int tickTime;
|
public int tickTime;
|
||||||
public Inventory inventory = new Inventory(3, "TileIronFurnace", 64, this);
|
public Inventory inventory = new Inventory(3, "TileIronFurnace", 64, this);
|
||||||
|
@ -79,16 +79,16 @@ public class TileIronFurnace extends TileLegacyMachineBase
|
||||||
this.updateState();
|
this.updateState();
|
||||||
}
|
}
|
||||||
if (this.fuel <= 0 && this.canSmelt()) {
|
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) {
|
if (this.fuel > 0) {
|
||||||
// Fuel slot
|
// Fuel slot
|
||||||
ItemStack fuelStack = this.getStackInSlot(this.fuelslot);
|
ItemStack fuelStack = inventory.getStackInSlot(this.fuelslot);
|
||||||
if (fuelStack.getItem().hasContainerItem(fuelStack)) {
|
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) {
|
} else if (fuelStack.getCount() > 1) {
|
||||||
this.decrStackSize(this.fuelslot, 1);
|
inventory.shrinkSlot(this.fuelslot, 1);
|
||||||
} else if (fuelStack.getCount() == 1) {
|
} else if (fuelStack.getCount() == 1) {
|
||||||
this.setInventorySlotContents(this.fuelslot, ItemStack.EMPTY);
|
inventory.setStackInSlot(this.fuelslot, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
updateInventory = true;
|
updateInventory = true;
|
||||||
}
|
}
|
||||||
|
@ -113,33 +113,33 @@ public class TileIronFurnace extends TileLegacyMachineBase
|
||||||
|
|
||||||
public void cookItems() {
|
public void cookItems() {
|
||||||
if (this.canSmelt()) {
|
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()) {
|
if (inventory.getStackInSlot(this.output).isEmpty()) {
|
||||||
this.setInventorySlotContents(this.output, itemstack.copy());
|
inventory.setStackInSlot(this.output, itemstack.copy());
|
||||||
} else if (this.getStackInSlot(this.output).isItemEqual(itemstack)) {
|
} else if (inventory.getStackInSlot(this.output).isItemEqual(itemstack)) {
|
||||||
this.getStackInSlot(this.output).grow(itemstack.getCount());
|
inventory.getStackInSlot(this.output).grow(itemstack.getCount());
|
||||||
}
|
}
|
||||||
if (this.getStackInSlot(this.input1).getCount() > 1) {
|
if (inventory.getStackInSlot(this.input1).getCount() > 1) {
|
||||||
this.decrStackSize(this.input1, 1);
|
inventory.shrinkSlot(this.input1, 1);
|
||||||
} else {
|
} else {
|
||||||
this.setInventorySlotContents(this.input1, ItemStack.EMPTY);
|
inventory.setStackInSlot(this.input1, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSmelt() {
|
public boolean canSmelt() {
|
||||||
if (this.getStackInSlot(this.input1).isEmpty())
|
if (inventory.getStackInSlot(this.input1).isEmpty())
|
||||||
return false;
|
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())
|
if (itemstack.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
if (this.getStackInSlot(this.output).isEmpty())
|
if (inventory.getStackInSlot(this.output).isEmpty())
|
||||||
return true;
|
return true;
|
||||||
if (!this.getStackInSlot(this.output).isItemEqual(itemstack))
|
if (!inventory.getStackInSlot(this.output).isItemEqual(itemstack))
|
||||||
return false;
|
return false;
|
||||||
final int result = this.getStackInSlot(this.output).getCount() + itemstack.getCount();
|
final int result = inventory.getStackInSlot(this.output).getCount() + itemstack.getCount();
|
||||||
return result <= this.getInventoryStackLimit() && result <= itemstack.getMaxStackSize();
|
return result <= inventory.getStackLimit() && result <= itemstack.getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBurning() {
|
public boolean isBurning() {
|
||||||
|
@ -172,7 +172,7 @@ public class TileIronFurnace extends TileLegacyMachineBase
|
||||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||||
boolean isFuel = TileEntityFurnace.isItemFuel(stack);
|
boolean isFuel = TileEntityFurnace.isItemFuel(stack);
|
||||||
if(isFuel){
|
if(isFuel){
|
||||||
ItemStack fuelSlotStack = getStackInSlot(fuelslot);
|
ItemStack fuelSlotStack = inventory.getStackInSlot(fuelslot);
|
||||||
if(fuelSlotStack.isEmpty() || ItemUtils.isItemEqual(stack, fuelSlotStack, true, true) && fuelSlotStack.getMaxStackSize() != fuelSlotStack.getCount()){
|
if(fuelSlotStack.isEmpty() || ItemUtils.isItemEqual(stack, fuelSlotStack, true, true) && fuelSlotStack.getMaxStackSize() != fuelSlotStack.getCount()){
|
||||||
return index == fuelslot;
|
return index == fuelslot;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ package techreborn.tiles.tier1;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.CraftingManager;
|
import net.minecraft.item.crafting.CraftingManager;
|
||||||
|
@ -35,9 +34,10 @@ import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
import reborncore.common.registration.impl.ConfigRegistry;
|
import reborncore.common.registration.impl.ConfigRegistry;
|
||||||
|
@ -59,7 +59,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class TileAutoCraftingTable extends TilePowerAcceptor
|
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)")
|
@ConfigRegistry(config = "machines", category = "autocrafter", key = "AutoCrafterInput", comment = "AutoCrafting Table Max Input (Value in EU)")
|
||||||
public static int maxInput = 32;
|
public static int maxInput = 32;
|
||||||
|
@ -160,7 +160,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasRoomForExtraItem(ItemStack stack) {
|
boolean hasRoomForExtraItem(ItemStack stack) {
|
||||||
ItemStack extraOutputSlot = getStackInSlot(10);
|
ItemStack extraOutputSlot = inventory.getStackInSlot(10);
|
||||||
if (extraOutputSlot.isEmpty()) {
|
if (extraOutputSlot.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
||||||
// TODO fire forge recipe event
|
// TODO fire forge recipe event
|
||||||
ItemStack ouputStack = recipe.getCraftingResult(getCraftingInventory());
|
ItemStack ouputStack = recipe.getCraftingResult(getCraftingInventory());
|
||||||
if (output.isEmpty()) {
|
if (output.isEmpty()) {
|
||||||
inventory.setInventorySlotContents(9, ouputStack.copy());
|
inventory.setStackInSlot(9, ouputStack.copy());
|
||||||
} else {
|
} else {
|
||||||
// TODO use ouputStack in someway?
|
// TODO use ouputStack in someway?
|
||||||
output.grow(recipe.getRecipeOutput().getCount());
|
output.grow(recipe.getRecipeOutput().getCount());
|
||||||
|
@ -219,10 +219,10 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
||||||
private void handleContainerItem(ItemStack stack) {
|
private void handleContainerItem(ItemStack stack) {
|
||||||
if (stack.getItem().hasContainerItem(stack)) {
|
if (stack.getItem().hasContainerItem(stack)) {
|
||||||
ItemStack containerItem = stack.getItem().getContainerItem(stack);
|
ItemStack containerItem = stack.getItem().getContainerItem(stack);
|
||||||
ItemStack extraOutputSlot = getStackInSlot(10);
|
ItemStack extraOutputSlot = inventory.getStackInSlot(10);
|
||||||
if (hasOutputSpace(containerItem, 10)) {
|
if (hasOutputSpace(containerItem, 10)) {
|
||||||
if (extraOutputSlot.isEmpty()) {
|
if (extraOutputSlot.isEmpty()) {
|
||||||
setInventorySlotContents(10, containerItem.copy());
|
inventory.setStackInSlot(10, containerItem.copy());
|
||||||
} else if (ItemUtils.isItemEqual(extraOutputSlot, containerItem, true, true)
|
} else if (ItemUtils.isItemEqual(extraOutputSlot, containerItem, true, true)
|
||||||
&& extraOutputSlot.getMaxStackSize() < extraOutputSlot.getCount() + containerItem.getCount()) {
|
&& extraOutputSlot.getMaxStackSize() < extraOutputSlot.getCount() + containerItem.getCount()) {
|
||||||
extraOutputSlot.grow(1);
|
extraOutputSlot.grow(1);
|
||||||
|
@ -442,9 +442,9 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
||||||
return new ItemStack(ModBlocks.AUTO_CRAFTING_TABLE, 1);
|
return new ItemStack(ModBlocks.AUTO_CRAFTING_TABLE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public IInventory getInventory() {
|
public IItemHandler getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
|
@ -44,7 +44,7 @@ import techreborn.lib.ModInfo;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class TileElectricFurnace extends TilePowerAcceptor
|
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)")
|
@ConfigRegistry(config = "machines", category = "electric_furnace", key = "ElectricFurnaceInput", comment = "Electric Furnace Max Input (Value in EU)")
|
||||||
public static int maxInput = 32;
|
public static int maxInput = 32;
|
||||||
|
@ -69,37 +69,37 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
||||||
|
|
||||||
public void cookItems() {
|
public void cookItems() {
|
||||||
if (canSmelt()) {
|
if (canSmelt()) {
|
||||||
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
|
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(inventory.getStackInSlot(input1));
|
||||||
|
|
||||||
if (getStackInSlot(output).isEmpty()) {
|
if (inventory.getStackInSlot(output).isEmpty()) {
|
||||||
setInventorySlotContents(output, itemstack.copy());
|
inventory.setStackInSlot(output, itemstack.copy());
|
||||||
} else if (getStackInSlot(output).isItemEqual(itemstack)) {
|
} else if (inventory.getStackInSlot(output).isItemEqual(itemstack)) {
|
||||||
getStackInSlot(output).grow(itemstack.getCount());
|
inventory.getStackInSlot(output).grow(itemstack.getCount());
|
||||||
}
|
}
|
||||||
if (getStackInSlot(input1).getCount() > 1) {
|
if (inventory.getStackInSlot(input1).getCount() > 1) {
|
||||||
decrStackSize(input1, 1);
|
inventory.shrinkSlot(input1, 1);
|
||||||
} else {
|
} else {
|
||||||
setInventorySlotContents(input1, ItemStack.EMPTY);
|
inventory.setStackInSlot(input1, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSmelt() {
|
public boolean canSmelt() {
|
||||||
if (getStackInSlot(input1).isEmpty()) {
|
if (inventory.getStackInSlot(input1).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
|
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(inventory.getStackInSlot(input1));
|
||||||
if (itemstack.isEmpty()) {
|
if (itemstack.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getStackInSlot(output).isEmpty()) {
|
if (inventory.getStackInSlot(output).isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!getStackInSlot(output).isItemEqual(itemstack)) {
|
if (!inventory.getStackInSlot(output).isItemEqual(itemstack)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int result = getStackInSlot(output).getCount() + itemstack.getCount();
|
final int result = inventory.getStackInSlot(output).getCount() + itemstack.getCount();
|
||||||
return result <= this.getInventoryStackLimit() && result <= itemstack.getMaxStackSize();
|
return result <= this.inventory.getStackLimit() && result <= itemstack.getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBurning() {
|
public boolean isBurning() {
|
||||||
|
@ -207,7 +207,7 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
||||||
return new ItemStack(ModBlocks.ELECTRIC_FURNACE, 1);
|
return new ItemStack(ModBlocks.ELECTRIC_FURNACE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
|
|
|
@ -29,7 +29,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
|
@ -44,7 +44,7 @@ import techreborn.lib.ModInfo;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class TileRecycler extends TilePowerAcceptor
|
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)")
|
@ConfigRegistry(config = "machines", category = "recycler", key = "RecyclerInput", comment = "Recycler Max Input (Value in EU)")
|
||||||
public static int maxInput = 32;
|
public static int maxInput = 32;
|
||||||
|
@ -79,24 +79,24 @@ public class TileRecycler extends TilePowerAcceptor
|
||||||
final int randomchance = this.world.rand.nextInt(chance);
|
final int randomchance = this.world.rand.nextInt(chance);
|
||||||
|
|
||||||
if (randomchance == 1) {
|
if (randomchance == 1) {
|
||||||
if (getStackInSlot(1).isEmpty()) {
|
if (inventory.getStackInSlot(1).isEmpty()) {
|
||||||
setInventorySlotContents(1, itemstack.copy());
|
inventory.setStackInSlot(1, itemstack.copy());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.getStackInSlot(1).grow(itemstack.getCount());
|
inventory.getStackInSlot(1).grow(itemstack.getCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
decrStackSize(0, 1);
|
inventory.shrinkSlot(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRecycle() {
|
public boolean canRecycle() {
|
||||||
return !getStackInSlot(0) .isEmpty() && hasSlotGotSpace(1);
|
return !inventory.getStackInSlot(0) .isEmpty() && hasSlotGotSpace(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSlotGotSpace(int slot) {
|
public boolean hasSlotGotSpace(int slot) {
|
||||||
if (getStackInSlot(slot).isEmpty()) {
|
if (inventory.getStackInSlot(slot).isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (getStackInSlot(slot).getCount() < getStackInSlot(slot).getMaxStackSize()) {
|
} else if (inventory.getStackInSlot(slot).getCount() < inventory.getStackInSlot(slot).getMaxStackSize()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -191,7 +191,7 @@ public class TileRecycler extends TilePowerAcceptor
|
||||||
return new ItemStack(ModBlocks.RECYCLER, 1);
|
return new ItemStack(ModBlocks.RECYCLER, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// ItemHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return this.inventory;
|
return this.inventory;
|
||||||
|
|
|
@ -34,7 +34,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.ItemHandlerProvider;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
import reborncore.common.registration.impl.ConfigRegistry;
|
import reborncore.common.registration.impl.ConfigRegistry;
|
||||||
|
@ -56,7 +56,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class TileRollingMachine extends TilePowerAcceptor
|
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)")
|
@ConfigRegistry(config = "machines", category = "rolling_machine", key = "RollingMachineMaxInput", comment = "Rolling Machine Max Input (Value in EU)")
|
||||||
public static int maxInput = 32;
|
public static int maxInput = 32;
|
||||||
|
@ -137,7 +137,7 @@ public class TileRollingMachine extends TilePowerAcceptor
|
||||||
if (!currentRecipeOutput.isEmpty()) {
|
if (!currentRecipeOutput.isEmpty()) {
|
||||||
boolean hasCrafted = false;
|
boolean hasCrafted = false;
|
||||||
if (inventory.getStackInSlot(outputSlot).isEmpty()) {
|
if (inventory.getStackInSlot(outputSlot).isEmpty()) {
|
||||||
inventory.setInventorySlotContents(outputSlot, currentRecipeOutput);
|
inventory.setStackInSlot(outputSlot, currentRecipeOutput);
|
||||||
tickTime = 0;
|
tickTime = 0;
|
||||||
hasCrafted = true;
|
hasCrafted = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,14 +145,14 @@ public class TileRollingMachine extends TilePowerAcceptor
|
||||||
+ currentRecipeOutput.getCount() <= currentRecipeOutput.getMaxStackSize()) {
|
+ currentRecipeOutput.getCount() <= currentRecipeOutput.getMaxStackSize()) {
|
||||||
final ItemStack stack = inventory.getStackInSlot(outputSlot);
|
final ItemStack stack = inventory.getStackInSlot(outputSlot);
|
||||||
stack.setCount(stack.getCount() + currentRecipeOutput.getCount());
|
stack.setCount(stack.getCount() + currentRecipeOutput.getCount());
|
||||||
inventory.setInventorySlotContents(outputSlot, stack);
|
inventory.setStackInSlot(outputSlot, stack);
|
||||||
tickTime = 0;
|
tickTime = 0;
|
||||||
hasCrafted = true;
|
hasCrafted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasCrafted) {
|
if (hasCrafted) {
|
||||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
|
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
|
||||||
inventory.decrStackSize(i, 1);
|
inventory.shrinkSlot(i, 1);
|
||||||
}
|
}
|
||||||
currentRecipeOutput = ItemStack.EMPTY;
|
currentRecipeOutput = ItemStack.EMPTY;
|
||||||
currentRecipe = null;
|
currentRecipe = null;
|
||||||
|
@ -234,7 +234,7 @@ public class TileRollingMachine extends TilePowerAcceptor
|
||||||
}
|
}
|
||||||
sourceStack.shrink(1);
|
sourceStack.shrink(1);
|
||||||
inventory.getStackInSlot(bestSlot.getLeft()).grow(1);
|
inventory.getStackInSlot(bestSlot.getLeft()).grow(1);
|
||||||
inventory.hasChanged = true;
|
inventory.setChanged();
|
||||||
|
|
||||||
return Optional.of(getCraftingMatrix());
|
return Optional.of(getCraftingMatrix());
|
||||||
}
|
}
|
||||||
|
@ -243,11 +243,11 @@ public class TileRollingMachine extends TilePowerAcceptor
|
||||||
if (craftCache == null) {
|
if (craftCache == null) {
|
||||||
craftCache = new InventoryCrafting(new RollingTileContainer(), 3, 3);
|
craftCache = new InventoryCrafting(new RollingTileContainer(), 3, 3);
|
||||||
}
|
}
|
||||||
if (inventory.hasChanged) {
|
if (inventory.hasChanged()) {
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
craftCache.setInventorySlotContents(i, inventory.getStackInSlot(i).copy());
|
craftCache.setInventorySlotContents(i, inventory.getStackInSlot(i).copy());
|
||||||
}
|
}
|
||||||
inventory.hasChanged = false;
|
inventory.resetChanged();
|
||||||
}
|
}
|
||||||
return craftCache;
|
return craftCache;
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ public class TileRollingMachine extends TilePowerAcceptor
|
||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ItemStack output = getStackInSlot(outputSlot);
|
ItemStack output = inventory.getStackInSlot(outputSlot);
|
||||||
if (output.isEmpty()) {
|
if (output.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ public class TileRollingMachine extends TilePowerAcceptor
|
||||||
.slot(0, 30, 22).slot(1, 48, 22).slot(2, 66, 22)
|
.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(3, 30, 40).slot(4, 48, 40).slot(5, 66, 40)
|
||||||
.slot(6, 30, 58).slot(7, 48, 58).slot(8, 66, 58)
|
.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)
|
.outputSlot(9, 124, 40)
|
||||||
.energySlot(10, 8, 70)
|
.energySlot(10, 8, 70)
|
||||||
.syncEnergyValue().syncIntegerValue(this::getBurnTime, this::setBurnTime).syncIntegerValue(this::getLockedInt, this::setLockedInt).addInventory().create(this);
|
.syncEnergyValue().syncIntegerValue(this::getBurnTime, this::setBurnTime).syncIntegerValue(this::getLockedInt, this::setLockedInt).addInventory().create(this);
|
||||||
|
|
Loading…
Reference in a new issue