Add JEI transfer support for ContainerBuilder + Convert Compressor, Extractor and Grinder

This commit is contained in:
Ourten 2017-01-08 02:04:02 +01:00
parent 1df2c84e16
commit 94a0616d8e
28 changed files with 401 additions and 433 deletions

View file

@ -67,17 +67,18 @@ 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.gasTurbineID || ID == GuiHandler.semifluidGeneratorID
|| ID == GuiHandler.thermalGeneratorID || ID == GuiHandler.dieselGeneratorID) {
return new ContainerBuilder().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();
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) {
@ -87,7 +88,8 @@ public class GuiHandler implements IGuiHandler {
} 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);
@ -98,9 +100,10 @@ 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)));
container = new ContainerAssemblingMachine(player,
(TileAssemblingMachine) world.getTileEntity(new BlockPos(x, y, z)));
} else if (ID == GuiHandler.chunkloaderID) {
return new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory()
return new ContainerBuilder("chunkloader").player(player.inventory).inventory().hotbar().addInventory()
.create();
} else if (ID == GuiHandler.industrialElectrolyzerID) {
return new ContainerIndustrialElectrolyzer(
@ -127,38 +130,47 @@ 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 ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).fuelSlot(0, 80, 53)
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.extractorID) {
container = new ContainerExtractor(player, (TileExtractor) world.getTileEntity(new BlockPos(x, y, z)));
} 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 ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 56, 34)
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 ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 56, 17)
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)
@ -170,11 +182,16 @@ public class GuiHandler implements IGuiHandler {
} 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();
@ -193,7 +210,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,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,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,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

@ -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

@ -10,6 +10,7 @@ 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;
@ -110,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

@ -17,7 +17,7 @@ public class GuiBatbox extends GuiContainer {
TileBatBox generator;
public GuiBatbox(final EntityPlayer player, final TileBatBox generator) {
super(new ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
super(new ContainerBuilder("batbox").player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile(generator).energySlot(0, 80, 17).energySlot(1, 80, 53).syncEnergyValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;

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

@ -13,7 +13,7 @@ import techreborn.tiles.TileChunkLoader;
public class GuiChunkLoader extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/industrial_chunkloader.png");
"textures/gui/industrial_chunkloader.png");
TileChunkLoader chunkloader;
private GuiButton plusOneButton;
private GuiButton plusTenButton;
@ -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,33 +33,34 @@ 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);
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
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.ContainerCompressor;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.teir1.TileCompressor;
public class GuiCompressor extends GuiContainer {
@ -13,42 +14,45 @@ 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);
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.ySize - 96 + 2, 4210752);
}
}

View file

@ -19,8 +19,9 @@ public class GuiDieselGenerator extends GuiContainer {
TileDieselGenerator tile;
public GuiDieselGenerator(final EntityPlayer player, final TileDieselGenerator tile) {
super(new ContainerBuilder().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());
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;

View file

@ -2,6 +2,7 @@ package techreborn.client.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.TileDigitalChest;
@ -10,25 +11,27 @@ 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

@ -16,9 +16,9 @@ public class GuiElectricFurnace extends GuiContainer {
TileElectricFurnace furnace;
public GuiElectricFurnace(final EntityPlayer player, final TileElectricFurnace furnace) {
super(new ContainerBuilder().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()
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;

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,42 +14,44 @@ 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);
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.ySize - 96 + 2, 4210752);
}
}

View file

@ -18,8 +18,10 @@ public class GuiGasTurbine extends GuiContainer {
TileGasTurbine tile;
public GuiGasTurbine(final EntityPlayer player, final TileGasTurbine tile) {
super(new ContainerBuilder().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());
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;

View file

@ -17,7 +17,7 @@ public class GuiGenerator extends GuiContainer {
TileGenerator generator;
public GuiGenerator(final EntityPlayer player, final TileGenerator generator) {
super(new ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
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());

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);
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.ySize - 96 + 2, 4210752);
}
}

View file

@ -17,8 +17,8 @@ public class GuiIronFurnace extends GuiContainer {
TileIronFurnace furnace;
public GuiIronFurnace(final EntityPlayer player, final TileIronFurnace furnace) {
super(new ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile(furnace).slot(0, 56, 17).outputSlot(1, 116, 34).fuelSlot(2, 56, 53)
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());

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

@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.common.util.ItemUtils;
import techreborn.client.container.builder.ContainerBuilder;
@ -14,42 +15,44 @@ import techreborn.tiles.TileQuantumChest;
public class GuiQuantumChest extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/thermal_generator.png");
"textures/gui/thermal_generator.png");
TileQuantumChest tile;
public GuiQuantumChest(final EntityPlayer player, final TileQuantumChest tile) {
super(new ContainerBuilder().player(player.inventory).inventory(8, 64).hotbar(8, 152).addInventory().tile(tile)
.slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).addInventory().create());
super(new ContainerBuilder("quantumchest").player(player.inventory).inventory(8, 64).hotbar(8, 152)
.addInventory().tile(tile).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).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(GuiQuantumChest.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.quantumChest.name");
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.quantumChest.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Amount", 10, 20, 16448255);
int count = 0;
if (tile.storedItem != ItemStack.EMPTY || !tile.getStackInSlot(1).isEmpty()) {
if (this.tile.storedItem != ItemStack.EMPTY || !this.tile.getStackInSlot(1).isEmpty()) {
count = tile.storedItem.getCount();
if (tile.getStackInSlot(1) != ItemStack.EMPTY && (tile.storedItem.isEmpty()
|| ItemUtils.isItemEqual(tile.getStackInSlot(1), tile.getStackInSlot(2), true, true)))
count += tile.getStackInSlot(1).getCount();
count = this.tile.storedItem.getCount();
if (this.tile.getStackInSlot(1) != ItemStack.EMPTY && (this.tile.storedItem.isEmpty()
|| ItemUtils.isItemEqual(this.tile.getStackInSlot(1), this.tile.getStackInSlot(2), true, true)))
count += this.tile.getStackInSlot(1).getCount();
}
this.fontRendererObj.drawString(count + "", 10, 30, 16448255);
}

View file

@ -20,8 +20,9 @@ public class GuiSemifluidGenerator extends GuiContainer {
TileSemifluidGenerator tile;
public GuiSemifluidGenerator(final EntityPlayer player, final TileSemifluidGenerator tile) {
super(new ContainerBuilder().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());
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;

View file

@ -19,8 +19,9 @@ public class GuiThermalGenerator extends GuiContainer {
TileThermalGenerator tile;
public GuiThermalGenerator(final EntityPlayer player, final TileThermalGenerator tile) {
super(new ContainerBuilder().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());
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;

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,26 +59,33 @@ 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,
dirtBlock, time, 120);
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,
dirtBlock, time, 120);
final int time = (int) Math.round(200 + Math.random() * 100);
final ImplosionCompressorRecipe recipe = new ImplosionCompressorRecipe(diamondBlock, diamondBlock, dirtBlock,
dirtBlock, time, 120);
debugRecipes.add(recipe);
}
registry.addRecipes(debugRecipes);
@ -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,28 +186,28 @@ 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.");
.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"),
I18n.translateToLocal("techreborn.desc.rubberSap"));
I18n.translateToLocal("techreborn.desc.rubberSap"));
if (!ConfigTechReborn.ScrapboxDispenser) {
registry.addDescription(new ItemStack(ModItems.SCRAP_BOX),
I18n.translateToLocal("techreborn.desc.scrapBoxNoDispenser"));
I18n.translateToLocal("techreborn.desc.scrapBoxNoDispenser"));
} else {
registry.addDescription(new ItemStack(ModItems.SCRAP_BOX),
I18n.translateToLocal("techreborn.desc.scrapBox"));
I18n.translateToLocal("techreborn.desc.scrapBox"));
}
registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER,
VanillaRecipeCategoryUid.FUEL);
VanillaRecipeCategoryUid.FUEL);
registry.addRecipeClickArea(GuiAlloySmelter.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER);
registry.addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE);
registry.addRecipeClickArea(GuiBlastFurnace.class, 63, 36, 24, 15, RecipeCategoryUids.BLAST_FURNACE);
@ -215,16 +219,16 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR);
registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER);
registry.addRecipeClickArea(GuiImplosionCompressor.class, 60, 37, 24, 15,
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
registry.addRecipeClickArea(GuiIndustrialElectrolyzer.class, 72, 37, 33, 14,
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
registry.addRecipeClickArea(GuiRollingMachine.class, 89, 32, 26, 25, RecipeCategoryUids.ROLLING_MACHINE);
registry.addRecipeClickArea(GuiVacuumFreezer.class, 78, 36, 24, 16, RecipeCategoryUids.VACUUM_FREEZER);
registry.addRecipeClickArea(GuiGrinder.class, 78, 36, 24, 16, RecipeCategoryUids.GRINDER);
registry.addRecipeClickArea(GuiExtractor.class, 78, 36, 24, 16, RecipeCategoryUids.EXTRACTOR);
registry.addRecipeClickArea(GuiCompressor.class, 78, 36, 24, 16, RecipeCategoryUids.COMPRESSOR);
registry.addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING,
VanillaRecipeCategoryUid.FUEL);
VanillaRecipeCategoryUid.FUEL);
registry.addRecipeClickArea(GuiElectricFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING);
registry.addRecipeClickArea(GuiSemifluidGenerator.class, 79, 34, 18, 18,
@ -240,23 +244,23 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IRON_ALLOY_FURNACE), RecipeCategoryUids.ALLOY_SMELTER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ALLOY_SMELTER), RecipeCategoryUids.ALLOY_SMELTER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ASSEMBLY_MACHINE),
RecipeCategoryUids.ASSEMBLING_MACHINE);
RecipeCategoryUids.ASSEMBLING_MACHINE);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_BLAST_FURNACE), RecipeCategoryUids.BLAST_FURNACE);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_CENTRIFUGE), RecipeCategoryUids.CENTRIFUGE);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.CHEMICAL_REACTOR),
RecipeCategoryUids.CHEMICAL_REACTOR);
RecipeCategoryUids.CHEMICAL_REACTOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.EXTRACTOR), RecipeCategoryUids.EXTRACTOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.FUSION_CONTROL_COMPUTER),
RecipeCategoryUids.FUSION_REACTOR);
RecipeCategoryUids.FUSION_REACTOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GRINDER), RecipeCategoryUids.GRINDER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IMPLOSION_COMPRESSOR),
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_ELECTROLYZER),
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_GRINDER),
RecipeCategoryUids.INDUSTRIAL_GRINDER);
RecipeCategoryUids.INDUSTRIAL_GRINDER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ROLLING_MACHINE),
RecipeCategoryUids.ROLLING_MACHINE);
RecipeCategoryUids.ROLLING_MACHINE);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModItems.SCRAP_BOX), RecipeCategoryUids.SCRAPBOX);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.SEMIFLUID_GENERATOR),
@ -268,43 +272,44 @@ 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);
.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloySmelter.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 8, 36);
.addRecipeTransferHandler(ContainerAlloySmelter.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 8, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloyFurnace.class, VanillaRecipeCategoryUid.FUEL, 3, 1, 4, 36);
.addRecipeTransferHandler(ContainerAlloyFurnace.class, VanillaRecipeCategoryUid.FUEL, 3, 1, 4, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAssemblingMachine.class, RecipeCategoryUids.ASSEMBLING_MACHINE, 0, 2,
.addRecipeTransferHandler(ContainerAssemblingMachine.class, RecipeCategoryUids.ASSEMBLING_MACHINE, 0, 2,
8, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerCentrifuge.class, RecipeCategoryUids.CENTRIFUGE, 0, 2, 11, 36);
.addRecipeTransferHandler(ContainerCentrifuge.class, RecipeCategoryUids.CENTRIFUGE, 0, 2, 11, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerChemicalReactor.class, RecipeCategoryUids.CHEMICAL_REACTOR, 0, 2, 8,
.addRecipeTransferHandler(ContainerChemicalReactor.class, RecipeCategoryUids.CHEMICAL_REACTOR, 0, 2, 8,
36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerIndustrialGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36);
.addRecipeTransferHandler(ContainerIndustrialGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerImplosionCompressor.class, RecipeCategoryUids.IMPLOSION_COMPRESSOR,
.addRecipeTransferHandler(ContainerImplosionCompressor.class, RecipeCategoryUids.IMPLOSION_COMPRESSOR,
0, 2, 4, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialElectrolyzer.class,
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36);
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11,
.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11,
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);
.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 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

@ -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;
}
}