diff options
author | draknyte1 <draknyte1@hotmail.com> | 2016-11-04 15:23:26 +1000 |
---|---|---|
committer | draknyte1 <draknyte1@hotmail.com> | 2016-11-04 15:23:26 +1000 |
commit | 0669f5eb9d5029a8b94ec552171b0837605f7747 (patch) | |
tree | 6b40e64c04d51b7a33cf2f0b35f7232cf37c4247 /src/Java/gtPlusPlus/core/block | |
parent | 3654052fb63a571c5eaca7f20714b87c17f7e966 (diff) | |
download | GT5-Unofficial-0669f5eb9d5029a8b94ec552171b0837605f7747.tar.gz GT5-Unofficial-0669f5eb9d5029a8b94ec552171b0837605f7747.tar.bz2 GT5-Unofficial-0669f5eb9d5029a8b94ec552171b0837605f7747.zip |
$ Cleaned up the entire project.
> Much neat, very nices.
Diffstat (limited to 'src/Java/gtPlusPlus/core/block')
20 files changed, 1466 insertions, 1533 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index 2e6a7c3e07..69ecb9ed5b 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -13,47 +13,48 @@ import net.minecraftforge.fluids.Fluid; public final class ModBlocks { - public static Block blockWorkbench; - public static Block blockWorkbenchAdvanced; - //Blocks - //public static Block blockBloodSteel; - //public static Block blockStaballoy; + public static Block blockWorkbench; + public static Block blockWorkbenchAdvanced; + // Blocks + // public static Block blockBloodSteel; + // public static Block blockStaballoy; // WIP TODO public static Block blockToolBuilder; - public static Block blockGriefSaver; - public static Block blockCasingsMisc; - public static Block blockMetaTileEntity; - public static Block blockHeliumGenerator; - public static Block blockNHG; - public static Block blockCharger; - - public static Block MatterFabricatorEffectBlock; - - public static Fluid fluidJackDaniels = new Fluid("fluidJackDaniels"); - public static Block blockFluidJackDaniels; - public static Block blockCasings2Misc; + public static Block blockGriefSaver; + public static Block blockCasingsMisc; + public static Block blockMetaTileEntity; + public static Block blockHeliumGenerator; + public static Block blockNHG; + public static Block blockCharger; + public static Block MatterFabricatorEffectBlock; + public static Fluid fluidJackDaniels = new Fluid("fluidJackDaniels"); + public static Block blockFluidJackDaniels; + public static Block blockCasings2Misc; public static void init() { Utils.LOG_INFO("Initializing Blocks."); - //blockGriefSaver = new TowerDevice().setBlockName("blockGriefSaver").setCreativeTab(AddToCreativeTab.tabBlock).setBlockTextureName("blockDefault"); + // blockGriefSaver = new + // TowerDevice().setBlockName("blockGriefSaver").setCreativeTab(AddToCreativeTab.tabBlock).setBlockTextureName("blockDefault"); - registerBlocks(); + ModBlocks.registerBlocks(); } - public static void registerBlocks(){ + public static void registerBlocks() { Utils.LOG_INFO("Registering Blocks."); - GameRegistry.registerBlock(MatterFabricatorEffectBlock = new LightGlass(Material.glass, false).setHardness(0.1F).setBlockTextureName(CORE.MODID + ":" + "blockMFEffect").setStepSound(Block.soundTypeGlass), "blockMFEffect"); + GameRegistry.registerBlock( + ModBlocks.MatterFabricatorEffectBlock = new LightGlass(Material.glass, false).setHardness(0.1F) + .setBlockTextureName(CORE.MODID + ":" + "blockMFEffect").setStepSound(Block.soundTypeGlass), + "blockMFEffect"); - //Fluids + // Fluids FluidRegistryHandler.registerFluids(); - //Workbench - blockWorkbench = new Machine_Workbench().setHardness(1.5F); - blockWorkbenchAdvanced = new Machine_WorkbenchAdvanced().setHardness(2.5F); + // Workbench + ModBlocks.blockWorkbench = new Machine_Workbench().setHardness(1.5F); + ModBlocks.blockWorkbenchAdvanced = new Machine_WorkbenchAdvanced().setHardness(2.5F); - } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java index b7ac24a71b..0160da883f 100644 --- a/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java +++ b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java @@ -9,23 +9,25 @@ import net.minecraft.world.World; public class AdvancedBlock extends Block { - protected AdvancedBlock(String unlocalizedName, Material material, CreativeTabs x, float blockHardness, float blockResistance, float blockLightLevel, - String blockHarvestTool, int blockHarvestLevel, SoundType BlockSound) { - super(material); - this.setBlockName(unlocalizedName); - this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(x); - this.setHardness(blockHardness); //block Hardness - this.setResistance(blockResistance); - this.setLightLevel(blockLightLevel); - this.setHarvestLevel(blockHarvestTool, blockHarvestLevel); - this.setStepSound(BlockSound); - } - - @Override - public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) - { - return false; - } + protected AdvancedBlock(final String unlocalizedName, final Material material, final CreativeTabs x, + final float blockHardness, final float blockResistance, final float blockLightLevel, + final String blockHarvestTool, final int blockHarvestLevel, final SoundType BlockSound) { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(x); + this.setHardness(blockHardness); // block Hardness + this.setResistance(blockResistance); + this.setLightLevel(blockLightLevel); + this.setHarvestLevel(blockHarvestTool, blockHarvestLevel); + this.setStepSound(BlockSound); + } + + @Override + public boolean onBlockActivated(final World p_149727_1_, final int p_149727_2_, final int p_149727_3_, + final int p_149727_4_, final EntityPlayer p_149727_5_, final int p_149727_6_, final float p_149727_7_, + final float p_149727_8_, final float p_149727_9_) { + return false; + } } diff --git a/src/Java/gtPlusPlus/core/block/base/BasicBlock.java b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java index c95f37d9c5..64ee68224e 100644 --- a/src/Java/gtPlusPlus/core/block/base/BasicBlock.java +++ b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java @@ -8,45 +8,43 @@ import net.minecraft.block.material.Material; public class BasicBlock extends Block { - public BasicBlock(final String unlocalizedName, final Material material) { - super(material); - this.setBlockName(Utils.sanitizeString(unlocalizedName)); - this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setHardness(2.0F); - this.setResistance(6.0F); - this.setLightLevel(0.0F); - this.setHarvestLevel("pickaxe", 2); - this.setStepSound(soundTypeMetal); - } - - - public static enum BlockTypes { - STANDARD("blockBlock", "pickaxe", soundTypeStone), - FRAME("blockFrameGt", "wrench", soundTypeMetal); - - private String TEXTURE_NAME; - private String HARVEST_TOOL; - private SoundType soundOfBlock; - private BlockTypes (final String textureName, final String harvestTool, final SoundType blockSound) - { - this.TEXTURE_NAME = textureName; - this.HARVEST_TOOL = harvestTool; - this.soundOfBlock = blockSound; - } - - public String getTexture() { - return TEXTURE_NAME; - } - - public String getHarvestTool(){ - return HARVEST_TOOL; - } - - public SoundType getBlockSoundType(){ - return soundOfBlock; - } - - } - + public static enum BlockTypes { + STANDARD("blockBlock", "pickaxe", Block.soundTypeStone), FRAME("blockFrameGt", "wrench", Block.soundTypeMetal); + + private String TEXTURE_NAME; + private String HARVEST_TOOL; + private SoundType soundOfBlock; + + private BlockTypes(final String textureName, final String harvestTool, final SoundType blockSound) { + this.TEXTURE_NAME = textureName; + this.HARVEST_TOOL = harvestTool; + this.soundOfBlock = blockSound; + } + + public SoundType getBlockSoundType() { + return this.soundOfBlock; + } + + public String getHarvestTool() { + return this.HARVEST_TOOL; + } + + public String getTexture() { + return this.TEXTURE_NAME; + } + + } + + public BasicBlock(final String unlocalizedName, final Material material) { + super(material); + this.setBlockName(Utils.sanitizeString(unlocalizedName)); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(2.0F); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHarvestLevel("pickaxe", 2); + this.setStepSound(Block.soundTypeMetal); + } + } diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java index 5d003fc2a3..f389f5bf32 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -13,137 +13,141 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.world.IBlockAccess; -public class BlockBaseModular extends BasicBlock{ +public class BlockBaseModular extends BasicBlock { - protected int blockColour; - protected BlockTypes thisBlock; - protected String thisBlockMaterial; - protected final String thisBlockType; + protected int blockColour; + protected BlockTypes thisBlock; + protected String thisBlockMaterial; + protected final String thisBlockType; - public BlockBaseModular(String unlocalizedName, String blockMaterial, BlockTypes blockType, int colour) { - super(blockType.getTexture()+unlocalizedName, Material.iron); + public BlockBaseModular(final String unlocalizedName, final String blockMaterial, final BlockTypes blockType, + final int colour) { + super(blockType.getTexture() + unlocalizedName, Material.iron); this.setHarvestLevel(blockType.getHarvestTool(), 2); - this.setBlockTextureName(CORE.MODID+":"+blockType.getTexture()); + this.setBlockTextureName(CORE.MODID + ":" + blockType.getTexture()); this.blockColour = colour; this.thisBlock = blockType; this.thisBlockMaterial = blockMaterial; this.thisBlockType = blockType.name().toUpperCase(); - this.setBlockName(GetProperName()); - - if (!CORE.DEBUG){ - //Utils.LOG_INFO("=============Block Info Dump============="); - //Utils.LOG_INFO("thisBlock.name().toLowerCase() - "+thisBlock.name().toLowerCase()); - //Utils.LOG_INFO("This Blocks Type - "+thisBlockType); - //Utils.LOG_INFO("BlockTypes.STANDARD.name().toLowerCase() - "+BlockTypes.STANDARD.name().toLowerCase()); - //Utils.LOG_INFO("BlockTypes.FRAME.name().toLowerCase() - "+BlockTypes.FRAME.name().toLowerCase()); - //Utils.LOG_INFO("blockMaterial - "+blockMaterial); - //Utils.LOG_INFO("=========================================="); + this.setBlockName(this.GetProperName()); + + if (!CORE.DEBUG) { + // Utils.LOG_INFO("=============Block Info Dump============="); + // Utils.LOG_INFO("thisBlock.name().toLowerCase() - + // "+thisBlock.name().toLowerCase()); + // Utils.LOG_INFO("This Blocks Type - "+thisBlockType); + // Utils.LOG_INFO("BlockTypes.STANDARD.name().toLowerCase() - + // "+BlockTypes.STANDARD.name().toLowerCase()); + // Utils.LOG_INFO("BlockTypes.FRAME.name().toLowerCase() - + // "+BlockTypes.FRAME.name().toLowerCase()); + // Utils.LOG_INFO("blockMaterial - "+blockMaterial); + // Utils.LOG_INFO("=========================================="); } - - if (thisBlockType == BlockTypes.STANDARD.name().toUpperCase()){ - LanguageRegistry.addName(this, "Block of "+blockMaterial); - //Utils.LOG_INFO("Registered Block in Language Registry as: "+"Block of "+blockMaterial); + + if (this.thisBlockType == BlockTypes.STANDARD.name().toUpperCase()) { + LanguageRegistry.addName(this, "Block of " + blockMaterial); + // Utils.LOG_INFO("Registered Block in Language Registry as: + // "+"Block of "+blockMaterial); } - else if (thisBlockType == BlockTypes.FRAME.name().toUpperCase()){ - LanguageRegistry.addName(this, blockMaterial+ " Frame Box"); - //Utils.LOG_INFO("Registered Block in Language Registry as: "+blockMaterial+ " Frame Box"); + else if (this.thisBlockType == BlockTypes.FRAME.name().toUpperCase()) { + LanguageRegistry.addName(this, blockMaterial + " Frame Box"); + // Utils.LOG_INFO("Registered Block in Language Registry as: + // "+blockMaterial+ " Frame Box"); } else { LanguageRegistry.addName(this, blockMaterial); - //Utils.LOG_INFO("Registered Block in Language Registry as: "+blockMaterial); - } - - //setOreDict(unlocalizedName, blockType); - if (thisBlockType == BlockTypes.STANDARD.name().toUpperCase()){ - GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); - //Utils.LOG_INFO("Registered Block in Block Registry as: "+"Block of "+blockMaterial); + // Utils.LOG_INFO("Registered Block in Language Registry as: + // "+blockMaterial); } - else if (thisBlockType == BlockTypes.FRAME.name().toUpperCase()){ - GameRegistry.registerBlock(this, ItemBlockGtFrameBox.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); - //Utils.LOG_INFO("Registered Block in Block Registry as: "+blockMaterial+" Frame Box"); + + // setOreDict(unlocalizedName, blockType); + if (this.thisBlockType == BlockTypes.STANDARD.name().toUpperCase()) { + GameRegistry.registerBlock(this, ItemBlockGtBlock.class, + Utils.sanitizeString(blockType.getTexture() + unlocalizedName)); + // Utils.LOG_INFO("Registered Block in Block Registry as: "+"Block + // of "+blockMaterial); + } + else if (this.thisBlockType == BlockTypes.FRAME.name().toUpperCase()) { + GameRegistry.registerBlock(this, ItemBlockGtFrameBox.class, + Utils.sanitizeString(blockType.getTexture() + unlocalizedName)); + // Utils.LOG_INFO("Registered Block in Block Registry as: + // "+blockMaterial+" Frame Box"); } else { - GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); - //Utils.LOG_INFO("Registered Block in Block Registry as: "+blockMaterial); + GameRegistry.registerBlock(this, ItemBlockGtBlock.class, + Utils.sanitizeString(blockType.getTexture() + unlocalizedName)); + // Utils.LOG_INFO("Registered Block in Block Registry as: + // "+blockMaterial); } - - + } - /** - * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha - */ @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass() - { - if (thisBlock == BlockTypes.FRAME){ - return 1; + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); } - return 0; + + return this.blockColour; } - - /*@Override - public String getLocalizedName() { - String tempIngot; - if (thisBlock == BlockTypes.STANDARD){ - tempIngot = "Block of "+thisBlockMaterial; - } - else if (thisBlock == BlockTypes.FRAME){ - tempIngot = thisBlockMaterial + " Frame Box"; - } - else { - tempIngot = getUnlocalizedName().replace("tile.blockGt", "ingot"); - } - return tempIngot; - }*/ - + /* + * @Override public String getLocalizedName() { String tempIngot; if + * (thisBlock == BlockTypes.STANDARD){ tempIngot = "Block of " + * +thisBlockMaterial; } else if (thisBlock == BlockTypes.FRAME){ tempIngot + * = thisBlockMaterial + " Frame Box"; } else { + * + * tempIngot = getUnlocalizedName().replace("tile.blockGt", "ingot"); } + * return tempIngot; } + */ + public String GetProperName() { - String tempIngot; - if (thisBlock == BlockTypes.STANDARD){ - tempIngot = "Block of "+thisBlockMaterial; + String tempIngot; + if (this.thisBlock == BlockTypes.STANDARD) { + tempIngot = "Block of " + this.thisBlockMaterial; } - else if (thisBlock == BlockTypes.FRAME){ - tempIngot = thisBlockMaterial + " Frame Box"; + else if (this.thisBlock == BlockTypes.FRAME) { + tempIngot = this.thisBlockMaterial + " Frame Box"; } else { - tempIngot = getUnlocalizedName().replace("tile.blockGt", "ingot"); + tempIngot = this.getUnlocalizedName().replace("tile.blockGt", "ingot"); } return tempIngot; } - @Override - public boolean isOpaqueCube() - { - return false; - } - + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 + * for alpha + */ @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iIcon) - { - this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + thisBlock.getTexture()); + public int getRenderBlockPass() { + if (this.thisBlock == BlockTypes.FRAME) { + return 1; + } + return 0; } @Override - public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4){ - - if (this.blockColour == 0){ + public int getRenderColor(final int aMeta) { + if (this.blockColour == 0) { return MathUtils.generateSingularRandomHexValue(); } - + return this.blockColour; } - - @Override - public int getRenderColor(int aMeta) { - if (this.blockColour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - - return this.blockColour; - } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + this.thisBlock.getTexture()); + } } diff --git a/src/Java/gtPlusPlus/core/block/base/MetaBlock.java b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java index 4009c36726..3763b71448 100644 --- a/src/Java/gtPlusPlus/core/block/base/MetaBlock.java +++ b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java @@ -7,22 +7,22 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class MetaBlock extends MultiTextureBlock { +public class MetaBlock extends MultiTextureBlock { - protected MetaBlock(String unlocalizedName, Material material, SoundType soundType) { - super(unlocalizedName, material, soundType); - } - - @Override - public int damageDropped(int meta) { - return meta; - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 6; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } - -}
\ No newline at end of file + protected MetaBlock(final String unlocalizedName, final Material material, final SoundType soundType) { + super(unlocalizedName, material, soundType); + } + + @Override + public int damageDropped(final int meta) { + return meta; + } + + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { + for (int i = 0; i < 6; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java b/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java index 4f022bae6d..9953dfa991 100644 --- a/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java +++ b/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java @@ -7,30 +7,29 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; -public class MultiTextureBlock extends Block { +public class MultiTextureBlock extends Block { public IIcon[] icons = new IIcon[6]; - - protected MultiTextureBlock(String unlocalizedName, Material material, SoundType blockSound) - { - super(material); - this.setBlockName(unlocalizedName); - this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setHardness(2.0F); - this.setResistance(6.0F); - this.setStepSound(blockSound); - } - - @Override - public void registerBlockIcons(IIconRegister reg) { - for (int i = 0; i < 6; i ++) { - this.icons[i] = reg.registerIcon(this.textureName + "_" + i); - } - } - - @Override - public IIcon getIcon(int side, int meta) { - return this.icons[side]; - } + + protected MultiTextureBlock(final String unlocalizedName, final Material material, final SoundType blockSound) { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(2.0F); + this.setResistance(6.0F); + this.setStepSound(blockSound); + } + + @Override + public IIcon getIcon(final int side, final int meta) { + return this.icons[side]; + } + + @Override + public void registerBlockIcons(final IIconRegister reg) { + for (int i = 0; i < 6; i++) { + this.icons[i] = reg.registerIcon(this.textureName + "_" + i); + } + } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/general/LightGlass.java b/src/Java/gtPlusPlus/core/block/general/LightGlass.java index 873752d8a3..9b4d8bf1b8 100644 --- a/src/Java/gtPlusPlus/core/block/general/LightGlass.java +++ b/src/Java/gtPlusPlus/core/block/general/LightGlass.java @@ -13,17 +13,15 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class LightGlass extends BlockBreakable -{ - private int state = 0; - private int a = 255; - private int r = 255; - private int g = 0; - private int b = 0; - private int hex; +public class LightGlass extends BlockBreakable { + private int state = 0; + private final int a = 255; + private int r = 255; + private int g = 0; + private int b = 0; + private int hex; - public LightGlass(Material mat, boolean bool) - { + public LightGlass(final Material mat, final boolean bool) { super("blockMFEffect", mat, bool); this.setCreativeTab(AddToCreativeTab.tabBlock); this.setBlockName("blockMFEffect"); @@ -34,94 +32,99 @@ public class LightGlass extends BlockBreakable } /** - * Returns the quantity of items to drop on block destruction. + * Return true if a player with Silk Touch can harvest this block directly, + * and not its normal drops. */ @Override - public int quantityDropped(Random rand) - { - return 0; + protected boolean canSilkHarvest() { + return false; + } + + @Override + // http://stackoverflow.com/questions/31784658/how-can-i-loop-through-all-rgb-combinations-in-rainbow-order-in-java + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + if (this.state == 0) { + this.g++; + if (this.g == 255) { + this.state = 1; + } + } + if (this.state == 1) { + this.r--; + if (this.r == 0) { + this.state = 2; + } + } + if (this.state == 2) { + this.b++; + if (this.b == 255) { + this.state = 3; + } + } + if (this.state == 3) { + this.g--; + if (this.g == 0) { + this.state = 4; + } + } + if (this.state == 4) { + this.r++; + if (this.r == 255) { + this.state = 5; + } + } + if (this.state == 5) { + this.b--; + if (this.b == 0) { + this.state = 0; + } + } + this.hex = (this.a << 24) + (this.r << 16) + (this.g << 8) + this.b; + return this.hex; } /** - * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + * Returns which pass should this block be rendered on. 0 for solids and 1 + * for alpha */ @Override @SideOnly(Side.CLIENT) - public int getRenderBlockPass() - { + public int getRenderBlockPass() { return 0; } /** - * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + * Returns the quantity of items to drop on block destruction. */ @Override - public boolean renderAsNormalBlock() - { - return true; + public int quantityDropped(final Random rand) { + return 0; } /** - * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops. + * A randomly called display update to be able to add particles or other + * items for display */ @Override - protected boolean canSilkHarvest() - { - return false; + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World world, final int posX, final int posY, final int posZ, + final Random random) { + Utils.spawnFX(world, posX, posY, posZ, "smoke", "cloud"); + } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iIcon) - { + public void registerBlockIcons(final IIconRegister iIcon) { this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockMFEffect"); } - @Override - //http://stackoverflow.com/questions/31784658/how-can-i-loop-through-all-rgb-combinations-in-rainbow-order-in-java - public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) - { - if(state == 0){ - g++; - if(g == 255) - state = 1; - } - if(state == 1){ - r--; - if(r == 0) - state = 2; - } - if(state == 2){ - b++; - if(b == 255) - state = 3; - } - if(state == 3){ - g--; - if(g == 0) - state = 4; - } - if(state == 4){ - r++; - if(r == 255) - state = 5; - } - if(state == 5){ - b--; - if(b == 0) - state = 0; - } - hex = (a << 24) + (r << 16) + (g << 8) + (b); - return hex; - } - /** - * A randomly called display update to be able to add particles or other items for display + * If this block doesn't render as an ordinary block it will return False + * (examples: signs, buttons, stairs, etc) */ @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int posX, int posY, int posZ, Random random){ - Utils.spawnFX(world, posX, posY, posZ, "smoke", "cloud"); - + public boolean renderAsNormalBlock() { + return true; } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java b/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java index ab5417a0e5..2f659b7806 100644 --- a/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java +++ b/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java @@ -1,12 +1,11 @@ package gtPlusPlus.core.block.general.antigrief; -import static gtPlusPlus.core.block.ModBlocks.blockGriefSaver; - import java.util.List; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityReverter; @@ -27,250 +26,239 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class TowerDevice extends Block { - private static IIcon TEX_ANTIBUILDER; - public static final int META_ANTIBUILDER = 9; - private boolean bUnbreakable; - - public TowerDevice() - { - super(Material.wood); - setHardness(10.0F); - setResistance(35.0F); - setStepSound(Block.soundTypeWood); - setCreativeTab(AddToCreativeTab.tabMachines); - } - - public int tickRate() - { - return 15; - } - - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("bUnbreakable", bUnbreakable); + private static IIcon TEX_ANTIBUILDER; + public static final int META_ANTIBUILDER = 9; + public static boolean areNearbyLockBlocks(final World world, final int x, final int y, final int z) { + boolean locked = false; + for (int dx = x - 2; dx <= x + 2; dx++) { + for (int dy = y - 2; dy <= y + 2; dy++) { + for (int dz = z - 2; dz <= z + 2; dz++) { + if (world.getBlock(dx, dy, dz) == ModBlocks.blockGriefSaver + && world.getBlockMetadata(dx, dy, dz) == 4) { + locked = true; + } + } + } + } + return locked; + } + + public static void changeToActiveVanishBlock(final World par1World, final int x, final int y, final int z, + final int meta) { + TowerDevice.changeToBlockMeta(par1World, x, y, z, meta); + par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.pop", 0.3F, 0.6F); + + final Block thereBlockID = par1World.getBlock(x, y, z); + par1World.scheduleBlockUpdate(x, y, z, thereBlockID, + TowerDevice.getTickRateFor(thereBlockID, meta, par1World.rand)); + } + + private static void changeToBlockMeta(final World par1World, final int x, final int y, final int z, + final int meta) { + final Block thereBlockID = par1World.getBlock(x, y, z); + if (thereBlockID == ModBlocks.blockGriefSaver) { + par1World.setBlock(x, y, z, thereBlockID, meta, 3); + par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z); + par1World.notifyBlocksOfNeighborChange(x, y, z, thereBlockID); + } + } + + public static void checkAndActivateVanishBlock(final World world, final int x, final int y, final int z) { + final Block thereID = world.getBlock(x, y, z); + final int thereMeta = world.getBlockMetadata(x, y, z); + } + + private static int getTickRateFor(final Block thereBlockID, final int meta, final Random rand) { + return 15; + } + + public static void unlockBlock(final World par1World, final int x, final int y, final int z) { + final Block thereBlockID = par1World.getBlock(x, y, z); + final int thereBlockMeta = par1World.getBlockMetadata(x, y, z); + if (thereBlockID == ModBlocks.blockGriefSaver || thereBlockMeta == 4) { + TowerDevice.changeToBlockMeta(par1World, x, y, z, 5); + par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.click", 0.3F, 0.6F); + } + } + + private boolean bUnbreakable; + + public TowerDevice() { + super(Material.wood); + this.setHardness(10.0F); + this.setResistance(35.0F); + this.setStepSound(Block.soundTypeWood); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @Override + public TileEntity createTileEntity(final World world, final int metadata) { + if (metadata == 0) { + Utils.LOG_INFO("I have been created. [Antigriefer]" + this.getLocalizedName()); + return new TileEntityReverter(); + } + return null; + } + + @Override + public int damageDropped(final int meta) { + return meta; + } + + @Override + public float getBlockHardness(final World world, final int x, final int y, final int z) { + final int meta = world.getBlockMetadata(x, y, z); + return super.getBlockHardness(world, x, y, z); + } + + @Override + public float getExplosionResistance(final Entity par1Entity, final World world, final int x, final int y, + final int z, final double explosionX, final double explosionY, final double explosionZ) { + final int meta = world.getBlockMetadata(x, y, z); + return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ); + } + + @Override + public IIcon getIcon(final int side, final int meta) { + return TowerDevice.TEX_ANTIBUILDER; + } + + @Override + public Item getItemDropped(final int meta, final Random par2Random, final int par3) { + switch (meta) { + case 0: + return null; + } + return Item.getItemFromBlock(this); + } + + @Override + public int getLightValue(final IBlockAccess world, final int x, final int y, final int z) { + final Block blockID = world.getBlock(x, y, z); + final int meta = world.getBlockMetadata(x, y, z); + if (blockID != this) { + return 0; + } + return 10; + } + + @Override + public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) { + par3List.add(new ItemStack(par1, 1, 9)); + } + + @Override + public boolean hasTileEntity(final int metadata) { + return metadata == 0; + } + + private boolean isInactiveTrapCharged(final World par1World, final int x, final int y, final int z) { + return false; + } + + private boolean isReactorReady(final World world, final int x, final int y, final int z) { + if (world.getBlock(x, y + 1, z) != Blocks.redstone_block || world.getBlock(x, y - 1, z) != Blocks.redstone_block + || world.getBlock(x + 1, y, z) != Blocks.redstone_block + || world.getBlock(x - 1, y, z) != Blocks.redstone_block + || world.getBlock(x, y, z + 1) != Blocks.redstone_block + || world.getBlock(x, y, z - 1) != Blocks.redstone_block) { + return false; + } + return true; + } + + private void letsBuild(final World par1World, final int x, final int y, final int z) { + + } + + public void loadNBTData(final NBTTagCompound aNBT) { + this.bUnbreakable = aNBT.getBoolean("bUnbreakable"); + } + + @Override + public boolean onBlockActivated(final World par1World, final int x, final int y, final int z, + final EntityPlayer par5EntityPlayer, final int par6, final float par7, final float par8, final float par9) { + final int meta = par1World.getBlockMetadata(x, y, z); + return false; + } + + @Override + public void onBlockAdded(final World par1World, final int x, final int y, final int z) { + final int meta = par1World.getBlockMetadata(x, y, z); + if (!par1World.isRemote) { + + } + } + + @Override + public void onNeighborBlockChange(final World par1World, final int x, final int y, final int z, + final Block myBlockID) { + final int meta = par1World.getBlockMetadata(x, y, z); + if (!par1World.isRemote) { + + } + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World par1World, final int x, final int y, final int z, + final Random par5Random) { + final int meta = par1World.getBlockMetadata(x, y, z); + if (meta == 3 || meta == 1 || meta == 9) { + for (int i = 0; i < 1; i++) { + this.sparkle(par1World, x, y, z, par5Random); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister par1IconRegister) { + TowerDevice.TEX_ANTIBUILDER = par1IconRegister.registerIcon(CORE.MODID + ":" + "blockAntiGrief"); + } + + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setBoolean("bUnbreakable", this.bUnbreakable); + } + + public void sparkle(final World world, final int x, final int y, final int z, final Random rand) { + final double offset = 0.0625D; + for (int side = 0; side < 6; side++) { + double rx = x + rand.nextFloat(); + double ry = y + rand.nextFloat(); + double rz = z + rand.nextFloat(); + if (side == 0 && !world.getBlock(x, y + 1, z).isOpaqueCube()) { + ry = y + 1 + offset; + } + if (side == 1 && !world.getBlock(x, y - 1, z).isOpaqueCube()) { + ry = y + 0 - offset; + } + if (side == 2 && !world.getBlock(x, y, z + 1).isOpaqueCube()) { + rz = z + 1 + offset; + } + if (side == 3 && !world.getBlock(x, y, z - 1).isOpaqueCube()) { + rz = z + 0 - offset; + } + if (side == 4 && !world.getBlock(x + 1, y, z).isOpaqueCube()) { + rx = x + 1 + offset; + } + if (side == 5 && !world.getBlock(x - 1, y, z).isOpaqueCube()) { + rx = x + 0 - offset; + } + if (rx < x || rx > x + 1 || ry < 0.0D || ry > y + 1 || rz < z || rz > z + 1) { + world.spawnParticle("reddust", rx, ry, rz, 0.0D, 0.0D, 0.0D); + } + } + } + + public int tickRate() { + return 15; } - public void loadNBTData(NBTTagCompound aNBT) { - bUnbreakable = aNBT.getBoolean("bUnbreakable"); + @Override + public void updateTick(final World par1World, final int x, final int y, final int z, final Random par5Random) { + if (!par1World.isRemote) { + final int meta = par1World.getBlockMetadata(x, y, z); + } } - - public IIcon getIcon(int side, int meta) - { - return TEX_ANTIBUILDER; - } - - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { - TEX_ANTIBUILDER = par1IconRegister.registerIcon(CORE.MODID + ":" + "blockAntiGrief"); - } - - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) - { - par3List.add(new ItemStack(par1, 1, 9)); - } - - public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) - { - int meta = par1World.getBlockMetadata(x, y, z); - return false; - } - - public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) - { - int meta = world.getBlockMetadata(x, y, z); - return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ); - } - - public float getBlockHardness(World world, int x, int y, int z) - { - int meta = world.getBlockMetadata(x, y, z); - return super.getBlockHardness(world, x, y, z); - } - - public static boolean areNearbyLockBlocks(World world, int x, int y, int z) - { - boolean locked = false; - for (int dx = x - 2; dx <= x + 2; dx++) { - for (int dy = y - 2; dy <= y + 2; dy++) { - for (int dz = z - 2; dz <= z + 2; dz++) { - if ((world.getBlock(dx, dy, dz) == blockGriefSaver) && (world.getBlockMetadata(dx, dy, dz) == 4)) { - locked = true; - } - } - } - } - return locked; - } - - public static void unlockBlock(World par1World, int x, int y, int z) - { - Block thereBlockID = par1World.getBlock(x, y, z); - int thereBlockMeta = par1World.getBlockMetadata(x, y, z); - if ((thereBlockID == blockGriefSaver) || (thereBlockMeta == 4)) - { - changeToBlockMeta(par1World, x, y, z, 5); - par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.click", 0.3F, 0.6F); - } - } - - private static void changeToBlockMeta(World par1World, int x, int y, int z, int meta) - { - Block thereBlockID = par1World.getBlock(x, y, z); - if ((thereBlockID == blockGriefSaver)) - { - par1World.setBlock(x, y, z, thereBlockID, meta, 3); - par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z); - par1World.notifyBlocksOfNeighborChange(x, y, z, thereBlockID); - } - } - - public void onBlockAdded(World par1World, int x, int y, int z) - { - int meta = par1World.getBlockMetadata(x, y, z); - if (!par1World.isRemote) { - - } - } - - public void onNeighborBlockChange(World par1World, int x, int y, int z, Block myBlockID) - { - int meta = par1World.getBlockMetadata(x, y, z); - if (!par1World.isRemote) - { - - } - } - - public void updateTick(World par1World, int x, int y, int z, Random par5Random) - { - if (!par1World.isRemote) - { - int meta = par1World.getBlockMetadata(x, y, z); - } - } - - private void letsBuild(World par1World, int x, int y, int z) - { - - } - - private boolean isInactiveTrapCharged(World par1World, int x, int y, int z) - { - return false; - } - - private boolean isReactorReady(World world, int x, int y, int z) - { - if ((world.getBlock(x, y + 1, z) != Blocks.redstone_block) || - (world.getBlock(x, y - 1, z) != Blocks.redstone_block) || - (world.getBlock(x + 1, y, z) != Blocks.redstone_block) || - (world.getBlock(x - 1, y, z) != Blocks.redstone_block) || - (world.getBlock(x, y, z + 1) != Blocks.redstone_block) || - (world.getBlock(x, y, z - 1) != Blocks.redstone_block)) { - return false; - } - return true; - } - - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World par1World, int x, int y, int z, Random par5Random) - { - int meta = par1World.getBlockMetadata(x, y, z); - if ((meta == 3) || (meta == 1) || (meta == 9)) { - for (int i = 0; i < 1; i++) { - sparkle(par1World, x, y, z, par5Random); - } - } - } - - public void sparkle(World world, int x, int y, int z, Random rand) - { - double offset = 0.0625D; - for (int side = 0; side < 6; side++) - { - double rx = x + rand.nextFloat(); - double ry = y + rand.nextFloat(); - double rz = z + rand.nextFloat(); - if ((side == 0) && (!world.getBlock(x, y + 1, z).isOpaqueCube())) { - ry = y + 1 + offset; - } - if ((side == 1) && (!world.getBlock(x, y - 1, z).isOpaqueCube())) { - ry = y + 0 - offset; - } - if ((side == 2) && (!world.getBlock(x, y, z + 1).isOpaqueCube())) { - rz = z + 1 + offset; - } - if ((side == 3) && (!world.getBlock(x, y, z - 1).isOpaqueCube())) { - rz = z + 0 - offset; - } - if ((side == 4) && (!world.getBlock(x + 1, y, z).isOpaqueCube())) { - rx = x + 1 + offset; - } - if ((side == 5) && (!world.getBlock(x - 1, y, z).isOpaqueCube())) { - rx = x + 0 - offset; - } - if ((rx < x) || (rx > x + 1) || (ry < 0.0D) || (ry > y + 1) || (rz < z) || (rz > z + 1)) { - world.spawnParticle("reddust", rx, ry, rz, 0.0D, 0.0D, 0.0D); - } - } - } - - public static void checkAndActivateVanishBlock(World world, int x, int y, int z) - { - Block thereID = world.getBlock(x, y, z); - int thereMeta = world.getBlockMetadata(x, y, z); - } - - public static void changeToActiveVanishBlock(World par1World, int x, int y, int z, int meta) - { - changeToBlockMeta(par1World, x, y, z, meta); - par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.pop", 0.3F, 0.6F); - - Block thereBlockID = par1World.getBlock(x, y, z); - par1World.scheduleBlockUpdate(x, y, z, thereBlockID, getTickRateFor(thereBlockID, meta, par1World.rand)); - } - - private static int getTickRateFor(Block thereBlockID, int meta, Random rand) - { - return 15; - } - - public int getLightValue(IBlockAccess world, int x, int y, int z) - { - Block blockID = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - if (blockID != this) { - return 0; - } - return 10; - } - - public boolean hasTileEntity(int metadata) - { - return (metadata == 0); - } - - public TileEntity createTileEntity(World world, int metadata) - { - if (metadata == 0) { - Utils.LOG_INFO("I have been created. [Antigriefer]"+this.getLocalizedName()); - return new TileEntityReverter(); - } - return null; - } - - public Item getItemDropped(int meta, Random par2Random, int par3) - { - switch (meta) - { - case 0: - return null; - } - return Item.getItemFromBlock(this); - } - - public int damageDropped(int meta) - { - return meta; - } } diff --git a/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java index 6a8c89064f..768822dd6e 100644 --- a/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java +++ b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java @@ -14,38 +14,42 @@ import net.minecraftforge.fluids.Fluid; public class BlockFluidJackDaniels extends BlockFluidClassic { - @SideOnly(Side.CLIENT) - protected IIcon stillIcon; - @SideOnly(Side.CLIENT) - protected IIcon flowingIcon; - - public BlockFluidJackDaniels(Fluid fluid, Material material) { - super(fluid, material); - setCreativeTab(AddToCreativeTab.tabMisc); - } - - @Override - public IIcon getIcon(int side, int meta) { - return (side == 0 || side == 1)? stillIcon : flowingIcon; - } - - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister register) { - stillIcon = register.registerIcon(CORE.MODID+":fluids/fluid.jackdaniels"); - flowingIcon = register.registerIcon(CORE.MODID+":fluids/fluid.jackdaniels"); - } - - @Override - public boolean canDisplace(IBlockAccess world, int x, int y, int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; - return super.canDisplace(world, x, y, z); - } - - @Override - public boolean displaceIfPossible(World world, int x, int y, int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; - return super.displaceIfPossible(world, x, y, z); - } - -} + @SideOnly(Side.CLIENT) + protected IIcon stillIcon; + @SideOnly(Side.CLIENT) + protected IIcon flowingIcon; + + public BlockFluidJackDaniels(final Fluid fluid, final Material material) { + super(fluid, material); + this.setCreativeTab(AddToCreativeTab.tabMisc); + } + + @Override + public boolean canDisplace(final IBlockAccess world, final int x, final int y, final int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(final World world, final int x, final int y, final int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.displaceIfPossible(world, x, y, z); + } + + @Override + public IIcon getIcon(final int side, final int meta) { + return side == 0 || side == 1 ? this.stillIcon : this.flowingIcon; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(final IIconRegister register) { + this.stillIcon = register.registerIcon(CORE.MODID + ":fluids/fluid.jackdaniels"); + this.flowingIcon = register.registerIcon(CORE.MODID + ":fluids/fluid.jackdaniels"); + } + +} 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<TileEntityHeliumGenerator> -{ +public class ContainerHeliumGenerator extends ContainerBase<TileEntityHeliumGenerator> { 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<String> getNetworkedFields() - { - List<String> ret = super.getNetworkedFields(); + public List<String> getNetworkedFields() { + final List<String> 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, this.yCoord, this.zCoord) == this + && player.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D; } - public boolean calculateHeatEffects() - { - Utils.LOG_WARNING("calculateHeatEffects"); - if ((this.heat < 8000) || (!IC2.platform.isSimulating()) || (ConfigUtil.getFloat(MainConfig.get(), "protection/reactorExplosionPowerLimit") <= 0.0F)) { + public boolean isUsefulItem(final ItemStack stack, final boolean forInsertion) { + // Utils.LOG_WARNING("isUsefulItem"); + final Item item = stack.getItem(); + if (forInsertion && this.fluidcoolreactor && item instanceof ItemReactorHeatStorage + && ((ItemReactorHeatStorage) item).getCustomDamage(stack) > 0) { return false; } - float power = this.heat / this.maxHeat; - if (power >= 1.0F) - { - explode(); + if (item instanceof IReactorComponent) { return true; } - if ((power >= 0.85F) && (this.worldObj.rand.nextFloat() <= 0.2F * this.hem)) - { - int[] coord = getRandCoord(2); - if (coord != null) - { - 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)) - { - 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) - { - 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++) - { - 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)) - { - int[] coord = getRandCoord(2); - if (coord != null) - { - 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)) - { - int[] coord = getRandCoord(2); - if ((coord != null) && - (this.worldObj.getTileEntity(coord[0], coord[1], coord[2]) == null)) - { - Block block = this.worldObj.getBlock(coord[0], coord[1], coord[2]); - 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; + 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(); } - public int[] getRandCoord(int radius) - { - if (radius <= 0) { - return null; - } - 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; + @Override + public void onDataPacket(final net.minecraft.network.NetworkManager net, final S35PacketUpdateTileEntity packet) { + super.onDataPacket(net, packet); + this.readFromNBT(packet.func_148857_g()); } - public void processChambers() - { + @Override + public void openInventory() { + } + + public void processChambers() { Utils.LOG_WARNING("processChambers"); - int size = getReactorSize(); + final int size = this.getReactorSize(); for (int pass = 0; pass < 6; pass++) { for (int y = 0; y < 3; y++) { - for (int x = 0; x < size; x++) - { - ItemStack stack = this.reactorSlot.get(x, y); - if ((stack != null) && ((stack.getItem() instanceof IReactorComponent))) - { - IReactorComponent comp = (IReactorComponent)stack.getItem(); + for (int x = 0; x < size; x++) { + final ItemStack stack = this.reactorSlot.get(x, y); + if (stack != null && stack.getItem() instanceof IReactorComponent) { + final IReactorComponent comp = (IReactorComponent) stack.getItem(); comp.processChamber(this, stack, x, y, pass == 0); } } @@ -471,175 +423,170 @@ public class TileEntityHeliumGenerator extends TileEntityInventory implements II } @Override - public ChunkCoordinates getPosition() - { - return new ChunkCoordinates(this.xCoord, this.yCoord, this.zCoord); - } - - @Override - public World getWorld() { - return this.worldObj; - } - - @Override - public int getHeat() { - return this.heat; + public boolean produceEnergy() { + Utils.LOG_WARNING("produceEnergy"); + return this.receiveredstone() + && ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/generator") > 0.0F; } @Override - public void setHeat(int heat1) - { - this.heat = heat1; - } + public void readFromNBT(final NBTTagCompound nbttagcompound) { + super.readFromNBT(nbttagcompound); - @Override - public int addHeat(int amount) - { - this.heat += amount; - return this.heat; + // this.heliumStack = + // ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Helium")); + final NBTTagList list = nbttagcompound.getTagList("Items", 10); + for (int i = 0; i < list.tagCount(); ++i) { + final NBTTagCompound stackTag = list.getCompoundTagAt(i); + final 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 int getMaxHeat() - { - return this.maxHeat; + public boolean receiveredstone() { + Utils.LOG_WARNING("receiveRedstone"); + if (this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) || this.redstone) { + this.decrStackSize(-1, 1); + return true; + } + return false; } @Override - public void setMaxHeat(int newMaxHeat) - { - this.maxHeat = newMaxHeat; + public void setActive(final boolean active1) { + Utils.LOG_WARNING("setActive"); + this.active = active1; + if (this.prevActive != active1) { + IC2.network.get().updateTileEntityField(this, "active"); + } + this.prevActive = active1; } @Override - public void addEmitHeat(int heat) - { - this.EmitHeatbuffer += heat; + public void setFacing(final short dir) { + this.facing = dir; } @Override - public float getHeatEffectModifier() - { - return this.hem; + public void setHeat(final int heat1) { + this.heat = heat1; } @Override - public void setHeatEffectModifier(float newHEM) - { + public void setHeatEffectModifier(final float newHEM) { this.hem = newHEM; } @Override - public float getReactorEnergyOutput() - { - return this.output; - } - - @Override - public double getReactorEUEnergyOutput() - { - return getOfferedEnergy(); - } - - public double getOfferedEnergy() - { - return getReactorEnergyOutput() * 5.0F * 1.0F; - } - - @Override - public float addOutput(float energy) - { - return this.output += energy; + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.heliumStack = stack; } @Override - public ItemStack getItemAt(int x, int y) - { - Utils.LOG_WARNING("getItemAt"); - if ((x < 0) || (x >= getReactorSize()) || (y < 0) || (y >= 6)) { - return null; - } - return this.reactorSlot.get(x, y); - } - - @Override - public void setItemAt(int x, int y, ItemStack item) - { + public void setItemAt(final int x, final int y, final ItemStack item) { Utils.LOG_WARNING("setItemAt"); - if ((x < 0) || (x >= getReactorSize()) || (y < 0) || (y >= 6)) { + if (x < 0 || x >= this.getReactorSize() || y < 0 || y >= 6) { return; } this.reactorSlot.put(x, y, item); } - public TileEntityHeliumGenerator() { - this.updateTicker = IC2.random.nextInt(getTickRate()); - this.reactorSlot = new InvSlotRadiation(this, "helium_collector", 0, 54); //TODO - } - @Override - public void explode() { - Utils.LOG_WARNING("Explosion"); - //TODO + public void setMaxHeat(final int newMaxHeat) { + this.maxHeat = newMaxHeat; } @Override - public int getTickRate() - { - return 20; + public void setRedstoneSignal(final boolean redstone) { + this.redstone = redstone; } - public boolean receiveredstone() - { - Utils.LOG_WARNING("receiveRedstone"); - if ((this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) || (this.redstone)) { - decrStackSize(-1, 1); - return true; + public void update2Entity() { + Utils.LOG_WARNING("updateEntity"); + if (++this.progress >= 40) { + // if(++progress >= 300){ + if (this.heliumStack == null) { + this.heliumStack = ItemUtils.getSimpleStack(ModItems.itemHeliumBlob); + } + else if (this.heliumStack.getItem() == ModItems.itemHeliumBlob && this.heliumStack.stackSize < 64) { + this.heliumStack.stackSize++; + } + this.progress = 0; + this.markDirty(); } - return false; } @Override - public boolean produceEnergy() - { - Utils.LOG_WARNING("produceEnergy"); - return (receiveredstone()) && (ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/generator") > 0.0F); - } + protected void updateEntityServer() { + Utils.LOG_WARNING("updateEntityServer"); + super.updateEntity(); - @Override - public void setRedstoneSignal(boolean redstone) - { - this.redstone = redstone; - } + if (this.updateTicker++ % this.getTickRate() != 0) { + return; + } + if (!this.worldObj.doChunksNearChunkExist(this.xCoord, this.yCoord, this.zCoord, 2)) { + this.output = 0.0F; + } + else { - @Override - public boolean isFluidCooled() { - Utils.LOG_WARNING("isFluidCooled"); - return false; + this.dropAllUnfittingStuff(); + + this.output = 0.0F; + this.maxHeat = 10000; + this.hem = 1.0F; + + this.processChambers(); + this.EmitHeatbuffer = 0; + if (this.calculateHeatEffects()) { + return; + } + this.setActive(this.heat >= 1000 || this.output > 0.0F); + + this.markDirty(); + } + IC2.network.get().updateTileEntityField(this, "output"); } @Override - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) - { + public boolean wrenchCanRemove(final EntityPlayer entityPlayer) { return true; } @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) - { + public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final int side) { return true; } @Override - public float getWrenchDropRate() - { - return 1F; - } + public void writeToNBT(final NBTTagCompound nbttagcompound) { + super.writeToNBT(nbttagcompound); - @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) - { - return new ItemStack(ModBlocks.blockHeliumGenerator, 1); + nbttagcompound.setInteger("Progress", this.progress); + nbttagcompound.setShort("Facing", (short) this.facing); + nbttagcompound.setInteger("heat", this.heat); + nbttagcompound.setShort("output", (short) (int) this.getReactorEnergyOutput()); + nbttagcompound.setBoolean("active", this.active); + /* + * if(heliumStack != null) { NBTTagCompound produce = new + * NBTTagCompound(); heliumStack.writeToNBT(produce); + * nbttagcompound.setTag("Helium", produce); } else + * nbttagcompound.removeTag("Helium"); + */ + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < this.getSizeInventory(); ++i) { + if (this.getStackInSlot(i) != null) { + final NBTTagCompound stackTag = new NBTTagCompound(); + stackTag.setByte("Slot", (byte) i); + this.getStackInSlot(i).writeToNBT(stackTag); + list.appendTag(stackTag); + } + } + nbttagcompound.setTag("Items", list); } } |