From d4f11459f2e78e954a4c060c92861614c114d1cb Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sun, 19 Jun 2016 14:53:32 +1000 Subject: +More classes stolen from GT to implement my own items on a metaitem. +Added LuV -> Max Voltage Machine components. +Added Rocket Engines, High tier diesel generators. +Added new textures for everything. +Added BedLocator_Base.java - Debug item for testing and NBT data storage. +Added Machine_Charger.java - Another Debug machine for testing NBT value manipulation. --- src/Java/miscutil/core/block/ModBlocks.java | 46 +- .../miscutil/core/block/antigrief/TowerDevice.java | 276 --------- .../miscutil/core/block/fluids/BlocktestFluid.java | 50 -- .../core/block/general/antigrief/TowerDevice.java | 276 +++++++++ .../general/fluids/BlockFluidJackDaniels.java | 51 ++ .../block/general/fluids/FluidRegistryHandler.java | 49 ++ .../block/heliumgen/block/HeliumGenerator.java | 164 ------ .../container/ContainerHeliumGenerator.java | 75 --- .../block/heliumgen/gui/GUIHeliumGenerator.java | 72 --- .../block/heliumgen/slots/InvSlotRadiation.java | 78 --- .../tileentity/TileEntityHeliumGenerator.java | 648 --------------------- .../core/block/machine/Machine_Charger.java | 82 +++ .../miscutil/core/block/machine/Machine_NHG.java | 2 +- .../machine/heliumgen/block/HeliumGenerator.java | 164 ++++++ .../container/ContainerHeliumGenerator.java | 75 +++ .../machine/heliumgen/gui/GUIHeliumGenerator.java | 72 +++ .../machine/heliumgen/slots/InvSlotRadiation.java | 78 +++ .../tileentity/TileEntityHeliumGenerator.java | 648 +++++++++++++++++++++ src/Java/miscutil/core/common/CommonProxy.java | 8 +- .../miscutil/core/container/Container_Charger.java | 81 +++ .../miscutil/core/container/Container_NHG.java | 2 +- .../miscutil/core/creative/AddToCreativeTab.java | 4 + .../core/creative/MiscUtilCreativeTabBlock.java | 18 - .../core/creative/MiscUtilCreativeTabMachines.java | 18 - .../core/creative/MiscUtilCreativeTabMisc.java | 18 - .../core/creative/MiscUtilCreativeTabTools.java | 18 - .../creative/tabs/MiscUtilCreativeTabBlock.java | 18 + .../creative/tabs/MiscUtilCreativeTabMachines.java | 18 + .../creative/tabs/MiscUtilCreativeTabMisc.java | 18 + .../creative/tabs/MiscUtilCreativeTabTools.java | 18 + src/Java/miscutil/core/gui/ModGUI.java | 6 +- .../miscutil/core/gui/machine/GUI_Charger.java | 50 ++ src/Java/miscutil/core/gui/machine/GUI_NHG.java | 2 +- src/Java/miscutil/core/handler/COMPAT_HANDLER.java | 4 + src/Java/miscutil/core/handler/GuiHandler.java | 13 +- .../gregtech/GregtechIndustrialCentrifuge.java | 2 +- .../gregtech/GregtechIndustrialCokeOven.java | 2 +- .../gregtech/GregtechIndustrialPlatePress.java | 2 +- .../gregtech/GregtechRocketFuelGenerator.java | 34 ++ .../gregtech/GregtechSteamCondenser.java | 2 +- src/Java/miscutil/core/item/ModItems.java | 24 +- .../core/item/base/BaseItemWithCharge.java | 74 +++ .../core/item/general/BedLocator_Base.java | 106 ++++ .../core/item/general/fuelrods/FuelRod_Base.java | 78 ++- src/Java/miscutil/core/lib/CORE.java | 8 +- .../miscutil/core/recipe/RECIPES_GREGTECH.java | 5 + .../core/tileentities/ModTileEntities.java | 9 +- .../miscutil/core/tileentities/TileEntityNHG.java | 487 ---------------- .../core/tileentities/TileEntityReverter.java | 309 ---------- .../tileentities/general/TileEntityReverter.java | 309 ++++++++++ .../tileentities/machines/TileEntityCharger.java | 186 ++++++ .../core/tileentities/machines/TileEntityNHG.java | 501 ++++++++++++++++ 52 files changed, 3028 insertions(+), 2330 deletions(-) delete mode 100644 src/Java/miscutil/core/block/antigrief/TowerDevice.java delete mode 100644 src/Java/miscutil/core/block/fluids/BlocktestFluid.java create mode 100644 src/Java/miscutil/core/block/general/antigrief/TowerDevice.java create mode 100644 src/Java/miscutil/core/block/general/fluids/BlockFluidJackDaniels.java create mode 100644 src/Java/miscutil/core/block/general/fluids/FluidRegistryHandler.java delete mode 100644 src/Java/miscutil/core/block/heliumgen/block/HeliumGenerator.java delete mode 100644 src/Java/miscutil/core/block/heliumgen/container/ContainerHeliumGenerator.java delete mode 100644 src/Java/miscutil/core/block/heliumgen/gui/GUIHeliumGenerator.java delete mode 100644 src/Java/miscutil/core/block/heliumgen/slots/InvSlotRadiation.java delete mode 100644 src/Java/miscutil/core/block/heliumgen/tileentity/TileEntityHeliumGenerator.java create mode 100644 src/Java/miscutil/core/block/machine/Machine_Charger.java create mode 100644 src/Java/miscutil/core/block/machine/heliumgen/block/HeliumGenerator.java create mode 100644 src/Java/miscutil/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java create mode 100644 src/Java/miscutil/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java create mode 100644 src/Java/miscutil/core/block/machine/heliumgen/slots/InvSlotRadiation.java create mode 100644 src/Java/miscutil/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java create mode 100644 src/Java/miscutil/core/container/Container_Charger.java delete mode 100644 src/Java/miscutil/core/creative/MiscUtilCreativeTabBlock.java delete mode 100644 src/Java/miscutil/core/creative/MiscUtilCreativeTabMachines.java delete mode 100644 src/Java/miscutil/core/creative/MiscUtilCreativeTabMisc.java delete mode 100644 src/Java/miscutil/core/creative/MiscUtilCreativeTabTools.java create mode 100644 src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabBlock.java create mode 100644 src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMachines.java create mode 100644 src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMisc.java create mode 100644 src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabTools.java create mode 100644 src/Java/miscutil/core/gui/machine/GUI_Charger.java create mode 100644 src/Java/miscutil/core/handler/registration/gregtech/GregtechRocketFuelGenerator.java create mode 100644 src/Java/miscutil/core/item/base/BaseItemWithCharge.java create mode 100644 src/Java/miscutil/core/item/general/BedLocator_Base.java delete mode 100644 src/Java/miscutil/core/tileentities/TileEntityNHG.java delete mode 100644 src/Java/miscutil/core/tileentities/TileEntityReverter.java create mode 100644 src/Java/miscutil/core/tileentities/general/TileEntityReverter.java create mode 100644 src/Java/miscutil/core/tileentities/machines/TileEntityCharger.java create mode 100644 src/Java/miscutil/core/tileentities/machines/TileEntityNHG.java (limited to 'src/Java/miscutil/core') diff --git a/src/Java/miscutil/core/block/ModBlocks.java b/src/Java/miscutil/core/block/ModBlocks.java index 9893430b69..7ab4a4c5c0 100644 --- a/src/Java/miscutil/core/block/ModBlocks.java +++ b/src/Java/miscutil/core/block/ModBlocks.java @@ -1,16 +1,12 @@ package miscutil.core.block; import miscutil.core.block.base.BasicBlock; -import miscutil.core.block.fluids.BlocktestFluid; -import miscutil.core.block.heliumgen.block.HeliumGenerator; -import miscutil.core.block.machine.Machine_NHG; -import miscutil.core.lib.CORE; +import miscutil.core.block.general.fluids.FluidRegistryHandler; import miscutil.core.util.Utils; import miscutil.gregtech.common.blocks.GregtechMetaCasingBlocks; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; import cpw.mods.fml.common.registry.GameRegistry; public final class ModBlocks { @@ -23,28 +19,10 @@ public final class ModBlocks { public static Block blockCasingsMisc; public static Block blockHeliumGenerator; public static Block blockNHG; + public static Block blockCharger; - - - - //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 Fluid testFluid = new Fluid("testFluid"); - public static Block testFluidBlock; + public static Fluid fluidJackDaniels = new Fluid("fluidJackDaniels"); + public static Block blockFluidJackDaniels; @@ -69,19 +47,11 @@ public final class ModBlocks { blockCasingsMisc = new GregtechMetaCasingBlocks(); //Fluids - //testFluid - testFluid.setLuminosity(12); - testFluid.setDensity(1200); - testFluid.setTemperature(420); - testFluid.setViscosity(750); - testFluid.setGaseous(true); - FluidRegistry.registerFluid(testFluid); - testFluidBlock = new BlocktestFluid(testFluid, Material.water).setBlockName("yourFluid"); - GameRegistry.registerBlock(testFluidBlock, CORE.MODID + "_" + testFluidBlock.getUnlocalizedName().substring(5)); - testFluid.setUnlocalizedName(testFluidBlock.getUnlocalizedName()); + FluidRegistryHandler.registerFluids(); - blockHeliumGenerator = GameRegistry.registerBlock(new HeliumGenerator(), "Helium_Collector"); - blockNHG = GameRegistry.registerBlock(new Machine_NHG("blockNuclearFueledHeliumGenerator"), "blockNuclearFueledHeliumGenerator"); + // 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 diff --git a/src/Java/miscutil/core/block/antigrief/TowerDevice.java b/src/Java/miscutil/core/block/antigrief/TowerDevice.java deleted file mode 100644 index c3b0ab69a8..0000000000 --- a/src/Java/miscutil/core/block/antigrief/TowerDevice.java +++ /dev/null @@ -1,276 +0,0 @@ -package miscutil.core.block.antigrief; - -import static miscutil.core.block.ModBlocks.blockGriefSaver; - -import java.util.List; -import java.util.Random; - -import miscutil.core.creative.AddToCreativeTab; -import miscutil.core.lib.CORE; -import miscutil.core.tileentities.TileEntityReverter; -import miscutil.core.util.Utils; -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/miscutil/core/block/fluids/BlocktestFluid.java b/src/Java/miscutil/core/block/fluids/BlocktestFluid.java deleted file mode 100644 index 8676f21d81..0000000000 --- a/src/Java/miscutil/core/block/fluids/BlocktestFluid.java +++ /dev/null @@ -1,50 +0,0 @@ -package miscutil.core.block.fluids; - -import miscutil.core.creative.AddToCreativeTab; -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 BlocktestFluid extends BlockFluidClassic { - - @SideOnly(Side.CLIENT) - protected IIcon stillIcon; - @SideOnly(Side.CLIENT) - protected IIcon flowingIcon; - - public BlocktestFluid(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("modid:fluidStill"); - flowingIcon = register.registerIcon("modid:fluidFlowing"); - } - - @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/miscutil/core/block/general/antigrief/TowerDevice.java b/src/Java/miscutil/core/block/general/antigrief/TowerDevice.java new file mode 100644 index 0000000000..9ff0d36b33 --- /dev/null +++ b/src/Java/miscutil/core/block/general/antigrief/TowerDevice.java @@ -0,0 +1,276 @@ +package miscutil.core.block.general.antigrief; + +import static miscutil.core.block.ModBlocks.blockGriefSaver; + +import java.util.List; +import java.util.Random; + +import miscutil.core.creative.AddToCreativeTab; +import miscutil.core.lib.CORE; +import miscutil.core.tileentities.general.TileEntityReverter; +import miscutil.core.util.Utils; +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/miscutil/core/block/general/fluids/BlockFluidJackDaniels.java b/src/Java/miscutil/core/block/general/fluids/BlockFluidJackDaniels.java new file mode 100644 index 0000000000..1ddfcbe081 --- /dev/null +++ b/src/Java/miscutil/core/block/general/fluids/BlockFluidJackDaniels.java @@ -0,0 +1,51 @@ +package miscutil.core.block.general.fluids; + +import miscutil.core.creative.AddToCreativeTab; +import miscutil.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/miscutil/core/block/general/fluids/FluidRegistryHandler.java b/src/Java/miscutil/core/block/general/fluids/FluidRegistryHandler.java new file mode 100644 index 0000000000..bf03203247 --- /dev/null +++ b/src/Java/miscutil/core/block/general/fluids/FluidRegistryHandler.java @@ -0,0 +1,49 @@ +package miscutil.core.block.general.fluids; + +import static miscutil.core.block.ModBlocks.blockFluidJackDaniels; +import static miscutil.core.block.ModBlocks.fluidJackDaniels; +import miscutil.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); + FluidRegistry.registerFluid(fluidJackDaniels); + blockFluidJackDaniels = new BlockFluidJackDaniels(fluidJackDaniels, Material.water).setBlockName("fluidJackDaniels"); + GameRegistry.registerBlock(blockFluidJackDaniels, CORE.MODID + "_" + blockFluidJackDaniels.getUnlocalizedName().substring(5)); + fluidJackDaniels.setUnlocalizedName(blockFluidJackDaniels.getUnlocalizedName()); + } + +} diff --git a/src/Java/miscutil/core/block/heliumgen/block/HeliumGenerator.java b/src/Java/miscutil/core/block/heliumgen/block/HeliumGenerator.java deleted file mode 100644 index f424097240..0000000000 --- a/src/Java/miscutil/core/block/heliumgen/block/HeliumGenerator.java +++ /dev/null @@ -1,164 +0,0 @@ -package miscutil.core.block.heliumgen.block; - -import java.util.Random; - -import miscutil.MiscUtils; -import miscutil.core.block.heliumgen.tileentity.TileEntityHeliumGenerator; -import miscutil.core.creative.AddToCreativeTab; -import miscutil.core.lib.CORE; -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(MiscUtils.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/miscutil/core/block/heliumgen/container/ContainerHeliumGenerator.java b/src/Java/miscutil/core/block/heliumgen/container/ContainerHeliumGenerator.java deleted file mode 100644 index 7de3efd4c6..0000000000 --- a/src/Java/miscutil/core/block/heliumgen/container/ContainerHeliumGenerator.java +++ /dev/null @@ -1,75 +0,0 @@ -package miscutil.core.block.heliumgen.container; - -import ic2.core.ContainerBase; -import ic2.core.slot.SlotInvSlot; - -import java.util.List; - -import miscutil.core.block.heliumgen.tileentity.TileEntityHeliumGenerator; -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/miscutil/core/block/heliumgen/gui/GUIHeliumGenerator.java b/src/Java/miscutil/core/block/heliumgen/gui/GUIHeliumGenerator.java deleted file mode 100644 index 309a7b5fba..0000000000 --- a/src/Java/miscutil/core/block/heliumgen/gui/GUIHeliumGenerator.java +++ /dev/null @@ -1,72 +0,0 @@ -package miscutil.core.block.heliumgen.gui; - -import miscutil.core.block.heliumgen.container.ContainerHeliumGenerator; -import miscutil.core.block.heliumgen.tileentity.TileEntityHeliumGenerator; -import miscutil.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/miscutil/core/block/heliumgen/slots/InvSlotRadiation.java b/src/Java/miscutil/core/block/heliumgen/slots/InvSlotRadiation.java deleted file mode 100644 index 22491e6cf2..0000000000 --- a/src/Java/miscutil/core/block/heliumgen/slots/InvSlotRadiation.java +++ /dev/null @@ -1,78 +0,0 @@ -package miscutil.core.block.heliumgen.slots; - -import ic2.core.block.invslot.InvSlot; -import miscutil.core.block.heliumgen.tileentity.TileEntityHeliumGenerator; -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/miscutil/core/block/heliumgen/tileentity/TileEntityHeliumGenerator.java b/src/Java/miscutil/core/block/heliumgen/tileentity/TileEntityHeliumGenerator.java deleted file mode 100644 index 8793e06d4b..0000000000 --- a/src/Java/miscutil/core/block/heliumgen/tileentity/TileEntityHeliumGenerator.java +++ /dev/null @@ -1,648 +0,0 @@ -package miscutil.core.block.heliumgen.tileentity; - -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 miscutil.core.block.ModBlocks; -import miscutil.core.block.heliumgen.slots.InvSlotRadiation; -import miscutil.core.item.ModItems; -import miscutil.core.util.Utils; -import miscutil.core.util.item.UtilsItems; -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; - - @Override - public void updateEntity(){ - 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() - { - Utils.LOG_WARNING("updateEntityServer"); - super.updateEntity(); - - if (this.updateTicker++ % getTickRate() != 0) { - return; - } - if (!this.worldObj.doChunksNearChunkExist(this.xCoord, this.yCoord, this.zCoord, 2)) - { - this.output = 0.0F; - } - else - { - - dropAllUnfittingStuff(); - - this.output = 0.0F; - this.maxHeat = 10000; - this.hem = 1.0F; - - processChambers(); - this.EmitHeatbuffer = 0; - if (calculateHeatEffects()) { - return; - } - setActive((this.heat >= 1000) || (this.output > 0.0F)); - - markDirty(); - } - ((NetworkManager)IC2.network.get()).updateTileEntityField(this, "output"); - } - - @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 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); - - this.reactorSlot.put(i, null); - eject(stack); - } - } - - 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); - } - - 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()); - } - - public boolean calculateHeatEffects() - { - Utils.LOG_WARNING("calculateHeatEffects"); - if ((this.heat < 8000) || (!IC2.platform.isSimulating()) || (ConfigUtil.getFloat(MainConfig.get(), "protection/reactorExplosionPowerLimit") <= 0.0F)) { - return false; - } - float power = this.heat / this.maxHeat; - if (power >= 1.0F) - { - explode(); - 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; - } - - 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; - } - - public void processChambers() - { - Utils.LOG_WARNING("processChambers"); - int size = 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(); - comp.processChamber(this, stack, x, y, pass == 0); - } - } - } - } - } - - @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; - } - - @Override - public void setHeat(int heat1) - { - this.heat = heat1; - } - - @Override - public int addHeat(int amount) - { - this.heat += amount; - return this.heat; - } - - @Override - public int getMaxHeat() - { - return this.maxHeat; - } - - @Override - public void setMaxHeat(int newMaxHeat) - { - this.maxHeat = newMaxHeat; - } - - @Override - public void addEmitHeat(int heat) - { - this.EmitHeatbuffer += heat; - } - - @Override - public float getHeatEffectModifier() - { - return this.hem; - } - - @Override - public void setHeatEffectModifier(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; - } - - @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) - { - Utils.LOG_WARNING("setItemAt"); - if ((x < 0) || (x >= 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 - } - - @Override - public int getTickRate() - { - return 20; - } - - public boolean receiveredstone() - { - Utils.LOG_WARNING("receiveRedstone"); - if ((this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) || (this.redstone)) { - decrStackSize(-1, 1); - return true; - } - return false; - } - - @Override - public boolean produceEnergy() - { - Utils.LOG_WARNING("produceEnergy"); - return (receiveredstone()) && (ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/generator") > 0.0F); - } - - @Override - public void setRedstoneSignal(boolean redstone) - { - this.redstone = redstone; - } - - @Override - public boolean isFluidCooled() { - Utils.LOG_WARNING("isFluidCooled"); - return false; - } - - @Override - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) - { - return true; - } - - @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) - { - return true; - } - - @Override - public float getWrenchDropRate() - { - return 1F; - } - - @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) - { - return new ItemStack(ModBlocks.blockHeliumGenerator, 1); - } - -} diff --git a/src/Java/miscutil/core/block/machine/Machine_Charger.java b/src/Java/miscutil/core/block/machine/Machine_Charger.java new file mode 100644 index 0000000000..9efb539afb --- /dev/null +++ b/src/Java/miscutil/core/block/machine/Machine_Charger.java @@ -0,0 +1,82 @@ +package miscutil.core.block.machine; + +import java.util.ArrayList; + +import miscutil.MiscUtils; +import miscutil.core.creative.AddToCreativeTab; +import miscutil.core.lib.CORE; +import miscutil.core.tileentities.machines.TileEntityCharger; +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(MiscUtils.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/miscutil/core/block/machine/Machine_NHG.java b/src/Java/miscutil/core/block/machine/Machine_NHG.java index 1738469fd7..fe06577307 100644 --- a/src/Java/miscutil/core/block/machine/Machine_NHG.java +++ b/src/Java/miscutil/core/block/machine/Machine_NHG.java @@ -5,7 +5,7 @@ import java.util.ArrayList; import miscutil.MiscUtils; import miscutil.core.creative.AddToCreativeTab; import miscutil.core.lib.CORE; -import miscutil.core.tileentities.TileEntityNHG; +import miscutil.core.tileentities.machines.TileEntityNHG; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; diff --git a/src/Java/miscutil/core/block/machine/heliumgen/block/HeliumGenerator.java b/src/Java/miscutil/core/block/machine/heliumgen/block/HeliumGenerator.java new file mode 100644 index 0000000000..83897db5e0 --- /dev/null +++ b/src/Java/miscutil/core/block/machine/heliumgen/block/HeliumGenerator.java @@ -0,0 +1,164 @@ +package miscutil.core.block.machine.heliumgen.block; + +import java.util.Random; + +import miscutil.MiscUtils; +import miscutil.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +import miscutil.core.creative.AddToCreativeTab; +import miscutil.core.lib.CORE; +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(MiscUtils.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/miscutil/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java b/src/Java/miscutil/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java new file mode 100644 index 0000000000..17389a5abe --- /dev/null +++ b/src/Java/miscutil/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java @@ -0,0 +1,75 @@ +package miscutil.core.block.machine.heliumgen.container; + +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; + +import java.util.List; + +import miscutil.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +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/miscutil/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java b/src/Java/miscutil/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java new file mode 100644 index 0000000000..708ba9c924 --- /dev/null +++ b/src/Java/miscutil/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java @@ -0,0 +1,72 @@ +package miscutil.core.block.machine.heliumgen.gui; + +import miscutil.core.block.machine.heliumgen.container.ContainerHeliumGenerator; +import miscutil.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +import miscutil.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/miscutil/core/block/machine/heliumgen/slots/InvSlotRadiation.java b/src/Java/miscutil/core/block/machine/heliumgen/slots/InvSlotRadiation.java new file mode 100644 index 0000000000..d8a9c38897 --- /dev/null +++ b/src/Java/miscutil/core/block/machine/heliumgen/slots/InvSlotRadiation.java @@ -0,0 +1,78 @@ +package miscutil.core.block.machine.heliumgen.slots; + +import ic2.core.block.invslot.InvSlot; +import miscutil.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +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/miscutil/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java b/src/Java/miscutil/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java new file mode 100644 index 0000000000..66420a72a5 --- /dev/null +++ b/src/Java/miscutil/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java @@ -0,0 +1,648 @@ +package miscutil.core.block.machine.heliumgen.tileentity; + +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 miscutil.core.block.ModBlocks; +import miscutil.core.block.machine.heliumgen.slots.InvSlotRadiation; +import miscutil.core.item.ModItems; +import miscutil.core.util.Utils; +import miscutil.core.util.item.UtilsItems; +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; + + @Override + public void updateEntity(){ + 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() + { + Utils.LOG_WARNING("updateEntityServer"); + super.updateEntity(); + + if (this.updateTicker++ % getTickRate() != 0) { + return; + } + if (!this.worldObj.doChunksNearChunkExist(this.xCoord, this.yCoord, this.zCoord, 2)) + { + this.output = 0.0F; + } + else + { + + dropAllUnfittingStuff(); + + this.output = 0.0F; + this.maxHeat = 10000; + this.hem = 1.0F; + + processChambers(); + this.EmitHeatbuffer = 0; + if (calculateHeatEffects()) { + return; + } + setActive((this.heat >= 1000) || (this.output > 0.0F)); + + markDirty(); + } + ((NetworkManager)IC2.network.get()).updateTileEntityField(this, "output"); + } + + @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 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); + + this.reactorSlot.put(i, null); + eject(stack); + } + } + + 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); + } + + 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()); + } + + public boolean calculateHeatEffects() + { + Utils.LOG_WARNING("calculateHeatEffects"); + if ((this.heat < 8000) || (!IC2.platform.isSimulating()) || (ConfigUtil.getFloat(MainConfig.get(), "protection/reactorExplosionPowerLimit") <= 0.0F)) { + return false; + } + float power = this.heat / this.maxHeat; + if (power >= 1.0F) + { + explode(); + 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; + } + + 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; + } + + public void processChambers() + { + Utils.LOG_WARNING("processChambers"); + int size = 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(); + comp.processChamber(this, stack, x, y, pass == 0); + } + } + } + } + } + + @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; + } + + @Override + public void setHeat(int heat1) + { + this.heat = heat1; + } + + @Override + public int addHeat(int amount) + { + this.heat += amount; + return this.heat; + } + + @Override + public int getMaxHeat() + { + return this.maxHeat; + } + + @Override + public void setMaxHeat(int newMaxHeat) + { + this.maxHeat = newMaxHeat; + } + + @Override + public void addEmitHeat(int heat) + { + this.EmitHeatbuffer += heat; + } + + @Override + public float getHeatEffectModifier() + { + return this.hem; + } + + @Override + public void setHeatEffectModifier(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; + } + + @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) + { + Utils.LOG_WARNING("setItemAt"); + if ((x < 0) || (x >= 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 + } + + @Override + public int getTickRate() + { + return 20; + } + + public boolean receiveredstone() + { + Utils.LOG_WARNING("receiveRedstone"); + if ((this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) || (this.redstone)) { + decrStackSize(-1, 1); + return true; + } + return false; + } + + @Override + public boolean produceEnergy() + { + Utils.LOG_WARNING("produceEnergy"); + return (receiveredstone()) && (ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/generator") > 0.0F); + } + + @Override + public void setRedstoneSignal(boolean redstone) + { + this.redstone = redstone; + } + + @Override + public boolean isFluidCooled() { + Utils.LOG_WARNING("isFluidCooled"); + return false; + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return true; + } + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { + return true; + } + + @Override + public float getWrenchDropRate() + { + return 1F; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return new ItemStack(ModBlocks.blockHeliumGenerator, 1); + } + +} diff --git a/src/Java/miscutil/core/common/CommonProxy.java b/src/Java/miscutil/core/common/CommonProxy.java index 7c6b9b2d4f..499ea28eb6 100644 --- a/src/Java/miscutil/core/common/CommonProxy.java +++ b/src/Java/miscutil/core/common/CommonProxy.java @@ -17,6 +17,7 @@ import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; public class CommonProxy { @@ -57,9 +58,14 @@ public class CommonProxy { //Compat Handling COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); COMPAT_HANDLER.RemoveRecipesFromOtherMods(); - COMPAT_HANDLER.InitialiseLateHandlerThenAddRecipes(); COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); } + + + public void serverStarting(FMLServerStartingEvent e) + { + COMPAT_HANDLER.InitialiseLateHandlerThenAddRecipes(); + } public void registerNetworkStuff(){ ModGUI.init(); diff --git a/src/Java/miscutil/core/container/Container_Charger.java b/src/Java/miscutil/core/container/Container_Charger.java new file mode 100644 index 0000000000..cbe7156d0e --- /dev/null +++ b/src/Java/miscutil/core/container/Container_Charger.java @@ -0,0 +1,81 @@ +package miscutil.core.container; + +import miscutil.core.tileentities.machines.TileEntityCharger; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class Container_Charger extends Container +{ + private TileEntityCharger te; + + public static final int INPUT_1 = 0; + + private int slotID = 0; + + public Container_Charger(TileEntityCharger te, EntityPlayer player) + { + this.te = te; + + //Fuel Slot A + addSlotToContainer(new Slot(te, slotID++, 80, 53)); + + + + //Inventory + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 9; j++) + { + addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + // Hotbar + for (int i = 0; i < 9; i++) + { + addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) + { + ItemStack stack = null; + Slot slot = (Slot)inventorySlots.get(slotRaw); + + if (slot != null && slot.getHasStack()) + { + ItemStack stackInSlot = slot.getStack(); + stack = stackInSlot.copy(); + + if (slotRaw < 3 * 9) + { + if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) + { + return null; + } + } + else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) + { + return null; + } + + if (stackInSlot.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + } + return stack; + } + + @Override + public boolean canInteractWith(EntityPlayer player) + { + return te.isUseableByPlayer(player); + } +} \ No newline at end of file diff --git a/src/Java/miscutil/core/container/Container_NHG.java b/src/Java/miscutil/core/container/Container_NHG.java index 8baed3f5bd..78461ad2b7 100644 --- a/src/Java/miscutil/core/container/Container_NHG.java +++ b/src/Java/miscutil/core/container/Container_NHG.java @@ -1,6 +1,6 @@ package miscutil.core.container; -import miscutil.core.tileentities.TileEntityNHG; +import miscutil.core.tileentities.machines.TileEntityNHG; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; diff --git a/src/Java/miscutil/core/creative/AddToCreativeTab.java b/src/Java/miscutil/core/creative/AddToCreativeTab.java index 2f271dfa9e..869f2c4925 100644 --- a/src/Java/miscutil/core/creative/AddToCreativeTab.java +++ b/src/Java/miscutil/core/creative/AddToCreativeTab.java @@ -1,5 +1,9 @@ package miscutil.core.creative; +import miscutil.core.creative.tabs.MiscUtilCreativeTabBlock; +import miscutil.core.creative.tabs.MiscUtilCreativeTabMachines; +import miscutil.core.creative.tabs.MiscUtilCreativeTabMisc; +import miscutil.core.creative.tabs.MiscUtilCreativeTabTools; import miscutil.core.lib.CORE; import net.minecraft.creativetab.CreativeTabs; diff --git a/src/Java/miscutil/core/creative/MiscUtilCreativeTabBlock.java b/src/Java/miscutil/core/creative/MiscUtilCreativeTabBlock.java deleted file mode 100644 index b048df7f12..0000000000 --- a/src/Java/miscutil/core/creative/MiscUtilCreativeTabBlock.java +++ /dev/null @@ -1,18 +0,0 @@ -package miscutil.core.creative; - -import miscutil.core.block.ModBlocks; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; - -public class MiscUtilCreativeTabBlock extends CreativeTabs { - - public MiscUtilCreativeTabBlock(String lable) { - super(lable); - } - - @Override - public Item getTabIconItem() { - return Item.getItemFromBlock(ModBlocks.blockStaballoy); - } - -} diff --git a/src/Java/miscutil/core/creative/MiscUtilCreativeTabMachines.java b/src/Java/miscutil/core/creative/MiscUtilCreativeTabMachines.java deleted file mode 100644 index 9029e8d3c7..0000000000 --- a/src/Java/miscutil/core/creative/MiscUtilCreativeTabMachines.java +++ /dev/null @@ -1,18 +0,0 @@ -package miscutil.core.creative; - -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Items; -import net.minecraft.item.Item; - -public class MiscUtilCreativeTabMachines extends CreativeTabs { - - public MiscUtilCreativeTabMachines(String lable) { - super(lable); - } - - @Override - public Item getTabIconItem() { - return Items.experience_bottle; - } - -} diff --git a/src/Java/miscutil/core/creative/MiscUtilCreativeTabMisc.java b/src/Java/miscutil/core/creative/MiscUtilCreativeTabMisc.java deleted file mode 100644 index ee8aebe16d..0000000000 --- a/src/Java/miscutil/core/creative/MiscUtilCreativeTabMisc.java +++ /dev/null @@ -1,18 +0,0 @@ -package miscutil.core.creative; - -import miscutil.core.item.ModItems; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; - -public class MiscUtilCreativeTabMisc extends CreativeTabs { - - public MiscUtilCreativeTabMisc(String lable) { - super(lable); - } - - @Override - public Item getTabIconItem() { - return ModItems.itemPlateVibrantAlloy; - } - -} diff --git a/src/Java/miscutil/core/creative/MiscUtilCreativeTabTools.java b/src/Java/miscutil/core/creative/MiscUtilCreativeTabTools.java deleted file mode 100644 index 75fba9e0ff..0000000000 --- a/src/Java/miscutil/core/creative/MiscUtilCreativeTabTools.java +++ /dev/null @@ -1,18 +0,0 @@ -package miscutil.core.creative; - -import miscutil.core.item.ModItems; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; - -public class MiscUtilCreativeTabTools extends CreativeTabs { - - public MiscUtilCreativeTabTools(String lable) { - super(lable); - } - - @Override - public Item getTabIconItem() { - return ModItems.itemStaballoyAxe; - } - -} diff --git a/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabBlock.java b/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabBlock.java new file mode 100644 index 0000000000..343eb2f341 --- /dev/null +++ b/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabBlock.java @@ -0,0 +1,18 @@ +package miscutil.core.creative.tabs; + +import miscutil.core.block.ModBlocks; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class MiscUtilCreativeTabBlock extends CreativeTabs { + + public MiscUtilCreativeTabBlock(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return Item.getItemFromBlock(ModBlocks.blockStaballoy); + } + +} diff --git a/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMachines.java b/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMachines.java new file mode 100644 index 0000000000..6bc433b93a --- /dev/null +++ b/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMachines.java @@ -0,0 +1,18 @@ +package miscutil.core.creative.tabs; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; + +public class MiscUtilCreativeTabMachines extends CreativeTabs { + + public MiscUtilCreativeTabMachines(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return Items.experience_bottle; + } + +} diff --git a/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMisc.java b/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMisc.java new file mode 100644 index 0000000000..1330f86aee --- /dev/null +++ b/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMisc.java @@ -0,0 +1,18 @@ +package miscutil.core.creative.tabs; + +import miscutil.core.item.ModItems; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class MiscUtilCreativeTabMisc extends CreativeTabs { + + public MiscUtilCreativeTabMisc(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return ModItems.itemPlateVibrantAlloy; + } + +} diff --git a/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabTools.java b/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabTools.java new file mode 100644 index 0000000000..feddf0e5aa --- /dev/null +++ b/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabTools.java @@ -0,0 +1,18 @@ +package miscutil.core.creative.tabs; + +import miscutil.core.item.ModItems; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class MiscUtilCreativeTabTools extends CreativeTabs { + + public MiscUtilCreativeTabTools(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return ModItems.itemStaballoyAxe; + } + +} diff --git a/src/Java/miscutil/core/gui/ModGUI.java b/src/Java/miscutil/core/gui/ModGUI.java index 259270d224..82f6ebf3bf 100644 --- a/src/Java/miscutil/core/gui/ModGUI.java +++ b/src/Java/miscutil/core/gui/ModGUI.java @@ -1,9 +1,9 @@ package miscutil.core.gui; import miscutil.MiscUtils; -import miscutil.core.block.heliumgen.container.ContainerHeliumGenerator; -import miscutil.core.block.heliumgen.gui.GUIHeliumGenerator; -import miscutil.core.block.heliumgen.tileentity.TileEntityHeliumGenerator; +import miscutil.core.block.machine.heliumgen.container.ContainerHeliumGenerator; +import miscutil.core.block.machine.heliumgen.gui.GUIHeliumGenerator; +import miscutil.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; import miscutil.core.handler.GuiHandler; import miscutil.core.util.Utils; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/Java/miscutil/core/gui/machine/GUI_Charger.java b/src/Java/miscutil/core/gui/machine/GUI_Charger.java new file mode 100644 index 0000000000..deca8d4f09 --- /dev/null +++ b/src/Java/miscutil/core/gui/machine/GUI_Charger.java @@ -0,0 +1,50 @@ +package miscutil.core.gui.machine; + +import miscutil.core.container.Container_Charger; +import miscutil.core.lib.CORE; +import miscutil.core.tileentities.machines.TileEntityCharger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +public class GUI_Charger extends GuiContainer +{ + private ResourceLocation texture = new ResourceLocation(CORE.MODID, "textures/gui/machine_Charger.png"); + + private InventoryPlayer inventory; + private TileEntityCharger te; + + public GUI_Charger(TileEntityCharger te, EntityPlayer player) + { + super(new Container_Charger(te, player)); + inventory = player.inventory; + this.te = te; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + fontRendererObj.drawString(I18n.format(te.getInventoryName()), (xSize / 2) - (fontRendererObj.getStringWidth(I18n.format(te.getInventoryName())) / 2), 6, 4210752, false); + //fontRendererObj.drawString(I18n.format(inventory.getInventoryName()), 8, ySize - 96 + 2, 4210752); + fontRendererObj.drawString(I18n.format("Charge:"+te.getCharge()+"~"), 8, ySize - 96 + 2, 4210752); + fontRendererObj.drawString(I18n.format("Progress:"+te.getProgress()+"ticks"), 80, ySize - 96 + 2, 4210752); + } +} \ No newline at end of file diff --git a/src/Java/miscutil/core/gui/machine/GUI_NHG.java b/src/Java/miscutil/core/gui/machine/GUI_NHG.java index b536157a49..e2239d6d40 100644 --- a/src/Java/miscutil/core/gui/machine/GUI_NHG.java +++ b/src/Java/miscutil/core/gui/machine/GUI_NHG.java @@ -2,7 +2,7 @@ package miscutil.core.gui.machine; import miscutil.core.container.Container_NHG; import miscutil.core.lib.CORE; -import miscutil.core.tileentities.TileEntityNHG; +import miscutil.core.tileentities.machines.TileEntityNHG; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; diff --git a/src/Java/miscutil/core/handler/COMPAT_HANDLER.java b/src/Java/miscutil/core/handler/COMPAT_HANDLER.java index 9035039cdf..078c3984ac 100644 --- a/src/Java/miscutil/core/handler/COMPAT_HANDLER.java +++ b/src/Java/miscutil/core/handler/COMPAT_HANDLER.java @@ -24,6 +24,7 @@ import miscutil.core.handler.registration.gregtech.GregtechEnergyBuffer; import miscutil.core.handler.registration.gregtech.GregtechIndustrialCentrifuge; import miscutil.core.handler.registration.gregtech.GregtechIndustrialCokeOven; import miscutil.core.handler.registration.gregtech.GregtechIndustrialPlatePress; +import miscutil.core.handler.registration.gregtech.GregtechRocketFuelGenerator; import miscutil.core.handler.registration.gregtech.GregtechSafeBlock; import miscutil.core.handler.registration.gregtech.GregtechSteamCondenser; import miscutil.core.item.ModItems; @@ -34,6 +35,7 @@ import miscutil.core.recipe.ShapedRecipeObject; import miscutil.core.util.Utils; import miscutil.core.util.item.UtilsItems; import miscutil.core.util.recipe.UtilsRecipe; +import miscutil.gregtech.common.items.MetaGeneratedGregtechItems; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -71,6 +73,7 @@ public class COMPAT_HANDLER { public static void registerGregtechMachines() { if (Gregtech) { + new MetaGeneratedGregtechItems(); GregtechEnergyBuffer.run(); GregtechConduits.run(); GregtechSteamCondenser.run(); @@ -78,6 +81,7 @@ public class COMPAT_HANDLER { GregtechIndustrialCentrifuge.run(); GregtechIndustrialCokeOven.run(); GregtechIndustrialPlatePress.run(); + GregtechRocketFuelGenerator.run(); } } diff --git a/src/Java/miscutil/core/handler/GuiHandler.java b/src/Java/miscutil/core/handler/GuiHandler.java index 67200c6cf3..d604f1b147 100644 --- a/src/Java/miscutil/core/handler/GuiHandler.java +++ b/src/Java/miscutil/core/handler/GuiHandler.java @@ -1,8 +1,11 @@ package miscutil.core.handler; +import miscutil.core.container.Container_Charger; import miscutil.core.container.Container_NHG; +import miscutil.core.gui.machine.GUI_Charger; import miscutil.core.gui.machine.GUI_NHG; -import miscutil.core.tileentities.TileEntityNHG; +import miscutil.core.tileentities.machines.TileEntityCharger; +import miscutil.core.tileentities.machines.TileEntityNHG; import miscutil.core.util.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; @@ -12,7 +15,7 @@ import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { private static final int GUI1 = 0; //Nuclear Helium Gen. - private static final int GUI2 = 1; //Energy Buffer + private static final int GUI2 = 1; //Energy Charger @@ -25,7 +28,7 @@ public class GuiHandler implements IGuiHandler { return new Container_NHG((TileEntityNHG)te, player); } else if (ID == GUI2){ - + return new Container_Charger((TileEntityCharger)te, player); } @@ -44,8 +47,8 @@ public class GuiHandler implements IGuiHandler { return new GUI_NHG((TileEntityNHG) te, player); } else if (ID == GUI2){ - Utils.LOG_WARNING("Opening Gui with Id: "+ID+" Energy Buffer"); - //return new GUI_Bat_Buf(); + Utils.LOG_WARNING("Opening Gui with Id: "+ID+" Charger"); + return new GUI_Charger((TileEntityCharger) te, player); } } return null; diff --git a/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialCentrifuge.java b/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialCentrifuge.java index 06da27f8a3..324131155d 100644 --- a/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialCentrifuge.java +++ b/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialCentrifuge.java @@ -2,7 +2,7 @@ package miscutil.core.handler.registration.gregtech; import miscutil.core.util.Utils; import miscutil.gregtech.api.enums.GregtechItemList; -import miscutil.gregtech.common.machines.multi.GregtechMetaTileEntityIndustrialCentrifuge; +import miscutil.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialCentrifuge; public class GregtechIndustrialCentrifuge { diff --git a/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialCokeOven.java b/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialCokeOven.java index 00aecf6415..53f540609c 100644 --- a/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialCokeOven.java +++ b/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialCokeOven.java @@ -2,7 +2,7 @@ package miscutil.core.handler.registration.gregtech; import miscutil.core.util.Utils; import miscutil.gregtech.api.enums.GregtechItemList; -import miscutil.gregtech.common.machines.multi.GregtechMetaTileEntityIndustrialCokeOven; +import miscutil.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialCokeOven; public class GregtechIndustrialCokeOven { diff --git a/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialPlatePress.java b/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialPlatePress.java index c66dad598d..eba567ea42 100644 --- a/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialPlatePress.java +++ b/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialPlatePress.java @@ -1,7 +1,7 @@ package miscutil.core.handler.registration.gregtech; import miscutil.gregtech.api.enums.GregtechItemList; -import miscutil.gregtech.common.machines.multi.GregtechMetaTileEntityIndustrialPlatePress; +import miscutil.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialPlatePress; public class GregtechIndustrialPlatePress { diff --git a/src/Java/miscutil/core/handler/registration/gregtech/GregtechRocketFuelGenerator.java b/src/Java/miscutil/core/handler/registration/gregtech/GregtechRocketFuelGenerator.java new file mode 100644 index 0000000000..79e33d5a78 --- /dev/null +++ b/src/Java/miscutil/core/handler/registration/gregtech/GregtechRocketFuelGenerator.java @@ -0,0 +1,34 @@ +package miscutil.core.handler.registration.gregtech; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import miscutil.core.lib.LoadedMods; +import miscutil.core.util.Utils; +import miscutil.gregtech.api.enums.GregtechItemList; +import miscutil.gregtech.common.tileentities.generators.GregtechMetaTileEntityRocketFuelGenerator; + +public class GregtechRocketFuelGenerator { + + public static void run() + { + if (LoadedMods.Gregtech){ + Utils.LOG_INFO("MiscUtils: Gregtech5u Content | Registering Industrial Rocket Engines."); + run1(); + } + + } + + private static void run1(){ + GregtechItemList.Rocket_Engine_EV.set(new GregtechMetaTileEntityRocketFuelGenerator(793, "advancedgenerator.rocketFuel.tier.01", "Basic Rocket Engine", 4).getStackForm(1L)); + GregtechItemList.Rocket_Engine_IV.set(new GregtechMetaTileEntityRocketFuelGenerator(794, "advancedgenerator.rocketFuel.tier.02", "Advanced Rocket Engine", 5).getStackForm(1L)); + GregtechItemList.Rocket_Engine_LuV.set(new GregtechMetaTileEntityRocketFuelGenerator(795, "advancedgenerator.rocketFuel.tier.03", "Turbo Rocket Engine", 6).getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Rocket_Engine_EV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"PCP", "EME", "GWG", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('P'), ItemList.Electric_Piston_LV, Character.valueOf('E'), ItemList.Electric_Motor_LV, Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Aluminium), Character.valueOf('G'), OrePrefixes.gearGt.get(Materials.Titanium)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Rocket_Engine_IV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"PCP", "EME", "GWG", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('P'), ItemList.Electric_Piston_MV, Character.valueOf('E'), ItemList.Electric_Motor_MV, Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Platinum), Character.valueOf('G'), OrePrefixes.gearGt.get(Materials.TungstenSteel)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Rocket_Engine_LuV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"PCP", "EME", "GWG", Character.valueOf('M'), ItemList.Hull_LuV, Character.valueOf('P'), ItemList.Electric_Piston_HV, Character.valueOf('E'), ItemList.Electric_Motor_HV, Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Master), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Tungsten), Character.valueOf('G'), OrePrefixes.gearGt.get(Materials.Chrome)}); + + } + +} diff --git a/src/Java/miscutil/core/handler/registration/gregtech/GregtechSteamCondenser.java b/src/Java/miscutil/core/handler/registration/gregtech/GregtechSteamCondenser.java index 652f089719..afc899410b 100644 --- a/src/Java/miscutil/core/handler/registration/gregtech/GregtechSteamCondenser.java +++ b/src/Java/miscutil/core/handler/registration/gregtech/GregtechSteamCondenser.java @@ -3,7 +3,7 @@ package miscutil.core.handler.registration.gregtech; import miscutil.core.util.Utils; import miscutil.gregtech.api.enums.GregtechItemList; import miscutil.gregtech.api.metatileentity.implementations.GregtechMetaCondensor; -import miscutil.gregtech.common.machines.multi.GregtechMetaTileEntityIronBlastFurnace; +import miscutil.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIronBlastFurnace; public class GregtechSteamCondenser { diff --git a/src/Java/miscutil/core/item/ModItems.java b/src/Java/miscutil/core/item/ModItems.java index fbec6a59a3..6da428c924 100644 --- a/src/Java/miscutil/core/item/ModItems.java +++ b/src/Java/miscutil/core/item/ModItems.java @@ -105,6 +105,9 @@ Gold Tool: 22*/ public static Item FuelRod_Uranium; public static Item FuelRod_Plutonium; + public static Item itemBedLocator_Base; + public static Item itemBaseItemWithCharge; + //@SuppressWarnings("unused") public static final void init(){ @@ -225,10 +228,10 @@ Gold Tool: 22*/ FuelRod_Uranium = new FuelRod_Base("itemFuelRod_Uranium", "Uranium", 2500, 2500); FuelRod_Plutonium = new FuelRod_Base("itemFuelRod_Plutonium", "Plutonium", 5000, 5000); //Registry - GameRegistry.registerItem(FuelRod_Empty, "itemFuelRod_Empty"); - GameRegistry.registerItem(FuelRod_Thorium, "itemFuelRod_Thorium"); - GameRegistry.registerItem(FuelRod_Uranium, "itemFuelRod_Uranium"); - GameRegistry.registerItem(FuelRod_Plutonium, "itemFuelRod_Plutonium"); + //GameRegistry.registerItem(FuelRod_Empty, "itemFuelRod_Empty"); + //GameRegistry.registerItem(FuelRod_Thorium, "itemFuelRod_Thorium"); + //GameRegistry.registerItem(FuelRod_Uranium, "itemFuelRod_Uranium"); + //GameRegistry.registerItem(FuelRod_Plutonium, "itemFuelRod_Plutonium"); } else { Utils.LOG_WARNING("IndustrialCraft2 not Found - Skipping Resources."); @@ -236,6 +239,14 @@ Gold Tool: 22*/ /* * Misc Items */ + + + //itemBedLocator_Base = new BedLocator_Base("itemBedLocator_Base"); + //GameRegistry.registerItem(itemBedLocator_Base, "itemBedLocator_Base"); + + //itemBaseItemWithCharge = new BaseItemWithCharge("itemBaseItemWithCharge", 0, 1000); + //GameRegistry.registerItem(itemBaseItemWithCharge, "itemBaseItemWithCharge"); + //Staballoy Equipment itemStaballoyPickaxe = new StaballoyPickaxe("itemStaballoyPickaxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); GameRegistry.registerItem(itemStaballoyPickaxe, itemStaballoyPickaxe.getUnlocalizedName()); @@ -257,10 +268,10 @@ Gold Tool: 22*/ //Buffer Cores! Item itemBufferCore; for(int i=1; i<=10; i++){ - Utils.LOG_INFO(""+i); + //Utils.LOG_INFO(""+i); itemBufferCore = new BufferCore("itemBufferCore", i).setCreativeTab(AddToCreativeTab.tabMisc); GameRegistry.registerItem(itemBufferCore, itemBufferCore.getUnlocalizedName()+i); - System.out.println("Buffer Core registration count is: "+i); + //System.out.println("Buffer Core registration count is: "+i); } //Dev Items itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemStickyRubber"); @@ -270,6 +281,7 @@ Gold Tool: 22*/ GameRegistry.registerItem(itemIngotBatteryAlloy, "itemIngotBatteryAlloy"); itemPlateBatteryAlloy = new Item().setUnlocalizedName("itemPlateBatteryAlloy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemPlateBatteryAlloy"); GameRegistry.registerItem(itemPlateBatteryAlloy, "itemPlateBatteryAlloy"); + itemHeliumBlob = new Item().setUnlocalizedName("itemHeliumBlob").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob"); GameRegistry.registerItem(itemHeliumBlob, "itemHeliumBlob"); diff --git a/src/Java/miscutil/core/item/base/BaseItemWithCharge.java b/src/Java/miscutil/core/item/base/BaseItemWithCharge.java new file mode 100644 index 0000000000..7c88a62ed0 --- /dev/null +++ b/src/Java/miscutil/core/item/base/BaseItemWithCharge.java @@ -0,0 +1,74 @@ +package miscutil.core.item.base; + +import java.util.List; + +import miscutil.core.creative.AddToCreativeTab; +import miscutil.core.lib.CORE; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BaseItemWithCharge extends Item{ + + public int int_Charge = 0; + public int int_Max_Charge = 0; + + public BaseItemWithCharge(String unlocalizedName, int constructor_Charge, int constructor_Max_Charge) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.int_Charge = constructor_Charge; + this.int_Max_Charge = constructor_Max_Charge; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + int NBT_Charge = int_Charge; + int NBT_Max_Charge = int_Max_Charge; + if (stack.stackTagCompound != null) { + NBT_Charge = stack.stackTagCompound.getInteger("charge_Current"); + NBT_Max_Charge = stack.stackTagCompound.getInteger("charge_Max"); + String tempX = String.valueOf(NBT_Charge); + String tempY = String.valueOf(NBT_Max_Charge); + String formattedX = EnumChatFormatting.RED+tempX+EnumChatFormatting.GRAY; + String formattedY = EnumChatFormatting.DARK_RED+tempY+EnumChatFormatting.GRAY; + list.add(EnumChatFormatting.GRAY+"Charge:"+formattedX+"/"+formattedY+"."); + super.addInformation(stack, aPlayer, list, bool); + } + } + + //Ticking and NBT Handling + /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and + * update it's contents. + * + * public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = 5000; + * + */ + @Override + public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { + + } + + @Override + public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) { + itemStack.stackTagCompound = new NBTTagCompound(); + return super.onItemRightClick(itemStack, world, par3Entity); + } + + + +} diff --git a/src/Java/miscutil/core/item/general/BedLocator_Base.java b/src/Java/miscutil/core/item/general/BedLocator_Base.java new file mode 100644 index 0000000000..b4402e0689 --- /dev/null +++ b/src/Java/miscutil/core/item/general/BedLocator_Base.java @@ -0,0 +1,106 @@ +package miscutil.core.item.general; + +import java.util.List; + +import miscutil.core.creative.AddToCreativeTab; +import miscutil.core.lib.CORE; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BedLocator_Base extends Item{ + + public int bed_X = 0; + public int bed_Y = 0; + public int bed_Z = 0; + + public BedLocator_Base(String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + + + int NBT_X = bed_X; + int NBT_Y = bed_Y; + int NBT_Z = bed_Z; + + + if (stack.stackTagCompound != null) { + NBT_X = stack.stackTagCompound.getInteger("pos_x"); + NBT_Y = stack.stackTagCompound.getInteger("pos_y"); + NBT_Z = stack.stackTagCompound.getInteger("pos_z"); + + String tempX = String.valueOf(NBT_X); + String tempY = String.valueOf(NBT_Y); + String tempZ = String.valueOf(NBT_Z); + String formattedX = EnumChatFormatting.DARK_RED+tempX+EnumChatFormatting.GRAY; + String formattedY = EnumChatFormatting.RED+tempY+EnumChatFormatting.GRAY; + String formattedZ = EnumChatFormatting.RED+tempZ+EnumChatFormatting.GRAY; + + list.add(EnumChatFormatting.GRAY+"X: "+formattedX+"."); + list.add(EnumChatFormatting.GRAY+"Y: "+formattedY+"."); + list.add(EnumChatFormatting.GRAY+"Z: "+formattedZ+"."); + super.addInformation(stack, aPlayer, list, bool); + } + } + + //Ticking and NBT Handling + /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and + * update it's contents. + * + * public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = 5000; + * + */ + @Override + public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { + itemStack.stackTagCompound = new NBTTagCompound(); + this.bed_X = 0; + this.bed_Y = 0; + this.bed_Z = 0; + itemStack.stackTagCompound.setInteger("pos_x", bed_X); + itemStack.stackTagCompound.setInteger("pos_y", bed_Y); + itemStack.stackTagCompound.setInteger("pos_z", bed_Z); + } + + @Override + public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + + + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) { + itemStack.stackTagCompound = new NBTTagCompound(); + if (par3Entity.getBedLocation() != null){ + this.bed_X = par3Entity.getBedLocation().posX; + this.bed_Y = par3Entity.getBedLocation().posY; + this.bed_Z = par3Entity.getBedLocation().posZ; + } + else { + this.bed_X = 0; + this.bed_Y = 0; + this.bed_Z = 0; + } + itemStack.stackTagCompound.setInteger("pos_x", bed_X); + itemStack.stackTagCompound.setInteger("pos_y", bed_Y); + itemStack.stackTagCompound.setInteger("pos_z", bed_Z); + return super.onItemRightClick(itemStack, world, par3Entity); + } + + + +} diff --git a/src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java b/src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java index 20d6fcd08e..4aa9f57092 100644 --- a/src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java +++ b/src/Java/miscutil/core/item/general/fuelrods/FuelRod_Base.java @@ -19,7 +19,6 @@ public class FuelRod_Base extends Item{ public String fuelType = ""; public float heat = 0; public float maxHeat = getMaxHeat(); - private ItemStack thisStack = null; public FuelRod_Base(String unlocalizedName, String type, int fuelLeft, int maxFuel) { this.setUnlocalizedName(unlocalizedName); this.setTextureName(CORE.MODID + ":" + unlocalizedName); @@ -30,12 +29,6 @@ public class FuelRod_Base extends Item{ this.fuelType = type; this.setCreativeTab(AddToCreativeTab.tabMachines); } - - /*@Override - public void setDamage(ItemStack stack, int damage) { - this.heat=heat+5; - super.setDamage(stack, damage); - }*/ private float getMaxHeat(){ float tempvar; @@ -58,6 +51,13 @@ public class FuelRod_Base extends Item{ } + private void updateVars(ItemStack stack){ + if (stack.stackTagCompound != null) { + heat = stack.stackTagCompound.getFloat("heat"); + fuelRemaining = stack.stackTagCompound.getInteger("fuelRemaining"); + } + } + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { @@ -67,12 +67,12 @@ public class FuelRod_Base extends Item{ int NBT_Fuel = fuelRemaining; String NBT_Type= fuelType; - thisStack = stack; if (stack.stackTagCompound != null) { NBT_Heat = stack.stackTagCompound.getFloat("heat"); NBT_MaxHeat = stack.stackTagCompound.getFloat("maxHeat"); NBT_Fuel = stack.stackTagCompound.getInteger("fuelRemaining"); - NBT_Type = stack.stackTagCompound.getString("fuelType");} + NBT_Type = stack.stackTagCompound.getString("fuelType"); + } String tempHeat = String.valueOf(NBT_Heat); String tempMaxHeat = String.valueOf(NBT_MaxHeat); @@ -85,6 +85,8 @@ public class FuelRod_Base extends Item{ int tempMax = maximumFuel; float tempCurrentHeat = heat; int tempFuelLeft = fuelRemaining; + + //Fuel Usage Formatting if (tempFuelLeft <= maximumFuel/3){ formattedFuelLeft = EnumChatFormatting.RED+tempFuel+EnumChatFormatting.GRAY; } @@ -97,44 +99,54 @@ public class FuelRod_Base extends Item{ else { formattedFuelLeft = EnumChatFormatting.GRAY+tempFuel+EnumChatFormatting.GRAY; } - if (tempCurrentHeat <= maxHeat/3 && tempCurrentHeat != 0){ + + //Heat Formatting + if (tempCurrentHeat <= 200 && tempCurrentHeat >= 0){ formattedHeat = EnumChatFormatting.GRAY+tempHeat+EnumChatFormatting.GRAY; } - else if (tempCurrentHeat >= maxHeat/3 && tempMax <= (maxHeat/3)*2 && tempCurrentHeat != 0){ + else if (tempCurrentHeat <= maxHeat/3 && tempCurrentHeat > 200){ formattedHeat = EnumChatFormatting.YELLOW+tempHeat+EnumChatFormatting.GRAY; } - else if (tempCurrentHeat <= (maxHeat/3)*2 && tempMax <= maxHeat && tempCurrentHeat != 0){ + else if (tempCurrentHeat >= maxHeat/3 && tempMax < (maxHeat/3)*2 && tempCurrentHeat != 0){ + formattedHeat = EnumChatFormatting.GOLD+tempHeat+EnumChatFormatting.GRAY; + } + else if (tempCurrentHeat >= ((maxHeat/3)*2) && tempMax <= maxHeat && tempCurrentHeat != 0){ formattedHeat = EnumChatFormatting.RED+tempHeat+EnumChatFormatting.GRAY; } else { formattedHeat = EnumChatFormatting.BLUE+tempHeat+EnumChatFormatting.GRAY; } - list.add(EnumChatFormatting.GRAY+"A "+formattedType+" Fuel Rod."); list.add(EnumChatFormatting.GRAY+"Running at "+formattedHeat+"/"+formattedMaxHeat+" Kelvin."); list.add(EnumChatFormatting.GRAY+"Fuel Remaining: "+formattedFuelLeft+"L."); super.addInformation(stack, aPlayer, list, bool); } - public String getType(){ - return fuelType; + public String getType(ItemStack stack){ + if (stack.stackTagCompound != null){ + return stack.stackTagCompound.getString("fuelType"); + } + return fuelType; } - public int getFuelRemaining(){ - return fuelRemaining; + public int getFuelRemaining(ItemStack stack){ + if (stack.stackTagCompound != null){ + return stack.stackTagCompound.getInteger("fuelRemaining"); + } + return 0; } public int getMaxFuel(){ return maximumFuel; } - public int getFuel(){ - if (thisStack != null){ - int i = thisStack.getItemDamage(); + public int getFuel(ItemStack stack){ + if (stack != null){ + int i = stack.getItemDamage(); int r = maximumFuel - i; return r; } - return fuelRemaining; + return getFuelRemaining(stack); } public boolean setFuelRemainingExplicitly(int i){ @@ -155,8 +167,11 @@ public class FuelRod_Base extends Item{ return false; } - public float getHeat(){ - return heat; + public float getHeat(ItemStack value){ + if (value.stackTagCompound != null){ + return value.stackTagCompound.getFloat("heat"); + } + return 0f; } public boolean addHeat(float i){ @@ -183,22 +198,23 @@ public class FuelRod_Base extends Item{ @Override public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { itemStack.stackTagCompound = new NBTTagCompound(); - itemStack.stackTagCompound.setInteger("fuelRemaining", fuelRemaining); + itemStack.stackTagCompound.setInteger("fuelRemaining", getFuelRemaining(itemStack)); itemStack.stackTagCompound.setInteger("maximumFuel", maximumFuel); - itemStack.stackTagCompound.setFloat("heat", heat); - itemStack.stackTagCompound.setFloat("maxHeat", maxHeat); - itemStack.stackTagCompound.setString("fuelType", fuelType); + itemStack.stackTagCompound.setFloat("heat", getHeat(itemStack)); + itemStack.stackTagCompound.setFloat("maxHeat", getMaxHeat()); + itemStack.stackTagCompound.setString("fuelType", getType(itemStack)); + updateVars(itemStack); } @Override public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) { itemStack.stackTagCompound = new NBTTagCompound(); - itemStack.stackTagCompound.setInteger("fuelRemaining", getFuelRemaining()); + itemStack.stackTagCompound.setInteger("fuelRemaining", getFuelRemaining(itemStack)); itemStack.stackTagCompound.setInteger("maximumFuel", maximumFuel); - itemStack.stackTagCompound.setFloat("heat", getHeat()); + itemStack.stackTagCompound.setFloat("heat", getHeat(itemStack)); itemStack.stackTagCompound.setFloat("maxHeat", getMaxHeat()); - itemStack.stackTagCompound.setString("fuelType", fuelType); - + itemStack.stackTagCompound.setString("fuelType", getType(itemStack)); + updateVars(itemStack); } diff --git a/src/Java/miscutil/core/lib/CORE.java b/src/Java/miscutil/core/lib/CORE.java index f2be1776bd..1e9f9b90dc 100644 --- a/src/Java/miscutil/core/lib/CORE.java +++ b/src/Java/miscutil/core/lib/CORE.java @@ -15,7 +15,7 @@ public class CORE { public static final String name = "Misc. Utils"; public static final String MODID = "miscutils"; public static final String VERSION = "1.0.4"; - public static final boolean DEBUG = true; + public static final boolean DEBUG = false; public static final boolean LOAD_ALL_CONTENT = false; public static final int GREG_FIRST_ID = 760; public static Map PlayerCache; @@ -42,15 +42,17 @@ public class CORE { TEX_DIR = "textures/", TEX_DIR_GUI = TEX_DIR + "gui/", TEX_DIR_ITEM = TEX_DIR + "items/", - TEX_DIR_BLOCK = TEX_DIR/* + "blocks/"*/, + TEX_DIR_BLOCK = TEX_DIR + "blocks/", TEX_DIR_ENTITY = TEX_DIR + "entity/", TEX_DIR_ASPECTS = TEX_DIR + "aspects/", + TEX_DIR_FLUIDS = TEX_DIR_BLOCK + "fluids/", RES_PATH = MODID + ":" + TEX_DIR, RES_PATH_GUI = MODID + ":" + TEX_DIR_GUI, RES_PATH_ITEM = MODID + ":" + TEX_DIR_ITEM, RES_PATH_BLOCK = MODID + ":" + TEX_DIR_BLOCK, RES_PATH_ENTITY = MODID + ":" + TEX_DIR_ENTITY, - RES_PATH_ASPECTS = MODID + ":" + TEX_DIR_ASPECTS; + RES_PATH_ASPECTS = MODID + ":" + TEX_DIR_ASPECTS, + RES_PATH_FLUIDS = MODID + ":" + TEX_DIR_FLUIDS; //public static final Materials2[] MiscGeneratedMaterials = new Materials2[1000]; diff --git a/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java b/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java index 3f3338b1d1..d35e304815 100644 --- a/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java @@ -2,6 +2,7 @@ package miscutil.core.recipe; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import miscutil.core.lib.CORE; import miscutil.core.util.Utils; @@ -82,4 +83,8 @@ public class RECIPES_GREGTECH { //GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 6L), ItemList.Casing_Turbine.get(1L, new Object[0]), ItemList.Casing_Turbine3.get(1L, new Object[0]), 50, 16); } + + private static void addFuels(){ + CORE.RA.addFuel(GT_ModHandler.getModItem("ForbiddenMagic", "NetherShard", 1L, 1), null, 2800, 5); + } } \ No newline at end of file diff --git a/src/Java/miscutil/core/tileentities/ModTileEntities.java b/src/Java/miscutil/core/tileentities/ModTileEntities.java index a27e7be6ad..0f5ba5ed56 100644 --- a/src/Java/miscutil/core/tileentities/ModTileEntities.java +++ b/src/Java/miscutil/core/tileentities/ModTileEntities.java @@ -1,8 +1,6 @@ package miscutil.core.tileentities; -import miscutil.core.block.heliumgen.tileentity.TileEntityHeliumGenerator; import miscutil.core.util.Utils; -import cpw.mods.fml.common.registry.GameRegistry; public class ModTileEntities { @@ -10,9 +8,10 @@ public class ModTileEntities { public static void init(){ Utils.LOG_INFO("Registering Tile Entities."); //GameRegistry.registerTileEntity(TileEntityReverter.class, "TE_blockGriefSaver"); - GameRegistry.registerTileEntity(TileEntityReverter.class, "Tower Reverter"); - GameRegistry.registerTileEntity(TileEntityNHG.class, "NuclearFueledHeliumGenerator"); - GameRegistry.registerTileEntity(TileEntityHeliumGenerator.class, "Helium"); + //GameRegistry.registerTileEntity(TileEntityReverter.class, "Tower Reverter"); + //GameRegistry.registerTileEntity(TileEntityNHG.class, "NuclearFueledHeliumGenerator"); + //GameRegistry.registerTileEntity(TileEntityCharger.class, "TE_Charger"); + // GameRegistry.registerTileEntity(TileEntityHeliumGenerator.class, "Helium"); } } diff --git a/src/Java/miscutil/core/tileentities/TileEntityNHG.java b/src/Java/miscutil/core/tileentities/TileEntityNHG.java deleted file mode 100644 index 17dd8d4216..0000000000 --- a/src/Java/miscutil/core/tileentities/TileEntityNHG.java +++ /dev/null @@ -1,487 +0,0 @@ -package miscutil.core.tileentities; - -import miscutil.core.item.ModItems; -import miscutil.core.item.general.fuelrods.FuelRod_Base; -import miscutil.core.util.Utils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.Constants; - -public class TileEntityNHG extends TileEntity implements IInventory -{ - private ItemStack[] items = new ItemStack[19]; //18 - private int progress = 1; - private int maxProgress = 180; - private int heatCycleProgress = 12; - public float coreTemp; - public float maxTemp = 10000; - private boolean fuelrod_1 = false; - private boolean fuelrod_2 = false; - private boolean fuelrod_3 = false; - private boolean fuelrod_4 = false; - private boolean fuelrod_5 = false; - private boolean fuelrod_6 = false; - private boolean fuelrod_7 = false; - private boolean fuelrod_8 = false; - private boolean fuelrod_9 = false; - private boolean fuelrod_10 = false; - private boolean fuelrod_11 = false; - private boolean fuelrod_12 = false; - private boolean fuelrod_13 = false; - private boolean fuelrod_14 = false; - private boolean fuelrod_15 = false; - private boolean fuelrod_16 = false; - private boolean fuelrod_17 = false; - private boolean fuelrod_18 = false; - - public float getCoreTemp(){ - return coreTemp; - } - - public int getProgress(){ - return progress; - } - - public boolean isValidFuelRod(ItemStack input){ - if(!this.worldObj.isRemote){ - if (input != null){ - if (input.copy().getItem() instanceof FuelRod_Base){ - int fuelRodFuelLevel = getRodFuelValue(input); - float fuelRodHeatLevel = getRodHeatValue(input); - Utils.LOG_WARNING("Fuel Left: "+fuelRodFuelLevel+" Current Temp: "+fuelRodHeatLevel); - return true; - //return input.stackTagCompound.getInteger("code"); - } - } - - } - return false; - } - - public ItemStack doFuelRodHeatDamage(ItemStack input){ - if(!this.worldObj.isRemote){ - if (input.copy() != null){ - if (isValidFuelRod(input.copy())){ - int fuelRodFuelLevel = getRodFuelValue(input.copy()); - float fuelRodHeatLevel = getRodHeatValue(input.copy()); - if((fuelRodHeatLevel <= 0 || fuelRodHeatLevel == 0) && fuelRodFuelLevel > 0){ - - if(fuelRodFuelLevel <= 0 || fuelRodFuelLevel == 0){ - return null; - } - else if(fuelRodFuelLevel >= 5){ - int tempInt=fuelRodFuelLevel; - float tempFloat=fuelRodHeatLevel; - ItemStack output = input.copy(); - output.stackTagCompound.setInteger("fuelRemaining", tempInt-5); - output.stackTagCompound.setFloat("heat", tempFloat+5); - - return output; - } - else { - return null; - } - } - else if(fuelRodHeatLevel >= 5 && fuelRodFuelLevel == 0){ - input.stackTagCompound.setInteger("heat", -5); - return input; - } - else { - return null; - } - } - } - } - return null; - } - - public float getRodHeatValue(ItemStack value){ - if (value.copy() != null){ - if (value.copy().stackTagCompound != null){ - return value.copy().stackTagCompound.getFloat("heat"); - } - } - return 0f; - } - - public int getRodFuelValue(ItemStack value){ - if (value.copy() != null){ - if (value.copy().stackTagCompound != null){ - int tempInt = value.copy().stackTagCompound.getInteger("fuelRemaining"); - return tempInt; - } - } - return 0; - } - - public void checkFuelRods(){ - - if(!this.worldObj.isRemote){ - for (int i = 0; i < getSizeInventory(); i++){ - if (items[i] != null){ - if (items[i].copy().getItem() instanceof FuelRod_Base){ - ItemStack fuelRodStack = getStackInSlot(i).copy(); - //setInventorySlotContents(i, doFuelRodHeatDamage(fuelRodStack)); - if (i == 0){ - fuelrod_1 = true; - FuelRod_Base x = (FuelRod_Base) fuelRodStack.getItem(); - x.addHeat(5); - x.addFuel(-5); - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 1){ - fuelrod_2 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 2){ - fuelrod_3 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 3){ - fuelrod_4 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 4){ - fuelrod_5 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 5){ - fuelrod_6 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 6){ - fuelrod_7 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 7){ - fuelrod_8 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 8){ - fuelrod_9 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 9){ - fuelrod_10 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 10){ - fuelrod_11 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 11){ - fuelrod_12 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 12){ - fuelrod_13 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 13){ - fuelrod_14 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 14){ - fuelrod_15 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 15){ - fuelrod_16 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 16){ - fuelrod_17 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - else if (i == 17){ - fuelrod_18 = true; - ItemStack r = doFuelRodHeatDamage(fuelRodStack); - setInventorySlotContents(i, r); - } - - - } - } - } - - } - - } - - public boolean calculateHeat(){ - /*if (!fuelrod_1 || !fuelrod_2 || !fuelrod_3 || !fuelrod_4 || !fuelrod_5 || !fuelrod_6 || !fuelrod_7 || !fuelrod_8 || !fuelrod_9 || !fuelrod_10 || !fuelrod_11 || !fuelrod_12 || !fuelrod_13 || !fuelrod_14 || !fuelrod_15 || !fuelrod_16 || !fuelrod_17 || !fuelrod_18){ - coreTemp = 0; - } - else {*/ - if(!this.worldObj.isRemote){ - for (int i = 0; i < getSizeInventory(); i++){ - if (items[i] != null){ - if (items[i].copy().getItem() instanceof FuelRod_Base){ - ItemStack fuelRodStack = getStackInSlot(i).copy(); - //if (fuelRodStack.stackTagCompound.getFloat("heat") != 0){ - doFuelRodHeatDamage(fuelRodStack); - coreTemp = coreTemp+fuelRodStack.stackTagCompound.getFloat("heat"); - return true; - //} - } - } - } - } - //} - - - - return false; - } - - @Override - public int getSizeInventory() - { - return items.length; - } - - @Override - public ItemStack getStackInSlot(int slot) - { - - return items[slot]; - - } - - @Override - public ItemStack decrStackSize(int slot, int amount) - { - if (items[slot] != null) - { - ItemStack itemstack; - - if (items[slot].stackSize == amount) - { - itemstack = items[slot]; - items[slot] = null; - markDirty(); - return itemstack; - } - itemstack = items[slot].splitStack(amount); - if (items[slot].stackSize == 0) items[slot] = null; - markDirty(); - return itemstack; - } - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) - { - if (items[slot] != null) - { - ItemStack itemstack = items[slot]; - items[slot] = null; - return itemstack; - } - return null; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack) - { - if (stack != null){ - items[slot] = stack; - if (stack != null && stack.stackSize > getInventoryStackLimit()) - { - stack.stackSize = getInventoryStackLimit(); - } - - - markDirty(); - } - } - - @Override - public String getInventoryName() - { - return "container.NHG"; - } - - @Override - public boolean hasCustomInventoryName() - { - return false; - } - - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - NBTTagList list = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND); - items = new ItemStack[getSizeInventory()]; - - for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound comp = list.getCompoundTagAt(i); int j = comp.getByte("Slot") & 255; if (j >= 0 && j < items.length) - { - items[j] = ItemStack.loadItemStackFromNBT(comp); - } - } - } - - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - NBTTagList list = new NBTTagList(); - - for (int i = 0; i < items.length; ++i) - { - if (items[i] != null) - { - NBTTagCompound comp = new NBTTagCompound(); - comp.setByte("Slot", (byte)i); - items[i].writeToNBT(comp); - list.appendTag(comp); - } - } - - nbt.setTag("Items", list); - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack) - { - return true; - } - - //Machine Code - TODO - private ItemStack neutrons; - - @Override - public void updateEntity() { - - if(!this.worldObj.isRemote){ - - if(progress >= heatCycleProgress){ - //Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity "+this.getBlockType().getUnlocalizedName(), 376); - if (Utils.divideXintoY(heatCycleProgress, maxProgress)){ - Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity "+this.getBlockType().getUnlocalizedName(), 378); - calculateHeat(); - heatCycleProgress=0; - } - } - - if(++progress >= maxProgress){ - - - Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity "+this.getBlockType().getUnlocalizedName(), 338); - if (items[18] != null){ - ItemStack checkOutput = getStackInSlot(18); - if(neutrons == null){ - neutrons = new ItemStack(ModItems.itemHeliumBlob, 1); - if (checkOutput == null){ - Utils.LOG_WARNING("ItemStack in Output slot is definitely null, making a new ItemStack."); - setInventorySlotContents(18, neutrons); - progress = 0; - markDirty(); - } - else { - checkOutput.stackSize++; - Utils.LOG_WARNING("Found an ItemStack to increase the size of. Current size is "+neutrons.stackSize); - - progress = 0; - markDirty(); - } - } - else if(checkOutput.getItem() == ModItems.itemHeliumBlob && checkOutput.stackSize < 64){ - checkOutput.stackSize++; - Utils.LOG_WARNING("Found an ItemStack to increase size of. Current size is "+checkOutput.stackSize); - progress = 0; - markDirty(); - } - else if(checkOutput.getItem() == ModItems.itemHeliumBlob && checkOutput.stackSize == 64){ - Utils.LOG_WARNING("Output stack is full."); - progress = 0; - markDirty(); - } - } - else if (items[18] == null){ - Utils.LOG_WARNING("ItemStack in Output slot is null"); - neutrons = new ItemStack(ModItems.itemHeliumBlob, 1); - ItemStack checkOutput = getStackInSlot(18); - if (checkOutput == null){ - Utils.LOG_WARNING("ItemStack in Output slot is definitely null, making a new ItemStack."); - setInventorySlotContents(18, neutrons); - progress = 0; - markDirty(); - } - else { - Utils.LOG_WARNING("Found an ItemStack to increase the size of."); - checkOutput.stackSize++; - progress = 0; - markDirty(); - } - } - checkFuelRods(); - } - progress++; - } - } - - public void readCustomNBT(NBTTagCompound tag) - { - this.neutrons = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Neutrons")); - this.progress = tag.getInteger("Progress"); - this.coreTemp = tag.getFloat("coreTemp"); - } - - public void writeCustomNBT(NBTTagCompound tag) - { - tag.setInteger("Progress", this.progress); - tag.setFloat("coreTemp", this.coreTemp); - if(neutrons != null) { - NBTTagCompound produce = new NBTTagCompound(); - neutrons.writeToNBT(produce); - tag.setTag("Neutrons", produce); - } - else - tag.removeTag("Neutrons"); - } - - - -} \ No newline at end of file diff --git a/src/Java/miscutil/core/tileentities/TileEntityReverter.java b/src/Java/miscutil/core/tileentities/TileEntityReverter.java deleted file mode 100644 index 4ee8eeed4b..0000000000 --- a/src/Java/miscutil/core/tileentities/TileEntityReverter.java +++ /dev/null @@ -1,309 +0,0 @@ -package miscutil.core.tileentities; - -import java.util.Random; - -import miscutil.core.block.ModBlocks; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; - - - -public class TileEntityReverter extends TileEntity -{ - private static final int REVERT_CHANCE = 10; - public int radius = 16; - public int diameter = 8 * this.radius + 4; - public double requiredPlayerRange = 64.0D; - public Random rand = new Random(); - private int tickCount; - private boolean slowScan; - private int ticksSinceChange; - private Block[] blockData; - private byte[] metaData; - - public boolean canUpdate(){ - return true; - } - - public void updateEntity() - { - if (anyPlayerInRange()) - { - this.tickCount += 1; - if (this.worldObj.isRemote) - { - double var1 = this.xCoord + this.worldObj.rand.nextFloat(); - double var3 = this.yCoord + this.worldObj.rand.nextFloat(); - double var5 = this.zCoord + this.worldObj.rand.nextFloat(); - - this.worldObj.spawnParticle("enchantmenttable", var1, var3, var5, 0.0D, 0.0D, 0.0D); - if (this.rand.nextInt(5) == 0) - { - makeRandomOutline(); - makeRandomOutline(); - makeRandomOutline(); - } - } - else - { - if ((this.blockData == null) || (this.metaData == null)) - { - captureBlockData(); - this.slowScan = true; - } - if ((!this.slowScan) || (this.tickCount % 20 == 0)) { - if (scanAndRevertChanges()) - { - this.slowScan = false; - this.ticksSinceChange = 0; - } - else - { - this.ticksSinceChange += 1; - if (this.ticksSinceChange > 20) { - this.slowScan = true; - } - } - } - } - } - else - { - this.blockData = null; - this.metaData = null; - - this.tickCount = 0; - } - } - - private void makeRandomOutline() - { - makeOutline(this.rand.nextInt(12)); - } - - private void makeOutline(int outline) - { - double sx = this.xCoord; - double sy = this.yCoord; - double sz = this.zCoord; - - double dx = this.xCoord; - double dy = this.yCoord; - double dz = this.zCoord; - switch (outline) - { - case 0: - sx -= this.radius; - dx -= this.radius; - sz -= this.radius; - dz += this.radius + 1; - case 8: - sx -= this.radius; - dx += this.radius + 1; - sz -= this.radius; - dz -= this.radius; - break; - case 1: - case 9: - sx -= this.radius; - dx -= this.radius; - sz -= this.radius; - dz += this.radius + 1; - break; - case 2: - case 10: - sx -= this.radius; - dx += this.radius + 1; - sz += this.radius + 1; - dz += this.radius + 1; - break; - case 3: - case 11: - sx += this.radius + 1; - dx += this.radius + 1; - sz -= this.radius; - dz += this.radius + 1; - break; - case 4: - sx -= this.radius; - dx -= this.radius; - sz -= this.radius; - dz -= this.radius; - break; - case 5: - sx += this.radius + 1; - dx += this.radius + 1; - sz -= this.radius; - dz -= this.radius; - break; - case 6: - sx += this.radius + 1; - dx += this.radius + 1; - sz += this.radius + 1; - dz += this.radius + 1; - break; - case 7: - sx -= this.radius; - dx -= this.radius; - sz += this.radius + 1; - dz += this.radius + 1; - } - switch (outline) - { - case 0: - case 1: - case 2: - case 3: - sy += this.radius + 1; - dy += this.radius + 1; - break; - case 4: - case 5: - case 6: - case 7: - sy -= this.radius; - dy += this.radius + 1; - break; - case 8: - case 9: - case 10: - case 11: - sy -= this.radius; - dy -= this.radius; - } - if (this.rand.nextBoolean()) { - drawParticleLine(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, dx, dy, dz); - } else { - drawParticleLine(sx, sy, sz, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D); - } - drawParticleLine(sx, sy, sz, dx, dy, dz); - } - - protected void drawParticleLine(double srcX, double srcY, double srcZ, double destX, double destY, double destZ) - { - int particles = 16; - for (int i = 0; i < particles; i++) - { - double trailFactor = i / (particles - 1.0D); - - double tx = srcX + (destX - srcX) * trailFactor + this.rand.nextFloat() * 0.005D; - double ty = srcY + (destY - srcY) * trailFactor + this.rand.nextFloat() * 0.005D; - double tz = srcZ + (destZ - srcZ) * trailFactor + this.rand.nextFloat() * 0.005D; - this.worldObj.spawnParticle("portal", tx, ty, tz, 0.0D, 0.0D, 0.0D); - } - } - - private boolean scanAndRevertChanges() - { - int index = 0; - boolean reverted = false; - for (int x = -this.radius; x <= this.radius; x++) { - for (int y = -this.radius; y <= this.radius; y++) { - for (int z = -this.radius; z <= this.radius; z++) - { - Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z); - byte meta = (byte)this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z); - if (this.blockData[index] != blockID) { - if (revertBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z, blockID, meta, this.blockData[index], this.metaData[index])) - { - reverted = true; - } - else - { - this.blockData[index] = blockID; - this.metaData[index] = meta; - } - } - index++; - } - } - } - return reverted; - } - - private boolean revertBlock(int x, int y, int z, Block thereBlockID, byte thereMeta, Block replaceBlockID, byte replaceMeta) - { - /*if ((thereBlockID == Blocks.air) && (!replaceBlockID.getMaterial().blocksMovement())) - { - System.out.println("Not replacing block " + replaceBlockID + " because it doesn't block movement"); - - return false; - }*/ - if (isUnrevertable(thereBlockID, thereMeta, replaceBlockID, replaceMeta)) { - return false; - } - if (this.rand.nextInt(5) == 0) - { - if (replaceBlockID != Blocks.air) - { - //replaceBlockID = null; - replaceMeta = 4; - } - this.worldObj.setBlock(x, y, z, replaceBlockID, replaceMeta, 2); - if (thereBlockID == Blocks.air) - { - this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(replaceBlockID) + (replaceMeta << 12)); - } - else if (replaceBlockID == Blocks.air) - { - this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(thereBlockID) + (thereMeta << 12)); - thereBlockID.dropBlockAsItem(this.worldObj, x, y, z, thereMeta, 0); - } - } - return true; - } - - private boolean isUnrevertable(Block thereBlockID, byte thereMeta, Block replaceBlockID, byte replaceMeta) - { - if ((thereBlockID == ModBlocks.blockGriefSaver) || (replaceBlockID == ModBlocks.blockGriefSaver)) { - return true; - } - /*if (((thereBlockID == towerTranslucent) && (thereMeta != 4)) || ((replaceBlockID == towerTranslucent) && (replaceMeta != 4))) { - return true; - }*/ - if ((thereBlockID == Blocks.redstone_lamp) && (replaceBlockID == Blocks.lit_redstone_lamp)) { - return true; - } - if ((thereBlockID == Blocks.lit_redstone_lamp) && (replaceBlockID == Blocks.redstone_lamp)) { - return true; - } - /*if ((thereBlockID == Blocks.water) || (replaceBlockID == Blocks.flowing_water)) { - return true; - } - if ((thereBlockID == Blocks.flowing_water) || (replaceBlockID == Blocks.water)) { - return true; - }*/ - if (replaceBlockID == Blocks.tnt) { - return true; - } - return false; - } - - private void captureBlockData() - { - this.blockData = new Block[this.diameter * this.diameter * this.diameter]; - this.metaData = new byte[this.diameter * this.diameter * this.diameter]; - - int index = 0; - for (int x = -this.radius; x <= this.radius; x++) { - for (int y = -this.radius; y <= this.radius; y++) { - for (int z = -this.radius; z <= this.radius; z++) - { - Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z); - int meta = this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z); - - this.blockData[index] = blockID; - this.metaData[index] = ((byte)meta); - - index++; - } - } - } - } - - public boolean anyPlayerInRange() - { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, this.requiredPlayerRange) != null; - } -} diff --git a/src/Java/miscutil/core/tileentities/general/TileEntityReverter.java b/src/Java/miscutil/core/tileentities/general/TileEntityReverter.java new file mode 100644 index 0000000000..8793271985 --- /dev/null +++ b/src/Java/miscutil/core/tileentities/general/TileEntityReverter.java @@ -0,0 +1,309 @@ +package miscutil.core.tileentities.general; + +import java.util.Random; + +import miscutil.core.block.ModBlocks; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; + + + +public class TileEntityReverter extends TileEntity +{ + private static final int REVERT_CHANCE = 10; + public int radius = 16; + public int diameter = 8 * this.radius + 4; + public double requiredPlayerRange = 64.0D; + public Random rand = new Random(); + private int tickCount; + private boolean slowScan; + private int ticksSinceChange; + private Block[] blockData; + private byte[] metaData; + + public boolean canUpdate(){ + return true; + } + + public void updateEntity() + { + if (anyPlayerInRange()) + { + this.tickCount += 1; + if (this.worldObj.isRemote) + { + double var1 = this.xCoord + this.worldObj.rand.nextFloat(); + double var3 = this.yCoord + this.worldObj.rand.nextFloat(); + double var5 = this.zCoord + this.worldObj.rand.nextFloat(); + + this.worldObj.spawnParticle("enchantmenttable", var1, var3, var5, 0.0D, 0.0D, 0.0D); + if (this.rand.nextInt(5) == 0) + { + makeRandomOutline(); + makeRandomOutline(); + makeRandomOutline(); + } + } + else + { + if ((this.blockData == null) || (this.metaData == null)) + { + captureBlockData(); + this.slowScan = true; + } + if ((!this.slowScan) || (this.tickCount % 20 == 0)) { + if (scanAndRevertChanges()) + { + this.slowScan = false; + this.ticksSinceChange = 0; + } + else + { + this.ticksSinceChange += 1; + if (this.ticksSinceChange > 20) { + this.slowScan = true; + } + } + } + } + } + else + { + this.blockData = null; + this.metaData = null; + + this.tickCount = 0; + } + } + + private void makeRandomOutline() + { + makeOutline(this.rand.nextInt(12)); + } + + private void makeOutline(int outline) + { + double sx = this.xCoord; + double sy = this.yCoord; + double sz = this.zCoord; + + double dx = this.xCoord; + double dy = this.yCoord; + double dz = this.zCoord; + switch (outline) + { + case 0: + sx -= this.radius; + dx -= this.radius; + sz -= this.radius; + dz += this.radius + 1; + case 8: + sx -= this.radius; + dx += this.radius + 1; + sz -= this.radius; + dz -= this.radius; + break; + case 1: + case 9: + sx -= this.radius; + dx -= this.radius; + sz -= this.radius; + dz += this.radius + 1; + break; + case 2: + case 10: + sx -= this.radius; + dx += this.radius + 1; + sz += this.radius + 1; + dz += this.radius + 1; + break; + case 3: + case 11: + sx += this.radius + 1; + dx += this.radius + 1; + sz -= this.radius; + dz += this.radius + 1; + break; + case 4: + sx -= this.radius; + dx -= this.radius; + sz -= this.radius; + dz -= this.radius; + break; + case 5: + sx += this.radius + 1; + dx += this.radius + 1; + sz -= this.radius; + dz -= this.radius; + break; + case 6: + sx += this.radius + 1; + dx += this.radius + 1; + sz += this.radius + 1; + dz += this.radius + 1; + break; + case 7: + sx -= this.radius; + dx -= this.radius; + sz += this.radius + 1; + dz += this.radius + 1; + } + switch (outline) + { + case 0: + case 1: + case 2: + case 3: + sy += this.radius + 1; + dy += this.radius + 1; + break; + case 4: + case 5: + case 6: + case 7: + sy -= this.radius; + dy += this.radius + 1; + break; + case 8: + case 9: + case 10: + case 11: + sy -= this.radius; + dy -= this.radius; + } + if (this.rand.nextBoolean()) { + drawParticleLine(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, dx, dy, dz); + } else { + drawParticleLine(sx, sy, sz, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D); + } + drawParticleLine(sx, sy, sz, dx, dy, dz); + } + + protected void drawParticleLine(double srcX, double srcY, double srcZ, double destX, double destY, double destZ) + { + int particles = 16; + for (int i = 0; i < particles; i++) + { + double trailFactor = i / (particles - 1.0D); + + double tx = srcX + (destX - srcX) * trailFactor + this.rand.nextFloat() * 0.005D; + double ty = srcY + (destY - srcY) * trailFactor + this.rand.nextFloat() * 0.005D; + double tz = srcZ + (destZ - srcZ) * trailFactor + this.rand.nextFloat() * 0.005D; + this.worldObj.spawnParticle("portal", tx, ty, tz, 0.0D, 0.0D, 0.0D); + } + } + + private boolean scanAndRevertChanges() + { + int index = 0; + boolean reverted = false; + for (int x = -this.radius; x <= this.radius; x++) { + for (int y = -this.radius; y <= this.radius; y++) { + for (int z = -this.radius; z <= this.radius; z++) + { + Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z); + byte meta = (byte)this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z); + if (this.blockData[index] != blockID) { + if (revertBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z, blockID, meta, this.blockData[index], this.metaData[index])) + { + reverted = true; + } + else + { + this.blockData[index] = blockID; + this.metaData[index] = meta; + } + } + index++; + } + } + } + return reverted; + } + + private boolean revertBlock(int x, int y, int z, Block thereBlockID, byte thereMeta, Block replaceBlockID, byte replaceMeta) + { + /*if ((thereBlockID == Blocks.air) && (!replaceBlockID.getMaterial().blocksMovement())) + { + System.out.println("Not replacing block " + replaceBlockID + " because it doesn't block movement"); + + return false; + }*/ + if (isUnrevertable(thereBlockID, thereMeta, replaceBlockID, replaceMeta)) { + return false; + } + if (this.rand.nextInt(5) == 0) + { + if (replaceBlockID != Blocks.air) + { + //replaceBlockID = null; + replaceMeta = 4; + } + this.worldObj.setBlock(x, y, z, replaceBlockID, replaceMeta, 2); + if (thereBlockID == Blocks.air) + { + this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(replaceBlockID) + (replaceMeta << 12)); + } + else if (replaceBlockID == Blocks.air) + { + this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(thereBlockID) + (thereMeta << 12)); + thereBlockID.dropBlockAsItem(this.worldObj, x, y, z, thereMeta, 0); + } + } + return true; + } + + private boolean isUnrevertable(Block thereBlockID, byte thereMeta, Block replaceBlockID, byte replaceMeta) + { + if ((thereBlockID == ModBlocks.blockGriefSaver) || (replaceBlockID == ModBlocks.blockGriefSaver)) { + return true; + } + /*if (((thereBlockID == towerTranslucent) && (thereMeta != 4)) || ((replaceBlockID == towerTranslucent) && (replaceMeta != 4))) { + return true; + }*/ + if ((thereBlockID == Blocks.redstone_lamp) && (replaceBlockID == Blocks.lit_redstone_lamp)) { + return true; + } + if ((thereBlockID == Blocks.lit_redstone_lamp) && (replaceBlockID == Blocks.redstone_lamp)) { + return true; + } + /*if ((thereBlockID == Blocks.water) || (replaceBlockID == Blocks.flowing_water)) { + return true; + } + if ((thereBlockID == Blocks.flowing_water) || (replaceBlockID == Blocks.water)) { + return true; + }*/ + if (replaceBlockID == Blocks.tnt) { + return true; + } + return false; + } + + private void captureBlockData() + { + this.blockData = new Block[this.diameter * this.diameter * this.diameter]; + this.metaData = new byte[this.diameter * this.diameter * this.diameter]; + + int index = 0; + for (int x = -this.radius; x <= this.radius; x++) { + for (int y = -this.radius; y <= this.radius; y++) { + for (int z = -this.radius; z <= this.radius; z++) + { + Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z); + int meta = this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z); + + this.blockData[index] = blockID; + this.metaData[index] = ((byte)meta); + + index++; + } + } + } + } + + public boolean anyPlayerInRange() + { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, this.requiredPlayerRange) != null; + } +} diff --git a/src/Java/miscutil/core/tileentities/machines/TileEntityCharger.java b/src/Java/miscutil/core/tileentities/machines/TileEntityCharger.java new file mode 100644 index 0000000000..6d78cb829e --- /dev/null +++ b/src/Java/miscutil/core/tileentities/machines/TileEntityCharger.java @@ -0,0 +1,186 @@ +package miscutil.core.tileentities.machines; + +import miscutil.core.item.base.BaseItemWithCharge; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.Constants; + +public class TileEntityCharger extends TileEntity implements IInventory +{ + private ItemStack[] items = new ItemStack[1]; //18 + private int progress_Current = 1; + private int progress_Max = 1000; + public float charge_Current; + public float charge_Max = 10000; + private float tempItemChargeValue; + + public float getCharge(){ + return charge_Current; + } + + public int getProgress(){ + return progress_Current; + } + + @Override + public int getSizeInventory() + { + return items.length; + } + + @Override + public ItemStack getStackInSlot(int slot) + { + return items[slot]; + } + + @Override + public ItemStack decrStackSize(int slot, int amount) + { + if (items[slot] != null) + { + ItemStack itemstack; + + if (items[slot].stackSize == amount) + { + itemstack = items[slot]; + items[slot] = null; + markDirty(); + return itemstack; + } + itemstack = items[slot].splitStack(amount); + if (items[slot].stackSize == 0) items[slot] = null; + markDirty(); + return itemstack; + } + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + if (items[slot] != null) + { + ItemStack itemstack = items[slot]; + items[slot] = null; + return itemstack; + } + return null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) + { + if (stack != null){ + items[slot] = stack; + if (stack != null && stack.stackSize > getInventoryStackLimit()) + { + stack.stackSize = getInventoryStackLimit(); + } + + + markDirty(); + } + } + + @Override + public String getInventoryName() + { + return "container.Charger"; + } + + @Override + public boolean hasCustomInventoryName() + { + return false; + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + NBTTagList list = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND); + items = new ItemStack[getSizeInventory()]; + + for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound comp = list.getCompoundTagAt(i); int j = comp.getByte("Slot") & 255; if (j >= 0 && j < items.length) + { + items[j] = ItemStack.loadItemStackFromNBT(comp); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + NBTTagList list = new NBTTagList(); + + for (int i = 0; i < items.length; ++i) + { + if (items[i] != null) + { + NBTTagCompound comp = new NBTTagCompound(); + comp.setByte("Slot", (byte)i); + items[i].writeToNBT(comp); + list.appendTag(comp); + } + } + + nbt.setTag("Items", list); + } + + @Override + public int getInventoryStackLimit() + { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) + { + return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) + { + return true; + } + + @Override + public void updateEntity() { + if(!this.worldObj.isRemote){ + if (progress_Current < progress_Max){ + progress_Current++; + } + else if (progress_Current >= progress_Max){ + if (charge_Current < charge_Max){ + charge_Current = charge_Current+500; + } + if (getStackInSlot(0).getItem() instanceof BaseItemWithCharge){ + float tempCharge; + ItemStack output = getStackInSlot(0).copy(); + if (output.stackTagCompound != null){ + tempCharge = output.stackTagCompound.getFloat("charge_Current"); + output.stackTagCompound = new NBTTagCompound(); + output.stackTagCompound.setFloat("charge_Current", tempCharge+40); + this.charge_Current = charge_Current-40; + tempCharge = 0; + } + } + progress_Current = 0; + } + } + } + +} \ No newline at end of file diff --git a/src/Java/miscutil/core/tileentities/machines/TileEntityNHG.java b/src/Java/miscutil/core/tileentities/machines/TileEntityNHG.java new file mode 100644 index 0000000000..3581592c02 --- /dev/null +++ b/src/Java/miscutil/core/tileentities/machines/TileEntityNHG.java @@ -0,0 +1,501 @@ +package miscutil.core.tileentities.machines; + +import miscutil.core.item.ModItems; +import miscutil.core.item.general.fuelrods.FuelRod_Base; +import miscutil.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.Constants; + +public class TileEntityNHG extends TileEntity implements IInventory +{ + private ItemStack[] items = new ItemStack[19]; //18 + private int progress = 1; + private int maxProgress = 180; + private int heatCycleProgress = 12; + public float coreTemp; + public float maxTemp = 10000; + private boolean fuelrod_1 = false; + private boolean fuelrod_2 = false; + private boolean fuelrod_3 = false; + private boolean fuelrod_4 = false; + private boolean fuelrod_5 = false; + private boolean fuelrod_6 = false; + private boolean fuelrod_7 = false; + private boolean fuelrod_8 = false; + private boolean fuelrod_9 = false; + private boolean fuelrod_10 = false; + private boolean fuelrod_11 = false; + private boolean fuelrod_12 = false; + private boolean fuelrod_13 = false; + private boolean fuelrod_14 = false; + private boolean fuelrod_15 = false; + private boolean fuelrod_16 = false; + private boolean fuelrod_17 = false; + private boolean fuelrod_18 = false; + + public float getCoreTemp(){ + return coreTemp; + } + + public int getProgress(){ + return progress; + } + + public boolean isValidFuelRod(ItemStack input){ + if(!this.worldObj.isRemote){ + if (input != null){ + if (input.getItem() instanceof FuelRod_Base){ + int fuelRodFuelLevel = getRodFuelValue(input); + float fuelRodHeatLevel = getRodHeatValue(input); + Utils.LOG_WARNING("Fuel Left: "+fuelRodFuelLevel+" Current Temp: "+fuelRodHeatLevel); + return true; + //return input.stackTagCompound.getInteger("code"); + } + } + + } + return false; + } + + public ItemStack doFuelRodHeatDamage(ItemStack input){ + if(!this.worldObj.isRemote){ + if (input != null){ + if (isValidFuelRod(input)){ + int fuelRodFuelLevel = getRodFuelValue(input); + float fuelRodHeatLevel = getRodHeatValue(input); + if(fuelRodFuelLevel <= 0 || fuelRodFuelLevel == 0){ + return null; + } + if(fuelRodHeatLevel == 0 && fuelRodFuelLevel > 0){ + if(fuelRodFuelLevel >= 5){ + int tempInt=fuelRodFuelLevel; + float tempFloat=fuelRodHeatLevel; + ItemStack output = input.copy(); + if (input.stackTagCompound != null){ + output.stackTagCompound = new NBTTagCompound(); + output.stackTagCompound.setInteger("fuelRemaining", tempInt-40); + output.stackTagCompound.setFloat("heat", tempFloat+20); + } + return output; + } + return null; + } + else if(fuelRodHeatLevel >= 5 && fuelRodFuelLevel > 0){ + int tempInt=fuelRodFuelLevel; + float tempFloat=fuelRodHeatLevel; + ItemStack output = input.copy(); + if (input.stackTagCompound != null){ + output.stackTagCompound = new NBTTagCompound(); + output.stackTagCompound.setInteger("fuelRemaining", tempInt-5); + output.stackTagCompound.setFloat("heat", tempFloat+5); + } + return output; + } + + else if(fuelRodHeatLevel >= 5 && fuelRodFuelLevel == 0){ + ItemStack output = input.copy(); + if (input.stackTagCompound != null){ + output.stackTagCompound = new NBTTagCompound(); + output.stackTagCompound.setInteger("heat", -5); + } + return output; + } + else { + return null; + } + } + } + } + return null; + } + + public float getRodHeatValue(ItemStack value){ + if (value != null){ + if (value.stackTagCompound != null){ + return value.stackTagCompound.getFloat("heat"); + } + } + return 0f; + } + + public int getRodFuelValue(ItemStack value){ + if (value != null){ + if (value.stackTagCompound != null){ + int tempInt = value.stackTagCompound.getInteger("fuelRemaining"); + return tempInt; + } + } + return 0; + } + + public void checkFuelRods(){ + + if(!this.worldObj.isRemote){ + for (int i = 0; i < getSizeInventory(); i++){ + if (items[i] != null){ + if (items[i].getItem() instanceof FuelRod_Base){ + ItemStack fuelRodStack = getStackInSlot(i).copy(); + //setInventorySlotContents(i, doFuelRodHeatDamage(fuelRodStack)); + if (i == 0){ + fuelrod_1 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 1){ + fuelrod_2 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 2){ + fuelrod_3 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 3){ + fuelrod_4 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 4){ + fuelrod_5 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 5){ + fuelrod_6 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 6){ + fuelrod_7 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 7){ + fuelrod_8 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 8){ + fuelrod_9 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 9){ + fuelrod_10 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 10){ + fuelrod_11 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 11){ + fuelrod_12 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 12){ + fuelrod_13 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 13){ + fuelrod_14 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 14){ + fuelrod_15 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 15){ + fuelrod_16 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 16){ + fuelrod_17 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + else if (i == 17){ + fuelrod_18 = true; + ItemStack r = doFuelRodHeatDamage(fuelRodStack); + setInventorySlotContents(i, r); + } + + + } + } + } + Utils.LOG_WARNING("|"+fuelrod_1+"|"+fuelrod_2+"|"+fuelrod_3+"| "+"|"+fuelrod_10+"|"+fuelrod_11+"|"+fuelrod_12+"|"); + Utils.LOG_WARNING("|"+fuelrod_4+"|"+fuelrod_5+"|"+fuelrod_6+"| "+"|"+fuelrod_13+"|"+fuelrod_14+"|"+fuelrod_15+"|"); + Utils.LOG_WARNING("|"+fuelrod_7+"|"+fuelrod_8+"|"+fuelrod_9+"| "+"|"+fuelrod_16+"|"+fuelrod_17+"|"+fuelrod_18+"|"); + } + + } + + public boolean calculateHeat(){ + /*if (!fuelrod_1 || !fuelrod_2 || !fuelrod_3 || !fuelrod_4 || !fuelrod_5 || !fuelrod_6 || !fuelrod_7 || !fuelrod_8 || !fuelrod_9 || !fuelrod_10 || !fuelrod_11 || !fuelrod_12 || !fuelrod_13 || !fuelrod_14 || !fuelrod_15 || !fuelrod_16 || !fuelrod_17 || !fuelrod_18){ + coreTemp = 0; + } + else {*/ + if(!this.worldObj.isRemote){ + for (int i = 0; i < getSizeInventory(); i++){ + if (items[i] != null){ + if (items[i].getItem() instanceof FuelRod_Base){ + ItemStack fuelRodStack = getStackInSlot(i).copy(); + //if (fuelRodStack.stackTagCompound.getFloat("heat") != 0){ + doFuelRodHeatDamage(fuelRodStack); + coreTemp = coreTemp+fuelRodStack.stackTagCompound.getFloat("heat"); + return true; + //} + } + } + } + } + //} + + + + return false; + } + + @Override + public int getSizeInventory() + { + return items.length; + } + + @Override + public ItemStack getStackInSlot(int slot) + { + + return items[slot]; + + } + + @Override + public ItemStack decrStackSize(int slot, int amount) + { + if (items[slot] != null) + { + ItemStack itemstack; + + if (items[slot].stackSize == amount) + { + itemstack = items[slot]; + items[slot] = null; + markDirty(); + return itemstack; + } + itemstack = items[slot].splitStack(amount); + if (items[slot].stackSize == 0) items[slot] = null; + markDirty(); + return itemstack; + } + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + if (items[slot] != null) + { + ItemStack itemstack = items[slot]; + items[slot] = null; + return itemstack; + } + return null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) + { + if (stack != null){ + items[slot] = stack; + if (stack != null && stack.stackSize > getInventoryStackLimit()) + { + stack.stackSize = getInventoryStackLimit(); + } + + + markDirty(); + } + } + + @Override + public String getInventoryName() + { + return "container.NHG"; + } + + @Override + public boolean hasCustomInventoryName() + { + return false; + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + NBTTagList list = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND); + items = new ItemStack[getSizeInventory()]; + + for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound comp = list.getCompoundTagAt(i); int j = comp.getByte("Slot") & 255; if (j >= 0 && j < items.length) + { + items[j] = ItemStack.loadItemStackFromNBT(comp); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + NBTTagList list = new NBTTagList(); + + for (int i = 0; i < items.length; ++i) + { + if (items[i] != null) + { + NBTTagCompound comp = new NBTTagCompound(); + comp.setByte("Slot", (byte)i); + items[i].writeToNBT(comp); + list.appendTag(comp); + } + } + + nbt.setTag("Items", list); + } + + @Override + public int getInventoryStackLimit() + { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) + { + return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) + { + return true; + } + + //Machine Code - TODO + private ItemStack neutrons; + + @Override + public void updateEntity() { + + if(!this.worldObj.isRemote){ + + if(progress >= heatCycleProgress){ + //Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity "+this.getBlockType().getUnlocalizedName(), 376); + if (Utils.divideXintoY(heatCycleProgress, maxProgress)){ + Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity "+this.getBlockType().getUnlocalizedName(), 378); + calculateHeat(); + heatCycleProgress=0; + } + } + + if(++progress >= maxProgress){ + + + Utils.LOG_SPECIFIC_WARNING("NFHG", "Updating Entity "+this.getBlockType().getUnlocalizedName(), 338); + if (items[18] != null){ + ItemStack checkOutput = getStackInSlot(18); + if(neutrons == null){ + neutrons = new ItemStack(ModItems.itemHeliumBlob, 1); + if (checkOutput == null){ + Utils.LOG_WARNING("ItemStack in Output slot is definitely null, making a new ItemStack."); + setInventorySlotContents(18, neutrons); + progress = 0; + markDirty(); + } + else { + checkOutput.stackSize++; + Utils.LOG_WARNING("Found an ItemStack to increase the size of. Current size is "+neutrons.stackSize); + + progress = 0; + markDirty(); + } + } + else if(checkOutput.getItem() == ModItems.itemHeliumBlob && checkOutput.stackSize < 64){ + checkOutput.stackSize++; + Utils.LOG_WARNING("Found an ItemStack to increase size of. Current size is "+checkOutput.stackSize); + progress = 0; + markDirty(); + } + else if(checkOutput.getItem() == ModItems.itemHeliumBlob && checkOutput.stackSize == 64){ + Utils.LOG_WARNING("Output stack is full."); + progress = 0; + markDirty(); + } + } + else if (items[18] == null){ + Utils.LOG_WARNING("ItemStack in Output slot is null"); + neutrons = new ItemStack(ModItems.itemHeliumBlob, 1); + ItemStack checkOutput = getStackInSlot(18); + if (checkOutput == null){ + Utils.LOG_WARNING("ItemStack in Output slot is definitely null, making a new ItemStack."); + setInventorySlotContents(18, neutrons); + progress = 0; + markDirty(); + } + else { + Utils.LOG_WARNING("Found an ItemStack to increase the size of."); + checkOutput.stackSize++; + progress = 0; + markDirty(); + } + } + checkFuelRods(); + } + progress++; + } + } + + public void readCustomNBT(NBTTagCompound tag) + { + this.neutrons = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Neutrons")); + this.progress = tag.getInteger("Progress"); + this.coreTemp = tag.getFloat("coreTemp"); + } + + public void writeCustomNBT(NBTTagCompound tag) + { + tag.setInteger("Progress", this.progress); + tag.setFloat("coreTemp", this.coreTemp); + if(neutrons != null) { + NBTTagCompound produce = new NBTTagCompound(); + neutrons.writeToNBT(produce); + tag.setTag("Neutrons", produce); + } + else + tag.removeTag("Neutrons"); + } + + + +} \ No newline at end of file -- cgit