diff --git a/src/main/java/techreborn/blocks/BlockComputerCube.java b/src/main/java/techreborn/blocks/BlockComputerCube.java index 6a3435b2f..b938fb6fa 100644 --- a/src/main/java/techreborn/blocks/BlockComputerCube.java +++ b/src/main/java/techreborn/blocks/BlockComputerCube.java @@ -3,48 +3,50 @@ package techreborn.blocks; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; public class BlockComputerCube extends BlockMachineBase implements IAdvancedRotationTexture { private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockComputerCube(Material material) { + public BlockComputerCube(final Material material) { super(); - setUnlocalizedName("techreborn.computercube"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.computercube"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.manuelID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.MANUAL.ordinal(), world, x, y, z); return true; } @Override - public String getFront(boolean isActive) { - return prefix + "computer_cube"; + public String getFront(final boolean isActive) { + return this.prefix + "computer_cube"; } @Override - public String getSide(boolean isActive) { - return prefix + "computer_cube"; + public String getSide(final boolean isActive) { + return this.prefix + "computer_cube"; } @Override - public String getTop(boolean isActive) { - return prefix + "computer_cube"; + public String getTop(final boolean isActive) { + return this.prefix + "computer_cube"; } @Override - public String getBottom(boolean isActive) { - return prefix + "computer_cube"; + public String getBottom(final boolean isActive) { + return this.prefix + "computer_cube"; } } \ No newline at end of file diff --git a/src/main/java/techreborn/blocks/BlockDigitalChest.java b/src/main/java/techreborn/blocks/BlockDigitalChest.java index ca0624393..e62612032 100644 --- a/src/main/java/techreborn/blocks/BlockDigitalChest.java +++ b/src/main/java/techreborn/blocks/BlockDigitalChest.java @@ -6,7 +6,6 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -14,8 +13,9 @@ import net.minecraftforge.fluids.BlockFluidBase; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileDigitalChest; import techreborn.tiles.TileTechStorageBase; @@ -30,13 +30,13 @@ public class BlockDigitalChest extends BlockMachineBase implements IAdvancedRota public BlockDigitalChest() { super(); - setUnlocalizedName("techreborn.digitalChest"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.digitalChest"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - protected void dropInventory(World world, BlockPos pos) { - TileEntity tileEntity = world.getTileEntity(pos); + protected void dropInventory(final World world, final BlockPos pos) { + final TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity == null) { return; @@ -45,13 +45,13 @@ public class BlockDigitalChest extends BlockMachineBase implements IAdvancedRota return; } - TileTechStorageBase inventory = (TileTechStorageBase) tileEntity; + final TileTechStorageBase inventory = (TileTechStorageBase) tileEntity; - List items = new ArrayList(); + final List items = new ArrayList<>(); - List droppables = inventory.getContentDrops(); + final List droppables = inventory.getContentDrops(); for (int i = 0; i < droppables.size(); i++) { - ItemStack itemStack = droppables.get(i); + final ItemStack itemStack = droppables.get(i); if (itemStack == ItemStack.EMPTY) { continue; @@ -68,21 +68,21 @@ public class BlockDigitalChest extends BlockMachineBase implements IAdvancedRota items.add(itemStack.copy()); } - for (ItemStack itemStack : items) { - Random rand = new Random(); + for (final ItemStack itemStack : items) { + final Random rand = new Random(); - float dX = rand.nextFloat() * 0.8F + 0.1F; - float dY = rand.nextFloat() * 0.8F + 0.1F; - float dZ = rand.nextFloat() * 0.8F + 0.1F; + final float dX = rand.nextFloat() * 0.8F + 0.1F; + final float dY = rand.nextFloat() * 0.8F + 0.1F; + final float dZ = rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, + final EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, itemStack.copy()); if (itemStack.hasTagCompound()) { - entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); + entityItem.getEntityItem().setTagCompound(itemStack.getTagCompound().copy()); } - float factor = 0.05F; + final float factor = 0.05F; entityItem.motionX = rand.nextGaussian() * factor; entityItem.motionY = rand.nextGaussian() * factor + 0.2F; entityItem.motionZ = rand.nextGaussian() * factor; @@ -92,35 +92,35 @@ public class BlockDigitalChest extends BlockMachineBase implements IAdvancedRota } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileDigitalChest(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.digitalChestID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.DIGITAL_CHEST.ordinal(), world, x, y, z); return true; } @Override - public String getFront(boolean isActive) { - return prefix + "quantum_chest"; + public String getFront(final boolean isActive) { + return this.prefix + "quantum_chest"; } @Override - public String getSide(boolean isActive) { - return prefix + "qchest_side"; + public String getSide(final boolean isActive) { + return this.prefix + "qchest_side"; } @Override - public String getTop(boolean isActive) { - return prefix + "quantum_top"; + public String getTop(final boolean isActive) { + return this.prefix + "quantum_top"; } @Override - public String getBottom(boolean isActive) { - return prefix + "machine_bottom"; + public String getBottom(final boolean isActive) { + return this.prefix + "machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/BlockFusionControlComputer.java b/src/main/java/techreborn/blocks/BlockFusionControlComputer.java index c2b04f7fd..738f37855 100644 --- a/src/main/java/techreborn/blocks/BlockFusionControlComputer.java +++ b/src/main/java/techreborn/blocks/BlockFusionControlComputer.java @@ -6,10 +6,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.fusionReactor.TileEntityFusionController; import techreborn.utils.damageSources.FusionDamageSource; @@ -18,56 +20,56 @@ public class BlockFusionControlComputer extends BlockMachineBase implements IAdv private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockFusionControlComputer(Material material) { + public BlockFusionControlComputer(final Material material) { super(); - setUnlocalizedName("techreborn.fusioncontrolcomputer"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.fusioncontrolcomputer"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { - TileEntityFusionController tileEntityFusionController = (TileEntityFusionController) world - .getTileEntity(new BlockPos(x, y, z)); + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { + final TileEntityFusionController tileEntityFusionController = (TileEntityFusionController) world + .getTileEntity(new BlockPos(x, y, z)); tileEntityFusionController.checkCoils(); if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.fusionID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.FUSION_CONTROLLER.ordinal(), world, x, y, z); return true; } @Override - public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) { + public void onEntityWalk(final World worldIn, final BlockPos pos, final Entity entityIn) { super.onEntityWalk(worldIn, pos, entityIn); if (worldIn.getTileEntity(pos) instanceof TileEntityFusionController) { if (((TileEntityFusionController) worldIn.getTileEntity(pos)).crafingTickTime != 0 - && ((TileEntityFusionController) worldIn.getTileEntity(pos)).checkCoils()) { + && ((TileEntityFusionController) worldIn.getTileEntity(pos)).checkCoils()) { entityIn.attackEntityFrom(new FusionDamageSource(), 200F); } } } @Override - public TileEntity createNewTileEntity(World world, int meta) { + public TileEntity createNewTileEntity(final World world, final int meta) { return new TileEntityFusionController(); } @Override - public String getFront(boolean isActive) { - return prefix + "fusion_control_computer_front"; + public String getFront(final boolean isActive) { + return this.prefix + "fusion_control_computer_front"; } @Override - public String getSide(boolean isActive) { - return prefix + "machine_side"; + public String getSide(final boolean isActive) { + return this.prefix + "machine_side"; } @Override - public String getTop(boolean isActive) { - return prefix + "machine_side"; + public String getTop(final boolean isActive) { + return this.prefix + "machine_side"; } @Override - public String getBottom(boolean isActive) { - return prefix + "machine_side"; + public String getBottom(final boolean isActive) { + return this.prefix + "machine_side"; } } diff --git a/src/main/java/techreborn/blocks/BlockQuantumChest.java b/src/main/java/techreborn/blocks/BlockQuantumChest.java index ca4aa6342..f6c4d8789 100644 --- a/src/main/java/techreborn/blocks/BlockQuantumChest.java +++ b/src/main/java/techreborn/blocks/BlockQuantumChest.java @@ -5,10 +5,8 @@ import net.minecraft.block.BlockStaticLiquid; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; @@ -20,7 +18,7 @@ import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileQuantumChest; import techreborn.tiles.TileTechStorageBase; @@ -35,14 +33,14 @@ public class BlockQuantumChest extends BlockMachineBase implements IAdvancedRota public BlockQuantumChest() { super(); - setUnlocalizedName("techreborn.quantumChest"); - setCreativeTab(TechRebornCreativeTab.instance); - setHardness(2.0F); + this.setUnlocalizedName("techreborn.quantumChest"); + this.setCreativeTab(TechRebornCreativeTab.instance); + this.setHardness(2.0F); } @Override - protected void dropInventory(World world, BlockPos pos) { - TileEntity tileEntity = world.getTileEntity(pos); + protected void dropInventory(final World world, final BlockPos pos) { + final TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity == null) { return; @@ -51,13 +49,13 @@ public class BlockQuantumChest extends BlockMachineBase implements IAdvancedRota return; } - TileTechStorageBase inventory = (TileTechStorageBase) tileEntity; + final TileTechStorageBase inventory = (TileTechStorageBase) tileEntity; - List items = new ArrayList(); + final List items = new ArrayList<>(); - List droppables = inventory.getContentDrops(); + final List droppables = inventory.getContentDrops(); for (int i = 0; i < droppables.size(); i++) { - ItemStack itemStack = droppables.get(i); + final ItemStack itemStack = droppables.get(i); if (itemStack == ItemStack.EMPTY) { continue; @@ -74,21 +72,21 @@ public class BlockQuantumChest extends BlockMachineBase implements IAdvancedRota items.add(itemStack.copy()); } - for (ItemStack itemStack : items) { - Random rand = new Random(); + for (final ItemStack itemStack : items) { + final Random rand = new Random(); - float dX = rand.nextFloat() * 0.8F + 0.1F; - float dY = rand.nextFloat() * 0.8F + 0.1F; - float dZ = rand.nextFloat() * 0.8F + 0.1F; + final float dX = rand.nextFloat() * 0.8F + 0.1F; + final float dY = rand.nextFloat() * 0.8F + 0.1F; + final float dZ = rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, + final EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, itemStack.copy()); if (itemStack.hasTagCompound()) { - entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); + entityItem.getEntityItem().setTagCompound(itemStack.getTagCompound().copy()); } - float factor = 0.05F; + final float factor = 0.05F; entityItem.motionX = rand.nextGaussian() * factor; entityItem.motionY = rand.nextGaussian() * factor + 0.2F; entityItem.motionZ = rand.nextGaussian() * factor; @@ -98,35 +96,35 @@ public class BlockQuantumChest extends BlockMachineBase implements IAdvancedRota } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileQuantumChest(); } @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(final World worldIn, final BlockPos pos, final IBlockState state, final EntityPlayer playerIn, + final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ) { if (!playerIn.isSneaking()) - playerIn.openGui(Core.INSTANCE, GuiHandler.quantumChestID, worldIn, pos.getX(), pos.getY(), pos.getZ()); + playerIn.openGui(Core.INSTANCE, EGui.QUANTUM_CHEST.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } @Override - public String getFront(boolean isActive) { - return prefix + "quantum_chest"; + public String getFront(final boolean isActive) { + return this.prefix + "quantum_chest"; } @Override - public String getSide(boolean isActive) { - return prefix + "qchest_side"; + public String getSide(final boolean isActive) { + return this.prefix + "qchest_side"; } @Override - public String getTop(boolean isActive) { - return prefix + "quantum_top"; + public String getTop(final boolean isActive) { + return this.prefix + "quantum_top"; } @Override - public String getBottom(boolean isActive) { - return prefix + "machine_bottom"; + public String getBottom(final boolean isActive) { + return this.prefix + "machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/BlockQuantumTank.java b/src/main/java/techreborn/blocks/BlockQuantumTank.java index cae551d75..84725fc29 100644 --- a/src/main/java/techreborn/blocks/BlockQuantumTank.java +++ b/src/main/java/techreborn/blocks/BlockQuantumTank.java @@ -4,10 +4,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileQuantumTank; @@ -17,45 +19,45 @@ public class BlockQuantumTank extends BlockMachineBase implements IAdvancedRotat public BlockQuantumTank() { super(); - setUnlocalizedName("techreborn.quantumTank"); - setHardness(2.0F); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.quantumTank"); + this.setHardness(2.0F); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileQuantumTank(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { - if (fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { + if (this.fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { return true; } if (!player.isSneaking()) { - player.openGui(Core.INSTANCE, GuiHandler.quantumTankID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.QUANTUM_TANK.ordinal(), world, x, y, z); } return true; } @Override - public String getFront(boolean isActive) { + public String getFront(final boolean isActive) { return "techreborn:blocks/machine/generators/thermal_generator_side_off"; } @Override - public String getSide(boolean isActive) { + public String getSide(final boolean isActive) { return "techreborn:blocks/machine/generators/thermal_generator_side_off"; } @Override - public String getTop(boolean isActive) { - return prefix + "quantum_top"; + public String getTop(final boolean isActive) { + return this.prefix + "quantum_top"; } @Override - public String getBottom(boolean isActive) { + public String getBottom(final boolean isActive) { return "techreborn:blocks/machine/generators/thermal_generator_bottom"; } } diff --git a/src/main/java/techreborn/blocks/advanced_machine/BlockBlastFurnace.java b/src/main/java/techreborn/blocks/advanced_machine/BlockBlastFurnace.java index ea75349a5..75bdc6842 100644 --- a/src/main/java/techreborn/blocks/advanced_machine/BlockBlastFurnace.java +++ b/src/main/java/techreborn/blocks/advanced_machine/BlockBlastFurnace.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.multiblock.TileBlastFurnace; @@ -15,22 +17,22 @@ public class BlockBlastFurnace extends BlockMachineBase implements IRotationText private final String prefix = "techreborn:blocks/machine/advanced_machines/"; - public BlockBlastFurnace(Material material) { + public BlockBlastFurnace(final Material material) { super(); - setUnlocalizedName("techreborn.blastfurnace"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.blastfurnace"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileBlastFurnace(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.blastFurnaceID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.BLAST_FURNACE.ordinal(), world, x, y, z); return true; } @@ -41,26 +43,26 @@ public class BlockBlastFurnace extends BlockMachineBase implements IRotationText @Override public String getFrontOff() { - return prefix + "industrial_blast_furnace_front_off"; + return this.prefix + "industrial_blast_furnace_front_off"; } @Override public String getFrontOn() { - return prefix + "industrial_blast_furnace_front_on"; + return this.prefix + "industrial_blast_furnace_front_on"; } @Override public String getSide() { - return prefix + "advanced_machine_side"; + return this.prefix + "advanced_machine_side"; } @Override public String getTop() { - return prefix + "advanced_machine_top"; + return this.prefix + "advanced_machine_top"; } @Override public String getBottom() { - return prefix + "advanced_machine_bottom"; + return this.prefix + "advanced_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/advanced_machine/BlockCentrifuge.java b/src/main/java/techreborn/blocks/advanced_machine/BlockCentrifuge.java index 68b48f2b8..9379a70e0 100644 --- a/src/main/java/techreborn/blocks/advanced_machine/BlockCentrifuge.java +++ b/src/main/java/techreborn/blocks/advanced_machine/BlockCentrifuge.java @@ -3,10 +3,12 @@ package techreborn.blocks.advanced_machine; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileCentrifuge; @@ -16,46 +18,46 @@ public class BlockCentrifuge extends BlockMachineBase implements IRotationTextur public BlockCentrifuge() { super(); - setUnlocalizedName("techreborn.centrifuge"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.centrifuge"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileCentrifuge(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) { - player.openGui(Core.INSTANCE, GuiHandler.centrifugeID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.CENTRIFUGE.ordinal(), world, x, y, z); } return true; } @Override public String getFrontOff() { - return prefix + "industrial_centrifuge_side_off"; + return this.prefix + "industrial_centrifuge_side_off"; } @Override public String getFrontOn() { - return prefix + "industrial_centrifuge_side_on"; + return this.prefix + "industrial_centrifuge_side_on"; } @Override public String getSide() { - return getFrontOff(); + return this.getFrontOff(); } @Override public String getTop() { - return prefix + "industrial_centrifuge_top_off"; + return this.prefix + "industrial_centrifuge_top_off"; } @Override public String getBottom() { - return prefix + "industrial_centrifuge_bottom"; + return this.prefix + "industrial_centrifuge_bottom"; } } diff --git a/src/main/java/techreborn/blocks/advanced_machine/BlockImplosionCompressor.java b/src/main/java/techreborn/blocks/advanced_machine/BlockImplosionCompressor.java index fe557a377..0dbdff8ff 100644 --- a/src/main/java/techreborn/blocks/advanced_machine/BlockImplosionCompressor.java +++ b/src/main/java/techreborn/blocks/advanced_machine/BlockImplosionCompressor.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.multiblock.TileImplosionCompressor; @@ -15,47 +17,47 @@ public class BlockImplosionCompressor extends BlockMachineBase implements IRotat private final String prefix = "techreborn:blocks/machine/advanced_machines/"; - public BlockImplosionCompressor(Material material) { + public BlockImplosionCompressor(final Material material) { super(); - setUnlocalizedName("techreborn.implosioncompressor"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.implosioncompressor"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileImplosionCompressor(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.implosionCompresserID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.IMPLOSION_COMPRESSOR.ordinal(), world, x, y, z); return true; } @Override public String getFrontOff() { - return prefix + "implosion_compressor_front_off"; + return this.prefix + "implosion_compressor_front_off"; } @Override public String getFrontOn() { - return prefix + "implosion_compressor_front_on"; + return this.prefix + "implosion_compressor_front_on"; } @Override public String getSide() { - return prefix + "advanced_machine_side"; + return this.prefix + "advanced_machine_side"; } @Override public String getTop() { - return prefix + "industrial_centrifuge_top_off"; + return this.prefix + "industrial_centrifuge_top_off"; } @Override public String getBottom() { - return prefix + "implosion_compressor_bottom"; + return this.prefix + "implosion_compressor_bottom"; } } diff --git a/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialElectrolyzer.java b/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialElectrolyzer.java index a75777266..b546d3e9c 100644 --- a/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialElectrolyzer.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileIndustrialElectrolyzer; @@ -15,47 +17,47 @@ public class BlockIndustrialElectrolyzer extends BlockMachineBase implements IRo private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockIndustrialElectrolyzer(Material material) { + public BlockIndustrialElectrolyzer(final Material material) { super(); - setUnlocalizedName("techreborn.industrialelectrolyzer"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.industrialelectrolyzer"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileIndustrialElectrolyzer(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.industrialElectrolyzerID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.INDUSTRIAL_ELECTROLYZER.ordinal(), world, x, y, z); return true; } @Override public String getFrontOff() { - return prefix + "industrial_electrolyzer_front_off"; + return this.prefix + "industrial_electrolyzer_front_off"; } @Override public String getFrontOn() { - return prefix + "industrial_electrolyzer_front_on"; + return this.prefix + "industrial_electrolyzer_front_on"; } @Override public String getSide() { - return prefix + "industrial_electrolyzer_front_off"; + return this.prefix + "industrial_electrolyzer_front_off"; } @Override public String getTop() { - return prefix + "machine_top"; + return this.prefix + "machine_top"; } @Override public String getBottom() { - return prefix + "machine_bottom"; + return this.prefix + "machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialGrinder.java b/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialGrinder.java index f9208f60f..b1ecdb828 100644 --- a/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialGrinder.java +++ b/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialGrinder.java @@ -5,10 +5,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.multiblock.TileIndustrialGrinder; @@ -16,50 +18,50 @@ public class BlockIndustrialGrinder extends BlockMachineBase implements IRotatio private final String prefix = "techreborn:blocks/machine/advanced_machines/"; - public BlockIndustrialGrinder(Material material) { + public BlockIndustrialGrinder(final Material material) { super(); - setUnlocalizedName("techreborn.industrialgrinder"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.industrialgrinder"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileIndustrialGrinder(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { - if (fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { + if (this.fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { return true; } if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.industrialGrinderID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.INDUSTRIAL_GRINDER.ordinal(), world, x, y, z); return true; } @Override public String getFrontOff() { - return prefix + "industrial_grinder_front_off"; + return this.prefix + "industrial_grinder_front_off"; } @Override public String getFrontOn() { - return prefix + "industrial_grinder_front_on"; + return this.prefix + "industrial_grinder_front_on"; } @Override public String getSide() { - return prefix + "machine_side"; + return this.prefix + "machine_side"; } @Override public String getTop() { - return prefix + "industrial_grinder_top_off"; + return this.prefix + "industrial_grinder_top_off"; } @Override public String getBottom() { - return prefix + "industrial_centrifuge_bottom"; + return this.prefix + "industrial_centrifuge_bottom"; } } diff --git a/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialSawmill.java b/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialSawmill.java index 04ea9189a..03f3953e8 100644 --- a/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialSawmill.java +++ b/src/main/java/techreborn/blocks/advanced_machine/BlockIndustrialSawmill.java @@ -5,10 +5,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.multiblock.TileIndustrialSawmill; @@ -16,50 +18,50 @@ public class BlockIndustrialSawmill extends BlockMachineBase implements IRotatio private final String prefix = "techreborn:blocks/machine/advanced_machines/"; - public BlockIndustrialSawmill(Material material) { + public BlockIndustrialSawmill(final Material material) { super(); - setUnlocalizedName("techreborn.industrialsawmill"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.industrialsawmill"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileIndustrialSawmill(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { - if (fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { + if (this.fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { return true; } if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.sawMillID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.SAWMILL.ordinal(), world, x, y, z); return true; } @Override public String getFrontOff() { - return prefix + "industrial_sawmill_front_off"; + return this.prefix + "industrial_sawmill_front_off"; } @Override public String getFrontOn() { - return prefix + "industrial_sawmill_front_on"; + return this.prefix + "industrial_sawmill_front_on"; } @Override public String getSide() { - return prefix + "advanced_machine_side"; + return this.prefix + "advanced_machine_side"; } @Override public String getTop() { - return prefix + "advanced_machine_side"; + return this.prefix + "advanced_machine_side"; } @Override public String getBottom() { - return prefix + "advanced_machine_side"; + return this.prefix + "advanced_machine_side"; } } diff --git a/src/main/java/techreborn/blocks/generator/BlockDieselGenerator.java b/src/main/java/techreborn/blocks/generator/BlockDieselGenerator.java index 23d16fa48..0aa4289e7 100644 --- a/src/main/java/techreborn/blocks/generator/BlockDieselGenerator.java +++ b/src/main/java/techreborn/blocks/generator/BlockDieselGenerator.java @@ -5,10 +5,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.generator.TileDieselGenerator; @@ -16,46 +18,46 @@ public class BlockDieselGenerator extends BlockMachineBase implements IAdvancedR private final String prefix = "techreborn:blocks/machine/generators/"; - public BlockDieselGenerator(Material material) { + public BlockDieselGenerator(final Material material) { super(); - setUnlocalizedName("techreborn.dieselgenerator"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.dieselgenerator"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileDieselGenerator(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { - if (fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { + if (this.fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { return true; } if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.dieselGeneratorID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.DIESEL_GENERATOR.ordinal(), world, x, y, z); return true; } @Override - public String getFront(boolean isActive) { - return prefix + "generator_machine_side"; + public String getFront(final boolean isActive) { + return this.prefix + "generator_machine_side"; } @Override - public String getSide(boolean isActive) { - return prefix + "generator_machine_side"; + public String getSide(final boolean isActive) { + return this.prefix + "generator_machine_side"; } @Override - public String getTop(boolean isActive) { - return prefix + "diesel_generator_top_off"; + public String getTop(final boolean isActive) { + return this.prefix + "diesel_generator_top_off"; } @Override - public String getBottom(boolean isActive) { - return prefix + "generator_machine_bottom"; + public String getBottom(final boolean isActive) { + return this.prefix + "generator_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/generator/BlockGasTurbine.java b/src/main/java/techreborn/blocks/generator/BlockGasTurbine.java index 57f33316d..6cc270f9a 100644 --- a/src/main/java/techreborn/blocks/generator/BlockGasTurbine.java +++ b/src/main/java/techreborn/blocks/generator/BlockGasTurbine.java @@ -5,10 +5,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.generator.TileGasTurbine; @@ -16,46 +18,46 @@ public class BlockGasTurbine extends BlockMachineBase implements IAdvancedRotati private final String prefix = "techreborn:blocks/machine/generators/"; - public BlockGasTurbine(Material material) { + public BlockGasTurbine(final Material material) { super(); - setUnlocalizedName("techreborn.gasTurbine"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.gasTurbine"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileGasTurbine(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { - if (fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { + if (this.fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { return true; } if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.gasTurbineID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.GAS_TURBINE.ordinal(), world, x, y, z); return true; } @Override - public String getFront(boolean isActive) { - return prefix + "generator_machine_side"; + public String getFront(final boolean isActive) { + return this.prefix + "generator_machine_side"; } @Override - public String getSide(boolean isActive) { - return prefix + "generator_machine_side"; + public String getSide(final boolean isActive) { + return this.prefix + "generator_machine_side"; } @Override - public String getTop(boolean isActive) { - return prefix + "gas_generator_top"; + public String getTop(final boolean isActive) { + return this.prefix + "gas_generator_top"; } @Override - public String getBottom(boolean isActive) { - return prefix + "gas_generator_bottom"; + public String getBottom(final boolean isActive) { + return this.prefix + "gas_generator_bottom"; } } diff --git a/src/main/java/techreborn/blocks/generator/BlockGenerator.java b/src/main/java/techreborn/blocks/generator/BlockGenerator.java index c63e6c458..9da8a9731 100644 --- a/src/main/java/techreborn/blocks/generator/BlockGenerator.java +++ b/src/main/java/techreborn/blocks/generator/BlockGenerator.java @@ -3,10 +3,12 @@ package techreborn.blocks.generator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.generator.TileGenerator; @@ -16,46 +18,46 @@ public class BlockGenerator extends BlockMachineBase implements IRotationTexture public BlockGenerator() { super(); - setUnlocalizedName("techreborn.generator"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.generator"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileGenerator(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) { - player.openGui(Core.INSTANCE, GuiHandler.generatorID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.GENERATOR.ordinal(), world, x, y, z); } return true; } @Override public String getFrontOff() { - return prefix + "generator_front_off"; + return this.prefix + "generator_front_off"; } @Override public String getFrontOn() { - return prefix + "generator_front_on"; + return this.prefix + "generator_front_on"; } @Override public String getSide() { - return prefix + "generator_machine_side"; + return this.prefix + "generator_machine_side"; } @Override public String getTop() { - return prefix + "generator_machine_top"; + return this.prefix + "generator_machine_top"; } @Override public String getBottom() { - return prefix + "generator_machine_bottom"; + return this.prefix + "generator_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/generator/BlockSemiFluidGenerator.java b/src/main/java/techreborn/blocks/generator/BlockSemiFluidGenerator.java index c2eb20e2c..9a200c52c 100644 --- a/src/main/java/techreborn/blocks/generator/BlockSemiFluidGenerator.java +++ b/src/main/java/techreborn/blocks/generator/BlockSemiFluidGenerator.java @@ -5,10 +5,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.generator.TileSemifluidGenerator; @@ -16,46 +18,46 @@ public class BlockSemiFluidGenerator extends BlockMachineBase implements IAdvanc private final String prefix = "techreborn:blocks/machine/generators/"; - public BlockSemiFluidGenerator(Material material) { + public BlockSemiFluidGenerator(final Material material) { super(); - setUnlocalizedName("techreborn.semifluidgenerator"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.semifluidgenerator"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileSemifluidGenerator(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { - if (fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { + if (this.fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { return true; } if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.semifluidGeneratorID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.SEMIFLUID_GENERATOR.ordinal(), world, x, y, z); return true; } @Override - public String getFront(boolean isActive) { - return prefix + "semifluid_generator_side"; + public String getFront(final boolean isActive) { + return this.prefix + "semifluid_generator_side"; } @Override - public String getSide(boolean isActive) { - return prefix + "semifluid_generator_side"; + public String getSide(final boolean isActive) { + return this.prefix + "semifluid_generator_side"; } @Override - public String getTop(boolean isActive) { - return prefix + "generator_machine_top"; + public String getTop(final boolean isActive) { + return this.prefix + "generator_machine_top"; } @Override - public String getBottom(boolean isActive) { - return prefix + "generator_machine_bottom"; + public String getBottom(final boolean isActive) { + return this.prefix + "generator_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/generator/BlockThermalGenerator.java b/src/main/java/techreborn/blocks/generator/BlockThermalGenerator.java index 34522ec0f..95e8cea3f 100644 --- a/src/main/java/techreborn/blocks/generator/BlockThermalGenerator.java +++ b/src/main/java/techreborn/blocks/generator/BlockThermalGenerator.java @@ -4,10 +4,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.generator.TileThermalGenerator; @@ -17,43 +19,43 @@ public class BlockThermalGenerator extends BlockMachineBase implements IAdvanced public BlockThermalGenerator() { super(); - setUnlocalizedName("techreborn.thermalGenerator"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.thermalGenerator"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileThermalGenerator(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { - if (fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { + if (this.fillBlockWithFluid(world, new BlockPos(x, y, z), player)) { return true; } if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.thermalGeneratorID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.THERMAL_GENERATOR.ordinal(), world, x, y, z); return true; } @Override - public String getFront(boolean isActive) { - return isActive ? prefix + "thermal_generator_side_on" : prefix + "thermal_generator_side_off"; + public String getFront(final boolean isActive) { + return isActive ? this.prefix + "thermal_generator_side_on" : this.prefix + "thermal_generator_side_off"; } @Override - public String getSide(boolean isActive) { - return isActive ? prefix + "thermal_generator_side_on" : prefix + "thermal_generator_side_off"; + public String getSide(final boolean isActive) { + return isActive ? this.prefix + "thermal_generator_side_on" : this.prefix + "thermal_generator_side_off"; } @Override - public String getTop(boolean isActive) { - return isActive ? prefix + "thermal_generator_top_on" : prefix + "thermal_generator_top_off"; + public String getTop(final boolean isActive) { + return isActive ? this.prefix + "thermal_generator_top_on" : this.prefix + "thermal_generator_top_off"; } @Override - public String getBottom(boolean isActive) { - return prefix + "generator_machine_bottom"; + public String getBottom(final boolean isActive) { + return this.prefix + "generator_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/iron_machines/BlockAlloyFurnace.java b/src/main/java/techreborn/blocks/iron_machines/BlockAlloyFurnace.java index 2a18ef37e..7a96ebe52 100644 --- a/src/main/java/techreborn/blocks/iron_machines/BlockAlloyFurnace.java +++ b/src/main/java/techreborn/blocks/iron_machines/BlockAlloyFurnace.java @@ -8,10 +8,12 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileAlloyFurnace; @@ -22,54 +24,54 @@ public class BlockAlloyFurnace extends BlockMachineBase implements IRotationText private final String prefix = "techreborn:blocks/machine/iron_machines/"; - public BlockAlloyFurnace(Material material) { + public BlockAlloyFurnace(final Material material) { super(); - setUnlocalizedName("techreborn.alloyfurnace"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.alloyfurnace"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileAlloyFurnace(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.alloyFurnaceID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.ALLOY_FURNACE.ordinal(), world, x, y, z); return true; } @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - List items = new ArrayList<>(); + public List getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { + final List items = new ArrayList<>(); items.add(new ItemStack(this)); return items; } @Override public String getFrontOff() { - return prefix + "alloy_furnace_front_off"; + return this.prefix + "alloy_furnace_front_off"; } @Override public String getFrontOn() { - return prefix + "alloy_furnace_front_on"; + return this.prefix + "alloy_furnace_front_on"; } @Override public String getSide() { - return prefix + "iron_machine_side"; + return this.prefix + "iron_machine_side"; } @Override public String getTop() { - return prefix + "iron_machine_top"; + return this.prefix + "iron_machine_top"; } @Override public String getBottom() { - return prefix + "iron_machine_bottom"; + return this.prefix + "iron_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/iron_machines/BlockIronFurnace.java b/src/main/java/techreborn/blocks/iron_machines/BlockIronFurnace.java index 4fb6a9455..0d0810d0e 100644 --- a/src/main/java/techreborn/blocks/iron_machines/BlockIronFurnace.java +++ b/src/main/java/techreborn/blocks/iron_machines/BlockIronFurnace.java @@ -11,10 +11,12 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileIronFurnace; @@ -28,60 +30,60 @@ public class BlockIronFurnace extends BlockMachineBase implements IRotationTextu public BlockIronFurnace() { super(); - setUnlocalizedName("techreborn.ironfurnace"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.ironfurnace"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileIronFurnace(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.ironFurnace, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.IRON_FURNACE.ordinal(), world, x, y, z); return true; } @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - List items = new ArrayList<>(); + public List getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { + final List items = new ArrayList<>(); items.add(new ItemStack(this)); return items; } @SideOnly(Side.CLIENT) @SuppressWarnings("incomplete-switch") - public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + public void randomDisplayTick(final World worldIn, final BlockPos pos, final IBlockState state, final Random rand) { if (this.isActive(state)) { - EnumFacing enumfacing = state.getValue(FACING); - double d0 = (double) pos.getX() + 0.5D; - double d1 = (double) pos.getY() + rand.nextDouble() * 6.0D / 16.0D; - double d2 = (double) pos.getZ() + 0.5D; - double d3 = 0.52D; - double d4 = rand.nextDouble() * 0.6D - 0.3D; + final EnumFacing enumfacing = state.getValue(BlockMachineBase.FACING); + final double d0 = pos.getX() + 0.5D; + final double d1 = pos.getY() + rand.nextDouble() * 6.0D / 16.0D; + final double d2 = pos.getZ() + 0.5D; + final double d3 = 0.52D; + final double d4 = rand.nextDouble() * 0.6D - 0.3D; switch (enumfacing) { case WEST: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, - new int[0]); + new int[0]); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]); break; case EAST: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, - new int[0]); + new int[0]); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]); break; case NORTH: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, - new int[0]); + new int[0]); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]); break; case SOUTH: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, - new int[0]); + new int[0]); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]); } } @@ -89,26 +91,26 @@ public class BlockIronFurnace extends BlockMachineBase implements IRotationTextu @Override public String getFrontOff() { - return prefix + "iron_furnace_front_off"; + return this.prefix + "iron_furnace_front_off"; } @Override public String getFrontOn() { - return prefix + "iron_furnace_front_on"; + return this.prefix + "iron_furnace_front_on"; } @Override public String getSide() { - return prefix + "iron_machine_side"; + return this.prefix + "iron_machine_side"; } @Override public String getTop() { - return prefix + "iron_machine_top"; + return this.prefix + "iron_machine_top"; } @Override public String getBottom() { - return prefix + "iron_machine_bottom"; + return this.prefix + "iron_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/machine/BlockAssemblingMachine.java b/src/main/java/techreborn/blocks/machine/BlockAssemblingMachine.java index 3f9463857..17267fbe8 100644 --- a/src/main/java/techreborn/blocks/machine/BlockAssemblingMachine.java +++ b/src/main/java/techreborn/blocks/machine/BlockAssemblingMachine.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileAssemblingMachine; @@ -15,47 +17,47 @@ public class BlockAssemblingMachine extends BlockMachineBase implements IRotatio private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockAssemblingMachine(Material material) { + public BlockAssemblingMachine(final Material material) { super(); - setUnlocalizedName("techreborn.assemblingmachine"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.assemblingmachine"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileAssemblingMachine(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.assemblingmachineID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.ASSEMBLING_MACHINE.ordinal(), world, x, y, z); return true; } @Override public String getFrontOff() { - return prefix + "assembling_machine_front_off"; + return this.prefix + "assembling_machine_front_off"; } @Override public String getFrontOn() { - return prefix + "assembling_machine_front_on"; + return this.prefix + "assembling_machine_front_on"; } @Override public String getSide() { - return prefix + "machine_side"; + return this.prefix + "machine_side"; } @Override public String getTop() { - return prefix + "machine_top"; + return this.prefix + "machine_top"; } @Override public String getBottom() { - return prefix + "assembling_machine_top"; + return this.prefix + "assembling_machine_top"; } } diff --git a/src/main/java/techreborn/blocks/machine/BlockChargeBench.java b/src/main/java/techreborn/blocks/machine/BlockChargeBench.java index 399781edb..bb855cd52 100644 --- a/src/main/java/techreborn/blocks/machine/BlockChargeBench.java +++ b/src/main/java/techreborn/blocks/machine/BlockChargeBench.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileChargeBench; @@ -15,47 +17,47 @@ public class BlockChargeBench extends BlockMachineBase implements IRotationTextu private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockChargeBench(Material material) { + public BlockChargeBench(final Material material) { super(); - setUnlocalizedName("techreborn.chargebench"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.chargebench"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileChargeBench(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.chargeBench, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.CHARGEBENCH.ordinal(), world, x, y, z); return true; } @Override public String getFrontOff() { - return prefix + "chargeBench_side"; + return this.prefix + "chargeBench_side"; } @Override public String getFrontOn() { - return prefix + "chargeBench_side"; + return this.prefix + "chargeBench_side"; } @Override public String getSide() { - return prefix + "chargeBench_side"; + return this.prefix + "chargeBench_side"; } @Override public String getTop() { - return prefix + "chargeBench_side"; + return this.prefix + "chargeBench_side"; } @Override public String getBottom() { - return prefix + "chargeBench_side"; + return this.prefix + "chargeBench_side"; } } diff --git a/src/main/java/techreborn/blocks/machine/BlockChemicalReactor.java b/src/main/java/techreborn/blocks/machine/BlockChemicalReactor.java index 03d2a20e4..e4c1b32a2 100644 --- a/src/main/java/techreborn/blocks/machine/BlockChemicalReactor.java +++ b/src/main/java/techreborn/blocks/machine/BlockChemicalReactor.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileChemicalReactor; @@ -15,47 +17,47 @@ public class BlockChemicalReactor extends BlockMachineBase implements IRotationT private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockChemicalReactor(Material material) { + public BlockChemicalReactor(final Material material) { super(); - setUnlocalizedName("techreborn.chemicalreactor"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.chemicalreactor"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileChemicalReactor(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.chemicalReactorID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.CHEMICAL_REACTOR.ordinal(), world, x, y, z); return true; } @Override public String getFrontOff() { - return prefix + "chemical_reactor_side_off"; + return this.prefix + "chemical_reactor_side_off"; } @Override public String getFrontOn() { - return prefix + "chemical_reactor_side_on"; + return this.prefix + "chemical_reactor_side_on"; } @Override public String getSide() { - return prefix + "machine_side"; + return this.prefix + "machine_side"; } @Override public String getTop() { - return prefix + "machine_top"; + return this.prefix + "machine_top"; } @Override public String getBottom() { - return prefix + "chemical_reactor_bottom"; + return this.prefix + "chemical_reactor_bottom"; } } diff --git a/src/main/java/techreborn/blocks/machine/BlockChunkLoader.java b/src/main/java/techreborn/blocks/machine/BlockChunkLoader.java index 9af2cdc9b..d6239011d 100644 --- a/src/main/java/techreborn/blocks/machine/BlockChunkLoader.java +++ b/src/main/java/techreborn/blocks/machine/BlockChunkLoader.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileChunkLoader; @@ -15,42 +17,42 @@ public class BlockChunkLoader extends BlockMachineBase implements IAdvancedRotat private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockChunkLoader(Material material) { + public BlockChunkLoader(final Material material) { super(); - setUnlocalizedName("techreborn.chunkloader"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.chunkloader"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileChunkLoader(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.chunkloaderID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.CHUNK_LOADER.ordinal(), world, x, y, z); return true; } @Override - public String getFront(boolean isActive) { - return prefix + "industrial_chunk_loader_side"; + public String getFront(final boolean isActive) { + return this.prefix + "industrial_chunk_loader_side"; } @Override - public String getSide(boolean isActive) { - return prefix + "industrial_chunk_loader_side"; + public String getSide(final boolean isActive) { + return this.prefix + "industrial_chunk_loader_side"; } @Override - public String getTop(boolean isActive) { - return prefix + "machine_top"; + public String getTop(final boolean isActive) { + return this.prefix + "machine_top"; } @Override - public String getBottom(boolean isActive) { - return prefix + "machine_bottom"; + public String getBottom(final boolean isActive) { + return this.prefix + "machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/machine/BlockMatterFabricator.java b/src/main/java/techreborn/blocks/machine/BlockMatterFabricator.java index 8451960e7..6bb3d3c1c 100644 --- a/src/main/java/techreborn/blocks/machine/BlockMatterFabricator.java +++ b/src/main/java/techreborn/blocks/machine/BlockMatterFabricator.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileMatterFabricator; @@ -15,22 +17,22 @@ public class BlockMatterFabricator extends BlockMachineBase implements IAdvanced private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockMatterFabricator(Material material) { + public BlockMatterFabricator(final Material material) { super(); - setUnlocalizedName("techreborn.matterfabricator"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.matterfabricator"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileMatterFabricator(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.matterfabID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.MATTER_FABRICATOR.ordinal(), world, x, y, z); return true; } @@ -40,22 +42,22 @@ public class BlockMatterFabricator extends BlockMachineBase implements IAdvanced } @Override - public String getFront(boolean isActive) { - return isActive ? prefix + "matter_fabricator_on" : prefix + "matter_fabricator_off"; + public String getFront(final boolean isActive) { + return isActive ? this.prefix + "matter_fabricator_on" : this.prefix + "matter_fabricator_off"; } @Override - public String getSide(boolean isActive) { - return isActive ? prefix + "matter_fabricator_on" : prefix + "matter_fabricator_off"; + public String getSide(final boolean isActive) { + return isActive ? this.prefix + "matter_fabricator_on" : this.prefix + "matter_fabricator_off"; } @Override - public String getTop(boolean isActive) { - return isActive ? prefix + "matter_fabricator_on" : prefix + "matter_fabricator_off"; + public String getTop(final boolean isActive) { + return isActive ? this.prefix + "matter_fabricator_on" : this.prefix + "matter_fabricator_off"; } @Override - public String getBottom(boolean isActive) { - return isActive ? prefix + "matter_fabricator_on" : prefix + "matter_fabricator_off"; + public String getBottom(final boolean isActive) { + return isActive ? this.prefix + "matter_fabricator_on" : this.prefix + "matter_fabricator_off"; } } diff --git a/src/main/java/techreborn/blocks/machine/BlockRollingMachine.java b/src/main/java/techreborn/blocks/machine/BlockRollingMachine.java index 49425e60d..f668ce8db 100644 --- a/src/main/java/techreborn/blocks/machine/BlockRollingMachine.java +++ b/src/main/java/techreborn/blocks/machine/BlockRollingMachine.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileRollingMachine; @@ -15,42 +17,42 @@ public class BlockRollingMachine extends BlockMachineBase implements IAdvancedRo private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockRollingMachine(Material material) { + public BlockRollingMachine(final Material material) { super(); - setUnlocalizedName("techreborn.rollingmachine"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.rollingmachine"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileRollingMachine(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.rollingMachineID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.ROLLING_MACHINE.ordinal(), world, x, y, z); return true; } @Override - public String getFront(boolean isActive) { - return isActive ? prefix + "rolling_machine_side_on" : prefix + "rolling_machine_side_off"; + public String getFront(final boolean isActive) { + return isActive ? this.prefix + "rolling_machine_side_on" : this.prefix + "rolling_machine_side_off"; } @Override - public String getSide(boolean isActive) { - return prefix + "machine_side"; + public String getSide(final boolean isActive) { + return this.prefix + "machine_side"; } @Override - public String getTop(boolean isActive) { - return prefix + "machine_top"; + public String getTop(final boolean isActive) { + return this.prefix + "machine_top"; } @Override - public String getBottom(boolean isActive) { - return prefix + "machine_bottom"; + public String getBottom(final boolean isActive) { + return this.prefix + "machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/machine/BlockScrapboxinator.java b/src/main/java/techreborn/blocks/machine/BlockScrapboxinator.java index 08af21ccf..d5a6ae2d5 100644 --- a/src/main/java/techreborn/blocks/machine/BlockScrapboxinator.java +++ b/src/main/java/techreborn/blocks/machine/BlockScrapboxinator.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileScrapboxinator; @@ -15,48 +17,48 @@ public class BlockScrapboxinator extends BlockMachineBase implements IRotationTe private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockScrapboxinator(Material material) { + public BlockScrapboxinator(final Material material) { super(); - setUnlocalizedName("techreborn.scrapboxinator"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.scrapboxinator"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileScrapboxinator(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) { - player.openGui(Core.INSTANCE, GuiHandler.scrapboxinatorID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.SCRAPBOXINATOR.ordinal(), world, x, y, z); } return true; } @Override public String getFrontOff() { - return prefix + "scrapboxinator_front_off"; + return this.prefix + "scrapboxinator_front_off"; } @Override public String getFrontOn() { - return prefix + "scrapboxinator_front_on"; + return this.prefix + "scrapboxinator_front_on"; } @Override public String getSide() { - return prefix + "machine_side"; + return this.prefix + "machine_side"; } @Override public String getTop() { - return prefix + "machine_top"; + return this.prefix + "machine_top"; } @Override public String getBottom() { - return prefix + "machine_bottom"; + return this.prefix + "machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/machine/BlockVacuumFreezer.java b/src/main/java/techreborn/blocks/machine/BlockVacuumFreezer.java index 7b810b322..4768a5a23 100644 --- a/src/main/java/techreborn/blocks/machine/BlockVacuumFreezer.java +++ b/src/main/java/techreborn/blocks/machine/BlockVacuumFreezer.java @@ -8,10 +8,12 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.multiblock.TileVacuumFreezer; @@ -19,43 +21,43 @@ public class BlockVacuumFreezer extends BlockMachineBase implements IAdvancedRot private final String prefix = "techreborn:blocks/machine/greg_machines/"; - public BlockVacuumFreezer(Material material) { + public BlockVacuumFreezer(final Material material) { super(); - setUnlocalizedName("techreborn.vacuumfreezer"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.vacuumfreezer"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int meta) { + public TileEntity createNewTileEntity(final World world, final int meta) { return new TileVacuumFreezer(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final BlockPos pos, final IBlockState state, final EntityPlayer player, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ) { if (!player.isSneaking()) { - player.openGui(Core.INSTANCE, GuiHandler.vacuumFreezerID, world, pos.getX(), pos.getY(), pos.getZ()); + player.openGui(Core.INSTANCE, EGui.VACUUM_FREEZER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); return true; } return false; } @Override - public String getFront(boolean isActive) { - return prefix + "vacuum_freezer_front"; + public String getFront(final boolean isActive) { + return this.prefix + "vacuum_freezer_front"; } @Override - public String getSide(boolean isActive) { - return prefix + "machine_side"; + public String getSide(final boolean isActive) { + return this.prefix + "machine_side"; } @Override - public String getTop(boolean isActive) { - return prefix + "vacuum_freezer_top"; + public String getTop(final boolean isActive) { + return this.prefix + "vacuum_freezer_top"; } @Override - public String getBottom(boolean isActive) { - return prefix + "machine_bottom"; + public String getBottom(final boolean isActive) { + return this.prefix + "machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/storage/BlockAESU.java b/src/main/java/techreborn/blocks/storage/BlockAESU.java index 48e4e4454..7ffdb0fae 100644 --- a/src/main/java/techreborn/blocks/storage/BlockAESU.java +++ b/src/main/java/techreborn/blocks/storage/BlockAESU.java @@ -6,7 +6,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import techreborn.client.GuiHandler; + +import techreborn.client.EGui; import techreborn.init.ModBlocks; import techreborn.tiles.TileAesu; @@ -15,17 +16,17 @@ import java.util.List; public class BlockAESU extends BlockEnergyStorage { public BlockAESU() { - super("AESU", GuiHandler.aesuID); + super("AESU", EGui.AESU.ordinal()); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileAesu(); } @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - ArrayList list = new ArrayList<>(); + public List getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { + final ArrayList list = new ArrayList<>(); list.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 2)); return list; } diff --git a/src/main/java/techreborn/blocks/storage/BlockBatBox.java b/src/main/java/techreborn/blocks/storage/BlockBatBox.java index f85955e28..d2a7635a4 100644 --- a/src/main/java/techreborn/blocks/storage/BlockBatBox.java +++ b/src/main/java/techreborn/blocks/storage/BlockBatBox.java @@ -6,7 +6,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import techreborn.client.GuiHandler; + +import techreborn.client.EGui; import techreborn.tiles.storage.TileBatBox; import java.util.ArrayList; @@ -17,17 +18,17 @@ import java.util.List; */ public class BlockBatBox extends BlockEnergyStorage { public BlockBatBox() { - super("Batbox", GuiHandler.batboxID); + super("Batbox", EGui.BATBOX.ordinal()); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileBatBox(); } @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - ArrayList list = new ArrayList<>(); + public List getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { + final ArrayList list = new ArrayList<>(); list.add(new ItemStack(this)); return list; } diff --git a/src/main/java/techreborn/blocks/storage/BlockIDSU.java b/src/main/java/techreborn/blocks/storage/BlockIDSU.java index bd7521dc6..d33ba10f9 100644 --- a/src/main/java/techreborn/blocks/storage/BlockIDSU.java +++ b/src/main/java/techreborn/blocks/storage/BlockIDSU.java @@ -8,7 +8,8 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import techreborn.client.GuiHandler; + +import techreborn.client.EGui; import techreborn.tiles.idsu.TileIDSU; import java.util.ArrayList; @@ -16,18 +17,18 @@ import java.util.List; public class BlockIDSU extends BlockEnergyStorage { public BlockIDSU() { - super("IDSU", GuiHandler.idsuID); + super("IDSU", EGui.IDSU.ordinal()); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileIDSU(); } @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, - float hitZ, int meta, EntityLivingBase placer) { - TileEntity tile = world.getTileEntity(pos); + public IBlockState getStateForPlacement(final World world, final BlockPos pos, final EnumFacing facing, final float hitX, final float hitY, + final float hitZ, final int meta, final EntityLivingBase placer) { + final TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileIDSU) { ((TileIDSU) tile).ownerUdid = placer.getUniqueID().toString(); } @@ -35,8 +36,8 @@ public class BlockIDSU extends BlockEnergyStorage { } @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - ArrayList list = new ArrayList<>(); + public List getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { + final ArrayList list = new ArrayList<>(); list.add(new ItemStack(this, 1, 2)); return list; } diff --git a/src/main/java/techreborn/blocks/storage/BlockLESU.java b/src/main/java/techreborn/blocks/storage/BlockLESU.java index fa7e41232..883088c85 100644 --- a/src/main/java/techreborn/blocks/storage/BlockLESU.java +++ b/src/main/java/techreborn/blocks/storage/BlockLESU.java @@ -6,7 +6,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import techreborn.client.GuiHandler; + +import techreborn.client.EGui; import techreborn.tiles.lesu.TileLesu; import java.util.ArrayList; @@ -14,17 +15,17 @@ import java.util.List; public class BlockLESU extends BlockEnergyStorage { public BlockLESU() { - super("LESU", GuiHandler.lesuID); + super("LESU", EGui.LESU.ordinal()); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileLesu(); } @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - ArrayList list = new ArrayList<>(); + public List getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { + final ArrayList list = new ArrayList<>(); list.add(new ItemStack(this, 1, 2)); return list; } diff --git a/src/main/java/techreborn/blocks/storage/BlockMFE.java b/src/main/java/techreborn/blocks/storage/BlockMFE.java index cbb58fb21..463eaa52e 100644 --- a/src/main/java/techreborn/blocks/storage/BlockMFE.java +++ b/src/main/java/techreborn/blocks/storage/BlockMFE.java @@ -6,7 +6,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import techreborn.client.GuiHandler; + +import techreborn.client.EGui; import techreborn.init.ModBlocks; import techreborn.tiles.storage.TileMFE; @@ -18,17 +19,17 @@ import java.util.List; */ public class BlockMFE extends BlockEnergyStorage { public BlockMFE() { - super("MFE", GuiHandler.mfeID); + super("MFE", EGui.MFE.ordinal()); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileMFE(); } @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - ArrayList list = new ArrayList<>(); + public List getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { + final ArrayList list = new ArrayList<>(); list.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1)); return list; } diff --git a/src/main/java/techreborn/blocks/storage/BlockMFSU.java b/src/main/java/techreborn/blocks/storage/BlockMFSU.java index 9844f99ee..159c6796c 100644 --- a/src/main/java/techreborn/blocks/storage/BlockMFSU.java +++ b/src/main/java/techreborn/blocks/storage/BlockMFSU.java @@ -6,7 +6,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import techreborn.client.GuiHandler; + +import techreborn.client.EGui; import techreborn.init.ModBlocks; import techreborn.tiles.storage.TileMFSU; @@ -18,18 +19,18 @@ import java.util.List; */ public class BlockMFSU extends BlockEnergyStorage { public BlockMFSU() { - super("MFSU", GuiHandler.mfsuID); - setHardness(2f); + super("MFSU", EGui.MFSU.ordinal()); + this.setHardness(2f); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileMFSU(); } @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - ArrayList list = new ArrayList<>(); + public List getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { + final ArrayList list = new ArrayList<>(); list.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1)); return list; } diff --git a/src/main/java/techreborn/blocks/tier1/BlockAlloySmelter.java b/src/main/java/techreborn/blocks/tier1/BlockAlloySmelter.java index 15b59cea8..647ae4670 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockAlloySmelter.java +++ b/src/main/java/techreborn/blocks/tier1/BlockAlloySmelter.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileAlloySmelter; @@ -15,47 +17,47 @@ public class BlockAlloySmelter extends BlockMachineBase implements IRotationText private final String prefix = "techreborn:blocks/machine/tier1_machines/"; - public BlockAlloySmelter(Material material) { + public BlockAlloySmelter(final Material material) { super(); - setUnlocalizedName("techreborn.alloysmelter"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.alloysmelter"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { return new TileAlloySmelter(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.alloySmelterID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.ALLOY_SMELTER.ordinal(), world, x, y, z); return true; } @Override public String getFrontOff() { - return prefix + "electric_alloy_furnace_front_off"; + return this.prefix + "electric_alloy_furnace_front_off"; } @Override public String getFrontOn() { - return prefix + "electric_alloy_furnace_front_on"; + return this.prefix + "electric_alloy_furnace_front_on"; } @Override public String getSide() { - return prefix + "tier1_machine_side"; + return this.prefix + "tier1_machine_side"; } @Override public String getTop() { - return prefix + "tier1_machine_top"; + return this.prefix + "tier1_machine_top"; } @Override public String getBottom() { - return prefix + "tier1_machine_bottom"; + return this.prefix + "tier1_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/tier1/BlockCompressor.java b/src/main/java/techreborn/blocks/tier1/BlockCompressor.java index f34a3b485..e4ecb3dda 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockCompressor.java +++ b/src/main/java/techreborn/blocks/tier1/BlockCompressor.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.teir1.TileCompressor; @@ -15,48 +17,48 @@ public class BlockCompressor extends BlockMachineBase implements IRotationTextur private final String prefix = "techreborn:blocks/machine/tier1_machines/"; - public BlockCompressor(Material material) { + public BlockCompressor(final Material material) { super(); - setUnlocalizedName("techreborn.compressor"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.compressor"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileCompressor(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) { - player.openGui(Core.INSTANCE, GuiHandler.compressorID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.COMPRESSOR.ordinal(), world, x, y, z); } return true; } @Override public String getFrontOff() { - return prefix + "compressor_front_off"; + return this.prefix + "compressor_front_off"; } @Override public String getFrontOn() { - return prefix + "compressor_front_on"; + return this.prefix + "compressor_front_on"; } @Override public String getSide() { - return prefix + "tier1_machine_side"; + return this.prefix + "tier1_machine_side"; } @Override public String getTop() { - return prefix + "tier1_machine_top"; + return this.prefix + "tier1_machine_top"; } @Override public String getBottom() { - return prefix + "tier1_machine_bottom"; + return this.prefix + "tier1_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/tier1/BlockElectricFurnace.java b/src/main/java/techreborn/blocks/tier1/BlockElectricFurnace.java index f03ff38e8..289b6d530 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockElectricFurnace.java +++ b/src/main/java/techreborn/blocks/tier1/BlockElectricFurnace.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.teir1.TileElectricFurnace; @@ -15,48 +17,48 @@ public class BlockElectricFurnace extends BlockMachineBase implements IRotationT private final String prefix = "techreborn:blocks/machine/tier1_machines/"; - public BlockElectricFurnace(Material material) { + public BlockElectricFurnace(final Material material) { super(); - setUnlocalizedName("techreborn.electricfurnace"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.electricfurnace"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileElectricFurnace(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) { - player.openGui(Core.INSTANCE, GuiHandler.electricFurnaceID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.ELECTRIC_FURNACE.ordinal(), world, x, y, z); } return true; } @Override public String getFrontOff() { - return prefix + "electric_furnace_front_off"; + return this.prefix + "electric_furnace_front_off"; } @Override public String getFrontOn() { - return prefix + "electric_furnace_front_on"; + return this.prefix + "electric_furnace_front_on"; } @Override public String getSide() { - return prefix + "tier1_machine_side"; + return this.prefix + "tier1_machine_side"; } @Override public String getTop() { - return prefix + "tier1_machine_top"; + return this.prefix + "tier1_machine_top"; } @Override public String getBottom() { - return prefix + "tier1_machine_bottom"; + return this.prefix + "tier1_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/tier1/BlockExtractor.java b/src/main/java/techreborn/blocks/tier1/BlockExtractor.java index 0f7bad868..28276a0d7 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockExtractor.java +++ b/src/main/java/techreborn/blocks/tier1/BlockExtractor.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.teir1.TileExtractor; @@ -15,48 +17,48 @@ public class BlockExtractor extends BlockMachineBase implements IRotationTexture private final String prefix = "techreborn:blocks/machine/tier1_machines/"; - public BlockExtractor(Material material) { + public BlockExtractor(final Material material) { super(); - setUnlocalizedName("techreborn.extractor"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.extractor"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileExtractor(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) { - player.openGui(Core.INSTANCE, GuiHandler.extractorID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.EXTRACTOR.ordinal(), world, x, y, z); } return true; } @Override public String getFrontOff() { - return prefix + "extractor_front_off"; + return this.prefix + "extractor_front_off"; } @Override public String getFrontOn() { - return prefix + "extractor_front_on"; + return this.prefix + "extractor_front_on"; } @Override public String getSide() { - return prefix + "tier1_machine_side"; + return this.prefix + "tier1_machine_side"; } @Override public String getTop() { - return prefix + "tier1_machine_top"; + return this.prefix + "tier1_machine_top"; } @Override public String getBottom() { - return prefix + "tier1_machine_bottom"; + return this.prefix + "tier1_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/tier1/BlockGrinder.java b/src/main/java/techreborn/blocks/tier1/BlockGrinder.java index 62c39cfad..beb05e189 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockGrinder.java +++ b/src/main/java/techreborn/blocks/tier1/BlockGrinder.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IAdvancedRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.teir1.TileGrinder; @@ -15,44 +17,44 @@ public class BlockGrinder extends BlockMachineBase implements IAdvancedRotationT private final String prefix = "techreborn:blocks/machine/tier1_machines/"; - public BlockGrinder(Material material) { + public BlockGrinder(final Material material) { super(); - setUnlocalizedName("techreborn.grinder"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.grinder"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileGrinder(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) { - player.openGui(Core.INSTANCE, GuiHandler.grinderID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.GRINDER.ordinal(), world, x, y, z); } return true; } @Override - public String getFront(boolean isActive) { - return isActive ? prefix + "grinder_front_on" : prefix + "grinder_front_off"; + public String getFront(final boolean isActive) { + return isActive ? this.prefix + "grinder_front_on" : this.prefix + "grinder_front_off"; } @Override - public String getSide(boolean isActive) { - return prefix + "tier1_machine_side"; + public String getSide(final boolean isActive) { + return this.prefix + "tier1_machine_side"; } @Override - public String getTop(boolean isActive) { - return isActive ? prefix + "grinder_top_on" : prefix + "grinder_top_off"; + public String getTop(final boolean isActive) { + return isActive ? this.prefix + "grinder_top_on" : this.prefix + "grinder_top_off"; } @Override - public String getBottom(boolean isActive) { - return prefix + "tier1_machine_bottom"; + public String getBottom(final boolean isActive) { + return this.prefix + "tier1_machine_bottom"; } } diff --git a/src/main/java/techreborn/blocks/tier1/BlockRecycler.java b/src/main/java/techreborn/blocks/tier1/BlockRecycler.java index 4f4ed8bf6..eacc0d907 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockRecycler.java +++ b/src/main/java/techreborn/blocks/tier1/BlockRecycler.java @@ -4,10 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.IRotationTexture; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.teir1.TileRecycler; @@ -15,48 +17,48 @@ public class BlockRecycler extends BlockMachineBase implements IRotationTexture private final String prefix = "techreborn:blocks/machine/tier1_machines/"; - public BlockRecycler(Material material) { + public BlockRecycler(final Material material) { super(); - setUnlocalizedName("techreborn.recycler"); - setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.recycler"); + this.setCreativeTab(TechRebornCreativeTab.instance); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { return new TileRecycler(); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, - float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, + final float hitY, final float hitZ) { if (!player.isSneaking()) { - player.openGui(Core.INSTANCE, GuiHandler.recyclerID, world, x, y, z); + player.openGui(Core.INSTANCE, EGui.RECYCLER.ordinal(), world, x, y, z); } return true; } @Override public String getFrontOff() { - return prefix + "recycler_front_off"; + return this.prefix + "recycler_front_off"; } @Override public String getFrontOn() { - return prefix + "recycler_front_on"; + return this.prefix + "recycler_front_on"; } @Override public String getSide() { - return prefix + "tier1_machine_side"; + return this.prefix + "tier1_machine_side"; } @Override public String getTop() { - return prefix + "tier1_machine_top"; + return this.prefix + "tier1_machine_top"; } @Override public String getBottom() { - return prefix + "tier1_machine_bottom"; + return this.prefix + "tier1_machine_bottom"; } } diff --git a/src/main/java/techreborn/client/EGui.java b/src/main/java/techreborn/client/EGui.java new file mode 100644 index 000000000..0a884cd43 --- /dev/null +++ b/src/main/java/techreborn/client/EGui.java @@ -0,0 +1,55 @@ +package techreborn.client; + +public enum EGui { + + THERMAL_GENERATOR(true), + QUANTUM_TANK(true), + QUANTUM_CHEST(true), + CENTRIFUGE(true), + ROLLING_MACHINE(true), + BLAST_FURNACE(true), + ALLOY_SMELTER(true), + INDUSTRIAL_GRINDER(true), + IMPLOSION_COMPRESSOR(true), + MATTER_FABRICATOR(true), + MANUAL(false), + CHUNK_LOADER(true), + ASSEMBLING_MACHINE(true), + DIESEL_GENERATOR(true), + INDUSTRIAL_ELECTROLYZER(true), + AESU(false), + ALLOY_FURNACE(true), + SAWMILL(true), + CHEMICAL_REACTOR(true), + SEMIFLUID_GENERATOR(true), + GAS_TURBINE(true), + DIGITAL_CHEST(true), + DESTRUCTOPACK(false), + LESU(false), + IDSU(false), + CHARGEBENCH(true), + FUSION_CONTROLLER(true), + VACUUM_FREEZER(true), + GRINDER(true), + GENERATOR(true), + EXTRACTOR(true), + COMPRESSOR(true), + ELECTRIC_FURNACE(true), + IRON_FURNACE(true), + RECYCLER(true), + SCRAPBOXINATOR(true), + BATBOX(true), + MFSU(true), + MFE(true); + + private final boolean containerBuilder; + + private EGui(final boolean containerBuilder) + { + this.containerBuilder = containerBuilder; + } + + public boolean useContainerBuilder() { + return this.containerBuilder; + } +} diff --git a/src/main/java/techreborn/client/GuiHandler.java b/src/main/java/techreborn/client/GuiHandler.java index 8e54a659a..8218a457d 100644 --- a/src/main/java/techreborn/client/GuiHandler.java +++ b/src/main/java/techreborn/client/GuiHandler.java @@ -1,11 +1,11 @@ package techreborn.client; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; -import reborncore.api.tile.IContainerLayout; -import reborncore.common.container.RebornContainer; + import techreborn.client.container.*; import techreborn.client.gui.*; import techreborn.manual.GuiManual; @@ -22,236 +22,119 @@ import techreborn.tiles.teir1.*; public class GuiHandler implements IGuiHandler { - public static final int thermalGeneratorID = 0; - public static final int quantumTankID = 1; - public static final int quantumChestID = 2; - public static final int centrifugeID = 3; - public static final int rollingMachineID = 4; - public static final int blastFurnaceID = 5; - public static final int alloySmelterID = 6; - public static final int industrialGrinderID = 7; - public static final int implosionCompresserID = 8; - public static final int matterfabID = 9; - public static final int manuelID = 10; - public static final int chunkloaderID = 11; - public static final int assemblingmachineID = 12; - public static final int dieselGeneratorID = 15; - public static final int industrialElectrolyzerID = 16; - public static final int aesuID = 17; - public static final int alloyFurnaceID = 18; - public static final int sawMillID = 19; - public static final int chemicalReactorID = 20; - public static final int semifluidGeneratorID = 21; - public static final int gasTurbineID = 22; - public static final int digitalChestID = 23; - public static final int destructoPackID = 25; - public static final int lesuID = 26; - public static final int idsuID = 27; - public static final int chargeBench = 28; - public static final int fusionID = 29; - public static final int vacuumFreezerID = 30; - public static final int grinderID = 31; - public static final int generatorID = 32; - public static final int extractorID = 33; - public static final int compressorID = 34; - public static final int electricFurnaceID = 35; - public static final int ironFurnace = 36; - public static final int recyclerID = 37; - public static final int scrapboxinatorID = 38; - public static final int batboxID = 39; - public static final int mfsuID = 40; - public static final int mfeID = 41; - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - RebornContainer container = null; - if (ID == thermalGeneratorID) { - return new ContainerThermalGenerator((TileThermalGenerator) world.getTileEntity(new BlockPos(x, y, z)), - player); - } else if (ID == semifluidGeneratorID) { - return new ContainerSemifluidGenerator((TileSemifluidGenerator) world.getTileEntity(new BlockPos(x, y, z)), - player); - } else if (ID == gasTurbineID) { - return new ContainerGasTurbine((TileGasTurbine) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == quantumTankID) { - return new ContainerQuantumTank((TileQuantumTank) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == digitalChestID) { - return new ContainerDigitalChest((TileDigitalChest) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == quantumChestID) { - return new ContainerQuantumChest((TileQuantumChest) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == centrifugeID) { - container = new ContainerCentrifuge(player, (TileCentrifuge) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == rollingMachineID) { - return new ContainerRollingMachine((TileRollingMachine) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == blastFurnaceID) { - return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == alloySmelterID) { - container = new ContainerAlloySmelter(player, (TileAlloySmelter) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == industrialGrinderID) { - return new ContainerIndustrialGrinder((TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)), - player); - } else if (ID == implosionCompresserID) { - return new ContainerImplosionCompressor( - (TileImplosionCompressor) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == matterfabID) { - return new ContainerMatterFabricator((TileMatterFabricator) world.getTileEntity(new BlockPos(x, y, z)), - player); - } else if (ID == chunkloaderID) { - return new ContainerChunkloader((TileChunkLoader) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == assemblingmachineID) { - container = new ContainerAssemblingMachine(player, (TileAssemblingMachine) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == dieselGeneratorID) { - return new ContainerDieselGenerator((TileDieselGenerator) world.getTileEntity(new BlockPos(x, y, z)), - player); - } else if (ID == industrialElectrolyzerID) { - return new ContainerIndustrialElectrolyzer( - (TileIndustrialElectrolyzer) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == aesuID) { - return new ContainerAESU((TileAesu) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == alloyFurnaceID) { - return new ContainerAlloyFurnace((TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == sawMillID) { - return new ContainerIndustrialSawmill((TileIndustrialSawmill) world.getTileEntity(new BlockPos(x, y, z)), - player); - } else if (ID == chemicalReactorID) { - return new ContainerChemicalReactor((TileChemicalReactor) world.getTileEntity(new BlockPos(x, y, z)), - player); - } else if (ID == manuelID) { - return null; - } else if (ID == destructoPackID) { - return new ContainerDestructoPack(player); - } else if (ID == lesuID) { - return new ContainerLESU((TileLesu) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == idsuID) { - return new ContainerIDSU((TileIDSU) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == chargeBench) { - return new ContainerChargeBench((TileChargeBench) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == fusionID) { - return new ContainerFusionReactor((TileEntityFusionController) world.getTileEntity(new BlockPos(x, y, z)), - player); - } else if (ID == vacuumFreezerID) { - return new ContainerVacuumFreezer((TileVacuumFreezer) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == grinderID) { - container = new ContainerGrinder(player, (TileGrinder) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == generatorID) { - return new ContainerGenerator((TileGenerator) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == extractorID) { - container = new ContainerExtractor(player, (TileExtractor) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == compressorID) { - return new ContainerCompressor((TileCompressor) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == electricFurnaceID) { - return new ContainerElectricFurnace((TileElectricFurnace) world.getTileEntity(new BlockPos(x, y, z)), - player); - } else if (ID == ironFurnace) { - return new ContainerIronFurnace((TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == recyclerID) { - return new ContainerRecycler((TileRecycler) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == scrapboxinatorID) { - return new ContainerScrapboxinator((TileScrapboxinator) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == batboxID) { - return new ContainerBatbox((TileBatBox) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == mfsuID) { - return new ContainerMFSU((TileMFSU) world.getTileEntity(new BlockPos(x, y, z)), player); - } else if (ID == mfeID) { - return new ContainerMFE((TileMFE) world.getTileEntity(new BlockPos(x, y, z)), player); - } - if (container != null) { - if (container instanceof IContainerLayout) { - IContainerLayout layout = (IContainerLayout) container; - layout.setTile(world.getTileEntity(new BlockPos(x, y, z))); - layout.setPlayer(player); - layout.addInventorySlots(); - layout.addPlayerSlots(); - } - return container; + public Object getServerGuiElement(final int ID, final EntityPlayer player, final World world, final int x, + final int y, final int z) { + + final EGui gui = EGui.values()[ID]; + final TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); + + if (gui.useContainerBuilder() && tile != null) + return ((IContainerProvider) tile).createContainer(player); + + switch (gui) { + case AESU: + return new ContainerAESU((TileAesu) tile, player); + case DESTRUCTOPACK: + return new ContainerDestructoPack(player); + case LESU: + return new ContainerLESU((TileLesu) tile, player); + case IDSU: + return new ContainerIDSU((TileIDSU) tile, player); + default: + break; } return null; } @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - if (ID == thermalGeneratorID) { - return new GuiThermalGenerator(player, (TileThermalGenerator) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == semifluidGeneratorID) { - return new GuiSemifluidGenerator(player, - (TileSemifluidGenerator) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == gasTurbineID) { - return new GuiGasTurbine(player, (TileGasTurbine) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == quantumTankID) { - return new GuiQuantumTank(player, (TileQuantumTank) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == digitalChestID) { - return new GuiDigitalChest(player, (TileDigitalChest) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == quantumChestID) { - return new GuiQuantumChest(player, (TileQuantumChest) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == centrifugeID) { - return new GuiCentrifuge(player, (TileCentrifuge) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == rollingMachineID) { - return new GuiRollingMachine(player, (TileRollingMachine) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == blastFurnaceID) { - return new GuiBlastFurnace(player, (TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == alloySmelterID) { - return new GuiAlloySmelter(player, (TileAlloySmelter) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == industrialGrinderID) { - return new GuiIndustrialGrinder(player, (TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == implosionCompresserID) { - return new GuiImplosionCompressor(player, - (TileImplosionCompressor) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == matterfabID) { - return new GuiMatterFabricator(player, (TileMatterFabricator) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == chunkloaderID) { - return new GuiChunkLoader(player, (TileChunkLoader) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == assemblingmachineID) { - return new GuiAssemblingMachine(player, (TileAssemblingMachine) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == dieselGeneratorID) { - return new GuiDieselGenerator(player, (TileDieselGenerator) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == industrialElectrolyzerID) { - return new GuiIndustrialElectrolyzer(player, - (TileIndustrialElectrolyzer) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == aesuID) { - return new GuiAESU(player, (TileAesu) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == alloyFurnaceID) { - return new GuiAlloyFurnace(player, (TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == sawMillID) { - return new GuiIndustrialSawmill(player, (TileIndustrialSawmill) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == chemicalReactorID) { - return new GuiChemicalReactor(player, (TileChemicalReactor) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == manuelID) { - return new GuiManual(); - } else if (ID == destructoPackID) { - return new GuiDestructoPack(new ContainerDestructoPack(player)); - } else if (ID == lesuID) { - return new GuiLESU(player, (TileLesu) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == idsuID) { - return new GuiIDSU(player, (TileIDSU) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == chargeBench) { - return new GuiChargeBench(player, (TileChargeBench) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == fusionID) { - return new GuiFusionReactor(player, - (TileEntityFusionController) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == vacuumFreezerID) { - return new GuiVacuumFreezer(player, (TileVacuumFreezer) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == grinderID) { - return new GuiGrinder(player, (TileGrinder) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == generatorID) { - return new GuiGenerator(player, (TileGenerator) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == extractorID) { - return new GuiExtractor(player, (TileExtractor) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == compressorID) { - return new GuiCompressor(player, (TileCompressor) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == electricFurnaceID) { - return new GuiElectricFurnace(player, (TileElectricFurnace) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == ironFurnace) { - return new GuiIronFurnace(player, (TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == recyclerID) { - return new GuiRecycler(player, (TileRecycler) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == scrapboxinatorID) { - return new GuiScrapboxinator(player, (TileScrapboxinator) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == batboxID) { - return new GuiBatbox(player, (TileBatBox) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == mfsuID) { - return new GuiMFSU(player, (TileMFSU) world.getTileEntity(new BlockPos(x, y, z))); - } else if (ID == mfeID) { - return new GuiMFE(player, (TileMFE) world.getTileEntity(new BlockPos(x, y, z))); + public Object getClientGuiElement(final int ID, final EntityPlayer player, final World world, final int x, + final int y, final int z) { + final EGui gui = EGui.values()[ID]; + final TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); + + switch (gui) { + case AESU: + return new GuiAESU(player, (TileAesu) tile); + case ALLOY_FURNACE: + return new GuiAlloyFurnace(player, (TileAlloyFurnace) tile); + case ALLOY_SMELTER: + return new GuiAlloySmelter(player, (TileAlloySmelter) tile); + case ASSEMBLING_MACHINE: + return new GuiAssemblingMachine(player, (TileAssemblingMachine) tile); + case BATBOX: + return new GuiBatbox(player, (TileBatBox) tile); + case BLAST_FURNACE: + return new GuiBlastFurnace(player, (TileBlastFurnace) tile); + case CENTRIFUGE: + return new GuiCentrifuge(player, (TileCentrifuge) tile); + case CHARGEBENCH: + return new GuiChargeBench(player, (TileChargeBench) tile); + case CHEMICAL_REACTOR: + return new GuiChemicalReactor(player, (TileChemicalReactor) tile); + case CHUNK_LOADER: + return new GuiChunkLoader(player, (TileChunkLoader) tile); + case COMPRESSOR: + return new GuiCompressor(player, (TileCompressor) tile); + case DESTRUCTOPACK: + return new GuiDestructoPack(new ContainerDestructoPack(player)); + case DIESEL_GENERATOR: + return new GuiDieselGenerator(player, (TileDieselGenerator) tile); + case DIGITAL_CHEST: + return new GuiDigitalChest(player, (TileDigitalChest) tile); + case ELECTRIC_FURNACE: + return new GuiElectricFurnace(player, (TileElectricFurnace) tile); + case EXTRACTOR: + return new GuiExtractor(player, (TileExtractor) tile); + case FUSION_CONTROLLER: + return new GuiFusionReactor(player, (TileEntityFusionController) tile); + case GAS_TURBINE: + return new GuiGasTurbine(player, (TileGasTurbine) tile); + case GENERATOR: + return new GuiGenerator(player, (TileGenerator) tile); + case GRINDER: + return new GuiGrinder(player, (TileGrinder) tile); + case IDSU: + return new GuiIDSU(player, (TileIDSU) tile); + case IMPLOSION_COMPRESSOR: + return new GuiImplosionCompressor(player, (TileImplosionCompressor) tile); + case INDUSTRIAL_ELECTROLYZER: + return new GuiIndustrialElectrolyzer(player, (TileIndustrialElectrolyzer) tile); + case INDUSTRIAL_GRINDER: + return new GuiIndustrialGrinder(player, (TileIndustrialGrinder) tile); + case IRON_FURNACE: + return new GuiIronFurnace(player, (TileIronFurnace) tile); + case LESU: + return new GuiLESU(player, (TileLesu) tile); + case MANUAL: + return new GuiManual(); + case MATTER_FABRICATOR: + return new GuiMatterFabricator(player, (TileMatterFabricator) tile); + case MFE: + return new GuiMFE(player, (TileMFE) tile); + case MFSU: + return new GuiMFSU(player, (TileMFSU) tile); + case QUANTUM_CHEST: + return new GuiQuantumChest(player, (TileQuantumChest) tile); + case QUANTUM_TANK: + return new GuiQuantumTank(player, (TileQuantumTank) tile); + case RECYCLER: + return new GuiRecycler(player, (TileRecycler) tile); + case ROLLING_MACHINE: + return new GuiRollingMachine(player, (TileRollingMachine) tile); + case SAWMILL: + return new GuiIndustrialSawmill(player, (TileIndustrialSawmill) tile); + case SCRAPBOXINATOR: + return new GuiScrapboxinator(player, (TileScrapboxinator) tile); + case SEMIFLUID_GENERATOR: + return new GuiSemifluidGenerator(player, (TileSemifluidGenerator) tile); + case THERMAL_GENERATOR: + return new GuiThermalGenerator(player, (TileThermalGenerator) tile); + case VACUUM_FREEZER: + return new GuiVacuumFreezer(player, (TileVacuumFreezer) tile); + default: + break; + } return null; } diff --git a/src/main/java/techreborn/client/container/ContainerAlloyFurnace.java b/src/main/java/techreborn/client/container/ContainerAlloyFurnace.java deleted file mode 100644 index 668674fc1..000000000 --- a/src/main/java/techreborn/client/container/ContainerAlloyFurnace.java +++ /dev/null @@ -1,122 +0,0 @@ -package techreborn.client.container; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IContainerListener; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.SlotFurnaceFuel; -import reborncore.client.gui.slots.BaseSlot; -import reborncore.client.gui.slots.SlotOutput; -import net.minecraft.item.ItemStack; -import reborncore.api.recipe.IBaseRecipeType; -import reborncore.api.recipe.RecipeHandler; -import reborncore.common.container.RebornContainer; -import reborncore.common.recipes.RecipeTranslator; -import reborncore.common.util.ItemUtils; -import techreborn.api.recipe.machines.AlloySmelterRecipe; -import techreborn.tiles.TileAlloyFurnace; - -import javax.annotation.Nullable; - -public class ContainerAlloyFurnace extends RebornContainer { - - public int tickTime; - EntityPlayer player; - TileAlloyFurnace tile; - int currentItemBurnTime; - int burnTime; - int cookTime; - - public ContainerAlloyFurnace(TileAlloyFurnace tileAlloyfurnace, EntityPlayer player) { - tile = tileAlloyfurnace; - this.player = player; - - // input - this.addSlotToContainer(new SlotInputCustom(tileAlloyfurnace.inventory, 0, 47, 17, 0)); - this.addSlotToContainer(new SlotInputCustom(tileAlloyfurnace.inventory, 1, 65, 17, 1)); - // outputs - this.addSlotToContainer(new SlotOutput(tileAlloyfurnace.inventory, 2, 116, 35)); - // Fuel - this.addSlotToContainer(new SlotFurnaceFuel(tileAlloyfurnace.inventory, 3, 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)); - } - } - - public static class SlotInputCustom extends BaseSlot { - - int recipeSlot = 0; - - public SlotInputCustom(IInventory inventoryIn, int index, int xPosition, int yPosition, int recipeSlot) { - super(inventoryIn, index, xPosition, yPosition); - this.recipeSlot = recipeSlot; - } - - @Override - public boolean isItemValid( - @Nullable - ItemStack stack) { - for(IBaseRecipeType recipe : RecipeHandler.recipeList){ - if(recipe instanceof AlloySmelterRecipe){ - if(ItemUtils.isInputEqual(recipe.getInputs().get(recipeSlot), stack, true, true, true)){ - return true; - } - } - } - return false; - } - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } - - @Override - public void addListener(IContainerListener crafting) { - super.addListener(crafting); - crafting.sendProgressBarUpdate(this, 0, tile.currentItemBurnTime); - crafting.sendProgressBarUpdate(this, 1, tile.burnTime); - crafting.sendProgressBarUpdate(this, 2, tile.cookTime); - } - - @Override - public void detectAndSendChanges() { - for (int i = 0; i < this.listeners.size(); i++) { - IContainerListener crafting = this.listeners.get(i); - if (this.currentItemBurnTime != tile.currentItemBurnTime) { - crafting.sendProgressBarUpdate(this, 0, tile.currentItemBurnTime); - } - if (this.burnTime != tile.burnTime) { - crafting.sendProgressBarUpdate(this, 1, tile.burnTime); - } - if (this.cookTime != tile.cookTime) { - crafting.sendProgressBarUpdate(this, 2, tile.cookTime); - } - } - super.detectAndSendChanges(); - } - - @Override - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - if (id == 0) { - this.currentItemBurnTime = value; - } else if (id == 1) { - this.burnTime = value; - } else if (id == 2) { - this.cookTime = value; - } - this.tile.currentItemBurnTime = this.currentItemBurnTime; - this.tile.burnTime = this.burnTime; - this.tile.cookTime = this.cookTime; - } -} diff --git a/src/main/java/techreborn/client/container/ContainerAlloySmelter.java b/src/main/java/techreborn/client/container/ContainerAlloySmelter.java deleted file mode 100644 index cfe4691e4..000000000 --- a/src/main/java/techreborn/client/container/ContainerAlloySmelter.java +++ /dev/null @@ -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.SlotCharge; -import reborncore.client.gui.slots.SlotInput; -import reborncore.client.gui.slots.SlotOutput; -import techreborn.api.gui.SlotUpgrade; -import techreborn.tiles.TileAlloySmelter; - -import javax.annotation.Nullable; -import java.util.List; - -public class ContainerAlloySmelter extends ContainerCrafting { - - public int tickTime; - EntityPlayer player; - TileAlloySmelter tile; - - public ContainerAlloySmelter(EntityPlayer player, TileAlloySmelter tile) { - super(tile.crafter); - this.player = player; - this.tile = tile; - addPlayerSlots(); - addInventorySlots(); - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } - - - public void addInventorySlots() { - - // input - this.addSlotToContainer(new ContainerAlloyFurnace.SlotInputCustom(tile.inventory, 0, 47, 17, 0)); - this.addSlotToContainer(new ContainerAlloyFurnace.SlotInputCustom(tile.inventory, 1, 65, 17, 1)); - // outputs - this.addSlotToContainer(new SlotOutput(tile.inventory, 2, 116, 35)); - // battery - this.addSlotToContainer(new SlotCharge(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)); - } - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerAssemblingMachine.java b/src/main/java/techreborn/client/container/ContainerAssemblingMachine.java deleted file mode 100644 index 562d8cbf4..000000000 --- a/src/main/java/techreborn/client/container/ContainerAssemblingMachine.java +++ /dev/null @@ -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)); - } - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerBatbox.java b/src/main/java/techreborn/client/container/ContainerBatbox.java deleted file mode 100644 index 8d934ad15..000000000 --- a/src/main/java/techreborn/client/container/ContainerBatbox.java +++ /dev/null @@ -1,80 +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.SlotCharge; -import reborncore.common.container.RebornContainer; -import techreborn.tiles.storage.TileBatBox; - -public class ContainerBatbox extends RebornContainer { - - public int burnTime = 0; - public int totalBurnTime = 0; - public int energy; - public int tickTime; - EntityPlayer player; - TileBatBox tile; - - public ContainerBatbox(TileBatBox tile, EntityPlayer player) { - super(); - this.tile = tile; - this.player = player; - - int i; - - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142)); - } - - this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17)); - this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53)); - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - for (int i = 0; i < this.listeners.size(); i++) { - IContainerListener IContainerListener = this.listeners.get(i); - if (this.energy != (int) tile.getEnergy()) { - IContainerListener.sendProgressBarUpdate(this, 2, (int) tile.getEnergy()); - } - } - } - - @Override - public void addListener(IContainerListener crafting) { - super.addListener(crafting); - crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy()); - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int id, int value) { - if (id == 0) { - this.burnTime = value; - } else if (id == 1) { - this.totalBurnTime = value; - } else if (id == 2) { - this.energy = value; - } - this.tile.setEnergy(energy); - } - - public int getScaledBurnTime(int i) { - return (int) (((float) burnTime / (float) totalBurnTime) * i); - } -} diff --git a/src/main/java/techreborn/client/container/ContainerBlastFurnace.java b/src/main/java/techreborn/client/container/ContainerBlastFurnace.java deleted file mode 100644 index d190f0f47..000000000 --- a/src/main/java/techreborn/client/container/ContainerBlastFurnace.java +++ /dev/null @@ -1,74 +0,0 @@ -package techreborn.client.container; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IContainerListener; -import reborncore.client.gui.slots.BaseSlot; -import reborncore.client.gui.slots.SlotOutput; -import techreborn.tiles.multiblock.TileBlastFurnace; - -public class ContainerBlastFurnace extends ContainerCrafting { - - public int heat; - public int tickTime; - EntityPlayer player; - TileBlastFurnace tile; - - public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace, EntityPlayer player) { - super(tileblastfurnace.crafter); - tile = tileblastfurnace; - this.player = player; - - // input - this.addSlotToContainer(new BaseSlot(tileblastfurnace.inventory, 0, 40, 25));// Input - // 1 - this.addSlotToContainer(new BaseSlot(tileblastfurnace.inventory, 1, 40, 43));// Input - // 2 - // outputs - this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 2, 100, 35));// Output - // 1 - this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 3, 118, 35));// Output - // 2 - - 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.heat != tile.getHeat()) { - IContainerListener.sendProgressBarUpdate(this, 10, tile.getHeat()); - } - } - } - - @Override - public void addListener(IContainerListener crafting) { - super.addListener(crafting); - crafting.sendProgressBarUpdate(this, 10, tile.getHeat()); - } - - @Override - public void updateProgressBar(int id, int value) { - if (id == 10) { - this.heat = value; - } - super.updateProgressBar(id, value); - } -} diff --git a/src/main/java/techreborn/client/container/ContainerCentrifuge.java b/src/main/java/techreborn/client/container/ContainerCentrifuge.java deleted file mode 100644 index b8ee7e0ef..000000000 --- a/src/main/java/techreborn/client/container/ContainerCentrifuge.java +++ /dev/null @@ -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)); - } - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerChargeBench.java b/src/main/java/techreborn/client/container/ContainerChargeBench.java deleted file mode 100644 index 890b6d629..000000000 --- a/src/main/java/techreborn/client/container/ContainerChargeBench.java +++ /dev/null @@ -1,45 +0,0 @@ -package techreborn.client.container; - -import net.minecraft.entity.player.EntityPlayer; -import reborncore.client.gui.slots.BaseSlot; -import reborncore.common.container.RebornContainer; -import techreborn.tiles.TileChargeBench; - -//import reborncore.client.gui.slots.BaseSlot; - -public class ContainerChargeBench extends RebornContainer { - - public int tickTime; - EntityPlayer player; - TileChargeBench tile; - - public ContainerChargeBench(TileChargeBench tileChargeBench, EntityPlayer player) { - tile = tileChargeBench; - this.player = player; - - this.addSlotToContainer(new BaseSlot(tileChargeBench.inventory, 0, 62, 21)); - this.addSlotToContainer(new BaseSlot(tileChargeBench.inventory, 1, 80, 21)); - this.addSlotToContainer(new BaseSlot(tileChargeBench.inventory, 2, 98, 21)); - this.addSlotToContainer(new BaseSlot(tileChargeBench.inventory, 3, 62, 39)); - this.addSlotToContainer(new BaseSlot(tileChargeBench.inventory, 4, 80, 39)); - this.addSlotToContainer(new BaseSlot(tileChargeBench.inventory, 5, 98, 39)); - - 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; - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerChemicalReactor.java b/src/main/java/techreborn/client/container/ContainerChemicalReactor.java deleted file mode 100644 index babf78760..000000000 --- a/src/main/java/techreborn/client/container/ContainerChemicalReactor.java +++ /dev/null @@ -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; - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerChunkloader.java b/src/main/java/techreborn/client/container/ContainerChunkloader.java deleted file mode 100644 index 5c60df8fa..000000000 --- a/src/main/java/techreborn/client/container/ContainerChunkloader.java +++ /dev/null @@ -1,34 +0,0 @@ -package techreborn.client.container; - -import net.minecraft.entity.player.EntityPlayer; -import reborncore.client.gui.slots.BaseSlot; -import reborncore.common.container.RebornContainer; -import techreborn.tiles.TileChunkLoader; - -public class ContainerChunkloader extends RebornContainer { - - EntityPlayer player; - - public ContainerChunkloader(TileChunkLoader tilechunkloader, EntityPlayer player) { - this.player = player; - - int i; - - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142)); - } - - } - - @Override - public boolean canInteractWith(EntityPlayer p_75145_1_) { - return true; - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerCompressor.java b/src/main/java/techreborn/client/container/ContainerCompressor.java deleted file mode 100644 index 4ee749f15..000000000 --- a/src/main/java/techreborn/client/container/ContainerCompressor.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/techreborn/client/container/ContainerCrafting.java b/src/main/java/techreborn/client/container/ContainerCrafting.java deleted file mode 100644 index f660158c5..000000000 --- a/src/main/java/techreborn/client/container/ContainerCrafting.java +++ /dev/null @@ -1,71 +0,0 @@ -package techreborn.client.container; - -import net.minecraft.inventory.IContainerListener; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.common.container.RebornContainer; -import reborncore.common.recipes.RecipeCrafter; - -public abstract class ContainerCrafting extends RebornContainer { - - RecipeCrafter crafter; - - int currentTickTime = 0; - int currentNeededTicks = 0; - int energy; - - public ContainerCrafting(RecipeCrafter crafter) { - this(); - this.crafter = crafter; - } - - public ContainerCrafting() { - } - - public void setCrafter(RecipeCrafter crafter) { - this.crafter = crafter; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - for (int i = 0; i < this.listeners.size(); i++) { - IContainerListener IContainerListener = this.listeners.get(i); - if (this.currentTickTime != crafter.currentTickTime || crafter.currentTickTime == -1) { - IContainerListener.sendProgressBarUpdate(this, 0, crafter.currentTickTime); - } - if (this.currentNeededTicks != crafter.currentNeededTicks) { - IContainerListener.sendProgressBarUpdate(this, 1, crafter.currentNeededTicks); - } - if (this.energy != (int) crafter.energy.getEnergy()) { - IContainerListener.sendProgressBarUpdate(this, 2, (int) crafter.energy.getEnergy()); - } - } - } - - @Override - public void addListener(IContainerListener crafting) { - super.addListener(crafting); - crafting.sendProgressBarUpdate(this, 0, crafter.currentTickTime); - crafting.sendProgressBarUpdate(this, 1, crafter.currentNeededTicks); - crafting.sendProgressBarUpdate(this, 2, (int) crafter.energy.getEnergy()); - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int id, int value) { - if (id == 0) { - this.currentTickTime = value; - if (this.currentTickTime == -1) { - this.currentTickTime = 0; - } - } else if (id == 1) { - this.currentNeededTicks = value; - } else if (id == 2) { - this.energy = value; - } - this.crafter.currentTickTime = currentTickTime; - this.crafter.currentNeededTicks = currentNeededTicks; - this.crafter.energy.setEnergy(energy); - } -} diff --git a/src/main/java/techreborn/client/container/ContainerDieselGenerator.java b/src/main/java/techreborn/client/container/ContainerDieselGenerator.java deleted file mode 100644 index 45abd18a6..000000000 --- a/src/main/java/techreborn/client/container/ContainerDieselGenerator.java +++ /dev/null @@ -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; - } - } -} diff --git a/src/main/java/techreborn/client/container/ContainerDigitalChest.java b/src/main/java/techreborn/client/container/ContainerDigitalChest.java deleted file mode 100644 index 37f70db62..000000000 --- a/src/main/java/techreborn/client/container/ContainerDigitalChest.java +++ /dev/null @@ -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.SlotOutput; -import reborncore.common.container.RebornContainer; -import techreborn.tiles.TileDigitalChest; - -public class ContainerDigitalChest extends RebornContainer { - public TileDigitalChest tileDigitalChest; - public EntityPlayer player; - - public ContainerDigitalChest(TileDigitalChest tileDigitalChest, EntityPlayer player) { - super(); - this.tileDigitalChest = tileDigitalChest; - this.player = player; - - this.addSlotToContainer(new BaseSlot(tileDigitalChest.inventory, 0, 80, 17)); - this.addSlotToContainer(new SlotOutput(tileDigitalChest.inventory, 1, 80, 53)); - this.addSlotToContainer(new SlotFake(tileDigitalChest.inventory, 2, 59, 42, false, false, Integer.MAX_VALUE)); - - 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; - } - -} \ No newline at end of file diff --git a/src/main/java/techreborn/client/container/ContainerElectricFurnace.java b/src/main/java/techreborn/client/container/ContainerElectricFurnace.java deleted file mode 100644 index 14c3488bb..000000000 --- a/src/main/java/techreborn/client/container/ContainerElectricFurnace.java +++ /dev/null @@ -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; - } - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerExtractor.java b/src/main/java/techreborn/client/container/ContainerExtractor.java deleted file mode 100644 index 3d911b6a1..000000000 --- a/src/main/java/techreborn/client/container/ContainerExtractor.java +++ /dev/null @@ -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)); - } - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerFusionReactor.java b/src/main/java/techreborn/client/container/ContainerFusionReactor.java deleted file mode 100644 index d573a100a..000000000 --- a/src/main/java/techreborn/client/container/ContainerFusionReactor.java +++ /dev/null @@ -1,111 +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.SlotOutput; -import reborncore.common.container.RebornContainer; -import techreborn.tiles.fusionReactor.TileEntityFusionController; - -public class ContainerFusionReactor extends RebornContainer { - - public int coilStatus; - public int energy; - public int tickTime; - public int finalTickTime; - public int neededEU; - - TileEntityFusionController fusionController; - - public ContainerFusionReactor(TileEntityFusionController tileEntityFusionController, EntityPlayer player) { - super(); - this.fusionController = tileEntityFusionController; - - addSlotToContainer(new BaseSlot(tileEntityFusionController, 0, 88, 17)); - addSlotToContainer(new BaseSlot(tileEntityFusionController, 1, 88, 53)); - addSlotToContainer(new SlotOutput(tileEntityFusionController, 2, 148, 35)); - - 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.coilStatus != fusionController.coilStatus) { - IContainerListener.sendProgressBarUpdate(this, 0, fusionController.coilStatus); - } - if (this.energy != (int) fusionController.getEnergy()) { - IContainerListener.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy()); - } - if (this.tickTime != fusionController.crafingTickTime) { - IContainerListener.sendProgressBarUpdate(this, 2, fusionController.crafingTickTime); - } - if (this.finalTickTime != fusionController.finalTickTime) { - IContainerListener.sendProgressBarUpdate(this, 3, fusionController.finalTickTime); - } - if (this.neededEU != fusionController.neededPower) { - IContainerListener.sendProgressBarUpdate(this, 4, fusionController.neededPower); - } - } - } - - @Override - public void addListener(IContainerListener crafting) { - super.addListener(crafting); - crafting.sendProgressBarUpdate(this, 0, fusionController.coilStatus); - crafting.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy()); - crafting.sendProgressBarUpdate(this, 2, fusionController.crafingTickTime); - crafting.sendProgressBarUpdate(this, 3, fusionController.finalTickTime); - crafting.sendProgressBarUpdate(this, 4, fusionController.neededPower); - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int id, int value) { - if (id == 0) { - this.coilStatus = value; - } else if (id == 1) { - this.energy = value; - } else if (id == 2) { - this.tickTime = value; - } else if (id == 3) { - this.finalTickTime = value; - } else if (id == 4) { - this.neededEU = value; - } - if (tickTime == -1) { - tickTime = 0; - } - if (finalTickTime == -1) { - finalTickTime = 0; - } - if (neededEU == -1) { - neededEU = 0; - } - } - - public int getProgressScaled() { - return Math.max(0, Math.min(24, - (this.tickTime > 0 ? 1 : 0) + this.tickTime * 24 / (this.finalTickTime < 1 ? 1 : this.finalTickTime))); - } -} diff --git a/src/main/java/techreborn/client/container/ContainerGasTurbine.java b/src/main/java/techreborn/client/container/ContainerGasTurbine.java deleted file mode 100644 index aa4133532..000000000 --- a/src/main/java/techreborn/client/container/ContainerGasTurbine.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/techreborn/client/container/ContainerGenerator.java b/src/main/java/techreborn/client/container/ContainerGenerator.java deleted file mode 100644 index cc1dcca14..000000000 --- a/src/main/java/techreborn/client/container/ContainerGenerator.java +++ /dev/null @@ -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); - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerGrinder.java b/src/main/java/techreborn/client/container/ContainerGrinder.java deleted file mode 100644 index 3cff28cd3..000000000 --- a/src/main/java/techreborn/client/container/ContainerGrinder.java +++ /dev/null @@ -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)); - } - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerImplosionCompressor.java b/src/main/java/techreborn/client/container/ContainerImplosionCompressor.java deleted file mode 100644 index 7570ded8c..000000000 --- a/src/main/java/techreborn/client/container/ContainerImplosionCompressor.java +++ /dev/null @@ -1,77 +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.SlotOutput; -import techreborn.tiles.multiblock.TileImplosionCompressor; - -public class ContainerImplosionCompressor extends ContainerCrafting { - - public int tickTime; - public int multIBlockState = 0; - EntityPlayer player; - TileImplosionCompressor tile; - - public ContainerImplosionCompressor(TileImplosionCompressor tilecompressor, EntityPlayer player) { - super(tilecompressor.crafter); - tile = tilecompressor; - this.player = player; - - // input - this.addSlotToContainer(new BaseSlot(tilecompressor.inventory, 0, 37, 26)); - this.addSlotToContainer(new BaseSlot(tilecompressor.inventory, 1, 37, 44)); - // outputs - this.addSlotToContainer(new SlotOutput(tilecompressor.inventory, 2, 93, 35)); - this.addSlotToContainer(new SlotOutput(tilecompressor.inventory, 3, 111, 35)); - - 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; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - for (int i = 0; i < this.listeners.size(); i++) { - IContainerListener IContainerListener = this.listeners.get(i); - if (this.multIBlockState != getMultIBlockStateint()) { - IContainerListener.sendProgressBarUpdate(this, 3, getMultIBlockStateint()); - } - } - } - - @Override - public void addListener(IContainerListener crafting) { - super.addListener(crafting); - crafting.sendProgressBarUpdate(this, 3, getMultIBlockStateint()); - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int id, int value) { - if (id == 3) { - this.multIBlockState = value; - } - } - - public int getMultIBlockStateint() { - return tile.getMutliBlock() ? 1 : 0; - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerIndustrialElectrolyzer.java b/src/main/java/techreborn/client/container/ContainerIndustrialElectrolyzer.java deleted file mode 100644 index 34a1f82d8..000000000 --- a/src/main/java/techreborn/client/container/ContainerIndustrialElectrolyzer.java +++ /dev/null @@ -1,48 +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.tiles.TileIndustrialElectrolyzer; - -public class ContainerIndustrialElectrolyzer extends ContainerCrafting { - - public int tickTime; - EntityPlayer player; - TileIndustrialElectrolyzer tile; - - public ContainerIndustrialElectrolyzer(TileIndustrialElectrolyzer electrolyzer, EntityPlayer player) { - super(electrolyzer.crafter); - tile = electrolyzer; - this.player = player; - - // input - this.addSlotToContainer(new BaseSlot(electrolyzer.inventory, 0, 80, 51)); - this.addSlotToContainer(new BaseSlot(electrolyzer.inventory, 1, 50, 51)); - // outputs - this.addSlotToContainer(new SlotOutput(electrolyzer.inventory, 2, 50, 19)); - this.addSlotToContainer(new SlotOutput(electrolyzer.inventory, 3, 70, 19)); - this.addSlotToContainer(new SlotOutput(electrolyzer.inventory, 4, 90, 19)); - this.addSlotToContainer(new SlotOutput(electrolyzer.inventory, 5, 110, 19)); - - // battery - this.addSlotToContainer(new BaseSlot(electrolyzer.inventory, 6, 18, 51)); - - 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; - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerIndustrialGrinder.java b/src/main/java/techreborn/client/container/ContainerIndustrialGrinder.java deleted file mode 100644 index b5dfe21b3..000000000 --- a/src/main/java/techreborn/client/container/ContainerIndustrialGrinder.java +++ /dev/null @@ -1,45 +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.tiles.multiblock.TileIndustrialGrinder; - -public class ContainerIndustrialGrinder extends ContainerCrafting { - - EntityPlayer player; - TileIndustrialGrinder tile; - - public ContainerIndustrialGrinder(TileIndustrialGrinder tileGrinder, EntityPlayer player) { - super(tileGrinder.getRecipeCrafter()); - tile = tileGrinder; - this.player = player; - - // input - this.addSlotToContainer(new BaseSlot(tileGrinder.inventory, 0, 32, 26)); - this.addSlotToContainer(new BaseSlot(tileGrinder.inventory, 1, 32, 44)); - - // outputs - this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 2, 77, 35)); - this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 3, 95, 35)); - this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 4, 113, 35)); - this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 5, 131, 35)); - - for (int 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 (int i = 0; i < 9; ++i) { - this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142)); - } - - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerIndustrialSawmill.java b/src/main/java/techreborn/client/container/ContainerIndustrialSawmill.java deleted file mode 100644 index a18083cea..000000000 --- a/src/main/java/techreborn/client/container/ContainerIndustrialSawmill.java +++ /dev/null @@ -1,43 +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 reborncore.common.container.RebornContainer; -import techreborn.tiles.multiblock.TileIndustrialSawmill; - -public class ContainerIndustrialSawmill extends RebornContainer { - - public int tickTime; - EntityPlayer player; - TileIndustrialSawmill tile; - - public ContainerIndustrialSawmill(TileIndustrialSawmill tileIndustrialSawmill, EntityPlayer player) { - tile = tileIndustrialSawmill; - this.player = player; - - // input - this.addSlotToContainer(new BaseSlot(tileIndustrialSawmill.inventory, 0, 32, 26)); - this.addSlotToContainer(new BaseSlot(tileIndustrialSawmill.inventory, 1, 32, 44)); - // outputs - this.addSlotToContainer(new SlotOutput(tileIndustrialSawmill.inventory, 2, 84, 35)); - this.addSlotToContainer(new SlotOutput(tileIndustrialSawmill.inventory, 3, 102, 35)); - this.addSlotToContainer(new SlotOutput(tileIndustrialSawmill.inventory, 4, 120, 35)); - - for (int 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 (int i = 0; i < 9; ++i) { - this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142)); - } - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerIronFurnace.java b/src/main/java/techreborn/client/container/ContainerIronFurnace.java deleted file mode 100644 index 1757e03a4..000000000 --- a/src/main/java/techreborn/client/container/ContainerIronFurnace.java +++ /dev/null @@ -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; - } - } -} diff --git a/src/main/java/techreborn/client/container/ContainerMFE.java b/src/main/java/techreborn/client/container/ContainerMFE.java deleted file mode 100644 index c991e2dee..000000000 --- a/src/main/java/techreborn/client/container/ContainerMFE.java +++ /dev/null @@ -1,98 +0,0 @@ -package techreborn.client.container; - -/** - * Created by Rushmead - */ - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.inventory.IContainerListener; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.client.gui.slots.BaseSlot; -import reborncore.client.gui.slots.SlotCharge; -import reborncore.common.container.RebornContainer; -import techreborn.tiles.storage.TileMFE; - -public class ContainerMFE extends RebornContainer { - - public int burnTime = 0; - public int totalBurnTime = 0; - public int energy; - public int tickTime; - EntityPlayer player; - TileMFE tile; - private static final EntityEquipmentSlot[] equipmentSlots = new EntityEquipmentSlot[] { EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET }; - - public ContainerMFE(TileMFE tile, EntityPlayer player) { - super(); - this.tile = tile; - this.player = player; - - int i; - - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142)); - } - for (int k = 0; k < 4; k++) { - final EntityEquipmentSlot slot = equipmentSlots[k]; - addSlotToContainer(new BaseSlot(player.inventory, player.inventory.getSizeInventory() - 2 - k, 44, 6 + k * 19) { - @Override - public int getSlotStackLimit() { return 1; } - - @Override - public boolean isItemValid(ItemStack stack) { - return stack != null && stack.getItem().isValidArmor(stack, slot, player); - } - }); - } - this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17)); - this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53)); - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - for (int i = 0; i < this.listeners.size(); i++) { - IContainerListener IContainerListener = this.listeners.get(i); - if (this.energy != (int) tile.getEnergy()) { - IContainerListener.sendProgressBarUpdate(this, 2, (int) tile.getEnergy()); - } - } - } - - @Override - public void addListener(IContainerListener crafting) { - super.addListener(crafting); - crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy()); - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int id, int value) { - if (id == 0) { - this.burnTime = value; - } else if (id == 1) { - this.totalBurnTime = value; - } else if (id == 2) { - this.energy = value; - } - this.tile.setEnergy(energy); - } - - public int getScaledBurnTime(int i) { - return (int) (((float) burnTime / (float) totalBurnTime) * i); - } -} diff --git a/src/main/java/techreborn/client/container/ContainerMFSU.java b/src/main/java/techreborn/client/container/ContainerMFSU.java deleted file mode 100644 index a630caa82..000000000 --- a/src/main/java/techreborn/client/container/ContainerMFSU.java +++ /dev/null @@ -1,94 +0,0 @@ -package techreborn.client.container; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.inventory.IContainerListener; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.client.gui.slots.BaseSlot; -import reborncore.client.gui.slots.SlotCharge; -import reborncore.common.container.RebornContainer; -import techreborn.tiles.storage.TileMFSU; - -public class ContainerMFSU extends RebornContainer { - - public int burnTime = 0; - public int totalBurnTime = 0; - public int energy; - public int tickTime; - EntityPlayer player; - TileMFSU tile; - private static final EntityEquipmentSlot[] equipmentSlots = new EntityEquipmentSlot[] { EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET }; - - public ContainerMFSU(TileMFSU tile, EntityPlayer player) { - super(); - this.tile = tile; - this.player = player; - - int i; - - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142)); - } - for (int k = 0; k < 4; k++) { - final EntityEquipmentSlot slot = equipmentSlots[k]; - addSlotToContainer(new BaseSlot(player.inventory, player.inventory.getSizeInventory() - 2 - k, 44, 6 + k * 19) { - @Override - public int getSlotStackLimit() { return 1; } - - @Override - public boolean isItemValid(ItemStack stack) { - return stack != null && stack.getItem().isValidArmor(stack, slot, player); - } - }); - } - this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17)); - this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53)); - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - for (int i = 0; i < this.listeners.size(); i++) { - IContainerListener IContainerListener = this.listeners.get(i); - if (this.energy != (int) tile.getEnergy()) { - IContainerListener.sendProgressBarUpdate(this, 2, (int) tile.getEnergy()); - } - } - } - - @Override - public void addListener(IContainerListener crafting) { - super.addListener(crafting); - crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy()); - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int id, int value) { - if (id == 0) { - this.burnTime = value; - } else if (id == 1) { - this.totalBurnTime = value; - } else if (id == 2) { - this.energy = value; - } - this.tile.setEnergy(energy); - } - - public int getScaledBurnTime(int i) { - return (int) (((float) burnTime / (float) totalBurnTime) * i); - } -} diff --git a/src/main/java/techreborn/client/container/ContainerMatterFabricator.java b/src/main/java/techreborn/client/container/ContainerMatterFabricator.java deleted file mode 100644 index e00bca927..000000000 --- a/src/main/java/techreborn/client/container/ContainerMatterFabricator.java +++ /dev/null @@ -1,83 +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.SlotOutput; -import reborncore.common.container.RebornContainer; -import techreborn.tiles.TileMatterFabricator; - -public class ContainerMatterFabricator extends RebornContainer { - - public int progressTime; - EntityPlayer player; - TileMatterFabricator tile; - - public ContainerMatterFabricator(TileMatterFabricator tileMatterfab, EntityPlayer player) { - tile = tileMatterfab; - this.player = player; - - // input - this.addSlotToContainer(new BaseSlot(tileMatterfab.inventory, 0, 33, 17)); - this.addSlotToContainer(new BaseSlot(tileMatterfab.inventory, 1, 33, 35)); - this.addSlotToContainer(new BaseSlot(tileMatterfab.inventory, 2, 33, 53)); - this.addSlotToContainer(new BaseSlot(tileMatterfab.inventory, 3, 51, 17)); - this.addSlotToContainer(new BaseSlot(tileMatterfab.inventory, 4, 51, 35)); - this.addSlotToContainer(new BaseSlot(tileMatterfab.inventory, 5, 51, 53)); - - // outputs - this.addSlotToContainer(new SlotOutput(tileMatterfab.inventory, 6, 116, 35)); - - 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; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - for (int i = 0; i < this.listeners.size(); i++) { - IContainerListener IContainerListener = this.listeners.get(i); - if (this.progressTime != tile.progresstime) { - IContainerListener.sendProgressBarUpdate(this, 0, tile.progresstime); - } - } - } - - @Override - public void addListener(IContainerListener crafting) { - super.addListener(crafting); - crafting.sendProgressBarUpdate(this, 0, tile.progresstime); - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int id, int value) { - if (id == 0) { - this.progressTime = value; - } - } - - public int getProgressScaled(int scale) { - if (progressTime != 0) { - return progressTime * scale / tile.maxProgresstime(); - } - return 0; - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerQuantumChest.java b/src/main/java/techreborn/client/container/ContainerQuantumChest.java deleted file mode 100644 index c1e6641b5..000000000 --- a/src/main/java/techreborn/client/container/ContainerQuantumChest.java +++ /dev/null @@ -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.SlotOutput; -import reborncore.common.container.RebornContainer; -import techreborn.tiles.TileQuantumChest; - -public class ContainerQuantumChest extends RebornContainer { - public TileQuantumChest tileQuantumChest; - public EntityPlayer player; - - public ContainerQuantumChest(TileQuantumChest tileQuantumChest, EntityPlayer player) { - super(); - this.tileQuantumChest = tileQuantumChest; - this.player = player; - - this.addSlotToContainer(new BaseSlot(tileQuantumChest.inventory, 0, 80, 17)); - this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1, 80, 53)); - this.addSlotToContainer(new SlotFake(tileQuantumChest.inventory, 2, 59, 42, false, false, Integer.MAX_VALUE)); - - 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; - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerQuantumTank.java b/src/main/java/techreborn/client/container/ContainerQuantumTank.java deleted file mode 100644 index df3cb8ab9..000000000 --- a/src/main/java/techreborn/client/container/ContainerQuantumTank.java +++ /dev/null @@ -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.TileQuantumTank; - -public class ContainerQuantumTank extends RebornContainer { - public TileQuantumTank tileQuantumTank; - public EntityPlayer player; - - public ContainerQuantumTank(TileQuantumTank tileQuantumTank, EntityPlayer player) { - super(); - this.tileQuantumTank = tileQuantumTank; - this.player = player; - - this.addSlotToContainer(new SlotFluid(tileQuantumTank.inventory, 0, 80, 17)); - this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1, 80, 53)); - this.addSlotToContainer(new SlotFake(tileQuantumTank.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; - } -} diff --git a/src/main/java/techreborn/client/container/ContainerRecycler.java b/src/main/java/techreborn/client/container/ContainerRecycler.java deleted file mode 100644 index c192ee1f8..000000000 --- a/src/main/java/techreborn/client/container/ContainerRecycler.java +++ /dev/null @@ -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; - } - } -} diff --git a/src/main/java/techreborn/client/container/ContainerRollingMachine.java b/src/main/java/techreborn/client/container/ContainerRollingMachine.java deleted file mode 100644 index 4162bb33e..000000000 --- a/src/main/java/techreborn/client/container/ContainerRollingMachine.java +++ /dev/null @@ -1,111 +0,0 @@ -package techreborn.client.container; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IContainerListener; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import reborncore.client.gui.slots.BaseSlot; -import reborncore.client.gui.slots.SlotOutput; -import reborncore.common.container.RebornContainer; -import techreborn.api.RollingMachineRecipe; -import techreborn.tiles.TileRollingMachine; - -public class ContainerRollingMachine extends RebornContainer { - - EntityPlayer player; - TileRollingMachine tile; - int currentItemBurnTime; - int burnTime; - int energy; - - public ContainerRollingMachine(TileRollingMachine tileRollingmachine, EntityPlayer player) { - tile = tileRollingmachine; - this.player = player; - - for (int l = 0; l < 3; l++) { - for (int k1 = 0; k1 < 3; k1++) { - this.addSlotToContainer( - new BaseSlot(tileRollingmachine.craftMatrix, k1 + l * 3, 30 + k1 * 18, 17 + l * 18)); - } - } - - // output - this.addSlotToContainer(new SlotOutput(tileRollingmachine.inventory, 0, 124, 35)); - // battery - this.addSlotToContainer(new BaseSlot(tileRollingmachine.inventory, 2, 8, 51)); - - 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 final void onCraftMatrixChanged(IInventory inv) { - ItemStack output = RollingMachineRecipe.instance.findMatchingRecipe(tile.craftMatrix, tile.getWorld()); - tile.inventory.setInventorySlotContents(1, output); - } - - @Override - public void addListener(IContainerListener crafting) { - super.addListener(crafting); - crafting.sendProgressBarUpdate(this, 0, tile.runTime); - crafting.sendProgressBarUpdate(this, 1, tile.tickTime); - crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy()); - } - - @Override - public void detectAndSendChanges() { - for (int i = 0; i < this.listeners.size(); i++) { - IContainerListener crafting = this.listeners.get(i); - if (this.currentItemBurnTime != tile.runTime) { - crafting.sendProgressBarUpdate(this, 0, tile.runTime); - } - if (this.burnTime != tile.tickTime || tile.tickTime == -1) { - crafting.sendProgressBarUpdate(this, 1, tile.tickTime); - } - if (this.energy != (int) tile.getEnergy()) { - crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy()); - } - } - super.detectAndSendChanges(); - } - - @Override - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - if (id == 0) { - this.currentItemBurnTime = value; - } else if (id == 1) { - this.burnTime = value; - } else if (id == 2) { - this.energy = value; - } - this.tile.runTime = this.currentItemBurnTime; - if (this.burnTime == -1) { - this.burnTime = 0; - } - this.tile.tickTime = this.burnTime; - this.tile.setEnergy(this.energy); - } - - public int getBurnTimeRemainingScaled(int scale) { - if (burnTime == 0 || this.currentItemBurnTime == 0) { - return 0; - } - return this.burnTime * scale / this.currentItemBurnTime; - } - -} diff --git a/src/main/java/techreborn/client/container/ContainerScrapboxinator.java b/src/main/java/techreborn/client/container/ContainerScrapboxinator.java deleted file mode 100644 index 9a2b8d63d..000000000 --- a/src/main/java/techreborn/client/container/ContainerScrapboxinator.java +++ /dev/null @@ -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.TileScrapboxinator; - -public class ContainerScrapboxinator extends RebornContainer { - - public int connectionStatus; - EntityPlayer player; - TileScrapboxinator tile; - - public ContainerScrapboxinator(TileScrapboxinator tileScrapboxinator, EntityPlayer player) { - super(); - tile = tileScrapboxinator; - this.player = player; - - // input - this.addSlotToContainer(new SlotScrapbox(tileScrapboxinator.inventory, 0, 56, 34)); - this.addSlotToContainer(new SlotOutput(tileScrapboxinator.inventory, 1, 116, 34)); - - // upgrades - this.addSlotToContainer(new SlotUpgrade(tileScrapboxinator.inventory, 2, 152, 8)); - this.addSlotToContainer(new SlotUpgrade(tileScrapboxinator.inventory, 3, 152, 26)); - this.addSlotToContainer(new SlotUpgrade(tileScrapboxinator.inventory, 4, 152, 44)); - this.addSlotToContainer(new SlotUpgrade(tileScrapboxinator.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; - } - } -} diff --git a/src/main/java/techreborn/client/container/ContainerSemifluidGenerator.java b/src/main/java/techreborn/client/container/ContainerSemifluidGenerator.java deleted file mode 100644 index 95cd3def5..000000000 --- a/src/main/java/techreborn/client/container/ContainerSemifluidGenerator.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/techreborn/client/container/ContainerThermalGenerator.java b/src/main/java/techreborn/client/container/ContainerThermalGenerator.java deleted file mode 100644 index aac450f7e..000000000 --- a/src/main/java/techreborn/client/container/ContainerThermalGenerator.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/techreborn/client/container/ContainerVacuumFreezer.java b/src/main/java/techreborn/client/container/ContainerVacuumFreezer.java deleted file mode 100644 index 83abee067..000000000 --- a/src/main/java/techreborn/client/container/ContainerVacuumFreezer.java +++ /dev/null @@ -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.SlotOutput; -import techreborn.tiles.multiblock.TileVacuumFreezer; - -public class ContainerVacuumFreezer extends ContainerCrafting { - - EntityPlayer player; - TileVacuumFreezer tile; - - public ContainerVacuumFreezer(TileVacuumFreezer tileAlloysmelter, EntityPlayer player) { - super(tileAlloysmelter.crafter); - tile = tileAlloysmelter; - this.player = player; - - // input - this.addSlotToContainer(new BaseSlot(tileAlloysmelter.inventory, 0, 56, 34)); - // outputs - this.addSlotToContainer(new SlotOutput(tileAlloysmelter.inventory, 1, 116, 35)); - - for (int 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 (int i = 0; i < 9; ++i) { - this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142)); - } - - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } - -} diff --git a/src/main/java/techreborn/client/container/IContainerProvider.java b/src/main/java/techreborn/client/container/IContainerProvider.java new file mode 100644 index 000000000..bd3dfe432 --- /dev/null +++ b/src/main/java/techreborn/client/container/IContainerProvider.java @@ -0,0 +1,9 @@ +package techreborn.client.container; + +import net.minecraft.entity.player.EntityPlayer; + +import techreborn.client.container.builder.BuiltContainer; + +public interface IContainerProvider { + BuiltContainer createContainer(EntityPlayer player); +} diff --git a/src/main/java/techreborn/client/container/SlotScrapbox.java b/src/main/java/techreborn/client/container/SlotScrapbox.java deleted file mode 100644 index 193ca9560..000000000 --- a/src/main/java/techreborn/client/container/SlotScrapbox.java +++ /dev/null @@ -1,21 +0,0 @@ -package techreborn.client.container; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import reborncore.client.gui.slots.BaseSlot; -import techreborn.init.ModItems; - -public class SlotScrapbox extends BaseSlot { - - public SlotScrapbox(IInventory par1iInventory, int par2, int par3, int par4) { - super(par1iInventory, par2, par3, par4); - } - - public boolean isItemValid(ItemStack par1ItemStack) { - return par1ItemStack.getItem() == ModItems.SCRAP_BOX; - } - - public int getSlotStackLimit() { - return 64; - } -} \ No newline at end of file diff --git a/src/main/java/techreborn/client/container/builder/BuiltContainer.java b/src/main/java/techreborn/client/container/builder/BuiltContainer.java new file mode 100644 index 000000000..0742c5909 --- /dev/null +++ b/src/main/java/techreborn/client/container/builder/BuiltContainer.java @@ -0,0 +1,264 @@ +package techreborn.client.container.builder; + +import org.apache.commons.lang3.Range; +import org.apache.commons.lang3.tuple.MutableTriple; +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.*; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import reborncore.common.util.ItemUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.IntConsumer; +import java.util.function.IntSupplier; +import java.util.function.Predicate; + +public class BuiltContainer extends Container { + + private final String name; + + private final Predicate canInteract; + private final List> playerSlotRanges; + private final List> tileSlotRanges; + + private final ArrayList> shortValues; + private final ArrayList> integerValues; + private List> craftEvents; + private Integer[] integerParts; + + public BuiltContainer(final String name, final Predicate canInteract, + final List> playerSlotRange, + final List> tileSlotRange) { + this.name = name; + + this.canInteract = canInteract; + + this.playerSlotRanges = playerSlotRange; + this.tileSlotRanges = tileSlotRange; + + this.shortValues = new ArrayList<>(); + this.integerValues = new ArrayList<>(); + } + + public void addShortSync(final List> syncables) { + + for (final Pair syncable : syncables) + this.shortValues.add(MutableTriple.of(syncable.getLeft(), syncable.getRight(), (short) 0)); + this.shortValues.trimToSize(); + } + + public void addIntegerSync(final List> syncables) { + + for (final Pair syncable : syncables) + this.integerValues.add(MutableTriple.of(syncable.getLeft(), syncable.getRight(), 0)); + this.integerValues.trimToSize(); + this.integerParts = new Integer[this.integerValues.size()]; + } + + public void addCraftEvents(final List> craftEvents) { + this.craftEvents = craftEvents; + } + + public void addSlot(final Slot slot) { + this.addSlotToContainer(slot); + } + + @Override + public boolean canInteractWith(final EntityPlayer playerIn) { + return this.canInteract.test(playerIn); + } + + @Override + public final void onCraftMatrixChanged(final IInventory inv) { + if (!this.craftEvents.isEmpty()) + this.craftEvents.forEach(consumer -> consumer.accept((InventoryCrafting) inv)); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + + for (final IContainerListener listener : this.listeners) { + + int i = 0; + if (!this.shortValues.isEmpty()) + for (final MutableTriple value : this.shortValues) { + final short supplied = (short) value.getLeft().getAsInt(); + if (supplied != value.getRight()) { + + listener.sendProgressBarUpdate(this, i, supplied); + value.setRight(supplied); + } + i++; + } + + if (!this.integerValues.isEmpty()) + for (final MutableTriple value : this.integerValues) { + final int supplied = value.getLeft().getAsInt(); + if (supplied != value.getRight()) { + + listener.sendProgressBarUpdate(this, i, supplied >> 16); + listener.sendProgressBarUpdate(this, i + 1, (short) (supplied & 0xFFFF)); + value.setRight(supplied); + } + i += 2; + } + } + } + + @Override + public void addListener(final IContainerListener listener) { + super.addListener(listener); + + int i = 0; + if (!this.shortValues.isEmpty()) + for (final MutableTriple value : this.shortValues) { + final short supplied = (short) value.getLeft().getAsInt(); + + listener.sendProgressBarUpdate(this, i, supplied); + value.setRight(supplied); + i++; + } + + if (!this.integerValues.isEmpty()) + for (final MutableTriple value : this.integerValues) { + final int supplied = value.getLeft().getAsInt(); + + listener.sendProgressBarUpdate(this, i, supplied >> 16); + listener.sendProgressBarUpdate(this, i + 1, (short) (supplied & 0xFFFF)); + value.setRight(supplied); + i += 2; + } + + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(final int id, final int value) { + + if(id < this.shortValues.size()) + { + this.shortValues.get(id).getMiddle().accept((short) value); + this.shortValues.get(id).setRight((short) value); + } + else if (id - this.shortValues.size() < this.integerValues.size() * 2) + { + + if ((id - this.shortValues.size()) % 2 == 0) + this.integerParts[(id - this.shortValues.size()) / 2] = value; + else + { + this.integerValues.get((id - this.shortValues.size()) / 2).getMiddle().accept( + (this.integerParts[(id - this.shortValues.size()) / 2] & 0xFFFF) << 16 | value & 0xFFFF); + } + } + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer player, final int index) { + + ItemStack originalStack = ItemStack.EMPTY; + + final Slot slot = this.inventorySlots.get(index); + + if (slot != null && slot.getHasStack()) { + + final ItemStack stackInSlot = slot.getStack(); + originalStack = stackInSlot.copy(); + + boolean shifted = false; + + for (final Range range : this.playerSlotRanges) + if (range.contains(index)) { + + if (this.shiftToTile(stackInSlot)) + shifted = true; + break; + } + + if (!shifted) + for (final Range range : this.tileSlotRanges) + if (range.contains(index)) { + if (this.shiftToPlayer(stackInSlot)) + shifted = true; + break; + } + + slot.onSlotChange(stackInSlot, originalStack); + if (stackInSlot.getCount() <= 0) + slot.putStack(ItemStack.EMPTY); + else + slot.onSlotChanged(); + if (stackInSlot.getCount() == originalStack.getCount()) + return ItemStack.EMPTY; + slot.onTake(player, stackInSlot); + } + return originalStack; + } + + protected boolean shiftItemStack(final ItemStack stackToShift, final int start, final int end) { + boolean changed = false; + if (stackToShift.isStackable()) { + for (int slotIndex = start; stackToShift.getCount() > 0 && slotIndex < end; slotIndex++) { + final Slot slot = this.inventorySlots.get(slotIndex); + final ItemStack stackInSlot = slot.getStack(); + if (stackInSlot != ItemStack.EMPTY && ItemUtils.isItemEqual(stackInSlot, stackToShift, true, true) + && slot.isItemValid(stackToShift)) { + final int resultingStackSize = stackInSlot.getCount() + stackToShift.getCount(); + final int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit()); + if (resultingStackSize <= max) { + stackToShift.setCount(0); + stackInSlot.setCount(resultingStackSize); + slot.onSlotChanged(); + changed = true; + } else if (stackInSlot.getCount() < max) { + stackToShift.shrink(max - stackInSlot.getCount()); + stackInSlot.setCount(max); + slot.onSlotChanged(); + changed = true; + } + } + } + } + if (stackToShift.getCount() > 0) { + for (int slotIndex = start; stackToShift.getCount() > 0 && slotIndex < end; slotIndex++) { + final Slot slot = this.inventorySlots.get(slotIndex); + ItemStack stackInSlot = slot.getStack(); + if (stackInSlot == ItemStack.EMPTY && slot.isItemValid(stackToShift)) { + final int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit()); + stackInSlot = stackToShift.copy(); + stackInSlot.setCount(Math.min(stackToShift.getCount(), max)); + stackToShift.setCount(-stackInSlot.getCount()); + slot.putStack(stackInSlot); + slot.onSlotChanged(); + changed = true; + } + } + } + return changed; + } + + private boolean shiftToTile(final ItemStack stackToShift) { + for (final Range range : this.tileSlotRanges) + if (this.shiftItemStack(stackToShift, range.getMinimum(), range.getMaximum() + 1)) + return true; + return false; + } + + private boolean shiftToPlayer(final ItemStack stackToShift) { + for (final Range range : this.playerSlotRanges) + if (this.shiftItemStack(stackToShift, range.getMinimum(), range.getMaximum() + 1)) + return true; + return false; + } + + public String getName() { + return this.name; + } +} \ No newline at end of file diff --git a/src/main/java/techreborn/client/container/builder/ContainerBuilder.java b/src/main/java/techreborn/client/container/builder/ContainerBuilder.java new file mode 100644 index 000000000..56ac35700 --- /dev/null +++ b/src/main/java/techreborn/client/container/builder/ContainerBuilder.java @@ -0,0 +1,84 @@ +package techreborn.client.container.builder; + +import org.apache.commons.lang3.Range; +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.Slot; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.IntConsumer; +import java.util.function.IntSupplier; +import java.util.function.Predicate; + +public class ContainerBuilder { + + private final String name; + + private Predicate canInteract = player -> true; + + final List slots; + final List> playerInventoryRanges, tileInventoryRanges; + + final List> shortValues; + final List> integerValues; + + final List> craftEvents; + + public ContainerBuilder(final String name) { + + this.name = name; + + this.slots = new ArrayList<>(); + this.playerInventoryRanges = new ArrayList<>(); + this.tileInventoryRanges = new ArrayList<>(); + + this.shortValues = new ArrayList<>(); + this.integerValues = new ArrayList<>(); + + this.craftEvents = new ArrayList<>(); + } + + public ContainerBuilder interact(final Predicate canInteract) { + this.canInteract = canInteract; + return this; + } + + public ContainerPlayerInventoryBuilder player(final InventoryPlayer player) { + return new ContainerPlayerInventoryBuilder(this, player); + } + + public ContainerTileInventoryBuilder tile(final IInventory tile) { + return new ContainerTileInventoryBuilder(this, tile); + } + + void addPlayerInventoryRange(final Range range) { + this.playerInventoryRanges.add(range); + } + + void addTileInventoryRange(final Range range) { + this.tileInventoryRanges.add(range); + } + + public BuiltContainer create() { + final BuiltContainer built = new BuiltContainer(this.name, this.canInteract, + this.playerInventoryRanges, + this.tileInventoryRanges); + if (!this.shortValues.isEmpty()) + built.addShortSync(this.shortValues); + if (!this.integerValues.isEmpty()) + built.addIntegerSync(this.integerValues); + if (!this.craftEvents.isEmpty()) + built.addCraftEvents(this.craftEvents); + + this.slots.forEach(built::addSlot); + + this.slots.clear(); + return built; + } +} diff --git a/src/main/java/techreborn/client/container/builder/ContainerPlayerInventoryBuilder.java b/src/main/java/techreborn/client/container/builder/ContainerPlayerInventoryBuilder.java new file mode 100644 index 000000000..f1baf8982 --- /dev/null +++ b/src/main/java/techreborn/client/container/builder/ContainerPlayerInventoryBuilder.java @@ -0,0 +1,105 @@ +package techreborn.client.container.builder; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.EntityEquipmentSlot; +import org.apache.commons.lang3.Range; +import reborncore.client.gui.slots.BaseSlot; +import techreborn.client.container.builder.slot.FilteredSlot; + +public final class ContainerPlayerInventoryBuilder { + + private final InventoryPlayer player; + private final ContainerBuilder parent; + private Range main; + private Range hotbar; + private Range armor; + + ContainerPlayerInventoryBuilder(final ContainerBuilder parent, final InventoryPlayer player) { + this.player = player; + this.parent = parent; + } + + public ContainerPlayerInventoryBuilder inventory(final int xStart, final int yStart) { + final int startIndex = this.parent.slots.size(); + for (int i = 0; i < 3; ++i) + for (int j = 0; j < 9; ++j) + this.parent.slots.add(new BaseSlot(this.player, j + i * 9 + 9, xStart + j * 18, yStart + i * 18)); + this.main = Range.between(startIndex, this.parent.slots.size() - 1); + return this; + } + + public ContainerPlayerInventoryBuilder hotbar(final int xStart, final int yStart) { + final int startIndex = this.parent.slots.size(); + for (int i = 0; i < 9; ++i) + this.parent.slots.add(new BaseSlot(this.player, i, xStart + i * 18, yStart)); + this.hotbar = Range.between(startIndex, this.parent.slots.size() - 1); + return this; + } + + public ContainerPlayerInventoryBuilder inventory() { + return this.inventory(8, 94); + } + + public ContainerPlayerInventoryBuilder hotbar() { + return this.hotbar(8, 152); + } + + public ContainerPlayerArmorInventoryBuilder armor() { + return new ContainerPlayerArmorInventoryBuilder(this); + } + + public ContainerBuilder addInventory() { + if (this.hotbar != null) + this.parent.addPlayerInventoryRange(this.hotbar); + if (this.main != null) + this.parent.addPlayerInventoryRange(this.main); + if (this.armor != null) + this.parent.addTileInventoryRange(this.armor); + + return this.parent; + } + + public static final class ContainerPlayerArmorInventoryBuilder { + private final ContainerPlayerInventoryBuilder parent; + private final int startIndex; + + public ContainerPlayerArmorInventoryBuilder(final ContainerPlayerInventoryBuilder parent) { + this.parent = parent; + this.startIndex = parent.parent.slots.size(); + } + + private ContainerPlayerArmorInventoryBuilder armor(final int index, final int xStart, final int yStart, + final EntityEquipmentSlot slotType) { + + this.parent.parent.slots.add(new FilteredSlot(this.parent.player, index, xStart, yStart) + .setFilter(stack -> stack.getItem().isValidArmor(stack, slotType, this.parent.player.player))); + return this; + } + + public ContainerPlayerArmorInventoryBuilder helmet(final int xStart, final int yStart) { + return this.armor(this.parent.player.getSizeInventory() - 2, xStart, yStart, EntityEquipmentSlot.HEAD); + } + + public ContainerPlayerArmorInventoryBuilder chestplate(final int xStart, final int yStart) { + return this.armor(this.parent.player.getSizeInventory() - 3, xStart, yStart, EntityEquipmentSlot.CHEST); + } + + public ContainerPlayerArmorInventoryBuilder leggings(final int xStart, final int yStart) { + return this.armor(this.parent.player.getSizeInventory() - 4, xStart, yStart, EntityEquipmentSlot.LEGS); + } + + public ContainerPlayerArmorInventoryBuilder boots(final int xStart, final int yStart) { + return this.armor(this.parent.player.getSizeInventory() - 5, xStart, yStart, EntityEquipmentSlot.FEET); + } + + public ContainerPlayerArmorInventoryBuilder complete(final int xStart, final int yStart) { + return this.helmet(xStart, yStart).chestplate(xStart, yStart + 18).leggings(xStart, yStart + 18 + 18) + .boots(xStart, yStart + 18 + 18 + 18); + } + + public ContainerPlayerInventoryBuilder addArmor() { + this.parent.armor = Range.between(this.startIndex, this.parent.parent.slots.size() - 1); + return this.parent; + } + } +} \ No newline at end of file diff --git a/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java b/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java new file mode 100644 index 000000000..ba5e89f8e --- /dev/null +++ b/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java @@ -0,0 +1,147 @@ +package techreborn.client.container.builder; + +import org.apache.commons.lang3.Range; +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.SlotFurnaceFuel; +import net.minecraft.item.ItemStack; +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; +import reborncore.common.powerSystem.TilePowerAcceptor; + +import techreborn.Core; +import techreborn.client.container.builder.slot.FilteredSlot; +import techreborn.utils.upgrade.IMachineUpgrade; + +import java.util.function.Consumer; +import java.util.function.IntConsumer; +import java.util.function.IntSupplier; +import java.util.function.Predicate; + +public class ContainerTileInventoryBuilder { + + private final IInventory tile; + private final ContainerBuilder parent; + private final int rangeStart; + + ContainerTileInventoryBuilder(final ContainerBuilder parent, final IInventory tile) { + this.tile = tile; + this.parent = parent; + this.rangeStart = parent.slots.size(); + } + + public ContainerTileInventoryBuilder slot(final int index, final int x, final int y) { + this.parent.slots.add(new BaseSlot(this.tile, index, x, y)); + return this; + } + + public ContainerTileInventoryBuilder outputSlot(final int index, final int x, final int y) { + this.parent.slots.add(new SlotOutput(this.tile, index, x, y)); + return this; + } + + public ContainerTileInventoryBuilder fakeSlot(final int index, final int x, final int y) { + this.parent.slots.add(new SlotFake(this.tile, index, x, y, false, false, Integer.MAX_VALUE)); + return this; + } + + public ContainerTileInventoryBuilder filterSlot(final int index, final int x, final int y, + final Predicate filter) { + this.parent.slots.add(new FilteredSlot(this.tile, index, x, y).setFilter(filter)); + return this; + } + + @SuppressWarnings("null") + public ContainerTileInventoryBuilder energySlot(final int index, final int x, final int y) { + this.parent.slots.add(new FilteredSlot(this.tile, index, x, y) + .setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP) + || stack.getItem() instanceof IEnergyInterfaceItem)); + 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 + * The supplier must supply a variable holding inside a Short, it + * will be truncated by force. + * @param setter + * The setter to call when the variable has been updated. + */ + public ContainerTileInventoryBuilder syncShortValue(final IntSupplier supplier, final IntConsumer setter) { + this.parent.shortValues.add(Pair.of(supplier, setter)); + return this; + } + + /** + * + * @param supplier + * The supplier it can supply a variable holding in an Integer it + * will be split inside multiples shorts. + * @param setter + * The setter to call when the variable has been updated. + */ + public ContainerTileInventoryBuilder syncIntegerValue(final IntSupplier supplier, final IntConsumer setter) { + this.parent.integerValues.add(Pair.of(supplier, setter)); + return this; + } + + public ContainerTileInventoryBuilder syncEnergyValue() { + if (this.tile instanceof TilePowerAcceptor) + return this.syncIntegerValue(() -> (int) ((TilePowerAcceptor) this.tile).getEnergy(), + ((TilePowerAcceptor) this.tile)::setEnergy); + Core.logHelper.error(this.tile + " is not an instance of TilePowerAcceptor! Energy cannot be synced."); + return this; + } + + public 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 ContainerTileInventoryBuilder onCraft(final Consumer onCraft) { + this.parent.craftEvents.add(onCraft); + return this; + } + + public ContainerBuilder addInventory() { + this.parent.tileInventoryRanges.add(Range.between(this.rangeStart, this.parent.slots.size() - 1)); + return this.parent; + } +} diff --git a/src/main/java/techreborn/client/container/builder/slot/FilteredSlot.java b/src/main/java/techreborn/client/container/builder/slot/FilteredSlot.java new file mode 100644 index 000000000..ce1c6f2a9 --- /dev/null +++ b/src/main/java/techreborn/client/container/builder/slot/FilteredSlot.java @@ -0,0 +1,30 @@ +package techreborn.client.container.builder.slot; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import java.util.function.Predicate; + +public class FilteredSlot extends Slot { + + private Predicate filter; + + public FilteredSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition) { + super(inventory, index, xPosition, yPosition); + } + + public FilteredSlot setFilter(final Predicate filter) { + this.filter = filter; + return this; + } + + @Override + public boolean isItemValid(final ItemStack stack) { + try { + return this.filter.test(stack); + } catch (NullPointerException e) { + return true; + } + } +} diff --git a/src/main/java/techreborn/client/container/builder/slot/SpriteSlot.java b/src/main/java/techreborn/client/container/builder/slot/SpriteSlot.java new file mode 100644 index 000000000..7e157054e --- /dev/null +++ b/src/main/java/techreborn/client/container/builder/slot/SpriteSlot.java @@ -0,0 +1,37 @@ +package techreborn.client.container.builder.slot; + +import javax.annotation.Nullable; + +import net.minecraft.inventory.IInventory; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import techreborn.lib.ModInfo; + +public class SpriteSlot extends FilteredSlot { + + private final String sprite; + int stacksize; + + public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, final String sprite, final int stacksize) { + super(inventory, index, xPosition, yPosition); + this.sprite = ModInfo.MOD_ID + ":textures/gui/slot_sprites/" + sprite; + this.stacksize = stacksize; + } + + public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, final String sprite) { + this(inventory, index, xPosition, yPosition, sprite, 64); + } + + @Override + public int getSlotStackLimit() { + return this.stacksize; + } + + @Override + @Nullable + @SideOnly(Side.CLIENT) + public String getSlotTexture() { + return this.sprite; + } +} diff --git a/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java b/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java index 4c4084f80..95425f68e 100644 --- a/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java @@ -5,39 +5,36 @@ 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.ContainerAlloyFurnace; + import techreborn.tiles.TileAlloyFurnace; public class GuiAlloyFurnace extends GuiContainer { private static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/alloy_furnace.png"); + "textures/gui/alloy_furnace.png"); TileAlloyFurnace alloyfurnace; - ContainerAlloyFurnace containerAlloyFurnace; - - public GuiAlloyFurnace(EntityPlayer player, TileAlloyFurnace tileAlloyFurnace) { - super(new ContainerAlloyFurnace(tileAlloyFurnace, player)); + public GuiAlloyFurnace(final EntityPlayer player, final TileAlloyFurnace alloyFurnace) { + super(alloyFurnace.createContainer(player)); this.xSize = 176; this.ySize = 167; - this.alloyfurnace = tileAlloyFurnace; - this.containerAlloyFurnace = (ContainerAlloyFurnace) this.inventorySlots; + this.alloyfurnace = alloyFurnace; } @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(GuiAlloyFurnace.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); if (this.alloyfurnace.isBurning()) { @@ -48,12 +45,12 @@ public class GuiAlloyFurnace extends GuiContainer { } } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String name = I18n.translateToLocal("tile.techreborn.alloyfurnace.name"); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translateToLocal("tile.techreborn.alloyfurnace.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); } } diff --git a/src/main/java/techreborn/client/gui/GuiAlloySmelter.java b/src/main/java/techreborn/client/gui/GuiAlloySmelter.java index 011343134..dbc438223 100644 --- a/src/main/java/techreborn/client/gui/GuiAlloySmelter.java +++ b/src/main/java/techreborn/client/gui/GuiAlloySmelter.java @@ -5,57 +5,57 @@ 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.ContainerAlloySmelter; + import techreborn.tiles.TileAlloySmelter; public class GuiAlloySmelter extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/electric_alloy_furnace.png"); + "textures/gui/electric_alloy_furnace.png"); TileAlloySmelter alloysmelter; - public GuiAlloySmelter(EntityPlayer player, TileAlloySmelter tilealloysmelter) { - super(RebornContainer.createContainer(ContainerAlloySmelter.class, tilealloysmelter, player)); + public GuiAlloySmelter(final EntityPlayer player, final TileAlloySmelter alloySmelter) { + super(alloySmelter.createContainer(player)); this.xSize = 176; this.ySize = 167; - alloysmelter = tilealloysmelter; + this.alloysmelter = alloySmelter; } @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(GuiAlloySmelter.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 = alloysmelter.getProgressScaled(24); + j = this.alloysmelter.getProgressScaled(24); if (j > 0) { this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16); } - j = alloysmelter.getEnergyScaled(12); + j = this.alloysmelter.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.alloysmelter.name"); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translateToLocal("tile.techreborn.alloysmelter.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); } } diff --git a/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java b/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java index 65b91781b..e7f1b82f8 100644 --- a/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java +++ b/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java @@ -5,59 +5,57 @@ 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.tiles.TileAssemblingMachine; public class GuiAssemblingMachine extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/assembling_machine.png"); + "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(assemblingMachine.createContainer(player)); 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); + 4210752); this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); + this.ySize - 96 + 2, 4210752); } } diff --git a/src/main/java/techreborn/client/gui/GuiBase.java b/src/main/java/techreborn/client/gui/GuiBase.java new file mode 100644 index 000000000..7b92885fe --- /dev/null +++ b/src/main/java/techreborn/client/gui/GuiBase.java @@ -0,0 +1,127 @@ +package techreborn.client.gui; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.text.translation.I18n; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.gui.widget.GuiButtonPowerBar; + +/** + * Created by Prospector + */ +public class GuiBase extends GuiContainer { + + public int xSize = 176; + public int ySize = 176; + public TRBuilder builder = new TRBuilder(); + public TileEntity tile; + public BuiltContainer container; + + public GuiBase(EntityPlayer player, TileEntity tile, BuiltContainer container) { + super(container); + this.tile = tile; + this.container = container; + } + + protected void drawSlot(int x, int y, Layer layer) { + if (layer == Layer.BACKGROUND) { + x += guiLeft; + y += guiTop; + } + builder.drawSlot(this, x - 1, y - 1); + } + + protected void drawArmourSlots(int x, int y, Layer layer) { + if (layer == Layer.BACKGROUND) { + x += guiLeft; + y += guiTop; + } + builder.drawSlot(this, x - 1, y - 1); + builder.drawSlot(this, x - 1, y - 1 + 18); + builder.drawSlot(this, x - 1, y - 1 + 18 + 18); + builder.drawSlot(this, x - 1, y - 1 + 18 + 18 + 18); + } + + protected void drawOutputSlot(int x, int y, Layer layer) { + if (layer == Layer.BACKGROUND) { + x += guiLeft; + y += guiTop; + } + builder.drawOutputSlot(this, x - 5, y - 5); + } + + protected void drawSelectedStack(int x, int y, Layer layer) { + if (layer == Layer.BACKGROUND) { + x += guiLeft; + y += guiTop; + } + builder.drawSelectedStack(this, x, y); + } + + @Override + public void initGui() { + super.initGui(); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int mouseX, int mouseY) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + builder.drawDefaultBackground(this, guiLeft, guiTop, xSize, ySize); + builder.drawPlayerSlots(this, guiLeft + xSize / 2, guiTop + 93, true); + } + + @SideOnly(Side.CLIENT) + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + drawTitle(); + } + + protected void drawTitle() { + drawCentredString(I18n.translateToLocal(tile.getBlockType().getUnlocalizedName() + ".name"), 6, 4210752, Layer.FOREGROUND); + } + + protected void drawCentredString(String string, int y, int colour, Layer layer) { + drawString(string, (xSize / 2 - mc.fontRendererObj.getStringWidth(string) / 2), y, colour, layer); + } + + protected void drawCentredString(String string, int y, int colour, int modifier, Layer layer) { + drawString(string, (xSize / 2 - (mc.fontRendererObj.getStringWidth(string)) / 2) + modifier, y, colour, layer); + } + + protected void drawString(String string, int x, int y, int colour, Layer layer) { + int factorX = 0; + int factorY = 0; + if (layer == Layer.BACKGROUND) { + factorX = guiLeft; + factorY = guiTop; + } + mc.fontRendererObj.drawString(string, x + factorX, y + factorY, colour); + GlStateManager.color(1, 1, 1, 1); + } + + public void addPowerButton(int x, int y, int id, Layer layer) { + if (id == 0) + buttonList.clear(); + int factorX = 0; + int factorY = 0; + if (layer == Layer.BACKGROUND) { + factorX = guiLeft; + factorY = guiTop; + } + buttonList.add(new GuiButtonPowerBar(id, x + factorX, y + factorY, this, layer)); + } + + //TODO + public enum SlotRender { + STANDARD, OUTPUT, NONE, SPRITE; + + } + + public enum Layer { + BACKGROUND, FOREGROUND + } +} diff --git a/src/main/java/techreborn/client/gui/GuiBatbox.java b/src/main/java/techreborn/client/gui/GuiBatbox.java index 6422f1efa..b6652178d 100644 --- a/src/main/java/techreborn/client/gui/GuiBatbox.java +++ b/src/main/java/techreborn/client/gui/GuiBatbox.java @@ -1,68 +1,38 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; +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.ContainerBatbox; import techreborn.tiles.storage.TileBatBox; -public class GuiBatbox extends GuiContainer { +public class GuiBatbox extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/batbox.png"); + TileBatBox tile; - TileBatBox generator; - - ContainerBatbox containerGenerator; - - public GuiBatbox(EntityPlayer player, TileBatBox generator) { - super(new ContainerBatbox(generator, player)); - this.xSize = 176; - this.ySize = 167; - this.generator = generator; - this.containerGenerator = (ContainerBatbox) this.inventorySlots; + public GuiBatbox(final EntityPlayer player, final TileBatBox tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - public void initGui() { - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - super.initGui(); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; + + this.drawSlot(62, 45, layer); + this.drawSlot(98, 45, layer); } @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; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final Layer layer = Layer.FOREGROUND; - int j = 0; + GlStateManager.pushMatrix(); + GlStateManager.scale(0.6, 0.6, 5); + this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer); + GlStateManager.popMatrix(); - j = 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); - // 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.batbox.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(generator.getMaxPower()), 25, this.ySize - 140, - 4210752); - this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 25, this.ySize - 150, - 4210752); + this.builder.drawMultiEnergyBar(this, 81, 28, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiBlastFurnace.java b/src/main/java/techreborn/client/gui/GuiBlastFurnace.java index d10c020a2..d11e3bf5b 100644 --- a/src/main/java/techreborn/client/gui/GuiBlastFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiBlastFurnace.java @@ -2,170 +2,139 @@ package techreborn.client.gui; import net.minecraft.block.state.IBlockState; import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.translation.I18n; -import reborncore.client.gui.GuiUtil; import reborncore.client.multiblock.Multiblock; import reborncore.client.multiblock.MultiblockRenderEvent; import reborncore.client.multiblock.MultiblockSet; import reborncore.common.misc.Location; -import reborncore.common.multiblock.CoordTriplet; -import techreborn.client.container.ContainerBlastFurnace; +import techreborn.client.gui.widget.GuiButtonHologram; import techreborn.init.ModBlocks; import techreborn.proxies.ClientProxy; import techreborn.tiles.multiblock.TileBlastFurnace; import java.io.IOException; -public class GuiBlastFurnace extends GuiContainer { +public class GuiBlastFurnace extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/industrial_blast_furnace.png"); - - TileBlastFurnace blastfurnace; - - ContainerBlastFurnace containerBlastFurnace; + public TileBlastFurnace tile; boolean hasMultiBlock; - public GuiBlastFurnace(EntityPlayer player, TileBlastFurnace tileblastfurnace) { - super(new ContainerBlastFurnace(tileblastfurnace, player)); - this.xSize = 176; - this.ySize = 167; - blastfurnace = tileblastfurnace; - this.containerBlastFurnace = (ContainerBlastFurnace) this.inventorySlots; + public GuiBlastFurnace(final EntityPlayer player, final TileBlastFurnace tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override public void initGui() { - - hasMultiBlock = containerBlastFurnace.heat != 0; - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - GuiButton button = new GuiButton(212, k + 4, l + 6, 20, 20, ""); - buttonList.add(button); super.initGui(); - CoordTriplet coordinates = new CoordTriplet( - blastfurnace.getPos().getX() - (EnumFacing.getFront(blastfurnace.getFacingInt()).getFrontOffsetX() * 2), - blastfurnace.getPos().getY() - 1, blastfurnace.getPos().getZ() - - (EnumFacing.getFront(blastfurnace.getFacingInt()).getFrontOffsetZ() * 2)); - if (coordinates.equals(ClientProxy.multiblockRenderEvent.anchor) && blastfurnace.getHeat() != 0) { - ClientProxy.multiblockRenderEvent.setMultiblock(null); - button.displayString = "B"; - } else { - button.displayString = "A"; - } + this.hasMultiBlock = this.tile.getCachedHeat() != 0; } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + final GuiBase.Layer layer = Layer.BACKGROUND; - if (containerBlastFurnace.heat == 0) { - GuiUtil.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10); - this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, - l + 52 + 12 - 0, -1); - } + drawSlot(50, 27, layer); + drawSlot(50, 47, layer); + drawSlot(92, 36, layer); + drawSlot(110, 36, layer); - int j = 0; - this.mc.getTextureManager().bindTexture(texture); - j = blastfurnace.getProgressScaled(24); - if (j > 0) { - this.drawTexturedModalRect(k + 64, l + 37, 176, 14, j + 1, 16); - } - - j = blastfurnace.getEnergyScaled(12); - if (j > 0) { - this.drawTexturedModalRect(k + 9, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); - } - - } - - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - super.drawGuiContainerForegroundLayer(p_146979_1_, p_146979_2_); - String name = I18n.translateToLocal("tile.techreborn.blastfurnace.name"); - this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, - 4210752); - if (containerBlastFurnace.heat != 0) { - this.fontRendererObj.drawString("Current Heat: " + containerBlastFurnace.heat, 40, 60, 4210752); - } - this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); + this.builder.drawJEIButton(this, 150, 4, layer); } @Override - public void actionPerformed(GuiButton button) throws IOException { + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; + + this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 71, 40, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); + this.builder.drawBigHeatBar(this, 31, 71, tile.getCachedHeat(), 3230, layer); + addHologramButton(6, 4, 212, layer); + builder.drawHologramButton(this, 6, 4, mouseX, mouseY, layer); + } + + public void addHologramButton(int x, int y, int id, Layer layer) { + if (id == 0) + buttonList.clear(); + int factorX = 0; + int factorY = 0; + if (layer == Layer.BACKGROUND) { + factorX = guiLeft; + factorY = guiTop; + } + buttonList.add(new GuiButtonHologram(id, x + factorX, y + factorY, this, layer)); + } + + @Override + public void actionPerformed(final GuiButton button) throws IOException { super.actionPerformed(button); if (button.id == 212) { if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) { - {// This code here makes a basic multiblock and then sets to the - // selected one. - Multiblock multiblock = new Multiblock(); - addComponent(0, 0, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 0, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(0, 0, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 0, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(0, 0, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 0, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 0, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 0, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 0, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + { + // This code here makes a basic multiblock and then sets to the selected one. + final Multiblock multiblock = new Multiblock(); + this.addComponent(0, 0, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 0, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(0, 0, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 0, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(0, 0, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 0, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 0, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 0, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 0, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 1, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(0, 1, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 1, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(0, 1, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 1, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 1, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 1, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 1, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 1, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(0, 1, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 1, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(0, 1, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 1, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 1, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 1, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 1, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 2, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(0, 2, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 2, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(0, 2, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 2, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 2, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 2, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 2, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 2, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(0, 2, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 2, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(0, 2, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 2, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 2, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 2, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 2, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(0, 3, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 3, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(0, 3, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 3, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(0, 3, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 3, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(-1, 3, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 3, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - addComponent(1, 3, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(0, 3, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 3, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(0, 3, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 3, 0, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(0, 3, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 3, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(-1, 3, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 3, -1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); + this.addComponent(1, 3, 1, ModBlocks.MACHINE_CASINGS.getDefaultState(), multiblock); - MultiblockSet set = new MultiblockSet(multiblock); + final MultiblockSet set = new MultiblockSet(multiblock); ClientProxy.multiblockRenderEvent.setMultiblock(set); - ClientProxy.multiblockRenderEvent.parent = new Location(blastfurnace.getPos().getX(), - blastfurnace.getPos().getY(), blastfurnace.getPos().getZ(), blastfurnace.getWorld()); + ClientProxy.multiblockRenderEvent.parent = new Location(this.tile.getPos().getX(), + this.tile.getPos().getY(), this.tile.getPos().getZ(), this.tile.getWorld()); MultiblockRenderEvent.anchor = new BlockPos( - blastfurnace.getPos().getX() - - (EnumFacing.getFront(blastfurnace.getFacingInt()).getFrontOffsetX() * 2), - blastfurnace.getPos().getY() - 1, blastfurnace.getPos().getZ() - - (EnumFacing.getFront(blastfurnace.getFacingInt()).getFrontOffsetZ() * 2)); + this.tile.getPos().getX() + - EnumFacing.getFront(this.tile.getFacingInt()).getFrontOffsetX() * 2, + this.tile.getPos().getY() - 1, this.tile.getPos().getZ() + - EnumFacing.getFront(this.tile.getFacingInt()).getFrontOffsetZ() * 2); } - button.displayString = "A"; } else { ClientProxy.multiblockRenderEvent.setMultiblock(null); - button.displayString = "B"; } } } - public void addComponent(int x, int y, int z, IBlockState blockState, Multiblock multiblock) { + public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) { multiblock.addComponent(new BlockPos(x, y, z), blockState); } diff --git a/src/main/java/techreborn/client/gui/GuiCentrifuge.java b/src/main/java/techreborn/client/gui/GuiCentrifuge.java index c1d41ffdc..edc151c33 100644 --- a/src/main/java/techreborn/client/gui/GuiCentrifuge.java +++ b/src/main/java/techreborn/client/gui/GuiCentrifuge.java @@ -1,67 +1,41 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -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.tiles.TileCentrifuge; -public class GuiCentrifuge extends GuiContainer { +public class GuiCentrifuge extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/industrial_centrifuge.png"); + TileCentrifuge tile; - TileCentrifuge centrifuge; - - public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge) { - super(RebornContainer.createContainer(ContainerCentrifuge.class, tileCentrifuge, player)); - this.xSize = 176; - this.ySize = 167; - centrifuge = tileCentrifuge; + public GuiCentrifuge(final EntityPlayer player, final TileCentrifuge tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - public void initGui() { - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - super.initGui(); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; + + this.drawSlot(8, 72, layer); + + this.drawSlot(40, 34, layer); + this.drawSlot(40, 54, layer); + + this.drawSlot(82, 44, layer); + this.drawSlot(101, 25, layer); + this.drawSlot(120, 44, layer); + this.drawSlot(101, 63, layer); + + this.builder.drawJEIButton(this, 150, 4, layer); } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final Layer layer = Layer.FOREGROUND; - int j = 0; - - j = 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); - this.drawTexturedModalRect(k + 83, l + 53, 177, 39, 10, j); - this.drawTexturedModalRect(k + 68 + 10 - j, l + 38, 177 + 10 - j, 27, j, 10); - } - - j = 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 + " ", ""); - 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.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 61, 47, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiChargeBench.java b/src/main/java/techreborn/client/gui/GuiChargeBench.java index ead9d2e95..a4b05e9e7 100644 --- a/src/main/java/techreborn/client/gui/GuiChargeBench.java +++ b/src/main/java/techreborn/client/gui/GuiChargeBench.java @@ -1,54 +1,35 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -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.ContainerChargeBench; import techreborn.tiles.TileChargeBench; -public class GuiChargeBench extends GuiContainer { +public class GuiChargeBench extends GuiBase { - private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/chargebench.png"); + TileChargeBench tile; - TileChargeBench chargebench; - - public GuiChargeBench(EntityPlayer player, TileChargeBench tile) { - super(new ContainerChargeBench(tile, player)); - this.xSize = 176; - this.ySize = 167; - chargebench = tile; + public GuiChargeBench(final EntityPlayer player, final TileChargeBench tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - public void initGui() { - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - super.initGui(); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; + + this.drawSlot(62, 25, layer); + this.drawSlot(98, 25, layer); + this.drawSlot(62, 45, layer); + this.drawSlot(98, 45, layer); + this.drawSlot(62, 65, layer); + this.drawSlot(98, 65, layer); } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final Layer layer = Layer.FOREGROUND; - int j = 0; - - j = chargebench.getEnergyScaled(12); - if (j > 0) { - this.drawTexturedModalRect(k + 10, l + 32 + 12 - j, 176, 12 - j, 14, j + 2); - } - } - - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String name = I18n.translateToLocal("tile.techreborn.chargebench.name"); - 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.builder.drawMultiEnergyBar(this, 81, 28, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiChemicalReactor.java b/src/main/java/techreborn/client/gui/GuiChemicalReactor.java index 08c58a1a6..68e363752 100644 --- a/src/main/java/techreborn/client/gui/GuiChemicalReactor.java +++ b/src/main/java/techreborn/client/gui/GuiChemicalReactor.java @@ -1,63 +1,38 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -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.tiles.TileChemicalReactor; -public class GuiChemicalReactor extends GuiContainer { +public class GuiChemicalReactor extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/chemical_reactor.png"); + TileChemicalReactor tile; - TileChemicalReactor chemicalReactor; - ContainerChemicalReactor containerChemicalReactor; - - public GuiChemicalReactor(EntityPlayer player, TileChemicalReactor tilechemicalReactor) { - super(new ContainerChemicalReactor(tilechemicalReactor, player)); - containerChemicalReactor = (ContainerChemicalReactor) this.inventorySlots; - this.xSize = 176; - this.ySize = 167; - chemicalReactor = tilechemicalReactor; + public GuiChemicalReactor(final EntityPlayer player, final TileChemicalReactor tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - public void initGui() { - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - super.initGui(); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; + + this.drawSlot(8, 72, layer); + + this.drawSlot(34, 47, layer); + this.drawSlot(126, 47, layer); + this.drawOutputSlot(80, 47, layer); + + this.builder.drawJEIButton(this, 150, 4, layer); } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; - int j = 0; - - j = chemicalReactor.getProgressScaled(11); - if (j > 0) { - this.drawTexturedModalRect(k + 73, l + 39, 177, 15, 30, j); - } - - j = 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"); - 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.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 105, 51, mouseX, mouseY, TRBuilder.ProgressDirection.LEFT, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiChunkLoader.java b/src/main/java/techreborn/client/gui/GuiChunkLoader.java index b2ff33e1b..82e5717cd 100644 --- a/src/main/java/techreborn/client/gui/GuiChunkLoader.java +++ b/src/main/java/techreborn/client/gui/GuiChunkLoader.java @@ -6,24 +6,24 @@ 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.ContainerChunkloader; + 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; private GuiButton minusOneButton; private GuiButton minusTenButton; - public GuiChunkLoader(EntityPlayer player, TileChunkLoader tilechunkloader) { - super(new ContainerChunkloader(tilechunkloader, player)); + public GuiChunkLoader(final EntityPlayer player, final TileChunkLoader chunkLoader) { + super(chunkLoader.createContainer(player)); this.xSize = 176; this.ySize = 167; - chunkloader = tilechunkloader; + this.chunkloader = chunkLoader; } @Override @@ -31,33 +31,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); } } diff --git a/src/main/java/techreborn/client/gui/GuiCompressor.java b/src/main/java/techreborn/client/gui/GuiCompressor.java index fcd67335a..cafef96d8 100644 --- a/src/main/java/techreborn/client/gui/GuiCompressor.java +++ b/src/main/java/techreborn/client/gui/GuiCompressor.java @@ -1,54 +1,36 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -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.tiles.teir1.TileCompressor; -public class GuiCompressor extends GuiContainer { +public class GuiCompressor extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/compressor.png"); + TileCompressor tile; - TileCompressor compressor; - ContainerCompressor containerGrinder; - - public GuiCompressor(EntityPlayer player, TileCompressor tilegrinder) { - super(new ContainerCompressor(tilegrinder, player)); - this.xSize = 176; - this.ySize = 167; - compressor = tilegrinder; - containerGrinder = (ContainerCompressor) this.inventorySlots; + public GuiCompressor(final EntityPlayer player, final TileCompressor tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; - int j = 0; + //this.drawSlot(8, 72, layer); - j = compressor.getProgressScaled(24); - if (j > 0) { - this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); - } + this.drawSlot(55, 45, layer); + this.drawOutputSlot(101, 45, layer); - j = compressor.getEnergyScaled(12); - if (j > 0) { - this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); - } + this.builder.drawJEIButton(this, 150, 4, layer); } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - 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, - this.ySize - 96 + 2, 4210752); + @Override + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; + + this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiDieselGenerator.java b/src/main/java/techreborn/client/gui/GuiDieselGenerator.java index c498d7e4e..5793702f9 100644 --- a/src/main/java/techreborn/client/gui/GuiDieselGenerator.java +++ b/src/main/java/techreborn/client/gui/GuiDieselGenerator.java @@ -5,47 +5,46 @@ 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.tiles.generator.TileDieselGenerator; public class GuiDieselGenerator extends GuiContainer { private static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/diesel_generator.png"); + "textures/gui/diesel_generator.png"); - TileDieselGenerator tile; + TileDieselGenerator dieselGenerator; - ContainerDieselGenerator containerDieselGenerator; - - public GuiDieselGenerator(EntityPlayer player, TileDieselGenerator tile) { - super(new ContainerDieselGenerator(tile, player)); + public GuiDieselGenerator(final EntityPlayer player, final TileDieselGenerator dieselGenerator) { + super(dieselGenerator.createContainer(player)); this.xSize = 176; this.ySize = 167; - this.tile = tile; - containerDieselGenerator = (ContainerDieselGenerator) this.inventorySlots; + this.dieselGenerator = dieselGenerator; } @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); + 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("Liquid Amount", 10, 20, 16448255); - this.fontRendererObj.drawString(containerDieselGenerator.fluid + "", 10, 30, 16448255); + this.fontRendererObj.drawString(this.dieselGenerator.tank.getFluidAmount() + "", 10, 30, 16448255); this.fontRendererObj.drawString("Power Amount", 10, 40, 16448255); - this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerDieselGenerator.energy) + "", 10, 50, - 16448255); + this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.dieselGenerator.getEnergy()) + "", 10, 50, + 16448255); } } diff --git a/src/main/java/techreborn/client/gui/GuiDigitalChest.java b/src/main/java/techreborn/client/gui/GuiDigitalChest.java index 6b7f95fa4..24c136094 100644 --- a/src/main/java/techreborn/client/gui/GuiDigitalChest.java +++ b/src/main/java/techreborn/client/gui/GuiDigitalChest.java @@ -1,48 +1,41 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.translation.I18n; -import techreborn.client.container.ContainerDigitalChest; + import techreborn.tiles.TileDigitalChest; -public class GuiDigitalChest extends GuiContainer { +public class GuiDigitalChest extends GuiBase { - private static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/thermal_generator.png"); + TileDigitalChest digitalChest; - TileDigitalChest tile; - - public GuiDigitalChest(EntityPlayer player, TileDigitalChest tile) { - super(new ContainerDigitalChest(tile, player)); - this.xSize = 176; - this.ySize = 167; - this.tile = tile; + public GuiDigitalChest(final EntityPlayer player, final TileDigitalChest digitalChest) { + super(player, digitalChest, digitalChest.createContainer(player)); + this.digitalChest = digitalChest; } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; + + this.drawSlot(80, 24, layer); + this.drawSlot(80, 64, layer); } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String name = I18n.translateToLocal("tile.techreborn.digitalChest.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("Amount", 10, 20, 16448255); - if (tile.storedItem != ItemStack.EMPTY && tile.getStackInSlot(1) != null) - this.fontRendererObj.drawString(tile.storedItem.getCount() + tile.getStackInSlot(1).getCount() + "", 10, 30, - 16448255); - if (tile.storedItem == ItemStack.EMPTY && tile.getStackInSlot(1) != null) - this.fontRendererObj.drawString(tile.getStackInSlot(1).getCount() + "", 10, 30, 16448255); + @Override + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final Layer layer = Layer.FOREGROUND; + + if (this.digitalChest.storedItem != ItemStack.EMPTY && this.digitalChest.getStackInSlot(1) != null) { + this.builder.drawBigBlueBar(this, 31, 43, + this.digitalChest.storedItem.getCount() + this.digitalChest.getStackInSlot(1).getCount(), + this.digitalChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); + } + if (this.digitalChest.storedItem == ItemStack.EMPTY && this.digitalChest.getStackInSlot(1) != null) { + this.builder.drawBigBlueBar(this, 31, 43, this.digitalChest.getStackInSlot(1).getCount(), + this.digitalChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); + } } } diff --git a/src/main/java/techreborn/client/gui/GuiElectricFurnace.java b/src/main/java/techreborn/client/gui/GuiElectricFurnace.java index 5c80cbbd6..93523fa67 100644 --- a/src/main/java/techreborn/client/gui/GuiElectricFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiElectricFurnace.java @@ -1,55 +1,36 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -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.tiles.teir1.TileElectricFurnace; -public class GuiElectricFurnace extends GuiContainer { +public class GuiElectricFurnace extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/compressor.png"); + TileElectricFurnace tile; - TileElectricFurnace furnace; - ContainerElectricFurnace containerGrinder; - - public GuiElectricFurnace(EntityPlayer player, TileElectricFurnace tilegrinder) { - super(new ContainerElectricFurnace(tilegrinder, player)); - this.xSize = 176; - this.ySize = 167; - furnace = tilegrinder; - containerGrinder = (ContainerElectricFurnace) this.inventorySlots; + public GuiElectricFurnace(final EntityPlayer player, final TileElectricFurnace tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; - int j = 0; + //this.drawSlot(8, 72, layer); - j = furnace.gaugeProgressScaled(24); - if (j > 0) { - this.drawTexturedModalRect(k + 78, l + 34, 176, 14, j + 1, 16); - } + this.drawSlot(55, 45, layer); + this.drawOutputSlot(101, 45, layer); - j = furnace.getEnergyScaled(12); - if (j > 0) { - this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); - } + this.builder.drawJEIButton(this, 150, 4, layer); } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - 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); - } + @Override + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final Layer layer = Layer.FOREGROUND; + this.builder.drawProgressBar(this, this.tile.gaugeProgressScaled(100), 100, 76, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); + } } diff --git a/src/main/java/techreborn/client/gui/GuiExtractor.java b/src/main/java/techreborn/client/gui/GuiExtractor.java index a85f790de..6ecf64376 100644 --- a/src/main/java/techreborn/client/gui/GuiExtractor.java +++ b/src/main/java/techreborn/client/gui/GuiExtractor.java @@ -1,55 +1,36 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -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.tiles.teir1.TileExtractor; -public class GuiExtractor extends GuiContainer { +public class GuiExtractor extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/compressor.png"); + TileExtractor tile; - TileExtractor extractor; - ContainerExtractor containerExtractor; - - public GuiExtractor(EntityPlayer player, TileExtractor tileExtractor) { - super(RebornContainer.createContainer(ContainerExtractor.class, tileExtractor, player)); - this.xSize = 176; - this.ySize = 167; - this.extractor = tileExtractor; - containerExtractor = (ContainerExtractor) this.inventorySlots; + public GuiExtractor(final EntityPlayer player, final TileExtractor tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; - int j = 0; + //this.drawSlot(8, 72, layer); - j = extractor.getProgressScaled(24); - if (j > 0) { - this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); - } + this.drawSlot(55, 45, layer); + this.drawOutputSlot(101, 45, layer); - j = extractor.getEnergyScaled(12); - if (j > 0) { - this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); - } + this.builder.drawJEIButton(this, 150, 4, layer); } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - 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, - this.ySize - 96 + 2, 4210752); + @Override + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; + + this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiFusionReactor.java b/src/main/java/techreborn/client/gui/GuiFusionReactor.java index 5f98dc4c0..37a8dd2a9 100644 --- a/src/main/java/techreborn/client/gui/GuiFusionReactor.java +++ b/src/main/java/techreborn/client/gui/GuiFusionReactor.java @@ -8,12 +8,13 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.translation.I18n; + +import reborncore.client.multiblock.MultiblockRenderEvent; import reborncore.client.multiblock.MultiblockSet; import reborncore.common.misc.Location; -import reborncore.common.multiblock.CoordTriplet; import reborncore.common.powerSystem.PowerSystem; + import techreborn.client.ClientMultiBlocks; -import techreborn.client.container.ContainerFusionReactor; import techreborn.proxies.ClientProxy; import techreborn.tiles.fusionReactor.TileEntityFusionController; @@ -22,49 +23,46 @@ import java.io.IOException; public class GuiFusionReactor extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/fusion_reactor.png"); + "textures/gui/fusion_reactor.png"); - ContainerFusionReactor containerFusionReactor; TileEntityFusionController fusionController; - public GuiFusionReactor(EntityPlayer player, TileEntityFusionController tileaesu) { - super(new ContainerFusionReactor(tileaesu, player)); - containerFusionReactor = (ContainerFusionReactor) this.inventorySlots; - this.fusionController = tileaesu; + public GuiFusionReactor(final EntityPlayer player, final TileEntityFusionController fusion) { + super(fusion.createContainer(player)); + this.fusionController = fusion; } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String name = I18n.translateToLocal("tile.techreborn.fusioncontrolcomputer.name"); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translateToLocal("tile.techreborn.fusioncontrolcomputer.name"); this.fontRendererObj.drawString(name, 87, 6, 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(PowerSystem.getLocaliszedPower(containerFusionReactor.energy), 11, 8, 16448255); - this.fontRendererObj.drawString("Coils: " + (containerFusionReactor.coilStatus == 1 ? "Yes" : "No"), 11, 16, - 16448255); - if (containerFusionReactor.neededEU > 1 && containerFusionReactor.tickTime < 1) - this.fontRendererObj.drawString( - "Start: " + percentage(containerFusionReactor.neededEU, containerFusionReactor.energy) + "%", 11, - 24, 16448255); + this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.fusionController.getEnergy()), 11, 8, + 16448255); + this.fontRendererObj.drawString("Coils: " + (this.fusionController.getCoilStatus() == 1 ? "Yes" : "No"), 11, 16, + 16448255); + if (this.fusionController.getNeededPower() > 1 && this.fusionController.getCrafingTickTime() < 1) + this.fontRendererObj.drawString("Start: " + + this.percentage(this.fusionController.getNeededPower(), (int) this.fusionController.getEnergy()) + + "%", 11, 24, 16448255); } @Override public void initGui() { - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - GuiButton button = new GuiButton(212, k + this.xSize - 24, l + 4, 20, - 20, ""); - buttonList.add(button); + final int k = (this.width - this.xSize) / 2; + final int l = (this.height - this.ySize) / 2; + final GuiButton button = new GuiButton(212, k + this.xSize - 24, l + 4, 20, 20, ""); + this.buttonList.add(button); super.initGui(); - BlockPos coordinates = new - BlockPos(fusionController.getPos().getX() - - (EnumFacing.getFront(fusionController.getFacingInt()).getFrontOffsetX() - * 2), fusionController.getPos().getY() - 1, - fusionController.getPos().getZ() - - (EnumFacing.getFront(fusionController.getFacingInt()).getFrontOffsetZ() - * 2)); - if (coordinates.equals(ClientProxy.multiblockRenderEvent.anchor)) { + final BlockPos coordinates = new BlockPos( + this.fusionController.getPos().getX() + - EnumFacing.getFront(this.fusionController.getFacingInt()).getFrontOffsetX() * 2, + this.fusionController.getPos().getY() - 1, this.fusionController.getPos().getZ() + - EnumFacing.getFront(this.fusionController.getFacingInt()).getFrontOffsetZ() * 2); + if (coordinates.equals(MultiblockRenderEvent.anchor)) { ClientProxy.multiblockRenderEvent.setMultiblock(null); button.displayString = "B"; } else { @@ -73,42 +71,41 @@ public class GuiFusionReactor extends GuiContainer { } @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(GuiFusionReactor.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); - drawTexturedModalRect(k + 88, l + 36, 176, 0, 14, 14); + this.drawTexturedModalRect(k + 88, l + 36, 176, 0, 14, 14); // progressBar - drawTexturedModalRect(k + 111, l + 34, 176, 14, containerFusionReactor.getProgressScaled(), 16); + this.drawTexturedModalRect(k + 111, l + 34, 176, 14, this.fusionController.getProgressScaled(), 16); } - public int percentage(int MaxValue, int CurrentValue) { + public int percentage(final int MaxValue, final int CurrentValue) { if (CurrentValue == 0) return 0; - return (int) ((CurrentValue * 100.0f) / MaxValue); + return (int) (CurrentValue * 100.0f / MaxValue); } @Override - public void actionPerformed(GuiButton button) throws IOException { + public void actionPerformed(final GuiButton button) throws IOException { super.actionPerformed(button); if (button.id == 212) { if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) { - //This code here makes a basic multiblock and then sets to theselected one. - MultiblockSet set = new MultiblockSet(ClientMultiBlocks.reactor); - ClientProxy.multiblockRenderEvent.setMultiblock(set); - ClientProxy.multiblockRenderEvent.parent = new - Location(fusionController.getPos().getX(), - fusionController.getPos().getY(), fusionController.getPos().getZ(), - fusionController.getWorld()); - ClientProxy.multiblockRenderEvent.anchor = new - BlockPos(fusionController.getPos().getX(), - fusionController.getPos().getY() - 1, - fusionController.getPos().getZ()); + // This code here makes a basic multiblock and then sets to + // theselected one. + final MultiblockSet set = new MultiblockSet(ClientMultiBlocks.reactor); + ClientProxy.multiblockRenderEvent.setMultiblock(set); + ClientProxy.multiblockRenderEvent.parent = new Location(this.fusionController.getPos().getX(), + this.fusionController.getPos().getY(), this.fusionController.getPos().getZ(), + this.fusionController.getWorld()); + MultiblockRenderEvent.anchor = new BlockPos(this.fusionController.getPos().getX(), + this.fusionController.getPos().getY() - 1, this.fusionController.getPos().getZ()); button.displayString = "A"; } else { diff --git a/src/main/java/techreborn/client/gui/GuiGasTurbine.java b/src/main/java/techreborn/client/gui/GuiGasTurbine.java index 5dd4ebf76..dd535451e 100644 --- a/src/main/java/techreborn/client/gui/GuiGasTurbine.java +++ b/src/main/java/techreborn/client/gui/GuiGasTurbine.java @@ -5,40 +5,41 @@ 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.tiles.generator.TileGasTurbine; public class GuiGasTurbine extends GuiContainer { // TODO: use semifluid generator texture private static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/thermal_generator.png"); + "textures/gui/thermal_generator.png"); - TileGasTurbine tile; + TileGasTurbine gasTurbine; - public GuiGasTurbine(EntityPlayer player, TileGasTurbine tile) { - super(new ContainerGasTurbine(tile, player)); + public GuiGasTurbine(final EntityPlayer player, final TileGasTurbine gasTurbine) { + super(gasTurbine.createContainer(player)); this.xSize = 176; this.ySize = 167; - this.tile = tile; + this.gasTurbine = gasTurbine; } @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); + 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("Liquid Amount", 10, 20, 16448255); - this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255); + this.fontRendererObj.drawString(this.gasTurbine.tank.getFluidAmount() + "", 10, 30, 16448255); } } diff --git a/src/main/java/techreborn/client/gui/GuiGenerator.java b/src/main/java/techreborn/client/gui/GuiGenerator.java index d678bc235..127ffd471 100644 --- a/src/main/java/techreborn/client/gui/GuiGenerator.java +++ b/src/main/java/techreborn/client/gui/GuiGenerator.java @@ -1,64 +1,35 @@ package techreborn.client.gui; -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.tiles.generator.TileGenerator; -public class GuiGenerator extends GuiContainer { +public class GuiGenerator extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/generator.png"); + TileGenerator tile; - TileGenerator generator; - - ContainerGenerator containerGenerator; - - public GuiGenerator(EntityPlayer player, TileGenerator generator) { - super(new ContainerGenerator(generator, player)); - this.xSize = 176; - this.ySize = 167; - this.generator = generator; - this.containerGenerator = (ContainerGenerator) this.inventorySlots; + public GuiGenerator(final EntityPlayer player, final TileGenerator tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - public void initGui() { - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - super.initGui(); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; + + this.drawSlot(8, 72, layer); + + this.drawSlot(80, 54, layer); + + this.builder.drawJEIButton(this, 150, 4, layer); } @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; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final Layer layer = Layer.FOREGROUND; - int j = 0; - - j = 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); - 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"); - 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.builder.drawBurnBar(this, this.tile.getScaledBurnTime(100), 100, 81, 38, mouseX, mouseY, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiGrinder.java b/src/main/java/techreborn/client/gui/GuiGrinder.java index 10cc98cf3..3e784f679 100644 --- a/src/main/java/techreborn/client/gui/GuiGrinder.java +++ b/src/main/java/techreborn/client/gui/GuiGrinder.java @@ -1,56 +1,36 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -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.tiles.teir1.TileGrinder; -public class GuiGrinder extends GuiContainer { +public class GuiGrinder extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/grinder.png"); + TileGrinder tile; - TileGrinder grinder; - ContainerGrinder containerGrinder; - - public GuiGrinder(EntityPlayer player, TileGrinder tilegrinder) { - super(RebornContainer.createContainer(ContainerGrinder.class, tilegrinder, player)); - this.xSize = 176; - this.ySize = 167; - this.grinder = tilegrinder; - containerGrinder = (ContainerGrinder) this.inventorySlots; + public GuiGrinder(final EntityPlayer player, final TileGrinder tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; - int j = 0; + //this.drawSlot(8, 72, layer); - j = grinder.getProgressScaled(24); - if (j > 0) { - this.drawTexturedModalRect(k + 80, l + 36, 176, 14, j + 1, 16); - } + this.drawSlot(55, 45, layer); + this.drawOutputSlot(101, 45, layer); - j = grinder.getEnergyScaled(12); - if (j > 0) { - this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); - } + this.builder.drawJEIButton(this, 150, 4, layer); } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - 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); - } + @Override + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; + this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); + } } diff --git a/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java b/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java index 349c90563..51b47ddc9 100644 --- a/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java +++ b/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java @@ -5,59 +5,58 @@ 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.ContainerImplosionCompressor; + import techreborn.tiles.multiblock.TileImplosionCompressor; public class GuiImplosionCompressor extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/implosion_compressor.png"); + "textures/gui/implosion_compressor.png"); - TileImplosionCompressor compresser; - ContainerImplosionCompressor containerImplosionCompressor; + TileImplosionCompressor compressor; - public GuiImplosionCompressor(EntityPlayer player, TileImplosionCompressor tilecompresser) { - super(new ContainerImplosionCompressor(tilecompresser, player)); - containerImplosionCompressor = (ContainerImplosionCompressor) this.inventorySlots; + public GuiImplosionCompressor(final EntityPlayer player, final TileImplosionCompressor compressor) { + super(compressor.createContainer(player)); this.xSize = 176; this.ySize = 167; - compresser = tilecompresser; + this.compressor = compressor; } @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(GuiImplosionCompressor.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); - if (containerImplosionCompressor.multIBlockState == 0) { + if (!this.compressor.getMutliBlock()) { // GuiDraw.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10); this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1); } - this.mc.getTextureManager().bindTexture(texture); - int j = compresser.getProgressScaled(24); + this.mc.getTextureManager().bindTexture(GuiImplosionCompressor.texture); + int j = this.compressor.getProgressScaled(24); if (j > 0) { this.drawTexturedModalRect(k + 61, l + 37, 176, 14, j + 1, 16); } - j = compresser.getEnergyScaled(12); + j = this.compressor.getEnergyScaled(12); if (j > 0) { this.drawTexturedModalRect(k + 14, 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.implosioncompressor.name"); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translateToLocal("tile.techreborn.implosioncompressor.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); } diff --git a/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java b/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java index deb0be0a5..964e519dd 100644 --- a/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java @@ -5,59 +5,58 @@ 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.ContainerIndustrialElectrolyzer; + import techreborn.tiles.TileIndustrialElectrolyzer; public class GuiIndustrialElectrolyzer extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/industrial_electrolyzer.png"); + "textures/gui/industrial_electrolyzer.png"); TileIndustrialElectrolyzer eletrolyzer; - ContainerIndustrialElectrolyzer containerIndustrialElectrolyzer; - public GuiIndustrialElectrolyzer(EntityPlayer player, TileIndustrialElectrolyzer tileeletrolyzer) { - super(new ContainerIndustrialElectrolyzer(tileeletrolyzer, player)); + public GuiIndustrialElectrolyzer(final EntityPlayer player, final TileIndustrialElectrolyzer tileeletrolyzer) { + super(tileeletrolyzer.createContainer(player)); this.xSize = 176; this.ySize = 167; - eletrolyzer = tileeletrolyzer; - containerIndustrialElectrolyzer = (ContainerIndustrialElectrolyzer) this.inventorySlots; + this.eletrolyzer = tileeletrolyzer; } @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(GuiIndustrialElectrolyzer.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 = eletrolyzer.getProgressScaled(24); + j = this.eletrolyzer.getProgressScaled(24); if (j > 0) { this.drawTexturedModalRect(k + 72, l + 38, 176, 14, j + 1, 16); } - j = eletrolyzer.getEnergyScaled(12); + j = this.eletrolyzer.getEnergyScaled(12); if (j > 0) { this.drawTexturedModalRect(k + 134, 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.industrialelectrolyzer.name"); - this.fontRendererObj.drawString(name, (this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2), 6, - 4210752); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translateToLocal("tile.techreborn.industrialelectrolyzer.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.ySize - 96 + 2, 4210752); } } diff --git a/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java b/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java index e76c09b4b..28a6f96a4 100644 --- a/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java +++ b/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java @@ -8,76 +8,74 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; import net.minecraftforge.fluids.FluidStack; -import techreborn.client.container.ContainerIndustrialGrinder; + import techreborn.tiles.multiblock.TileIndustrialGrinder; public class GuiIndustrialGrinder extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/industrial_grinder.png"); + "textures/gui/industrial_grinder.png"); TileIndustrialGrinder grinder; - ContainerIndustrialGrinder containerGrinder; - public GuiIndustrialGrinder(EntityPlayer player, TileIndustrialGrinder tilegrinder) { - super(new ContainerIndustrialGrinder(tilegrinder, player)); + public GuiIndustrialGrinder(final EntityPlayer player, final TileIndustrialGrinder grinder) { + super(grinder.createContainer(player)); this.xSize = 176; this.ySize = 167; - grinder = tilegrinder; - containerGrinder = (ContainerIndustrialGrinder) this.inventorySlots; + this.grinder = grinder; } @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(GuiIndustrialGrinder.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 progress = grinder.getProgressScaled(24); + final int progress = this.grinder.getProgressScaled(24); if (progress > 0) { this.drawTexturedModalRect(k + 50, l + 35, 176, 14, progress + 1, 16); } - int energy = (int) (grinder.getEnergy() * 12f / grinder.getMaxPower()); + final int energy = (int) (this.grinder.getEnergy() * 12f / this.grinder.getMaxPower()); if (energy > 0) { this.drawTexturedModalRect(k + 132, l + 63 + 12 - energy, 176, 12 - energy, 14, energy + 2); } - if (!grinder.tank.isEmpty()) { - drawFluid(grinder.tank.getFluid(), k + 11, l + 66, 12, 47, grinder.tank.getCapacity()); + if (!this.grinder.tank.isEmpty()) { + this.drawFluid(this.grinder.tank.getFluid(), k + 11, l + 66, 12, 47, this.grinder.tank.getCapacity()); - mc.renderEngine.bindTexture(texture); - drawTexturedModalRect(k + 14, l + 24, 179, 88, 9, 37); + this.mc.renderEngine.bindTexture(GuiIndustrialGrinder.texture); + this.drawTexturedModalRect(k + 14, l + 24, 179, 88, 9, 37); } - if (!grinder.getMutliBlock()) { + if (!this.grinder.getMutliBlock()) { this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1); } } - public void drawFluid(FluidStack fluid, int x, int y, int width, int height, int maxCapacity) { - mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - ResourceLocation still = fluid.getFluid().getStill(fluid); - TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(still.toString()); + public void drawFluid(final FluidStack fluid, final int x, final int y, final int width, final int height, final int maxCapacity) { + this.mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + final ResourceLocation still = fluid.getFluid().getStill(fluid); + final TextureAtlasSprite sprite = this.mc.getTextureMapBlocks().getAtlasSprite(still.toString()); - int drawHeight = (int) ((fluid.amount / (maxCapacity * 1F)) * height); - int iconHeight = sprite.getIconHeight(); + final int drawHeight = (int) (fluid.amount / (maxCapacity * 1F) * height); + final int iconHeight = sprite.getIconHeight(); int offsetHeight = drawHeight; int iteration = 0; while (offsetHeight != 0) { - int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight; - drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight); + final int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight; + this.drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight); offsetHeight -= curHeight; iteration++; if (iteration > 50) @@ -86,12 +84,13 @@ public class GuiIndustrialGrinder extends GuiContainer { } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String name = I18n.translateToLocal("tile.techreborn.industrialgrinder.name"); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translateToLocal("tile.techreborn.industrialgrinder.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); } } diff --git a/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java b/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java index e133631b4..58c6d5572 100644 --- a/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java +++ b/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java @@ -8,74 +8,74 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; import net.minecraftforge.fluids.FluidStack; -import techreborn.client.container.ContainerIndustrialSawmill; + import techreborn.tiles.multiblock.TileIndustrialSawmill; public class GuiIndustrialSawmill extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/industrial_sawmill.png"); + "textures/gui/industrial_sawmill.png"); TileIndustrialSawmill sawmill; - public GuiIndustrialSawmill(EntityPlayer player, TileIndustrialSawmill tilesawmill) { - super(new ContainerIndustrialSawmill(tilesawmill, player)); + public GuiIndustrialSawmill(final EntityPlayer player, final TileIndustrialSawmill sawmill) { + super(sawmill.createContainer(player)); this.xSize = 176; this.ySize = 167; - this.sawmill = tilesawmill; + this.sawmill = sawmill; } @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(GuiIndustrialSawmill.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 progress = sawmill.getProgressScaled(24); + final int progress = this.sawmill.getProgressScaled(24); this.drawTexturedModalRect(k + 56, l + 38, 176, 14, progress - 1, 11); - int energy = 13 - (int) (sawmill.getEnergy() / sawmill.getMaxPower() * 13F); - drawTexturedModalRect(k + 36, l + 66 + energy, 179, 1 + energy, 7, 13 - energy); + final int energy = 13 - (int) (this.sawmill.getEnergy() / this.sawmill.getMaxPower() * 13F); + this.drawTexturedModalRect(k + 36, l + 66 + energy, 179, 1 + energy, 7, 13 - energy); - if (!sawmill.tank.isEmpty()) { - drawFluid(sawmill.tank.getFluid(), k + 11, l + 66, 12, 47, sawmill.tank.getCapacity()); + if (!this.sawmill.tank.isEmpty()) { + this.drawFluid(this.sawmill.tank.getFluid(), k + 11, l + 66, 12, 47, this.sawmill.tank.getCapacity()); - int j = sawmill.getEnergyScaled(12); + final int j = this.sawmill.getEnergyScaled(12); if (j > 0) { this.drawTexturedModalRect(k + 33, l + 65 + 12 - j, 176, 12 - j, 14, j + 2); } - if (!sawmill.getMutliBlock()) { + if (!this.sawmill.getMutliBlock()) { //GuiUtil.drawTooltipBox(k + 30, l + 50 + 12, 114, 10); this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, - l + 52 + 12, -1); + l + 52 + 12, -1); } } } - public void drawFluid(FluidStack fluid, int x, int y, int width, int height, int maxCapacity) { - mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - ResourceLocation still = fluid.getFluid().getStill(fluid); - TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(still.toString()); + public void drawFluid(final FluidStack fluid, final int x, final int y, final int width, final int height, final int maxCapacity) { + this.mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + final ResourceLocation still = fluid.getFluid().getStill(fluid); + final TextureAtlasSprite sprite = this.mc.getTextureMapBlocks().getAtlasSprite(still.toString()); - int drawHeight = (int) ((fluid.amount / (maxCapacity * 1F)) * height); - int iconHeight = sprite.getIconHeight(); + final int drawHeight = (int) (fluid.amount / (maxCapacity * 1F) * height); + final int iconHeight = sprite.getIconHeight(); int offsetHeight = drawHeight; int iteration = 0; while (offsetHeight != 0) { - int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight; - drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight); + final int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight; + this.drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight); offsetHeight -= curHeight; iteration++; if (iteration > 50) @@ -84,8 +84,9 @@ public class GuiIndustrialSawmill extends GuiContainer { } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String name = I18n.translateToLocal("tile.techreborn.industrialsawmill.name"); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translateToLocal("tile.techreborn.industrialsawmill.name"); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 58, this.ySize - 96 + 2, 4210752); } diff --git a/src/main/java/techreborn/client/gui/GuiIronFurnace.java b/src/main/java/techreborn/client/gui/GuiIronFurnace.java index f8b653b88..69504ca7c 100644 --- a/src/main/java/techreborn/client/gui/GuiIronFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiIronFurnace.java @@ -5,52 +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.ContainerIronFurnace; + import techreborn.tiles.TileIronFurnace; public class GuiIronFurnace extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("minecraft", - "textures/gui/container/furnace.png"); + "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(furnace.createContainer(player)); 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); + 4210752); this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); + this.ySize - 96 + 2, 4210752); } } diff --git a/src/main/java/techreborn/client/gui/GuiMFE.java b/src/main/java/techreborn/client/gui/GuiMFE.java index ca4275051..9634b8129 100644 --- a/src/main/java/techreborn/client/gui/GuiMFE.java +++ b/src/main/java/techreborn/client/gui/GuiMFE.java @@ -1,71 +1,39 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; +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.ContainerMFE; import techreborn.tiles.storage.TileMFE; -/** - * Created by Rushmead - */ -public class GuiMFE extends GuiContainer { +public class GuiMFE extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/mfe.png"); + TileMFE mfe; - TileMFE generator; - - ContainerMFE containerGenerator; - - public GuiMFE(EntityPlayer player, TileMFE generator) { - super(new ContainerMFE(generator, player)); - this.xSize = 176; - this.ySize = 167; - this.generator = generator; - this.containerGenerator = (ContainerMFE) this.inventorySlots; + public GuiMFE(final EntityPlayer player, final TileMFE mfe) { + super(player, mfe, mfe.createContainer(player)); + this.mfe = mfe; } @Override - public void initGui() { - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - super.initGui(); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; + + this.drawSlot(62, 45, layer); + this.drawSlot(98, 45, layer); + this.drawArmourSlots(8, 18, layer); } @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; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final Layer layer = Layer.FOREGROUND; - int j = 0; + GlStateManager.pushMatrix(); + GlStateManager.scale(0.6, 0.6, 1); + this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.mfe.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.mfe.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer); + GlStateManager.popMatrix(); - j = 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); - // 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.mfe.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]), this.xSize - 60, - this.ySize - 96 + 2, 4210752); - this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(generator.getMaxPower()), 110, this.ySize - 150, - 4210752); - this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 110, this.ySize - 160, - 4210752); + this.builder.drawMultiEnergyBar(this, 81, 28, (int) this.mfe.getEnergy(), (int) this.mfe.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiMFSU.java b/src/main/java/techreborn/client/gui/GuiMFSU.java index bdde73fc9..0d8489789 100644 --- a/src/main/java/techreborn/client/gui/GuiMFSU.java +++ b/src/main/java/techreborn/client/gui/GuiMFSU.java @@ -1,71 +1,39 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; +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.ContainerMFSU; import techreborn.tiles.storage.TileMFSU; -/** - * Created by Rushmead - */ -public class GuiMFSU extends GuiContainer { +public class GuiMFSU extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/mfsu.png"); + TileMFSU mfsu; - TileMFSU generator; - - ContainerMFSU containerGenerator; - - public GuiMFSU(EntityPlayer player, TileMFSU generator) { - super(new ContainerMFSU(generator, player)); - this.xSize = 176; - this.ySize = 167; - this.generator = generator; - this.containerGenerator = (ContainerMFSU) this.inventorySlots; + public GuiMFSU(final EntityPlayer player, final TileMFSU mfsu) { + super(player, mfsu, mfsu.createContainer(player)); + this.mfsu = mfsu; } @Override - public void initGui() { - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - super.initGui(); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; + + this.drawSlot(62, 45, layer); + this.drawSlot(98, 45, layer); + this.drawArmourSlots(8, 18, layer); } @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; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final Layer layer = Layer.FOREGROUND; - int j = 0; + GlStateManager.pushMatrix(); + GlStateManager.scale(0.6, 0.6, 1); + this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.mfsu.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.mfsu.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer); + GlStateManager.popMatrix(); - j = 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); - // 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.mfsu.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]), this.xSize - 60, - this.ySize - 96 + 2, 4210752); - this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(generator.getMaxPower()), 110, this.ySize - 150, - 4210752); - this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 110, this.ySize - 160, - 4210752); + this.builder.drawMultiEnergyBar(this, 81, 28, (int) this.mfsu.getEnergy(), (int) this.mfsu.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiMatterFabricator.java b/src/main/java/techreborn/client/gui/GuiMatterFabricator.java index 2c089e4f1..2e822c34e 100644 --- a/src/main/java/techreborn/client/gui/GuiMatterFabricator.java +++ b/src/main/java/techreborn/client/gui/GuiMatterFabricator.java @@ -5,49 +5,47 @@ 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.ContainerMatterFabricator; + import techreborn.tiles.TileMatterFabricator; public class GuiMatterFabricator extends GuiContainer { private static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/matterfabricator.png"); + "textures/gui/matterfabricator.png"); TileMatterFabricator matterfab; - ContainerMatterFabricator containerMatterFabricator; - - public GuiMatterFabricator(EntityPlayer player, TileMatterFabricator tilematterfab) { - super(new ContainerMatterFabricator(tilematterfab, player)); + public GuiMatterFabricator(final EntityPlayer player, final TileMatterFabricator tilematterfab) { + super(tilematterfab.createContainer(player)); this.xSize = 176; this.ySize = 167; - matterfab = tilematterfab; - containerMatterFabricator = (ContainerMatterFabricator) this.inventorySlots; + this.matterfab = tilematterfab; } @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(GuiMatterFabricator.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 = containerMatterFabricator.getProgressScaled(24); + final int j = this.matterfab.getProgressScaled(24); if (j > 0) { this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16); } } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - String name = I18n.translateToLocal("tile.techreborn.matterfabricator.name"); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final int k = (this.width - this.xSize) / 2; + final int l = (this.height - this.ySize) / 2; + final String name = I18n.translateToLocal("tile.techreborn.matterfabricator.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.fontRendererObj.drawString(containerMatterFabricator.getProgressScaled(100) + "%", 80, 50, 4210752); + this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString(this.matterfab.getProgressScaled(100) + "%", 80, 50, 4210752); } } diff --git a/src/main/java/techreborn/client/gui/GuiQuantumChest.java b/src/main/java/techreborn/client/gui/GuiQuantumChest.java index f8d31d0e0..a10e2c3a3 100644 --- a/src/main/java/techreborn/client/gui/GuiQuantumChest.java +++ b/src/main/java/techreborn/client/gui/GuiQuantumChest.java @@ -1,54 +1,38 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.GlStateManager; 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.ContainerQuantumChest; + import techreborn.tiles.TileQuantumChest; -public class GuiQuantumChest extends GuiContainer { +public class GuiQuantumChest extends GuiBase { - private static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/thermal_generator.png"); + TileQuantumChest quantumChest; - TileQuantumChest tile; - - public GuiQuantumChest(EntityPlayer player, TileQuantumChest tile) { - super(new ContainerQuantumChest(tile, player)); - this.xSize = 176; - this.ySize = 167; - this.tile = tile; + public GuiQuantumChest(final EntityPlayer player, final TileQuantumChest quantumChest) { + super(player, quantumChest, quantumChest.createContainer(player)); + this.quantumChest = quantumChest; } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; + + this.drawSlot(80, 24, layer); + this.drawSlot(80, 64, layer); } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String name = I18n.translateToLocal("tile.techreborn.quantumChest.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("Amount", 10, 20, 16448255); + @Override + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final Layer layer = Layer.FOREGROUND; - int count = 0; - if (tile.storedItem != ItemStack.EMPTY || !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(); + if (this.quantumChest.storedItem != ItemStack.EMPTY && this.quantumChest.getStackInSlot(1) != null) { + this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.storedItem.getCount() + this.quantumChest.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); + } + if (this.quantumChest.storedItem == ItemStack.EMPTY && this.quantumChest.getStackInSlot(1) != null) { + this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); } - this.fontRendererObj.drawString(count + "", 10, 30, 16448255); } } diff --git a/src/main/java/techreborn/client/gui/GuiQuantumTank.java b/src/main/java/techreborn/client/gui/GuiQuantumTank.java index 09b196dbe..813d69c1b 100644 --- a/src/main/java/techreborn/client/gui/GuiQuantumTank.java +++ b/src/main/java/techreborn/client/gui/GuiQuantumTank.java @@ -5,39 +5,40 @@ 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.ContainerQuantumTank; + import techreborn.tiles.TileQuantumTank; public class GuiQuantumTank extends GuiContainer { private static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/thermal_generator.png"); + "textures/gui/thermal_generator.png"); - TileQuantumTank tile; + TileQuantumTank quantumTank; - public GuiQuantumTank(EntityPlayer player, TileQuantumTank tile) { - super(new ContainerQuantumTank(tile, player)); + public GuiQuantumTank(final EntityPlayer player, final TileQuantumTank quantumTank) { + super(quantumTank.createContainer(player)); this.xSize = 176; this.ySize = 167; - this.tile = tile; + this.quantumTank = quantumTank; } @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(GuiQuantumTank.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.quantumTank.name"); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translateToLocal("tile.techreborn.quantumTank.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("Liquid Amount", 10, 20, 16448255); - this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255); + this.fontRendererObj.drawString(this.quantumTank.tank.getFluidAmount() + "", 10, 30, 16448255); } } diff --git a/src/main/java/techreborn/client/gui/GuiRecycler.java b/src/main/java/techreborn/client/gui/GuiRecycler.java index 5da0e7548..2678b9616 100644 --- a/src/main/java/techreborn/client/gui/GuiRecycler.java +++ b/src/main/java/techreborn/client/gui/GuiRecycler.java @@ -1,54 +1,34 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -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.tiles.teir1.TileRecycler; -public class GuiRecycler extends GuiContainer { +public class GuiRecycler extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/compressor.png"); + TileRecycler tile; - TileRecycler compressor; - ContainerRecycler containerGrinder; - - public GuiRecycler(EntityPlayer player, TileRecycler tilegrinder) { - super(new ContainerRecycler(tilegrinder, player)); - this.xSize = 176; - this.ySize = 167; - compressor = tilegrinder; - containerGrinder = (ContainerRecycler) this.inventorySlots; + public GuiRecycler(final EntityPlayer player, final TileRecycler tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; - int j = 0; + //this.drawSlot(8, 72, layer); - j = compressor.gaugeProgressScaled(24); - if (j > 0) { - this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); - } - - j = compressor.getEnergyScaled(12); - if (j > 0) { - this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); - } + this.drawSlot(55, 45, layer); + this.drawOutputSlot(101, 45, layer); } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - 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, - this.ySize - 96 + 2, 4210752); + @Override + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; + + this.builder.drawProgressBar(this, this.tile.gaugeProgressScaled(100), 100, 76, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/GuiRollingMachine.java b/src/main/java/techreborn/client/gui/GuiRollingMachine.java index 318448c0a..2b091c159 100644 --- a/src/main/java/techreborn/client/gui/GuiRollingMachine.java +++ b/src/main/java/techreborn/client/gui/GuiRollingMachine.java @@ -6,33 +6,31 @@ 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.ContainerRollingMachine; + import techreborn.tiles.TileRollingMachine; public class GuiRollingMachine extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/rolling_machine.png"); + "textures/gui/rolling_machine.png"); TileRollingMachine rollingMachine; - ContainerRollingMachine containerRollingMachine; - public GuiRollingMachine(EntityPlayer player, TileRollingMachine tileRollingmachine) { - super(new ContainerRollingMachine(tileRollingmachine, player)); + public GuiRollingMachine(final EntityPlayer player, final TileRollingMachine tileRollingmachine) { + super(tileRollingmachine.createContainer(player)); this.xSize = 176; this.ySize = 167; - rollingMachine = tileRollingmachine; - containerRollingMachine = (ContainerRollingMachine) this.inventorySlots; + this.rollingMachine = tileRollingmachine; } @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(GuiRollingMachine.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 = this.containerRollingMachine.getBurnTimeRemainingScaled(24); + int j = this.rollingMachine.getBurnTimeRemainingScaled(24); this.drawTexturedModalRect(k + 91, l + 34, 176, 14, j + 1, 19); j = this.rollingMachine.getEnergyScaled(12); @@ -41,19 +39,20 @@ public class GuiRollingMachine extends GuiContainer { } } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String name = I18n.translateToLocal("tile.techreborn.rollingmachine.name"); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translateToLocal("tile.techreborn.rollingmachine.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); } @Override public void initGui() { this.buttonList.clear(); - 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; this.buttonList.add(new GuiButton(0, k + 4, l + 4, 20, 20, "R")); super.initGui(); } diff --git a/src/main/java/techreborn/client/gui/GuiScrapboxinator.java b/src/main/java/techreborn/client/gui/GuiScrapboxinator.java index f6bf3633c..5e701edbc 100644 --- a/src/main/java/techreborn/client/gui/GuiScrapboxinator.java +++ b/src/main/java/techreborn/client/gui/GuiScrapboxinator.java @@ -5,52 +5,51 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -import techreborn.client.container.ContainerScrapboxinator; + import techreborn.tiles.TileScrapboxinator; public class GuiScrapboxinator extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/scrapboxinator.png"); + "textures/gui/scrapboxinator.png"); - TileScrapboxinator tile; - ContainerScrapboxinator containerScrapboxinator; + TileScrapboxinator scrapboxinator; - public GuiScrapboxinator(EntityPlayer player, TileScrapboxinator tileScrapboxinator) { - super(new ContainerScrapboxinator(tileScrapboxinator, player)); + public GuiScrapboxinator(final EntityPlayer player, final TileScrapboxinator scrapboxinator) { + super(scrapboxinator.createContainer(player)); this.xSize = 176; this.ySize = 167; - tile = tileScrapboxinator; - containerScrapboxinator = (ContainerScrapboxinator) this.inventorySlots; + this.scrapboxinator = scrapboxinator; } @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(GuiScrapboxinator.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 = tile.gaugeProgressScaled(24); + j = this.scrapboxinator.gaugeProgressScaled(24); // System.out.println(compressor.gaugeProgressScaled(10)); if (j > 0) { this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); } - j = tile.getEnergyScaled(12); + j = this.scrapboxinator.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 = net.minecraft.util.text.translation.I18n.translateToLocal("tile.techreborn.scrapboxinator.name"); + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String name = net.minecraft.util.text.translation.I18n.translateToLocal("tile.techreborn.scrapboxinator.name"); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, - 4210752); + 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, - 4210752); + 4210752); } } diff --git a/src/main/java/techreborn/client/gui/GuiSemifluidGenerator.java b/src/main/java/techreborn/client/gui/GuiSemifluidGenerator.java index aa8453436..45aec1763 100644 --- a/src/main/java/techreborn/client/gui/GuiSemifluidGenerator.java +++ b/src/main/java/techreborn/client/gui/GuiSemifluidGenerator.java @@ -5,42 +5,44 @@ 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.tiles.generator.TileSemifluidGenerator; public class GuiSemifluidGenerator extends GuiContainer { // TODO: use semifluid generator texture private static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/semifluid_generator.png"); + "textures/gui/semifluid_generator.png"); - TileSemifluidGenerator tile; + TileSemifluidGenerator semifluidGenerator; - public GuiSemifluidGenerator(EntityPlayer player, TileSemifluidGenerator tile) { - super(new ContainerSemifluidGenerator(tile, player)); + public GuiSemifluidGenerator(final EntityPlayer player, final TileSemifluidGenerator semifluidGenerator) { + super(semifluidGenerator.createContainer(player)); this.xSize = 176; this.ySize = 167; - this.tile = tile; + this.semifluidGenerator = semifluidGenerator; } @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.semifluidGenerator.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); + 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("Liquid Amount", 10, 20, 16448255); - this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255); + this.fontRendererObj.drawString(this.semifluidGenerator.tank.getFluidAmount() + "", 10, 30, 16448255); } } \ No newline at end of file diff --git a/src/main/java/techreborn/client/gui/GuiThermalGenerator.java b/src/main/java/techreborn/client/gui/GuiThermalGenerator.java index fc05f273f..c5f2b7cfc 100644 --- a/src/main/java/techreborn/client/gui/GuiThermalGenerator.java +++ b/src/main/java/techreborn/client/gui/GuiThermalGenerator.java @@ -5,43 +5,45 @@ 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.tiles.generator.TileThermalGenerator; public class GuiThermalGenerator extends GuiContainer { private static final ResourceLocation texture = new ResourceLocation("techreborn", - "textures/gui/thermal_generator.png"); + "textures/gui/thermal_generator.png"); - TileThermalGenerator tile; + TileThermalGenerator thermalGenerator; - public GuiThermalGenerator(EntityPlayer player, TileThermalGenerator tile) { - super(new ContainerThermalGenerator(tile, player)); + public GuiThermalGenerator(final EntityPlayer player, final TileThermalGenerator thermalGenerator) { + super(thermalGenerator.createContainer(player)); this.xSize = 176; this.ySize = 167; - this.tile = tile; + this.thermalGenerator = thermalGenerator; } @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.thermalGenerator.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); + 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("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.thermalGenerator.tank.getFluidAmount() + "", 10, 30, 16448255); + this.fontRendererObj.drawString(this.thermalGenerator.getEnergy() + "", 10, 40, 16448255); } } diff --git a/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java b/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java index 669fb2a30..665db5c29 100644 --- a/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java +++ b/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java @@ -1,58 +1,37 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; -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.ContainerVacuumFreezer; import techreborn.tiles.multiblock.TileVacuumFreezer; -public class GuiVacuumFreezer extends GuiContainer { +public class GuiVacuumFreezer extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/vacuum_freezer.png"); + TileVacuumFreezer tile; - TileVacuumFreezer crafter; - - public GuiVacuumFreezer(EntityPlayer player, TileVacuumFreezer freezer) { - super(new ContainerVacuumFreezer(freezer, player)); - this.xSize = 176; - this.ySize = 167; - crafter = freezer; + public GuiVacuumFreezer(final EntityPlayer player, final TileVacuumFreezer tile) { + super(player, tile, tile.createContainer(player)); + this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { - 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.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; - int j = crafter.getProgressScaled(24); - if (j > 0) { - this.drawTexturedModalRect(k + 80, l + 37, 176, 14, j + 1, 16); - } + //this.drawSlot(8, 72, layer); - j = (int) (crafter.getEnergy() * 12f / crafter.getMaxPower()); - if (j > 0) { - this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); - } + this.drawSlot(55, 45, layer); + this.drawOutputSlot(101, 45, layer); - if (!crafter.getMultiBlock()) { - this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1); - } - - j = crafter.getEnergyScaled(12); - if (j > 0) { - this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); - } + this.builder.drawJEIButton(this, 150, 4, layer); } - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - String name = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name"); - this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); - this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + @Override + protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; + + this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer); + this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer); } } diff --git a/src/main/java/techreborn/client/gui/TRBuilder.java b/src/main/java/techreborn/client/gui/TRBuilder.java new file mode 100644 index 000000000..24a728545 --- /dev/null +++ b/src/main/java/techreborn/client/gui/TRBuilder.java @@ -0,0 +1,274 @@ +package techreborn.client.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.translation.I18n; +import net.minecraftforge.fml.client.config.GuiUtils; +import net.minecraftforge.fml.common.Loader; +import reborncore.client.guibuilder.GuiBuilder; +import reborncore.common.powerSystem.PowerSystem; +import techreborn.lib.ModInfo; +import techreborn.proxies.ClientProxy; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Prospector + */ +public class TRBuilder extends GuiBuilder { + public static final ResourceLocation GUI_SHEET = new ResourceLocation(ModInfo.MOD_ID.toLowerCase() + ":" + "textures/gui/gui_sheet.png"); + + public TRBuilder() { + super(GUI_SHEET); + } + + public void drawMultiEnergyBar(GuiBase gui, int x, int y, int energyStored, int maxEnergyStored, int mouseX, int mouseY, int buttonID, GuiBase.Layer layer) { + if (layer == GuiBase.Layer.BACKGROUND) { + x += gui.getGuiLeft(); + y += gui.getGuiTop(); + } + if (layer == GuiBase.Layer.FOREGROUND) { + mouseX -= gui.getGuiLeft(); + mouseY -= gui.getGuiTop(); + } + Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET); + + gui.drawTexturedModalRect(x, y, PowerSystem.getDisplayPower().xBar - 15, PowerSystem.getDisplayPower().yBar - 1, 14, 50); + + int draw = (int) ((double) energyStored / (double) maxEnergyStored * (48)); + if (energyStored > maxEnergyStored) { + draw = (int) ((double) maxEnergyStored / (double) maxEnergyStored * (48)); + } + gui.drawTexturedModalRect(x + 1, y + 49 - draw, PowerSystem.getDisplayPower().xBar, 48 + PowerSystem.getDisplayPower().yBar - draw, 12, draw); + int percentage = percentage(maxEnergyStored, energyStored); + if (isInRect(x + 1, y + 1, 11, 48, mouseX, mouseY)) { + GlStateManager.disableLighting(); + GlStateManager.disableDepth(); + GlStateManager.colorMask(true, true, true, false); + GuiUtils.drawGradientRect(0, x + 1, y + 1, x + 13, y + 49, 0x80FFFFFF, 0x80FFFFFF); + GlStateManager.colorMask(true, true, true, true); + GlStateManager.enableDepth(); + + List list = new ArrayList<>(); + TextFormatting powerColour = TextFormatting.GOLD; + list.add(powerColour + PowerSystem.getLocaliszedPowerFormattedNoSuffix(energyStored) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix(maxEnergyStored) + " " + PowerSystem.getDisplayPower().abbreviation); + list.add(getPercentageColour(percentage) + "" + percentage + "%" + TextFormatting.GRAY + " Charged"); + net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRendererObj); + GlStateManager.disableLighting(); + GlStateManager.color(1, 1, 1, 1); + } + gui.addPowerButton(x, y, buttonID, layer); + } + + public void drawProgressBar(GuiBase gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, ProgressDirection direction, GuiBase.Layer layer) { + if (layer == GuiBase.Layer.BACKGROUND) { + x += gui.getGuiLeft(); + y += gui.getGuiTop(); + } + if (layer == GuiBase.Layer.FOREGROUND) { + mouseX -= gui.getGuiLeft(); + mouseY -= gui.getGuiTop(); + } + + gui.mc.getTextureManager().bindTexture(GUI_SHEET); + gui.drawTexturedModalRect(x, y, direction.x, direction.y, direction.width, direction.height); + + if (direction.equals(ProgressDirection.RIGHT)) { + int j = (int) ((double) progress / (double) maxProgress * 16); + if (j < 0) + j = 0; + gui.drawTexturedModalRect(x, y, direction.xActive, direction.yActive, j, 10); + } + + if (direction.equals(ProgressDirection.LEFT)) { + int j = (int) ((double) progress / (double) maxProgress * 16); + if (j < 0) + j = 0; + gui.drawTexturedModalRect(x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10); + } + + if (isInRect(x, y, direction.width, direction.height, mouseX, mouseY)) { + int percentage = percentage(maxProgress, progress); + List list = new ArrayList<>(); + list.add(getPercentageColour(percentage) + "" + percentage + "%"); + net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRendererObj); + GlStateManager.disableLighting(); + GlStateManager.color(1, 1, 1, 1); + } + } + + public void drawJEIButton(GuiBase gui, int x, int y, GuiBase.Layer layer) { + if (Loader.isModLoaded("jei")) { + if (layer == GuiBase.Layer.BACKGROUND) { + x += gui.getGuiLeft(); + y += gui.getGuiTop(); + } + gui.mc.getTextureManager().bindTexture(GUI_SHEET); + gui.drawTexturedModalRect(x, y, 184, 70, 20, 12); + } + } + + public void drawHologramButton(GuiBase gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) { + if (layer == GuiBase.Layer.BACKGROUND) { + x += gui.getGuiLeft(); + y += gui.getGuiTop(); + } + if (layer == GuiBase.Layer.FOREGROUND) { + mouseX -= gui.getGuiLeft(); + mouseY -= gui.getGuiTop(); + } + gui.mc.getTextureManager().bindTexture(GUI_SHEET); + if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) { + gui.drawTexturedModalRect(x, y, 184, 94, 20, 12); + } else { + gui.drawTexturedModalRect(x, y, 184, 106, 20, 12); + } + if (isInRect(x, y, 20, 12, mouseX, mouseY)) { + List list = new ArrayList<>(); + list.add("Toggle Multiblock Hologram"); + GlStateManager.pushMatrix(); + net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRendererObj); + GlStateManager.popMatrix(); + } + } + + public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, GuiBase.Layer layer) { + if (layer == GuiBase.Layer.BACKGROUND) { + x += gui.getGuiLeft(); + y += gui.getGuiTop(); + } + gui.mc.getTextureManager().bindTexture(GUI_SHEET); + if (!suffix.equals("")) { + suffix = " " + suffix; + } + gui.drawTexturedModalRect(x, y, 0, 218, 114, 18); + int j = (int) ((double) value / (double) max * 106); + if (j < 0) + j = 0; + gui.drawTexturedModalRect(x + 4, y + 4, 0, 236, j, 10); + gui.drawCentredString(value + suffix, y + 5, 0xFFFFFF, layer); + if (isInRect(x, y, 114, 18, mouseX, mouseY)) { + int percentage = percentage(max, value); + List list = new ArrayList<>(); + list.add("" + TextFormatting.GOLD + value + "/" + max + suffix); + list.add(getPercentageColour(percentage) + "" + percentage + "%" + TextFormatting.GRAY + " Full"); + + if (value > max) { + list.add(TextFormatting.GRAY + "Yo this is storing more than it should be able to"); + list.add(TextFormatting.GRAY + "prolly a bug"); + list.add(TextFormatting.GRAY + "pls report and tell how tf you did this"); + } + net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRendererObj); + GlStateManager.disableLighting(); + GlStateManager.color(1, 1, 1, 1); + } + } + + public void drawBigHeatBar(GuiBase gui, int x, int y, int value, int max, GuiBase.Layer layer) { + if (layer == GuiBase.Layer.BACKGROUND) { + x += gui.getGuiLeft(); + y += gui.getGuiTop(); + } + gui.mc.getTextureManager().bindTexture(GUI_SHEET); + gui.drawTexturedModalRect(x, y, 0, 218, 114, 18); + if (value != 0) { + int j = (int) ((double) value / (double) max * 106); + if (j < 0) + j = 0; + gui.drawTexturedModalRect(x + 4, y + 4, 0, 246, j, 10); + gui.drawCentredString(value + " Heat", y + 5, 0xFFFFFF, layer); + + } else { + gui.drawCentredString(I18n.translateToLocal("techreborn.message.missingmultiblock"), y + 5, 0xC60000, layer); + } + } + + public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, GuiBase.Layer layer) { + drawBigBlueBar(gui, x, y, value, max, mouseX, mouseY, "", layer); + } + + public void drawSelectedStack(GuiBase gui, int x, int y) { + Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET); + gui.drawTexturedModalRect(x - 4, y - 4, 202, 44, 24, 24); + } + + public void drawBurnBar(GuiBase gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) { + if (layer == GuiBase.Layer.BACKGROUND) { + x += gui.getGuiLeft(); + y += gui.getGuiTop(); + } + if (layer == GuiBase.Layer.FOREGROUND) { + mouseX -= gui.getGuiLeft(); + mouseY -= gui.getGuiTop(); + } + + gui.mc.getTextureManager().bindTexture(GUI_SHEET); + gui.drawTexturedModalRect(x, y, 171, 84, 13, 13); + int j = 13 - (int) ((double) progress / (double) maxProgress * 13); + if (j > 0) { + gui.drawTexturedModalRect(x, y + j, 171, 70 + j, 13, 13 - j); + + } + if (isInRect(x, y, 12, 12, mouseX, mouseY)) { + int percentage = percentage(maxProgress, progress); + List list = new ArrayList<>(); + list.add(getPercentageColour(percentage) + "" + percentage + "%"); + net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRendererObj); + GlStateManager.disableLighting(); + GlStateManager.color(1, 1, 1, 1); + } + } + + public void drawSlot(GuiScreen gui, int posX, int posY) { + Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET); + gui.drawTexturedModalRect(posX, posY, 150, 0, 18, 18); + } + + public void drawOutputSlot(GuiScreen gui, int posX, int posY) { + Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET); + gui.drawTexturedModalRect(posX, posY, 150, 18, 26, 26); + } + + public int getScaledBurnTime(int scale, int burnTime, int totalBurnTime) { + return (int) (((float) burnTime / (float) totalBurnTime) * scale); + } + + public TextFormatting getPercentageColour(int percentage) { + if (percentage <= 10) { + return TextFormatting.RED; + } else if (percentage >= 75) { + return TextFormatting.GREEN; + } else { + return TextFormatting.YELLOW; + } + } + + public int percentage(int MaxValue, int CurrentValue) { + if (CurrentValue == 0) + return 0; + return (int) ((CurrentValue * 100.0f) / MaxValue); + } + + public enum ProgressDirection { + RIGHT(84, 151, 100, 151, 16, 10), LEFT(100, 161, 84, 161, 16, 10)/*, DOWN(104, 171, 114, 171, 10, 16), UP(84, 171, 94, 171, 10, 16)*/; + public int x; + public int y; + public int xActive; + public int yActive; + public int width; + public int height; + + ProgressDirection(int x, int y, int xActive, int yActive, int width, int height) { + this.x = x; + this.y = y; + this.xActive = xActive; + this.yActive = yActive; + this.width = width; + this.height = height; + } + } +} diff --git a/src/main/java/techreborn/client/gui/widget/GuiButtonHologram.java b/src/main/java/techreborn/client/gui/widget/GuiButtonHologram.java new file mode 100644 index 000000000..761974142 --- /dev/null +++ b/src/main/java/techreborn/client/gui/widget/GuiButtonHologram.java @@ -0,0 +1,51 @@ +package techreborn.client.gui.widget; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.util.math.BlockPos; +import reborncore.client.multiblock.Multiblock; +import techreborn.client.gui.GuiBase; + +/** + * Created by Prospector + */ +public class GuiButtonHologram extends GuiButton { + + GuiBase.Layer layer; + GuiBase gui; + + public GuiButtonHologram(int buttonId, int x, int y, GuiBase gui, GuiBase.Layer layer) { + super(buttonId, x, y, 20, 12, ""); + this.layer = layer; + this.gui = gui; + } + + @Override + public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { + + if (layer == GuiBase.Layer.FOREGROUND) { + mouseX -= gui.getGuiLeft(); + mouseY -= gui.getGuiTop(); + } + + if (this.enabled && this.visible && mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) { + return true; + } + return false; + } + + public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) { + multiblock.addComponent(new BlockPos(x, y, z), blockState); + } + + @Override + public void drawButtonForegroundLayer(int mouseX, int mouseY) { + + } + + @Override + public void drawButton(Minecraft mc, int mouseX, int mouseY) { + + } +} diff --git a/src/main/java/techreborn/client/gui/widget/GuiButtonPowerBar.java b/src/main/java/techreborn/client/gui/widget/GuiButtonPowerBar.java new file mode 100644 index 000000000..5589c5eb7 --- /dev/null +++ b/src/main/java/techreborn/client/gui/widget/GuiButtonPowerBar.java @@ -0,0 +1,46 @@ +package techreborn.client.gui.widget; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import reborncore.common.powerSystem.PowerSystem; +import techreborn.client.gui.GuiBase; + +/** + * Created by Prospector + */ +public class GuiButtonPowerBar extends GuiButton { + + GuiBase.Layer layer; + GuiBase gui; + + public GuiButtonPowerBar(int buttonId, int x, int y, GuiBase gui, GuiBase.Layer layer) { + super(buttonId, x, y, 12, 48, ""); + this.layer = layer; + this.gui = gui; + } + + @Override + public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { + + if (layer == GuiBase.Layer.FOREGROUND) { + mouseX -= gui.getGuiLeft(); + mouseY -= gui.getGuiTop(); + } + + if (this.enabled && this.visible && mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) { + PowerSystem.bumpPowerConfig(); + return true; + } + return false; + } + + @Override + public void drawButtonForegroundLayer(int mouseX, int mouseY) { + + } + + @Override + public void drawButton(Minecraft mc, int mouseX, int mouseY) { + + } +} diff --git a/src/main/java/techreborn/compat/jei/BuiltContainerTransferInfo.java b/src/main/java/techreborn/compat/jei/BuiltContainerTransferInfo.java new file mode 100644 index 000000000..3cc2b14cc --- /dev/null +++ b/src/main/java/techreborn/compat/jei/BuiltContainerTransferInfo.java @@ -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 { + + 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 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 getRecipeSlots(final BuiltContainer container) { + final List slots = new ArrayList<>(); + for (int i = this.recipeSlotStart; i < this.recipeSlotStart + this.recipeSlotCount; i++) + slots.add(container.getSlot(i)); + return slots; + } + + @Override + public List getInventorySlots(final BuiltContainer container) { + final List slots = new ArrayList<>(); + for (int i = this.inventorySlotStart; i < this.inventorySlotStart + this.inventorySlotCount; i++) + slots.add(container.getSlot(i)); + return slots; + } +} diff --git a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java index 75b60f850..e8b253d08 100644 --- a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java +++ b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java @@ -17,7 +17,6 @@ import techreborn.api.generator.GeneratorRecipeHelper; import techreborn.api.reactor.FusionReactorRecipeHelper; import techreborn.api.recipe.machines.AssemblingMachineRecipe; import techreborn.api.recipe.machines.ImplosionCompressorRecipe; -import techreborn.client.container.*; import techreborn.client.gui.*; import techreborn.compat.CompatManager; import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory; @@ -68,19 +67,19 @@ import java.util.List; @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 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 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); } @@ -90,9 +89,10 @@ public class TechRebornJeiPlugin extends BlankModPlugin { @Override public void register( @Nonnull - IModRegistry registry) { - IJeiHelpers jeiHelpers = registry.getJeiHelpers(); - IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); + final + IModRegistry registry) { + 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)); @@ -128,13 +128,13 @@ public class TechRebornJeiPlugin extends BlankModPlugin { jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModFluids.BLOCK_OIL)); jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModItems.MISSING_RECIPE_PLACEHOLDER)); - if(IC2Duplicates.deduplicate()){ - for(IC2Duplicates duplicate : IC2Duplicates.values()){ - if(duplicate.hasIC2Stack()){ + if (IC2Duplicates.deduplicate()) { + for (final IC2Duplicates duplicate : IC2Duplicates.values()) { + if (duplicate.hasIC2Stack()) { jeiHelpers.getItemBlacklist().addItemToBlacklist(duplicate.getTrStack()); } } - if(TechRebornParts.cables != null){ + if (TechRebornParts.cables != null) { for (int i = 0; i < EnumCableType.values().length; i++) { jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(TechRebornParts.cables, 1, i)); } @@ -143,7 +143,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin { jeiHelpers.getItemBlacklist().addItemToBlacklist(ItemParts.getPartByName("rubberSap")); jeiHelpers.getItemBlacklist().addItemToBlacklist(ItemParts.getPartByName("electronicCircuit")); jeiHelpers.getItemBlacklist().addItemToBlacklist(ItemParts.getPartByName("advancedCircuit")); - if(!Core.worldGen.config.rubberTreeConfig.shouldSpawn){ + if (!Core.worldGen.config.rubberTreeConfig.shouldSpawn) { jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.RUBBER_SAPLING)); jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.RUBBER_LOG)); jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.RUBBER_PLANKS)); @@ -154,26 +154,26 @@ public class TechRebornJeiPlugin extends BlankModPlugin { } registry.addRecipeCategories(new AlloySmelterRecipeCategory(guiHelper), - new AssemblingMachineRecipeCategory(guiHelper), new BlastFurnaceRecipeCategory(guiHelper), - new CentrifugeRecipeCategory(guiHelper), new ChemicalReactorRecipeCategory(guiHelper), - new FusionReactorRecipeCategory(guiHelper), new IndustrialGrinderRecipeCategory(guiHelper), - new ImplosionCompressorRecipeCategory(guiHelper), new IndustrialElectrolyzerRecipeCategory(guiHelper), - new RollingMachineRecipeCategory(guiHelper), new VacuumFreezerRecipeCategory(guiHelper), - new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper), - new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper)); + new AssemblingMachineRecipeCategory(guiHelper), new BlastFurnaceRecipeCategory(guiHelper), + new CentrifugeRecipeCategory(guiHelper), new ChemicalReactorRecipeCategory(guiHelper), + new FusionReactorRecipeCategory(guiHelper), new IndustrialGrinderRecipeCategory(guiHelper), + new ImplosionCompressorRecipeCategory(guiHelper), new IndustrialElectrolyzerRecipeCategory(guiHelper), + new RollingMachineRecipeCategory(guiHelper), new VacuumFreezerRecipeCategory(guiHelper), + 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), - new AssemblingMachineRecipeHandler(jeiHelpers), new BlastFurnaceRecipeHandler(jeiHelpers), - new CentrifugeRecipeHandler(jeiHelpers), new ChemicalReactorRecipeHandler(jeiHelpers), - new FusionReactorRecipeHandler(), new IndustrialGrinderRecipeHandler(jeiHelpers), - new ImplosionCompressorRecipeHandler(jeiHelpers), new IndustrialElectrolyzerRecipeHandler(jeiHelpers), - new RollingMachineRecipeHandler(), new VacuumFreezerRecipeHandler(jeiHelpers), - new GrinderRecipeHandler(jeiHelpers), new ExtractorRecipeHandler(jeiHelpers), - new CompressorRecipeHandler(jeiHelpers), new ScrapboxRecipeHandler(jeiHelpers), - new FluidGeneratorRecipeHandler(jeiHelpers)); + new AssemblingMachineRecipeHandler(jeiHelpers), new BlastFurnaceRecipeHandler(jeiHelpers), + new CentrifugeRecipeHandler(jeiHelpers), new ChemicalReactorRecipeHandler(jeiHelpers), + new FusionReactorRecipeHandler(), new IndustrialGrinderRecipeHandler(jeiHelpers), + new ImplosionCompressorRecipeHandler(jeiHelpers), new IndustrialElectrolyzerRecipeHandler(jeiHelpers), + new RollingMachineRecipeHandler(), new VacuumFreezerRecipeHandler(jeiHelpers), + new GrinderRecipeHandler(jeiHelpers), new ExtractorRecipeHandler(jeiHelpers), + new CompressorRecipeHandler(jeiHelpers), new ScrapboxRecipeHandler(jeiHelpers), + new FluidGeneratorRecipeHandler(jeiHelpers)); registry.addRecipes(RecipeHandler.recipeList); registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes); @@ -182,14 +182,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"), @@ -202,16 +202,22 @@ public class TechRebornJeiPlugin extends BlankModPlugin { I18n.translateToLocal("techreborn.desc.scrapBox")); } + //NEW ONES + registry.addRecipeClickArea(GuiCentrifuge.class, 150, 4, 20, 12, RecipeCategoryUids.CENTRIFUGE); + registry.addRecipeClickArea(GuiElectricFurnace.class, 150, 4, 20, 12, VanillaRecipeCategoryUid.SMELTING); + registry.addRecipeClickArea(GuiGenerator.class, 150, 4, 20, 12, VanillaRecipeCategoryUid.FUEL); + registry.addRecipeClickArea(GuiExtractor.class, 150, 4, 20, 12, RecipeCategoryUids.EXTRACTOR); + registry.addRecipeClickArea(GuiCompressor.class, 150, 4, 20, 12, RecipeCategoryUids.COMPRESSOR); + registry.addRecipeClickArea(GuiGrinder.class, 150, 4, 20, 12, RecipeCategoryUids.GRINDER); + registry.addRecipeClickArea(GuiVacuumFreezer.class, 150, 4, 20, 12, RecipeCategoryUids.VACUUM_FREEZER); + registry.addRecipeClickArea(GuiBlastFurnace.class, 150, 4, 20, 12, RecipeCategoryUids.BLAST_FURNACE); + registry.addRecipeClickArea(GuiChemicalReactor.class, 150, 4, 20, 12, RecipeCategoryUids.CHEMICAL_REACTOR); + + //OLD ONES registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER, 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); - registry.addRecipeClickArea(GuiCentrifuge.class, 98, 37, 9, 12, RecipeCategoryUids.CENTRIFUGE); - registry.addRecipeClickArea(GuiCentrifuge.class, 68, 37, 9, 12, RecipeCategoryUids.CENTRIFUGE); - registry.addRecipeClickArea(GuiCentrifuge.class, 83, 23, 12, 9, RecipeCategoryUids.CENTRIFUGE); - registry.addRecipeClickArea(GuiCentrifuge.class, 83, 53, 12, 9, RecipeCategoryUids.CENTRIFUGE); - registry.addRecipeClickArea(GuiChemicalReactor.class, 73, 39, 32, 12, RecipeCategoryUids.CHEMICAL_REACTOR); 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, @@ -219,25 +225,26 @@ public class TechRebornJeiPlugin extends BlankModPlugin { registry.addRecipeClickArea(GuiIndustrialElectrolyzer.class, 72, 37, 33, 14, 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); - registry.addRecipeClickArea(GuiElectricFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING); registry.addRecipeClickArea(GuiSemifluidGenerator.class, 79, 34, 18, 18, - EFluidGenerator.SEMIFLUID.getRecipeID()); + EFluidGenerator.SEMIFLUID.getRecipeID()); registry.addRecipeClickArea(GuiDieselGenerator.class, 79, 34, 18, 18, - EFluidGenerator.DIESEL.getRecipeID()); + EFluidGenerator.DIESEL.getRecipeID()); registry.addRecipeClickArea(GuiGasTurbine.class, 79, 34, 18, 18, - EFluidGenerator.GAS.getRecipeID()); + EFluidGenerator.GAS.getRecipeID()); registry.addRecipeClickArea(GuiThermalGenerator.class, 79, 34, 18, 18, - EFluidGenerator.THERMAL.getRecipeID()); + EFluidGenerator.THERMAL.getRecipeID()); + registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IRON_FURNACE), VanillaRecipeCategoryUid.SMELTING, VanillaRecipeCategoryUid.FUEL); + registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IRON_ALLOY_FURNACE), RecipeCategoryUids.ALLOY_SMELTER, VanillaRecipeCategoryUid.FUEL); + registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.SOLID_FUEL_GENEREATOR), VanillaRecipeCategoryUid.FUEL); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.COMPRESSOR), RecipeCategoryUids.COMPRESSOR); - registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IRON_ALLOY_FURNACE), RecipeCategoryUids.ALLOY_SMELTER); + registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.EXTRACTOR), RecipeCategoryUids.EXTRACTOR); + registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GRINDER), RecipeCategoryUids.GRINDER); + registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.VACUUM_FREEZER), RecipeCategoryUids.VACUUM_FREEZER); + registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ELECTRIC_FURNACE), VanillaRecipeCategoryUid.SMELTING); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ALLOY_SMELTER), RecipeCategoryUids.ALLOY_SMELTER); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ASSEMBLY_MACHINE), RecipeCategoryUids.ASSEMBLING_MACHINE); @@ -245,10 +252,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin { registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_CENTRIFUGE), RecipeCategoryUids.CENTRIFUGE); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.CHEMICAL_REACTOR), RecipeCategoryUids.CHEMICAL_REACTOR); - registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.EXTRACTOR), RecipeCategoryUids.EXTRACTOR); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.FUSION_CONTROL_COMPUTER), RecipeCategoryUids.FUSION_REACTOR); - registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GRINDER), RecipeCategoryUids.GRINDER); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IMPLOSION_COMPRESSOR), RecipeCategoryUids.IMPLOSION_COMPRESSOR); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_ELECTROLYZER), @@ -260,51 +265,51 @@ public class TechRebornJeiPlugin extends BlankModPlugin { registry.addRecipeCategoryCraftingItem(new ItemStack(ModItems.SCRAP_BOX), RecipeCategoryUids.SCRAPBOX); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.SEMIFLUID_GENERATOR), - EFluidGenerator.SEMIFLUID.getRecipeID()); + EFluidGenerator.SEMIFLUID.getRecipeID()); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GAS_TURBINE), - EFluidGenerator.GAS.getRecipeID()); + EFluidGenerator.GAS.getRecipeID()); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.DIESEL_GENERATOR), - EFluidGenerator.DIESEL.getRecipeID()); + EFluidGenerator.DIESEL.getRecipeID()); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.THERMAL_GENERATOR), - EFluidGenerator.THERMAL.getRecipeID()); + EFluidGenerator.THERMAL.getRecipeID()); - 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 - .addRecipeTransferHandler(ContainerIndustrialGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36); - recipeTransferRegistry - .addRecipeTransferHandler(ContainerImplosionCompressor.class, RecipeCategoryUids.IMPLOSION_COMPRESSOR, - 0, 2, 4, 36); - recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialElectrolyzer.class, - RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36); - recipeTransferRegistry - .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); + final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry(); + + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("fusionreactor", RecipeCategoryUids.FUSION_REACTOR, 36, 2, 0, 36)); + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("industrialelectrolyzer", RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 36, + 2, 0, 36)); + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("industrialgrinder", RecipeCategoryUids.GRINDER, 36, 2, 0, 36)); + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("implosioncompressor", RecipeCategoryUids.IMPLOSION_COMPRESSOR, 36, 2, 0, + 36)); + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("vacuumfreezer", RecipeCategoryUids.VACUUM_FREEZER, 36, 1, 0, 36)); + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("blastfurnace", RecipeCategoryUids.BLAST_FURNACE, 36, 2, 0, 36)); + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("rollingmachine", RecipeCategoryUids.ROLLING_MACHINE, 36, 9, 0, 36)); + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("alloyfurnace", RecipeCategoryUids.ALLOY_SMELTER, 36, 2, 0, 36)); + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("alloyfurnace", VanillaRecipeCategoryUid.FUEL, 36, 2, 0, 36)); + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("alloysmelter", RecipeCategoryUids.ALLOY_SMELTER, 36, 2, 0, 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)); diff --git a/src/main/java/techreborn/compat/jei/blastFurnace/BlastFurnaceRecipeCategory.java b/src/main/java/techreborn/compat/jei/blastFurnace/BlastFurnaceRecipeCategory.java index 68f82db64..831235314 100644 --- a/src/main/java/techreborn/compat/jei/blastFurnace/BlastFurnaceRecipeCategory.java +++ b/src/main/java/techreborn/compat/jei/blastFurnace/BlastFurnaceRecipeCategory.java @@ -6,14 +6,15 @@ import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeCategory; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; -import techreborn.client.gui.GuiBlastFurnace; import techreborn.compat.jei.RecipeCategoryUids; import techreborn.compat.jei.RecipeUtil; import javax.annotation.Nonnull; public class BlastFurnaceRecipeCategory extends BlankRecipeCategory { + public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0, 1 }; private static final int[] OUTPUT_SLOTS = { 2, 3 }; @@ -21,7 +22,7 @@ public class BlastFurnaceRecipeCategory extends BlankRecipeCategory { + private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_blast_furnace.png"); private final IDrawableAnimated progress; + private final IDrawable heat; public BlastFurnaceRecipeWrapper( @Nonnull @@ -21,22 +26,30 @@ public class BlastFurnaceRecipeWrapper extends BaseRecipeWrapper { + public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0, 1 }; private static final int[] OUTPUT_SLOTS = { 2, 3, 4, 5 }; - private final IDrawable background; private final String title; public CentrifugeRecipeCategory(IGuiHelper guiHelper) { - background = guiHelper.createDrawable(GuiCentrifuge.texture, 49, 4, 78, 78); + background = guiHelper.createDrawable(texture, 0, 0, 104, 62); title = I18n.translateToLocal("tile.techreborn.centrifuge.name"); } @@ -52,13 +52,13 @@ public class CentrifugeRecipeCategory extends BlankRecipeCategory { - private final IDrawableAnimated progressUp; - private final IDrawableAnimated progressLeft; - private final IDrawableAnimated progressDown; - private final IDrawableAnimated progressRight; + private final IDrawableAnimated progress; public CentrifugeRecipeWrapper( @Nonnull @@ -24,37 +22,25 @@ public class CentrifugeRecipeWrapper extends BaseRecipeWrapper CentrifugeRecipe baseRecipe) { super(baseRecipe); IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); - IDrawableStatic progressUpStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 14, 12, 12); - IDrawableStatic progressLeftStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 26, 12, 12); - IDrawableStatic progressDownStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 38, 12, 12); - IDrawableStatic progressRightStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 50, 12, 12); + IDrawableStatic progressStatic = guiHelper.createDrawable(TRBuilder.GUI_SHEET, 100, 151, 16, 10); int ticksPerCycle = baseRecipe.tickTime() / 4; // speed up the animation - // a bit - this.progressUp = guiHelper.createAnimatedDrawable(progressUpStatic, ticksPerCycle, - IDrawableAnimated.StartDirection.BOTTOM, false); - this.progressLeft = guiHelper.createAnimatedDrawable(progressLeftStatic, ticksPerCycle, - IDrawableAnimated.StartDirection.RIGHT, false); - this.progressDown = guiHelper.createAnimatedDrawable(progressDownStatic, ticksPerCycle, - IDrawableAnimated.StartDirection.TOP, false); - this.progressRight = guiHelper.createAnimatedDrawable(progressRightStatic, ticksPerCycle, - IDrawableAnimated.StartDirection.LEFT, false); + + this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle, IDrawableAnimated.StartDirection.LEFT, false); } @Override public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); - progressUp.draw(minecraft, 33, 18); - progressLeft.draw(minecraft, 18, 33); - progressDown.draw(minecraft, 33, 48); - progressRight.draw(minecraft, 48, 33); + progress.draw(minecraft, 25, 26); - int x = -45; - int y = 60; + int x = -10; + int y1 = 1; + int y2 = 54; int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT; - minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " secs", x, y, 0x444444); - minecraft.fontRendererObj.drawString("EU: " + baseRecipe.euPerTick + " EU/t", x, y += lineHeight, 0x444444); + minecraft.fontRendererObj.drawString(baseRecipe.tickTime / 20 + " seconds", (recipeWidth / 2 - minecraft.fontRendererObj.getStringWidth(baseRecipe.tickTime / 20 + " seconds") / 2) - 40, y1, 0x444444); + minecraft.fontRendererObj.drawString(PowerSystem.getLocaliszedPowerFormatted(baseRecipe.euPerTick * baseRecipe.tickTime), (recipeWidth / 2 - minecraft.fontRendererObj.getStringWidth(PowerSystem.getLocaliszedPowerFormatted(baseRecipe.euPerTick * baseRecipe.tickTime)) / 2) - 40, y2, 0x444444); } } diff --git a/src/main/java/techreborn/compat/jei/chemicalReactor/ChemicalReactorRecipeCategory.java b/src/main/java/techreborn/compat/jei/chemicalReactor/ChemicalReactorRecipeCategory.java index 0f25238b0..f7a20586b 100644 --- a/src/main/java/techreborn/compat/jei/chemicalReactor/ChemicalReactorRecipeCategory.java +++ b/src/main/java/techreborn/compat/jei/chemicalReactor/ChemicalReactorRecipeCategory.java @@ -6,14 +6,15 @@ import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeCategory; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; -import techreborn.client.gui.GuiChemicalReactor; import techreborn.compat.jei.RecipeCategoryUids; import techreborn.compat.jei.RecipeUtil; import javax.annotation.Nonnull; public class ChemicalReactorRecipeCategory extends BlankRecipeCategory { + public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0, 1 }; private static final int[] OUTPUT_SLOTS = { 2 }; @@ -21,7 +22,7 @@ public class ChemicalReactorRecipeCategory extends BlankRecipeCategory { - private final IDrawableAnimated progress; + private final IDrawableAnimated progressright; + private final IDrawableAnimated progressleft; public ChemicalReactorRecipeWrapper( @Nonnull @@ -21,23 +23,25 @@ public class ChemicalReactorRecipeWrapper extends BaseRecipeWrapper CompressorRecipe baseRecipe) { super(baseRecipe); IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); - IDrawableStatic progressStatic = guiHelper.createDrawable(GuiCompressor.texture, 176, 14, 20, 11); + IDrawableStatic progressStatic = guiHelper.createDrawable(TRBuilder.GUI_SHEET, 100, 151, 16, 10); + + int ticksPerCycle = baseRecipe.tickTime(); // speed up the animation - int ticksPerCycle = baseRecipe.tickTime(); this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle, IDrawableAnimated.StartDirection.LEFT, false); } @@ -31,13 +32,6 @@ public class CompressorRecipeWrapper extends BaseRecipeWrapper @Override public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); - progress.draw(minecraft, 25, 7); - - int x = -45; - int y = 4; - int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT; - - minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " s", x, y, 0x444444); - minecraft.fontRendererObj.drawString("EU: " + baseRecipe.euPerTick + " EU/t", x, y += lineHeight, 0x444444); + progress.draw(minecraft, 25, 11); } } diff --git a/src/main/java/techreborn/compat/jei/extractor/ExtractorRecipeCategory.java b/src/main/java/techreborn/compat/jei/extractor/ExtractorRecipeCategory.java index c6ee59019..cd28c0c1b 100644 --- a/src/main/java/techreborn/compat/jei/extractor/ExtractorRecipeCategory.java +++ b/src/main/java/techreborn/compat/jei/extractor/ExtractorRecipeCategory.java @@ -6,14 +6,15 @@ import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeCategory; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; -import techreborn.client.gui.GuiExtractor; import techreborn.compat.jei.RecipeCategoryUids; import techreborn.compat.jei.RecipeUtil; import javax.annotation.Nonnull; public class ExtractorRecipeCategory extends BlankRecipeCategory { + public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0 }; private static final int[] OUTPUT_SLOTS = { 1 }; @@ -21,7 +22,7 @@ public class ExtractorRecipeCategory extends BlankRecipeCategory { ExtractorRecipe baseRecipe) { super(baseRecipe); IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); - IDrawableStatic progressStatic = guiHelper.createDrawable(GuiExtractor.texture, 176, 17, 22, 11); + IDrawableStatic progressStatic = guiHelper.createDrawable(TRBuilder.GUI_SHEET, 100, 151, 16, 10); + + int ticksPerCycle = baseRecipe.tickTime(); // speed up the animation - int ticksPerCycle = baseRecipe.tickTime(); this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle, IDrawableAnimated.StartDirection.LEFT, false); } @@ -31,13 +32,6 @@ public class ExtractorRecipeWrapper extends BaseRecipeWrapper { @Override public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); - progress.draw(minecraft, 25, 7); - - int x = -45; - int y = 4; - int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT; - - minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " s", x, y, 0x444444); - minecraft.fontRendererObj.drawString("EU: " + baseRecipe.euPerTick + " EU/t", x, y += lineHeight, 0x444444); + progress.draw(minecraft, 25, 11); } } diff --git a/src/main/java/techreborn/compat/jei/grinder/GrinderRecipeCategory.java b/src/main/java/techreborn/compat/jei/grinder/GrinderRecipeCategory.java index 584d3735a..e5d6f2293 100644 --- a/src/main/java/techreborn/compat/jei/grinder/GrinderRecipeCategory.java +++ b/src/main/java/techreborn/compat/jei/grinder/GrinderRecipeCategory.java @@ -6,14 +6,15 @@ import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeCategory; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; -import techreborn.client.gui.GuiGrinder; import techreborn.compat.jei.RecipeCategoryUids; import techreborn.compat.jei.RecipeUtil; import javax.annotation.Nonnull; public class GrinderRecipeCategory extends BlankRecipeCategory { + public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0 }; private static final int[] OUTPUT_SLOTS = { 1 }; @@ -21,7 +22,7 @@ public class GrinderRecipeCategory extends BlankRecipeCategory { GrinderRecipe baseRecipe) { super(baseRecipe); IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); - IDrawableStatic progressStatic = guiHelper.createDrawable(GuiGrinder.texture, 176, 14, 20, 11); + IDrawableStatic progressStatic = guiHelper.createDrawable(TRBuilder.GUI_SHEET, 100, 151, 16, 10); + + int ticksPerCycle = baseRecipe.tickTime(); // speed up the animation - int ticksPerCycle = baseRecipe.tickTime(); this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle, IDrawableAnimated.StartDirection.LEFT, false); } @@ -31,13 +32,6 @@ public class GrinderRecipeWrapper extends BaseRecipeWrapper { @Override public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); - progress.draw(minecraft, 25, 7); - - int x = -45; - int y = 4; - int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT; - - minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " s", x, y, 0x444444); - minecraft.fontRendererObj.drawString("EU: " + baseRecipe.euPerTick + " EU/t", x, y += lineHeight, 0x444444); + progress.draw(minecraft, 25, 11); } } diff --git a/src/main/java/techreborn/compat/jei/scrapbox/ScrapboxRecipeCategory.java b/src/main/java/techreborn/compat/jei/scrapbox/ScrapboxRecipeCategory.java index c4673a99e..fad667242 100644 --- a/src/main/java/techreborn/compat/jei/scrapbox/ScrapboxRecipeCategory.java +++ b/src/main/java/techreborn/compat/jei/scrapbox/ScrapboxRecipeCategory.java @@ -6,14 +6,15 @@ import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeCategory; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; -import techreborn.client.gui.GuiCompressor; import techreborn.compat.jei.RecipeCategoryUids; import techreborn.compat.jei.RecipeUtil; import javax.annotation.Nonnull; public class ScrapboxRecipeCategory extends BlankRecipeCategory { + public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0 }; private static final int[] OUTPUT_SLOTS = { 1 }; @@ -21,7 +22,7 @@ public class ScrapboxRecipeCategory extends BlankRecipeCategory { - private final IDrawableAnimated progress; - public ScrapboxRecipeWrapper( @Nonnull IJeiHelpers jeiHelpers, @Nonnull ScrapboxRecipe baseRecipe) { super(baseRecipe); - IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); - IDrawableStatic progressStatic = guiHelper.createDrawable(GuiCompressor.texture, 176, 14, 20, 11); - - int ticksPerCycle = baseRecipe.tickTime(); - this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle, - IDrawableAnimated.StartDirection.LEFT, false); - } - - @Override - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); - progress.draw(minecraft, 25, 7); } } diff --git a/src/main/java/techreborn/compat/jei/vacuumFreezer/VacuumFreezerRecipeCategory.java b/src/main/java/techreborn/compat/jei/vacuumFreezer/VacuumFreezerRecipeCategory.java index f6cd4d63b..4c6ce4b24 100644 --- a/src/main/java/techreborn/compat/jei/vacuumFreezer/VacuumFreezerRecipeCategory.java +++ b/src/main/java/techreborn/compat/jei/vacuumFreezer/VacuumFreezerRecipeCategory.java @@ -6,14 +6,15 @@ import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeCategory; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; -import techreborn.client.gui.GuiVacuumFreezer; import techreborn.compat.jei.RecipeCategoryUids; import techreborn.compat.jei.RecipeUtil; import javax.annotation.Nonnull; public class VacuumFreezerRecipeCategory extends BlankRecipeCategory { + public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0 }; private static final int[] OUTPUT_SLOTS = { 1 }; @@ -21,7 +22,7 @@ public class VacuumFreezerRecipeCategory extends BlankRecipeCategory strs = new ArrayList<>(); diff --git a/src/main/java/techreborn/init/recipes/RollingMachineRecipes.java b/src/main/java/techreborn/init/recipes/RollingMachineRecipes.java index f1b6a9837..f6a2e1aa5 100644 --- a/src/main/java/techreborn/init/recipes/RollingMachineRecipes.java +++ b/src/main/java/techreborn/init/recipes/RollingMachineRecipes.java @@ -15,11 +15,11 @@ public class RollingMachineRecipes extends RecipeMethods { if (oresExist("ingotAluminum")) { register(getMaterial("kanthal_heating_coil", 3, Type.PART), "RRR", "CAA", "CCA", 'R', "ingotRefinedIron", 'C', "ingotChrome", 'A', "ingotAluminum"); } - if (oresExist("ingotAluminum")) { + if (oresExist("ingotAluminium")) { register(getMaterial("kanthal_heating_coil", 3, Type.PART), "RRR", "CAA", "CCA", 'R', "ingotRefinedIron", 'C', "ingotChrome", 'A', "ingotAluminium"); } register(getStack(Blocks.RAIL, 24), "I I", "ISI", "I I", 'I', "ingotIron", 'S', "stickWood"); - register(getStack(Blocks.GOLDEN_RAIL, 8), "I I", "ISI", "IRI", 'I', "ingotIron", 'S', "stickWood", 'R', "dustRedstone"); + register(getStack(Blocks.GOLDEN_RAIL, 8), "I I", "ISI", "IRI", 'I', "ingotGold", 'S', "stickWood", 'R', "dustRedstone"); register(getStack(Blocks.DETECTOR_RAIL, 8), "I I", "IPI", "IRI", 'I', "ingotIron", 'P', getStack(Blocks.STONE_PRESSURE_PLATE), 'R', "dustRedstone"); register(getStack(Blocks.ACTIVATOR_RAIL, 8), "ISI", "IRI", "ISI", 'I', "ingotIron", 'S', "stickWood", 'R', getStack(Blocks.REDSTONE_TORCH)); register(getStack(Blocks.IRON_BARS, 24), "III", "III", 'I', "ingotIron"); diff --git a/src/main/java/techreborn/items/ItemDestructopack.java b/src/main/java/techreborn/items/ItemDestructopack.java index 98a84435a..17640a5e5 100644 --- a/src/main/java/techreborn/items/ItemDestructopack.java +++ b/src/main/java/techreborn/items/ItemDestructopack.java @@ -1,30 +1,33 @@ package techreborn.items; -import me.modmuss50.jsonDestroyer.api.ITexturedItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.world.World; + import reborncore.RebornCore; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTabMisc; +import me.modmuss50.jsonDestroyer.api.ITexturedItem; + public class ItemDestructopack extends ItemTextureBase implements ITexturedItem { public ItemDestructopack() { - setUnlocalizedName("techreborn.destructopack"); - setCreativeTab(TechRebornCreativeTabMisc.instance); + this.setUnlocalizedName("techreborn.destructopack"); + this.setCreativeTab(TechRebornCreativeTabMisc.instance); RebornCore.jsonDestroyer.registerObject(this); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, - EnumHand hand) { - player.openGui(Core.INSTANCE, GuiHandler.destructoPackID, world, (int) player.posX, (int) player.posY, - (int) player.posY); + public ActionResult onItemRightClick(final World world, final EntityPlayer player, + final EnumHand hand) { + player.openGui(Core.INSTANCE, EGui.DESTRUCTOPACK.ordinal(), world, (int) player.posX, (int) player.posY, + (int) player.posY); return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } @@ -34,7 +37,7 @@ public class ItemDestructopack extends ItemTextureBase implements ITexturedItem } @Override - public String getTextureName(int arg0) { + public String getTextureName(final int arg0) { return "techreborn:items/misc/destructopack"; } } diff --git a/src/main/java/techreborn/items/ItemParts.java b/src/main/java/techreborn/items/ItemParts.java index cbc37c08c..7ab30baed 100644 --- a/src/main/java/techreborn/items/ItemParts.java +++ b/src/main/java/techreborn/items/ItemParts.java @@ -1,14 +1,16 @@ package techreborn.items; import com.google.common.base.CaseFormat; + import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.world.World; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.init.ModItems; @@ -16,21 +18,21 @@ import java.security.InvalidParameterException; public class ItemParts extends ItemTRNoDestroy { public static final String[] types = new String[] { "energy_flow_circuit", "data_control_circuit", "data_storage_circuit", - "data_orb", "diamond_grinding_head", "diamond_saw_blade", "tungsten_grinding_head", "helium_coolant_simple", - "helium_coolant_triple", "helium_coolant_six", "nak_coolant_simple", "nak_coolant_triple", "nak_coolant_six", - "cupronickel_heating_coil", "nichrome_heating_coil", "kanthal_heating_coil", ModItems.META_PLACEHOLDER, "super_conductor", - "thorium_cell", "double_thorium_cell", "quad_thorium_cell", "plutonium_cell", "double_plutonium_cell", - "quad_plutonium_cell", "computer_monitor", "machine_parts", "neutron_reflector", "iridium_neutron_reflector", - "thick_neutron_reflector", "electronic_circuit", "advanced_circuit", "sap", "rubber", "scrap", - "carbon_mesh", "carbon_fiber", "coolant_simple", "coolant_triple", "coolant_six" }; + "data_orb", "diamond_grinding_head", "diamond_saw_blade", "tungsten_grinding_head", "helium_coolant_simple", + "helium_coolant_triple", "helium_coolant_six", "nak_coolant_simple", "nak_coolant_triple", "nak_coolant_six", + "cupronickel_heating_coil", "nichrome_heating_coil", "kanthal_heating_coil", ModItems.META_PLACEHOLDER, "super_conductor", + "thorium_cell", "double_thorium_cell", "quad_thorium_cell", "plutonium_cell", "double_plutonium_cell", + "quad_plutonium_cell", "computer_monitor", "machine_parts", "neutron_reflector", "iridium_neutron_reflector", + "thick_neutron_reflector", "electronic_circuit", "advanced_circuit", "sap", "rubber", "scrap", + "carbon_mesh", "carbon_fiber", "coolant_simple", "coolant_triple", "coolant_six" }; public ItemParts() { - setCreativeTab(TechRebornCreativeTab.instance); - setHasSubtypes(true); - setUnlocalizedName("techreborn.part"); + this.setCreativeTab(TechRebornCreativeTab.instance); + this.setHasSubtypes(true); + this.setUnlocalizedName("techreborn.part"); } - public static ItemStack getPartByName(String name, int count) { + public static ItemStack getPartByName(String name, final int count) { //TODO: Change all recipes n' shit to use proper snake_case names so I don't have to do this bullshit if (name.equals("NaKCoolantSimple")) name = "nak_coolant_simple"; @@ -47,43 +49,44 @@ public class ItemParts extends ItemTRNoDestroy { if (name.equals("rubberSap")) name = "sap"; name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name); - for (int i = 0; i < types.length; i++) { - if (types[i].equalsIgnoreCase(name)) { + for (int i = 0; i < ItemParts.types.length; i++) { + if (ItemParts.types[i].equalsIgnoreCase(name)) { return new ItemStack(ModItems.PARTS, count, i); } } throw new InvalidParameterException("The part " + name + " could not be found."); } - public static ItemStack getPartByName(String name) { - return getPartByName(name, 1); + public static ItemStack getPartByName(final String name) { + return ItemParts.getPartByName(name, 1); } @Override // gets Unlocalized Name depending on meta data - public String getUnlocalizedName(ItemStack itemStack) { + public String getUnlocalizedName(final ItemStack itemStack) { int meta = itemStack.getItemDamage(); - if (meta < 0 || meta >= types.length) { + if (meta < 0 || meta >= ItemParts.types.length) { meta = 0; } - return super.getUnlocalizedName() + "." + types[meta]; + return super.getUnlocalizedName() + "." + ItemParts.types[meta]; } // Adds Dusts SubItems To Creative Tab - public void getSubItems(Item item, CreativeTabs creativeTabs, NonNullList list) { - for (int meta = 0; meta < types.length; ++meta) { - if (!types[meta].equals(ModItems.META_PLACEHOLDER)) { + @Override + public void getSubItems(final Item item, final CreativeTabs creativeTabs, final NonNullList list) { + for (int meta = 0; meta < ItemParts.types.length; ++meta) { + if (!ItemParts.types[meta].equals(ModItems.META_PLACEHOLDER)) { list.add(new ItemStack(item, 1, meta)); } } } - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer player) { switch (itemStack.getItemDamage()) { case 37: // Destructo pack - player.openGui(Core.INSTANCE, GuiHandler.destructoPackID, world, (int) player.posX, (int) player.posY, - (int) player.posY); + player.openGui(Core.INSTANCE, EGui.DESTRUCTOPACK.ordinal(), world, (int) player.posX, (int) player.posY, + (int) player.posY); break; } return itemStack; diff --git a/src/main/java/techreborn/items/ItemUpgrades.java b/src/main/java/techreborn/items/ItemUpgrades.java index 38cd6336e..3ef7fb3b4 100644 --- a/src/main/java/techreborn/items/ItemUpgrades.java +++ b/src/main/java/techreborn/items/ItemUpgrades.java @@ -17,7 +17,7 @@ import java.util.List; public class ItemUpgrades extends ItemTRNoDestroy implements IMachineUpgrade { - public static final String[] types = new String[] { "overclock", "transformer", "energy_storage" }; + public static final String[] types = new String[] { "overclock", "transformer", "energy_storage", "range" }; public ItemUpgrades() { setUnlocalizedName("techreborn.upgrade"); diff --git a/src/main/java/techreborn/items/tools/ItemTechManual.java b/src/main/java/techreborn/items/tools/ItemTechManual.java index c66846d20..d2e395051 100644 --- a/src/main/java/techreborn/items/tools/ItemTechManual.java +++ b/src/main/java/techreborn/items/tools/ItemTechManual.java @@ -8,8 +8,9 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; + import techreborn.Core; -import techreborn.client.GuiHandler; +import techreborn.client.EGui; import techreborn.client.TechRebornCreativeTab; import techreborn.items.ItemTRNoDestroy; @@ -18,21 +19,21 @@ import java.util.List; public class ItemTechManual extends ItemTRNoDestroy { public ItemTechManual() { - setCreativeTab(TechRebornCreativeTab.instance); - setUnlocalizedName("techreborn.manual"); - setMaxStackSize(1); + this.setCreativeTab(TechRebornCreativeTab.instance); + this.setUnlocalizedName("techreborn.manual"); + this.setMaxStackSize(1); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, - EnumHand hand) { - player.openGui(Core.INSTANCE, GuiHandler.manuelID, world, (int) player.posX, (int) player.posY, - (int) player.posY); + public ActionResult onItemRightClick(final World world, final EntityPlayer player, + final EnumHand hand) { + player.openGui(Core.INSTANCE, EGui.MANUAL.ordinal(), world, (int) player.posX, (int) player.posY, + (int) player.posY); return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } @Override - public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { + public void addInformation(final ItemStack stack, final EntityPlayer playerIn, final List tooltip, final boolean advanced) { tooltip.add(TextFormatting.RED + I18n.translateToLocal("tooltip.wip")); } } diff --git a/src/main/java/techreborn/tiles/TileAlloyFurnace.java b/src/main/java/techreborn/tiles/TileAlloyFurnace.java index 1565a1fb7..fc7051a7b 100644 --- a/src/main/java/techreborn/tiles/TileAlloyFurnace.java +++ b/src/main/java/techreborn/tiles/TileAlloyFurnace.java @@ -8,6 +8,7 @@ import net.minecraft.init.Items; import net.minecraft.item.*; import net.minecraft.util.EnumFacing; import net.minecraftforge.fml.common.registry.GameRegistry; + import reborncore.api.recipe.IBaseRecipeType; import reborncore.api.recipe.RecipeHandler; import reborncore.api.tile.IInventoryProvider; @@ -16,10 +17,16 @@ import reborncore.common.recipes.RecipeTranslator; import reborncore.common.tile.TileLegacyMachineBase; import reborncore.common.util.Inventory; import reborncore.common.util.ItemUtils; + import techreborn.api.Reference; +import techreborn.api.recipe.machines.AlloySmelterRecipe; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchable, IInventoryProvider { +public class TileAlloyFurnace extends TileLegacyMachineBase +implements IWrenchable, IInventoryProvider, IContainerProvider { public int tickTime; public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64, this); @@ -39,14 +46,14 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab * Returns the number of ticks that the supplied fuel item will keep the * furnace burning, or 0 if the item isn't fuel */ - public static int getItemBurnTime(ItemStack stack) { + public static int getItemBurnTime(final ItemStack stack) { if (stack == null) { return 0; } else { - Item item = stack.getItem(); + final Item item = stack.getItem(); if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) { - Block block = Block.getBlockFromItem(item); + final Block block = Block.getBlockFromItem(item); if (block == Blocks.WOODEN_SLAB) { return 150; @@ -84,19 +91,19 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab @Override public void updateEntity() { super.updateEntity(); - boolean flag = this.burnTime > 0; + final boolean flag = this.burnTime > 0; boolean flag1 = false; if (this.burnTime > 0) { --this.burnTime; } if (!this.world.isRemote) { - if (this.burnTime != 0 || getStackInSlot(input1) != ItemStack.EMPTY && getStackInSlot(fuel) != ItemStack.EMPTY) { + if (this.burnTime != 0 || this.getStackInSlot(this.input1) != ItemStack.EMPTY && this.getStackInSlot(this.fuel) != ItemStack.EMPTY) { if (this.burnTime == 0 && this.canSmelt()) { - this.currentItemBurnTime = this.burnTime = getItemBurnTime(getStackInSlot(fuel)); + this.currentItemBurnTime = this.burnTime = TileAlloyFurnace.getItemBurnTime(this.getStackInSlot(this.fuel)); if (this.burnTime > 0) { flag1 = true; - if (this.getStackInSlot(fuel) != ItemStack.EMPTY) { - decrStackSize(fuel, 1); + if (this.getStackInSlot(this.fuel) != ItemStack.EMPTY) { + this.decrStackSize(this.fuel, 1); } } } @@ -121,11 +128,11 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab } } - public boolean hasAllInputs(IBaseRecipeType recipeType) { + public boolean hasAllInputs(final IBaseRecipeType recipeType) { if (recipeType == null) { return false; } - for (Object input : recipeType.getInputs()) { + for (final Object input : recipeType.getInputs()) { boolean hasItem = false; boolean useOreDict = input instanceof String || recipeType.useOreDic(); boolean checkSize = input instanceof ItemStack; @@ -138,7 +145,6 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab } } } - if (!hasItem) return false; } @@ -146,12 +152,12 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab } private boolean canSmelt() { - if (this.getStackInSlot(input1) == ItemStack.EMPTY || this.getStackInSlot(input2) == ItemStack.EMPTY) { + if (this.getStackInSlot(this.input1) == ItemStack.EMPTY || this.getStackInSlot(this.input2) == ItemStack.EMPTY) { return false; } else { ItemStack itemstack = null; - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { - if (hasAllInputs(recipeType)) { + for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { + if (this.hasAllInputs(recipeType)) { itemstack = recipeType.getOutput(0); break; } @@ -159,12 +165,12 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab if (itemstack == null) return false; - if (this.getStackInSlot(output) == ItemStack.EMPTY) + if (this.getStackInSlot(this.output) == ItemStack.EMPTY) return true; - if (!this.getStackInSlot(output).isItemEqual(itemstack)) + if (!this.getStackInSlot(this.output).isItemEqual(itemstack)) return false; - int result = getStackInSlot(output).getCount() + itemstack.getCount(); - return result <= getInventoryStackLimit() && result <= this.getStackInSlot(output).getMaxStackSize(); // Forge + final int result = this.getStackInSlot(this.output).getCount() + itemstack.getCount(); + return result <= this.getInventoryStackLimit() && result <= this.getStackInSlot(this.output).getMaxStackSize(); // Forge // BugFix: // Make // it @@ -182,8 +188,8 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = null; - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { - if (hasAllInputs(recipeType)) { + for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { + if (this.hasAllInputs(recipeType)) { itemstack = recipeType.getOutput(0); break; } @@ -192,15 +198,15 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab } } - if (this.getStackInSlot(output) == ItemStack.EMPTY) { - setInventorySlotContents(output, itemstack.copy()); - } else if (this.getStackInSlot(output).getItem() == itemstack.getItem()) { - decrStackSize(output, -itemstack.getCount()); + if (this.getStackInSlot(this.output) == ItemStack.EMPTY) { + this.setInventorySlotContents(this.output, itemstack.copy()); + } else if (this.getStackInSlot(this.output).getItem() == itemstack.getItem()) { + this.decrStackSize(this.output, -itemstack.getCount()); } - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { + for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { boolean hasAllRecipes = true; - if (hasAllInputs(recipeType)) { + if (this.hasAllInputs(recipeType)) { } else { hasAllRecipes = false; @@ -209,8 +215,8 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab for (Object input : recipeType.getInputs()) { boolean useOreDict = input instanceof String || recipeType.useOreDic(); for (int inputSlot = 0; inputSlot < 2; inputSlot++) { - if (ItemUtils.isInputEqual(input, inventory.getStackInSlot(inputSlot), true, true, - useOreDict)) { + if (ItemUtils.isInputEqual(input, this.inventory.getStackInSlot(inputSlot), true, true, + recipeType.useOreDic())) { int count = 1; if(input instanceof ItemStack){ count = RecipeTranslator.getStackFromObject(input).getCount(); @@ -233,7 +239,7 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab return this.burnTime > 0; } - public int getBurnTimeRemainingScaled(int scale) { + public int getBurnTimeRemainingScaled(final int scale) { if (this.currentItemBurnTime == 0) { this.currentItemBurnTime = 200; } @@ -241,22 +247,22 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab return this.burnTime * scale / this.currentItemBurnTime; } - public int getCookProgressScaled(int scale) { + public int getCookProgressScaled(final int scale) { return this.cookTime * scale / 200; } @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(); } @@ -266,7 +272,7 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.IRON_ALLOY_FURNACE, 1); } @@ -276,22 +282,68 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab @Override public Inventory getInventory() { - return inventory; + return this.inventory; } @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return new int[] { 0, 1, 2 }; } @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 || index == 1; } @Override - public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { + public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) { return index == 2; } + public int getBurnTime() + { + return this.burnTime; + } + + public void setBurnTime(final int burnTime) + { + this.burnTime = burnTime; + } + + public int getCurrentItemBurnTime() + { + return this.currentItemBurnTime; + } + + public void setCurrentItemBurnTime(final int currentItemBurnTime) + { + this.currentItemBurnTime = currentItemBurnTime; + } + + public int getCookTime() + { + return this.cookTime; + } + + public void setCookTime(final int cookTime) + { + this.cookTime = cookTime; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("alloyfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this) + .filterSlot(0, 47, 17, + stack -> RecipeHandler.recipeList.stream() + .anyMatch(recipe -> recipe instanceof AlloySmelterRecipe + && ItemUtils.isInputEqual(recipe.getInputs().get(0), stack, true, true, true))) + .filterSlot(1, 65, 17, + stack -> RecipeHandler.recipeList.stream() + .anyMatch(recipe -> recipe instanceof AlloySmelterRecipe + && ItemUtils.isInputEqual(recipe.getInputs().get(1), stack, true, true, true))) + .outputSlot(2, 116, 35).fuelSlot(3, 56, 53).syncIntegerValue(this::getBurnTime, this::setBurnTime) + .syncIntegerValue(this::getCookTime, this::setCookTime) + .syncIntegerValue(this::getCurrentItemBurnTime, this::setCurrentItemBurnTime).addInventory().create(); + } } diff --git a/src/main/java/techreborn/tiles/TileAlloySmelter.java b/src/main/java/techreborn/tiles/TileAlloySmelter.java index 0e10d1be7..5cf2e305f 100644 --- a/src/main/java/techreborn/tiles/TileAlloySmelter.java +++ b/src/main/java/techreborn/tiles/TileAlloySmelter.java @@ -5,18 +5,27 @@ import net.minecraft.inventory.ISidedInventory; 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.recipe.RecipeHandler; import reborncore.api.tile.IInventoryProvider; import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; +import reborncore.common.util.ItemUtils; + import techreborn.api.Reference; +import techreborn.api.recipe.machines.AlloySmelterRecipe; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; import techreborn.utils.upgrade.UpgradeHandler; -public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider { +public class TileAlloySmelter extends TilePowerAcceptor + implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider, IContainerProvider { public int tickTime; public Inventory inventory = new Inventory(8, "TileAlloySmelter", 64, this); @@ -27,35 +36,35 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, public TileAlloySmelter() { super(1); // Input slots - int[] inputs = new int[2]; + final int[] inputs = new int[2]; inputs[0] = 0; inputs[1] = 1; - int[] outputs = new int[1]; + final int[] outputs = new int[1]; outputs[0] = 2; - crafter = new RecipeCrafter(Reference.alloySmelteRecipe, this, 2, 1, inventory, inputs, outputs); - upgrades = new UpgradeHandler(crafter, inventory, 4, 5, 6, 7); + this.crafter = new RecipeCrafter(Reference.alloySmelteRecipe, this, 2, 1, this.inventory, inputs, outputs); + this.upgrades = new UpgradeHandler(this.crafter, this.inventory, 4, 5, 6, 7); } @Override public void update() { super.update(); - crafter.updateEntity(); - upgrades.tick(); - charge(3); + this.crafter.updateEntity(); + this.upgrades.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(); } @@ -65,7 +74,7 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.ALLOY_SMELTER, 1); } @@ -74,16 +83,16 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, } @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; } @@ -99,41 +108,41 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, // ISidedInventory @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 }; } @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 == 2; } - 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; } @@ -154,11 +163,28 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, @Override public Inventory getInventory() { - return inventory; + return this.inventory; } @Override public RecipeCrafter getRecipeCrafter() { - return crafter; + return this.crafter; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("alloysmelter").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this) + .filterSlot(0, 47, 17, + stack -> RecipeHandler.recipeList.stream() + .anyMatch(recipe -> recipe instanceof AlloySmelterRecipe + && ItemUtils.isInputEqual(recipe.getInputs().get(0), stack, true, true, true))) + .filterSlot(1, 65, 17, + stack -> RecipeHandler.recipeList.stream() + .anyMatch(recipe -> recipe instanceof AlloySmelterRecipe + && ItemUtils.isInputEqual(recipe.getInputs().get(1), stack, true, true, true))) + .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(); } } diff --git a/src/main/java/techreborn/tiles/TileAssemblingMachine.java b/src/main/java/techreborn/tiles/TileAssemblingMachine.java index 197b395ac..652bc104a 100644 --- a/src/main/java/techreborn/tiles/TileAssemblingMachine.java +++ b/src/main/java/techreborn/tiles/TileAssemblingMachine.java @@ -4,6 +4,7 @@ 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.recipe.IRecipeCrafterProvider; import reborncore.api.tile.IInventoryProvider; @@ -11,10 +12,15 @@ import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; + import techreborn.api.Reference; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -public class TileAssemblingMachine extends TilePowerAcceptor implements IWrenchable, ISidedInventory, IInventoryProvider, IRecipeCrafterProvider { +public class TileAssemblingMachine extends TilePowerAcceptor +implements IWrenchable, ISidedInventory, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider { public int tickTime; public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64, this); @@ -23,32 +29,32 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha public TileAssemblingMachine() { super(2); // Input slots - int[] inputs = new int[2]; + final int[] inputs = new int[2]; inputs[0] = 0; inputs[1] = 1; - int[] outputs = new int[1]; + final int[] outputs = new int[1]; outputs[0] = 2; - crafter = new RecipeCrafter(Reference.assemblingMachineRecipe, this, 2, 2, inventory, inputs, outputs); + this.crafter = new RecipeCrafter(Reference.assemblingMachineRecipe, this, 2, 2, this.inventory, inputs, outputs); } @Override public void updateEntity() { super.updateEntity(); - 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(); } @@ -58,7 +64,7 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.ASSEMBLY_MACHINE, 1); } @@ -76,9 +82,9 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha // } // } - 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; } @@ -89,12 +95,12 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha } @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; } @@ -115,27 +121,34 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha @Override public Inventory getInventory() { - return inventory; + return this.inventory; } @Override public RecipeCrafter getRecipeCrafter() { - return crafter; + return this.crafter; } @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return new int[] { 0, 1, 2 }; } @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 || index == 1; } @Override - public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { + public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) { return index == 2; } + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("assemblingmachine").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).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(); + } } diff --git a/src/main/java/techreborn/tiles/TileCentrifuge.java b/src/main/java/techreborn/tiles/TileCentrifuge.java index 44521101f..84eb7fd0d 100644 --- a/src/main/java/techreborn/tiles/TileCentrifuge.java +++ b/src/main/java/techreborn/tiles/TileCentrifuge.java @@ -15,6 +15,9 @@ import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; import techreborn.api.Reference; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; import techreborn.items.DynamicCell; @@ -23,7 +26,7 @@ import techreborn.utils.upgrade.UpgradeHandler; import java.util.List; public class TileCentrifuge extends TilePowerAcceptor - implements IWrenchable, IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider { + implements IWrenchable, IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider { public int tickTime; public Inventory inventory = new Inventory(11, "TileCentrifuge", 64, this); @@ -35,30 +38,30 @@ public class TileCentrifuge extends TilePowerAcceptor public TileCentrifuge() { super(2); // Input slots - int[] inputs = new int[] { 0, 1 }; - int[] outputs = new int[4]; + final int[] inputs = new int[] { 0, 1 }; + final int[] outputs = new int[4]; outputs[0] = 2; outputs[1] = 3; outputs[2] = 4; outputs[3] = 5; - crafter = new RecipeCrafter(Reference.centrifugeRecipe, this, 2, 4, inventory, inputs, outputs); - upgradeHandler = new UpgradeHandler(crafter, inventory, 7, 8, 9, 10); + this.crafter = new RecipeCrafter(Reference.centrifugeRecipe, this, 2, 4, this.inventory, inputs, outputs); + this.upgradeHandler = new UpgradeHandler(this.crafter, this.inventory, 7, 8, 9, 10); } @Override public void updateEntity() { super.updateEntity(); - crafter.updateEntity(); - upgradeHandler.tick(); - charge(6); - if (inventory.getStackInSlot(6) != ItemStack.EMPTY) { - ItemStack stack = inventory.getStackInSlot(6); + this.crafter.updateEntity(); + this.upgradeHandler.tick(); + this.charge(6); + if (this.inventory.getStackInSlot(6) != ItemStack.EMPTY) { + final ItemStack stack = this.inventory.getStackInSlot(6); if (stack.getItem() instanceof IEnergyItemInfo) { - IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem(); + final IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem(); if (item.canProvideEnergy(stack)) { - if (getEnergy() != getMaxPower()) { - addEnergy(item.getMaxTransfer(stack)); + if (this.getEnergy() != this.getMaxPower()) { + this.addEnergy(item.getMaxTransfer(stack)); PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack); } } @@ -67,17 +70,17 @@ public class TileCentrifuge extends TilePowerAcceptor } @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(); } @@ -87,7 +90,7 @@ public class TileCentrifuge extends TilePowerAcceptor } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.INDUSTRIAL_CENTRIFUGE, 1); } @@ -96,44 +99,44 @@ public class TileCentrifuge extends TilePowerAcceptor } @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; } // ISidedInventory @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 }; } @Override - public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) { + public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) { return itemStackIn.isItemEqual(DynamicCell.getEmptyCell(1).copy()) ? index == 1 : index == 0; } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { + public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) { return slotIndex >= 2 && slotIndex <= 5; } @Override - public void addInfo(List info, boolean isRealTile) { + public void addInfo(final List info, final boolean isRealTile) { super.addInfo(info, isRealTile); info.add("Round and round it goes"); } - 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; } @@ -144,12 +147,12 @@ public class TileCentrifuge extends TilePowerAcceptor } @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; } @@ -170,12 +173,20 @@ public class TileCentrifuge extends TilePowerAcceptor @Override public Inventory getInventory() { - return inventory; + return this.inventory; } @Override public RecipeCrafter getRecipeCrafter() { - return crafter; + return this.crafter; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("centrifuge").player(player.inventory).inventory().hotbar() + .addInventory().tile(this).slot(0, 40, 34).slot(1, 40, 54).outputSlot(2, 82, 44).outputSlot(3, 101, 25) + .outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue() + .syncCrafterValue().addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/TileChargeBench.java b/src/main/java/techreborn/tiles/TileChargeBench.java index 46bcae051..0f7f86942 100644 --- a/src/main/java/techreborn/tiles/TileChargeBench.java +++ b/src/main/java/techreborn/tiles/TileChargeBench.java @@ -4,15 +4,21 @@ 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.power.IEnergyInterfaceItem; import reborncore.api.tile.IInventoryProvider; import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.Inventory; + +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory { +public class TileChargeBench extends TilePowerAcceptor +implements IWrenchable, IInventoryProvider, ISidedInventory, IContainerProvider { public Inventory inventory = new Inventory(6, "TileChargeBench", 64, this); public int capacity = 100000; @@ -26,15 +32,15 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I super.updateEntity(); for (int i = 0; i < 6; i++) { - if (inventory.getStackInSlot(i) != ItemStack.EMPTY) { - if (getEnergy() > 0) { - ItemStack stack = inventory.getStackInSlot(i); + if (this.inventory.getStackInSlot(i) != ItemStack.EMPTY) { + if (this.getEnergy() > 0) { + final ItemStack stack = this.inventory.getStackInSlot(i); if (stack.getItem() instanceof IEnergyInterfaceItem) { - IEnergyInterfaceItem interfaceItem = (IEnergyInterfaceItem) stack.getItem(); - double trans = Math.min(interfaceItem.getMaxPower(stack) - interfaceItem.getEnergy(stack), - Math.min(interfaceItem.getMaxTransfer(stack), getEnergy())); + final IEnergyInterfaceItem interfaceItem = (IEnergyInterfaceItem) stack.getItem(); + final double trans = Math.min(interfaceItem.getMaxPower(stack) - interfaceItem.getEnergy(stack), + Math.min(interfaceItem.getMaxTransfer(stack), this.getEnergy())); interfaceItem.setEnergy(trans + interfaceItem.getEnergy(stack), stack); - useEnergy(trans); + this.useEnergy(trans); } } } @@ -42,17 +48,17 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I } @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(); } @@ -62,7 +68,7 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.CHARGE_O_MAT, 1); } @@ -72,17 +78,17 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I // ISidedInventory @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 }; } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { - return isItemValidForSlot(slotIndex, itemStack); + public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) { + 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) { // if (itemStack.getItem() instanceof IElectricItem) { // double CurrentCharge = ElectricItem.manager.getCharge(itemStack); // double MaxCharge = ((IElectricItem) @@ -95,16 +101,16 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I @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; } @@ -125,6 +131,13 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I @Override public Inventory getInventory() { - return inventory; + return this.inventory; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("chargebench").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).energySlot(0, 62, 25).energySlot(1, 98, 25).energySlot(2, 62, 45).energySlot(3, 98, 45) + .energySlot(4, 62, 65).energySlot(5, 98, 65).syncEnergyValue().addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/TileChemicalReactor.java b/src/main/java/techreborn/tiles/TileChemicalReactor.java index e38cc6fb9..97686482d 100644 --- a/src/main/java/techreborn/tiles/TileChemicalReactor.java +++ b/src/main/java/techreborn/tiles/TileChemicalReactor.java @@ -13,9 +13,13 @@ import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; import techreborn.api.Reference; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider { +public class TileChemicalReactor extends TilePowerAcceptor + implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider, IContainerProvider { public int tickTime; public Inventory inventory = new Inventory(8, "TileChemicalReactor", 64, this); @@ -24,33 +28,33 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl public TileChemicalReactor() { super(2); // Input slots - int[] inputs = new int[2]; + final int[] inputs = new int[2]; inputs[0] = 0; inputs[1] = 1; - int[] outputs = new int[1]; + final int[] outputs = new int[1]; outputs[0] = 2; - crafter = new RecipeCrafter(Reference.chemicalReactorRecipe, this, 2, 2, inventory, inputs, outputs); + this.crafter = new RecipeCrafter(Reference.chemicalReactorRecipe, this, 2, 2, this.inventory, inputs, outputs); } @Override public void updateEntity() { super.updateEntity(); - crafter.updateEntity(); - charge(3); + this.crafter.updateEntity(); + 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(); } @@ -60,7 +64,7 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.CHEMICAL_REACTOR, 1); } @@ -69,33 +73,33 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl } @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; } // ISidedInventory @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 }; } @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 == 2; } @@ -109,9 +113,9 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl // } // } - 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; } @@ -122,12 +126,12 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl } @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; } @@ -148,11 +152,18 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl @Override public Inventory getInventory() { - return inventory; + return this.inventory; } @Override public RecipeCrafter getRecipeCrafter() { - return crafter; + return this.crafter; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("chemicalreactor").player(player.inventory).inventory().hotbar() + .addInventory().tile(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).energySlot(3, 8, 72) + .syncEnergyValue().syncCrafterValue().addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/TileChunkLoader.java b/src/main/java/techreborn/tiles/TileChunkLoader.java index 98c9675bc..2645f6d4a 100644 --- a/src/main/java/techreborn/tiles/TileChunkLoader.java +++ b/src/main/java/techreborn/tiles/TileChunkLoader.java @@ -3,14 +3,19 @@ package techreborn.tiles; import net.minecraft.entity.player.EntityPlayer; 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.powerSystem.TilePowerAcceptor; import reborncore.common.util.Inventory; + +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, IInventoryProvider { +public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IContainerProvider { public Inventory inventory = new Inventory(1, "TileChunkLoader", 64, this); @@ -24,17 +29,17 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, I } @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(); } @@ -44,7 +49,7 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, I } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.CHUNK_LOADER, 1); } @@ -58,12 +63,12 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, I } @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; } @@ -84,6 +89,12 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, I @Override public Inventory getInventory() { - return inventory; + return this.inventory; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("chunkloader").player(player.inventory).inventory().hotbar().addInventory() + .create(); } } diff --git a/src/main/java/techreborn/tiles/TileDigitalChest.java b/src/main/java/techreborn/tiles/TileDigitalChest.java index c5bea87bb..fdd7a0549 100644 --- a/src/main/java/techreborn/tiles/TileDigitalChest.java +++ b/src/main/java/techreborn/tiles/TileDigitalChest.java @@ -1,8 +1,19 @@ package techreborn.tiles; -public class TileDigitalChest extends TileTechStorageBase { +import net.minecraft.entity.player.EntityPlayer; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; + +public class TileDigitalChest extends TileTechStorageBase implements IContainerProvider { public TileDigitalChest() { - super("TileDigitalChest", Short.MAX_VALUE); + super("TileDigitalChest", 32768); + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("digitalchest").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/TileIndustrialElectrolyzer.java b/src/main/java/techreborn/tiles/TileIndustrialElectrolyzer.java index 5b40cee66..c4476176b 100644 --- a/src/main/java/techreborn/tiles/TileIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/tiles/TileIndustrialElectrolyzer.java @@ -5,6 +5,7 @@ import net.minecraft.inventory.ISidedInventory; 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.IInventoryProvider; @@ -12,10 +13,15 @@ import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; + import techreborn.api.Reference; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider { +public class TileIndustrialElectrolyzer extends TilePowerAcceptor + implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider, IContainerProvider { public int tickTime; public Inventory inventory = new Inventory(8, "TileIndustrialElectrolyzer", 64, this); @@ -24,36 +30,36 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr public TileIndustrialElectrolyzer() { super(2); // Input slots - int[] inputs = new int[2]; + final int[] inputs = new int[2]; inputs[0] = 0; inputs[1] = 1; - int[] outputs = new int[4]; + final int[] outputs = new int[4]; outputs[0] = 2; outputs[1] = 3; outputs[2] = 4; outputs[3] = 5; - crafter = new RecipeCrafter(Reference.industrialElectrolyzerRecipe, this, 2, 4, inventory, inputs, outputs); + this.crafter = new RecipeCrafter(Reference.industrialElectrolyzerRecipe, this, 2, 4, this.inventory, inputs, outputs); } @Override public void updateEntity() { super.updateEntity(); - crafter.updateEntity(); - charge(6); + this.crafter.updateEntity(); + this.charge(6); } @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(); } @@ -63,7 +69,7 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.INDUSTRIAL_ELECTROLYZER, 1); } @@ -72,15 +78,15 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr } @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; } @@ -96,25 +102,25 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr // ISidedInventory @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 }; } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { + public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) { if (slotIndex >= 1) 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 == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5; } - 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; } @@ -125,12 +131,12 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr } @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; } @@ -151,11 +157,19 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr @Override public Inventory getInventory() { - return inventory; + return this.inventory; } @Override public RecipeCrafter getRecipeCrafter() { - return crafter; + return this.crafter; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("industrialelectrolyzer").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 80, 51).slot(1, 50, 51).outputSlot(2, 50, 19).outputSlot(3, 70, 19) + .outputSlot(4, 90, 19).outputSlot(5, 110, 19).energySlot(6, 18, 51).syncEnergyValue().syncCrafterValue() + .addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/TileIronFurnace.java b/src/main/java/techreborn/tiles/TileIronFurnace.java index bc2d7b09e..bf80f2b5a 100644 --- a/src/main/java/techreborn/tiles/TileIronFurnace.java +++ b/src/main/java/techreborn/tiles/TileIronFurnace.java @@ -1,6 +1,7 @@ package techreborn.tiles; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; @@ -8,12 +9,18 @@ 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; import reborncore.common.util.Inventory; -public class TileIronFurnace extends TileLegacyMachineBase implements IInventoryProvider, ISidedInventory { +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; + +public class TileIronFurnace extends TileLegacyMachineBase + implements IInventoryProvider, ISidedInventory, IContainerProvider { private static final int[] SLOTS_TOP = new int[] { 0 }; private static final int[] SLOTS_BOTTOM = new int[] { 2, 1 }; @@ -30,100 +37,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 - // slot + 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)); - if (itemstack == ItemStack.EMPTY) - return false; - if (getStackInSlot(output) == ItemStack.EMPTY) - return true; - if (!getStackInSlot(output).isItemEqual(itemstack)) - return false; - int result = getStackInSlot(output).getCount() + itemstack.getCount(); - return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); - } + final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1)); + if (itemstack == ItemStack.EMPTY) + return false; + if (this.getStackInSlot(this.output) == ItemStack.EMPTY) + return true; + if (!this.getStackInSlot(this.output).isItemEqual(itemstack)) + return false; + 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 +136,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 +171,28 @@ 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; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("ironfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 56, 17).outputSlot(1, 116, 34).fuelSlot(2, 56, 53) + .syncIntegerValue(this::getBurnTime, this::setBurnTime) + .syncIntegerValue(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(); + } } diff --git a/src/main/java/techreborn/tiles/TileMatterFabricator.java b/src/main/java/techreborn/tiles/TileMatterFabricator.java index f1ed08aec..d19df487b 100644 --- a/src/main/java/techreborn/tiles/TileMatterFabricator.java +++ b/src/main/java/techreborn/tiles/TileMatterFabricator.java @@ -3,17 +3,23 @@ package techreborn.tiles; import net.minecraft.entity.player.EntityPlayer; 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.powerSystem.TilePowerAcceptor; import reborncore.common.util.Inventory; import reborncore.common.util.ItemUtils; + +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; import techreborn.init.ModItems; import techreborn.items.ItemParts; -public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchable, IInventoryProvider { +public class TileMatterFabricator extends TilePowerAcceptor + implements IWrenchable, IInventoryProvider, IContainerProvider { public static int fabricationRate = 10000; public int tickTime; @@ -27,17 +33,17 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab } @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(); } @@ -47,7 +53,7 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.MATTER_FABRICATOR, 1); } @@ -77,7 +83,7 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab // } public int maxProgresstime() { - return fabricationRate; + return TileMatterFabricator.fabricationRate; } @Override @@ -86,14 +92,14 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab if (!super.world.isRemote) { for (int i = 0; i < 6; i++) { - ItemStack stack = inventory.getStackInSlot(i); + final ItemStack stack = this.inventory.getStackInSlot(i); if (this.amplifier < 10000 && stack != ItemStack.EMPTY) { - int amp = (int) ((long) (getValue(stack) / 32)); - if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true)) { - if (canUseEnergy(1)) { - useEnergy(1); + final int amp = this.getValue(stack) / 32; + if (ItemUtils.isItemEqual(stack, this.inventory.getStackInSlot(i), true, true)) { + if (this.canUseEnergy(1)) { + this.useEnergy(1); this.amplifier += amp; - inventory.decrStackSize(i, 1); + this.inventory.decrStackSize(i, 1); } } } @@ -120,27 +126,27 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab } private boolean spaceForOutput() { - return inventory.getStackInSlot(6) == ItemStack.EMPTY - || ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.UU_MATTER), true, true) - && inventory.getStackInSlot(6).getCount() < 64; + return this.inventory.getStackInSlot(6) == ItemStack.EMPTY + || ItemUtils.isItemEqual(this.inventory.getStackInSlot(6), new ItemStack(ModItems.UU_MATTER), true, true) + && this.inventory.getStackInSlot(6).getCount() < 64; } private void addOutputProducts() { - if (inventory.getStackInSlot(6) == ItemStack.EMPTY) { - inventory.setInventorySlotContents(6, new ItemStack(ModItems.UU_MATTER)); - } else if (ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.UU_MATTER), true, true)) { - inventory.getStackInSlot(6).setCount(Math.min(64, 1 + inventory.getStackInSlot(6).getCount())); + if (this.inventory.getStackInSlot(6) == ItemStack.EMPTY) { + this.inventory.setInventorySlotContents(6, new ItemStack(ModItems.UU_MATTER)); + } else if (ItemUtils.isItemEqual(this.inventory.getStackInSlot(6), new ItemStack(ModItems.UU_MATTER), true, true)) { + this.inventory.getStackInSlot(6).setCount(Math.min(64, 1 + this.inventory.getStackInSlot(6).getCount())); } } - public boolean decreaseStoredEnergy(double aEnergy, boolean aIgnoreTooLessEnergy) { + public boolean decreaseStoredEnergy(final double aEnergy, final boolean aIgnoreTooLessEnergy) { if (this.getEnergy() - aEnergy < 0 && !aIgnoreTooLessEnergy) { return false; } else { - setEnergy(this.getEnergy() - aEnergy); + this.setEnergy(this.getEnergy() - aEnergy); if (this.getEnergy() < 0) { - setEnergy(0); + this.setEnergy(0); return false; } else { return true; @@ -149,7 +155,7 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab } // TODO ic2 - public int getValue(ItemStack itemStack) { + public int getValue(final ItemStack itemStack) { // int value = getValue(Recipes.matterAmplifier.getOutputFor(itemStack, // false)); if (itemStack.getItem() == ModItems.PARTS && itemStack.getItemDamage() == ItemParts.getPartByName("scrap").getItemDamage()) { @@ -173,12 +179,12 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab } @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; } @@ -199,6 +205,29 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab @Override public Inventory getInventory() { - return inventory; + return this.inventory; + } + + public int getProgress() { + return this.progresstime; + } + + public void setProgress(final int progress) { + this.progresstime = progress; + } + + public int getProgressScaled(final int scale) { + if (this.progresstime != 0) { + return this.progresstime * scale / this.maxProgresstime(); + } + return 0; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("matterfabricator").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 33, 17).slot(1, 33, 35).slot(2, 33, 53).slot(3, 51, 17) + .slot(4, 51, 35).slot(5, 51, 53).outputSlot(6, 116, 35).syncEnergyValue() + .syncIntegerValue(this::getProgress, this::setProgress).addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/TileQuantumChest.java b/src/main/java/techreborn/tiles/TileQuantumChest.java index c636234d7..2eb294d77 100644 --- a/src/main/java/techreborn/tiles/TileQuantumChest.java +++ b/src/main/java/techreborn/tiles/TileQuantumChest.java @@ -1,8 +1,19 @@ package techreborn.tiles; -public class TileQuantumChest extends TileTechStorageBase { +import net.minecraft.entity.player.EntityPlayer; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; + +public class TileQuantumChest extends TileTechStorageBase implements IContainerProvider { public TileQuantumChest() { super("TileQuantumChest", Integer.MAX_VALUE); } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("quantumchest").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create(); + } } diff --git a/src/main/java/techreborn/tiles/TileQuantumTank.java b/src/main/java/techreborn/tiles/TileQuantumTank.java index 6fb1558b0..6303cea81 100644 --- a/src/main/java/techreborn/tiles/TileQuantumTank.java +++ b/src/main/java/techreborn/tiles/TileQuantumTank.java @@ -8,6 +8,7 @@ import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; + import reborncore.api.IListInfoProvider; import reborncore.api.tile.IInventoryProvider; import reborncore.common.IWrenchable; @@ -15,63 +16,67 @@ import reborncore.common.tile.TileLegacyMachineBase; import reborncore.common.util.FluidUtils; import reborncore.common.util.Inventory; import reborncore.common.util.Tank; + +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; import java.util.List; public class TileQuantumTank extends TileLegacyMachineBase - implements IInventoryProvider, IWrenchable, IListInfoProvider { +implements IInventoryProvider, IWrenchable, IListInfoProvider, IContainerProvider { public Tank tank = new Tank("TileQuantumTank", Integer.MAX_VALUE, this); public Inventory inventory = new Inventory(3, "TileQuantumTank", 64, this); @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); - readFromNBTWithoutCoords(tagCompound); + this.readFromNBTWithoutCoords(tagCompound); } - public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) { - tank.readFromNBT(tagCompound); + public void readFromNBTWithoutCoords(final NBTTagCompound tagCompound) { + this.tank.readFromNBT(tagCompound); } @Override - public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); - writeToNBTWithoutCoords(tagCompound); + this.writeToNBTWithoutCoords(tagCompound); return tagCompound; } - public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) { - tank.writeToNBT(tagCompound); + public NBTTagCompound writeToNBTWithoutCoords(final NBTTagCompound tagCompound) { + this.tank.writeToNBT(tagCompound); return tagCompound; } @Override - public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { - world.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), - getPos().getY(), getPos().getZ()); - readFromNBT(packet.getNbtCompound()); + public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) { + this.world.markBlockRangeForRenderUpdate(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), + this.getPos().getX(), this.getPos().getY(), this.getPos().getZ()); + this.readFromNBT(packet.getNbtCompound()); } @Override public void updateEntity() { super.updateEntity(); - if (!world.isRemote) { - if (FluidUtils.drainContainers(tank, inventory, 0, 1) - || FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType())) + if (!this.world.isRemote) { + if (FluidUtils.drainContainers(this.tank, this.inventory, 0, 1) + || FluidUtils.fillContainers(this.tank, this.inventory, 0, 1, this.tank.getFluidType())) this.syncWithAll(); - if (tank.getFluidType() != null && getStackInSlot(2) == ItemStack.EMPTY) { - inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock())); - } else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) { - setInventorySlotContents(2, ItemStack.EMPTY); + if (this.tank.getFluidType() != null && this.getStackInSlot(2) == ItemStack.EMPTY) { + this.inventory.setInventorySlotContents(2, new ItemStack(this.tank.getFluidType().getBlock())); + } else if (this.tank.getFluidType() == null && this.getStackInSlot(2) != ItemStack.EMPTY) { + this.setInventorySlotContents(2, ItemStack.EMPTY); } } } @Override - public boolean hasCapability(Capability capability, EnumFacing facing) { + public boolean hasCapability(final Capability capability, final EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return true; } @@ -79,25 +84,25 @@ public class TileQuantumTank extends TileLegacyMachineBase } @Override - public T getCapability(Capability capability, EnumFacing facing) { + public T getCapability(final Capability capability, final EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { - return (T) tank; + return (T) this.tank; } return super.getCapability(capability, facing); } @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(); } @@ -107,34 +112,41 @@ public class TileQuantumTank extends TileLegacyMachineBase } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { - return getDropWithNBT(); + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { + return this.getDropWithNBT(); } public ItemStack getDropWithNBT() { - NBTTagCompound tileEntity = new NBTTagCompound(); - ItemStack dropStack = new ItemStack(ModBlocks.QUANTUM_TANK, 1); - writeToNBTWithoutCoords(tileEntity); + final NBTTagCompound tileEntity = new NBTTagCompound(); + final ItemStack dropStack = new ItemStack(ModBlocks.QUANTUM_TANK, 1); + this.writeToNBTWithoutCoords(tileEntity); dropStack.setTagCompound(new NBTTagCompound()); dropStack.getTagCompound().setTag("tileEntity", tileEntity); return dropStack; } @Override - public void addInfo(List info, boolean isRealTile) { + public void addInfo(final List info, final boolean isRealTile) { if (isRealTile) { - if (tank.getFluid() != null) { - info.add(tank.getFluidAmount() + " of " + tank.getFluidType().getName()); + if (this.tank.getFluid() != null) { + info.add(this.tank.getFluidAmount() + " of " + this.tank.getFluidType().getName()); } else { info.add("Empty"); } } - info.add("Capacity " + tank.getCapacity() + " mb"); + info.add("Capacity " + this.tank.getCapacity() + " mb"); } @Override public Inventory getInventory() { - return inventory; + return this.inventory; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("quantumtank").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).fluidSlot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).addInventory() + .create(); } } diff --git a/src/main/java/techreborn/tiles/TileRollingMachine.java b/src/main/java/techreborn/tiles/TileRollingMachine.java index 8f14838d4..e6b45f1d9 100644 --- a/src/main/java/techreborn/tiles/TileRollingMachine.java +++ b/src/main/java/techreborn/tiles/TileRollingMachine.java @@ -6,17 +6,23 @@ import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; + import reborncore.api.power.EnumPowerTier; import reborncore.api.tile.IInventoryProvider; import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.Inventory; import reborncore.common.util.ItemUtils; + import techreborn.api.RollingMachineRecipe; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; //TODO add tick and power bars. -public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable, IInventoryProvider { +public class TileRollingMachine extends TilePowerAcceptor + implements IWrenchable, IInventoryProvider, IContainerProvider { public final InventoryCrafting craftMatrix = new InventoryCrafting(new RollingTileContainer(), 3, 3); public Inventory inventory = new Inventory(3, "TileRollingMachine", 64, this); @@ -37,12 +43,12 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable } @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; } @@ -64,72 +70,72 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable @Override public void updateEntity() { super.updateEntity(); - charge(2); - if (!world.isRemote) { - currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world); - if (currentRecipe != null && canMake()) { - if (tickTime >= runTime) { - currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world); - if (currentRecipe != null) { + this.charge(2); + if (!this.world.isRemote) { + this.currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(this.craftMatrix, this.world); + if (this.currentRecipe != null && this.canMake()) { + if (this.tickTime >= this.runTime) { + this.currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(this.craftMatrix, this.world); + if (this.currentRecipe != null) { boolean hasCrafted = false; - if (inventory.getStackInSlot(0) == ItemStack.EMPTY) { - inventory.setInventorySlotContents(0, currentRecipe); - tickTime = -1; + if (this.inventory.getStackInSlot(0) == ItemStack.EMPTY) { + this.inventory.setInventorySlotContents(0, this.currentRecipe); + this.tickTime = -1; hasCrafted = true; } else { - if (inventory.getStackInSlot(0).getCount() + currentRecipe.getCount() <= currentRecipe - .getMaxStackSize()) { - ItemStack stack = inventory.getStackInSlot(0); - stack.setCount(stack.getCount() + currentRecipe.getCount()); - inventory.setInventorySlotContents(0, stack); - tickTime = -1; + if (this.inventory.getStackInSlot(0).getCount() + this.currentRecipe.getCount() <= this.currentRecipe + .getMaxStackSize()) { + final ItemStack stack = this.inventory.getStackInSlot(0); + stack.setCount(stack.getCount() + this.currentRecipe.getCount()); + this.inventory.setInventorySlotContents(0, stack); + this.tickTime = -1; hasCrafted = true; } } if (hasCrafted) { - for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { - craftMatrix.decrStackSize(i, 1); + for (int i = 0; i < this.craftMatrix.getSizeInventory(); i++) { + this.craftMatrix.decrStackSize(i, 1); } - currentRecipe = null; + this.currentRecipe = null; } } } } - if (currentRecipe != null) { - if (canUseEnergy(euTick) && tickTime < runTime) { - useEnergy(euTick); - tickTime++; + if (this.currentRecipe != null) { + if (this.canUseEnergy(this.euTick) && this.tickTime < this.runTime) { + this.useEnergy(this.euTick); + this.tickTime++; } } - if (currentRecipe == null) { - tickTime = -1; + if (this.currentRecipe == null) { + this.tickTime = -1; } } else { - currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world); - if (currentRecipe != null) { - inventory.setInventorySlotContents(1, currentRecipe); + this.currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(this.craftMatrix, this.world); + if (this.currentRecipe != null) { + this.inventory.setInventorySlotContents(1, this.currentRecipe); } else { - inventory.setInventorySlotContents(1, ItemStack.EMPTY); + this.inventory.setInventorySlotContents(1, ItemStack.EMPTY); } } } public boolean canMake() { - return RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world) != null; + return RollingMachineRecipe.instance.findMatchingRecipe(this.craftMatrix, this.world) != null; } @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,29 +145,29 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.ROLLING_MACHINE, 1); } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); - ItemUtils.readInvFromNBT(craftMatrix, "Crafting", tagCompound); - isRunning = tagCompound.getBoolean("isRunning"); - tickTime = tagCompound.getInteger("tickTime"); + ItemUtils.readInvFromNBT(this.craftMatrix, "Crafting", tagCompound); + this.isRunning = tagCompound.getBoolean("isRunning"); + this.tickTime = tagCompound.getInteger("tickTime"); } @Override - public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); - ItemUtils.writeInvToNBT(craftMatrix, "Crafting", tagCompound); - writeUpdateToNBT(tagCompound); + ItemUtils.writeInvToNBT(this.craftMatrix, "Crafting", tagCompound); + this.writeUpdateToNBT(tagCompound); return tagCompound; } - public void writeUpdateToNBT(NBTTagCompound tagCompound) { - tagCompound.setBoolean("isRunning", isRunning); - tagCompound.setInteger("tickTime", tickTime); + public void writeUpdateToNBT(final NBTTagCompound tagCompound) { + tagCompound.setBoolean("isRunning", this.isRunning); + tagCompound.setInteger("tickTime", this.tickTime); } @Override @@ -176,15 +182,41 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable @Override public Inventory getInventory() { - return inventory; + return this.inventory; } private static class RollingTileContainer extends Container { @Override - public boolean canInteractWith(EntityPlayer entityplayer) { + public boolean canInteractWith(final EntityPlayer entityplayer) { return true; } } + + public int getBurnTime() { + return this.tickTime; + } + + public void setBurnTime(final int burnTime) { + this.tickTime = burnTime; + } + + public int getBurnTimeRemainingScaled(final int scale) { + if (this.tickTime == 0 || this.runTime == 0) { + return 0; + } + return this.tickTime * scale / this.runTime; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("rollingmachine").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this.craftMatrix).slot(0, 30, 17).slot(1, 48, 17).slot(2, 66, 17).slot(3, 30, 35) + .slot(4, 48, 35).slot(5, 66, 35).slot(6, 30, 53).slot(7, 48, 53).slot(8, 66, 53) + .onCraft(inv -> this.inventory.setInventorySlotContents(1, + RollingMachineRecipe.instance.findMatchingRecipe(inv, this.world))) + .addInventory().tile(this).outputSlot(0, 124, 35).energySlot(2, 8, 51).syncEnergyValue() + .syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create(); + } } diff --git a/src/main/java/techreborn/tiles/TileScrapboxinator.java b/src/main/java/techreborn/tiles/TileScrapboxinator.java index db2e0c712..6f1f0b84d 100644 --- a/src/main/java/techreborn/tiles/TileScrapboxinator.java +++ b/src/main/java/techreborn/tiles/TileScrapboxinator.java @@ -5,19 +5,25 @@ 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.api.ScrapboxList; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; import techreborn.init.ModItems; import java.util.Random; -public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory { +public class TileScrapboxinator extends TilePowerAcceptor +implements IWrenchable, IInventoryProvider, ISidedInventory, IContainerProvider { public Inventory inventory = new Inventory(6, "TileScrapboxinator", 64, this); public int capacity = 1000; @@ -33,88 +39,88 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable 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() { - boolean burning = isBurning(); + final boolean burning = this.isBurning(); boolean updateInventory = false; - if (getEnergy() <= cost && canOpen()) { - if (getEnergy() > cost) { + if (this.getEnergy() <= this.cost && this.canOpen()) { + if (this.getEnergy() > this.cost) { updateInventory = true; } } - if (isBurning() && canOpen()) { - updateState(); + if (this.isBurning() && this.canOpen()) { + 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.canOpen() && !world.isRemote) { - int random = new Random().nextInt(ScrapboxList.stacks.size()); - ItemStack out = ScrapboxList.stacks.get(random).copy(); - if (getStackInSlot(output) == null) { - useEnergy(cost); - setInventorySlotContents(output, out); + if (this.canOpen() && !this.world.isRemote) { + final int random = new Random().nextInt(ScrapboxList.stacks.size()); + final ItemStack out = ScrapboxList.stacks.get(random).copy(); + if (this.getStackInSlot(this.output) == null) { + this.useEnergy(this.cost); + this.setInventorySlotContents(this.output, out); } - 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 canOpen() { - return getStackInSlot(input1) != ItemStack.EMPTY && getStackInSlot(output) == ItemStack.EMPTY; + return this.getStackInSlot(this.input1) != ItemStack.EMPTY && this.getStackInSlot(this.output) == ItemStack.EMPTY; } public boolean isBurning() { - return getEnergy() > cost; + return this.getEnergy() > this.cost; } public void updateState() { - IBlockState blockState = world.getBlockState(pos); + final IBlockState blockState = this.world.getBlockState(this.pos); if (blockState.getBlock() instanceof BlockMachineBase) { - BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock(); - if (blockState.getValue(BlockMachineBase.ACTIVE) != progress > 0) - blockMachineBase.setActive(progress > 0, world, pos); + final BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock(); + if (blockState.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(); } @@ -124,7 +130,7 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.SCRAPBOXINATOR, 1); } @@ -134,12 +140,12 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable // ISidedInventory @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 }; } @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; if (slotIndex == 1) { @@ -147,26 +153,26 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable return true; } } - 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 == 2; } @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; } @@ -187,6 +193,23 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable @Override public Inventory getInventory() { - return inventory; + return this.inventory; + } + + public int getProgress() { + return this.progress; + } + + public void setProgress(final int progress) { + this.progress = progress; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("scrapboxinator").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).filterSlot(0, 56, 34, stack -> stack.getItem() == ModItems.SCRAP_BOX) + .outputSlot(1, 116, 34).upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44) + .upgradeSlot(5, 152, 62).syncEnergyValue().syncIntegerValue(this::getProgress, this::setProgress) + .addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/TileTechStorageBase.java b/src/main/java/techreborn/tiles/TileTechStorageBase.java index d209bc3c2..407c67193 100644 --- a/src/main/java/techreborn/tiles/TileTechStorageBase.java +++ b/src/main/java/techreborn/tiles/TileTechStorageBase.java @@ -9,9 +9,7 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.wrapper.InvWrapper; - import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; - import reborncore.api.IListInfoProvider; import reborncore.api.tile.IInventoryProvider; import reborncore.common.IWrenchable; @@ -23,14 +21,12 @@ import java.util.ArrayList; import java.util.List; public class TileTechStorageBase extends TileLegacyMachineBase - implements IInventoryProvider, IWrenchable, IListInfoProvider, IDeepStorageUnit { - - public InvWrapper invWrapper; - - public ItemStack storedItem; + implements IInventoryProvider, IWrenchable, IListInfoProvider, IDeepStorageUnit { public final int maxCapacity; public final Inventory inventory; + public InvWrapper invWrapper; + public ItemStack storedItem; public TileTechStorageBase(String name, int maxCapacity) { this.maxCapacity = maxCapacity; @@ -43,7 +39,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase if (!world.isRemote) { if (this.getStackInSlot(0) != ItemStack.EMPTY) { if (this.getStoredItemType().isEmpty() || (this.storedItem.isEmpty() - && ItemUtils.isItemEqual(this.getStackInSlot(0), this.getStackInSlot(1), true, true))) { + && ItemUtils.isItemEqual(this.getStackInSlot(0), this.getStackInSlot(1), true, true))) { this.storedItem = this.getStackInSlot(0); this.setInventorySlotContents(0, ItemStack.EMPTY); @@ -70,10 +66,10 @@ public class TileTechStorageBase extends TileLegacyMachineBase this.setInventorySlotContents(1, delivered); this.syncWithAll(); } else if (ItemUtils.isItemEqual(this.storedItem, this.getStackInSlot(1), true, true) - && this.getStackInSlot(1).getCount() < this.getStackInSlot(1).getMaxStackSize()) { + && this.getStackInSlot(1).getCount() < this.getStackInSlot(1).getMaxStackSize()) { int wanted = Math.min(this.storedItem.getCount(), - this.getStackInSlot(1).getMaxStackSize() - this.getStackInSlot(1).getCount()); + this.getStackInSlot(1).getMaxStackSize() - this.getStackInSlot(1).getCount()); this.getStackInSlot(1).setCount(this.getStackInSlot(1).getCount() + wanted); this.storedItem.shrink(wanted); @@ -83,28 +79,13 @@ public class TileTechStorageBase extends TileLegacyMachineBase this.syncWithAll(); } } - - if (this.getStackInSlot(2) == ItemStack.EMPTY - && (!this.storedItem.isEmpty() || !this.getStackInSlot(1).isEmpty())) { - - ItemStack fake = storedItem.isEmpty() ? this.getStackInSlot(1).copy() : storedItem.copy(); - fake.setCount(1); - - this.setInventorySlotContents(2, fake); - } else if (!ItemUtils.isItemEqual(this.getStackInSlot(2), this.storedItem, true, true)) { - - ItemStack fake = storedItem.isEmpty() ? this.getStackInSlot(1).copy() : storedItem.copy(); - fake.setCount(1); - - this.setInventorySlotContents(2, fake); - } } } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { world.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), - getPos().getY(), getPos().getZ()); + getPos().getY(), getPos().getZ()); readFromNBT(packet.getNbtCompound()); } @@ -259,7 +240,8 @@ public class TileTechStorageBase extends TileLegacyMachineBase @Override public boolean hasCapability(final net.minecraftforge.common.capabilities.Capability capability, - @javax.annotation.Nullable final net.minecraft.util.EnumFacing facing) { + @javax.annotation.Nullable + final net.minecraft.util.EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } diff --git a/src/main/java/techreborn/tiles/fusionReactor/TileEntityFusionController.java b/src/main/java/techreborn/tiles/fusionReactor/TileEntityFusionController.java index be9088032..8009c8d09 100644 --- a/src/main/java/techreborn/tiles/fusionReactor/TileEntityFusionController.java +++ b/src/main/java/techreborn/tiles/fusionReactor/TileEntityFusionController.java @@ -1,20 +1,26 @@ package techreborn.tiles.fusionReactor; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; + import reborncore.api.power.EnumPowerTier; import reborncore.api.tile.IInventoryProvider; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.Inventory; import reborncore.common.util.ItemUtils; + import techreborn.api.reactor.FusionReactorRecipe; import techreborn.api.reactor.FusionReactorRecipeHelper; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -public class TileEntityFusionController extends TilePowerAcceptor implements IInventoryProvider { +public class TileEntityFusionController extends TilePowerAcceptor implements IInventoryProvider, IContainerProvider { public Inventory inventory = new Inventory(3, "TileEntityFusionController", 64, this); @@ -39,18 +45,18 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(final EnumFacing direction) { return !(direction == EnumFacing.DOWN || direction == EnumFacing.UP); } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(final EnumFacing direction) { return direction == EnumFacing.DOWN || direction == EnumFacing.UP; } @Override public double getMaxOutput() { - if (!hasStartedCrafting) { + if (!this.hasStartedCrafting) { return 0; } return 1000000; @@ -58,7 +64,7 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn @Override public double getMaxInput() { - if (hasStartedCrafting) { + if (this.hasStartedCrafting) { return 0; } return 8192; @@ -70,68 +76,68 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); - crafingTickTime = tagCompound.getInteger("crafingTickTime"); - finalTickTime = tagCompound.getInteger("finalTickTime"); - neededPower = tagCompound.getInteger("neededPower"); - hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting"); + this.crafingTickTime = tagCompound.getInteger("crafingTickTime"); + this.finalTickTime = tagCompound.getInteger("finalTickTime"); + this.neededPower = tagCompound.getInteger("neededPower"); + this.hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting"); } @Override - public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); - if (crafingTickTime == -1) { - crafingTickTime = 0; + if (this.crafingTickTime == -1) { + this.crafingTickTime = 0; } - if (finalTickTime == -1) { - finalTickTime = 0; + if (this.finalTickTime == -1) { + this.finalTickTime = 0; } - if (neededPower == -1) { - neededPower = 0; + if (this.neededPower == -1) { + this.neededPower = 0; } - tagCompound.setInteger("crafingTickTime", crafingTickTime); - tagCompound.setInteger("finalTickTime", finalTickTime); - tagCompound.setInteger("neededPower", neededPower); - tagCompound.setBoolean("hasStartedCrafting", hasStartedCrafting); + tagCompound.setInteger("crafingTickTime", this.crafingTickTime); + tagCompound.setInteger("finalTickTime", this.finalTickTime); + tagCompound.setInteger("neededPower", this.neededPower); + tagCompound.setBoolean("hasStartedCrafting", this.hasStartedCrafting); return tagCompound; } public boolean checkCoils() { - if ((isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ() + 1)) - && (isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ())) - && (isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ() - 1)) - && (isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ() + 1)) - && (isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ())) - && (isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ() - 1)) - && (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() + 2)) - && (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() + 1)) - && (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() - 1)) - && (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() - 2)) - && (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() + 2)) - && (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() + 1)) - && (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() - 1)) - && (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() - 2)) - && (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() + 3)) - && (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() + 2)) - && (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() - 2)) - && (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() - 3)) - && (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() + 3)) - && (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() + 2)) - && (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() - 2)) - && (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() - 3)) - && (isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() + 3)) - && (isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() - 3))) { - coilStatus = 1; + if (this.isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ() + 1) + && this.isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ()) + && this.isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ() - 1) + && this.isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ() + 1) + && this.isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ()) + && this.isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ() - 1) + && this.isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() + 2) + && this.isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() + 1) + && this.isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() - 1) + && this.isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() - 2) + && this.isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() + 2) + && this.isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() + 1) + && this.isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() - 1) + && this.isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() - 2) + && this.isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() + 3) + && this.isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() + 2) + && this.isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() - 2) + && this.isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() - 3) + && this.isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() + 3) + && this.isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() + 2) + && this.isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() - 2) + && this.isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() - 3) + && this.isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() + 3) + && this.isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() - 3)) { + this.coilStatus = 1; return true; } - coilStatus = 0; + this.coilStatus = 0; return false; } - private boolean isCoil(int x, int y, int z) { - return world.getBlockState(new BlockPos(x, y, z)).getBlock() == ModBlocks.FUSION_COIL; + private boolean isCoil(final int x, final int y, final int z) { + return this.world.getBlockState(new BlockPos(x, y, z)).getBlock() == ModBlocks.FUSION_COIL; } @Override @@ -139,104 +145,104 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn super.updateEntity(); // TODO improve this code a lot - if (world.getTotalWorldTime() % 20 == 0) { - checkCoils(); + if (this.world.getTotalWorldTime() % 20 == 0) { + this.checkCoils(); } - if (!world.isRemote) { - if (coilStatus == 1) { - if (currentRecipe == null) { - if (inventory.hasChanged || crafingTickTime != 0) { - for (FusionReactorRecipe reactorRecipe : FusionReactorRecipeHelper.reactorRecipes) { - if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), reactorRecipe.getTopInput(), true, - true, true)) { + if (!this.world.isRemote) { + if (this.coilStatus == 1) { + if (this.currentRecipe == null) { + if (this.inventory.hasChanged || this.crafingTickTime != 0) { + for (final FusionReactorRecipe reactorRecipe : FusionReactorRecipeHelper.reactorRecipes) { + if (ItemUtils.isItemEqual(this.getStackInSlot(this.topStackSlot), reactorRecipe.getTopInput(), true, + true, true)) { if (reactorRecipe.getBottomInput() != null) { - if (!ItemUtils.isItemEqual(getStackInSlot(bottomStackSlot), - reactorRecipe.getBottomInput(), true, true, true)) { + if (!ItemUtils.isItemEqual(this.getStackInSlot(this.bottomStackSlot), + reactorRecipe.getBottomInput(), true, true, true)) { break; } } - if (canFitStack(reactorRecipe.getOutput(), outputStackSlot, true)) { - currentRecipe = reactorRecipe; - if (crafingTickTime != 0) { - finalTickTime = currentRecipe.getTickTime(); - neededPower = (int) currentRecipe.getStartEU(); + if (this.canFitStack(reactorRecipe.getOutput(), this.outputStackSlot, true)) { + this.currentRecipe = reactorRecipe; + if (this.crafingTickTime != 0) { + this.finalTickTime = this.currentRecipe.getTickTime(); + this.neededPower = (int) this.currentRecipe.getStartEU(); } - hasStartedCrafting = false; - crafingTickTime = 0; - finalTickTime = currentRecipe.getTickTime(); - neededPower = (int) currentRecipe.getStartEU(); + this.hasStartedCrafting = false; + this.crafingTickTime = 0; + this.finalTickTime = this.currentRecipe.getTickTime(); + this.neededPower = (int) this.currentRecipe.getStartEU(); break; } } } } } else { - if (inventory.hasChanged) { - if (!validateRecipe()) { - resetCrafter(); + if (this.inventory.hasChanged) { + if (!this.validateRecipe()) { + this.resetCrafter(); return; } } - if (!hasStartedCrafting) { - if (canUseEnergy(currentRecipe.getStartEU() + 64)) { - useEnergy(currentRecipe.getStartEU()); - hasStartedCrafting = true; + if (!this.hasStartedCrafting) { + if (this.canUseEnergy(this.currentRecipe.getStartEU() + 64)) { + this.useEnergy(this.currentRecipe.getStartEU()); + this.hasStartedCrafting = true; } } else { - if (crafingTickTime < currentRecipe.getTickTime()) { - if (currentRecipe.getEuTick() > 0) { // Power gen - addEnergy(currentRecipe.getEuTick()); // Waste + if (this.crafingTickTime < this.currentRecipe.getTickTime()) { + if (this.currentRecipe.getEuTick() > 0) { // Power gen + this.addEnergy(this.currentRecipe.getEuTick()); // Waste // power // if it // has // no // where // to go - crafingTickTime++; + this.crafingTickTime++; } else { // Power user - if (canUseEnergy(currentRecipe.getEuTick() * -1)) { - setEnergy(getEnergy() - (currentRecipe.getEuTick() * -1)); - crafingTickTime++; + if (this.canUseEnergy(this.currentRecipe.getEuTick() * -1)) { + this.setEnergy(this.getEnergy() - this.currentRecipe.getEuTick() * -1); + this.crafingTickTime++; } } } else { - if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) { - if (getStackInSlot(outputStackSlot) == ItemStack.EMPTY) { - setInventorySlotContents(outputStackSlot, currentRecipe.getOutput().copy()); + if (this.canFitStack(this.currentRecipe.getOutput(), this.outputStackSlot, true)) { + if (this.getStackInSlot(this.outputStackSlot) == ItemStack.EMPTY) { + this.setInventorySlotContents(this.outputStackSlot, this.currentRecipe.getOutput().copy()); } else { - decrStackSize(outputStackSlot, -currentRecipe.getOutput().getCount()); + this.decrStackSize(this.outputStackSlot, -this.currentRecipe.getOutput().getCount()); } - decrStackSize(topStackSlot, currentRecipe.getTopInput().getCount()); - if (currentRecipe.getBottomInput() != ItemStack.EMPTY) { - decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().getCount()); + this.decrStackSize(this.topStackSlot, this.currentRecipe.getTopInput().getCount()); + if (this.currentRecipe.getBottomInput() != ItemStack.EMPTY) { + this.decrStackSize(this.bottomStackSlot, this.currentRecipe.getBottomInput().getCount()); } - resetCrafter(); + this.resetCrafter(); } } } } } else { - if (currentRecipe != null) { - resetCrafter(); + if (this.currentRecipe != null) { + this.resetCrafter(); } } } - if (inventory.hasChanged) { - inventory.hasChanged = false; + if (this.inventory.hasChanged) { + this.inventory.hasChanged = false; } } private boolean validateRecipe() { - if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), currentRecipe.getTopInput(), true, true, true)) { - if (currentRecipe.getBottomInput() != null) { - if (!ItemUtils.isItemEqual(getStackInSlot(bottomStackSlot), currentRecipe.getBottomInput(), true, true, - true)) { + if (ItemUtils.isItemEqual(this.getStackInSlot(this.topStackSlot), this.currentRecipe.getTopInput(), true, true, true)) { + if (this.currentRecipe.getBottomInput() != null) { + if (!ItemUtils.isItemEqual(this.getStackInSlot(this.bottomStackSlot), this.currentRecipe.getBottomInput(), true, true, + true)) { return false; } } - if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) { + if (this.canFitStack(this.currentRecipe.getOutput(), this.outputStackSlot, true)) { return true; } } @@ -244,22 +250,22 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn } private void resetCrafter() { - currentRecipe = null; - crafingTickTime = -1; - finalTickTime = -1; - neededPower = -1; - hasStartedCrafting = false; + this.currentRecipe = null; + this.crafingTickTime = -1; + this.finalTickTime = -1; + this.neededPower = -1; + this.hasStartedCrafting = false; } - public boolean canFitStack(ItemStack stack, int slot, boolean oreDic) {// Checks to see if it can fit the stack + public boolean canFitStack(final ItemStack stack, final int slot, final boolean oreDic) {// Checks to see if it can fit the stack if (stack == ItemStack.EMPTY) { return true; } - if (inventory.getStackInSlot(slot) == ItemStack.EMPTY) { + if (this.inventory.getStackInSlot(slot) == ItemStack.EMPTY) { return true; } - if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic)) { - if (stack.getCount() + inventory.getStackInSlot(slot).getCount() <= stack.getMaxStackSize()) { + if (ItemUtils.isItemEqual(this.inventory.getStackInSlot(slot), stack, true, true, oreDic)) { + if (stack.getCount() + this.inventory.getStackInSlot(slot).getCount() <= stack.getMaxStackSize()) { return true; } } @@ -283,6 +289,53 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn @Override public Inventory getInventory() { - return inventory; + return this.inventory; + } + + public int getCoilStatus() { + return this.coilStatus; + } + + public void setCoilStatus(final int coilStatus) { + this.coilStatus = coilStatus; + } + + public int getCrafingTickTime() { + return this.crafingTickTime; + } + + public void setCrafingTickTime(final int crafingTickTime) { + this.crafingTickTime = crafingTickTime; + } + + public int getFinalTickTime() { + return this.finalTickTime; + } + + public void setFinalTickTime(final int finalTickTime) { + this.finalTickTime = finalTickTime; + } + + public int getNeededPower() { + return this.neededPower; + } + + public void setNeededPower(final int neededPower) { + this.neededPower = neededPower; + } + + public int getProgressScaled() { + return Math.max(0, Math.min(24, (this.getCrafingTickTime() > 0 ? 1 : 0) + + this.getCrafingTickTime() * 24 / (this.finalTickTime < 1 ? 1 : this.finalTickTime))); + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("fusionreactor").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 88, 17).slot(1, 88, 53).outputSlot(2, 148, 35).syncEnergyValue() + .syncIntegerValue(this::getCoilStatus, this::setCoilStatus) + .syncIntegerValue(this::getCrafingTickTime, this::setCrafingTickTime) + .syncIntegerValue(this::getFinalTickTime, this::setFinalTickTime) + .syncIntegerValue(this::getNeededPower, this::setNeededPower).addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/generator/TileDieselGenerator.java b/src/main/java/techreborn/tiles/generator/TileDieselGenerator.java index e386b68fa..3154cae9f 100644 --- a/src/main/java/techreborn/tiles/generator/TileDieselGenerator.java +++ b/src/main/java/techreborn/tiles/generator/TileDieselGenerator.java @@ -2,12 +2,17 @@ package techreborn.tiles.generator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; + import reborncore.api.power.EnumPowerTier; + import techreborn.api.generator.EFluidGenerator; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; -public class TileDieselGenerator extends TileBaseFluidGenerator { +public class TileDieselGenerator extends TileBaseFluidGenerator implements IContainerProvider { public TileDieselGenerator() { super(EFluidGenerator.DIESEL, ConfigTechReborn.ThermalGeneratorTier, "TileDieselGenerator", 1000 * 10, @@ -15,7 +20,7 @@ public class TileDieselGenerator extends TileBaseFluidGenerator { } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.DIESEL_GENERATOR, 1); } @@ -33,4 +38,11 @@ public class TileDieselGenerator extends TileBaseFluidGenerator { public EnumPowerTier getTier() { return EnumPowerTier.LOW; } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("dieselgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue() + .addInventory().create(); + } } diff --git a/src/main/java/techreborn/tiles/generator/TileGasTurbine.java b/src/main/java/techreborn/tiles/generator/TileGasTurbine.java index ef4e2db84..2d731e384 100644 --- a/src/main/java/techreborn/tiles/generator/TileGasTurbine.java +++ b/src/main/java/techreborn/tiles/generator/TileGasTurbine.java @@ -2,19 +2,24 @@ package techreborn.tiles.generator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; + import reborncore.api.power.EnumPowerTier; + import techreborn.api.generator.EFluidGenerator; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; -public class TileGasTurbine extends TileBaseFluidGenerator { +public class TileGasTurbine extends TileBaseFluidGenerator implements IContainerProvider { public TileGasTurbine() { super(EFluidGenerator.GAS, ConfigTechReborn.ThermalGeneratorTier, "TileGasTurbine", 1000 * 10, 16); } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.GAS_TURBINE, 1); } @@ -27,4 +32,11 @@ public class TileGasTurbine extends TileBaseFluidGenerator { public double getMaxPower() { return ConfigTechReborn.ThermalGeneratorCharge; } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("gasturbine").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue() + .addInventory().create(); + } } diff --git a/src/main/java/techreborn/tiles/generator/TileGenerator.java b/src/main/java/techreborn/tiles/generator/TileGenerator.java index 6b3e5a192..23b4a5ce5 100644 --- a/src/main/java/techreborn/tiles/generator/TileGenerator.java +++ b/src/main/java/techreborn/tiles/generator/TileGenerator.java @@ -13,9 +13,12 @@ import reborncore.common.IWrenchable; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.Inventory; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IInventoryProvider { +public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IContainerProvider { public static int outputAmount = 10; public Inventory inventory = new Inventory(2, "TileGenerator", 64, this); public int fuelSlot = 0; @@ -31,69 +34,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(); } @@ -104,16 +107,16 @@ public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IIn @Override public double getMaxPower() { - return 100; + return 10000; } @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 +136,40 @@ 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); + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("generator").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).fuelSlot(0, 80, 54).energySlot(1, 8, 72).syncEnergyValue() + .syncIntegerValue(this::getBurnTime, this::setBurnTime) + .syncIntegerValue(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/generator/TileSemifluidGenerator.java b/src/main/java/techreborn/tiles/generator/TileSemifluidGenerator.java index ac1949eb5..0e1d5b964 100644 --- a/src/main/java/techreborn/tiles/generator/TileSemifluidGenerator.java +++ b/src/main/java/techreborn/tiles/generator/TileSemifluidGenerator.java @@ -2,19 +2,24 @@ package techreborn.tiles.generator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; + import reborncore.api.power.EnumPowerTier; + import techreborn.api.generator.EFluidGenerator; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; -public class TileSemifluidGenerator extends TileBaseFluidGenerator { +public class TileSemifluidGenerator extends TileBaseFluidGenerator implements IContainerProvider { public TileSemifluidGenerator() { super(EFluidGenerator.SEMIFLUID, ConfigTechReborn.ThermalGeneratorTier, "TileSemifluidGenerator", 1000 * 10, 8); } @Override - public ItemStack getWrenchDrop(EntityPlayer arg0) { + public ItemStack getWrenchDrop(final EntityPlayer arg0) { return new ItemStack(ModBlocks.SEMIFLUID_GENERATOR, 1); } @@ -27,4 +32,11 @@ public class TileSemifluidGenerator extends TileBaseFluidGenerator { public double getMaxPower() { return ConfigTechReborn.ThermalGeneratorCharge; } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("semifluidgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue() + .addInventory().create(); + } } diff --git a/src/main/java/techreborn/tiles/generator/TileThermalGenerator.java b/src/main/java/techreborn/tiles/generator/TileThermalGenerator.java index e0c8a2018..865401c5c 100644 --- a/src/main/java/techreborn/tiles/generator/TileThermalGenerator.java +++ b/src/main/java/techreborn/tiles/generator/TileThermalGenerator.java @@ -5,13 +5,18 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; + import reborncore.api.power.EnumPowerTier; import reborncore.common.util.FluidUtils; + import techreborn.api.generator.EFluidGenerator; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; -public class TileThermalGenerator extends TileBaseFluidGenerator { +public class TileThermalGenerator extends TileBaseFluidGenerator implements IContainerProvider { public TileThermalGenerator() { super(EFluidGenerator.THERMAL, ConfigTechReborn.ThermalGeneratorTier, "TileThermalGenerator", 1000 * 10, @@ -19,7 +24,7 @@ public class TileThermalGenerator extends TileBaseFluidGenerator { } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.THERMAL_GENERATOR, 1); } @@ -28,7 +33,7 @@ public class TileThermalGenerator extends TileBaseFluidGenerator { super.updateEntity(); if (!this.world.isRemote) { - if (acceptFluid() && FluidUtils.drainContainers(this.tank, this.inventory, 0, 1)) + if (this.acceptFluid() && FluidUtils.drainContainers(this.tank, this.inventory, 0, 1)) this.syncWithAll(); for (final EnumFacing direction : EnumFacing.values()) { if (this.world @@ -57,4 +62,11 @@ public class TileThermalGenerator extends TileBaseFluidGenerator { public EnumPowerTier getTier() { return EnumPowerTier.LOW; } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("thermalgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue() + .addInventory().create(); + } } diff --git a/src/main/java/techreborn/tiles/multiblock/TileBlastFurnace.java b/src/main/java/techreborn/tiles/multiblock/TileBlastFurnace.java index 512465283..af10a6485 100644 --- a/src/main/java/techreborn/tiles/multiblock/TileBlastFurnace.java +++ b/src/main/java/techreborn/tiles/multiblock/TileBlastFurnace.java @@ -1,7 +1,6 @@ package techreborn.tiles.multiblock; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; @@ -9,6 +8,7 @@ import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; + import reborncore.api.power.EnumPowerTier; import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.tile.IInventoryProvider; @@ -18,16 +18,21 @@ import reborncore.common.multiblock.IMultiblockPart; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; + import techreborn.api.Reference; import techreborn.api.recipe.ITileRecipeHandler; import techreborn.api.recipe.machines.BlastFurnaceRecipe; import techreborn.blocks.BlockMachineCasing; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; import techreborn.multiblocks.MultiBlockCasing; import techreborn.tiles.TileMachineCasing; -public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, ITileRecipeHandler, IRecipeCrafterProvider { +public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, + ITileRecipeHandler, IRecipeCrafterProvider, IContainerProvider { public static int euTick = 5; public int tickTime; @@ -35,36 +40,38 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable, public RecipeCrafter crafter; public int capacity = 1000; + private int cachedHeat; + public TileBlastFurnace() { super(ConfigTechReborn.CentrifugeTier); // TODO configs - int[] inputs = new int[2]; + final int[] inputs = new int[2]; inputs[0] = 0; inputs[1] = 1; - int[] outputs = new int[2]; + final int[] outputs = new int[2]; outputs[0] = 2; outputs[1] = 3; - crafter = new RecipeCrafter(Reference.blastFurnaceRecipe, this, 2, 2, inventory, inputs, outputs); + this.crafter = new RecipeCrafter(Reference.blastFurnaceRecipe, this, 2, 2, this.inventory, inputs, outputs); } @Override public void updateEntity() { super.updateEntity(); - crafter.updateEntity(); + this.crafter.updateEntity(); } @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(); } @@ -74,39 +81,39 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable, } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.INDUSTRIAL_BLAST_FURNACE, 1); } public int getHeat() { - for (EnumFacing direction : EnumFacing.values()) { - TileEntity tileEntity = world.getTileEntity(new BlockPos(getPos().getX() + direction.getFrontOffsetX(), - getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ())); + for (final EnumFacing direction : EnumFacing.values()) { + final TileEntity tileEntity = this.world.getTileEntity(new BlockPos(this.getPos().getX() + direction.getFrontOffsetX(), + this.getPos().getY() + direction.getFrontOffsetY(), this.getPos().getZ() + direction.getFrontOffsetZ())); if (tileEntity instanceof TileMachineCasing) { if (((TileMachineCasing) tileEntity).isConnected() - && ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled()) { - MultiBlockCasing casing = ((TileMachineCasing) tileEntity).getMultiblockController(); - Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction); + && ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled()) { + final MultiBlockCasing casing = ((TileMachineCasing) tileEntity).getMultiblockController(); + final Location location = new Location(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), direction); location.modifyPositionFromSide(direction, 1); int heat = 0; - if (world.getBlockState(new BlockPos(location.getX(), location.getY() - 1, location.getZ())) - .getBlock() == tileEntity.getBlockType()) { + if (this.world.getBlockState(new BlockPos(location.getX(), location.getY() - 1, location.getZ())) + .getBlock() == tileEntity.getBlockType()) { return 0; } - for (IMultiblockPart part : casing.connectedParts) { - BlockMachineCasing casing1 = (BlockMachineCasing) world.getBlockState(part.getPos()) - .getBlock(); + for (final IMultiblockPart part : casing.connectedParts) { + final BlockMachineCasing casing1 = (BlockMachineCasing) this.world.getBlockState(part.getPos()) + .getBlock(); heat += casing1 - .getHeatFromState(part.getWorld().getBlockState(part.getWorldLocation().toBlockPos())); + .getHeatFromState(part.getWorld().getBlockState(part.getWorldLocation().toBlockPos())); // TODO meta fix } - if (world.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ())) - .getBlock().getUnlocalizedName().equals("tile.lava") - && world - .getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ())) - .getBlock().getUnlocalizedName().equals("tile.lava")) { + if (this.world.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ())) + .getBlock().getUnlocalizedName().equals("tile.lava") + && this.world + .getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ())) + .getBlock().getUnlocalizedName().equals("tile.lava")) { heat += 500; } return heat; @@ -117,50 +124,50 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable, } @Override - public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { - world.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), - getPos().getY(), getPos().getZ()); - readFromNBT(packet.getNbtCompound()); + public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) { + this.world.markBlockRangeForRenderUpdate(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.getPos().getX(), + this.getPos().getY(), this.getPos().getZ()); + this.readFromNBT(packet.getNbtCompound()); } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); - tickTime = tagCompound.getInteger("tickTime"); + this.tickTime = tagCompound.getInteger("tickTime"); } @Override - public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); - writeUpdateToNBT(tagCompound); + this.writeUpdateToNBT(tagCompound); return tagCompound; } - public void writeUpdateToNBT(NBTTagCompound tagCompound) { - tagCompound.setInteger("tickTime", tickTime); + public void writeUpdateToNBT(final NBTTagCompound tagCompound) { + tagCompound.setInteger("tickTime", this.tickTime); } // ISidedInventory @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3 } : new int[] { 0, 1, 2, 3 }; } @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 == 2 || slotIndex == 3; } - 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; } @@ -171,12 +178,12 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable, } @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; } @@ -196,26 +203,42 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable, } @Override - public boolean canCraft(TileEntity tile, BlastFurnaceRecipe recipe) { + public boolean canCraft(final TileEntity tile, final BlastFurnaceRecipe recipe) { if (tile instanceof TileBlastFurnace) { - TileBlastFurnace blastFurnace = (TileBlastFurnace) tile; + final TileBlastFurnace blastFurnace = (TileBlastFurnace) tile; return blastFurnace.getHeat() >= recipe.neededHeat; } return false; } @Override - public boolean onCraft(TileEntity tile, BlastFurnaceRecipe recipe) { + public boolean onCraft(final TileEntity tile, final BlastFurnaceRecipe recipe) { return true; } @Override public Inventory getInventory() { - return inventory; + return this.inventory; } @Override public RecipeCrafter getRecipeCrafter() { - return crafter; + return this.crafter; + } + + public void setHeat(final int heat) { + this.cachedHeat = heat; + } + + public int getCachedHeat() { + return this.cachedHeat; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("blastfurnace").player(player.inventory).inventory().hotbar() + .addInventory().tile(this).slot(0, 50, 27).slot(1, 50, 47).outputSlot(2, 92, 36).outputSlot(3, 110, 36) + .syncEnergyValue().syncCrafterValue().syncIntegerValue(this::getHeat, this::setHeat).addInventory() + .create(); } } diff --git a/src/main/java/techreborn/tiles/multiblock/TileImplosionCompressor.java b/src/main/java/techreborn/tiles/multiblock/TileImplosionCompressor.java index 099cbd994..4e8672b0e 100644 --- a/src/main/java/techreborn/tiles/multiblock/TileImplosionCompressor.java +++ b/src/main/java/techreborn/tiles/multiblock/TileImplosionCompressor.java @@ -1,11 +1,11 @@ package techreborn.tiles.multiblock; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; + import reborncore.api.power.EnumPowerTier; import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.tile.IInventoryProvider; @@ -13,13 +13,15 @@ import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; + import techreborn.api.Reference; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -import static techreborn.tiles.multiblock.MultiblockChecker.CASING_REINFORCED; -import static techreborn.tiles.multiblock.MultiblockChecker.ZERO_OFFSET; - -public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider { +public class TileImplosionCompressor extends TilePowerAcceptor + implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider { public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64, this); public MultiblockChecker multiblockChecker; @@ -27,29 +29,29 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc public TileImplosionCompressor() { super(2); - int[] inputs = new int[] { 0, 1 }; - int[] outputs = new int[] { 2, 3 }; - crafter = new RecipeCrafter(Reference.implosionCompressorRecipe, this, 2, 2, inventory, inputs, outputs); + final int[] inputs = new int[] { 0, 1 }; + final int[] outputs = new int[] { 2, 3 }; + this.crafter = new RecipeCrafter(Reference.implosionCompressorRecipe, this, 2, 2, this.inventory, inputs, outputs); } @Override public void validate() { super.validate(); - multiblockChecker = new MultiblockChecker(world, getPos().down(3)); + this.multiblockChecker = new MultiblockChecker(this.world, this.getPos().down(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(); } @@ -59,56 +61,56 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.IMPLOSION_COMPRESSOR, 1); } public boolean getMutliBlock() { - boolean down = multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, ZERO_OFFSET); - boolean up = multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, new BlockPos(0, 2, 0)); - boolean chamber = multiblockChecker.checkRingYHollow(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0)); + final boolean down = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_REINFORCED, MultiblockChecker.ZERO_OFFSET); + final boolean up = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_REINFORCED, new BlockPos(0, 2, 0)); + final boolean chamber = this.multiblockChecker.checkRingYHollow(1, 1, MultiblockChecker.CASING_REINFORCED, new BlockPos(0, 1, 0)); return down && chamber && up; } @Override public void update() { super.update(); - if (getMutliBlock()) { - crafter.updateEntity(); + if (this.getMutliBlock()) { + this.crafter.updateEntity(); } } @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; } @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return new int[] { 0, 1, 2, 3 }; } @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 || index == 1; } @Override - public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { + public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) { return index == 2 || index == 3; } - 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; } @@ -119,12 +121,12 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc } @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; } @@ -145,12 +147,19 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc @Override public Inventory getInventory() { - return inventory; + return this.inventory; } @Override public RecipeCrafter getRecipeCrafter() { - return crafter; + return this.crafter; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("implosioncompressor").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 37, 26).slot(1, 37, 44).outputSlot(2, 93, 35).outputSlot(3, 111, 35) + .syncEnergyValue().syncCrafterValue().addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/multiblock/TileIndustrialGrinder.java b/src/main/java/techreborn/tiles/multiblock/TileIndustrialGrinder.java index 2829a07f8..01a7be173 100644 --- a/src/main/java/techreborn/tiles/multiblock/TileIndustrialGrinder.java +++ b/src/main/java/techreborn/tiles/multiblock/TileIndustrialGrinder.java @@ -3,7 +3,6 @@ package techreborn.tiles.multiblock; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -12,6 +11,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; + import reborncore.api.power.EnumPowerTier; import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.tile.IInventoryProvider; @@ -21,22 +21,22 @@ import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.FluidUtils; import reborncore.common.util.Inventory; import reborncore.common.util.Tank; + import techreborn.api.Reference; import techreborn.api.recipe.ITileRecipeHandler; import techreborn.api.recipe.machines.IndustrialGrinderRecipe; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; -import static techreborn.tiles.multiblock.MultiblockChecker.CASING_NORMAL; -import static techreborn.tiles.multiblock.MultiblockChecker.CASING_REINFORCED; -import static techreborn.tiles.multiblock.MultiblockChecker.ZERO_OFFSET; - -public class TileIndustrialGrinder extends TilePowerAcceptor - implements IWrenchable, IInventoryProvider, ISidedInventory, ITileRecipeHandler, IRecipeCrafterProvider { +public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, +ITileRecipeHandler, IRecipeCrafterProvider, IContainerProvider { public static final int TANK_CAPACITY = 16000; public Inventory inventory = new Inventory(6, "TileGrinder", 64, this); - public Tank tank = new Tank("TileGrinder", TANK_CAPACITY, this); + public Tank tank = new Tank("TileGrinder", TileIndustrialGrinder.TANK_CAPACITY, this); public RecipeCrafter crafter; public MultiblockChecker multiblockChecker; @@ -44,29 +44,30 @@ public class TileIndustrialGrinder extends TilePowerAcceptor super(ConfigTechReborn.CentrifugeTier); // TODO configs - int[] inputs = new int[2]; + final int[] inputs = new int[2]; inputs[0] = 0; inputs[1] = 1; - int[] outputs = new int[4]; + final int[] outputs = new int[4]; outputs[0] = 2; outputs[1] = 3; outputs[2] = 4; outputs[3] = 5; - crafter = new RecipeCrafter(Reference.industrialGrinderRecipe, this, 1, 4, inventory, inputs, outputs); + this.crafter = new RecipeCrafter(Reference.industrialGrinderRecipe, this, 1, 4, this.inventory, inputs, + outputs); } @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(); } @@ -76,16 +77,19 @@ public class TileIndustrialGrinder extends TilePowerAcceptor } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.INDUSTRIAL_GRINDER, 1); } public boolean getMutliBlock() { - boolean down = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, ZERO_OFFSET); - boolean up = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, new BlockPos(0, 2, 0)); - boolean blade = multiblockChecker.checkRingY(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0)); - IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0); - boolean center = centerBlock.getBlock() == Blocks.WATER; + final boolean down = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_NORMAL, + MultiblockChecker.ZERO_OFFSET); + final boolean up = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_NORMAL, + new BlockPos(0, 2, 0)); + final boolean blade = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.CASING_REINFORCED, + new BlockPos(0, 1, 0)); + final IBlockState centerBlock = this.multiblockChecker.getBlock(0, 1, 0); + final boolean center = centerBlock.getBlock() == Blocks.WATER; return down && center && blade && up; } @@ -93,29 +97,29 @@ public class TileIndustrialGrinder extends TilePowerAcceptor public void update() { super.update(); - if (multiblockChecker == null) { - BlockPos pos = getPos().offset(getFacing().getOpposite(), 2).down(); - multiblockChecker = new MultiblockChecker(world, pos); + if (this.multiblockChecker == null) { + final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2).down(); + this.multiblockChecker = new MultiblockChecker(this.world, pos); } - if (getMutliBlock()) { - crafter.updateEntity(); + if (this.getMutliBlock()) { + this.crafter.updateEntity(); } - FluidUtils.drainContainers(tank, inventory, 1, 5); + FluidUtils.drainContainers(this.tank, this.inventory, 1, 5); } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); - tank.readFromNBT(tagCompound); - crafter.readFromNBT(tagCompound); + this.tank.readFromNBT(tagCompound); + this.crafter.readFromNBT(tagCompound); } @Override - public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); - tank.writeToNBT(tagCompound); - crafter.writeToNBT(tagCompound); + this.tank.writeToNBT(tagCompound); + this.crafter.writeToNBT(tagCompound); return tagCompound; } @@ -130,7 +134,7 @@ public class TileIndustrialGrinder extends TilePowerAcceptor } @Override - public boolean hasCapability(Capability capability, EnumFacing facing) { + public boolean hasCapability(final Capability capability, final EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return true; } @@ -138,34 +142,34 @@ public class TileIndustrialGrinder extends TilePowerAcceptor } @Override - public T getCapability(Capability capability, EnumFacing facing) { + public T getCapability(final Capability capability, final EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { - return (T) tank; + return (T) this.tank; } return super.getCapability(capability, facing); } // ISidedInventory @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 }; } @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 == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5; } - 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; } @@ -176,12 +180,12 @@ public class TileIndustrialGrinder extends TilePowerAcceptor } @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; } @@ -201,9 +205,9 @@ public class TileIndustrialGrinder extends TilePowerAcceptor } @Override - public boolean canCraft(TileEntity tile, IndustrialGrinderRecipe recipe) { - FluidStack recipeFluid = recipe.fluidStack; - FluidStack tankFluid = tank.getFluid(); + public boolean canCraft(final TileEntity tile, final IndustrialGrinderRecipe recipe) { + final FluidStack recipeFluid = recipe.fluidStack; + final FluidStack tankFluid = this.tank.getFluid(); if (recipe.fluidStack == null) { return true; } @@ -219,9 +223,9 @@ public class TileIndustrialGrinder extends TilePowerAcceptor } @Override - public boolean onCraft(TileEntity tile, IndustrialGrinderRecipe recipe) { - FluidStack recipeFluid = recipe.fluidStack; - FluidStack tankFluid = tank.getFluid(); + public boolean onCraft(final TileEntity tile, final IndustrialGrinderRecipe recipe) { + final FluidStack recipeFluid = recipe.fluidStack; + final FluidStack tankFluid = this.tank.getFluid(); if (recipe.fluidStack == null) { return true; } @@ -231,7 +235,7 @@ public class TileIndustrialGrinder extends TilePowerAcceptor if (tankFluid.isFluidEqual(recipeFluid)) { if (tankFluid.amount >= recipeFluid.amount) { if (tankFluid.amount == recipeFluid.amount) - tank.setFluid(null); + this.tank.setFluid(null); else tankFluid.amount -= recipeFluid.amount; return true; @@ -242,12 +246,20 @@ public class TileIndustrialGrinder extends TilePowerAcceptor @Override public Inventory getInventory() { - return inventory; + return this.inventory; } @Override public RecipeCrafter getRecipeCrafter() { - return crafter; + return this.crafter; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("industrialgrinder").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 32, 26).slot(1, 32, 44).outputSlot(2, 77, 35).outputSlot(3, 95, 35) + .outputSlot(4, 113, 35).outputSlot(5, 131, 35).syncEnergyValue().syncCrafterValue().addInventory() + .create(); } } diff --git a/src/main/java/techreborn/tiles/multiblock/TileIndustrialSawmill.java b/src/main/java/techreborn/tiles/multiblock/TileIndustrialSawmill.java index 86a98ad3e..05685f2b2 100644 --- a/src/main/java/techreborn/tiles/multiblock/TileIndustrialSawmill.java +++ b/src/main/java/techreborn/tiles/multiblock/TileIndustrialSawmill.java @@ -4,7 +4,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; @@ -12,7 +11,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.oredict.OreDictionary; -import reborncore.api.IListInfoProvider; + import reborncore.api.power.EnumPowerTier; import reborncore.api.tile.IInventoryProvider; import reborncore.common.IWrenchable; @@ -20,16 +19,17 @@ import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.FluidUtils; import reborncore.common.util.Inventory; import reborncore.common.util.Tank; + +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; import techreborn.items.ItemDusts; import java.util.Random; -import static techreborn.tiles.multiblock.MultiblockChecker.CASING_NORMAL; -import static techreborn.tiles.multiblock.MultiblockChecker.CASING_REINFORCED; -import static techreborn.tiles.multiblock.MultiblockChecker.ZERO_OFFSET; - -public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, IListInfoProvider { +public class TileIndustrialSawmill extends TilePowerAcceptor +implements IWrenchable, IInventoryProvider, IContainerProvider { public Inventory inventory = new Inventory(5, "Sawmill", 64, this); public Tank tank = new Tank("Sawmill", 16000, this); @@ -44,83 +44,84 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha @Override public void update() { super.update(); - if (getMutliBlock()) { - ItemStack wood = inventory.getStackInSlot(0); - if (tickTime == 0) { - if (wood != null) { - for (int id : OreDictionary.getOreIDs(wood)) { - String name = OreDictionary.getOreName(id); - if (name.equals("logWood") && - canAddOutput(2, 10) && - canAddOutput(3, 5) && - canAddOutput(4, 3) && - canUseEnergy(128.0F) && - !tank.isEmpty() && - tank.getFluid().amount >= 1000) { + + if (this.getMutliBlock()) { + final ItemStack wood = this.inventory.getStackInSlot(0); + if (this.tickTime == 0) { + if (!wood.isEmpty()) { + for (final int id : OreDictionary.getOreIDs(wood)) { + final String name = OreDictionary.getOreName(id); + if (name.equals("logWood") && this.canAddOutput(2, 10) && this.canAddOutput(3, 5) + && this.canAddOutput(4, 3) && this.canUseEnergy(128.0F) && !this.tank.isEmpty() + && this.tank.getFluid().amount >= 1000) { wood.shrink(1); if (wood.getCount() == 0) - setInventorySlotContents(0, ItemStack.EMPTY); - tank.drain(1000, true); - useEnergy(128.0F); - tickTime = 1; + this.setInventorySlotContents(0, ItemStack.EMPTY); + this.tank.drain(1000, true); + this.useEnergy(128.0F); + this.syncWithAll(); + this.tickTime = 1; } } } - } else if (++tickTime > 100) { - Random rnd = world.rand; - addOutput(2, new ItemStack(Blocks.PLANKS, 6 + rnd.nextInt(4))); + } else if (++this.tickTime > 100) { + final Random rnd = this.world.rand; + this.addOutput(2, new ItemStack(Blocks.PLANKS, 6 + rnd.nextInt(4))); if (rnd.nextInt(4) != 0) { - ItemStack pulp = ItemDusts.getDustByName("sawDust", 2 + rnd.nextInt(3)); - addOutput(3, pulp); + final ItemStack pulp = ItemDusts.getDustByName("sawDust", 2 + rnd.nextInt(3)); + this.addOutput(3, pulp); } if (rnd.nextInt(3) == 0) { - ItemStack paper = new ItemStack(Items.PAPER, 1 + rnd.nextInt(2)); - addOutput(4, paper); + final ItemStack paper = new ItemStack(Items.PAPER, 1 + rnd.nextInt(2)); + this.addOutput(4, paper); } - tickTime = 0; + this.tickTime = 0; } } - FluidUtils.drainContainers(tank, inventory, 1, 4); + FluidUtils.drainContainers(this.tank, this.inventory, 1, 4); } - public void addOutput(int slot, ItemStack stack) { - if (getStackInSlot(slot) == ItemStack.EMPTY) - setInventorySlotContents(slot, stack); - getStackInSlot(slot).grow(stack.getCount()); + public void addOutput(final int slot, final ItemStack stack) { + if (this.getStackInSlot(slot) == ItemStack.EMPTY) + this.setInventorySlotContents(slot, stack); + this.getStackInSlot(slot).grow(stack.getCount()); } - public boolean canAddOutput(int slot, int amount) { - ItemStack stack = getStackInSlot(slot); - return stack == ItemStack.EMPTY || getInventoryStackLimit() - stack.getCount() >= amount; + public boolean canAddOutput(final int slot, final int amount) { + final ItemStack stack = this.getStackInSlot(slot); + return stack == ItemStack.EMPTY || this.getInventoryStackLimit() - stack.getCount() >= amount; } @Override public void validate() { super.validate(); - multiblockChecker = new MultiblockChecker(world, getPos().down(3)); + this.multiblockChecker = new MultiblockChecker(this.world, this.getPos().down(3)); } public boolean getMutliBlock() { - boolean down = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, ZERO_OFFSET); - boolean up = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, new BlockPos(0, 2, 0)); - boolean blade = multiblockChecker.checkRingY(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0)); - IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0); - boolean center = centerBlock.getBlock() == Blocks.WATER; + final boolean down = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_NORMAL, + MultiblockChecker.ZERO_OFFSET); + final boolean up = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_NORMAL, + new BlockPos(0, 2, 0)); + final boolean blade = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.CASING_REINFORCED, + new BlockPos(0, 1, 0)); + final IBlockState centerBlock = this.multiblockChecker.getBlock(0, 1, 0); + final boolean center = centerBlock.getBlock() == Blocks.WATER; return down && center && blade && up; } @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(); } @@ -130,27 +131,27 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.INDUSTRIAL_SAWMILL, 1); } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); - tank.readFromNBT(tagCompound); - tickTime = tagCompound.getInteger("tickTime"); + this.tank.readFromNBT(tagCompound); + this.tickTime = tagCompound.getInteger("tickTime"); } @Override - public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); - tank.writeToNBT(tagCompound); - tagCompound.setInteger("tickTime", tickTime); + this.tank.writeToNBT(tagCompound); + tagCompound.setInteger("tickTime", this.tickTime); return tagCompound; } @Override - public boolean hasCapability(Capability capability, EnumFacing facing) { + public boolean hasCapability(final Capability capability, final EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return true; } @@ -158,31 +159,31 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha } @Override - public T getCapability(Capability capability, EnumFacing facing) { + public T getCapability(final Capability capability, final EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { - return (T) tank; + return (T) this.tank; } return super.getCapability(capability, facing); } @Override - public int[] getSlotsForFace(EnumFacing side) { + public int[] getSlotsForFace(final EnumFacing side) { return new int[] { 0, 2, 3, 4, 5 }; } @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 >= 2; } - public int getProgressScaled(int scale) { - if (tickTime != 0) { - return tickTime * scale / 100; + public int getProgressScaled(final int scale) { + if (this.tickTime != 0) { + return this.tickTime * scale / 100; } return 0; } @@ -193,12 +194,12 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha } @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; } @@ -219,7 +220,13 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha @Override public Inventory getInventory() { - return inventory; + return this.inventory; } + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("industrialsawmill").player(player.inventory).inventory(8, 84).hotbar(8, 142) + .addInventory().tile(this).slot(0, 32, 26).slot(1, 32, 44).outputSlot(2, 84, 35).outputSlot(3, 102, 35) + .outputSlot(4, 120, 35).syncEnergyValue().addInventory().create(); + } } diff --git a/src/main/java/techreborn/tiles/multiblock/TileVacuumFreezer.java b/src/main/java/techreborn/tiles/multiblock/TileVacuumFreezer.java index e92b690b9..d2e42dd86 100644 --- a/src/main/java/techreborn/tiles/multiblock/TileVacuumFreezer.java +++ b/src/main/java/techreborn/tiles/multiblock/TileVacuumFreezer.java @@ -1,10 +1,10 @@ package techreborn.tiles.multiblock; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; 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.IInventoryProvider; @@ -12,13 +12,15 @@ import reborncore.common.IWrenchable; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; + import techreborn.api.Reference; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -import static techreborn.tiles.multiblock.MultiblockChecker.CASING_REINFORCED; -import static techreborn.tiles.multiblock.MultiblockChecker.ZERO_OFFSET; - -public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, ISidedInventory { +public class TileVacuumFreezer extends TilePowerAcceptor + implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider { public Inventory inventory = new Inventory(3, "TileVacuumFreezer", 64, this); public MultiblockChecker multiblockChecker; @@ -26,26 +28,26 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, public TileVacuumFreezer() { super(2); - int[] inputs = new int[] { 0 }; - int[] outputs = new int[] { 1 }; - crafter = new RecipeCrafter(Reference.vacuumFreezerRecipe, this, 2, 1, inventory, inputs, outputs); + final int[] inputs = new int[] { 0 }; + final int[] outputs = new int[] { 1 }; + this.crafter = new RecipeCrafter(Reference.vacuumFreezerRecipe, this, 2, 1, this.inventory, inputs, outputs); } @Override public void validate() { super.validate(); - multiblockChecker = new MultiblockChecker(world, getPos().down()); + this.multiblockChecker = new MultiblockChecker(this.world, this.getPos().down()); } @Override public void update() { super.update(); - if (getMultiBlock()) - crafter.updateEntity(); + if (this.getMultiBlock()) + this.crafter.updateEntity(); } public boolean getMultiBlock() { - return multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, ZERO_OFFSET); + return this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_REINFORCED, MultiblockChecker.ZERO_OFFSET); } @Override @@ -54,12 +56,12 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, } @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; } @@ -79,17 +81,17 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, } @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(); } @@ -99,53 +101,60 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.ALLOY_SMELTER, 1); } @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 Inventory getInventory() { - return inventory; + return this.inventory; } @Override public RecipeCrafter getRecipeCrafter() { - return crafter; + return this.crafter; } @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; } + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("vacuumfreezer").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).syncEnergyValue().syncCrafterValue().addInventory() + .create(); + } + } diff --git a/src/main/java/techreborn/tiles/storage/TileBatBox.java b/src/main/java/techreborn/tiles/storage/TileBatBox.java index d43b16dea..49319df82 100644 --- a/src/main/java/techreborn/tiles/storage/TileBatBox.java +++ b/src/main/java/techreborn/tiles/storage/TileBatBox.java @@ -1,22 +1,24 @@ package techreborn.tiles.storage; -import reborncore.api.IListInfoProvider; +import net.minecraft.entity.player.EntityPlayer; import reborncore.api.power.EnumPowerTier; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -import java.util.List; - /** * Created by modmuss50 on 14/03/2016. */ -public class TileBatBox extends TileEnergyStorage implements IListInfoProvider { +public class TileBatBox extends TileEnergyStorage implements IContainerProvider { public TileBatBox() { super("BatBox", 2, ModBlocks.BATTERY_BOX, EnumPowerTier.LOW, 32, 32, 40000); } @Override - public void addInfo(List info, boolean isRealTile) { - info.add("Batbox"); + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("batbox").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/storage/TileMFE.java b/src/main/java/techreborn/tiles/storage/TileMFE.java index 282ad8581..5c759eb60 100644 --- a/src/main/java/techreborn/tiles/storage/TileMFE.java +++ b/src/main/java/techreborn/tiles/storage/TileMFE.java @@ -1,15 +1,26 @@ package techreborn.tiles.storage; +import net.minecraft.entity.player.EntityPlayer; import reborncore.api.power.EnumPowerTier; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; /** * Created by modmuss50 on 14/03/2016. */ -public class TileMFE extends TileEnergyStorage { +public class TileMFE extends TileEnergyStorage implements IContainerProvider { public TileMFE() { super("MFE", 2, ModBlocks.MVSU, EnumPowerTier.MEDIUM, 512, 512, 600000); } + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("mfe").player(player.inventory).inventory().hotbar().armor() + .complete(8, 18).addArmor().addInventory().tile(this).energySlot(0, 62, 45).energySlot(1, 98, 45) + .syncEnergyValue().addInventory().create(); + } + } \ No newline at end of file diff --git a/src/main/java/techreborn/tiles/storage/TileMFSU.java b/src/main/java/techreborn/tiles/storage/TileMFSU.java index 5bb232a85..726b0a700 100644 --- a/src/main/java/techreborn/tiles/storage/TileMFSU.java +++ b/src/main/java/techreborn/tiles/storage/TileMFSU.java @@ -1,14 +1,25 @@ package techreborn.tiles.storage; +import net.minecraft.entity.player.EntityPlayer; import reborncore.api.power.EnumPowerTier; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; /** * Created by modmuss50 on 14/03/2016. */ -public class TileMFSU extends TileEnergyStorage { +public class TileMFSU extends TileEnergyStorage implements IContainerProvider { public TileMFSU() { super("MFSU", 2, ModBlocks.HVSU, EnumPowerTier.HIGH, 2048, 2048, 1000000); } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("mfsu").player(player.inventory).inventory().hotbar().armor() + .complete(8, 18).addArmor().addInventory().tile(this).energySlot(0, 62, 45).energySlot(1, 98, 45) + .syncEnergyValue().addInventory().create(); + } } \ No newline at end of file diff --git a/src/main/java/techreborn/tiles/teir1/TileCompressor.java b/src/main/java/techreborn/tiles/teir1/TileCompressor.java index a50129ae9..c63fff7b2 100644 --- a/src/main/java/techreborn/tiles/teir1/TileCompressor.java +++ b/src/main/java/techreborn/tiles/teir1/TileCompressor.java @@ -1,7 +1,6 @@ package techreborn.tiles.teir1; 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; @@ -12,10 +11,13 @@ import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; import techreborn.api.Reference; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; import techreborn.utils.upgrade.UpgradeHandler; -public class TileCompressor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, ISidedInventory { +public class TileCompressor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider { public Inventory inventory = new Inventory(6, "TileCompressor", 64, this); @@ -26,32 +28,34 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II public TileCompressor() { super(1); - int[] inputs = new int[] { 0 }; - int[] outputs = new int[] { 1 }; - crafter = new RecipeCrafter(Reference.compressorRecipe, this, 2, 1, inventory, inputs, outputs); - upgradeHandler = new UpgradeHandler(crafter, inventory, 2, 3, 4, 5); + final int[] inputs = new int[] { 0 }; + final int[] outputs = new int[] { 1 }; + this.crafter = new RecipeCrafter(Reference.compressorRecipe, 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); + if (!this.world.isRemote) { + super.update(); + 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(); } @@ -61,7 +65,7 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { return new ItemStack(ModBlocks.COMPRESSOR, 1); } @@ -71,39 +75,43 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II // ISidedInventory @Override - public int[] getSlotsForFace(EnumFacing side) { - return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 }; + public int[] getSlotsForFace(final EnumFacing side) { + if (side.equals(EnumFacing.UP)) + return new int[] { 0 }; + else if (side.equals(EnumFacing.DOWN)) + return new int[] { 1 }; + return new int[0]; } @Override - public boolean canInsertItem(int Index, ItemStack itemStack, EnumFacing side) { + public boolean canInsertItem(final int Index, final ItemStack itemStack, final EnumFacing side) { return Index == 0; } @Override - public boolean canExtractItem(int Index, ItemStack itemStack, EnumFacing side) { + public boolean canExtractItem(final int Index, final ItemStack itemStack, final EnumFacing side) { return Index == 1; } - 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; } @@ -124,11 +132,18 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II @Override public Inventory getInventory() { - return inventory; + return this.inventory; } @Override public RecipeCrafter getRecipeCrafter() { - return crafter; + return this.crafter; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("compressor").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).syncEnergyValue().syncCrafterValue().addInventory() + .create(); } } diff --git a/src/main/java/techreborn/tiles/teir1/TileElectricFurnace.java b/src/main/java/techreborn/tiles/teir1/TileElectricFurnace.java index 217500567..00d776643 100644 --- a/src/main/java/techreborn/tiles/teir1/TileElectricFurnace.java +++ b/src/main/java/techreborn/tiles/teir1/TileElectricFurnace.java @@ -2,19 +2,24 @@ package techreborn.tiles.teir1; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; -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.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory { +public class TileElectricFurnace extends TilePowerAcceptor + implements IWrenchable, IInventoryProvider, IContainerProvider { public Inventory inventory = new Inventory(6, "TileElectricFurnace", 64, this); public int capacity = 1000; @@ -23,86 +28,85 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl public int cost = 8; int input1 = 0; int output = 1; - private static final int[] SLOTS_TOP = new int[] { 0 }; - private static final int[] SLOTS_BOTTOM = new int[] { 1 }; - private static final int[] SLOTS_SIDES = new int[] { 1 }; public TileElectricFurnace() { 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(); - boolean updateInventory = false; - if (isBurning() && canSmelt()) { - updateState(); + if (!this.world.isRemote) { + super.update(); - progress++; - if (progress % 10 == 0) { - useEnergy(cost); + final boolean burning = this.isBurning(); + boolean updateInventory = false; + if (this.isBurning() && this.canSmelt()) { + this.updateState(); + + this.progress++; + if (this.progress % 10 == 0) { + this.useEnergy(this.cost); + } + if (this.progress >= this.fuelScale) { + this.progress = 0; + this.cookItems(); + updateInventory = true; + } + } else { + this.progress = 0; + this.updateState(); } - if (progress >= fuelScale) { - progress = 0; - cookItems(); + if (burning != this.isBurning()) { updateInventory = true; } - } else { - progress = 0; - updateState(); - } - if (burning != isBurning()) { - updateInventory = true; - } - if (updateInventory) { - markDirty(); + if (updateInventory) { + 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)); - if (itemstack == ItemStack.EMPTY) - return false; - if (getStackInSlot(output) == ItemStack.EMPTY) - return true; - if (!getStackInSlot(output).isItemEqual(itemstack)) - return false; - int result = getStackInSlot(output).getCount() + itemstack.getCount(); - return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } + final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1)); + if (itemstack == ItemStack.EMPTY) + return false; + if (this.getStackInSlot(this.output) == ItemStack.EMPTY) + return true; + if (!this.getStackInSlot(this.output).isItemEqual(itemstack)) + return false; + 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 +114,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 +143,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 +153,38 @@ 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) { + if (side.equals(EnumFacing.UP)) + return new int[] { 0 }; + else if (side.equals(EnumFacing.DOWN)) + return new int[] { 1 }; + return new int[0]; } @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 +205,21 @@ 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; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("electricfurnace").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).syncEnergyValue() + .syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create(); } } diff --git a/src/main/java/techreborn/tiles/teir1/TileExtractor.java b/src/main/java/techreborn/tiles/teir1/TileExtractor.java index 44256aec5..0fec7d940 100644 --- a/src/main/java/techreborn/tiles/teir1/TileExtractor.java +++ b/src/main/java/techreborn/tiles/teir1/TileExtractor.java @@ -6,19 +6,20 @@ 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.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; 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, IContainerProvider { public Inventory inventory = new Inventory(6, "TileExtractor", 64, this); @@ -29,34 +30,36 @@ 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); + if (!this.world.isRemote) { + super.update(); + 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 +69,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 +78,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,32 +129,38 @@ 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); + public int[] getSlotsForFace(final EnumFacing side) { + if (side.equals(EnumFacing.UP)) + return new int[] { 0 }; + else if (side.equals(EnumFacing.DOWN)) + return new int[] { 1 }; + return new int[0]; } @Override - public int[] getSlotsForFace(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; } + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("extractor").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).syncEnergyValue().syncCrafterValue().addInventory() + .create(); + } + } diff --git a/src/main/java/techreborn/tiles/teir1/TileGrinder.java b/src/main/java/techreborn/tiles/teir1/TileGrinder.java index 59065045d..1fd823dbc 100644 --- a/src/main/java/techreborn/tiles/teir1/TileGrinder.java +++ b/src/main/java/techreborn/tiles/teir1/TileGrinder.java @@ -1,29 +1,29 @@ package techreborn.tiles.teir1; import net.minecraft.entity.player.EntityPlayer; -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.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; 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 { +public class TileGrinder extends TilePowerAcceptor +implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider { public Inventory inventory = new Inventory(6, "TileGrinder", 64, this); @@ -34,34 +34,36 @@ 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(); - //charge(3); TODO - charge(3); + public void update() { + if (!this.world.isRemote) { + super.update(); + this.upgradeHandler.tick(); + //charge(3); TODO + 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 +73,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 +82,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 +133,43 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInve } @Override - public void addInfo(List info, boolean isRealTile) { + public void addInfo(final List 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); + public int[] getSlotsForFace(final EnumFacing side) { + if (side.equals(EnumFacing.UP)) + return new int[] { 0 }; + else if (side.equals(EnumFacing.DOWN)) + return new int[] { 1 }; + return new int[0]; } @Override - public int[] getSlotsForFace(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; } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("grinder").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).syncEnergyValue().syncCrafterValue().addInventory() + .create(); + } } diff --git a/src/main/java/techreborn/tiles/teir1/TileRecycler.java b/src/main/java/techreborn/tiles/teir1/TileRecycler.java index d45fc7cd3..1802a3499 100644 --- a/src/main/java/techreborn/tiles/teir1/TileRecycler.java +++ b/src/main/java/techreborn/tiles/teir1/TileRecycler.java @@ -2,7 +2,6 @@ package techreborn.tiles.teir1; import net.minecraft.block.state.IBlockState; 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; @@ -11,126 +10,112 @@ import reborncore.common.IWrenchable; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.Inventory; +import techreborn.client.container.IContainerProvider; +import techreborn.client.container.builder.BuiltContainer; +import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; import techreborn.items.ItemParts; -public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory { +public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IContainerProvider { - public Inventory inventory = new Inventory(6, "TileRecycler", 64, this); - public int capacity = 1000; - public int cost = 20; - public int progress; - public int time = 200; - public int chance = 4; - public int random; - public int input1 = 0; - public int output = 1; + private final Inventory inventory = new Inventory(6, "TileRecycler", 64, this); + private final int capacity = 1000; + private final int cost = 2; + private final int time = 15; + private final int chance = 6; + private boolean isBurning; + private int progress; public TileRecycler() { 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(); - boolean updateInventory = false; - if (getEnergy() <= cost && canRecycle()) { - if (getEnergy() > cost) { - updateInventory = true; - } - } - if (isBurning() && canRecycle()) { - updateState(); - progress++; - if (progress >= time) { - progress = 0; - recycleItems(); + boolean updateInventory = false; + if (this.canRecycle() && !this.isBurning() && this.getEnergy() != 0) + this.setBurning(true); + else if (this.isBurning()) { + if (this.useEnergy(this.cost) != this.cost) + this.setBurning(false); + this.progress++; + if (this.progress >= this.time) { + this.progress = 0; + this.recycleItems(); updateInventory = true; + this.setBurning(false); } - } else { - progress = 0; - updateState(); - } - if (burning != isBurning()) { - updateInventory = true; } + + this.updateState(); + 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 (randomchance == 1) { - setInventorySlotContents(output, itemstack.copy()); - } - } else if (getStackInSlot(output).isItemEqual(itemstack)) { - useEnergy(cost); - if (randomchance == 1) { - getStackInSlot(output).setCount(itemstack.getCount()); - } - } - if (getStackInSlot(input1).getCount() > 1) { - useEnergy(cost); - this.decrStackSize(input1, 1); - } else { - useEnergy(cost); - setInventorySlotContents(input1, ItemStack.EMPTY); - } + if (randomchance == 1) { + if (this.getStackInSlot(1).isEmpty()) + this.setInventorySlotContents(1, itemstack.copy()); + else + this.getStackInSlot(1).grow(itemstack.getCount()); } + this.decrStackSize(0, 1); } public boolean canRecycle() { - return getStackInSlot(input1) != null && hasSlotGotSpace(output); + return this.getStackInSlot(0) != ItemStack.EMPTY && this.hasSlotGotSpace(1); } - 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.isBurning; + } + + public void setBurning(final boolean burning) { + this.isBurning = burning; } 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.isBurning) + blockMachineBase.setActive(this.isBurning, 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 +125,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 +135,38 @@ 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) { + if (side.equals(EnumFacing.UP)) + return new int[] { 0 }; + else if (side.equals(EnumFacing.DOWN)) + return new int[] { 1 }; + return new int[0]; } @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 == 1) 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 == 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; } @@ -198,6 +187,21 @@ 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; + } + + @Override + public BuiltContainer createContainer(final EntityPlayer player) { + return new ContainerBuilder("recycler").player(player.inventory).inventory().hotbar().addInventory() + .tile(this).slot(0, 55, 45).slot(1, 101, 45).syncEnergyValue() + .syncIntegerValue(this::getProgress, this::setProgress).addInventory().create(); } } diff --git a/src/main/resources/assets/techreborn/blockstates/items/misc/upgrades.json b/src/main/resources/assets/techreborn/blockstates/items/misc/upgrades.json index af5cac1d5..147fed2d3 100644 --- a/src/main/resources/assets/techreborn/blockstates/items/misc/upgrades.json +++ b/src/main/resources/assets/techreborn/blockstates/items/misc/upgrades.json @@ -20,6 +20,11 @@ "textures": { "layer0": "techreborn:items/upgrade/energy_storage_upgrade" } + }, + "range": { + "textures": { + "layer0": "techreborn:items/upgrade/range_upgrade" + } } } } diff --git a/src/main/resources/assets/techreborn/lang/en_us.lang b/src/main/resources/assets/techreborn/lang/en_us.lang index 78d901d8b..7353696ab 100644 --- a/src/main/resources/assets/techreborn/lang/en_us.lang +++ b/src/main/resources/assets/techreborn/lang/en_us.lang @@ -16,7 +16,7 @@ tile.techreborn.rollingmachine.name=Rolling Machine tile.techreborn.machineCasing.standard.name=Standard Machine Casing tile.techreborn.machineCasing.reinforced.name=Reinforced Machine Casing tile.techreborn.machineCasing.advanced.name=Advanced Machine Casing -tile.techreborn.blastfurnace.name=Industrial Blast Furnace +tile.techreborn.blastfurnace.name=Blast Furnace tile.techreborn.alloysmelter.name=Electric Alloy Furnace tile.techreborn.matterfabricator.name=Matter Fabricator tile.techreborn.implosioncompressor.name=Implosion Compressor @@ -381,6 +381,7 @@ item.techreborn.nanosaber.name=Nanosaber item.techreborn.upgrade.overclock.name=Overclocker Upgrade item.techreborn.upgrade.transformer.name=Tranformer Upgrade item.techreborn.upgrade.energy_storage.name=Energy Storage Upgrade +item.techreborn.upgrade.range.name=Range Upgrade item.techreborn.electric_treetap.name=Electric Treetap #Gems diff --git a/src/main/resources/assets/techreborn/textures/blocks/fluids/wolframium_flowing.png b/src/main/resources/assets/techreborn/textures/blocks/fluids/wolframium_flowing.png deleted file mode 100644 index e433795bf..000000000 Binary files a/src/main/resources/assets/techreborn/textures/blocks/fluids/wolframium_flowing.png and /dev/null differ diff --git a/src/main/resources/assets/techreborn/textures/gui/centrifuge.png b/src/main/resources/assets/techreborn/textures/gui/centrifuge.png deleted file mode 100644 index a1f11c512..000000000 Binary files a/src/main/resources/assets/techreborn/textures/gui/centrifuge.png and /dev/null differ diff --git a/src/main/resources/assets/techreborn/textures/gui/gui_sheet.png b/src/main/resources/assets/techreborn/textures/gui/gui_sheet.png new file mode 100644 index 000000000..b56382f1c Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/gui/gui_sheet.png differ diff --git a/src/main/resources/assets/techreborn/textures/gui/guisheet.png b/src/main/resources/assets/techreborn/textures/gui/guisheet.png deleted file mode 100644 index 90818f092..000000000 Binary files a/src/main/resources/assets/techreborn/textures/gui/guisheet.png and /dev/null differ diff --git a/src/main/resources/assets/techreborn/textures/gui/jei.png b/src/main/resources/assets/techreborn/textures/gui/jei.png new file mode 100644 index 000000000..c76f62e9c Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/gui/jei.png differ diff --git a/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_chest.png b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_chest.png new file mode 100644 index 000000000..ae52fd808 Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_chest.png differ diff --git a/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_feet.png b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_feet.png new file mode 100644 index 000000000..774a41471 Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_feet.png differ diff --git a/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_head.png b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_head.png new file mode 100644 index 000000000..d2d2f4df1 Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_head.png differ diff --git a/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_legs.png b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_legs.png new file mode 100644 index 000000000..6ebae576a Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_legs.png differ diff --git a/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_offhand.png b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_offhand.png new file mode 100644 index 000000000..fb4f1b387 Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/armour_offhand.png differ diff --git a/src/main/resources/assets/techreborn/textures/gui/slot_sprites/cells.png b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/cells.png new file mode 100644 index 000000000..c68c624d8 Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/cells.png differ diff --git a/src/main/resources/assets/techreborn/textures/gui/slot_sprites/upgrade.png b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/upgrade.png new file mode 100644 index 000000000..0f69c497b Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/gui/slot_sprites/upgrade.png differ diff --git a/src/main/resources/assets/techreborn/textures/items/upgrade/range_upgrade.png b/src/main/resources/assets/techreborn/textures/items/upgrade/range_upgrade.png new file mode 100644 index 000000000..abcaf37d5 Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/items/upgrade/range_upgrade.png differ