Merge branch 'feature/containers-builder' of https://github.com/TechReborn/TechReborn into feature/containers-builder

# Conflicts:
#	src/main/java/techreborn/client/gui/GuiBatbox.java
#	src/main/java/techreborn/client/gui/GuiQuantumChest.java
This commit is contained in:
ProfessorProspector 2017-01-07 20:22:34 -08:00
commit 0cccb0a91b
47 changed files with 915 additions and 1452 deletions

View file

@ -67,30 +67,34 @@ public class GuiHandler implements IGuiHandler {
public static final int mfeID = 41;
@Override
public Object getServerGuiElement(final int ID, final EntityPlayer player, final World world, final int x, final int y, final 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 == GuiHandler.thermalGeneratorID) {
return new ContainerThermalGenerator((TileThermalGenerator) world.getTileEntity(new BlockPos(x, y, z)),
player);
} else if (ID == GuiHandler.semifluidGeneratorID) {
return new ContainerSemifluidGenerator((TileSemifluidGenerator) world.getTileEntity(new BlockPos(x, y, z)),
player);
} else if (ID == GuiHandler.gasTurbineID) {
return new ContainerGasTurbine((TileGasTurbine) world.getTileEntity(new BlockPos(x, y, z)), player);
if (ID == GuiHandler.gasTurbineID || ID == GuiHandler.semifluidGeneratorID
|| ID == GuiHandler.thermalGeneratorID || ID == GuiHandler.dieselGeneratorID) {
return new ContainerBuilder("fluidgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 80, 17)
.outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue().addInventory().create();
} 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()
return new ContainerBuilder("digitalchest").player(player.inventory).inventory().hotbar().addInventory()
.tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 80, 17).outputSlot(1, 80, 53)
.fakeSlot(2, 59, 42).addInventory().create();
} else if (ID == GuiHandler.centrifugeID) {
container = new ContainerCentrifuge(player, (TileCentrifuge) world.getTileEntity(new BlockPos(x, y, z)));
return new ContainerBuilder("centrifuge").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 80, 35)
.slot(1, 50, 5).outputSlot(2, 80, 5).outputSlot(3, 110, 35).outputSlot(4, 80, 65)
.outputSlot(5, 50, 35).energySlot(6, 8, 51).upgradeSlot(7, 152, 8).upgradeSlot(8, 152, 26)
.upgradeSlot(9, 152, 44).upgradeSlot(10, 152, 62).syncEnergyValue().syncCrafterValue()
.addInventory().create();
} else if (ID == GuiHandler.rollingMachineID) {
return new ContainerRollingMachine((TileRollingMachine) world.getTileEntity(new BlockPos(x, y, z)), player);
} else if (ID == GuiHandler.blastFurnaceID) {
return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z)), player);
} else if (ID == GuiHandler.alloySmelterID) {
container = new ContainerAlloySmelter(player, (TileAlloySmelter) world.getTileEntity(new BlockPos(x, y, z)));
container = new ContainerAlloySmelter(player,
(TileAlloySmelter) world.getTileEntity(new BlockPos(x, y, z)));
} else if (ID == GuiHandler.industrialGrinderID) {
return new ContainerIndustrialGrinder((TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)),
player);
@ -101,13 +105,14 @@ public class GuiHandler implements IGuiHandler {
return new ContainerMatterFabricator((TileMatterFabricator) world.getTileEntity(new BlockPos(x, y, z)),
player);
} else if (ID == GuiHandler.assemblingmachineID) {
container = new ContainerAssemblingMachine(player, (TileAssemblingMachine) world.getTileEntity(new BlockPos(x, y, z)));
return new ContainerBuilder("assemblingmachine").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 47, 17)
.slot(1, 65, 17).outputSlot(2, 116, 35).energySlot(3, 56, 53).upgradeSlot(4, 152, 8)
.upgradeSlot(5, 152, 26).upgradeSlot(6, 152, 44).upgradeSlot(7, 152, 62).syncEnergyValue()
.syncCrafterValue().addInventory().create();
} else if (ID == GuiHandler.chunkloaderID) {
return new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory()
return new ContainerBuilder("chunkloader").player(player.inventory).inventory().hotbar().addInventory()
.create();
} else if (ID == GuiHandler.dieselGeneratorID) {
return new ContainerDieselGenerator((TileDieselGenerator) world.getTileEntity(new BlockPos(x, y, z)),
player);
} else if (ID == GuiHandler.industrialElectrolyzerID) {
return new ContainerIndustrialElectrolyzer(
(TileIndustrialElectrolyzer) world.getTileEntity(new BlockPos(x, y, z)), player);
@ -119,8 +124,11 @@ public class GuiHandler implements IGuiHandler {
return new ContainerIndustrialSawmill((TileIndustrialSawmill) world.getTileEntity(new BlockPos(x, y, z)),
player);
} else if (ID == GuiHandler.chemicalReactorID) {
return new ContainerChemicalReactor((TileChemicalReactor) world.getTileEntity(new BlockPos(x, y, z)),
player);
return new ContainerBuilder("chemicalreactor").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 70, 21)
.slot(1, 90, 21).outputSlot(2, 80, 51).energySlot(3, 8, 51).upgradeSlot(4, 152, 8)
.upgradeSlot(5, 152, 26).upgradeSlot(6, 152, 44).upgradeSlot(7, 152, 62).syncEnergyValue()
.syncCrafterValue().addInventory().create();
} else if (ID == GuiHandler.manuelID) {
return null;
} else if (ID == GuiHandler.destructoPackID) {
@ -133,35 +141,74 @@ public class GuiHandler implements IGuiHandler {
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(8, 142).addInventory()
.tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).energySlot(0, 62, 21)
return new ContainerBuilder("chargebench").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).syncEnergyValue().addInventory().create();
} else if (ID == GuiHandler.vacuumFreezerID) {
return new ContainerVacuumFreezer((TileVacuumFreezer) world.getTileEntity(new BlockPos(x, y, z)), player);
} else if (ID == GuiHandler.grinderID) {
container = new ContainerGrinder(player, (TileGrinder) world.getTileEntity(new BlockPos(x, y, z)));
} else if (ID == GuiHandler.generatorID) {
return new ContainerGenerator((TileGenerator) world.getTileEntity(new BlockPos(x, y, z)), player);
} else if (ID == GuiHandler.extractorID) {
container = new ContainerExtractor(player, (TileExtractor) world.getTileEntity(new BlockPos(x, y, z)));
return new ContainerBuilder("generator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).fuelSlot(0, 80, 53)
.energySlot(1, 80, 17).syncEnergyValue()
.syncIntegerValue(((TileGenerator) world.getTileEntity(new BlockPos(x, y, z)))::getBurnTime,
((TileGenerator) world.getTileEntity(new BlockPos(x, y, z)))::setBurnTime)
.syncIntegerValue(((TileGenerator) world.getTileEntity(new BlockPos(x, y, z)))::getTotalBurnTime,
((TileGenerator) world.getTileEntity(new BlockPos(x, y, z)))::setTotalBurnTime)
.addInventory().create();
} else if (ID == GuiHandler.compressorID) {
return new ContainerCompressor((TileCompressor) world.getTileEntity(new BlockPos(x, y, z)), player);
return new ContainerBuilder("compressor").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 56, 34)
.outputSlot(1, 116, 34).upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44)
.upgradeSlot(5, 152, 62).syncEnergyValue().syncCrafterValue().addInventory().create();
} else if (ID == GuiHandler.extractorID) {
return new ContainerBuilder("extractor").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 56, 34)
.outputSlot(1, 116, 34).upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44)
.upgradeSlot(5, 152, 62).syncEnergyValue().syncCrafterValue().addInventory().create();
} else if (ID == GuiHandler.grinderID) {
return new ContainerBuilder("grinder").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 56, 34)
.outputSlot(1, 116, 34).upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44)
.upgradeSlot(5, 152, 62).syncEnergyValue().syncCrafterValue().addInventory().create();
} else if (ID == GuiHandler.electricFurnaceID) {
return new ContainerElectricFurnace((TileElectricFurnace) world.getTileEntity(new BlockPos(x, y, z)),
player);
return new ContainerBuilder("electricfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 56, 34)
.outputSlot(1, 116, 34).upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44)
.upgradeSlot(5, 152, 62).syncEnergyValue()
.syncIntegerValue(((TileElectricFurnace) world.getTileEntity(new BlockPos(x, y, z)))::getBurnTime,
((TileElectricFurnace) world.getTileEntity(new BlockPos(x, y, z)))::setBurnTime)
.addInventory().create();
} else if (ID == GuiHandler.ironFurnace) {
return new ContainerIronFurnace((TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)), player);
return new ContainerBuilder("ironfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 56, 17)
.outputSlot(1, 116, 34).fuelSlot(2, 56, 53)
.syncIntegerValue(((TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)))::getBurnTime,
((TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)))::setBurnTime)
.syncIntegerValue(((TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)))::getTotalBurnTime,
((TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)))::setTotalBurnTime)
.addInventory().create();
} else if (ID == GuiHandler.recyclerID) {
return new ContainerRecycler((TileRecycler) world.getTileEntity(new BlockPos(x, y, z)), player);
return new ContainerBuilder("recycler").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 56, 34)
.slot(1, 116, 34).upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44)
.upgradeSlot(5, 152, 62).syncEnergyValue()
.syncIntegerValue(((TileRecycler) world.getTileEntity(new BlockPos(x, y, z)))::getProgress,
((TileRecycler) world.getTileEntity(new BlockPos(x, y, z)))::setProgress)
.addInventory().create();
} else if (ID == GuiHandler.scrapboxinatorID) {
return new ContainerScrapboxinator((TileScrapboxinator) world.getTileEntity(new BlockPos(x, y, z)), player);
} else if (ID == GuiHandler.batboxID) {
return new ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
return new ContainerBuilder("batbox").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).energySlot(0, 80, 17)
.energySlot(1, 80, 53).syncEnergyValue().addInventory().create();
} else if (ID == GuiHandler.mfeID) {
return new ContainerBuilder("mfe").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();
} else if (ID == GuiHandler.mfeID || ID == GuiHandler.mfsuID) {
return new ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).armor()
} else if (ID == GuiHandler.mfsuID) {
return new ContainerBuilder("mfsu").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();
@ -180,7 +227,8 @@ public class GuiHandler implements IGuiHandler {
}
@Override
public Object getClientGuiElement(final int ID, final EntityPlayer player, final World world, final int x, final int y, final int z) {
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 == GuiHandler.semifluidGeneratorID) {

View file

@ -1,64 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import reborncore.api.tile.IContainerLayout;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotOutput;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.TileAssemblingMachine;
import javax.annotation.Nullable;
import java.util.List;
public class ContainerAssemblingMachine extends ContainerCrafting{
public int tickTime;
EntityPlayer player;
TileAssemblingMachine tile;
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
public ContainerAssemblingMachine(EntityPlayer player, TileAssemblingMachine tile) {
super(tile.crafter);
this.player = player;
this.tile = tile;
addPlayerSlots();
addInventorySlots();
}
public void addInventorySlots() {
// input
this.addSlotToContainer(new BaseSlot(tile.inventory, 0, 47, 17));
this.addSlotToContainer(new BaseSlot(tile.inventory, 1, 65, 17));
// outputs
this.addSlotToContainer(new SlotOutput(tile.inventory, 2, 116, 35));
// power
this.addSlotToContainer(new BaseSlot(tile.inventory, 3, 56, 53));
// upgrades
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 4, 152, 8));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 5, 152, 26));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 6, 152, 44));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 7, 152, 62));
}
public void addPlayerSlots() {
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));
}
}
}

View file

@ -1,67 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import reborncore.api.tile.IContainerLayout;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotOutput;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.TileCentrifuge;
import javax.annotation.Nullable;
import java.util.List;
public class ContainerCentrifuge extends ContainerCrafting {
public int tickTime;
EntityPlayer player;
TileCentrifuge tile;
public ContainerCentrifuge(EntityPlayer player, TileCentrifuge tile) {
super(tile.crafter);
this.player = player;
this.tile = tile;
addInventorySlots();
addPlayerSlots();
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
public void addInventorySlots() {
// input
this.addSlotToContainer(new BaseSlot(tile.inventory, 0, 80, 35));
this.addSlotToContainer(new BaseSlot(tile.inventory, 1, 50, 5));
// outputs
this.addSlotToContainer(new SlotOutput(tile.inventory, 2, 80, 5));
this.addSlotToContainer(new SlotOutput(tile.inventory, 3, 110, 35));
this.addSlotToContainer(new SlotOutput(tile.inventory, 4, 80, 65));
this.addSlotToContainer(new SlotOutput(tile.inventory, 5, 50, 35));
// battery
this.addSlotToContainer(new BaseSlot(tile.inventory, 6, 8, 51));
// upgrades
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 7, 152, 8));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 8, 152, 26));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 9, 152, 44));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 10, 152, 62));
}
public void addPlayerSlots() {
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));
}
}
}

View file

@ -1,51 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotOutput;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.TileChemicalReactor;
public class ContainerChemicalReactor extends ContainerCrafting {
public int tickTime;
EntityPlayer player;
TileChemicalReactor tile;
public ContainerChemicalReactor(TileChemicalReactor tilechemicalReactor, EntityPlayer player) {
super(tilechemicalReactor.crafter);
tile = tilechemicalReactor;
this.player = player;
// input
this.addSlotToContainer(new BaseSlot(tilechemicalReactor.inventory, 0, 70, 21));
this.addSlotToContainer(new BaseSlot(tilechemicalReactor.inventory, 1, 90, 21));
// outputs
this.addSlotToContainer(new SlotOutput(tilechemicalReactor.inventory, 2, 80, 51));
// battery
this.addSlotToContainer(new BaseSlot(tilechemicalReactor.inventory, 3, 8, 51));
// upgrades
this.addSlotToContainer(new SlotUpgrade(tilechemicalReactor.inventory, 4, 152, 8));
this.addSlotToContainer(new SlotUpgrade(tilechemicalReactor.inventory, 5, 152, 26));
this.addSlotToContainer(new SlotUpgrade(tilechemicalReactor.inventory, 6, 152, 44));
this.addSlotToContainer(new SlotUpgrade(tilechemicalReactor.inventory, 7, 152, 62));
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));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
}

View file

@ -1,47 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotOutput;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.teir1.TileCompressor;
public class ContainerCompressor extends ContainerCrafting {
public int connectionStatus;
EntityPlayer player;
TileCompressor tile;
public ContainerCompressor(TileCompressor tileGrinder, EntityPlayer player) {
super(tileGrinder.crafter);
tile = tileGrinder;
this.player = player;
// input
this.addSlotToContainer(new BaseSlot(tileGrinder.inventory, 0, 56, 34));
this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 1, 116, 34));
// upgrades
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 2, 152, 8));
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 3, 152, 26));
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 4, 152, 44));
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 5, 152, 62));
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));
}
}
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return true;
}
}

View file

@ -1,76 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotFake;
import reborncore.client.gui.slots.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.tiles.generator.TileDieselGenerator;
public class ContainerDieselGenerator extends RebornContainer {
public TileDieselGenerator tiledieselGenerator;
public EntityPlayer player;
public int energy;
public int fluid;
public ContainerDieselGenerator(TileDieselGenerator tiledieselGenerator, EntityPlayer player) {
super();
this.tiledieselGenerator = tiledieselGenerator;
this.player = player;
this.addSlotToContainer(new BaseSlot(tiledieselGenerator.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tiledieselGenerator.inventory, 1, 80, 53));
this.addSlotToContainer(new SlotFake(tiledieselGenerator.inventory, 2, 59, 42, false, false, 1));
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));
}
}
@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) tiledieselGenerator.getEnergy()) {
IContainerListener.sendProgressBarUpdate(this, 0, (int) tiledieselGenerator.getEnergy());
}
if (this.fluid != tiledieselGenerator.tank.getFluidAmount()) {
IContainerListener.sendProgressBarUpdate(this, 1, tiledieselGenerator.tank.getFluidAmount());
}
}
}
@Override
public void addListener(IContainerListener crafting) {
super.addListener(crafting);
crafting.sendProgressBarUpdate(this, 0, (int) tiledieselGenerator.getEnergy());
crafting.sendProgressBarUpdate(this, 1, tiledieselGenerator.tank.getFluidAmount());
}
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value) {
if (id == 0) {
this.energy = value;
} else if (id == 1) {
this.fluid = value;
}
}
}

View file

@ -1,59 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.teir1.TileElectricFurnace;
public class ContainerElectricFurnace extends RebornContainer {
public int connectionStatus;
EntityPlayer player;
TileElectricFurnace tile;
public ContainerElectricFurnace(TileElectricFurnace tileGrinder, EntityPlayer player) {
super();
tile = tileGrinder;
this.player = player;
// input
this.addSlotToContainer(new BaseSlot(tileGrinder.inventory, 0, 56, 34));
this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 1, 116, 34));
// upgrades
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 2, 152, 8));
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 3, 152, 26));
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 4, 152, 44));
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 5, 152, 62));
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));
}
}
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return true;
}
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value) {
if (id == 10) {
this.connectionStatus = value;
}
}
}

View file

@ -1,51 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotInput;
import reborncore.client.gui.slots.SlotOutput;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.teir1.TileExtractor;
public class ContainerExtractor extends ContainerCrafting {
EntityPlayer player;
TileExtractor tileExtractor;
public ContainerExtractor(EntityPlayer player, TileExtractor tileExtractor) {
super(tileExtractor.crafter);
this.player = player;
this.tileExtractor = tileExtractor;
// input
this.addSlotToContainer(new SlotInput(tileExtractor.inventory, 0, 56, 34));
this.addSlotToContainer(new SlotOutput(tileExtractor.inventory, 1, 116, 34));
// upgrades
this.addSlotToContainer(new SlotUpgrade(tileExtractor.inventory, 2, 152, 8));
this.addSlotToContainer(new SlotUpgrade(tileExtractor.inventory, 3, 152, 26));
this.addSlotToContainer(new SlotUpgrade(tileExtractor.inventory, 4, 152, 44));
this.addSlotToContainer(new SlotUpgrade(tileExtractor.inventory, 5, 152, 62));
addPlayerSlots();
}
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return true;
}
public void addPlayerSlots() {
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));
}
}
}

View file

@ -1,40 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotFake;
import reborncore.client.gui.slots.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.tiles.generator.TileGasTurbine;
public class ContainerGasTurbine extends RebornContainer {
public TileGasTurbine tileGasTurbine;
public EntityPlayer player;
public ContainerGasTurbine(TileGasTurbine tileGasTurbine, EntityPlayer player) {
super();
this.tileGasTurbine = tileGasTurbine;
this.player = player;
this.addSlotToContainer(new BaseSlot(tileGasTurbine.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileGasTurbine.inventory, 1, 80, 53));
this.addSlotToContainer(new SlotFake(tileGasTurbine.inventory, 2, 59, 42, false, false, 1));
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));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
}

View file

@ -1,92 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.SlotFurnaceFuel;
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.generator.TileGenerator;
public class ContainerGenerator extends RebornContainer {
public int burnTime = 0;
public int totalBurnTime = 0;
public int energy;
public int tickTime;
EntityPlayer player;
TileGenerator tile;
public ContainerGenerator(TileGenerator tile, EntityPlayer player) {
super();
this.tile = tile;
this.player = player;
// fuel
this.addSlotToContainer(new SlotFurnaceFuel(tile.inventory, 0, 80, 53));
// charge
this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 17));
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));
}
}
@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.burnTime != tile.burnTime) {
IContainerListener.sendProgressBarUpdate(this, 0, tile.burnTime);
}
if (this.totalBurnTime != tile.totalBurnTime) {
IContainerListener.sendProgressBarUpdate(this, 1, tile.totalBurnTime);
}
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, 0, tile.burnTime);
crafting.sendProgressBarUpdate(this, 1, tile.totalBurnTime);
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);
}
}

View file

@ -1,56 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotInput;
import reborncore.client.gui.slots.SlotOutput;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.teir1.TileGrinder;
public class ContainerGrinder extends ContainerCrafting {
public int connectionStatus;
EntityPlayer player;
TileGrinder tile;
public ContainerGrinder(EntityPlayer player, TileGrinder tile) {
super(tile.crafter);
this.player = player;
this.tile = tile;
addInventorySlots();
}
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return true;
}
public void addInventorySlots() {
// input
this.addSlotToContainer(new SlotInput(tile.inventory, 0, 56, 34));
this.addSlotToContainer(new SlotOutput(tile.inventory, 1, 116, 34));
// upgrades
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 2, 152, 8));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 3, 152, 26));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 4, 152, 44));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 5, 152, 62));
addPlayerSlots();
}
public void addPlayerSlots() {
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));
}
}
}

View file

@ -1,54 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.SlotFurnaceFuel;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.tiles.TileIronFurnace;
public class ContainerIronFurnace extends RebornContainer {
public int connectionStatus;
EntityPlayer player;
TileIronFurnace tile;
public ContainerIronFurnace(TileIronFurnace tileGrinder, EntityPlayer player) {
super();
tile = tileGrinder;
this.player = player;
// input
this.addSlotToContainer(new BaseSlot(tileGrinder.inventory, 0, 56, 17));
this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 1, 116, 34));
// Fuel
this.addSlotToContainer(new SlotFurnaceFuel(tileGrinder.inventory, 2, 56, 53));
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));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value) {
if (id == 10) {
this.connectionStatus = value;
}
}
}

View file

@ -1,58 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.teir1.TileRecycler;
public class ContainerRecycler extends RebornContainer {
public int connectionStatus;
EntityPlayer player;
TileRecycler tile;
public ContainerRecycler(TileRecycler tileGrinder, EntityPlayer player) {
super();
tile = tileGrinder;
this.player = player;
// input
this.addSlotToContainer(new BaseSlot(tileGrinder.inventory, 0, 56, 34));
this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 1, 116, 34));
// upgrades
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 2, 152, 8));
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 3, 152, 26));
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 4, 152, 44));
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 5, 152, 62));
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));
}
}
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return true;
}
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value) {
if (id == 10) {
this.connectionStatus = value;
}
}
}

View file

@ -1,38 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotFake;
import reborncore.client.gui.slots.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.tiles.generator.TileSemifluidGenerator;
public class ContainerSemifluidGenerator extends RebornContainer {
public TileSemifluidGenerator tileSemifluidGenerator;
public EntityPlayer player;
public ContainerSemifluidGenerator(TileSemifluidGenerator tileSemifluidGenerator, EntityPlayer player) {
super();
this.tileSemifluidGenerator = tileSemifluidGenerator;
this.player = player;
this.addSlotToContainer(new BaseSlot(tileSemifluidGenerator.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileSemifluidGenerator.inventory, 1, 80, 53));
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));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
}

View file

@ -1,41 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotFake;
import reborncore.client.gui.slots.SlotFluid;
import reborncore.client.gui.slots.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.tiles.generator.TileThermalGenerator;
public class ContainerThermalGenerator extends RebornContainer {
public TileThermalGenerator tileThermalGenerator;
public EntityPlayer player;
public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator, EntityPlayer player) {
super();
this.tileThermalGenerator = tileThermalGenerator;
this.player = player;
this.addSlotToContainer(new SlotFluid(tileThermalGenerator.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileThermalGenerator.inventory, 1, 80, 53));
this.addSlotToContainer(new SlotFake(tileThermalGenerator.inventory, 2, 59, 42, false, false, 1));
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));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
}

View file

@ -20,7 +20,9 @@ import java.util.function.IntConsumer;
import java.util.function.IntSupplier;
import java.util.function.Predicate;
final class BuiltContainer extends Container {
public class BuiltContainer extends Container {
private final String name;
private final Predicate<EntityPlayer> canInteract;
private final List<Range<Integer>> playerSlotRanges;
@ -30,8 +32,11 @@ final class BuiltContainer extends Container {
private final ArrayList<MutableTriple<IntSupplier, IntConsumer, Integer>> integerValues;
private Integer[] integerParts;
public BuiltContainer(final Predicate<EntityPlayer> canInteract, final List<Range<Integer>> playerSlotRange,
public BuiltContainer(final String name, final Predicate<EntityPlayer> canInteract,
final List<Range<Integer>> playerSlotRange,
final List<Range<Integer>> tileSlotRange) {
this.name = name;
this.canInteract = canInteract;
this.playerSlotRanges = playerSlotRange;
@ -242,4 +247,8 @@ final class BuiltContainer extends Container {
return true;
return false;
}
public String getName() {
return this.name;
}
}

View file

@ -15,6 +15,8 @@ import java.util.function.IntSupplier;
import java.util.function.Predicate;
public class ContainerBuilder {
private final String name;
private Predicate<EntityPlayer> canInteract = player -> true;
final List<Slot> slots;
@ -23,7 +25,10 @@ public class ContainerBuilder {
final List<Pair<IntSupplier, IntConsumer>> shortValues;
final List<Pair<IntSupplier, IntConsumer>> integerValues;
public ContainerBuilder() {
public ContainerBuilder(final String name) {
this.name = name;
this.slots = new ArrayList<>();
this.playerInventoryRanges = new ArrayList<>();
this.tileInventoryRanges = new ArrayList<>();
@ -54,7 +59,7 @@ public class ContainerBuilder {
}
public BuiltContainer create() {
final BuiltContainer built = new BuiltContainer(this.canInteract, this.playerInventoryRanges,
final BuiltContainer built = new BuiltContainer(this.name, this.canInteract, this.playerInventoryRanges,
this.tileInventoryRanges);
if (!this.shortValues.isEmpty())
built.addShortSync(this.shortValues);

View file

@ -4,10 +4,13 @@ import org.apache.commons.lang3.Range;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.SlotFurnaceFuel;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import reborncore.api.power.IEnergyInterfaceItem;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotFake;
import reborncore.client.gui.slots.SlotOutput;
@ -15,6 +18,7 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.Core;
import techreborn.client.container.builder.slot.FilteredSlot;
import techreborn.utils.upgrade.IMachineUpgrade;
import java.util.function.IntConsumer;
import java.util.function.IntSupplier;
@ -54,6 +58,25 @@ public class ContainerTileInventoryBuilder {
return this;
}
@SuppressWarnings("null")
public ContainerTileInventoryBuilder fluidSlot(final int index, final int x, final int y) {
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y).setFilter(
stack -> stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.UP)));
return this;
}
public ContainerTileInventoryBuilder fuelSlot(final int index, final int x, final int y)
{
this.parent.slots.add(new SlotFurnaceFuel(this.tile, index, x, y));
return this;
}
public ContainerTileInventoryBuilder upgradeSlot(final int index, final int x, final int y) {
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y)
.setFilter(stack -> stack.getItem() instanceof IMachineUpgrade));
return this;
}
/**
*
* @param supplier
@ -88,6 +111,20 @@ public class ContainerTileInventoryBuilder {
return this;
}
public ContainerTileInventoryBuilder syncCrafterValue() {
if (this.tile instanceof IRecipeCrafterProvider)
return this
.syncIntegerValue(() -> ((IRecipeCrafterProvider) this.tile).getRecipeCrafter().currentTickTime,
(currentTickTime) -> ((IRecipeCrafterProvider) this.tile)
.getRecipeCrafter().currentTickTime = currentTickTime)
.syncIntegerValue(() -> ((IRecipeCrafterProvider) this.tile).getRecipeCrafter().currentNeededTicks,
(currentNeededTicks) -> ((IRecipeCrafterProvider) this.tile)
.getRecipeCrafter().currentNeededTicks = currentNeededTicks);
Core.logHelper
.error(this.tile + " is not an instance of IRecipeCrafterProvider! Craft progress cannot be synced.");
return this;
}
public ContainerBuilder addInventory() {
this.parent.tileInventoryRanges.add(Range.between(this.rangeStart, this.parent.slots.size() - 1));
return this.parent;

View file

@ -5,8 +5,8 @@ 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 reborncore.common.container.RebornContainer;
import techreborn.client.container.ContainerAssemblingMachine;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.TileAssemblingMachine;
public class GuiAssemblingMachine extends GuiContainer {
@ -15,46 +15,48 @@ public class GuiAssemblingMachine extends GuiContainer {
"textures/gui/assembling_machine.png");
TileAssemblingMachine assemblingmachine;
ContainerAssemblingMachine containerAssemblingMachine;
public GuiAssemblingMachine(EntityPlayer player, TileAssemblingMachine tileassemblinmachine) {
super(RebornContainer.createContainer(ContainerAssemblingMachine.class, tileassemblinmachine, player));
containerAssemblingMachine = (ContainerAssemblingMachine) this.inventorySlots;
public GuiAssemblingMachine(final EntityPlayer player, final TileAssemblingMachine assemblingMachine) {
super(new ContainerBuilder("assemblingmachine").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(assemblingMachine).slot(0, 47, 17).slot(1, 65, 17).outputSlot(2, 116, 35)
.energySlot(3, 56, 53).upgradeSlot(4, 152, 8).upgradeSlot(5, 152, 26).upgradeSlot(6, 152, 44)
.upgradeSlot(7, 152, 62).syncEnergyValue().syncCrafterValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
assemblingmachine = tileassemblinmachine;
this.assemblingmachine = assemblingMachine;
}
@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(GuiAssemblingMachine.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 = assemblingmachine.getProgressScaled(20);
j = this.assemblingmachine.getProgressScaled(20);
if (j > 0) {
this.drawTexturedModalRect(k + 86, l + 34, 176, 14, j + 1, 16);
}
j = assemblingmachine.getEnergyScaled(12);
j = this.assemblingmachine.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 56, l + 36 + 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.assemblinmachine.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.assemblinmachine.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,

View file

@ -12,17 +12,10 @@ public class GuiBatbox extends GuiBase {
TileBatBox tile;
public GuiBatbox(final EntityPlayer player, final TileBatBox tile) {
super(player, tile, new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory().tile(tile).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create());
super(player, tile, new ContainerBuilder("batbox").player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory().tile(tile).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create());
this.tile = tile;
}
@Override
public void initGui() {
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
super.initGui();
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
@ -33,6 +26,7 @@ public class GuiBatbox extends GuiBase {
this.buttonList.add(new GuiButtonPowerBar(0, guiLeft + 82, guiTop + 29));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
builder.drawMultiEnergyBar(this, 81, 28, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX - guiLeft, mouseY - guiTop);

View file

@ -5,8 +5,8 @@ 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 reborncore.common.container.RebornContainer;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.TileCentrifuge;
public class GuiCentrifuge extends GuiContainer {
@ -16,31 +16,35 @@ public class GuiCentrifuge extends GuiContainer {
TileCentrifuge centrifuge;
public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge) {
super(RebornContainer.createContainer(ContainerCentrifuge.class, tileCentrifuge, player));
public GuiCentrifuge(final EntityPlayer player, final TileCentrifuge tileCentrifuge) {
super(new ContainerBuilder("centrifuge").player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile(tileCentrifuge).slot(0, 80, 35).slot(1, 50, 5).outputSlot(2, 80, 5).outputSlot(3, 110, 35)
.outputSlot(4, 80, 65).outputSlot(5, 50, 35).energySlot(6, 8, 51).upgradeSlot(7, 152, 8)
.upgradeSlot(8, 152, 26).upgradeSlot(9, 152, 44).upgradeSlot(10, 152, 62).syncEnergyValue()
.syncCrafterValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
centrifuge = tileCentrifuge;
this.centrifuge = tileCentrifuge;
}
@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(GuiCentrifuge.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 = centrifuge.getProgressScaled(11);
j = this.centrifuge.getProgressScaled(11);
if (j > 0) {
this.drawTexturedModalRect(k + 83, l + 23 + 10 - j, 177, 15 + 10 - j, 10, j);
this.drawTexturedModalRect(k + 98, l + 38, 177, 51, j, 10);
@ -48,20 +52,21 @@ public class GuiCentrifuge extends GuiContainer {
this.drawTexturedModalRect(k + 68 + 10 - j, l + 38, 177 + 10 - j, 27, j, 10);
}
j = centrifuge.getEnergyScaled(12);
j = this.centrifuge.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 9, l + 32 + 12 - j, 176, 12 - j, 14, j + 2);
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String namePt1 = I18n.translateToLocal("tile.techreborn.industrialBlock.name");
String namePt2 = I18n.translateToLocal("tile.techreborn.centrifuge.name").replace(namePt1 + " ", "");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String namePt1 = I18n.translateToLocal("tile.techreborn.industrialBlock.name");
final String namePt2 = I18n.translateToLocal("tile.techreborn.centrifuge.name").replace(namePt1 + " ", "");
this.fontRendererObj.drawString(namePt1, 98, 6, 4210752);
this.fontRendererObj.drawString(namePt2, 98, 14, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(centrifuge.getProgressScaled(100) + "%", 98, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(this.centrifuge.getProgressScaled(100) + "%", 98, this.ySize - 96 + 2, 4210752);
}
}

View file

@ -16,9 +16,9 @@ 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, 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).syncEnergyValue().addInventory().create());
super(new ContainerBuilder("charbench").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).syncEnergyValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
this.chargebench = tile;

View file

@ -5,7 +5,8 @@ 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.ContainerChemicalReactor;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.TileChemicalReactor;
public class GuiChemicalReactor extends GuiContainer {
@ -14,47 +15,49 @@ public class GuiChemicalReactor extends GuiContainer {
"textures/gui/chemical_reactor.png");
TileChemicalReactor chemicalReactor;
ContainerChemicalReactor containerChemicalReactor;
public GuiChemicalReactor(EntityPlayer player, TileChemicalReactor tilechemicalReactor) {
super(new ContainerChemicalReactor(tilechemicalReactor, player));
containerChemicalReactor = (ContainerChemicalReactor) this.inventorySlots;
public GuiChemicalReactor(final EntityPlayer player, final TileChemicalReactor tilechemicalReactor) {
super(new ContainerBuilder("chemicalreactor").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(tilechemicalReactor).slot(0, 70, 21).slot(1, 90, 21).outputSlot(2, 80, 51)
.energySlot(3, 8, 51).upgradeSlot(4, 152, 8).upgradeSlot(5, 152, 26).upgradeSlot(6, 152, 44)
.upgradeSlot(7, 152, 62).syncEnergyValue().syncCrafterValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
chemicalReactor = tilechemicalReactor;
this.chemicalReactor = tilechemicalReactor;
}
@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(GuiChemicalReactor.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 = chemicalReactor.getProgressScaled(11);
j = this.chemicalReactor.getProgressScaled(11);
if (j > 0) {
this.drawTexturedModalRect(k + 73, l + 39, 177, 15, 30, j);
}
j = chemicalReactor.getEnergyScaled(12);
j = this.chemicalReactor.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 9, 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.chemicalreactor.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.chemicalreactor.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,

View file

@ -21,10 +21,11 @@ public class GuiChunkLoader extends GuiContainer {
private GuiButton minusTenButton;
public GuiChunkLoader(final EntityPlayer player, final TileChunkLoader tilechunkloader) {
super(new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory().create());
super(new ContainerBuilder("chunkloader").player(player.inventory).inventory().hotbar().addInventory()
.create());
this.xSize = 176;
this.ySize = 167;
chunkloader = tilechunkloader;
this.chunkloader = tilechunkloader;
}
@Override
@ -32,29 +33,30 @@ public class GuiChunkLoader extends GuiContainer {
super.initGui();
this.guiLeft = this.width / 2 - this.xSize / 2;
this.guiTop = this.height / 2 - this.ySize / 2;
plusOneButton = new GuiButton(0, guiLeft + 5, guiTop + 37, 40, 20, "+1");
plusTenButton = new GuiButton(0, guiLeft + 45, guiTop + 37, 40, 20, "+10");
this.plusOneButton = new GuiButton(0, this.guiLeft + 5, this.guiTop + 37, 40, 20, "+1");
this.plusTenButton = new GuiButton(0, this.guiLeft + 45, this.guiTop + 37, 40, 20, "+10");
minusOneButton = new GuiButton(0, guiLeft + 90, guiTop + 37, 40, 20, "-1");
minusTenButton = new GuiButton(0, guiLeft + 130, guiTop + 37, 40, 20, "-10");
this.minusOneButton = new GuiButton(0, this.guiLeft + 90, this.guiTop + 37, 40, 20, "-1");
this.minusTenButton = new GuiButton(0, this.guiLeft + 130, this.guiTop + 37, 40, 20, "-10");
buttonList.add(plusOneButton);
buttonList.add(plusTenButton);
buttonList.add(minusOneButton);
buttonList.add(minusTenButton);
this.buttonList.add(this.plusOneButton);
this.buttonList.add(this.plusTenButton);
this.buttonList.add(this.minusOneButton);
this.buttonList.add(this.minusTenButton);
}
@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(GuiChunkLoader.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);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.chunkloader.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.chunkloader.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,

View file

@ -5,7 +5,8 @@ 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.ContainerCompressor;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.teir1.TileCompressor;
public class GuiCompressor extends GuiContainer {
@ -13,39 +14,42 @@ public class GuiCompressor extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/compressor.png");
TileCompressor compressor;
ContainerCompressor containerGrinder;
public GuiCompressor(EntityPlayer player, TileCompressor tilegrinder) {
super(new ContainerCompressor(tilegrinder, player));
public GuiCompressor(final EntityPlayer player, final TileCompressor compressor) {
super(new ContainerBuilder("compressor").player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile(compressor).slot(0, 56, 34).outputSlot(1, 116, 34).upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26)
.upgradeSlot(4, 152, 44).upgradeSlot(5, 152, 62).syncEnergyValue().syncCrafterValue().addInventory()
.create());
this.xSize = 176;
this.ySize = 167;
compressor = tilegrinder;
containerGrinder = (ContainerCompressor) this.inventorySlots;
this.compressor = compressor;
}
@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(GuiCompressor.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 = compressor.getProgressScaled(24);
j = this.compressor.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = compressor.getEnergyScaled(12);
j = this.compressor.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 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.compressor.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.compressor.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,

View file

@ -5,8 +5,10 @@ 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 reborncore.common.powerSystem.PowerSystem;
import techreborn.client.container.ContainerDieselGenerator;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.generator.TileDieselGenerator;
public class GuiDieselGenerator extends GuiContainer {
@ -16,36 +18,36 @@ public class GuiDieselGenerator extends GuiContainer {
TileDieselGenerator tile;
ContainerDieselGenerator containerDieselGenerator;
public GuiDieselGenerator(EntityPlayer player, TileDieselGenerator tile) {
super(new ContainerDieselGenerator(tile, player));
public GuiDieselGenerator(final EntityPlayer player, final TileDieselGenerator tile) {
super(new ContainerBuilder("fluidgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(tile).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue()
.addInventory().create());
this.xSize = 176;
this.ySize = 167;
this.tile = tile;
containerDieselGenerator = (ContainerDieselGenerator) this.inventorySlots;
}
@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(GuiDieselGenerator.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);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.dieselgenerator.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.dieselgenerator.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRendererObj.drawString(containerDieselGenerator.fluid + "", 10, 30, 16448255);
this.fontRendererObj.drawString(this.tile.tank.getFluidAmount() + "", 10, 30, 16448255);
this.fontRendererObj.drawString("Power Amount", 10, 40, 16448255);
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerDieselGenerator.energy) + "", 10, 50,
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.tile.getEnergy()) + "", 10, 50,
16448255);
}
}

View file

@ -10,25 +10,26 @@ public class GuiDigitalChest extends GuiBase {
TileDigitalChest tile;
public GuiDigitalChest(final EntityPlayer player, final TileDigitalChest tile) {
super(player, tile, new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory().tile(tile).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create());
super(player, tile, new ContainerBuilder("digitalchest").player(player.inventory).inventory().hotbar().addInventory().tile(tile).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create());
this.tile = tile;
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
drawSlotBackground(80, 24);
drawSlotBackground(80, 64);
this.drawSlotBackground(80, 24);
this.drawSlotBackground(80, 64);
}
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
if (tile.storedItem != ItemStack.EMPTY && tile.getStackInSlot(1) != null) {
builder.drawBigBlueBar(this, 31, 43, tile.storedItem.getCount() + tile.getStackInSlot(1).getCount(), tile.maxCapacity, mouseX - guiLeft, mouseY - guiTop, "Stored");
if (this.tile.storedItem != ItemStack.EMPTY && this.tile.getStackInSlot(1) != null) {
this.builder.drawBigBlueBar(this, 31, 43, this.tile.storedItem.getCount() + this.tile.getStackInSlot(1).getCount(), this.tile.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored");
}
if (tile.storedItem == ItemStack.EMPTY && tile.getStackInSlot(1) != null) {
builder.drawBigBlueBar(this, 31, 43, tile.getStackInSlot(1).getCount(), tile.maxCapacity, mouseX - guiLeft, mouseY - guiTop, "Stored");
if (this.tile.storedItem == ItemStack.EMPTY && this.tile.getStackInSlot(1) != null) {
this.builder.drawBigBlueBar(this, 31, 43, this.tile.getStackInSlot(1).getCount(), this.tile.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored");
}
}
}

View file

@ -5,7 +5,8 @@ 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.ContainerElectricFurnace;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.teir1.TileElectricFurnace;
public class GuiElectricFurnace extends GuiContainer {
@ -13,43 +14,44 @@ public class GuiElectricFurnace extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/compressor.png");
TileElectricFurnace furnace;
ContainerElectricFurnace containerGrinder;
public GuiElectricFurnace(EntityPlayer player, TileElectricFurnace tilegrinder) {
super(new ContainerElectricFurnace(tilegrinder, player));
public GuiElectricFurnace(final EntityPlayer player, final TileElectricFurnace furnace) {
super(new ContainerBuilder("electricfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(furnace).slot(0, 56, 34).outputSlot(1, 116, 34).upgradeSlot(2, 152, 8)
.upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44).upgradeSlot(5, 152, 62).syncEnergyValue()
.syncIntegerValue(furnace::getBurnTime, furnace::setBurnTime).addInventory().create());
this.xSize = 176;
this.ySize = 167;
furnace = tilegrinder;
containerGrinder = (ContainerElectricFurnace) this.inventorySlots;
this.furnace = furnace;
}
@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(GuiElectricFurnace.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 = furnace.gaugeProgressScaled(24);
j = this.furnace.gaugeProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 34, 176, 14, j + 1, 16);
}
j = furnace.getEnergyScaled(12);
j = this.furnace.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 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.electricfurnace.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.electricfurnace.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
}
}

View file

@ -5,8 +5,8 @@ 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 reborncore.common.container.RebornContainer;
import techreborn.client.container.ContainerExtractor;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.teir1.TileExtractor;
public class GuiExtractor extends GuiContainer {
@ -14,39 +14,41 @@ public class GuiExtractor extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/compressor.png");
TileExtractor extractor;
ContainerExtractor containerExtractor;
public GuiExtractor(EntityPlayer player, TileExtractor tileExtractor) {
super(RebornContainer.createContainer(ContainerExtractor.class, tileExtractor, player));
public GuiExtractor(final EntityPlayer player, final TileExtractor extractor) {
super(new ContainerBuilder("extractor").player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile(extractor).slot(0, 56, 34).outputSlot(1, 116, 34).upgradeSlot(2, 152, 8)
.upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44).upgradeSlot(5, 152, 62).syncEnergyValue()
.syncCrafterValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
this.extractor = tileExtractor;
containerExtractor = (ContainerExtractor) this.inventorySlots;
this.extractor = extractor;
}
@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(GuiExtractor.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 = extractor.getProgressScaled(24);
j = this.extractor.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = extractor.getEnergyScaled(12);
j = this.extractor.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 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.extractor.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.extractor.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,

View file

@ -5,7 +5,8 @@ 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.ContainerGasTurbine;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.generator.TileGasTurbine;
public class GuiGasTurbine extends GuiContainer {
@ -16,29 +17,33 @@ public class GuiGasTurbine extends GuiContainer {
TileGasTurbine tile;
public GuiGasTurbine(EntityPlayer player, TileGasTurbine tile) {
super(new ContainerGasTurbine(tile, player));
public GuiGasTurbine(final EntityPlayer player, final TileGasTurbine tile) {
super(new ContainerBuilder("fluidgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory()
.tile(tile).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue().addInventory()
.create());
this.xSize = 176;
this.ySize = 167;
this.tile = tile;
}
@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(GuiGasTurbine.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);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = "Gas Turbine";
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = "Gas Turbine";
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255);
this.fontRendererObj.drawString(this.tile.tank.getFluidAmount() + "", 10, 30, 16448255);
}
}

View file

@ -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.ContainerGenerator;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.generator.TileGenerator;
public class GuiGenerator extends GuiContainer {
@ -14,51 +16,52 @@ public class GuiGenerator extends GuiContainer {
TileGenerator generator;
ContainerGenerator containerGenerator;
public GuiGenerator(EntityPlayer player, TileGenerator generator) {
super(new ContainerGenerator(generator, player));
public GuiGenerator(final EntityPlayer player, final TileGenerator generator) {
super(new ContainerBuilder("generator").player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile(generator).fuelSlot(0, 80, 53).energySlot(1, 80, 17).syncEnergyValue()
.syncIntegerValue(generator::getBurnTime, generator::setBurnTime)
.syncIntegerValue(generator::getTotalBurnTime, generator::setTotalBurnTime).addInventory().create());
this.xSize = 176;
this.ySize = 167;
this.generator = generator;
this.containerGenerator = (ContainerGenerator) 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(GuiGenerator.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);
}
if (containerGenerator.burnTime != 0) {
j = containerGenerator.getScaledBurnTime(13);
if (this.generator.burnTime != 0) {
j = this.generator.getScaledBurnTime(13);
this.drawTexturedModalRect(k + 80, l + 38 + 12 - j, 176, 30 - j, 14, j + 1);
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.generator.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.generator.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 25, this.ySize - 150,
4210752);
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.generator.getEnergy()), 25,
this.ySize - 150, 4210752);
}
}

View file

@ -5,8 +5,8 @@ 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 reborncore.common.container.RebornContainer;
import techreborn.client.container.ContainerGrinder;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.teir1.TileGrinder;
public class GuiGrinder extends GuiContainer {
@ -14,43 +14,44 @@ public class GuiGrinder extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/grinder.png");
TileGrinder grinder;
ContainerGrinder containerGrinder;
public GuiGrinder(EntityPlayer player, TileGrinder tilegrinder) {
super(RebornContainer.createContainer(ContainerGrinder.class, tilegrinder, player));
public GuiGrinder(final EntityPlayer player, final TileGrinder grinder) {
super(new ContainerBuilder("grinder").player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile(grinder).slot(0, 56, 34).outputSlot(1, 116, 34).upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26)
.upgradeSlot(4, 152, 44).upgradeSlot(5, 152, 62).syncEnergyValue().syncCrafterValue().addInventory()
.create());
this.xSize = 176;
this.ySize = 167;
this.grinder = tilegrinder;
containerGrinder = (ContainerGrinder) this.inventorySlots;
this.grinder = grinder;
}
@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(GuiGrinder.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 = grinder.getProgressScaled(24);
j = this.grinder.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 80, l + 36, 176, 14, j + 1, 16);
}
j = grinder.getEnergyScaled(12);
j = this.grinder.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 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.grinder.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.grinder.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
}
}

View file

@ -5,7 +5,8 @@ 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.ContainerIronFurnace;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.TileIronFurnace;
public class GuiIronFurnace extends GuiContainer {
@ -14,39 +15,42 @@ public class GuiIronFurnace extends GuiContainer {
"textures/gui/container/furnace.png");
TileIronFurnace furnace;
ContainerIronFurnace containerGrinder;
public GuiIronFurnace(EntityPlayer player, TileIronFurnace tilegrinder) {
super(new ContainerIronFurnace(tilegrinder, player));
public GuiIronFurnace(final EntityPlayer player, final TileIronFurnace furnace) {
super(new ContainerBuilder("ironfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(furnace).slot(0, 56, 17).outputSlot(1, 116, 34).fuelSlot(2, 56, 53)
.syncIntegerValue(furnace::getBurnTime, furnace::setBurnTime)
.syncIntegerValue(furnace::getTotalBurnTime, furnace::setTotalBurnTime).addInventory()
.create());
this.xSize = 176;
this.ySize = 167;
furnace = tilegrinder;
containerGrinder = (ContainerIronFurnace) this.inventorySlots;
this.furnace = furnace;
}
@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(GuiIronFurnace.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 = furnace.gaugeProgressScaled(24);
j = this.furnace.gaugeProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = furnace.gaugeFuelScaled(12);
j = this.furnace.gaugeFuelScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 57, l + 36 + 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.ironfurnace.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.ironfurnace.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,

View file

@ -21,9 +21,9 @@ public class GuiMFE extends GuiContainer {
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());
super(new ContainerBuilder("mfe").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;

View file

@ -20,9 +20,9 @@ public class GuiMFSU extends GuiContainer {
TileMFSU generator;
public GuiMFSU(final EntityPlayer player, final TileMFSU 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());
super(new ContainerBuilder("mfsu").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;

View file

@ -10,7 +10,7 @@ public class GuiQuantumChest extends GuiBase {
TileQuantumChest tile;
public GuiQuantumChest(final EntityPlayer player, final TileQuantumChest tile) {
super(player, tile, new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory().tile(tile).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create());
super(player, tile, new ContainerBuilder("quantumchest").player(player.inventory).inventory().hotbar().addInventory().tile(tile).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create());
this.tile = tile;
}

View file

@ -5,47 +5,51 @@ 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.ContainerRecycler;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.teir1.TileRecycler;
public class GuiRecycler extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/compressor.png");
TileRecycler compressor;
ContainerRecycler containerGrinder;
TileRecycler recycler;
public GuiRecycler(EntityPlayer player, TileRecycler tilegrinder) {
super(new ContainerRecycler(tilegrinder, player));
public GuiRecycler(final EntityPlayer player, final TileRecycler recycler) {
super(new ContainerBuilder("recycler").player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile(recycler).slot(0, 56, 34).slot(1, 116, 34).upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26)
.upgradeSlot(4, 152, 44).upgradeSlot(5, 152, 62).syncEnergyValue()
.syncIntegerValue(recycler::getProgress, recycler::setProgress).addInventory().create());
this.xSize = 176;
this.ySize = 167;
compressor = tilegrinder;
containerGrinder = (ContainerRecycler) this.inventorySlots;
this.recycler = recycler;
}
@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(GuiRecycler.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 = compressor.gaugeProgressScaled(24);
j = this.recycler.gaugeProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = compressor.getEnergyScaled(12);
j = this.recycler.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 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.recycler.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.recycler.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,

View file

@ -5,8 +5,10 @@ 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 reborncore.client.RenderUtil;
import techreborn.client.container.ContainerSemifluidGenerator;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.generator.TileSemifluidGenerator;
public class GuiSemifluidGenerator extends GuiContainer {
@ -17,30 +19,33 @@ public class GuiSemifluidGenerator extends GuiContainer {
TileSemifluidGenerator tile;
public GuiSemifluidGenerator(EntityPlayer player, TileSemifluidGenerator tile) {
super(new ContainerSemifluidGenerator(tile, player));
public GuiSemifluidGenerator(final EntityPlayer player, final TileSemifluidGenerator tile) {
super(new ContainerBuilder("fluidgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(tile).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue()
.addInventory().create());
this.xSize = 176;
this.ySize = 167;
this.tile = tile;
}
@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(GuiSemifluidGenerator.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);
RenderUtil.renderGuiTank(tile.tank.getFluid(), 16, 16, k + 59, l + 42, this.zLevel, 16, 16);
RenderUtil.renderGuiTank(this.tile.tank.getFluid(), 16, 16, k + 59, l + 42, this.zLevel, 16, 16);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = "Semifluid Generator";
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = "Semifluid Generator";
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255);
this.fontRendererObj.drawString(this.tile.tank.getFluidAmount() + "", 10, 30, 16448255);
}
}

View file

@ -5,8 +5,10 @@ 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 reborncore.client.RenderUtil;
import techreborn.client.container.ContainerThermalGenerator;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.generator.TileThermalGenerator;
public class GuiThermalGenerator extends GuiContainer {
@ -16,32 +18,35 @@ public class GuiThermalGenerator extends GuiContainer {
TileThermalGenerator tile;
public GuiThermalGenerator(EntityPlayer player, TileThermalGenerator tile) {
super(new ContainerThermalGenerator(tile, player));
public GuiThermalGenerator(final EntityPlayer player, final TileThermalGenerator tile) {
super(new ContainerBuilder("fluidgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(tile).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue()
.addInventory().create());
this.xSize = 176;
this.ySize = 167;
this.tile = tile;
}
@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(GuiThermalGenerator.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);
RenderUtil.renderGuiTank(tile.tank.getFluid(), 16, 16, k + 59, l + 42, this.zLevel, 16, 16);
RenderUtil.renderGuiTank(this.tile.tank.getFluid(), 16, 16, k + 59, l + 42, this.zLevel, 16, 16);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.thermalGenerator.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.thermalGenerator.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255);
this.fontRendererObj.drawString(tile.getEnergy() + "", 10, 40, 16448255);
this.fontRendererObj.drawString(this.tile.tank.getFluidAmount() + "", 10, 30, 16448255);
this.fontRendererObj.drawString(this.tile.getEnergy() + "", 10, 40, 16448255);
}
}

View file

@ -0,0 +1,61 @@
package techreborn.compat.jei;
import net.minecraft.inventory.Slot;
import techreborn.client.container.builder.BuiltContainer;
import java.util.ArrayList;
import java.util.List;
import mezz.jei.api.recipe.transfer.IRecipeTransferInfo;
public class BuiltContainerTransferInfo implements IRecipeTransferInfo<BuiltContainer> {
private final String containerName, recipeCategory;
private final int recipeSlotStart, recipeSlotCount, inventorySlotStart, inventorySlotCount;
public BuiltContainerTransferInfo(final String containerName, final String recipeCategory,
final int recipeSlotStart, final int recipeSlotCount, final int inventorySlotStart,
final int inventorySlotCount) {
this.containerName = containerName;
this.recipeCategory = recipeCategory;
this.recipeSlotStart = recipeSlotStart;
this.recipeSlotCount = recipeSlotCount;
this.inventorySlotStart = inventorySlotStart;
this.inventorySlotCount = inventorySlotCount;
}
@Override
public Class<BuiltContainer> getContainerClass() {
return BuiltContainer.class;
}
@Override
public String getRecipeCategoryUid() {
return this.recipeCategory;
}
@Override
public boolean canHandle(final BuiltContainer container) {
return container.getName().equals(this.containerName);
}
@Override
public List<Slot> getRecipeSlots(final BuiltContainer container) {
final List<Slot> slots = new ArrayList<>();
for (int i = this.recipeSlotStart; i < this.recipeSlotStart + this.recipeSlotCount; i++)
slots.add(container.getSlot(i));
return slots;
}
@Override
public List<Slot> getInventorySlots(final BuiltContainer container) {
final List<Slot> slots = new ArrayList<>();
for (int i = this.inventorySlotStart; i < this.inventorySlotStart + this.inventorySlotCount; i++)
slots.add(container.getSlot(i));
return slots;
}
}

View file

@ -1,16 +1,13 @@
package techreborn.compat.jei;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
import mezz.jei.config.Config;
import javax.annotation.Nonnull;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.translation.I18n;
import reborncore.api.recipe.RecipeHandler;
import techreborn.Core;
import techreborn.api.generator.EFluidGenerator;
import techreborn.api.generator.GeneratorRecipeHelper;
@ -62,25 +59,32 @@ import techreborn.items.ItemParts;
import techreborn.parts.TechRebornParts;
import techreborn.parts.powerCables.EnumCableType;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
import mezz.jei.config.Config;
@mezz.jei.api.JEIPlugin
public class TechRebornJeiPlugin extends BlankModPlugin {
private static void addDebugRecipes(IModRegistry registry) {
ItemStack diamondBlock = new ItemStack(Blocks.DIAMOND_BLOCK);
ItemStack dirtBlock = new ItemStack(Blocks.DIRT);
List<Object> debugRecipes = new ArrayList<>();
private static void addDebugRecipes(final IModRegistry registry) {
final ItemStack diamondBlock = new ItemStack(Blocks.DIAMOND_BLOCK);
final ItemStack dirtBlock = new ItemStack(Blocks.DIRT);
final List<Object> debugRecipes = new ArrayList<>();
for (int i = 0; i < 10; i++) {
int time = (int) Math.round(200 + Math.random() * 100);
AssemblingMachineRecipe assemblingMachineRecipe = new AssemblingMachineRecipe(diamondBlock, diamondBlock,
final int time = (int) Math.round(200 + Math.random() * 100);
final AssemblingMachineRecipe assemblingMachineRecipe = new AssemblingMachineRecipe(diamondBlock, diamondBlock,
dirtBlock, time, 120);
debugRecipes.add(assemblingMachineRecipe);
}
for (int i = 0; i < 10; i++) {
int time = (int) Math.round(200 + Math.random() * 100);
ImplosionCompressorRecipe recipe = new ImplosionCompressorRecipe(diamondBlock, diamondBlock, dirtBlock,
final int time = (int) Math.round(200 + Math.random() * 100);
final ImplosionCompressorRecipe recipe = new ImplosionCompressorRecipe(diamondBlock, diamondBlock, dirtBlock,
dirtBlock, time, 120);
debugRecipes.add(recipe);
}
@ -89,10 +93,10 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
@Override
public void register(
@Nonnull
@Nonnull final
IModRegistry registry) {
IJeiHelpers jeiHelpers = registry.getJeiHelpers();
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
final IJeiHelpers jeiHelpers = registry.getJeiHelpers();
final IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModFluids.BLOCK_BERYLLIUM));
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModFluids.BLOCK_CALCIUM));
@ -129,7 +133,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModItems.MISSING_RECIPE_PLACEHOLDER));
if(IC2Duplicates.deduplicate()){
for(IC2Duplicates duplicate : IC2Duplicates.values()){
for(final IC2Duplicates duplicate : IC2Duplicates.values()){
if(duplicate.hasIC2Stack()){
jeiHelpers.getItemBlacklist().addItemToBlacklist(duplicate.getTrStack());
}
@ -162,7 +166,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper),
new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper));
for(EFluidGenerator type : EFluidGenerator.values())
for(final EFluidGenerator type : EFluidGenerator.values())
registry.addRecipeCategories(new FluidGeneratorRecipeCategory(type, guiHelper));
registry.addRecipeHandlers(new AlloySmelterRecipeHandler(jeiHelpers),
@ -182,14 +186,14 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
try {
registry.addRecipes(RollingMachineRecipeMaker.getRecipes(jeiHelpers));
} catch (RuntimeException e) {
} catch (final RuntimeException e) {
Core.logHelper
.error("Could not register rolling machine recipes. JEI may have changed its internal recipe wrapper locations.");
e.printStackTrace();
}
if (Config.isDebugModeEnabled()) {
addDebugRecipes(registry);
TechRebornJeiPlugin.addDebugRecipes(registry);
}
registry.addDescription(ItemParts.getPartByName("rubberSap"),
@ -268,23 +272,15 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.THERMAL_GENERATOR),
EFluidGenerator.THERMAL.getRecipeID());
IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloySmelter.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 8, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloyFurnace.class, VanillaRecipeCategoryUid.FUEL, 3, 1, 4, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAssemblingMachine.class, RecipeCategoryUids.ASSEMBLING_MACHINE, 0, 2,
8, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerCentrifuge.class, RecipeCategoryUids.CENTRIFUGE, 0, 2, 11, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerChemicalReactor.class, RecipeCategoryUids.CHEMICAL_REACTOR, 0, 2, 8,
36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
recipeTransferRegistry
@ -299,12 +295,20 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerGrinder.class, RecipeCategoryUids.GRINDER, 0, 1, 2, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerExtractor.class, RecipeCategoryUids.EXTRACTOR, 0, 1, 2, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerCompressor.class, RecipeCategoryUids.COMPRESSOR, 0, 1, 2, 36);
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("assemblingmachine", RecipeCategoryUids.ASSEMBLING_MACHINE, 36, 2, 0,
36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("chemicalreactor", RecipeCategoryUids.CHEMICAL_REACTOR, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("centrifuge", RecipeCategoryUids.CENTRIFUGE, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("grinder", RecipeCategoryUids.GRINDER, 36, 1, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("extractor", RecipeCategoryUids.EXTRACTOR, 36, 1, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("compressor", RecipeCategoryUids.COMPRESSOR, 36, 1, 0, 36));
if (CompatManager.isQuantumStorageLoaded) {
registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.QUANTUM_CHEST));

View file

@ -8,6 +8,7 @@ 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.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TileLegacyMachineBase;
@ -30,100 +31,98 @@ public class TileIronFurnace extends TileLegacyMachineBase implements IInventory
int fuelslot = 2;
boolean active = false;
public int gaugeProgressScaled(int scale) {
return (progress * scale) / fuelScale;
public int gaugeProgressScaled(final int scale) {
return this.progress * scale / this.fuelScale;
}
public int gaugeFuelScaled(int scale) {
if (fuelGague == 0) {
fuelGague = fuel;
if (fuelGague == 0) {
fuelGague = fuelScale;
public int gaugeFuelScaled(final int scale) {
if (this.fuelGague == 0) {
this.fuelGague = this.fuel;
if (this.fuelGague == 0) {
this.fuelGague = this.fuelScale;
}
}
return (fuel * scale) / fuelGague;
return this.fuel * scale / this.fuelGague;
}
@Override
public void updateEntity() {
boolean burning = isBurning();
final boolean burning = this.isBurning();
boolean updateInventory = false;
if (fuel > 0) {
fuel--;
updateState();
if (this.fuel > 0) {
this.fuel--;
this.updateState();
}
if (fuel <= 0 && canSmelt()) {
fuel = fuelGague = (int) (TileEntityFurnace.getItemBurnTime(getStackInSlot(fuelslot)) * 1.25);
if (fuel > 0) {
if (getStackInSlot(fuelslot).getItem().hasContainerItem()) // Fuel
if (this.fuel <= 0 && this.canSmelt()) {
this.fuel = this.fuelGague = (int) (TileEntityFurnace.getItemBurnTime(this.getStackInSlot(this.fuelslot)) * 1.25);
if (this.fuel > 0) {
if (this.getStackInSlot(this.fuelslot).getItem().hasContainerItem()) // Fuel
// slot
{
setInventorySlotContents(fuelslot, new ItemStack(getStackInSlot(fuelslot).getItem().getContainerItem()));
} else if (getStackInSlot(fuelslot).getCount() > 1) {
decrStackSize(fuelslot, 1);
} else if (getStackInSlot(fuelslot).getCount() == 1) {
setInventorySlotContents(fuelslot, ItemStack.EMPTY);
this.setInventorySlotContents(this.fuelslot, new ItemStack(this.getStackInSlot(this.fuelslot).getItem().getContainerItem()));
} else if (this.getStackInSlot(this.fuelslot).getCount() > 1) {
this.decrStackSize(this.fuelslot, 1);
} else if (this.getStackInSlot(this.fuelslot).getCount() == 1) {
this.setInventorySlotContents(this.fuelslot, ItemStack.EMPTY);
}
updateInventory = true;
}
}
if (isBurning() && canSmelt()) {
progress++;
if (progress >= fuelScale) {
progress = 0;
cookItems();
if (this.isBurning() && this.canSmelt()) {
this.progress++;
if (this.progress >= this.fuelScale) {
this.progress = 0;
this.cookItems();
updateInventory = true;
}
} else {
progress = 0;
this.progress = 0;
}
if (burning != isBurning()) {
if (burning != this.isBurning()) {
updateInventory = true;
}
if (updateInventory) {
markDirty();
this.markDirty();
}
}
public void cookItems() {
if (this.canSmelt()) {
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
if (getStackInSlot(output) == ItemStack.EMPTY) {
setInventorySlotContents(output, itemstack.copy());
} else if (getStackInSlot(output).isItemEqual(itemstack)) {
getStackInSlot(output).grow(itemstack.getCount());
if (this.getStackInSlot(this.output) == ItemStack.EMPTY) {
this.setInventorySlotContents(this.output, itemstack.copy());
} else if (this.getStackInSlot(this.output).isItemEqual(itemstack)) {
this.getStackInSlot(this.output).grow(itemstack.getCount());
}
if (getStackInSlot(input1).getCount() > 1) {
this.decrStackSize(input1, 1);
if (this.getStackInSlot(this.input1).getCount() > 1) {
this.decrStackSize(this.input1, 1);
} else {
setInventorySlotContents(input1, ItemStack.EMPTY);
this.setInventorySlotContents(this.input1, ItemStack.EMPTY);
}
}
}
public boolean canSmelt() {
if (getStackInSlot(input1) == ItemStack.EMPTY) {
if (this.getStackInSlot(this.input1) == ItemStack.EMPTY)
return false;
} else {
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
if (itemstack == ItemStack.EMPTY)
return false;
if (getStackInSlot(output) == ItemStack.EMPTY)
if (this.getStackInSlot(this.output) == ItemStack.EMPTY)
return true;
if (!getStackInSlot(output).isItemEqual(itemstack))
if (!this.getStackInSlot(this.output).isItemEqual(itemstack))
return false;
int result = getStackInSlot(output).getCount() + itemstack.getCount();
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
}
final int result = this.getStackInSlot(this.output).getCount() + itemstack.getCount();
return result <= this.getInventoryStackLimit() && result <= itemstack.getMaxStackSize();
}
public boolean isBurning() {
return fuel > 0;
return this.fuel > 0;
}
public ItemStack getResultFor(ItemStack stack) {
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
public ItemStack getResultFor(final ItemStack stack) {
final ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
if (result != ItemStack.EMPTY) {
return result.copy();
}
@ -131,30 +130,33 @@ public class TileIronFurnace extends TileLegacyMachineBase implements IInventory
}
public void updateState() {
IBlockState BlockStateContainer = world.getBlockState(pos);
final IBlockState BlockStateContainer = this.world.getBlockState(this.pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != fuel > 0)
blockMachineBase.setActive(fuel > 0, world, pos);
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != this.fuel > 0)
blockMachineBase.setActive(this.fuel > 0, this.world, this.pos);
}
}
@Override
public Inventory getInventory() {
return inventory;
return this.inventory;
}
public int[] getSlotsForFace(EnumFacing side) {
return side == EnumFacing.DOWN ? SLOTS_BOTTOM : (side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES);
@Override
public int[] getSlotsForFace(final EnumFacing side) {
return side == EnumFacing.DOWN ? TileIronFurnace.SLOTS_BOTTOM : side == EnumFacing.UP ? TileIronFurnace.SLOTS_TOP : TileIronFurnace.SLOTS_SIDES;
}
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
@Override
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
return this.isItemValidForSlot(index, itemStackIn);
}
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
@Override
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
if (direction == EnumFacing.DOWN && index == 1) {
Item item = stack.getItem();
final Item item = stack.getItem();
if (item != Items.WATER_BUCKET && item != Items.BUCKET) {
return false;
@ -163,4 +165,20 @@ public class TileIronFurnace extends TileLegacyMachineBase implements IInventory
return true;
}
public int getBurnTime() {
return this.fuel;
}
public void setBurnTime(final int burnTime) {
this.fuel = burnTime;
}
public int getTotalBurnTime() {
return this.fuelGague;
}
public void setTotalBurnTime(final int totalBurnTime) {
this.fuelGague = totalBurnTime;
}
}

View file

@ -7,12 +7,14 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.ForgeModContainer;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks;
public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IInventoryProvider {
@ -31,69 +33,69 @@ public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IIn
super(1);
}
public static int getItemBurnTime(ItemStack stack) {
public static int getItemBurnTime(final ItemStack stack) {
return TileEntityFurnace.getItemBurnTime(stack) / 4;
}
@Override
public void updateEntity() {
super.updateEntity();
if (world.isRemote) {
if (this.world.isRemote) {
return;
}
if (getEnergy() < getMaxPower()) {
if (burnTime > 0) {
burnTime--;
addEnergy(outputAmount);
isBurning = true;
if (this.getEnergy() < this.getMaxPower()) {
if (this.burnTime > 0) {
this.burnTime--;
this.addEnergy(TileGenerator.outputAmount);
this.isBurning = true;
}
} else {
isBurning = false;
this.isBurning = false;
}
if (burnTime == 0) {
updateState();
burnTime = totalBurnTime = getItemBurnTime(getStackInSlot(fuelSlot));
if (burnTime > 0) {
updateState();
burnItem = getStackInSlot(fuelSlot);
if (getStackInSlot(fuelSlot).getCount() == 1) {
if (getStackInSlot(fuelSlot).getItem() == Items.LAVA_BUCKET || getStackInSlot(fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket) {
setInventorySlotContents(fuelSlot, new ItemStack(Items.BUCKET));
if (this.burnTime == 0) {
this.updateState();
this.burnTime = this.totalBurnTime = TileGenerator.getItemBurnTime(this.getStackInSlot(this.fuelSlot));
if (this.burnTime > 0) {
this.updateState();
this.burnItem = this.getStackInSlot(this.fuelSlot);
if (this.getStackInSlot(this.fuelSlot).getCount() == 1) {
if (this.getStackInSlot(this.fuelSlot).getItem() == Items.LAVA_BUCKET || this.getStackInSlot(this.fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket) {
this.setInventorySlotContents(this.fuelSlot, new ItemStack(Items.BUCKET));
} else {
setInventorySlotContents(fuelSlot, ItemStack.EMPTY);
this.setInventorySlotContents(this.fuelSlot, ItemStack.EMPTY);
}
} else {
decrStackSize(fuelSlot, 1);
this.decrStackSize(this.fuelSlot, 1);
}
}
}
lastTickBurning = isBurning;
this.lastTickBurning = this.isBurning;
}
public void updateState() {
IBlockState BlockStateContainer = world.getBlockState(pos);
final IBlockState BlockStateContainer = this.world.getBlockState(this.pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != burnTime > 0)
blockMachineBase.setActive(burnTime > 0, world, pos);
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != this.burnTime > 0)
blockMachineBase.setActive(this.burnTime > 0, this.world, this.pos);
}
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
return false;
}
@Override
public EnumFacing getFacing() {
return getFacingEnum();
return this.getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
return entityPlayer.isSneaking();
}
@ -108,12 +110,12 @@ public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IIn
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
public boolean canAcceptEnergy(final EnumFacing direction) {
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
public boolean canProvideEnergy(final EnumFacing direction) {
return true;
}
@ -133,12 +135,32 @@ public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IIn
}
@Override
public ItemStack getWrenchDrop(EntityPlayer p0) {
public ItemStack getWrenchDrop(final EntityPlayer p0) {
return new ItemStack(ModBlocks.SOLID_FUEL_GENEREATOR);
}
@Override
public Inventory getInventory() {
return inventory;
return this.inventory;
}
public int getBurnTime() {
return this.burnTime;
}
public void setBurnTime(final int burnTime) {
this.burnTime = burnTime;
}
public int getTotalBurnTime() {
return this.totalBurnTime;
}
public void setTotalBurnTime(final int totalBurnTime) {
this.totalBurnTime = totalBurnTime;
}
public int getScaledBurnTime(final int i) {
return (int) ((float) this.burnTime / (float) this.totalBurnTime * i);
}
}

View file

@ -6,12 +6,14 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks;
public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory {
@ -31,78 +33,78 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
super(1);
}
public int gaugeProgressScaled(int scale) {
return (progress * scale) / fuelScale;
public int gaugeProgressScaled(final int scale) {
return this.progress * scale / this.fuelScale;
}
@Override
public void update() {
super.update();
boolean burning = isBurning();
final boolean burning = this.isBurning();
boolean updateInventory = false;
if (isBurning() && canSmelt()) {
updateState();
if (this.isBurning() && this.canSmelt()) {
this.updateState();
progress++;
if (progress % 10 == 0) {
useEnergy(cost);
this.progress++;
if (this.progress % 10 == 0) {
this.useEnergy(this.cost);
}
if (progress >= fuelScale) {
progress = 0;
cookItems();
if (this.progress >= this.fuelScale) {
this.progress = 0;
this.cookItems();
updateInventory = true;
}
} else {
progress = 0;
updateState();
this.progress = 0;
this.updateState();
}
if (burning != isBurning()) {
if (burning != this.isBurning()) {
updateInventory = true;
}
if (updateInventory) {
markDirty();
this.markDirty();
}
}
public void cookItems() {
if (this.canSmelt()) {
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
if (getStackInSlot(output) == ItemStack.EMPTY) {
setInventorySlotContents(output, itemstack.copy());
} else if (getStackInSlot(output).isItemEqual(itemstack)) {
getStackInSlot(output).grow(itemstack.getCount());
if (this.getStackInSlot(this.output) == ItemStack.EMPTY) {
this.setInventorySlotContents(this.output, itemstack.copy());
} else if (this.getStackInSlot(this.output).isItemEqual(itemstack)) {
this.getStackInSlot(this.output).grow(itemstack.getCount());
}
if (getStackInSlot(input1).getCount() > 1) {
this.decrStackSize(input1, 1);
if (this.getStackInSlot(this.input1).getCount() > 1) {
this.decrStackSize(this.input1, 1);
} else {
setInventorySlotContents(input1, ItemStack.EMPTY);
this.setInventorySlotContents(this.input1, ItemStack.EMPTY);
}
}
}
public boolean canSmelt() {
if (getStackInSlot(input1) == ItemStack.EMPTY) {
if (this.getStackInSlot(this.input1) == ItemStack.EMPTY) {
return false;
} else {
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
if (itemstack == ItemStack.EMPTY)
return false;
if (getStackInSlot(output) == ItemStack.EMPTY)
if (this.getStackInSlot(this.output) == ItemStack.EMPTY)
return true;
if (!getStackInSlot(output).isItemEqual(itemstack))
if (!this.getStackInSlot(this.output).isItemEqual(itemstack))
return false;
int result = getStackInSlot(output).getCount() + itemstack.getCount();
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
final int result = this.getStackInSlot(this.output).getCount() + itemstack.getCount();
return result <= this.getInventoryStackLimit() && result <= itemstack.getMaxStackSize();
}
}
public boolean isBurning() {
return getEnergy() > cost;
return this.getEnergy() > this.cost;
}
public ItemStack getResultFor(ItemStack stack) {
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
public ItemStack getResultFor(final ItemStack stack) {
final ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
if (result != ItemStack.EMPTY) {
return result.copy();
}
@ -110,26 +112,26 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
}
public void updateState() {
IBlockState BlockStateContainer = world.getBlockState(pos);
final IBlockState BlockStateContainer = this.world.getBlockState(this.pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != progress > 0)
blockMachineBase.setActive(progress > 0, world, pos);
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != this.progress > 0)
blockMachineBase.setActive(this.progress > 0, this.world, this.pos);
}
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
return false;
}
@Override
public EnumFacing getFacing() {
return getFacingEnum();
return this.getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
return entityPlayer.isSneaking();
}
@ -139,7 +141,7 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.ELECTRIC_FURNACE, 1);
}
@ -149,34 +151,34 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
// ISidedInventory
@Override
public int[] getSlotsForFace(EnumFacing side) {
return side == EnumFacing.DOWN ? SLOTS_BOTTOM : (side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES);
public int[] getSlotsForFace(final EnumFacing side) {
return side == EnumFacing.DOWN ? TileElectricFurnace.SLOTS_BOTTOM : side == EnumFacing.UP ? TileElectricFurnace.SLOTS_TOP : TileElectricFurnace.SLOTS_SIDES;
}
@Override
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
if (slotIndex == 2)
return false;
return isItemValidForSlot(slotIndex, itemStack);
return this.isItemValidForSlot(slotIndex, itemStack);
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
return slotIndex == 1;
}
@Override
public double getMaxPower() {
return capacity;
return this.capacity;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@ -197,6 +199,14 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
@Override
public Inventory getInventory() {
return inventory;
return this.inventory;
}
public int getBurnTime() {
return this.progress;
}
public void setBurnTime(final int burnTime) {
this.progress = burnTime;
}
}

View file

@ -4,21 +4,21 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.client.container.ContainerExtractor;
import techreborn.init.ModBlocks;
import techreborn.utils.upgrade.UpgradeHandler;
public class TileExtractor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
public class TileExtractor extends TilePowerAcceptor
implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider {
public Inventory inventory = new Inventory(6, "TileExtractor", 64, this);
@ -29,34 +29,34 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable, IIn
public TileExtractor() {
super(1);
int[] inputs = new int[1];
final int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
final int[] outputs = new int[1];
outputs[0] = 1;
crafter = new RecipeCrafter(Reference.extractorRecipe, this, 2, 1, inventory, inputs, outputs);
upgradeHandler = new UpgradeHandler(crafter, inventory, 2, 3, 4, 5);
this.crafter = new RecipeCrafter(Reference.extractorRecipe, this, 2, 1, this.inventory, inputs, outputs);
this.upgradeHandler = new UpgradeHandler(this.crafter, this.inventory, 2, 3, 4, 5);
}
@Override
public void update() {
super.update();
crafter.updateEntity();
upgradeHandler.tick();
charge(3);
this.crafter.updateEntity();
this.upgradeHandler.tick();
this.charge(3);
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
return false;
}
@Override
public EnumFacing getFacing() {
return getFacingEnum();
return this.getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
return entityPlayer.isSneaking();
}
@ -66,7 +66,7 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable, IIn
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.EXTRACTOR, 1);
}
@ -75,37 +75,37 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable, IIn
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
public void readFromNBT(final NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
this.crafter.readFromNBT(tagCompound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
this.crafter.writeToNBT(tagCompound);
return tagCompound;
}
public int getProgressScaled(int scale) {
if (crafter.currentTickTime != 0) {
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
public int getProgressScaled(final int scale) {
if (this.crafter.currentTickTime != 0) {
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
}
return 0;
}
@Override
public double getMaxPower() {
return capacity;
return this.capacity;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@ -126,31 +126,26 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable, IIn
@Override
public Inventory getInventory() {
return inventory;
return this.inventory;
}
@Override
public RecipeCrafter getRecipeCrafter() {
return crafter;
return this.crafter;
}
@Override
public RebornContainer getContainer() {
return RebornContainer.getContainerFromClass(ContainerExtractor.class, this);
}
@Override
public int[] getSlotsForFace(EnumFacing side) {
public int[] getSlotsForFace(final EnumFacing side) {
return new int[] { 0, 1 };
}
@Override
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
return index == 0;
}
@Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
return index == 1;
}

View file

@ -5,25 +5,24 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import reborncore.api.IListInfoProvider;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.client.container.ContainerGrinder;
import techreborn.init.ModBlocks;
import techreborn.utils.upgrade.UpgradeHandler;
import java.util.List;
public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInventoryProvider,
IListInfoProvider, IRecipeCrafterProvider, IContainerProvider, ISidedInventory {
IListInfoProvider, IRecipeCrafterProvider, ISidedInventory {
public Inventory inventory = new Inventory(6, "TileGrinder", 64, this);
@ -34,34 +33,34 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInve
public TileGrinder() {
super(1);
int[] inputs = new int[1];
final int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
final int[] outputs = new int[1];
outputs[0] = 1;
crafter = new RecipeCrafter(Reference.grinderRecipe, this, 2, 1, inventory, inputs, outputs);
upgradeHandler = new UpgradeHandler(crafter, inventory, 2, 3, 4, 5);
this.crafter = new RecipeCrafter(Reference.grinderRecipe, this, 2, 1, this.inventory, inputs, outputs);
this.upgradeHandler = new UpgradeHandler(this.crafter, this.inventory, 2, 3, 4, 5);
}
@Override
public void updateEntity() {
super.updateEntity();
upgradeHandler.tick();
this.upgradeHandler.tick();
//charge(3); TODO
charge(3);
this.charge(3);
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
return false;
}
@Override
public EnumFacing getFacing() {
return getFacingEnum();
return this.getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
return entityPlayer.isSneaking();
}
@ -71,7 +70,7 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInve
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.GRINDER, 1);
}
@ -80,38 +79,38 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInve
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
public void readFromNBT(final NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
this.inventory.readFromNBT(tagCompound);
this.crafter.readFromNBT(tagCompound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
this.crafter.writeToNBT(tagCompound);
return tagCompound;
}
public int getProgressScaled(int scale) {
if (crafter.currentTickTime != 0 && crafter.currentNeededTicks != 0) {
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
public int getProgressScaled(final int scale) {
if (this.crafter.currentTickTime != 0 && this.crafter.currentNeededTicks != 0) {
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
}
return 0;
}
@Override
public double getMaxPower() {
return capacity;
return this.capacity;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@ -131,37 +130,32 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInve
}
@Override
public void addInfo(List<String> info, boolean isRealTile) {
public void addInfo(final List<String> info, final boolean isRealTile) {
info.add("Macerator");
}
@Override
public Inventory getInventory() {
return inventory;
return this.inventory;
}
@Override
public RecipeCrafter getRecipeCrafter() {
return crafter;
return this.crafter;
}
@Override
public RebornContainer getContainer() {
return RebornContainer.getContainerFromClass(ContainerGrinder.class, this);
}
@Override
public int[] getSlotsForFace(EnumFacing side) {
public int[] getSlotsForFace(final EnumFacing side) {
return new int[] { 0, 1 };
}
@Override
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
return index == 0;
}
@Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
return index == 1;
}
}

View file

@ -5,12 +5,14 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks;
import techreborn.items.ItemParts;
@ -30,107 +32,107 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInv
super(1);
}
public int gaugeProgressScaled(int scale) {
return (progress * scale) / time;
public int gaugeProgressScaled(final int scale) {
return this.progress * scale / this.time;
}
@Override
public void updateEntity() {
if (world.isRemote) {
if (this.world.isRemote) {
return;
}
boolean burning = isBurning();
final boolean burning = this.isBurning();
boolean updateInventory = false;
if (getEnergy() <= cost && canRecycle()) {
if (getEnergy() > cost) {
if (this.getEnergy() <= this.cost && this.canRecycle()) {
if (this.getEnergy() > this.cost) {
updateInventory = true;
}
}
if (isBurning() && canRecycle()) {
updateState();
if (this.isBurning() && this.canRecycle()) {
this.updateState();
progress++;
if (progress >= time) {
progress = 0;
recycleItems();
this.progress++;
if (this.progress >= this.time) {
this.progress = 0;
this.recycleItems();
updateInventory = true;
}
} else {
progress = 0;
updateState();
this.progress = 0;
this.updateState();
}
if (burning != isBurning()) {
if (burning != this.isBurning()) {
updateInventory = true;
}
if (updateInventory) {
markDirty();
this.markDirty();
}
}
public void recycleItems() {
if (this.canRecycle()) {
ItemStack itemstack = ItemParts.getPartByName("scrap");
int randomchance = world.rand.nextInt(chance);
final ItemStack itemstack = ItemParts.getPartByName("scrap");
final int randomchance = this.world.rand.nextInt(this.chance);
if (getStackInSlot(output) == ItemStack.EMPTY) {
useEnergy(cost);
if (this.getStackInSlot(this.output) == ItemStack.EMPTY) {
this.useEnergy(this.cost);
if (randomchance == 1) {
setInventorySlotContents(output, itemstack.copy());
this.setInventorySlotContents(this.output, itemstack.copy());
}
} else if (getStackInSlot(output).isItemEqual(itemstack)) {
useEnergy(cost);
} else if (this.getStackInSlot(this.output).isItemEqual(itemstack)) {
this.useEnergy(this.cost);
if (randomchance == 1) {
getStackInSlot(output).setCount(itemstack.getCount());
this.getStackInSlot(this.output).setCount(itemstack.getCount());
}
}
if (getStackInSlot(input1).getCount() > 1) {
useEnergy(cost);
this.decrStackSize(input1, 1);
if (this.getStackInSlot(this.input1).getCount() > 1) {
this.useEnergy(this.cost);
this.decrStackSize(this.input1, 1);
} else {
useEnergy(cost);
setInventorySlotContents(input1, ItemStack.EMPTY);
this.useEnergy(this.cost);
this.setInventorySlotContents(this.input1, ItemStack.EMPTY);
}
}
}
public boolean canRecycle() {
return getStackInSlot(input1) != null && hasSlotGotSpace(output);
return this.getStackInSlot(this.input1) != null && this.hasSlotGotSpace(this.output);
}
public boolean hasSlotGotSpace(int slot) {
if (getStackInSlot(slot) == ItemStack.EMPTY) {
public boolean hasSlotGotSpace(final int slot) {
if (this.getStackInSlot(slot) == ItemStack.EMPTY) {
return true;
} else if (getStackInSlot(slot).getCount() < getStackInSlot(slot).getMaxStackSize()) {
} else if (this.getStackInSlot(slot).getCount() < this.getStackInSlot(slot).getMaxStackSize()) {
return true;
}
return true;
}
public boolean isBurning() {
return getEnergy() > cost;
return this.getEnergy() > this.cost;
}
public void updateState() {
IBlockState BlockStateContainer = world.getBlockState(pos);
final IBlockState BlockStateContainer = this.world.getBlockState(this.pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != progress > 0)
blockMachineBase.setActive(progress > 0, world, pos);
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != this.progress > 0)
blockMachineBase.setActive(this.progress > 0, this.world, this.pos);
}
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
return false;
}
@Override
public EnumFacing getFacing() {
return getFacingEnum();
return this.getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
return entityPlayer.isSneaking();
}
@ -140,7 +142,7 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInv
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.RECYCLER, 1);
}
@ -150,34 +152,34 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInv
// ISidedInventory
@Override
public int[] getSlotsForFace(EnumFacing side) {
return side == EnumFacing.DOWN ? new int[] { output } : new int[] { input1 };
public int[] getSlotsForFace(final EnumFacing side) {
return side == EnumFacing.DOWN ? new int[] { this.output } : new int[] { this.input1 };
}
@Override
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
if (slotIndex == output)
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
if (slotIndex == this.output)
return false;
return isItemValidForSlot(slotIndex, itemStack);
return this.isItemValidForSlot(slotIndex, itemStack);
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
return slotIndex == output;
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
return slotIndex == this.output;
}
@Override
public double getMaxPower() {
return capacity;
return this.capacity;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@ -198,6 +200,14 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInv
@Override
public Inventory getInventory() {
return inventory;
return this.inventory;
}
public int getProgress() {
return this.progress;
}
public void setProgress(final int progress) {
this.progress = progress;
}
}