Add convenient energy sync method to builder + Convert MFE + Fix slots range again
This commit is contained in:
parent
28c4932ef6
commit
e7eaa40bde
7 changed files with 154 additions and 236 deletions
|
@ -5,8 +5,10 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
|
||||
import reborncore.api.tile.IContainerLayout;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
|
||||
import techreborn.client.container.*;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import techreborn.client.gui.*;
|
||||
|
@ -65,17 +67,17 @@ public class GuiHandler implements IGuiHandler {
|
|||
public static final int mfeID = 41;
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
public Object getServerGuiElement(final int ID, final EntityPlayer player, final World world, final int x, final int y, final int z) {
|
||||
RebornContainer container = null;
|
||||
if (ID == thermalGeneratorID) {
|
||||
if (ID == GuiHandler.thermalGeneratorID) {
|
||||
return new ContainerThermalGenerator((TileThermalGenerator) world.getTileEntity(new BlockPos(x, y, z)),
|
||||
player);
|
||||
} else if (ID == semifluidGeneratorID) {
|
||||
player);
|
||||
} else if (ID == GuiHandler.semifluidGeneratorID) {
|
||||
return new ContainerSemifluidGenerator((TileSemifluidGenerator) world.getTileEntity(new BlockPos(x, y, z)),
|
||||
player);
|
||||
} else if (ID == gasTurbineID) {
|
||||
player);
|
||||
} else if (ID == GuiHandler.gasTurbineID) {
|
||||
return new ContainerGasTurbine((TileGasTurbine) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == quantumTankID) {
|
||||
} else if (ID == GuiHandler.quantumTankID) {
|
||||
return new ContainerQuantumTank((TileQuantumTank) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == GuiHandler.digitalChestID || ID == GuiHandler.quantumChestID) {
|
||||
return new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory()
|
||||
|
@ -83,91 +85,90 @@ public class GuiHandler implements IGuiHandler {
|
|||
.fakeSlot(2, 59, 42).addInventory().create();
|
||||
} else if (ID == GuiHandler.centrifugeID) {
|
||||
container = new ContainerCentrifuge(player, (TileCentrifuge) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == rollingMachineID) {
|
||||
} else if (ID == GuiHandler.rollingMachineID) {
|
||||
return new ContainerRollingMachine((TileRollingMachine) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == blastFurnaceID) {
|
||||
} else if (ID == GuiHandler.blastFurnaceID) {
|
||||
return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == alloySmelterID) {
|
||||
} else if (ID == GuiHandler.alloySmelterID) {
|
||||
container = new ContainerAlloySmelter(player, (TileAlloySmelter) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == industrialGrinderID) {
|
||||
} else if (ID == GuiHandler.industrialGrinderID) {
|
||||
return new ContainerIndustrialGrinder((TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)),
|
||||
player);
|
||||
} else if (ID == implosionCompresserID) {
|
||||
player);
|
||||
} else if (ID == GuiHandler.implosionCompresserID) {
|
||||
return new ContainerImplosionCompressor(
|
||||
(TileImplosionCompressor) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == matterfabID) {
|
||||
(TileImplosionCompressor) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == GuiHandler.matterfabID) {
|
||||
return new ContainerMatterFabricator((TileMatterFabricator) world.getTileEntity(new BlockPos(x, y, z)),
|
||||
player);
|
||||
} else if (ID == assemblingmachineID) {
|
||||
player);
|
||||
} else if (ID == GuiHandler.assemblingmachineID) {
|
||||
container = new ContainerAssemblingMachine(player, (TileAssemblingMachine) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == GuiHandler.chunkloaderID) {
|
||||
return new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory()
|
||||
.create();
|
||||
} else if (ID == dieselGeneratorID) {
|
||||
} else if (ID == GuiHandler.dieselGeneratorID) {
|
||||
return new ContainerDieselGenerator((TileDieselGenerator) world.getTileEntity(new BlockPos(x, y, z)),
|
||||
player);
|
||||
} else if (ID == industrialElectrolyzerID) {
|
||||
player);
|
||||
} else if (ID == GuiHandler.industrialElectrolyzerID) {
|
||||
return new ContainerIndustrialElectrolyzer(
|
||||
(TileIndustrialElectrolyzer) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == aesuID) {
|
||||
(TileIndustrialElectrolyzer) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == GuiHandler.aesuID) {
|
||||
return new ContainerAESU((TileAesu) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == alloyFurnaceID) {
|
||||
} else if (ID == GuiHandler.alloyFurnaceID) {
|
||||
return new ContainerAlloyFurnace((TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == sawMillID) {
|
||||
} else if (ID == GuiHandler.sawMillID) {
|
||||
return new ContainerIndustrialSawmill((TileIndustrialSawmill) world.getTileEntity(new BlockPos(x, y, z)),
|
||||
player);
|
||||
} else if (ID == chemicalReactorID) {
|
||||
player);
|
||||
} else if (ID == GuiHandler.chemicalReactorID) {
|
||||
return new ContainerChemicalReactor((TileChemicalReactor) world.getTileEntity(new BlockPos(x, y, z)),
|
||||
player);
|
||||
} else if (ID == manuelID) {
|
||||
player);
|
||||
} else if (ID == GuiHandler.manuelID) {
|
||||
return null;
|
||||
} else if (ID == destructoPackID) {
|
||||
} else if (ID == GuiHandler.destructoPackID) {
|
||||
return new ContainerDestructoPack(player);
|
||||
} else if (ID == lesuID) {
|
||||
} else if (ID == GuiHandler.lesuID) {
|
||||
return new ContainerLESU((TileLesu) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == idsuID) {
|
||||
} else if (ID == GuiHandler.idsuID) {
|
||||
return new ContainerIDSU((TileIDSU) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == fusionID) {
|
||||
} else if (ID == GuiHandler.fusionID) {
|
||||
return new ContainerFusionReactor((TileEntityFusionController) world.getTileEntity(new BlockPos(x, y, z)),
|
||||
player);
|
||||
} else if (ID == GuiHandler.chargeBench) {
|
||||
return new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory()
|
||||
return new ContainerBuilder().player(player.inventory).inventory().hotbar(8, 142).addInventory()
|
||||
.tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).energySlot(0, 62, 21)
|
||||
.energySlot(1, 80, 21).energySlot(2, 98, 21).energySlot(3, 62, 39).energySlot(4, 80, 39)
|
||||
.energySlot(5, 98, 39)
|
||||
.syncIntegerValue(
|
||||
() -> (int) ((TileChargeBench) world.getTileEntity(new BlockPos(x, y, z))).getEnergy(),
|
||||
((TileChargeBench) world.getTileEntity(new BlockPos(x, y, z)))::setEnergy)
|
||||
.addInventory().create();
|
||||
} else if (ID == vacuumFreezerID) {
|
||||
.energySlot(5, 98, 39).syncEnergyValue().addInventory().create();
|
||||
} else if (ID == GuiHandler.vacuumFreezerID) {
|
||||
return new ContainerVacuumFreezer((TileVacuumFreezer) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == grinderID) {
|
||||
} else if (ID == GuiHandler.grinderID) {
|
||||
container = new ContainerGrinder(player, (TileGrinder) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == generatorID) {
|
||||
} else if (ID == GuiHandler.generatorID) {
|
||||
return new ContainerGenerator((TileGenerator) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == extractorID) {
|
||||
} else if (ID == GuiHandler.extractorID) {
|
||||
container = new ContainerExtractor(player, (TileExtractor) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == compressorID) {
|
||||
} else if (ID == GuiHandler.compressorID) {
|
||||
return new ContainerCompressor((TileCompressor) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == electricFurnaceID) {
|
||||
} else if (ID == GuiHandler.electricFurnaceID) {
|
||||
return new ContainerElectricFurnace((TileElectricFurnace) world.getTileEntity(new BlockPos(x, y, z)),
|
||||
player);
|
||||
} else if (ID == ironFurnace) {
|
||||
player);
|
||||
} else if (ID == GuiHandler.ironFurnace) {
|
||||
return new ContainerIronFurnace((TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == recyclerID) {
|
||||
} else if (ID == GuiHandler.recyclerID) {
|
||||
return new ContainerRecycler((TileRecycler) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == scrapboxinatorID) {
|
||||
} else if (ID == GuiHandler.scrapboxinatorID) {
|
||||
return new ContainerScrapboxinator((TileScrapboxinator) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == batboxID) {
|
||||
} else if (ID == GuiHandler.batboxID) {
|
||||
return new ContainerBatbox((TileBatBox) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == mfsuID) {
|
||||
} else if (ID == GuiHandler.mfsuID) {
|
||||
return new ContainerMFSU((TileMFSU) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == mfeID) {
|
||||
return new ContainerMFE((TileMFE) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
} else if (ID == GuiHandler.mfeID) {
|
||||
return new ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).armor()
|
||||
.complete(44, 6).addArmor().addInventory()
|
||||
.tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).energySlot(0, 80, 17)
|
||||
.energySlot(1, 80, 53).syncEnergyValue().addInventory().create();
|
||||
}
|
||||
if (container != null) {
|
||||
if (container instanceof IContainerLayout) {
|
||||
IContainerLayout layout = (IContainerLayout) container;
|
||||
final IContainerLayout layout = (IContainerLayout) container;
|
||||
layout.setTile(world.getTileEntity(new BlockPos(x, y, z)));
|
||||
layout.setPlayer(player);
|
||||
layout.addInventorySlots();
|
||||
|
@ -179,88 +180,88 @@ public class GuiHandler implements IGuiHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (ID == thermalGeneratorID) {
|
||||
public Object getClientGuiElement(final int ID, final EntityPlayer player, final World world, final int x, final int y, final int z) {
|
||||
if (ID == GuiHandler.thermalGeneratorID) {
|
||||
return new GuiThermalGenerator(player, (TileThermalGenerator) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == semifluidGeneratorID) {
|
||||
} else if (ID == GuiHandler.semifluidGeneratorID) {
|
||||
return new GuiSemifluidGenerator(player,
|
||||
(TileSemifluidGenerator) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == gasTurbineID) {
|
||||
(TileSemifluidGenerator) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == GuiHandler.gasTurbineID) {
|
||||
return new GuiGasTurbine(player, (TileGasTurbine) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == quantumTankID) {
|
||||
} else if (ID == GuiHandler.quantumTankID) {
|
||||
return new GuiQuantumTank(player, (TileQuantumTank) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == digitalChestID) {
|
||||
} else if (ID == GuiHandler.digitalChestID) {
|
||||
return new GuiDigitalChest(player, (TileDigitalChest) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == quantumChestID) {
|
||||
} else if (ID == GuiHandler.quantumChestID) {
|
||||
return new GuiQuantumChest(player, (TileQuantumChest) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == centrifugeID) {
|
||||
} else if (ID == GuiHandler.centrifugeID) {
|
||||
return new GuiCentrifuge(player, (TileCentrifuge) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == rollingMachineID) {
|
||||
} else if (ID == GuiHandler.rollingMachineID) {
|
||||
return new GuiRollingMachine(player, (TileRollingMachine) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == blastFurnaceID) {
|
||||
} else if (ID == GuiHandler.blastFurnaceID) {
|
||||
return new GuiBlastFurnace(player, (TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == alloySmelterID) {
|
||||
} else if (ID == GuiHandler.alloySmelterID) {
|
||||
return new GuiAlloySmelter(player, (TileAlloySmelter) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == industrialGrinderID) {
|
||||
} else if (ID == GuiHandler.industrialGrinderID) {
|
||||
return new GuiIndustrialGrinder(player, (TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == implosionCompresserID) {
|
||||
} else if (ID == GuiHandler.implosionCompresserID) {
|
||||
return new GuiImplosionCompressor(player,
|
||||
(TileImplosionCompressor) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == matterfabID) {
|
||||
(TileImplosionCompressor) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == GuiHandler.matterfabID) {
|
||||
return new GuiMatterFabricator(player, (TileMatterFabricator) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == chunkloaderID) {
|
||||
} else if (ID == GuiHandler.chunkloaderID) {
|
||||
return new GuiChunkLoader(player, (TileChunkLoader) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == assemblingmachineID) {
|
||||
} else if (ID == GuiHandler.assemblingmachineID) {
|
||||
return new GuiAssemblingMachine(player, (TileAssemblingMachine) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == dieselGeneratorID) {
|
||||
} else if (ID == GuiHandler.dieselGeneratorID) {
|
||||
return new GuiDieselGenerator(player, (TileDieselGenerator) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == industrialElectrolyzerID) {
|
||||
} else if (ID == GuiHandler.industrialElectrolyzerID) {
|
||||
return new GuiIndustrialElectrolyzer(player,
|
||||
(TileIndustrialElectrolyzer) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == aesuID) {
|
||||
(TileIndustrialElectrolyzer) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == GuiHandler.aesuID) {
|
||||
return new GuiAESU(player, (TileAesu) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == alloyFurnaceID) {
|
||||
} else if (ID == GuiHandler.alloyFurnaceID) {
|
||||
return new GuiAlloyFurnace(player, (TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == sawMillID) {
|
||||
} else if (ID == GuiHandler.sawMillID) {
|
||||
return new GuiIndustrialSawmill(player, (TileIndustrialSawmill) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == chemicalReactorID) {
|
||||
} else if (ID == GuiHandler.chemicalReactorID) {
|
||||
return new GuiChemicalReactor(player, (TileChemicalReactor) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == manuelID) {
|
||||
} else if (ID == GuiHandler.manuelID) {
|
||||
return new GuiManual();
|
||||
} else if (ID == destructoPackID) {
|
||||
} else if (ID == GuiHandler.destructoPackID) {
|
||||
return new GuiDestructoPack(new ContainerDestructoPack(player));
|
||||
} else if (ID == lesuID) {
|
||||
} else if (ID == GuiHandler.lesuID) {
|
||||
return new GuiLESU(player, (TileLesu) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == idsuID) {
|
||||
} else if (ID == GuiHandler.idsuID) {
|
||||
return new GuiIDSU(player, (TileIDSU) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == chargeBench) {
|
||||
} else if (ID == GuiHandler.chargeBench) {
|
||||
return new GuiChargeBench(player, (TileChargeBench) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == fusionID) {
|
||||
} else if (ID == GuiHandler.fusionID) {
|
||||
return new GuiFusionReactor(player,
|
||||
(TileEntityFusionController) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == vacuumFreezerID) {
|
||||
(TileEntityFusionController) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == GuiHandler.vacuumFreezerID) {
|
||||
return new GuiVacuumFreezer(player, (TileVacuumFreezer) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == grinderID) {
|
||||
} else if (ID == GuiHandler.grinderID) {
|
||||
return new GuiGrinder(player, (TileGrinder) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == generatorID) {
|
||||
} else if (ID == GuiHandler.generatorID) {
|
||||
return new GuiGenerator(player, (TileGenerator) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == extractorID) {
|
||||
} else if (ID == GuiHandler.extractorID) {
|
||||
return new GuiExtractor(player, (TileExtractor) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == compressorID) {
|
||||
} else if (ID == GuiHandler.compressorID) {
|
||||
return new GuiCompressor(player, (TileCompressor) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == electricFurnaceID) {
|
||||
} else if (ID == GuiHandler.electricFurnaceID) {
|
||||
return new GuiElectricFurnace(player, (TileElectricFurnace) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == ironFurnace) {
|
||||
} else if (ID == GuiHandler.ironFurnace) {
|
||||
return new GuiIronFurnace(player, (TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == recyclerID) {
|
||||
} else if (ID == GuiHandler.recyclerID) {
|
||||
return new GuiRecycler(player, (TileRecycler) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == scrapboxinatorID) {
|
||||
} else if (ID == GuiHandler.scrapboxinatorID) {
|
||||
return new GuiScrapboxinator(player, (TileScrapboxinator) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == batboxID) {
|
||||
} else if (ID == GuiHandler.batboxID) {
|
||||
return new GuiBatbox(player, (TileBatBox) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == mfsuID) {
|
||||
} else if (ID == GuiHandler.mfsuID) {
|
||||
return new GuiMFSU(player, (TileMFSU) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
} else if (ID == mfeID) {
|
||||
} else if (ID == GuiHandler.mfeID) {
|
||||
return new GuiMFE(player, (TileMFE) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
/**
|
||||
* Created by Rushmead
|
||||
*/
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.slots.BaseSlot;
|
||||
import reborncore.client.gui.slots.SlotCharge;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.storage.TileMFE;
|
||||
|
||||
public class ContainerMFE extends RebornContainer {
|
||||
|
||||
public int burnTime = 0;
|
||||
public int totalBurnTime = 0;
|
||||
public int energy;
|
||||
public int tickTime;
|
||||
EntityPlayer player;
|
||||
TileMFE tile;
|
||||
private static final EntityEquipmentSlot[] equipmentSlots = new EntityEquipmentSlot[] { EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET };
|
||||
|
||||
public ContainerMFE(TileMFE tile, EntityPlayer player) {
|
||||
super();
|
||||
this.tile = tile;
|
||||
this.player = player;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
for (int k = 0; k < 4; k++) {
|
||||
final EntityEquipmentSlot slot = equipmentSlots[k];
|
||||
addSlotToContainer(new BaseSlot(player.inventory, player.inventory.getSizeInventory() - 2 - k, 44, 6 + k * 19) {
|
||||
@Override
|
||||
public int getSlotStackLimit() { return 1; }
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack != null && stack.getItem().isValidArmor(stack, slot, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.listeners.size(); i++) {
|
||||
IContainerListener IContainerListener = this.listeners.get(i);
|
||||
if (this.energy != (int) tile.getEnergy()) {
|
||||
IContainerListener.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IContainerListener crafting) {
|
||||
super.addListener(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
if (id == 0) {
|
||||
this.burnTime = value;
|
||||
} else if (id == 1) {
|
||||
this.totalBurnTime = value;
|
||||
} else if (id == 2) {
|
||||
this.energy = value;
|
||||
}
|
||||
this.tile.setEnergy(energy);
|
||||
}
|
||||
|
||||
public int getScaledBurnTime(int i) {
|
||||
return (int) (((float) burnTime / (float) totalBurnTime) * i);
|
||||
}
|
||||
}
|
|
@ -231,14 +231,14 @@ final class BuiltContainer extends Container {
|
|||
|
||||
private boolean shiftToTile(final ItemStack stackToShift) {
|
||||
for (final Range<Integer> range : this.tileSlotRanges)
|
||||
if (this.shiftItemStack(stackToShift, range.getMinimum(), range.getMaximum()))
|
||||
if (this.shiftItemStack(stackToShift, range.getMinimum(), range.getMaximum() + 1))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean shiftToPlayer(final ItemStack stackToShift) {
|
||||
for (final Range<Integer> range : this.playerSlotRanges)
|
||||
if (this.shiftItemStack(stackToShift, range.getMinimum(), range.getMaximum()))
|
||||
if (this.shiftItemStack(stackToShift, range.getMinimum(), range.getMaximum() + 1))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public final class ContainerPlayerInventoryBuilder {
|
|||
for (int i = 0; i < 3; ++i)
|
||||
for (int j = 0; j < 9; ++j)
|
||||
this.parent.slots.add(new BaseSlot(this.player, j + i * 9 + 9, xStart + j * 18, yStart + i * 18));
|
||||
this.main = Range.between(startIndex, this.parent.slots.size());
|
||||
this.main = Range.between(startIndex, this.parent.slots.size() - 1);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public final class ContainerPlayerInventoryBuilder {
|
|||
final int startIndex = this.parent.slots.size();
|
||||
for (int i = 0; i < 9; ++i)
|
||||
this.parent.slots.add(new BaseSlot(this.player, i, xStart + i * 18, yStart));
|
||||
this.hotbar = Range.between(startIndex, this.parent.slots.size());
|
||||
this.hotbar = Range.between(startIndex, this.parent.slots.size() - 1);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public final class ContainerPlayerInventoryBuilder {
|
|||
}
|
||||
|
||||
public ContainerPlayerInventoryBuilder addArmor() {
|
||||
this.parent.armor = Range.between(this.startIndex, this.parent.parent.slots.size());
|
||||
this.parent.armor = Range.between(this.startIndex, this.parent.parent.slots.size() - 1);
|
||||
return this.parent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ import reborncore.api.power.IEnergyInterfaceItem;
|
|||
import reborncore.client.gui.slots.BaseSlot;
|
||||
import reborncore.client.gui.slots.SlotFake;
|
||||
import reborncore.client.gui.slots.SlotOutput;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
|
||||
import techreborn.Core;
|
||||
import techreborn.client.container.builder.slot.FilteredSlot;
|
||||
|
||||
import java.util.function.IntConsumer;
|
||||
|
@ -78,8 +80,16 @@ public class ContainerTileInventoryBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder syncEnergyValue() {
|
||||
if (this.tile instanceof TilePowerAcceptor)
|
||||
return this.syncIntegerValue(() -> (int) ((TilePowerAcceptor) this.tile).getEnergy(),
|
||||
((TilePowerAcceptor) this.tile)::setEnergy);
|
||||
Core.logHelper.error(this.tile + " is not an instance of TilePowerAcceptor! Energy cannot be synced.");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerBuilder addInventory() {
|
||||
this.parent.tileInventoryRanges.add(Range.between(this.rangeStart, this.parent.slots.size()));
|
||||
this.parent.tileInventoryRanges.add(Range.between(this.rangeStart, this.parent.slots.size() - 1));
|
||||
return this.parent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import techreborn.tiles.TileChargeBench;
|
||||
|
||||
|
@ -15,43 +16,43 @@ public class GuiChargeBench extends GuiContainer {
|
|||
TileChargeBench chargebench;
|
||||
|
||||
public GuiChargeBench(final EntityPlayer player, final TileChargeBench tile) {
|
||||
super(new ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 152).addInventory().tile(tile)
|
||||
super(new ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory().tile(tile)
|
||||
.energySlot(0, 62, 21).energySlot(1, 80, 21).energySlot(2, 98, 21).energySlot(3, 62, 39).energySlot(4, 80, 39)
|
||||
.energySlot(5, 98, 39).syncIntegerValue(() -> (int) tile.getEnergy(), tile::setEnergy).addInventory()
|
||||
.create());
|
||||
.energySlot(5, 98, 39).syncEnergyValue().addInventory().create());
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
chargebench = tile;
|
||||
this.chargebench = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
final int k = (this.width - this.xSize) / 2;
|
||||
final int l = (this.height - this.ySize) / 2;
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.mc.getTextureManager().bindTexture(GuiChargeBench.texture);
|
||||
final int k = (this.width - this.xSize) / 2;
|
||||
final int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int j = 0;
|
||||
|
||||
j = chargebench.getEnergyScaled(12);
|
||||
j = this.chargebench.getEnergyScaled(12);
|
||||
if (j > 0) {
|
||||
this.drawTexturedModalRect(k + 10, l + 32 + 12 - j, 176, 12 - j, 14, j + 2);
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
String name = I18n.translateToLocal("tile.techreborn.chargebench.name");
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
|
||||
final String name = I18n.translateToLocal("tile.techreborn.chargebench.name");
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
|
||||
4210752);
|
||||
4210752);
|
||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@ import net.minecraft.client.gui.inventory.GuiContainer;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.client.container.ContainerMFE;
|
||||
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import techreborn.tiles.storage.TileMFE;
|
||||
|
||||
/**
|
||||
|
@ -17,33 +19,33 @@ public class GuiMFE extends GuiContainer {
|
|||
|
||||
TileMFE generator;
|
||||
|
||||
ContainerMFE containerGenerator;
|
||||
|
||||
public GuiMFE(EntityPlayer player, TileMFE generator) {
|
||||
super(new ContainerMFE(generator, player));
|
||||
public GuiMFE(final EntityPlayer player, final TileMFE generator) {
|
||||
super(new ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).armor().complete(44, 6)
|
||||
.addArmor().addInventory().tile(generator).energySlot(0, 80, 17).energySlot(1, 80, 53).syncEnergyValue()
|
||||
.addInventory().create());
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
this.generator = generator;
|
||||
this.containerGenerator = (ContainerMFE) this.inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
final int k = (this.width - this.xSize) / 2;
|
||||
final int l = (this.height - this.ySize) / 2;
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
|
||||
this.mc.getTextureManager().bindTexture(GuiMFE.texture);
|
||||
final int k = (this.width - this.xSize) / 2;
|
||||
final int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int j = 0;
|
||||
|
||||
j = generator.getEnergyScaled(24);
|
||||
j = this.generator.getEnergyScaled(24);
|
||||
if (j > 0) {
|
||||
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
|
||||
}
|
||||
|
@ -56,16 +58,18 @@ public class GuiMFE extends GuiContainer {
|
|||
// }
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
String name = I18n.translateToLocal("tile.techreborn.mfe.name");
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
|
||||
final String name = I18n.translateToLocal("tile.techreborn.mfe.name");
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
|
||||
4210752);
|
||||
4210752);
|
||||
|
||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(generator.getMaxPower()), 110, this.ySize - 150,
|
||||
4210752);
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 110, this.ySize - 160,
|
||||
4210752);
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.generator.getMaxPower()), 110, this.ySize - 150,
|
||||
4210752);
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.generator.getEnergy()), 110,
|
||||
this.ySize - 160,
|
||||
4210752);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue