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 ++++++++++++++++ .../gregtech/api/enums/GregtechItemList.java | 17 +- .../interfaces/internal/IGregtech_RecipeAdder.java | 2 + .../internal/Interface_ItemBehaviour.java | 41 ++ .../gregtech/api/items/Gregtech_Generic_Item.java | 176 ++++++ .../gregtech/api/items/Gregtech_MetaItem.java | 323 ++++++++++ .../gregtech/api/items/Gregtech_MetaItem_Base.java | 634 ++++++++++++++++++++ .../gregtech/api/items/Gregtech_MetaItem_X32.java | 194 ++++++ .../base/GregtechRocketFuelGeneratorBase.java | 263 +++++++++ .../miscutil/gregtech/api/util/GregtechRecipe.java | 93 ++- .../gregtech/common/GregtechRecipeAdder.java | 74 +-- .../common/blocks/GregtechMetaCasingBlocks.java | 2 +- .../common/items/MetaGeneratedGregtechItems.java | 125 ++++ ...GregtechMetaTileEntityIndustrialCentrifuge.java | 391 ------------- .../GregtechMetaTileEntityIndustrialCokeOven.java | 268 --------- ...GregtechMetaTileEntityIndustrialPlatePress.java | 249 -------- .../GregtechMetaTileEntityIronBlastFurnace.java | 369 ------------ .../GregtechMetaTileEntityRocketFuelGenerator.java | 119 ++++ ...GregtechMetaTileEntityIndustrialCentrifuge.java | 391 +++++++++++++ .../GregtechMetaTileEntityIndustrialCokeOven.java | 268 +++++++++ ...GregtechMetaTileEntityIndustrialPlatePress.java | 249 ++++++++ .../GregtechMetaTileEntityIronBlastFurnace.java | 369 ++++++++++++ 73 files changed, 6308 insertions(+), 3667 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 create mode 100644 src/Java/miscutil/gregtech/api/interfaces/internal/Interface_ItemBehaviour.java create mode 100644 src/Java/miscutil/gregtech/api/items/Gregtech_Generic_Item.java create mode 100644 src/Java/miscutil/gregtech/api/items/Gregtech_MetaItem.java create mode 100644 src/Java/miscutil/gregtech/api/items/Gregtech_MetaItem_Base.java create mode 100644 src/Java/miscutil/gregtech/api/items/Gregtech_MetaItem_X32.java create mode 100644 src/Java/miscutil/gregtech/api/metatileentity/implementations/base/GregtechRocketFuelGeneratorBase.java create mode 100644 src/Java/miscutil/gregtech/common/items/MetaGeneratedGregtechItems.java delete mode 100644 src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java delete mode 100644 src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java delete mode 100644 src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java delete mode 100644 src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java create mode 100644 src/Java/miscutil/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java create mode 100644 src/Java/miscutil/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java create mode 100644 src/Java/miscutil/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java create mode 100644 src/Java/miscutil/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java create mode 100644 src/Java/miscutil/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java (limited to 'src/Java/miscutil') 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[]