From 0669f5eb9d5029a8b94ec552171b0837605f7747 Mon Sep 17 00:00:00 2001 From: draknyte1 Date: Fri, 4 Nov 2016 15:23:26 +1000 Subject: $ Cleaned up the entire project. > Much neat, very nices. --- .../core/block/machine/BlockGtFrameBox.java | 33 +- .../core/block/machine/Machine_Charger.java | 126 +-- .../gtPlusPlus/core/block/machine/Machine_NHG.java | 126 +-- .../core/block/machine/Machine_WireiusDeletus.java | 3 +- .../core/block/machine/Machine_Workbench.java | 121 ++- .../block/machine/Machine_WorkbenchAdvanced.java | 82 +- .../machine/heliumgen/block/HeliumGenerator.java | 270 +++---- .../container/ContainerHeliumGenerator.java | 64 +- .../machine/heliumgen/gui/GUIHeliumGenerator.java | 104 +-- .../machine/heliumgen/slots/InvSlotRadiation.java | 88 +-- .../tileentity/TileEntityHeliumGenerator.java | 845 ++++++++++----------- 11 files changed, 898 insertions(+), 964 deletions(-) (limited to 'src/Java/gtPlusPlus/core/block/machine') diff --git a/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java index 6de87e522b..dbbc91c902 100644 --- a/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java +++ b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java @@ -8,27 +8,26 @@ import net.minecraft.world.IBlockAccess; public class BlockGtFrameBox extends MetaBlock { - private int[] colours; - private int totalColours; - - public BlockGtFrameBox( - String unlocalizedName, Material material, - BlockTypes blockTypeENUM, boolean recolour, int... colour) { + private int[] colours; + private int totalColours; + + public BlockGtFrameBox(final String unlocalizedName, final Material material, final BlockTypes blockTypeENUM, + final boolean recolour, final int... colour) { super(unlocalizedName, material, blockTypeENUM.getBlockSoundType()); - this.setBlockTextureName(CORE.MODID + ":" + "blockGtFrame"); - this.setHarvestLevel(blockTypeENUM.getHarvestTool(), 2); - if (recolour && (colour != null && colour.length > 0)){ - colours = colour; - totalColours = colours.length; - } + this.setBlockTextureName(CORE.MODID + ":" + "blockGtFrame"); + this.setHarvestLevel(blockTypeENUM.getHarvestTool(), 2); + if (recolour && colour != null && colour.length > 0) { + this.colours = colour; + this.totalColours = this.colours.length; + } } @Override - public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, - int p_149720_3_, int p_149720_4_) { - for (int i : colours){ - - } + public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_, + final int p_149720_4_) { + for (final int i : this.colours) { + + } return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); } diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java index 43a38d0b52..e88c5c5b6b 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java @@ -16,67 +16,67 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import scala.util.Random; -public class Machine_Charger extends BlockContainer -{ - private static final String name = "Charging Machine"; - - private final Random rand = new Random(); - - public Machine_Charger(String unlocalizedName) - { - super(Material.iron); - //GameRegistry.registerBlock(this, unlocalizedName); - this.setBlockName(unlocalizedName); - this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMachines); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) - { - if (world.isRemote) return true; - - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TileEntityCharger) - { - player.openGui(GTplusplus.instance, 1, world, x, y, z); - return true; - } - return false; - } - - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int par6) - { - if (world.isRemote) return; - - ArrayList drops = new ArrayList(); - - TileEntity teRaw = world.getTileEntity(x, y, z); - - if (teRaw != null && teRaw instanceof TileEntityCharger) - { - TileEntityCharger te = (TileEntityCharger) teRaw; - - for (int i = 0; i < te.getSizeInventory(); i++) - { - ItemStack stack = te.getStackInSlot(i); - - if (stack != null) drops.add(stack.copy()); - } - } - - for (int i = 0;i < drops.size();i++) - { - EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, (ItemStack) drops.get(i)); - item.setVelocity((rand.nextDouble() - 0.5) * 0.25, rand.nextDouble() * 0.5 * 0.25, (rand.nextDouble() - 0.5) * 0.25); - world.spawnEntityInWorld(item); - } - } - - @Override - public TileEntity createNewTileEntity(World world, int par2) - { - return new TileEntityCharger(); - } +public class Machine_Charger extends BlockContainer { + private static final String name = "Charging Machine"; + + private final Random rand = new Random(); + + public Machine_Charger(final String unlocalizedName) { + super(Material.iron); + // GameRegistry.registerBlock(this, unlocalizedName); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, + final int par6) { + if (world.isRemote) { + return; + } + + final ArrayList drops = new ArrayList(); + + final TileEntity teRaw = world.getTileEntity(x, y, z); + + if (teRaw != null && teRaw instanceof TileEntityCharger) { + final TileEntityCharger te = (TileEntityCharger) teRaw; + + for (int i = 0; i < te.getSizeInventory(); i++) { + final ItemStack stack = te.getStackInSlot(i); + + if (stack != null) { + drops.add(stack.copy()); + } + } + } + + for (int i = 0; i < drops.size(); i++) { + final EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, (ItemStack) drops.get(i)); + item.setVelocity((this.rand.nextDouble() - 0.5) * 0.25, this.rand.nextDouble() * 0.5 * 0.25, + (this.rand.nextDouble() - 0.5) * 0.25); + world.spawnEntityInWorld(item); + } + } + + @Override + public TileEntity createNewTileEntity(final World world, final int par2) { + return new TileEntityCharger(); + } + + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float lx, final float ly, final float lz) { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TileEntityCharger) { + player.openGui(GTplusplus.instance, 1, world, x, y, z); + return true; + } + return false; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java b/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java index 72cfc91826..cfad3006b9 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java @@ -16,67 +16,67 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import scala.util.Random; -public class Machine_NHG extends BlockContainer -{ - private static final String name = "Nuclear Fueled Helium Generator"; - - private final Random rand = new Random(); - - public Machine_NHG(String unlocalizedName) - { - super(Material.iron); - //GameRegistry.registerBlock(this, unlocalizedName); - this.setBlockName(unlocalizedName); - this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMachines); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) - { - if (world.isRemote) return true; - - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TileEntityNHG) - { - player.openGui(GTplusplus.instance, 0, world, x, y, z); - return true; - } - return false; - } - - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int par6) - { - if (world.isRemote) return; - - ArrayList drops = new ArrayList(); - - TileEntity teRaw = world.getTileEntity(x, y, z); - - if (teRaw != null && teRaw instanceof TileEntityNHG) - { - TileEntityNHG te = (TileEntityNHG) teRaw; - - for (int i = 0; i < te.getSizeInventory(); i++) - { - ItemStack stack = te.getStackInSlot(i); - - if (stack != null) drops.add(stack.copy()); - } - } - - for (int i = 0;i < drops.size();i++) - { - EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, (ItemStack) drops.get(i)); - item.setVelocity((rand.nextDouble() - 0.5) * 0.25, rand.nextDouble() * 0.5 * 0.25, (rand.nextDouble() - 0.5) * 0.25); - world.spawnEntityInWorld(item); - } - } - - @Override - public TileEntity createNewTileEntity(World world, int par2) - { - return new TileEntityNHG(); - } +public class Machine_NHG extends BlockContainer { + private static final String name = "Nuclear Fueled Helium Generator"; + + private final Random rand = new Random(); + + public Machine_NHG(final String unlocalizedName) { + super(Material.iron); + // GameRegistry.registerBlock(this, unlocalizedName); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, + final int par6) { + if (world.isRemote) { + return; + } + + final ArrayList drops = new ArrayList(); + + final TileEntity teRaw = world.getTileEntity(x, y, z); + + if (teRaw != null && teRaw instanceof TileEntityNHG) { + final TileEntityNHG te = (TileEntityNHG) teRaw; + + for (int i = 0; i < te.getSizeInventory(); i++) { + final ItemStack stack = te.getStackInSlot(i); + + if (stack != null) { + drops.add(stack.copy()); + } + } + } + + for (int i = 0; i < drops.size(); i++) { + final EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, (ItemStack) drops.get(i)); + item.setVelocity((this.rand.nextDouble() - 0.5) * 0.25, this.rand.nextDouble() * 0.5 * 0.25, + (this.rand.nextDouble() - 0.5) * 0.25); + world.spawnEntityInWorld(item); + } + } + + @Override + public TileEntity createNewTileEntity(final World world, final int par2) { + return new TileEntityNHG(); + } + + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float lx, final float ly, final float lz) { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TileEntityNHG) { + player.openGui(GTplusplus.instance, 0, world, x, y, z); + return true; + } + return false; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java b/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java index e964a9da01..e881d40d35 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java @@ -1,5 +1,6 @@ package gtPlusPlus.core.block.machine; -public class Machine_WireiusDeletus { //A Block that removes GT Cable and Wire from it's inventory. +public class Machine_WireiusDeletus { // A Block that removes GT Cable and Wire + // from it's inventory. } diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java index 6827ec6741..1921aa8000 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -22,89 +22,84 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -public class Machine_Workbench extends BlockContainer -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; +public class Machine_Workbench extends BlockContainer { + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; - @SuppressWarnings("deprecation") - public Machine_Workbench() - { - super(Material.iron); - this.setBlockName("blockWorkbenchGT"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, "blockWorkbenchGT"); + @SuppressWarnings("deprecation") + public Machine_Workbench() { + super(Material.iron); + this.setBlockName("blockWorkbenchGT"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockWorkbenchGT"); LanguageRegistry.addName(this, "Bronze Workbench"); - - } - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int p_149691_2_) - { - return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : (p_149691_1_ != 2 && p_149691_1_ != 4 ? this.blockIcon : this.textureFront)); - } + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityWorkbench(); + } - @Override + /** + * Gets the block's texture. Args: side, meta + */ + @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_side_cabinet"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_top_crafting"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_side"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_side_cabinet"); - } + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 ? this.textureTop + : p_149691_1_ == 0 ? this.textureBottom + : p_149691_1_ != 2 && p_149691_1_ != 4 ? this.blockIcon : this.textureFront; + } - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) - { + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float lx, final float ly, final float lz) { ItemStack heldItem = null; - if (world.isRemote){ - heldItem = PlayerUtils.getItemStackInPlayersHand(); - } + if (world.isRemote) { + heldItem = PlayerUtils.getItemStackInPlayersHand(); + } boolean holdingWrench = false; - if (heldItem != null){ - if (heldItem.getItem() instanceof ItemToolWrench){ + if (heldItem != null) { + if (heldItem.getItem() instanceof ItemToolWrench) { holdingWrench = true; } - else if (heldItem.getItem() instanceof IToolWrench){ + else if (heldItem.getItem() instanceof IToolWrench) { holdingWrench = true; } - else if (heldItem.getItem() instanceof ITool){ + else if (heldItem.getItem() instanceof ITool) { holdingWrench = true; } - /*else if (heldItem.getItem() instanceof GT_MetaGenerated_Tool){ - GT_MetaGenerated_Tool testTool = (GT_MetaGenerated_Tool) heldItem.getItem(); - if (testTool.canWrench(player, x, y, z)){ - holdingWrench = true; - } - }*/ + /* + * else if (heldItem.getItem() instanceof GT_MetaGenerated_Tool){ + * GT_MetaGenerated_Tool testTool = (GT_MetaGenerated_Tool) + * heldItem.getItem(); if (testTool.canWrench(player, x, y, z)){ + * holdingWrench = true; } } + */ else { holdingWrench = false; } } - if (world.isRemote) return true; + if (world.isRemote) { + return true; + } - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TileEntityWorkbench) - { - if (!holdingWrench){ + final TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TileEntityWorkbench) { + if (!holdingWrench) { player.openGui(GTplusplus.instance, 3, world, x, y, z); - return true; + return true; } Utils.LOG_INFO("Holding a Wrench, doing wrench things instead."); } @@ -112,7 +107,11 @@ public class Machine_Workbench extends BlockContainer } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { - return new TileEntityWorkbench(); + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_side_cabinet"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_top_crafting"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_side"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "bronze_side_cabinet"); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java b/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java index 37b801836f..20d6c8601c 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java @@ -22,18 +22,16 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -public class Machine_WorkbenchAdvanced extends BlockContainer -{ +public class Machine_WorkbenchAdvanced extends BlockContainer { @SideOnly(Side.CLIENT) - private IIcon textureTop; + private IIcon textureTop; @SideOnly(Side.CLIENT) - private IIcon textureBottom; + private IIcon textureBottom; @SideOnly(Side.CLIENT) - private IIcon textureFront; + private IIcon textureFront; @SuppressWarnings("deprecation") - public Machine_WorkbenchAdvanced() - { + public Machine_WorkbenchAdvanced() { super(Material.iron); this.setBlockName("blockWorkbenchGTAdvanced"); this.setCreativeTab(AddToCreativeTab.tabMachines); @@ -42,65 +40,61 @@ public class Machine_WorkbenchAdvanced extends BlockContainer } - /** - * Gets the block's texture. Args: side, meta - */ @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int p_149691_2_) - { - return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : (p_149691_1_ != 2 && p_149691_1_ != 4 ? this.blockIcon : this.textureFront)); + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityWorkbenchAdvanced(128000, 2); } + /** + * Gets the block's texture. Args: side, meta + */ @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "cover_crafting"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 ? this.textureTop + : p_149691_1_ == 0 ? this.textureBottom + : p_149691_1_ != 2 && p_149691_1_ != 4 ? this.blockIcon : this.textureFront; } /** * Called upon block activation (right click on the block.) */ @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) - { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float lx, final float ly, final float lz) { - ItemStack heldItem = PlayerUtils.getItemStackInPlayersHand(player); - if (world.isRemote) return true; + final ItemStack heldItem = PlayerUtils.getItemStackInPlayersHand(player); + if (world.isRemote) { + return true; + } boolean holdingWrench = false; - if (heldItem != null){ - if (heldItem.getItem() instanceof ItemToolWrench){ + if (heldItem != null) { + if (heldItem.getItem() instanceof ItemToolWrench) { holdingWrench = true; } - else if (heldItem.getItem() instanceof IToolWrench){ + else if (heldItem.getItem() instanceof IToolWrench) { holdingWrench = true; } - else if (heldItem.getItem() instanceof ITool){ + else if (heldItem.getItem() instanceof ITool) { holdingWrench = true; } - /*else if (heldItem.getItem() instanceof GT_MetaGenerated_Tool){ - GT_MetaGenerated_Tool testTool = (GT_MetaGenerated_Tool) heldItem.getItem(); - if (testTool.canWrench(player, x, y, z)){ - holdingWrench = true; - } - }*/ + /* + * else if (heldItem.getItem() instanceof GT_MetaGenerated_Tool){ + * GT_MetaGenerated_Tool testTool = (GT_MetaGenerated_Tool) + * heldItem.getItem(); if (testTool.canWrench(player, x, y, z)){ + * holdingWrench = true; } } + */ else { holdingWrench = false; } } - - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TileEntityWorkbenchAdvanced) - { - if (!holdingWrench){ + final TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TileEntityWorkbenchAdvanced) { + if (!holdingWrench) { player.openGui(GTplusplus.instance, 4, world, x, y, z); - return true; + return true; } Utils.LOG_INFO("Holding a Wrench, doing wrench things instead."); } @@ -108,7 +102,11 @@ public class Machine_WorkbenchAdvanced extends BlockContainer } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { - return new TileEntityWorkbenchAdvanced(128000, 2); + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "cover_crafting"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java index e83e189ddf..19e9b09e8f 100644 --- a/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java @@ -25,140 +25,142 @@ import net.minecraft.world.World; public class HeliumGenerator extends BlockContainer { - private IIcon top, sides, front; - private Random randy = new Random(); - - public HeliumGenerator(){ - super(Material.iron); - setStepSound(Block.soundTypeMetal); - setHardness(20.0F); - setBlockName("helium_collector"); - setHarvestLevel("pickaxe", 3); - setCreativeTab(AddToCreativeTab.tabMachines); - } - - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons (IIconRegister iconRegister) - { - this.top = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_SIDE"); - this.sides = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_SIDE"); - this.front = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_FRONT"); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ - if(side == 1) - return top; - int facing = 2; - TileEntityHeliumGenerator machine = (TileEntityHeliumGenerator)world.getTileEntity(x, y, z); - if(machine != null) - facing = machine.getFacing(); - if(side == facing) - return front; - else - return sides; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon (int side, int metadata) - { - if(side == 1) - return top; - if(side == 3) - return front; - return sides; - } - - @Override - public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) - { - if (world.isRemote) - { - return true; - } + private IIcon top, sides, front; + private final Random randy = new Random(); + + public HeliumGenerator() { + super(Material.iron); + this.setStepSound(Block.soundTypeMetal); + this.setHardness(20.0F); + this.setBlockName("helium_collector"); + this.setHarvestLevel("pickaxe", 3); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int wut) { + final TileEntityHeliumGenerator collector = (TileEntityHeliumGenerator) world.getTileEntity(x, y, z); + + if (collector != null) { + int i = 0; + for (i = 0; i < collector.getSizeInventory(); i++) { + + final ItemStack itemstack = collector.getStackInSlot(i); + + if (itemstack != null) { + final float f = this.randy.nextFloat() * 0.8F + 0.1F; + final float f1 = this.randy.nextFloat() * 0.8F + 0.1F; + final float f2 = this.randy.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) { + int j1 = this.randy.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + final EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, + new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + + if (itemstack.hasTagCompound()) { + entityitem.getEntityItem() + .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); + } + + final float f3 = 0.05F; + entityitem.motionX = (float) this.randy.nextGaussian() * f3; + entityitem.motionY = (float) this.randy.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) this.randy.nextGaussian() * f3; + world.spawnEntityInWorld(entityitem); + } + } + + world.func_147453_f(x, y, z, block); + } + } + + super.breakBlock(world, x, y, z, block, wut); + } + + @Override + public TileEntity createNewTileEntity(final World world, final int meta) { + return new TileEntityHeliumGenerator(); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final IBlockAccess world, final int x, final int y, final int z, final int side) { + if (side == 1) { + return this.top; + } + int facing = 2; + final TileEntityHeliumGenerator machine = (TileEntityHeliumGenerator) world.getTileEntity(x, y, z); + if (machine != null) { + facing = machine.getFacing(); + } + if (side == facing) { + return this.front; + } + else { + return this.sides; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int side, final int metadata) { + if (side == 1) { + return this.top; + } + if (side == 3) { + return this.front; + } + return this.sides; + } + + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int par6, final float par7, final float par8, final float par9) { + if (world.isRemote) { + return true; + } player.openGui(GTplusplus.instance, 2, world, x, y, z); return true; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) - { - return new TileEntityHeliumGenerator(); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack item) - { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile instanceof TileEntityHeliumGenerator) { - TileEntityHeliumGenerator machine = (TileEntityHeliumGenerator)tile; - int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - - if (l == 0) - machine.setFacing((short) 2); - - if (l == 1) - machine.setFacing((short) 5); - - if (l == 2) - machine.setFacing((short) 3); - - if (l == 3) - machine.setFacing((short) 4); - } - - } - - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int wut) - { - TileEntityHeliumGenerator collector = (TileEntityHeliumGenerator)world.getTileEntity(x, y, z); - - if (collector != null) - { - int i = 0; - for (i = 0; i < collector.getSizeInventory(); i++){ - - ItemStack itemstack = collector.getStackInSlot(i); - - if (itemstack != null) - { - float f = this.randy.nextFloat() * 0.8F + 0.1F; - float f1 = this.randy.nextFloat() * 0.8F + 0.1F; - float f2 = this.randy.nextFloat() * 0.8F + 0.1F; - - while (itemstack.stackSize > 0) - { - int j1 = this.randy.nextInt(21) + 10; - - if (j1 > itemstack.stackSize) - { - j1 = itemstack.stackSize; - } - - itemstack.stackSize -= j1; - EntityItem entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); - - if (itemstack.hasTagCompound()) - { - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - - float f3 = 0.05F; - entityitem.motionX = (double)((float)this.randy.nextGaussian() * f3); - entityitem.motionY = (double)((float)this.randy.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = (double)((float)this.randy.nextGaussian() * f3); - world.spawnEntityInWorld(entityitem); - } - } - - world.func_147453_f(x, y, z, block); - } - } - - super.breakBlock(world, x, y, z, block, wut); - } + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase player, + final ItemStack item) { + final TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileEntityHeliumGenerator) { + final TileEntityHeliumGenerator machine = (TileEntityHeliumGenerator) tile; + final int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + + if (l == 0) { + machine.setFacing((short) 2); + } + + if (l == 1) { + machine.setFacing((short) 5); + } + + if (l == 2) { + machine.setFacing((short) 3); + } + + if (l == 3) { + machine.setFacing((short) 4); + } + } + + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(final IIconRegister iconRegister) { + this.top = iconRegister.registerIcon(CORE.MODID + ":blockHeliumCollector_SIDE"); + this.sides = iconRegister.registerIcon(CORE.MODID + ":blockHeliumCollector_SIDE"); + this.front = iconRegister.registerIcon(CORE.MODID + ":blockHeliumCollector_FRONT"); + } } diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java index 6531d5810f..a05eeeccbb 100644 --- a/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java @@ -9,66 +9,62 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotFurnace; -public class ContainerHeliumGenerator -extends ContainerBase -{ +public class ContainerHeliumGenerator extends ContainerBase { public short size; - public ContainerHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine) - { + public ContainerHeliumGenerator(final InventoryPlayer player, final TileEntityHeliumGenerator machine) { super(machine); - //Utils.LOG_WARNING("containerHeliumGenerator"); - short sr = machine.getReactorSize(); + // Utils.LOG_WARNING("containerHeliumGenerator"); + final short sr = machine.getReactorSize(); this.addSlotToContainer(new SlotFurnace(player.player, machine, 2, 80, 35)); this.size = sr; int startX = 16; int startY = 16; int i = 0; - for (i = 0; i < 9; i++) - { - int x = i % this.size; - int y = i / this.size; + for (i = 0; i < 9; i++) { + final int x = i % this.size; + final int y = i / this.size; - addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); + this.addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); } startX = 108; startY = 16; - for (i = 9; i < 18; i++) - { - int x = i % this.size; - int y = (i-9) / this.size; + for (i = 9; i < 18; i++) { + final int x = i % this.size; + final int y = (i - 9) / this.size; - addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); + this.addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); } - for (i = 0; i < 3; ++i) - { - for (int j = 0; j < 9; ++j) - { + for (i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } - for (i = 0; i < 9; ++i) - { + for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } - // addSlotToContainer(new SlotInvSlot(machine.coolantinputSlot, 0, 8, 25)); - //addSlotToContainer(new SlotInvSlot(machine.hotcoolinputSlot, 0, 188, 25)); - //addSlotToContainer(new SlotInvSlot(machine.coolantoutputSlot, 0, 8, 115)); - //addSlotToContainer(new SlotInvSlot(machine.hotcoolantoutputSlot, 0, 188, 115)); + // addSlotToContainer(new SlotInvSlot(machine.coolantinputSlot, 0, 8, + // 25)); + // addSlotToContainer(new SlotInvSlot(machine.hotcoolinputSlot, 0, 188, + // 25)); + // addSlotToContainer(new SlotInvSlot(machine.coolantoutputSlot, 0, 8, + // 115)); + // addSlotToContainer(new SlotInvSlot(machine.hotcoolantoutputSlot, 0, + // 188, 115)); } @Override - public List getNetworkedFields() - { - List ret = super.getNetworkedFields(); + public List getNetworkedFields() { + final List ret = super.getNetworkedFields(); ret.add("heat"); ret.add("maxHeat"); ret.add("EmitHeat"); - /*ret.add("inputTank"); - ret.add("outputTank"); - ret.add("fluidcoolreactor");*/ + /* + * ret.add("inputTank"); ret.add("outputTank"); + * ret.add("fluidcoolreactor"); + */ return ret; - } + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java index 850a7f3629..707f1b8944 100644 --- a/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java @@ -13,59 +13,61 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; @SideOnly(Side.CLIENT) -public class GUIHeliumGenerator extends GuiContainer -{ - private static final ResourceLocation collectorGuiTexture = new ResourceLocation(CORE.MODID, "textures/gui/helium_collector_gui.png"); +public class GUIHeliumGenerator extends GuiContainer { + private static final ResourceLocation collectorGuiTexture = new ResourceLocation(CORE.MODID, + "textures/gui/helium_collector_gui.png"); - public GUIHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine) - { - super(new ContainerHeliumGenerator(player, machine)); - } + public GUIHeliumGenerator(final InventoryPlayer player, final TileEntityHeliumGenerator machine) { + super(new ContainerHeliumGenerator(player, machine)); + } - /** - * Draw the foreground layer for the GuiContainer (everything in front of the items) - */ - @Override - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) - { - String s = StatCollector.translateToLocal("Helium Collector"); - this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); - this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); - - this.fontRendererObj.drawString(StatCollector.translateToLocal("|"+-1), 80, 35, 2); - - short sr = 3; - int size = sr; - int startX = 16; - int startY = 16; - int i = 0; - for (i = 0; i < 9; i++) - { - int x = i % size; - int y = i / size; - this.fontRendererObj.drawString(StatCollector.translateToLocal("|"+i), startX + 18 * x, startY + 18 * y, 4210752); - //addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); - } - startX = 108; - startY = 16; - for (i = 9; i < 18; i++) - { - int x = i % size; - int y = (i-9) / size; - this.fontRendererObj.drawString(StatCollector.translateToLocal("|"+i), startX + 18 * x, startY + 18 * y, 4210752); - // addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); - } - - } + @Override + protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, + final int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(GUIHeliumGenerator.collectorGuiTexture); + 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); - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(collectorGuiTexture); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } - } + /** + * Draw the foreground layer for the GuiContainer (everything in front of + * the items) + */ + @Override + protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { + final String s = StatCollector.translateToLocal("Helium Collector"); + this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, + 4210752); + + this.fontRendererObj.drawString(StatCollector.translateToLocal("|" + -1), 80, 35, 2); + + final short sr = 3; + final int size = sr; + int startX = 16; + int startY = 16; + int i = 0; + for (i = 0; i < 9; i++) { + final int x = i % size; + final int y = i / size; + this.fontRendererObj.drawString(StatCollector.translateToLocal("|" + i), startX + 18 * x, startY + 18 * y, + 4210752); + // addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + // + 18 * x, startY + 18 * y)); + } + startX = 108; + startY = 16; + for (i = 9; i < 18; i++) { + final int x = i % size; + final int y = (i - 9) / size; + this.fontRendererObj.drawString(StatCollector.translateToLocal("|" + i), startX + 18 * x, startY + 18 * y, + 4210752); + // addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + // + 18 * x, startY + 18 * y)); + } + + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java index 86507a2d64..b5eb8b7898 100644 --- a/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java @@ -4,75 +4,65 @@ import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenera import ic2.core.block.invslot.InvSlot; import net.minecraft.item.ItemStack; -public class InvSlotRadiation extends InvSlot -{ - public InvSlotRadiation(TileEntityHeliumGenerator base, String name1, int oldStartIndex1, int count) - { - super(base, name1, oldStartIndex1, InvSlot.Access.IO, count); +public class InvSlotRadiation extends InvSlot { + private final int rows = 6; - setStackSizeLimit(1); - } + private final int maxCols = 9; - @Override - public boolean accepts(ItemStack itemStack) - { - return ((TileEntityHeliumGenerator)this.base).isUsefulItem(itemStack, true); - } - - @Override - public int size() - { - //Utils.LOG_INFO("InvSlotRadiation/Size"); - return 3 * 6; - } + public InvSlotRadiation(final TileEntityHeliumGenerator base, final String name1, final int oldStartIndex1, + final int count) { + super(base, name1, oldStartIndex1, InvSlot.Access.IO, count); - public int rawSize() - { - return super.size(); + this.setStackSizeLimit(1); } @Override - public ItemStack get(int index) - { - return super.get(mapIndex(index)); - } - - public ItemStack get(int x, int y) - { - return super.get(y * 9 + x); + public boolean accepts(final ItemStack itemStack) { + return ((TileEntityHeliumGenerator) this.base).isUsefulItem(itemStack, true); } @Override - public void put(int index, ItemStack content) - { - super.put(mapIndex(index), content); + public ItemStack get(final int index) { + return super.get(this.mapIndex(index)); } - public void put(int x, int y, ItemStack content) - { - super.put(y * 9 + x, content); + public ItemStack get(final int x, final int y) { + return super.get(y * 9 + x); } - private int mapIndex(int index) - { - int size = size(); - int cols = size / 6; - if (index < size) - { - int row = index / cols; - int col = index % cols; + private int mapIndex(int index) { + final int size = this.size(); + final int cols = size / 6; + if (index < size) { + final int row = index / cols; + final int col = index % cols; return row * 9 + col; } index -= size; - int remCols = 9 - cols; + final int remCols = 9 - cols; - int row = index / remCols; - int col = cols + index % remCols; + final int row = index / remCols; + final int col = cols + index % remCols; return row * 9 + col; } - private final int rows = 6; - private final int maxCols = 9; + public void put(final int x, final int y, final ItemStack content) { + super.put(y * 9 + x, content); + } + + @Override + public void put(final int index, final ItemStack content) { + super.put(this.mapIndex(index), content); + } + + public int rawSize() { + return super.size(); + } + @Override + public int size() { + // Utils.LOG_INFO("InvSlotRadiation/Size"); + return 3 * 6; + } } diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java index 805f3df2f8..16c66d6802 100644 --- a/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java @@ -15,7 +15,6 @@ import ic2.core.*; import ic2.core.block.TileEntityInventory; import ic2.core.init.MainConfig; import ic2.core.item.reactor.ItemReactorHeatStorage; -import ic2.core.network.NetworkManager; import ic2.core.util.ConfigUtil; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -36,433 +35,386 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; -public class TileEntityHeliumGenerator extends TileEntityInventory implements IInventory ,IReactor, IWrenchable { +public class TileEntityHeliumGenerator extends TileEntityInventory implements IInventory, IReactor, IWrenchable { - private ItemStack heliumStack; - private int facing = 2; - private int progress; + private ItemStack heliumStack; + private int facing = 2; + private int progress; - - public void update2Entity(){ - Utils.LOG_WARNING("updateEntity"); - if(++progress >= 40){ - //if(++progress >= 300){ - if(heliumStack == null) - heliumStack = ItemUtils.getSimpleStack(ModItems.itemHeliumBlob); - else if(heliumStack.getItem() == ModItems.itemHeliumBlob && heliumStack.stackSize < 64) - heliumStack.stackSize++; - progress = 0; - markDirty(); - } - } + public Block[][][] surroundings = new Block[5][5][5]; - @Override - public short getFacing(){ - return (short) facing; - } + public final InvSlotRadiation reactorSlot; - @Override - public void setFacing(short dir){ - facing = dir; - } + public float output = 0.0F; - /*@Override - public void readCustomNBT(NBTTagCompound tag) - { - this.heliumStack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Helium")); - this.progress = tag.getInteger("Progress"); - this.facing = tag.getShort("Facing"); - this.heat = tag.getInteger("heat"); - this.prevActive = (this.active = tag.getBoolean("active")); - } + /* + * @Override public void readCustomNBT(NBTTagCompound tag) { + * this.heliumStack = + * ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Helium")); + * this.progress = tag.getInteger("Progress"); this.facing = + * tag.getShort("Facing"); this.heat = tag.getInteger("heat"); + * this.prevActive = (this.active = tag.getBoolean("active")); } + * + * @Override public void writeCustomNBT(NBTTagCompound tag) { + * tag.setInteger("Progress", this.progress); tag.setShort("Facing", (short) + * this.facing); tag.setInteger("heat", this.heat); tag.setBoolean("active", + * this.active); if(heliumStack != null) { NBTTagCompound produce = new + * NBTTagCompound(); heliumStack.writeToNBT(produce); tag.setTag("Helium", + * produce); } else tag.removeTag("Helium"); } + */ - @Override - public void writeCustomNBT(NBTTagCompound tag) - { - tag.setInteger("Progress", this.progress); - tag.setShort("Facing", (short) this.facing); - tag.setInteger("heat", this.heat); - tag.setBoolean("active", this.active); - if(heliumStack != null) { - NBTTagCompound produce = new NBTTagCompound(); - heliumStack.writeToNBT(produce); - tag.setTag("Helium", produce); - } - else - tag.removeTag("Helium"); - }*/ + public int updateTicker; + public int heat = 5000; - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) - { - super.readFromNBT(nbttagcompound); + public int maxHeat = 100000; - //this.heliumStack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Helium")); - NBTTagList list = nbttagcompound.getTagList("Items", 10); - for (int i = 0; i < list.tagCount(); ++i) { - NBTTagCompound stackTag = list.getCompoundTagAt(i); - int slot = stackTag.getByte("Slot") & 255; - this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag)); - } - this.progress = nbttagcompound.getInteger("Progress"); - this.facing = nbttagcompound.getShort("Facing"); - this.heat = nbttagcompound.getInteger("heat"); - this.output = nbttagcompound.getShort("output"); - this.prevActive = (this.active = nbttagcompound.getBoolean("active")); - } + public float hem = 1.0F; - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) - { - super.writeToNBT(nbttagcompound); + private int EmitHeatbuffer = 0; - nbttagcompound.setInteger("Progress", this.progress); - nbttagcompound.setShort("Facing", (short) this.facing); - nbttagcompound.setInteger("heat", this.heat); - nbttagcompound.setShort("output", (short)(int)getReactorEnergyOutput()); - nbttagcompound.setBoolean("active", this.active); - /*if(heliumStack != null) { - NBTTagCompound produce = new NBTTagCompound(); - heliumStack.writeToNBT(produce); - nbttagcompound.setTag("Helium", produce); - } - else - nbttagcompound.removeTag("Helium");*/ - NBTTagList list = new NBTTagList(); - for (int i = 0; i < this.getSizeInventory(); ++i) { - if (this.getStackInSlot(i) != null) { - NBTTagCompound stackTag = new NBTTagCompound(); - stackTag.setByte("Slot", (byte) i); - this.getStackInSlot(i).writeToNBT(stackTag); - list.appendTag(stackTag); - } - } - nbttagcompound.setTag("Items", list); - } + public int EmitHeat = 0; + private boolean redstone = false; - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tag = new NBTTagCompound(); - writeToNBT(tag); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, tag); + private final boolean fluidcoolreactor = false; + + private boolean active = true; + + public boolean prevActive = false; + + public TileEntityHeliumGenerator() { + this.updateTicker = IC2.random.nextInt(this.getTickRate()); + this.reactorSlot = new InvSlotRadiation(this, "helium_collector", 0, 54); // TODO } @Override - public void onDataPacket(net.minecraft.network.NetworkManager net, S35PacketUpdateTileEntity packet) { - super.onDataPacket(net, packet); - readFromNBT(packet.func_148857_g()); + public void addEmitHeat(final int heat) { + this.EmitHeatbuffer += heat; } + @Override + public int addHeat(final int amount) { + this.heat += amount; + return this.heat; + } @Override - public int getSizeInventory() - { - return 19; + public float addOutput(final float energy) { + return this.output += energy; + } + + public boolean calculateHeatEffects() { + Utils.LOG_WARNING("calculateHeatEffects"); + if (this.heat < 8000 || !IC2.platform.isSimulating() + || ConfigUtil.getFloat(MainConfig.get(), "protection/reactorExplosionPowerLimit") <= 0.0F) { + return false; + } + final float power = this.heat / this.maxHeat; + if (power >= 1.0F) { + this.explode(); + return true; + } + if (power >= 0.85F && this.worldObj.rand.nextFloat() <= 0.2F * this.hem) { + final int[] coord = this.getRandCoord(2); + if (coord != null) { + final Block block = this.worldObj.getBlock(coord[0], coord[1], coord[2]); + if (block.isAir(this.worldObj, coord[0], coord[1], coord[2])) { + this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.fire, 0, 7); + } + else if (block.getBlockHardness(this.worldObj, coord[0], coord[1], coord[2]) >= 0.0F + && this.worldObj.getTileEntity(coord[0], coord[1], coord[2]) == null) { + final Material mat = block.getMaterial(); + if (mat == Material.rock || mat == Material.iron || mat == Material.lava || mat == Material.ground + || mat == Material.clay) { + this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.flowing_lava, 15, 7); + } + else { + this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.fire, 0, 7); + } + } + } + } + if (power >= 0.7F) { + final List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, + AxisAlignedBB.getBoundingBox(this.xCoord - 3, this.yCoord - 3, this.zCoord - 3, this.xCoord + 4, + this.yCoord + 4, this.zCoord + 4)); + for (int l = 0; l < list1.size(); l++) { + final Entity ent = (Entity) list1.get(l); + ent.attackEntityFrom(IC2DamageSource.radiation, (int) (this.worldObj.rand.nextInt(4) * this.hem)); + } + } + if (power >= 0.5F && this.worldObj.rand.nextFloat() <= this.hem) { + final int[] coord = this.getRandCoord(2); + if (coord != null) { + final Block block = this.worldObj.getBlock(coord[0], coord[1], coord[2]); + if (block.getMaterial() == Material.water) { + this.worldObj.setBlockToAir(coord[0], coord[1], coord[2]); + } + } + } + if (power >= 0.4F && this.worldObj.rand.nextFloat() <= this.hem) { + final int[] coord = this.getRandCoord(2); + if (coord != null && this.worldObj.getTileEntity(coord[0], coord[1], coord[2]) == null) { + final Block block = this.worldObj.getBlock(coord[0], coord[1], coord[2]); + final Material mat = block.getMaterial(); + if (mat == Material.wood || mat == Material.leaves || mat == Material.cloth) { + this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.fire, 0, 7); + } + } + } + return false; } @Override - public ItemStack getStackInSlot(int slot){ - return heliumStack; + public void closeInventory() { } + // IC2 Nuclear Code + @Override - public ItemStack decrStackSize(int slot, int decrement){ + public ItemStack decrStackSize(final int slot, final int decrement) { Utils.LOG_WARNING("decrStackSize"); - if(heliumStack == null) + if (this.heliumStack == null) { return null; - if(decrement < heliumStack.stackSize){ - ItemStack take = heliumStack.splitStack(decrement); - if(heliumStack.stackSize <= 0) - heliumStack = null; + } + if (decrement < this.heliumStack.stackSize) { + final ItemStack take = this.heliumStack.splitStack(decrement); + if (this.heliumStack.stackSize <= 0) { + this.heliumStack = null; + } return take; } - ItemStack take = heliumStack; - heliumStack = null; + final ItemStack take = this.heliumStack; + this.heliumStack = null; return take; } + public void dropAllUnfittingStuff() { + Utils.LOG_WARNING("dropAllUnfittingStuff"); + for (int i = 0; i < this.reactorSlot.size(); i++) { + final ItemStack stack = this.reactorSlot.get(i); + if (stack != null && !this.isUsefulItem(stack, false)) { + this.reactorSlot.put(i, null); + this.eject(stack); + } + } + for (int i = this.reactorSlot.size(); i < this.reactorSlot.rawSize(); i++) { + final ItemStack stack = this.reactorSlot.get(i); + this.reactorSlot.put(i, null); + this.eject(stack); + } + } + public void eject(final ItemStack drop) { + Utils.LOG_WARNING("eject"); + if (!IC2.platform.isSimulating() || drop == null) { + return; + } + final float f = 0.7F; + final double d = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D; + final double d1 = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D; + final double d2 = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D; + final EntityItem entityitem = new EntityItem(this.worldObj, this.xCoord + d, this.yCoord + d1, this.zCoord + d2, + drop); + entityitem.delayBeforeCanPickup = 10; + this.worldObj.spawnEntityInWorld(entityitem); + } @Override - public void openInventory() {} - @Override - public void closeInventory() {} - - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this && player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + public void explode() { + Utils.LOG_WARNING("Explosion"); + // TODO } - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack){ - return false; + public Packet getDescriptionPacket() { + final NBTTagCompound tag = new NBTTagCompound(); + this.writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, -999, tag); } - @Override - public int getInventoryStackLimit(){ - return 64; + public short getFacing() { + return (short) this.facing; } - @Override - public void setInventorySlotContents(int slot, ItemStack stack){ - heliumStack = stack; + public int getHeat() { + return this.heat; } - @Override - public ItemStack getStackInSlotOnClosing(int slot){ - return null; + public float getHeatEffectModifier() { + return this.hem; } - /** * Returns the name of the inventory */ @Override - public String getInventoryName() - { - //return "container.helium_collector"; - return "container.helium_collector"; + public String getInventoryName() { + // return "container.helium_collector"; + return "container.helium_collector"; } - - /** - * Returns if the inventory is named - */ @Override - public boolean hasCustomInventoryName() - { - return false; + public int getInventoryStackLimit() { + return 64; + } + @Override + public ItemStack getItemAt(final int x, final int y) { + Utils.LOG_WARNING("getItemAt"); + if (x < 0 || x >= this.getReactorSize() || y < 0 || y >= 6) { + return null; + } + return this.reactorSlot.get(x, y); + } + @Override + public int getMaxHeat() { + return this.maxHeat; + } + public double getOfferedEnergy() { + return this.getReactorEnergyOutput() * 5.0F * 1.0F; } - //IC2 Nuclear Code + @Override + public ChunkCoordinates getPosition() { + return new ChunkCoordinates(this.xCoord, this.yCoord, this.zCoord); + } + public int[] getRandCoord(final int radius) { + if (radius <= 0) { + return null; + } + final int[] c = new int[3]; + c[0] = this.xCoord + this.worldObj.rand.nextInt(2 * radius + 1) - radius; + c[1] = this.yCoord + this.worldObj.rand.nextInt(2 * radius + 1) - radius; + c[2] = this.zCoord + this.worldObj.rand.nextInt(2 * radius + 1) - radius; + if (c[0] == this.xCoord && c[1] == this.yCoord && c[2] == this.zCoord) { + return null; + } + return c; + } - public Block[][][] surroundings = new Block[5][5][5]; - public final InvSlotRadiation reactorSlot; - public float output = 0.0F; - public int updateTicker; - public int heat = 5000; - public int maxHeat = 100000; - public float hem = 1.0F; - private int EmitHeatbuffer = 0; - public int EmitHeat = 0; - private boolean redstone = false; - private boolean fluidcoolreactor = false; - private boolean active = true; - public boolean prevActive = false; + @Override + public float getReactorEnergyOutput() { + return this.output; + } + @Override + public double getReactorEUEnergyOutput() { + return this.getOfferedEnergy(); + } - public short getReactorSize() - { - //Utils.LOG_WARNING("getReactorSize"); + public short getReactorSize() { + // Utils.LOG_WARNING("getReactorSize"); if (this.worldObj == null) { Utils.LOG_WARNING("getReactorSize == 9"); return 9; } short cols = 3; - //Utils.LOG_WARNING("getReactorSize == "+cols); - for (Direction direction : Direction.directions) - { - TileEntity target = direction.applyToTileEntity(this); - if ((target instanceof TileEntityHeliumGenerator)) { - cols = (short)(cols + 1); - Utils.LOG_WARNING("getReactorSize =1= "+cols); + // Utils.LOG_WARNING("getReactorSize == "+cols); + for (final Direction direction : Direction.directions) { + final TileEntity target = direction.applyToTileEntity(this); + if (target instanceof TileEntityHeliumGenerator) { + cols = (short) (cols + 1); + Utils.LOG_WARNING("getReactorSize =1= " + cols); } } - //Utils.LOG_WARNING("getReactorSize == "+cols); + // Utils.LOG_WARNING("getReactorSize == "+cols); return cols; } - protected void updateEntityServer() - { - Utils.LOG_WARNING("updateEntityServer"); - super.updateEntity(); + @Override + public int getSizeInventory() { + return 19; + } - if (this.updateTicker++ % getTickRate() != 0) { - return; - } - if (!this.worldObj.doChunksNearChunkExist(this.xCoord, this.yCoord, this.zCoord, 2)) - { - this.output = 0.0F; - } - else - { + @Override + public ItemStack getStackInSlot(final int slot) { + return this.heliumStack; + } - dropAllUnfittingStuff(); + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return null; + } - this.output = 0.0F; - this.maxHeat = 10000; - this.hem = 1.0F; + @Override + public int getTickRate() { + return 20; + } - processChambers(); - this.EmitHeatbuffer = 0; - if (calculateHeatEffects()) { - return; - } - setActive((this.heat >= 1000) || (this.output > 0.0F)); + @Override + public World getWorld() { + return this.worldObj; + } - markDirty(); - } - ((NetworkManager)IC2.network.get()).updateTileEntityField(this, "output"); + @Override + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { + return new ItemStack(ModBlocks.blockHeliumGenerator, 1); } @Override - public void setActive(boolean active1) - { - Utils.LOG_WARNING("setActive"); - this.active = active1; - if (this.prevActive != active1) { - ((NetworkManager)IC2.network.get()).updateTileEntityField(this, "active"); - } - this.prevActive = active1; + public float getWrenchDropRate() { + return 1F; } - public void dropAllUnfittingStuff() - { - Utils.LOG_WARNING("dropAllUnfittingStuff"); - for (int i = 0; i < this.reactorSlot.size(); i++) - { - ItemStack stack = this.reactorSlot.get(i); - if ((stack != null) && (!isUsefulItem(stack, false))) - { - this.reactorSlot.put(i, null); - eject(stack); - } - } - for (int i = this.reactorSlot.size(); i < this.reactorSlot.rawSize(); i++) - { - ItemStack stack = this.reactorSlot.get(i); + /** + * Returns if the inventory is named + */ + @Override + public boolean hasCustomInventoryName() { + return false; + } - this.reactorSlot.put(i, null); - eject(stack); - } + @Override + public boolean isFluidCooled() { + Utils.LOG_WARNING("isFluidCooled"); + return false; } - public void eject(ItemStack drop) - { - Utils.LOG_WARNING("eject"); - if ((!IC2.platform.isSimulating()) || (drop == null)) { - return; - } - float f = 0.7F; - double d = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D; - double d1 = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D; - double d2 = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D; - EntityItem entityitem = new EntityItem(this.worldObj, this.xCoord + d, this.yCoord + d1, this.zCoord + d2, drop); - entityitem.delayBeforeCanPickup = 10; - this.worldObj.spawnEntityInWorld(entityitem); + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack stack) { + return false; } - public boolean isUsefulItem(ItemStack stack, boolean forInsertion) - { - //Utils.LOG_WARNING("isUsefulItem"); - Item item = stack.getItem(); - if ((forInsertion) && (this.fluidcoolreactor) && - ((item instanceof ItemReactorHeatStorage)) && - (((ItemReactorHeatStorage)item).getCustomDamage(stack) > 0)) { - return false; - } - if ((item instanceof IReactorComponent)) { - return true; - } - return (item == Ic2Items.TritiumCell.getItem()) || (item == Ic2Items.reactorDepletedUraniumSimple.getItem()) || (item == Ic2Items.reactorDepletedUraniumDual.getItem()) || (item == Ic2Items.reactorDepletedUraniumQuad.getItem()) || (item == Ic2Items.reactorDepletedMOXSimple.getItem()) || (item == Ic2Items.reactorDepletedMOXDual.getItem()) || (item == Ic2Items.reactorDepletedMOXQuad.getItem()); + @Override + public boolean isUseableByPlayer(final EntityPlayer player) { + return this.worldObj.getTileEntity(this.xCoord, thi