From cbe0e497be8e466c380a5b4fa781b314ede9ada3 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sun, 6 Nov 2016 19:32:27 +1000 Subject: Revert "$ Cleaned up the entire project." This reverts commit 0669f5eb9d5029a8b94ec552171b0837605f7747. # Conflicts: # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java Revert "% Cleaned up Imports." This reverts commit 3654052fb63a571c5eaca7f20714b87c17f7e966. --- .../core/block/machine/BlockGtFrameBox.java | 35 +- .../core/block/machine/Machine_Charger.java | 131 ++-- .../gtPlusPlus/core/block/machine/Machine_NHG.java | 131 ++-- .../core/block/machine/Machine_WireiusDeletus.java | 3 +- .../core/block/machine/Machine_Workbench.java | 133 ++-- .../block/machine/Machine_WorkbenchAdvanced.java | 94 +-- .../machine/heliumgen/block/HeliumGenerator.java | 279 ++++--- .../container/ContainerHeliumGenerator.java | 69 +- .../machine/heliumgen/gui/GUIHeliumGenerator.java | 111 ++- .../machine/heliumgen/slots/InvSlotRadiation.java | 88 ++- .../tileentity/TileEntityHeliumGenerator.java | 854 +++++++++++---------- 11 files changed, 1001 insertions(+), 927 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 dbbc91c902..2832d4d0a4 100644 --- a/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java +++ b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java @@ -1,33 +1,34 @@ package gtPlusPlus.core.block.machine; -import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.MetaBlock; +import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.lib.CORE; import net.minecraft.block.material.Material; import net.minecraft.world.IBlockAccess; public class BlockGtFrameBox extends MetaBlock { - private int[] colours; - private int totalColours; - - public BlockGtFrameBox(final String unlocalizedName, final Material material, final BlockTypes blockTypeENUM, - final boolean recolour, final int... colour) { + private int[] colours; + private int totalColours; + + public BlockGtFrameBox( + String unlocalizedName, Material material, + BlockTypes blockTypeENUM, boolean recolour, int... colour) { super(unlocalizedName, material, blockTypeENUM.getBlockSoundType()); - 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; - } + this.setBlockTextureName(CORE.MODID + ":" + "blockGtFrame"); + this.setHarvestLevel(blockTypeENUM.getHarvestTool(), 2); + if (recolour && (colour != null && colour.length > 0)){ + colours = colour; + totalColours = colours.length; + } } @Override - 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) { - - } + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, + int p_149720_3_, int p_149720_4_) { + for (int i : 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 e88c5c5b6b..4f426b99c9 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java @@ -1,11 +1,12 @@ package gtPlusPlus.core.block.machine; -import java.util.ArrayList; - import gtPlusPlus.GTplusplus; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityCharger; + +import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -16,67 +17,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(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; - } +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(); + } } \ 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 cfad3006b9..011e293000 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java @@ -1,11 +1,12 @@ package gtPlusPlus.core.block.machine; -import java.util.ArrayList; - import gtPlusPlus.GTplusplus; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityNHG; + +import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -16,67 +17,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(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; - } +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(); + } } \ 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 e881d40d35..e964a9da01 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java @@ -1,6 +1,5 @@ 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 1921aa8000..ed986b756e 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -1,11 +1,5 @@ package gtPlusPlus.core.block.machine; -import buildcraft.api.tools.IToolWrench; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.LanguageRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import crazypants.enderio.api.tool.ITool; import gtPlusPlus.GTplusplus; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; @@ -21,85 +15,96 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import buildcraft.api.tools.IToolWrench; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import crazypants.enderio.api.tool.ITool; -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"); + + } - } - - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityWorkbench(); - } + /** + * 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)); + } - /** - * Gets the block's texture. Args: side, meta - */ - @Override + @Override @SideOnly(Side.CLIENT) - 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; - } + 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"); + } - /** - * 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) { + /** + * 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) + { 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; - final TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TileEntityWorkbench) { - if (!holdingWrench) { + 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."); } @@ -107,11 +112,7 @@ public class Machine_Workbench extends BlockContainer { } @Override - @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"); + public TileEntity createNewTileEntity(World world, int p_149915_2_) { + return new TileEntityWorkbench(); } } \ 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 20d6c8601c..2f061ea298 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java @@ -1,11 +1,5 @@ package gtPlusPlus.core.block.machine; -import buildcraft.api.tools.IToolWrench; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.LanguageRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import crazypants.enderio.api.tool.ITool; import gtPlusPlus.GTplusplus; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; @@ -21,17 +15,25 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import buildcraft.api.tools.IToolWrench; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import crazypants.enderio.api.tool.ITool; -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); @@ -40,61 +42,65 @@ public class Machine_WorkbenchAdvanced extends BlockContainer { } - @Override - 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 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; + 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 + @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"); } /** * 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) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) + { - final ItemStack heldItem = PlayerUtils.getItemStackInPlayersHand(player); - if (world.isRemote) { - return true; - } + 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; } } - final TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TileEntityWorkbenchAdvanced) { - if (!holdingWrench) { + + 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."); } @@ -102,11 +108,7 @@ public class Machine_WorkbenchAdvanced extends BlockContainer { } @Override - @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"); + public TileEntity createNewTileEntity(World world, int p_149915_2_) { + return new TileEntityWorkbenchAdvanced(128000, 2); } } \ 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 19e9b09e8f..7a76b09cca 100644 --- a/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java @@ -1,13 +1,12 @@ package gtPlusPlus.core.block.machine.heliumgen.block; -import java.util.Random; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.GTplusplus; import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; + +import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -22,145 +21,145 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class HeliumGenerator extends BlockContainer { - 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; - } + 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; + } player.openGui(GTplusplus.instance, 2, world, x, y, z); return true; - } - - @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"); - } + } + + @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); + } } 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 a05eeeccbb..d701f6f125 100644 --- a/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java @@ -1,70 +1,75 @@ package gtPlusPlus.core.block.machine.heliumgen.container; -import java.util.List; - import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; import ic2.core.ContainerBase; import ic2.core.slot.SlotInvSlot; + +import java.util.List; + 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(final InventoryPlayer player, final TileEntityHeliumGenerator machine) { + public ContainerHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine) + { super(machine); - // Utils.LOG_WARNING("containerHeliumGenerator"); - final short sr = machine.getReactorSize(); + //Utils.LOG_WARNING("containerHeliumGenerator"); + 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++) { - final int x = i % this.size; - final int y = i / this.size; + for (i = 0; i < 9; i++) + { + int x = i % this.size; + int y = i / this.size; - this.addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); + 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 % this.size; - final int y = (i - 9) / this.size; + for (i = 9; i < 18; i++) + { + int x = i % this.size; + int y = (i-9) / this.size; - this.addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); + 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() { - final List ret = super.getNetworkedFields(); + public List getNetworkedFields() + { + 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 707f1b8944..2106f144be 100644 --- a/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java @@ -1,9 +1,5 @@ package gtPlusPlus.core.block.machine.heliumgen.gui; -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.block.machine.heliumgen.container.ContainerHeliumGenerator; import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; import gtPlusPlus.core.lib.CORE; @@ -12,62 +8,65 @@ import net.minecraft.entity.player.InventoryPlayer; 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 GUIHeliumGenerator(final InventoryPlayer player, final TileEntityHeliumGenerator machine) { - super(new ContainerHeliumGenerator(player, machine)); - } +import org.lwjgl.opengl.GL11; - @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); +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; - } +@SideOnly(Side.CLIENT) +public class GUIHeliumGenerator extends GuiContainer +{ + private static final ResourceLocation collectorGuiTexture = new ResourceLocation(CORE.MODID, "textures/gui/helium_collector_gui.png"); - /** - * 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); + public GUIHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine) + { + super(new ContainerHeliumGenerator(player, machine)); + } - this.fontRendererObj.drawString(StatCollector.translateToLocal("|" + -1), 80, 35, 2); + /** + * 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)); + } + + } - 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)); - } + @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); - } + } } \ 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 b5eb8b7898..86507a2d64 100644 --- a/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java @@ -4,65 +4,75 @@ import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenera import ic2.core.block.invslot.InvSlot; import net.minecraft.item.ItemStack; -public class InvSlotRadiation extends InvSlot { - private final int rows = 6; - - private final int maxCols = 9; - - public InvSlotRadiation(final TileEntityHeliumGenerator base, final String name1, final int oldStartIndex1, - final int count) { +public class InvSlotRadiation extends InvSlot +{ + public InvSlotRadiation(TileEntityHeliumGenerator base, String name1, int oldStartIndex1, int count) + { super(base, name1, oldStartIndex1, InvSlot.Access.IO, count); - this.setStackSizeLimit(1); + setStackSizeLimit(1); } @Override - public boolean accepts(final ItemStack itemStack) { - return ((TileEntityHeliumGenerator) this.base).isUsefulItem(itemStack, true); + public boolean accepts(ItemStack itemStack) + { + return ((TileEntityHeliumGenerator)this.base).isUsefulItem(itemStack, true); } @Override - public ItemStack get(final int index) { - return super.get(this.mapIndex(index)); + public int size() + { + //Utils.LOG_INFO("InvSlotRadiation/Size"); + return 3 * 6; } - public ItemStack get(final int x, final int y) { + public int rawSize() + { + return super.size(); + } + + @Override + public ItemStack get(int index) + { + return super.get(mapIndex(index)); + } + + public ItemStack get(int x, int y) + { return super.get(y * 9 + x); } - 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; + @Override + public void put(int index, ItemStack content) + { + super.put(mapIndex(index), content); + } + + public void put(int x, int y, ItemStack content) + { + super.put(y * 9 + x, content); + } + + private int mapIndex(int index) + { + int size = size(); + int cols = size / 6; + if (index < size) + { + int row = index / cols; + int col = index % cols; return row * 9 + col; } index -= size; - final int remCols = 9 - cols; + int remCols = 9 - cols; - final int row = index / remCols; - final int col = cols + index % remCols; + int row = index / remCols; + int col = cols + index % remCols; return row * 9 + col; } - 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; - } + private final int rows = 6; + private final int maxCols = 9; } 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 16c66d6802..5ffd70efc4 100644 --- a/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.block.machine.heliumgen.tileentity; -import java.util.List; - import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.block.machine.heliumgen.slots.InvSlotRadiation; import gtPlusPlus.core.item.ModItems; @@ -11,11 +9,17 @@ import ic2.api.Direction; import ic2.api.reactor.IReactor; import ic2.api.reactor.IReactorComponent; import ic2.api.tile.IWrenchable; -import ic2.core.*; +import ic2.core.IC2; +import ic2.core.IC2DamageSource; +import ic2.core.Ic2Items; 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 java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; @@ -35,386 +39,433 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; -public class TileEntityHeliumGenerator extends TileEntityInventory implements IInventory, IReactor, IWrenchable { - - private ItemStack heliumStack; - private int facing = 2; - private int progress; - - public Block[][][] surroundings = new Block[5][5][5]; - - public final InvSlotRadiation reactorSlot; - - 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 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; +public class TileEntityHeliumGenerator extends TileEntityInventory implements IInventory ,IReactor, IWrenchable { - public int maxHeat = 100000; + private ItemStack heliumStack; + private int facing = 2; + private int progress; - public float hem = 1.0F; + + 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(); + } + } - private int EmitHeatbuffer = 0; + @Override + public short getFacing(){ + return (short) facing; + } - public int EmitHeat = 0; + @Override + public void setFacing(short dir){ + facing = dir; + } - private boolean redstone = false; + /*@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")); + } - private final boolean fluidcoolreactor = false; + @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"); + }*/ - private boolean active = true; - public boolean prevActive = false; + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); - public TileEntityHeliumGenerator() { - this.updateTicker = IC2.random.nextInt(this.getTickRate()); - this.reactorSlot = new InvSlotRadiation(this, "helium_collector", 0, 54); // TODO + //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")); } @Override - public void addEmitHeat(final int heat) { - this.EmitHeatbuffer += heat; + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + + 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); } + @Override - public int addHeat(final int amount) { - this.heat += amount; - return this.heat; + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, tag); } @Override - public float addOutput(final float energy) { - return this.output += energy; + public void onDataPacket(net.minecraft.network.NetworkManager net, S35PacketUpdateTileEntity packet) { + super.onDataPacket(net, packet); + readFromNBT(packet.func_148857_g()); } - 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 void closeInventory() { + public int getSizeInventory() + { + return 19; } - // IC2 Nuclear Code + @Override + public ItemStack getStackInSlot(int slot){ + return heliumStack; + } @Override - public ItemStack decrStackSize(final int slot, final int decrement) { + public ItemStack decrStackSize(int slot, int decrement){ Utils.LOG_WARNING("decrStackSize"); - if (this.heliumStack == null) { + if(heliumStack == null) return null; - } - if (decrement < this.heliumStack.stackSize) { - final ItemStack take = this.heliumStack.splitStack(decrement); - if (this.heliumStack.stackSize <= 0) { - this.heliumStack = null; - } + if(decrement < heliumStack.stackSize){ + ItemStack take = heliumStack.splitStack(decrement); + if(heliumStack.stackSize <= 0) + heliumStack = null; return take; } - final ItemStack take = this.heliumStack; - this.heliumStack = null; + ItemStack take = heliumStack; + 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 explode() { - Utils.LOG_WARNING("Explosion"); - // TODO + 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; } + @Override - public Packet getDescriptionPacket() { - final NBTTagCompound tag = new NBTTagCompound(); - this.writeToNBT(tag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, -999, tag); + public boolean isItemValidForSlot(int slot, ItemStack stack){ + return false; } + @Override - public short getFacing() { - return (short) this.facing; + public int getInventoryStackLimit(){ + return 64; } + @Override - public int getHeat() { - return this.heat; + public void setInventorySlotContents(int slot, ItemStack stack){ + heliumStack = stack; } + @Override - public float getHeatEffectModifier() { - return this.hem; + public ItemStack getStackInSlotOnClosing(int slot){ + return null; } + /** * Returns the name of the inventory */ @Override - public String getInventoryName() { - // return "container.helium_collector"; - return "container.helium_collector"; - } - @Override - 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; + public String getInventoryName() + { + //return "container.helium_collector"; + return "container.helium_collector"; } + /** + * Returns if the inventory is named + */ @Override - public ChunkCoordinates getPosition() { - return new ChunkCoordinates(this.xCoord, this.yCoord, this.zCoord); + public boolean hasCustomInventoryName() + { + return false; } - 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; - } + //IC2 Nuclear Code - @Override - public float getReactorEnergyOutput() { - return this.output; - } - @Override - public double getReactorEUEnergyOutput() { - return this.getOfferedEnergy(); - } + 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 activ