From 221c2f0fe81430e7dd4087e5f5845bd7c62ec56d Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Wed, 7 Sep 2016 16:36:25 +1000 Subject: % Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus. --- src/Java/gtPlusPlus/core/block/ModBlocks.java | 78 +++ .../gtPlusPlus/core/block/base/AdvancedBlock.java | 31 + .../gtPlusPlus/core/block/base/BasicBlock.java | 52 ++ .../core/block/base/BlockBaseModular.java | 154 +++++ src/Java/gtPlusPlus/core/block/base/MetaBlock.java | 28 + .../core/block/base/MultiTextureBlock.java | 36 ++ .../gtPlusPlus/core/block/general/LightGlass.java | 128 ++++ .../core/block/general/antigrief/TowerDevice.java | 276 +++++++++ .../general/fluids/BlockFluidJackDaniels.java | 51 ++ .../block/general/fluids/FluidRegistryHandler.java | 50 ++ .../core/block/machine/BlockGtFrameBox.java | 35 ++ .../core/block/machine/Machine_Charger.java | 83 +++ .../gtPlusPlus/core/block/machine/Machine_NHG.java | 83 +++ .../core/block/machine/Machine_WireiusDeletus.java | 5 + .../machine/heliumgen/block/HeliumGenerator.java | 165 ++++++ .../container/ContainerHeliumGenerator.java | 75 +++ .../machine/heliumgen/gui/GUIHeliumGenerator.java | 72 +++ .../machine/heliumgen/slots/InvSlotRadiation.java | 78 +++ .../tileentity/TileEntityHeliumGenerator.java | 648 +++++++++++++++++++++ 19 files changed, 2128 insertions(+) create mode 100644 src/Java/gtPlusPlus/core/block/ModBlocks.java create mode 100644 src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java create mode 100644 src/Java/gtPlusPlus/core/block/base/BasicBlock.java create mode 100644 src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java create mode 100644 src/Java/gtPlusPlus/core/block/base/MetaBlock.java create mode 100644 src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java create mode 100644 src/Java/gtPlusPlus/core/block/general/LightGlass.java create mode 100644 src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java create mode 100644 src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java create mode 100644 src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java create mode 100644 src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java create mode 100644 src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java create mode 100644 src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java create mode 100644 src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java create mode 100644 src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java create mode 100644 src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java create mode 100644 src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java create mode 100644 src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java create mode 100644 src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java (limited to 'src/Java/gtPlusPlus/core/block') diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java new file mode 100644 index 0000000000..ceb8880299 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -0,0 +1,78 @@ +package gtPlusPlus.core.block; + +import gtPlusPlus.core.block.general.LightGlass; +import gtPlusPlus.core.block.general.fluids.FluidRegistryHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraftforge.fluids.Fluid; +import cpw.mods.fml.common.registry.GameRegistry; + +public final class ModBlocks { + + //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 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 blockGtFrameStaballoy; + public static Block blockGtFrameTantalloy60; + public static Block blockGtFrameTantalloy61; + + + + public static void init() { + Utils.LOG_INFO("Initializing Blocks."); + //blockGriefSaver = new TowerDevice().setBlockName("blockGriefSaver").setCreativeTab(AddToCreativeTab.tabBlock).setBlockTextureName("blockDefault"); + + registerBlocks(); + } + + public static void registerBlocks(){ + + Utils.LOG_INFO("Registering Blocks."); + + //Blood Steel Block + //GameRegistry.registerBlock(blockBloodSteel = new BasicBlock("blockBloodSteel", Material.iron), "blockBloodSteel"); + + //Staballoy Block + //GameRegistry.registerBlock(blockStaballoy = new BasicBlock("blockStaballoy", Material.iron), "blockStaballoy"); + + //GameRegistry.registerBlock(MatterFabricatorEffectBlock = new MatterFabricatorEffectBlock(), "blockMF_Effect"); + + GameRegistry.registerBlock(MatterFabricatorEffectBlock = new LightGlass(Material.glass, false).setHardness(0.1F).setBlockTextureName(CORE.MODID + ":" + "blockMFEffect").setStepSound(Block.soundTypeGlass), "blockMFEffect"); + + + //Casing Blocks + blockCasingsMisc = new GregtechMetaCasingBlocks(); + + //Fluids + FluidRegistryHandler.registerFluids(); + + // blockHeliumGenerator = GameRegistry.registerBlock(new HeliumGenerator(), "Helium_Collector"); + // blockNHG = GameRegistry.registerBlock(new Machine_NHG("blockNuclearFueledHeliumGenerator"), "blockNuclearFueledHeliumGenerator"); + // blockCharger = GameRegistry.registerBlock(new Machine_Charger("blockMachineCharger"), "blockMachineCharger"); + + + //WIP TODO + //GameRegistry.registerBlock(blockGriefSaver, "blockGriefSaver"); + + //GtFrames + //GameRegistry.registerBlock(blockGtFrameSet1 = new BlockGtFrameBox("blockGtFrameSet1", Material.iron ,BlockTypes.FRAME, true, Utils.rgbtoHexValue(68, 75, 66), Utils.rgbtoHexValue(68, 75, 166), Utils.rgbtoHexValue(122, 135, 196)), "blockGtFrameSet1"); + //GameRegistry.registerBlock(blockGtFrameTantalloy60 = new BlockBaseModular("blockGtFrameStaballoy", "Staballoy", BlockTypes.FRAME, Utils.rgbtoHexValue(68, 75, 66)), ItemBlockGtFrameBox.class, "blockGtFrameStaballoy"); + //GameRegistry.registerBlock(blockGtFrameTantalloy60 = new BlockBaseModular("blockGtFrameTantalloy60", "Tantalloy-60", BlockTypes.FRAME, Utils.rgbtoHexValue(68, 75, 166)), ItemBlockGtFrameBox.class, "blockGtFrameTantalloy60"); + //GameRegistry.registerBlock(blockGtFrameTantalloy61 = new BlockBaseModular("blockGtFrameTantalloy61", "Tantalloy-61", BlockTypes.FRAME, Utils.rgbtoHexValue(122, 135, 196)), ItemBlockGtFrameBox.class, "blockGtFrameTantalloy61"); + } + +} \ 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 new file mode 100644 index 0000000000..b7ac24a71b --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java @@ -0,0 +1,31 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +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; + } + +} diff --git a/src/Java/gtPlusPlus/core/block/base/BasicBlock.java b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java new file mode 100644 index 0000000000..cd879167ba --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java @@ -0,0 +1,52 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; + +public class BasicBlock extends Block { + + public BasicBlock(String unlocalizedName, 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 (String textureName, String harvestTool, 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; + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java new file mode 100644 index 0000000000..9654caac00 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -0,0 +1,154 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.item.base.itemblock.ItemBlockGtBlock; +import gtPlusPlus.core.item.base.itemblock.ItemBlockGtFrameBox; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockBaseModular extends BasicBlock{ + + 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); + this.setHarvestLevel(blockType.getHarvestTool(), 2); + 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("=========================================="); + } + + if (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 { + 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); + } + 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"); + } + else { + 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; + } + return 0; + } + + /*@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; + } + else if (thisBlock == BlockTypes.FRAME){ + tempIngot = thisBlockMaterial + " Frame Box"; + } + else { + + tempIngot = getUnlocalizedName().replace("tile.blockGt", "ingot"); + } + return tempIngot; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iIcon) + { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + thisBlock.getTexture()); + } + + @Override + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4){ + + 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 int getBlockColor() { + return this.blockColour; + } + +} diff --git a/src/Java/gtPlusPlus/core/block/base/MetaBlock.java b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java new file mode 100644 index 0000000000..4009c36726 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.block.base; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +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 diff --git a/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java b/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java new file mode 100644 index 0000000000..4f022bae6d --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java @@ -0,0 +1,36 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +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]; + } +} \ 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 new file mode 100644 index 0000000000..5aa9f5b818 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/LightGlass.java @@ -0,0 +1,128 @@ +package gtPlusPlus.core.block.general; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; + +import java.util.Random; + +import net.minecraft.block.BlockBreakable; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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 LightGlass(Material mat, boolean bool) + { + super("blockMFEffect", mat, bool); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setBlockName("blockMFEffect"); + this.setLightLevel(12F); + this.setLightOpacity(0); + this.setTickRandomly(true); + this.setResistance(1); + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random rand) + { + return 0; + } + + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return 0; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() + { + return true; + } + + /** + * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops. + */ + @Override + protected boolean canSilkHarvest() + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(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 + */ + @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"); + + } +} \ 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 new file mode 100644 index 0000000000..7fa890b6c8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java @@ -0,0 +1,276 @@ +package gtPlusPlus.core.block.general.antigrief; + +import static gtPlusPlus.core.block.ModBlocks.blockGriefSaver; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityReverter; +import gtPlusPlus.core.util.Utils; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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); + } + + public void loadNBTData(NBTTagCompound aNBT) { + bUnbreakable = aNBT.getBoolean("bUnbreakable"); + } + + 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 new file mode 100644 index 0000000000..6096da7054 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java @@ -0,0 +1,51 @@ +package gtPlusPlus.core.block.general.fluids; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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); + } + +} diff --git a/src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java b/src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java new file mode 100644 index 0000000000..bda2aae35b --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java @@ -0,0 +1,50 @@ +package gtPlusPlus.core.block.general.fluids; + +import static gtPlusPlus.core.block.ModBlocks.blockFluidJackDaniels; +import static gtPlusPlus.core.block.ModBlocks.fluidJackDaniels; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.material.Material; +import net.minecraftforge.fluids.FluidRegistry; +import cpw.mods.fml.common.registry.GameRegistry; + +public class FluidRegistryHandler { + + //Fluids + /** + * + * Luminosity .setLuminosity(luminosity) + How much light does the fluid emit. Default: 0, Lava uses 15 + Density .setDensity(density) + How dense is the fluid, the only effect is whether or not a fluid replaces another fluid when they flow into each other. Default: 1000, the density of water at 4 degrees Celsius in kg/m³ + Temperature .setTemperature(temp) + How hot, or cold is the fluid. Has currently no effect. Default: 295, the "normal" room temperature in degrees Kelvin, this is approximately 72°F or 22°C. + Viscosity .setViscosity(viscosity) + How thick the fluid is. Determines how fast it flows. Default: 1000 for water, lava uses 6000 + Is Gaseous .setGaseous(boolean) + Indicates if the fluid is gaseous. Used for rendering. Default: false + * + */ + + public static void registerFluids(){ + run(); + } + + private static void run(){ + fluidJackDaniels(); + } + + private static void fluidJackDaniels(){ + //testFluid + fluidJackDaniels.setLuminosity(12); + fluidJackDaniels.setDensity(1200); + fluidJackDaniels.setTemperature(420); + fluidJackDaniels.setViscosity(750); + fluidJackDaniels.setGaseous(true); + fluidJackDaniels.setUnlocalizedName("fluidJackDaniels"); + FluidRegistry.registerFluid(fluidJackDaniels); + blockFluidJackDaniels = new BlockFluidJackDaniels(fluidJackDaniels, Material.water).setBlockName("fluidBlockJackDaniels"); + GameRegistry.registerBlock(blockFluidJackDaniels, CORE.MODID + "_" + blockFluidJackDaniels.getUnlocalizedName().substring(5)); + fluidJackDaniels.setUnlocalizedName(blockFluidJackDaniels.getUnlocalizedName()); + } + +} diff --git a/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java new file mode 100644 index 0000000000..2832d4d0a4 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java @@ -0,0 +1,35 @@ +package gtPlusPlus.core.block.machine; + +import gtPlusPlus.core.block.base.MetaBlock; +import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.material.Material; +import net.minecraft.world.IBlockAccess; + +public class BlockGtFrameBox extends MetaBlock { + + private int[] colours; + private int totalColours; + + public BlockGtFrameBox( + String unlocalizedName, Material material, + BlockTypes blockTypeENUM, boolean recolour, int... colour) { + super(unlocalizedName, material, blockTypeENUM.getBlockSoundType()); + this.setBlockTextureName(CORE.MODID + ":" + "blockGtFrame"); + this.setHarvestLevel(blockTypeENUM.getHarvestTool(), 2); + if (recolour && (colour != null && colour.length > 0)){ + colours = colour; + totalColours = 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){ + + } + 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 new file mode 100644 index 0000000000..4f426b99c9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java @@ -0,0 +1,83 @@ +package gtPlusPlus.core.block.machine; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityCharger; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +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(); + } +} \ 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 new file mode 100644 index 0000000000..011e293000 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java @@ -0,0 +1,83 @@ +package gtPlusPlus.core.block.machine; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityNHG; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +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(); + } +} \ 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 new file mode 100644 index 0000000000..e964a9da01 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java @@ -0,0 +1,5 @@ +package gtPlusPlus.core.block.machine; + +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/heliumgen/block/HeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java new file mode 100644 index 0000000000..7a76b09cca --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java @@ -0,0 +1,165 @@ +package gtPlusPlus.core.block.machine.heliumgen.block; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class HeliumGenerator extends BlockContainer { + + private IIcon top, sides, front; + private Random randy = new Random(); + + public HeliumGenerator(){ + super(Material.iron); + setStepSound(Block.soundTypeMetal); + setHardness(20.0F); + setBlockName("helium_collector"); + setHarvestLevel("pickaxe", 3); + setCreativeTab(AddToCreativeTab.tabMachines); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons (IIconRegister iconRegister) + { + this.top = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_SIDE"); + this.sides = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_SIDE"); + this.front = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_FRONT"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ + if(side == 1) + return top; + int facing = 2; + TileEntityHeliumGenerator machine = (TileEntityHeliumGenerator)world.getTileEntity(x, y, z); + if(machine != null) + facing = machine.getFacing(); + if(side == facing) + return front; + else + return sides; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon (int side, int metadata) + { + if(side == 1) + return top; + if(side == 3) + return front; + return sides; + } + + @Override + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) + { + if (world.isRemote) + { + return true; + } + player.openGui(GTplusplus.instance, 2, world, x, y, z); + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) + { + return new TileEntityHeliumGenerator(); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack item) + { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof TileEntityHeliumGenerator) { + TileEntityHeliumGenerator machine = (TileEntityHeliumGenerator)tile; + int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (l == 0) + machine.setFacing((short) 2); + + if (l == 1) + machine.setFacing((short) 5); + + if (l == 2) + machine.setFacing((short) 3); + + if (l == 3) + machine.setFacing((short) 4); + } + + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int wut) + { + TileEntityHeliumGenerator collector = (TileEntityHeliumGenerator)world.getTileEntity(x, y, z); + + if (collector != null) + { + int i = 0; + for (i = 0; i < collector.getSizeInventory(); i++){ + + ItemStack itemstack = collector.getStackInSlot(i); + + if (itemstack != null) + { + float f = this.randy.nextFloat() * 0.8F + 0.1F; + float f1 = this.randy.nextFloat() * 0.8F + 0.1F; + float f2 = this.randy.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j1 = this.randy.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) + { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + EntityItem entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.randy.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.randy.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.randy.nextGaussian() * f3); + world.spawnEntityInWorld(entityitem); + } + } + + world.func_147453_f(x, y, z, block); + } + } + + super.breakBlock(world, x, y, z, block, wut); + } +} diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java new file mode 100644 index 0000000000..d701f6f125 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java @@ -0,0 +1,75 @@ +package gtPlusPlus.core.block.machine.heliumgen.container; + +import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; + +import java.util.List; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.inventory.SlotFurnace; + +public class ContainerHeliumGenerator +extends ContainerBase +{ + public short size; + + public ContainerHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine) + { + super(machine); + //Utils.LOG_WARNING("containerHeliumGenerator"); + short sr = machine.getReactorSize(); + this.addSlotToContainer(new SlotFurnace(player.player, machine, 2, 80, 35)); + this.size = sr; + int startX = 16; + int startY = 16; + int i = 0; + for (i = 0; i < 9; i++) + { + int x = i % this.size; + int y = i / this.size; + + 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; + + 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) + { + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + 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)); + } + + @Override + public List getNetworkedFields() + { + List ret = super.getNetworkedFields(); + + ret.add("heat"); + ret.add("maxHeat"); + ret.add("EmitHeat"); + /*ret.add("inputTank"); + ret.add("outputTank"); + ret.add("fluidcoolreactor");*/ + 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 new file mode 100644 index 0000000000..2106f144be --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java @@ -0,0 +1,72 @@ +package gtPlusPlus.core.block.machine.heliumgen.gui; + +import gtPlusPlus.core.block.machine.heliumgen.container.ContainerHeliumGenerator; +import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GUIHeliumGenerator extends GuiContainer +{ + private static final ResourceLocation collectorGuiTexture = new ResourceLocation(CORE.MODID, "textures/gui/helium_collector_gui.png"); + + public GUIHeliumGenerator(InventoryPlayer player, 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(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(collectorGuiTexture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java new file mode 100644 index 0000000000..86507a2d64 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java @@ -0,0 +1,78 @@ +package gtPlusPlus.core.block.machine.heliumgen.slots; + +import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +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); + + setStackSizeLimit(1); + } + + @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 int rawSize() + { + return super.size(); + } + + @Override + public ItemStack get(int index) + { + return super.get(mapIndex(index)); + } + + public ItemStack get(int x, int y) + { + return super.get(y * 9 + x); + } + + @Override + public void put(int index, ItemStack content) + { + super.put(mapIndex(index), content); + } + + public void put(int x, int y, ItemStack content) + { + super.put(y * 9 + x, content); + } + + private int mapIndex(int index) + { + int size = size(); + int cols = size / 6; + if (index < size) + { + int row = index / cols; + int col = index % cols; + + return row * 9 + col; + } + index -= size; + int remCols = 9 - cols; + + int row = index / remCols; + int col = cols + index % remCols; + + return row * 9 + col; + } + + private final int rows = 6; + private final int maxCols = 9; +} diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java new file mode 100644 index 0000000000..06c13f997a --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java @@ -0,0 +1,648 @@ +package gtPlusPlus.core.block.machine.heliumgen.tileentity; + +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.block.machine.heliumgen.slots.InvSlotRadiation; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import ic2.api.Direction; +import ic2.api.reactor.IReactor; +import ic2.api.reactor.IReactorComponent; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.IC2DamageSource; +import ic2.core.Ic2Items; +import ic2.core.block.TileEntityInventory; +import ic2.core.init.MainConfig; +import ic2.core.item.reactor.ItemReactorHeatStorage; +import ic2.core.network.NetworkManager; +import ic2.core.util.ConfigUtil; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +public class TileEntityHeliumGenerator extends TileEntityInventory implements IInventory ,IReactor, IWrenchable { + + private ItemStack heliumStack; + private int facing = 2; + private int progress; + + + public void update2Entity(){ + Utils.LOG_WARNING("updateEntity"); + if(++progress >= 40){ + //if(++progress >= 300){ + if(heliumStack == null) + heliumStack = UtilsItems.getSimpleStack(ModItems.itemHeliumBlob); + else if(heliumStack.getItem() == ModItems.itemHeliumBlob && heliumStack.stackSize < 64) + heliumStack.stackSize++; + progress = 0; + markDirty(); + } + } + + @Override + public short getFacing(){ + return (short) facing; + } + + @Override + public void setFacing(short dir){ + facing = dir; + } + + /*@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 readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + + //this.heliumStack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Helium")); + NBTTagList list = nbttagcompound.getTagList("Items", 10); + for (int i = 0; i < list.tagCount(); ++i) { + NBTTagCompound stackTag = list.getCompoundTagAt(i); + int slot = stackTag.getByte("Slot") & 255; + this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag)); + } + this.progress = nbttagcompound.getInteger("Progress"); + this.facing = nbttagcompound.getShort("Facing"); + this.heat = nbttagcompound.getInteger("heat"); + this.output = nbttagcompound.getShort("output"); + this.prevActive = (this.active = nbttagcompound.getBoolean("active")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + + nbttagcompound.setInteger("Progress", this.progress); + nbttagcompound.setShort("Facing", (short) this.facing); + nbttagcompound.setInteger("heat", this.heat); + nbttagcompound.setShort("output", (short)(int)getReactorEnergyOutput()); + nbttagcompound.setBoolean("active", this.active); + /*if(heliumStack != null) { + NBTTagCompound produce = new NBTTagCompound(); + heliumStack.writeToNBT(produce); + nbttagcompound.setTag("Helium", produce); + } + else + nbttagcompound.removeTag("Helium");*/ + NBTTagList list = new NBTTagList(); + for (int i = 0; i < this.getSizeInventory(); ++i) { + if (this.getStackInSlot(i) != null) { + NBTTagCompound stackTag = new NBTTagCompound(); + stackTag.setByte("Slot", (byte) i); + this.getStackInSlot(i).writeToNBT(stackTag); + list.appendTag(stackTag); + } + } + nbttagcompound.setTag("Items", list); + } + + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, tag); + } + + @Override + public void onDataPacket(net.minecraft.network.NetworkManager net, S35PacketUpdateTileEntity packet) { + super.onDataPacket(net, packet); + readFromNBT(packet.func_148857_g()); + } + + + @Override + public int getSizeInventory() + { + return 19; + } + + @Override + public ItemStack getStackInSlot(int slot){ + return heliumStack; + } + + @Override + public ItemStack decrStackSize(int slot, int decrement){ + Utils.LOG_WARNING("decrStackSize"); + if(heliumStack == null) + return null; + if(decrement < heliumStack.stackSize){ + ItemStack take = heliumStack.splitStack(decrement); + if(heliumStack.stackSize <= 0) + heliumStack = null; + return take; + } + ItemStack take = heliumStack; + heliumStack = null; + return take; + } + + @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; + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack){ + return false; + } + + @Override + public int getInventoryStackLimit(){ + return 64; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack){ + heliumStack = stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot){ + return null; + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + //return "container.helium_collector"; + return "container.helium_collector"; + } + + /** + * Returns if the inventory is named + */ + @Override + public boolean hasCustomInventoryName() + { + return false; + } + + //IC2 Nuclear Code + + + 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; + + + 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); + return cols; + } + + protected void updateEntityServer() + { + Uti