Fix slot config, some changes to the way Inventory works as well to allow for this.
This commit is contained in:
parent
305f74b107
commit
01644e4f65
35 changed files with 114 additions and 108 deletions
|
@ -55,7 +55,7 @@ public class UpgradeSlot extends BaseSlot implements IRightClickHandler {
|
|||
public boolean handleRightClick(int slotID, EntityPlayer player, BuiltContainer container) {
|
||||
if (inventory instanceof Inventory) {
|
||||
Inventory inv = (Inventory) inventory;
|
||||
TileEntity tileEntity = inv.getTileBase();
|
||||
TileEntity tileEntity = inv.getTile();
|
||||
if (tileEntity instanceof IUpgradeable) {
|
||||
IUpgradeable upgradeable = (IUpgradeable) tileEntity;
|
||||
if (upgradeable.canBeUpgraded()) {
|
||||
|
|
|
@ -32,6 +32,9 @@ import net.minecraft.inventory.Slot;
|
|||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import reborncore.client.gui.GuiUtil;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
|
@ -64,10 +67,16 @@ public class GuiSlotConfiguration {
|
|||
public static void init(GuiBase guiBase) {
|
||||
reset();
|
||||
slotElementMap.clear();
|
||||
IItemHandler itemHandler = getMachine().getInventoryForTile().orElseGet(null);
|
||||
if(itemHandler == null){
|
||||
return;
|
||||
}
|
||||
|
||||
BuiltContainer container = guiBase.container;
|
||||
for (Slot slot : container.inventorySlots) {
|
||||
if (guiBase.tile != slot.inventory) {
|
||||
if(!(slot instanceof SlotItemHandler)){
|
||||
continue;
|
||||
} else if (((SlotItemHandler) slot).getItemHandler() != itemHandler){
|
||||
continue;
|
||||
}
|
||||
ConfigSlotElement slotElement = new ConfigSlotElement(guiBase.getMachine().getInventoryForTile().get(), slot.getSlotIndex(), SlotType.NORMAL, slot.xPos - guiBase.guiLeft + 50, slot.yPos - guiBase.guiTop - 25, guiBase);
|
||||
|
@ -77,9 +86,15 @@ public class GuiSlotConfiguration {
|
|||
}
|
||||
|
||||
public static void draw(GuiBase guiBase, int mouseX, int mouseY) {
|
||||
IItemHandler itemHandler = getMachine().getInventoryForTile().orElseGet(null);
|
||||
if(itemHandler == null){
|
||||
return;
|
||||
}
|
||||
BuiltContainer container = guiBase.container;
|
||||
for (Slot slot : container.inventorySlots) {
|
||||
if (guiBase.tile != slot.inventory) {
|
||||
if(!(slot instanceof SlotItemHandler)){
|
||||
continue;
|
||||
} else if (((SlotItemHandler) slot).getItemHandler() != itemHandler){
|
||||
continue;
|
||||
}
|
||||
GlStateManager.color(255, 0, 0);
|
||||
|
@ -172,8 +187,11 @@ public class GuiSlotConfiguration {
|
|||
BuiltContainer container = guiBase.container;
|
||||
|
||||
if(getVisibleElements().isEmpty()) {
|
||||
IItemHandler itemHandler = getMachine().getInventoryForTile().orElseGet(null);
|
||||
for (Slot slot : container.inventorySlots) {
|
||||
if (guiBase.tile != slot.inventory) {
|
||||
if(!(slot instanceof SlotItemHandler)){
|
||||
continue;
|
||||
} else if (((SlotItemHandler) slot).getItemHandler() != itemHandler){
|
||||
continue;
|
||||
}
|
||||
if (guiBase.isPointInRect(slot.xPos, slot.yPos, 18, 18, mouseX, mouseY)) {
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TileChargeOMat extends TilePowerAcceptor
|
|||
@ConfigRegistry(config = "machines", category = "charge_bench", key = "ChargeBenchMaxEnergy", comment = "Charge Bench Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 100_000_000;
|
||||
|
||||
public Inventory inventory = new Inventory(6, "TileChargeOMat", 64, this);
|
||||
public Inventory<TileChargeOMat> inventory = new Inventory<>(6, "TileChargeOMat", 64, this);
|
||||
|
||||
public TileChargeOMat() {
|
||||
super();
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TileChunkLoader extends TilePowerAcceptor implements IToolDrop, Ite
|
|||
// @ConfigRegistry(config = "machines", category = "chunk_loader", key = "ChunkLoaderWrenchDropRate", comment = "Chunk Loader Wrench Drop Rate")
|
||||
public static float wrenchDropRate = 1.0F;
|
||||
|
||||
public Inventory inventory = new Inventory(1, "TileChunkLoader", 64, this);
|
||||
public Inventory<TileChunkLoader> inventory = new Inventory<>(1, "TileChunkLoader", 64, this);
|
||||
|
||||
public boolean isRunning;
|
||||
public int tickTime;
|
||||
|
|
|
@ -53,7 +53,7 @@ public class TileIndustrialCentrifuge extends TileGenericMachine implements ICon
|
|||
super("IndustrialCentrifuge", maxInput, maxEnergy, ModBlocks.INDUSTRIAL_CENTRIFUGE, 6);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2, 3, 4, 5 };
|
||||
this.inventory = new Inventory(7, "TileIndustrialCentrifuge", 64, this);
|
||||
this.inventory = new Inventory<>(7, "TileIndustrialCentrifuge", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.CENTRIFUGE_RECIPE, this, 2, 4, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class TileMatterFabricator extends TilePowerAcceptor
|
|||
@ConfigRegistry(config = "machines", category = "matter_fabricator", key = "MatterFabricatorEnergyPerAmp", comment = "Matter Fabricator EU per amplifier unit, multiply this with the rate for total EU")
|
||||
public static int energyPerAmp = 5;
|
||||
|
||||
public Inventory inventory = new Inventory(12, "TileMatterFabricator", 64, this);
|
||||
public Inventory<TileMatterFabricator> inventory = new Inventory<>(12, "TileMatterFabricator", 64, this);
|
||||
private int amplifier = 0;
|
||||
|
||||
public TileMatterFabricator() {
|
||||
|
|
|
@ -55,7 +55,7 @@ public class TileQuantumTank extends TileLegacyMachineBase
|
|||
public static int maxStorage = Integer.MAX_VALUE;
|
||||
|
||||
public Tank tank = new Tank("TileQuantumTank", maxStorage, this);
|
||||
public Inventory inventory = new Inventory(3, "TileQuantumTank", 64, this);
|
||||
public Inventory<TileQuantumTank> inventory = new Inventory<>(3, "TileQuantumTank", 64, this);
|
||||
|
||||
public void readFromNBTWithoutCoords(final NBTTagCompound tagCompound) {
|
||||
tank.readFromNBT(tagCompound);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
|||
public TileTechStorageBase(String name, int maxCapacity) {
|
||||
this.maxCapacity = maxCapacity;
|
||||
storedItem = ItemStack.EMPTY;
|
||||
inventory = new Inventory(3, name, maxCapacity, this);
|
||||
inventory = new Inventory<>(3, name, maxCapacity, this);
|
||||
}
|
||||
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
|||
public TileFusionControlComputer() {
|
||||
super();
|
||||
checkOverfill = false;
|
||||
this.inventory = new Inventory(3, "TileFusionControlComputer", 64, this);
|
||||
this.inventory = new Inventory<>(3, "TileFusionControlComputer", 64, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,7 +62,7 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
|
|||
super();
|
||||
recipes = GeneratorRecipeHelper.getFluidRecipesForGenerator(type);
|
||||
tank = new Tank(tileName, tankCapacity, this);
|
||||
inventory = new Inventory(3, tileName, 64, this);
|
||||
inventory = new Inventory<>(3, tileName, 64, this);
|
||||
this.euTick = euTick;
|
||||
this.ticksSinceLastChange = 0;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TileDragonEggSyphon extends TilePowerAcceptor
|
|||
@ConfigRegistry(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerEnergyPerTick", comment = "Dragon Egg Siphoner Energy Per Tick (Value in EU)")
|
||||
public static int energyPerTick = 4;
|
||||
|
||||
public Inventory inventory = new Inventory(3, "TileDragonEggSyphon", 64, this);
|
||||
public Inventory<TileDragonEggSyphon> inventory = new Inventory<>(3, "TileDragonEggSyphon", 64, this);
|
||||
private long lastOutput = 0;
|
||||
|
||||
public TileDragonEggSyphon() {
|
||||
|
|
|
@ -54,7 +54,7 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
|
|||
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorEnergyOutput", comment = "Solid Fuel Generator Energy Output Amount (Value in EU)")
|
||||
public static int outputAmount = 10;
|
||||
|
||||
public Inventory inventory = new Inventory(2, "TileSolidFuelGenerator", 64, this);
|
||||
public Inventory<TileSolidFuelGenerator> inventory = new Inventory<>(2, "TileSolidFuelGenerator", 64, this);
|
||||
public int fuelSlot = 0;
|
||||
public int burnTime;
|
||||
public int totalBurnTime = 0;
|
||||
|
|
|
@ -53,7 +53,7 @@ public class TileDistillationTower extends TileGenericMachine implements IContai
|
|||
super("DistillationTower", maxInput, maxEnergy, ModBlocks.DISTILLATION_TOWER, 6);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2, 3, 4, 5 };
|
||||
this.inventory = new Inventory(7, "TileDistillationTower", 64, this);
|
||||
this.inventory = new Inventory<>(7, "TileDistillationTower", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.DISTILLATION_TOWER_RECIPE, this, 2, 4, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,10 +28,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
import reborncore.common.util.IInventoryAccess;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.api.fluidreplicator.FluidReplicatorRecipeCrafter;
|
||||
|
@ -66,7 +68,7 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine
|
|||
public TileFluidReplicator() {
|
||||
super("FluidReplicator", maxInput, maxEnergy, ModBlocks.FLUID_REPLICATOR, 3);
|
||||
final int[] inputs = new int[] { 0 };
|
||||
this.inventory = new Inventory(4, "TileFluidReplicator", 64, this);
|
||||
this.inventory = new Inventory<>(4, "TileFluidReplicator", 64, this, getInventoryAccess());
|
||||
this.crafter = new FluidReplicatorRecipeCrafter(this, this.inventory, inputs, null);
|
||||
this.tank = new Tank("TileFluidReplicator", TileFluidReplicator.TANK_CAPACITY, this);
|
||||
}
|
||||
|
@ -123,17 +125,13 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
// TileLegacyMachineBase
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == 0) {
|
||||
if (itemStack.isItemEqual(TRIngredients.Parts.UU_MATTER.getStack())) {
|
||||
private static IInventoryAccess<TileFluidReplicator> getInventoryAccess(){
|
||||
return (slotID, stack, face, direction, tile) -> {
|
||||
if(slotID == 0){
|
||||
return stack.isItemEqual(TRIngredients.Parts.UU_MATTER.getStack());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.isItemValidForSlot(slotIndex, itemStack);
|
||||
};
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TileImplosionCompressor extends TileGenericMachine implements ICont
|
|||
super("ImplosionCompressor", maxInput, maxEnergy, ModBlocks.IMPLOSION_COMPRESSOR, 4);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2, 3 };
|
||||
this.inventory = new Inventory(5, "TileImplosionCompressor", 64, this);
|
||||
this.inventory = new Inventory<>(5, "TileImplosionCompressor", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.IMPLOSION_COMPRESSOR_RECIPE, this, 2, 2, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public class TileIndustrialBlastFurnace extends TileGenericMachine implements IC
|
|||
super("IndustrialBlastFurnace", maxInput, maxEnergy, ModBlocks.INDUSTRIAL_BLAST_FURNACE, 4);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2, 3 };
|
||||
this.inventory = new Inventory(5, "TileIndustrialBlastFurnace", 64, this);
|
||||
this.inventory = new Inventory<>(5, "TileIndustrialBlastFurnace", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.BLAST_FURNACE_RECIPE, this, 2, 2, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import reborncore.common.recipes.RecipeCrafter;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
import reborncore.common.util.IInventoryAccess;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.api.Reference;
|
||||
|
@ -48,6 +49,7 @@ import techreborn.client.container.IContainerProvider;
|
|||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.TRIngredients;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
||||
|
@ -70,7 +72,7 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
|
|||
super("IndustrialGrinder", maxInput, maxEnergy, ModBlocks.INDUSTRIAL_GRINDER, 7);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] {2, 3, 4, 5};
|
||||
this.inventory = new Inventory(8, "TileIndustrialGrinder", 64, this);
|
||||
this.inventory = new Inventory<>(8, "TileIndustrialGrinder", 64, this, getInventoryAccess());
|
||||
this.crafter = new RecipeCrafter(Reference.INDUSTRIAL_GRINDER_RECIPE, this, 1, 4, this.inventory, inputs, outputs);
|
||||
this.tank = new Tank("TileIndustrialGrinder", TileIndustrialGrinder.TANK_CAPACITY, this);
|
||||
this.ticksSinceLastChange = 0;
|
||||
|
@ -128,18 +130,13 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
// TileLegacyMachineBase
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == 1) {
|
||||
if (itemStack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)){
|
||||
private static IInventoryAccess<TileIndustrialGrinder> getInventoryAccess(){
|
||||
return (slotID, stack, face, direction, tile) -> {
|
||||
if(slotID == 1){
|
||||
return stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.isItemValidForSlot(slotIndex, itemStack);
|
||||
};
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
|
@ -39,6 +40,7 @@ import reborncore.common.recipes.RecipeCrafter;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
import reborncore.common.util.IInventoryAccess;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.api.Reference;
|
||||
|
@ -50,6 +52,7 @@ import techreborn.client.container.builder.ContainerBuilder;
|
|||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
import techreborn.tiles.tier1.TileAutoCraftingTable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -70,7 +73,7 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
|
|||
super("IndustrialSawmill", maxInput, maxEnergy, ModBlocks.INDUSTRIAL_SAWMILL, 6);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2, 3, 4 };
|
||||
this.inventory = new Inventory(7, "TileSawmill", 64, this);
|
||||
this.inventory = new Inventory<>(7, "TileSawmill", 64, this, getInventoryAccess());
|
||||
this.crafter = new RecipeCrafter(Reference.INDUSTRIAL_SAWMILL_RECIPE, this, 1, 3, this.inventory, inputs, outputs);
|
||||
this.tank = new Tank("TileSawmill", TileIndustrialSawmill.TANK_CAPACITY, this);
|
||||
this.ticksSinceLastChange = 0;
|
||||
|
@ -128,19 +131,16 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
// TileLegacyMachineBase
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == 1) {
|
||||
if (itemStack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
|
||||
private static IInventoryAccess<TileIndustrialSawmill> getInventoryAccess(){
|
||||
return (slotID, stack, face, direction, tile) -> {
|
||||
if(direction == IInventoryAccess.AccessDirection.INSERT){
|
||||
return stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.isItemValidForSlot(slotIndex, itemStack);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TileVacuumFreezer extends TileGenericMachine implements IContainerP
|
|||
super("VacuumFreezer", maxInput, maxEnergy, ModBlocks.VACUUM_FREEZER, 2);
|
||||
final int[] inputs = new int[] { 0 };
|
||||
final int[] outputs = new int[] { 1 };
|
||||
this.inventory = new Inventory(3, "TileVacuumFreezer", 64, this);
|
||||
this.inventory = new Inventory<>(3, "TileVacuumFreezer", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.VACUUM_FREEZER_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro
|
|||
@ConfigRegistry(config = "machines", category = "aesu", key = "AesuMaxEnergy", comment = "AESU Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 100_000_000;
|
||||
|
||||
public Inventory inventory = new Inventory(4, "TileAdjustableSU", 64, this);
|
||||
public Inventory<TileAdjustableSU> inventory = new Inventory<>(4, "TileAdjustableSU", 64, this);
|
||||
private int OUTPUT = 64; // The current output
|
||||
|
||||
public TileAdjustableSU() {
|
||||
|
|
|
@ -54,7 +54,7 @@ public class TileEnergyStorage extends TilePowerAcceptor
|
|||
|
||||
public TileEnergyStorage(String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage) {
|
||||
super();
|
||||
inventory = new Inventory(invSize, "Tile" + name, 64, this);
|
||||
inventory = new Inventory<>(invSize, "Tile" + name, 64, this);
|
||||
this.wrenchDrop = wrenchDrop;
|
||||
this.tier = tier;
|
||||
this.name = name;
|
||||
|
|
|
@ -53,7 +53,7 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
|||
implements IToolDrop, ItemHandlerProvider, IContainerProvider {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(4, "TileIronAlloyFurnace", 64, this);
|
||||
public Inventory<TileIronAlloyFurnace> inventory = new Inventory<>(4, "TileIronAlloyFurnace", 64, this);
|
||||
public int burnTime;
|
||||
public int currentItemBurnTime;
|
||||
public int cookTime;
|
||||
|
|
|
@ -29,9 +29,11 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.tile.ItemHandlerProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.common.util.IInventoryAccess;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
|
@ -42,7 +44,7 @@ public class TileIronFurnace extends TileLegacyMachineBase
|
|||
implements ItemHandlerProvider, IContainerProvider {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(3, "TileIronFurnace", 64, this);
|
||||
public Inventory<TileIronFurnace> inventory = new Inventory<>(3, "TileIronFurnace", 64, this, getInvetoryAccess());
|
||||
public int fuel;
|
||||
public int fuelGague;
|
||||
public int progress;
|
||||
|
@ -168,16 +170,20 @@ public class TileIronFurnace extends TileLegacyMachineBase
|
|||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
public static IInventoryAccess<TileIronFurnace> getInvetoryAccess(){
|
||||
return (slotID, stack, face, direction, tile) -> {
|
||||
if(direction == IInventoryAccess.AccessDirection.INSERT){
|
||||
boolean isFuel = TileEntityFurnace.isItemFuel(stack);
|
||||
if(isFuel){
|
||||
ItemStack fuelSlotStack = inventory.getStackInSlot(fuelslot);
|
||||
ItemStack fuelSlotStack = tile.inventory.getStackInSlot(tile.fuelslot);
|
||||
if(fuelSlotStack.isEmpty() || ItemUtils.isItemEqual(stack, fuelSlotStack, true, true) && fuelSlotStack.getMaxStackSize() != fuelSlotStack.getCount()){
|
||||
return index == fuelslot;
|
||||
return slotID == tile.fuelslot;
|
||||
}
|
||||
}
|
||||
return index != output;
|
||||
return slotID != tile.output;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public int getBurnTime() {
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TileAlloySmelter extends TileGenericMachine implements IContainerPr
|
|||
super("AlloySmelter", maxInput, maxEnergy, ModBlocks.ALLOY_SMELTER, 3);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2 };
|
||||
this.inventory = new Inventory(4, "TileAlloySmelter", 64, this);
|
||||
this.inventory = new Inventory<>(4, "TileAlloySmelter", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.ALLOY_SMELTER_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TileAssemblingMachine extends TileGenericMachine implements IContai
|
|||
super("AssemblingMachine", maxInput, maxEnergy, ModBlocks.ASSEMBLY_MACHINE, 3);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2 };
|
||||
this.inventory = new Inventory(4, "TileAssemblingMachine", 64, this);
|
||||
this.inventory = new Inventory<>(4, "TileAssemblingMachine", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.ASSEMBLING_MACHINE_RECIPE, this, 2, 2, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ import reborncore.api.tile.ItemHandlerProvider;
|
|||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.common.util.IInventoryAccess;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
|
@ -66,7 +68,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
@ConfigRegistry(config = "machines", category = "autocrafter", key = "AutoCrafterMaxEnergy", comment = "AutoCrafting Table Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 10_000;
|
||||
|
||||
public Inventory inventory = new Inventory(11, "TileAutoCraftingTable", 64, this);
|
||||
public Inventory<TileAutoCraftingTable> inventory = new Inventory<>(11, "TileAutoCraftingTable", 64, this, getInventoryAccess());
|
||||
public int progress;
|
||||
public int maxProgress = 120;
|
||||
public int euTick = 10;
|
||||
|
@ -396,38 +398,23 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
int bestSlot = findBestSlotForStack(getIRecipe(), stack);
|
||||
if (bestSlot != -1) {
|
||||
return index == bestSlot;
|
||||
}
|
||||
return super.isItemValidForSlot(index, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
if (index > 8) {
|
||||
private static IInventoryAccess<TileAutoCraftingTable> getInventoryAccess(){
|
||||
return (slotID, stack, facing, direction, tile) -> {
|
||||
switch (direction){
|
||||
case INSERT:
|
||||
if (slotID > 8) {
|
||||
return false;
|
||||
}
|
||||
int bestSlot = findBestSlotForStack(getIRecipe(), stack);
|
||||
int bestSlot = tile.findBestSlotForStack(tile.getIRecipe(), stack);
|
||||
if (bestSlot != -1) {
|
||||
return index == bestSlot;
|
||||
return slotID == bestSlot;
|
||||
}
|
||||
return true;
|
||||
case EXTRACT:
|
||||
return slotID > 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
if (index > 8) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
// This machine doesnt have a facing
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TileChemicalReactor extends TileGenericMachine implements IContaine
|
|||
super("ChemicalReactor", maxInput, maxEnergy, ModBlocks.CHEMICAL_REACTOR, 3);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2 };
|
||||
this.inventory = new Inventory(4, "TileChemicalReactor", 64, this);
|
||||
this.inventory = new Inventory<>(4, "TileChemicalReactor", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.CHEMICAL_REACTOR_RECIPE, this, 2, 2, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TileCompressor extends TileGenericMachine implements IContainerProv
|
|||
super("Compressor", maxInput, maxEnergy, ModBlocks.COMPRESSOR, 2);
|
||||
final int[] inputs = new int[] { 0 };
|
||||
final int[] outputs = new int[] { 1 };
|
||||
this.inventory = new Inventory(3, "TileCompressor", 64, this);
|
||||
this.inventory = new Inventory<>(3, "TileCompressor", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.COMPRESSOR_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
|||
@ConfigRegistry(config = "machines", category = "electric_furnace", key = "ElectricFurnaceMaxEnergy", comment = "Electric Furnace Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 1000;
|
||||
|
||||
public Inventory inventory = new Inventory(3, "TileElectricFurnace", 64, this);
|
||||
public Inventory<TileElectricFurnace> inventory = new Inventory<>(3, "TileElectricFurnace", 64, this);
|
||||
public int progress;
|
||||
public int fuelScale = 100;
|
||||
public int cost = 6;
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TileExtractor extends TileGenericMachine implements IContainerProvi
|
|||
super("Extractor", maxInput, maxEnergy, ModBlocks.EXTRACTOR, 2);
|
||||
final int[] inputs = new int[] { 0 };
|
||||
final int[] outputs = new int[] { 1 };
|
||||
this.inventory = new Inventory(3, "TileExtractor", 64, this);
|
||||
this.inventory = new Inventory<>(3, "TileExtractor", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.EXTRACTOR_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TileGrinder extends TileGenericMachine implements IContainerProvide
|
|||
super("Grinder", maxInput, maxEnergy, ModBlocks.GRINDER, 2);
|
||||
final int[] inputs = new int[] { 0 };
|
||||
final int[] outputs = new int[] { 1 };
|
||||
this.inventory = new Inventory(3, "TileGrinder", 64, this);
|
||||
this.inventory = new Inventory<>(3, "TileGrinder", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.GRINDER_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TileIndustrialElectrolyzer extends TileGenericMachine implements IC
|
|||
super("IndustrialElectrolyzer", maxInput, maxEnergy, ModBlocks.INDUSTRIAL_ELECTROLYZER, 6);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2, 3, 4, 5 };
|
||||
this.inventory = new Inventory(7, "TileIndustrialElectrolyzer", 64, this);
|
||||
this.inventory = new Inventory<>(7, "TileIndustrialElectrolyzer", 64, this);
|
||||
this.crafter = new RecipeCrafter(Reference.INDUSTRIAL_ELECTROLYZER_RECIPE, this, 2, 4, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TileRecycler extends TilePowerAcceptor
|
|||
@ConfigRegistry(config = "machines", category = "recycler", key = "RecyclerMaxEnergy", comment = "Recycler Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 1000;
|
||||
|
||||
private final Inventory inventory = new Inventory(3, "TileRecycler", 64, this);
|
||||
private final Inventory inventory = new Inventory<>(3, "TileRecycler", 64, this);
|
||||
private final int cost = 2;
|
||||
private final int time = 15;
|
||||
private final int chance = 6;
|
||||
|
|
|
@ -69,7 +69,7 @@ public class TileRollingMachine extends TilePowerAcceptor
|
|||
|
||||
public int[] craftingSlots = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
private InventoryCrafting craftCache;
|
||||
public Inventory inventory = new Inventory(12, "TileRollingMachine", 64, this);
|
||||
public Inventory<TileRollingMachine> inventory = new Inventory<>(12, "TileRollingMachine", 64, this);
|
||||
public boolean isRunning;
|
||||
public int tickTime;
|
||||
@Nonnull
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TileScrapboxinator extends TileGenericMachine implements IContainer
|
|||
super("Scrapboxinator", maxInput, maxEnergy, ModBlocks.SCRAPBOXINATOR, 2);
|
||||
final int[] inputs = new int[] { 0 };
|
||||
final int[] outputs = new int[] { 1 };
|
||||
this.inventory = new Inventory(3, "TileScrapboxinator", 64, this);
|
||||
this.inventory = new Inventory<>(3, "TileScrapboxinator", 64, this);
|
||||
this.crafter = new ScrapboxRecipeCrafter(this, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue