diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
commit | 221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch) | |
tree | d6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/core | |
parent | 5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff) | |
download | GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2 GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip |
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/core')
151 files changed, 17530 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java new file mode 100644 index 0000000000..ceb8880299 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -0,0 +1,78 @@ +package gtPlusPlus.core.block; + +import gtPlusPlus.core.block.general.LightGlass; +import gtPlusPlus.core.block.general.fluids.FluidRegistryHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraftforge.fluids.Fluid; +import cpw.mods.fml.common.registry.GameRegistry; + +public final class ModBlocks { + + //Blocks + //public static Block blockBloodSteel; + //public static Block blockStaballoy; + // WIP TODO public static Block blockToolBuilder; + public static Block blockGriefSaver; + public static Block blockCasingsMisc; + public static Block blockHeliumGenerator; + public static Block blockNHG; + public static Block blockCharger; + + public static Block MatterFabricatorEffectBlock; + + public static Fluid fluidJackDaniels = new Fluid("fluidJackDaniels"); + public static Block blockFluidJackDaniels; + public static Block blockGtFrameStaballoy; + public static Block blockGtFrameTantalloy60; + public static Block blockGtFrameTantalloy61; + + + + public static void init() { + Utils.LOG_INFO("Initializing Blocks."); + //blockGriefSaver = new TowerDevice().setBlockName("blockGriefSaver").setCreativeTab(AddToCreativeTab.tabBlock).setBlockTextureName("blockDefault"); + + registerBlocks(); + } + + public static void registerBlocks(){ + + Utils.LOG_INFO("Registering Blocks."); + + //Blood Steel Block + //GameRegistry.registerBlock(blockBloodSteel = new BasicBlock("blockBloodSteel", Material.iron), "blockBloodSteel"); + + //Staballoy Block + //GameRegistry.registerBlock(blockStaballoy = new BasicBlock("blockStaballoy", Material.iron), "blockStaballoy"); + + //GameRegistry.registerBlock(MatterFabricatorEffectBlock = new MatterFabricatorEffectBlock(), "blockMF_Effect"); + + GameRegistry.registerBlock(MatterFabricatorEffectBlock = new LightGlass(Material.glass, false).setHardness(0.1F).setBlockTextureName(CORE.MODID + ":" + "blockMFEffect").setStepSound(Block.soundTypeGlass), "blockMFEffect"); + + + //Casing Blocks + blockCasingsMisc = new GregtechMetaCasingBlocks(); + + //Fluids + FluidRegistryHandler.registerFluids(); + + // blockHeliumGenerator = GameRegistry.registerBlock(new HeliumGenerator(), "Helium_Collector"); + // blockNHG = GameRegistry.registerBlock(new Machine_NHG("blockNuclearFueledHeliumGenerator"), "blockNuclearFueledHeliumGenerator"); + // blockCharger = GameRegistry.registerBlock(new Machine_Charger("blockMachineCharger"), "blockMachineCharger"); + + + //WIP TODO + //GameRegistry.registerBlock(blockGriefSaver, "blockGriefSaver"); + + //GtFrames + //GameRegistry.registerBlock(blockGtFrameSet1 = new BlockGtFrameBox("blockGtFrameSet1", Material.iron ,BlockTypes.FRAME, true, Utils.rgbtoHexValue(68, 75, 66), Utils.rgbtoHexValue(68, 75, 166), Utils.rgbtoHexValue(122, 135, 196)), "blockGtFrameSet1"); + //GameRegistry.registerBlock(blockGtFrameTantalloy60 = new BlockBaseModular("blockGtFrameStaballoy", "Staballoy", BlockTypes.FRAME, Utils.rgbtoHexValue(68, 75, 66)), ItemBlockGtFrameBox.class, "blockGtFrameStaballoy"); + //GameRegistry.registerBlock(blockGtFrameTantalloy60 = new BlockBaseModular("blockGtFrameTantalloy60", "Tantalloy-60", BlockTypes.FRAME, Utils.rgbtoHexValue(68, 75, 166)), ItemBlockGtFrameBox.class, "blockGtFrameTantalloy60"); + //GameRegistry.registerBlock(blockGtFrameTantalloy61 = new BlockBaseModular("blockGtFrameTantalloy61", "Tantalloy-61", BlockTypes.FRAME, Utils.rgbtoHexValue(122, 135, 196)), ItemBlockGtFrameBox.class, "blockGtFrameTantalloy61"); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java new file mode 100644 index 0000000000..b7ac24a71b --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java @@ -0,0 +1,31 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class AdvancedBlock extends Block { + + protected AdvancedBlock(String unlocalizedName, Material material, CreativeTabs x, float blockHardness, float blockResistance, float blockLightLevel, + String blockHarvestTool, int blockHarvestLevel, SoundType BlockSound) { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(x); + this.setHardness(blockHardness); //block Hardness + this.setResistance(blockResistance); + this.setLightLevel(blockLightLevel); + this.setHarvestLevel(blockHarvestTool, blockHarvestLevel); + this.setStepSound(BlockSound); + } + + @Override + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + return false; + } + +} diff --git a/src/Java/gtPlusPlus/core/block/base/BasicBlock.java b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java new file mode 100644 index 0000000000..cd879167ba --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java @@ -0,0 +1,52 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; + +public class BasicBlock extends Block { + + public BasicBlock(String unlocalizedName, Material material) { + super(material); + this.setBlockName(Utils.sanitizeString(unlocalizedName)); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(2.0F); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHarvestLevel("pickaxe", 2); + this.setStepSound(soundTypeMetal); + } + + + public static enum BlockTypes { + STANDARD("blockBlock", "pickaxe", soundTypeStone), + FRAME("blockFrameGt", "wrench", soundTypeMetal); + + private String TEXTURE_NAME; + private String HARVEST_TOOL; + private SoundType soundOfBlock; + private BlockTypes (String textureName, String harvestTool, SoundType blockSound) + { + this.TEXTURE_NAME = textureName; + this.HARVEST_TOOL = harvestTool; + this.soundOfBlock = blockSound; + } + + public String getTexture() { + return TEXTURE_NAME; + } + + public String getHarvestTool(){ + return HARVEST_TOOL; + } + + public SoundType getBlockSoundType(){ + return soundOfBlock; + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java new file mode 100644 index 0000000000..9654caac00 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -0,0 +1,154 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.item.base.itemblock.ItemBlockGtBlock; +import gtPlusPlus.core.item.base.itemblock.ItemBlockGtFrameBox; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockBaseModular extends BasicBlock{ + + protected int blockColour; + protected BlockTypes thisBlock; + protected String thisBlockMaterial; + protected final String thisBlockType; + + public BlockBaseModular(String unlocalizedName, String blockMaterial, BlockTypes blockType, int colour) { + super(blockType.getTexture()+unlocalizedName, Material.iron); + this.setHarvestLevel(blockType.getHarvestTool(), 2); + this.setBlockTextureName(CORE.MODID+":"+blockType.getTexture()); + this.blockColour = colour; + this.thisBlock = blockType; + this.thisBlockMaterial = blockMaterial; + this.thisBlockType = blockType.name().toUpperCase(); + this.setBlockName(GetProperName()); + + if (!CORE.DEBUG){ + //Utils.LOG_INFO("=============Block Info Dump============="); + //Utils.LOG_INFO("thisBlock.name().toLowerCase() - "+thisBlock.name().toLowerCase()); + //Utils.LOG_INFO("This Blocks Type - "+thisBlockType); + //Utils.LOG_INFO("BlockTypes.STANDARD.name().toLowerCase() - "+BlockTypes.STANDARD.name().toLowerCase()); + //Utils.LOG_INFO("BlockTypes.FRAME.name().toLowerCase() - "+BlockTypes.FRAME.name().toLowerCase()); + //Utils.LOG_INFO("blockMaterial - "+blockMaterial); + //Utils.LOG_INFO("=========================================="); + } + + if (thisBlockType == BlockTypes.STANDARD.name().toUpperCase()){ + LanguageRegistry.addName(this, "Block of "+blockMaterial); + //Utils.LOG_INFO("Registered Block in Language Registry as: "+"Block of "+blockMaterial); + } + else if (thisBlockType == BlockTypes.FRAME.name().toUpperCase()){ + LanguageRegistry.addName(this, blockMaterial+ " Frame Box"); + //Utils.LOG_INFO("Registered Block in Language Registry as: "+blockMaterial+ " Frame Box"); + } + else { + LanguageRegistry.addName(this, blockMaterial); + //Utils.LOG_INFO("Registered Block in Language Registry as: "+blockMaterial); + } + + //setOreDict(unlocalizedName, blockType); + if (thisBlockType == BlockTypes.STANDARD.name().toUpperCase()){ + GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); + //Utils.LOG_INFO("Registered Block in Block Registry as: "+"Block of "+blockMaterial); + } + else if (thisBlockType == BlockTypes.FRAME.name().toUpperCase()){ + GameRegistry.registerBlock(this, ItemBlockGtFrameBox.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); + //Utils.LOG_INFO("Registered Block in Block Registry as: "+blockMaterial+" Frame Box"); + } + else { + GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); + //Utils.LOG_INFO("Registered Block in Block Registry as: "+blockMaterial); + } + + + } + + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + if (thisBlock == BlockTypes.FRAME){ + return 1; + } + return 0; + } + + /*@Override + public String getLocalizedName() { + String tempIngot; + if (thisBlock == BlockTypes.STANDARD){ + tempIngot = "Block of "+thisBlockMaterial; + } + else if (thisBlock == BlockTypes.FRAME){ + tempIngot = thisBlockMaterial + " Frame Box"; + } + else { + + tempIngot = getUnlocalizedName().replace("tile.blockGt", "ingot"); + } + return tempIngot; + }*/ + + public String GetProperName() { + String tempIngot; + if (thisBlock == BlockTypes.STANDARD){ + tempIngot = "Block of "+thisBlockMaterial; + } + else if (thisBlock == BlockTypes.FRAME){ + tempIngot = thisBlockMaterial + " Frame Box"; + } + else { + + tempIngot = getUnlocalizedName().replace("tile.blockGt", "ingot"); + } + return tempIngot; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iIcon) + { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + thisBlock.getTexture()); + } + + @Override + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4){ + + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + + @Override + public int getRenderColor(int aMeta) { + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + + @Override + public int getBlockColor() { + return this.blockColour; + } + +} diff --git a/src/Java/gtPlusPlus/core/block/base/MetaBlock.java b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java new file mode 100644 index 0000000000..4009c36726 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.block.base; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class MetaBlock extends MultiTextureBlock { + + protected MetaBlock(String unlocalizedName, Material material, SoundType soundType) { + super(unlocalizedName, material, soundType); + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 6; i ++) { + list.add(new ItemStack(item, 1, i)); + } + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java b/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java new file mode 100644 index 0000000000..4f022bae6d --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java @@ -0,0 +1,36 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +public class MultiTextureBlock extends Block { + + public IIcon[] icons = new IIcon[6]; + + protected MultiTextureBlock(String unlocalizedName, Material material, SoundType blockSound) + { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(2.0F); + this.setResistance(6.0F); + this.setStepSound(blockSound); + } + + @Override + public void registerBlockIcons(IIconRegister reg) { + for (int i = 0; i < 6; i ++) { + this.icons[i] = reg.registerIcon(this.textureName + "_" + i); + } + } + + @Override + public IIcon getIcon(int side, int meta) { + return this.icons[side]; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/general/LightGlass.java b/src/Java/gtPlusPlus/core/block/general/LightGlass.java new file mode 100644 index 0000000000..5aa9f5b818 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/LightGlass.java @@ -0,0 +1,128 @@ +package gtPlusPlus.core.block.general; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; + +import java.util.Random; + +import net.minecraft.block.BlockBreakable; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class LightGlass extends BlockBreakable +{ + private int state = 0; + private int a = 255; + private int r = 255; + private int g = 0; + private int b = 0; + private int hex; + + public LightGlass(Material mat, boolean bool) + { + super("blockMFEffect", mat, bool); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setBlockName("blockMFEffect"); + this.setLightLevel(12F); + this.setLightOpacity(0); + this.setTickRandomly(true); + this.setResistance(1); + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random rand) + { + return 0; + } + + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return 0; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() + { + return true; + } + + /** + * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops. + */ + @Override + protected boolean canSilkHarvest() + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iIcon) + { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockMFEffect"); + } + + @Override + //http://stackoverflow.com/questions/31784658/how-can-i-loop-through-all-rgb-combinations-in-rainbow-order-in-java + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) + { + if(state == 0){ + g++; + if(g == 255) + state = 1; + } + if(state == 1){ + r--; + if(r == 0) + state = 2; + } + if(state == 2){ + b++; + if(b == 255) + state = 3; + } + if(state == 3){ + g--; + if(g == 0) + state = 4; + } + if(state == 4){ + r++; + if(r == 255) + state = 5; + } + if(state == 5){ + b--; + if(b == 0) + state = 0; + } + hex = (a << 24) + (r << 16) + (g << 8) + (b); + return hex; + } + + /** + * A randomly called display update to be able to add particles or other items for display + */ + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int posX, int posY, int posZ, Random random){ + Utils.spawnFX(world, posX, posY, posZ, "smoke", "cloud"); + + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java b/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java new file mode 100644 index 0000000000..7fa890b6c8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java @@ -0,0 +1,276 @@ +package gtPlusPlus.core.block.general.antigrief; + +import static gtPlusPlus.core.block.ModBlocks.blockGriefSaver; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityReverter; +import gtPlusPlus.core.util.Utils; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class TowerDevice extends Block { + private static IIcon TEX_ANTIBUILDER; + public static final int META_ANTIBUILDER = 9; + private boolean bUnbreakable; + + public TowerDevice() + { + super(Material.wood); + setHardness(10.0F); + setResistance(35.0F); + setStepSound(Block.soundTypeWood); + setCreativeTab(AddToCreativeTab.tabMachines); + } + + public int tickRate() + { + return 15; + } + + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("bUnbreakable", bUnbreakable); + } + + public void loadNBTData(NBTTagCompound aNBT) { + bUnbreakable = aNBT.getBoolean("bUnbreakable"); + } + + public IIcon getIcon(int side, int meta) + { + return TEX_ANTIBUILDER; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + TEX_ANTIBUILDER = par1IconRegister.registerIcon(CORE.MODID + ":" + "blockAntiGrief"); + } + + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) + { + par3List.add(new ItemStack(par1, 1, 9)); + } + + public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) + { + int meta = par1World.getBlockMetadata(x, y, z); + return false; + } + + public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) + { + int meta = world.getBlockMetadata(x, y, z); + return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ); + } + + public float getBlockHardness(World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + return super.getBlockHardness(world, x, y, z); + } + + public static boolean areNearbyLockBlocks(World world, int x, int y, int z) + { + boolean locked = false; + for (int dx = x - 2; dx <= x + 2; dx++) { + for (int dy = y - 2; dy <= y + 2; dy++) { + for (int dz = z - 2; dz <= z + 2; dz++) { + if ((world.getBlock(dx, dy, dz) == blockGriefSaver) && (world.getBlockMetadata(dx, dy, dz) == 4)) { + locked = true; + } + } + } + } + return locked; + } + + public static void unlockBlock(World par1World, int x, int y, int z) + { + Block thereBlockID = par1World.getBlock(x, y, z); + int thereBlockMeta = par1World.getBlockMetadata(x, y, z); + if ((thereBlockID == blockGriefSaver) || (thereBlockMeta == 4)) + { + changeToBlockMeta(par1World, x, y, z, 5); + par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.click", 0.3F, 0.6F); + } + } + + private static void changeToBlockMeta(World par1World, int x, int y, int z, int meta) + { + Block thereBlockID = par1World.getBlock(x, y, z); + if ((thereBlockID == blockGriefSaver)) + { + par1World.setBlock(x, y, z, thereBlockID, meta, 3); + par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z); + par1World.notifyBlocksOfNeighborChange(x, y, z, thereBlockID); + } + } + + public void onBlockAdded(World par1World, int x, int y, int z) + { + int meta = par1World.getBlockMetadata(x, y, z); + if (!par1World.isRemote) { + + } + } + + public void onNeighborBlockChange(World par1World, int x, int y, int z, Block myBlockID) + { + int meta = par1World.getBlockMetadata(x, y, z); + if (!par1World.isRemote) + { + + } + } + + public void updateTick(World par1World, int x, int y, int z, Random par5Random) + { + if (!par1World.isRemote) + { + int meta = par1World.getBlockMetadata(x, y, z); + } + } + + private void letsBuild(World par1World, int x, int y, int z) + { + + } + + private boolean isInactiveTrapCharged(World par1World, int x, int y, int z) + { + return false; + } + + private boolean isReactorReady(World world, int x, int y, int z) + { + if ((world.getBlock(x, y + 1, z) != Blocks.redstone_block) || + (world.getBlock(x, y - 1, z) != Blocks.redstone_block) || + (world.getBlock(x + 1, y, z) != Blocks.redstone_block) || + (world.getBlock(x - 1, y, z) != Blocks.redstone_block) || + (world.getBlock(x, y, z + 1) != Blocks.redstone_block) || + (world.getBlock(x, y, z - 1) != Blocks.redstone_block)) { + return false; + } + return true; + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World par1World, int x, int y, int z, Random par5Random) + { + int meta = par1World.getBlockMetadata(x, y, z); + if ((meta == 3) || (meta == 1) || (meta == 9)) { + for (int i = 0; i < 1; i++) { + sparkle(par1World, x, y, z, par5Random); + } + } + } + + public void sparkle(World world, int x, int y, int z, Random rand) + { + double offset = 0.0625D; + for (int side = 0; side < 6; side++) + { + double rx = x + rand.nextFloat(); + double ry = y + rand.nextFloat(); + double rz = z + rand.nextFloat(); + if ((side == 0) && (!world.getBlock(x, y + 1, z).isOpaqueCube())) { + ry = y + 1 + offset; + } + if ((side == 1) && (!world.getBlock(x, y - 1, z).isOpaqueCube())) { + ry = y + 0 - offset; + } + if ((side == 2) && (!world.getBlock(x, y, z + 1).isOpaqueCube())) { + rz = z + 1 + offset; + } + if ((side == 3) && (!world.getBlock(x, y, z - 1).isOpaqueCube())) { + rz = z + 0 - offset; + } + if ((side == 4) && (!world.getBlock(x + 1, y, z).isOpaqueCube())) { + rx = x + 1 + offset; + } + if ((side == 5) && (!world.getBlock(x - 1, y, z).isOpaqueCube())) { + rx = x + 0 - offset; + } + if ((rx < x) || (rx > x + 1) || (ry < 0.0D) || (ry > y + 1) || (rz < z) || (rz > z + 1)) { + world.spawnParticle("reddust", rx, ry, rz, 0.0D, 0.0D, 0.0D); + } + } + } + + public static void checkAndActivateVanishBlock(World world, int x, int y, int z) + { + Block thereID = world.getBlock(x, y, z); + int thereMeta = world.getBlockMetadata(x, y, z); + } + + public static void changeToActiveVanishBlock(World par1World, int x, int y, int z, int meta) + { + changeToBlockMeta(par1World, x, y, z, meta); + par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.pop", 0.3F, 0.6F); + + Block thereBlockID = par1World.getBlock(x, y, z); + par1World.scheduleBlockUpdate(x, y, z, thereBlockID, getTickRateFor(thereBlockID, meta, par1World.rand)); + } + + private static int getTickRateFor(Block thereBlockID, int meta, Random rand) + { + return 15; + } + + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + Block blockID = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + if (blockID != this) { + return 0; + } + return 10; + } + + public boolean hasTileEntity(int metadata) + { + return (metadata == 0); + } + + public TileEntity createTileEntity(World world, int metadata) + { + if (metadata == 0) { + Utils.LOG_INFO("I have been created. [Antigriefer]"+this.getLocalizedName()); + return new TileEntityReverter(); + } + return null; + } + + public Item getItemDropped(int meta, Random par2Random, int par3) + { + switch (meta) + { + case 0: + return null; + } + return Item.getItemFromBlock(this); + } + + public int damageDropped(int meta) + { + return meta; + } +} diff --git a/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java new file mode 100644 index 0000000000..6096da7054 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidJackDaniels.java @@ -0,0 +1,51 @@ +package gtPlusPlus.core.block.general.fluids; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockFluidJackDaniels extends BlockFluidClassic { + + @SideOnly(Side.CLIENT) + protected IIcon stillIcon; + @SideOnly(Side.CLIENT) + protected IIcon flowingIcon; + + public BlockFluidJackDaniels(Fluid fluid, Material material) { + super(fluid, material); + setCreativeTab(AddToCreativeTab.tabMisc); + } + + @Override + public IIcon getIcon(int side, int meta) { + return (side == 0 || side == 1)? stillIcon : flowingIcon; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister register) { + stillIcon = register.registerIcon(CORE.MODID+":fluids/fluid.jackdaniels"); + flowingIcon = register.registerIcon(CORE.MODID+":fluids/fluid.jackdaniels"); + } + + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.displaceIfPossible(world, x, y, z); + } + +} diff --git a/src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java b/src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java new file mode 100644 index 0000000000..bda2aae35b --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/fluids/FluidRegistryHandler.java @@ -0,0 +1,50 @@ +package gtPlusPlus.core.block.general.fluids; + +import static gtPlusPlus.core.block.ModBlocks.blockFluidJackDaniels; +import static gtPlusPlus.core.block.ModBlocks.fluidJackDaniels; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.material.Material; +import net.minecraftforge.fluids.FluidRegistry; +import cpw.mods.fml.common.registry.GameRegistry; + +public class FluidRegistryHandler { + + //Fluids + /** + * + * Luminosity .setLuminosity(luminosity) + How much light does the fluid emit. Default: 0, Lava uses 15 + Density .setDensity(density) + How dense is the fluid, the only effect is whether or not a fluid replaces another fluid when they flow into each other. Default: 1000, the density of water at 4 degrees Celsius in kg/m³ + Temperature .setTemperature(temp) + How hot, or cold is the fluid. Has currently no effect. Default: 295, the "normal" room temperature in degrees Kelvin, this is approximately 72°F or 22°C. + Viscosity .setViscosity(viscosity) + How thick the fluid is. Determines how fast it flows. Default: 1000 for water, lava uses 6000 + Is Gaseous .setGaseous(boolean) + Indicates if the fluid is gaseous. Used for rendering. Default: false + * + */ + + public static void registerFluids(){ + run(); + } + + private static void run(){ + fluidJackDaniels(); + } + + private static void fluidJackDaniels(){ + //testFluid + fluidJackDaniels.setLuminosity(12); + fluidJackDaniels.setDensity(1200); + fluidJackDaniels.setTemperature(420); + fluidJackDaniels.setViscosity(750); + fluidJackDaniels.setGaseous(true); + fluidJackDaniels.setUnlocalizedName("fluidJackDaniels"); + FluidRegistry.registerFluid(fluidJackDaniels); + blockFluidJackDaniels = new BlockFluidJackDaniels(fluidJackDaniels, Material.water).setBlockName("fluidBlockJackDaniels"); + GameRegistry.registerBlock(blockFluidJackDaniels, CORE.MODID + "_" + blockFluidJackDaniels.getUnlocalizedName().substring(5)); + fluidJackDaniels.setUnlocalizedName(blockFluidJackDaniels.getUnlocalizedName()); + } + +} diff --git a/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java new file mode 100644 index 0000000000..2832d4d0a4 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java @@ -0,0 +1,35 @@ +package gtPlusPlus.core.block.machine; + +import gtPlusPlus.core.block.base.MetaBlock; +import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.material.Material; +import net.minecraft.world.IBlockAccess; + +public class BlockGtFrameBox extends MetaBlock { + + private int[] colours; + private int totalColours; + + public BlockGtFrameBox( + String unlocalizedName, Material material, + BlockTypes blockTypeENUM, boolean recolour, int... colour) { + super(unlocalizedName, material, blockTypeENUM.getBlockSoundType()); + this.setBlockTextureName(CORE.MODID + ":" + "blockGtFrame"); + this.setHarvestLevel(blockTypeENUM.getHarvestTool(), 2); + if (recolour && (colour != null && colour.length > 0)){ + colours = colour; + totalColours = colours.length; + } + } + + @Override + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, + int p_149720_3_, int p_149720_4_) { + for (int i : colours){ + + } + return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); + } + +} diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java new file mode 100644 index 0000000000..4f426b99c9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java @@ -0,0 +1,83 @@ +package gtPlusPlus.core.block.machine; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityCharger; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import scala.util.Random; + +public class Machine_Charger extends BlockContainer +{ + private static final String name = "Charging Machine"; + + private final Random rand = new Random(); + + public Machine_Charger(String unlocalizedName) + { + super(Material.iron); + //GameRegistry.registerBlock(this, unlocalizedName); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) + { + if (world.isRemote) return true; + + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TileEntityCharger) + { + player.openGui(GTplusplus.instance, 1, world, x, y, z); + return true; + } + return false; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6) + { + if (world.isRemote) return; + + ArrayList drops = new ArrayList(); + + TileEntity teRaw = world.getTileEntity(x, y, z); + + if (teRaw != null && teRaw instanceof TileEntityCharger) + { + TileEntityCharger te = (TileEntityCharger) teRaw; + + for (int i = 0; i < te.getSizeInventory(); i++) + { + ItemStack stack = te.getStackInSlot(i); + + if (stack != null) drops.add(stack.copy()); + } + } + + for (int i = 0;i < drops.size();i++) + { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, (ItemStack) drops.get(i)); + item.setVelocity((rand.nextDouble() - 0.5) * 0.25, rand.nextDouble() * 0.5 * 0.25, (rand.nextDouble() - 0.5) * 0.25); + world.spawnEntityInWorld(item); + } + } + + @Override + public TileEntity createNewTileEntity(World world, int par2) + { + return new TileEntityCharger(); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java b/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java new file mode 100644 index 0000000000..011e293000 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java @@ -0,0 +1,83 @@ +package gtPlusPlus.core.block.machine; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityNHG; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import scala.util.Random; + +public class Machine_NHG extends BlockContainer +{ + private static final String name = "Nuclear Fueled Helium Generator"; + + private final Random rand = new Random(); + + public Machine_NHG(String unlocalizedName) + { + super(Material.iron); + //GameRegistry.registerBlock(this, unlocalizedName); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) + { + if (world.isRemote) return true; + + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TileEntityNHG) + { + player.openGui(GTplusplus.instance, 0, world, x, y, z); + return true; + } + return false; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6) + { + if (world.isRemote) return; + + ArrayList drops = new ArrayList(); + + TileEntity teRaw = world.getTileEntity(x, y, z); + + if (teRaw != null && teRaw instanceof TileEntityNHG) + { + TileEntityNHG te = (TileEntityNHG) teRaw; + + for (int i = 0; i < te.getSizeInventory(); i++) + { + ItemStack stack = te.getStackInSlot(i); + + if (stack != null) drops.add(stack.copy()); + } + } + + for (int i = 0;i < drops.size();i++) + { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, (ItemStack) drops.get(i)); + item.setVelocity((rand.nextDouble() - 0.5) * 0.25, rand.nextDouble() * 0.5 * 0.25, (rand.nextDouble() - 0.5) * 0.25); + world.spawnEntityInWorld(item); + } + } + + @Override + public TileEntity createNewTileEntity(World world, int par2) + { + return new TileEntityNHG(); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java b/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java new file mode 100644 index 0000000000..e964a9da01 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java @@ -0,0 +1,5 @@ +package gtPlusPlus.core.block.machine; + +public class Machine_WireiusDeletus { //A Block that removes GT Cable and Wire from it's inventory. + +} diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java new file mode 100644 index 0000000000..7a76b09cca --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java @@ -0,0 +1,165 @@ +package gtPlusPlus.core.block.machine.heliumgen.block; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class HeliumGenerator extends BlockContainer { + + private IIcon top, sides, front; + private Random randy = new Random(); + + public HeliumGenerator(){ + super(Material.iron); + setStepSound(Block.soundTypeMetal); + setHardness(20.0F); + setBlockName("helium_collector"); + setHarvestLevel("pickaxe", 3); + setCreativeTab(AddToCreativeTab.tabMachines); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons (IIconRegister iconRegister) + { + this.top = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_SIDE"); + this.sides = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_SIDE"); + this.front = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_FRONT"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ + if(side == 1) + return top; + int facing = 2; + TileEntityHeliumGenerator machine = (TileEntityHeliumGenerator)world.getTileEntity(x, y, z); + if(machine != null) + facing = machine.getFacing(); + if(side == facing) + return front; + else + return sides; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon (int side, int metadata) + { + if(side == 1) + return top; + if(side == 3) + return front; + return sides; + } + + @Override + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) + { + if (world.isRemote) + { + return true; + } + player.openGui(GTplusplus.instance, 2, world, x, y, z); + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) + { + return new TileEntityHeliumGenerator(); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack item) + { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof TileEntityHeliumGenerator) { + TileEntityHeliumGenerator machine = (TileEntityHeliumGenerator)tile; + int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (l == 0) + machine.setFacing((short) 2); + + if (l == 1) + machine.setFacing((short) 5); + + if (l == 2) + machine.setFacing((short) 3); + + if (l == 3) + machine.setFacing((short) 4); + } + + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int wut) + { + TileEntityHeliumGenerator collector = (TileEntityHeliumGenerator)world.getTileEntity(x, y, z); + + if (collector != null) + { + int i = 0; + for (i = 0; i < collector.getSizeInventory(); i++){ + + ItemStack itemstack = collector.getStackInSlot(i); + + if (itemstack != null) + { + float f = this.randy.nextFloat() * 0.8F + 0.1F; + float f1 = this.randy.nextFloat() * 0.8F + 0.1F; + float f2 = this.randy.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j1 = this.randy.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) + { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + EntityItem entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.randy.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.randy.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.randy.nextGaussian() * f3); + world.spawnEntityInWorld(entityitem); + } + } + + world.func_147453_f(x, y, z, block); + } + } + + super.breakBlock(world, x, y, z, block, wut); + } +} diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java new file mode 100644 index 0000000000..d701f6f125 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java @@ -0,0 +1,75 @@ +package gtPlusPlus.core.block.machine.heliumgen.container; + +import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; + +import java.util.List; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.inventory.SlotFurnace; + +public class ContainerHeliumGenerator +extends ContainerBase<TileEntityHeliumGenerator> +{ + 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<String> getNetworkedFields() + { + List<String> ret = super.getNetworkedFields(); + + ret.add("heat"); + ret.add("maxHeat"); + ret.add("EmitHeat"); + /*ret.add("inputTank"); + ret.add("outputTank"); + ret.add("fluidcoolreactor");*/ + return ret; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java new file mode 100644 index 0000000000..2106f144be --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java @@ -0,0 +1,72 @@ +package gtPlusPlus.core.block.machine.heliumgen.gui; + +import gtPlusPlus.core.block.machine.heliumgen.container.ContainerHeliumGenerator; +import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GUIHeliumGenerator extends GuiContainer +{ + private static final ResourceLocation collectorGuiTexture = new ResourceLocation(CORE.MODID, "textures/gui/helium_collector_gui.png"); + + public GUIHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine) + { + super(new ContainerHeliumGenerator(player, machine)); + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + String s = StatCollector.translateToLocal("Helium Collector"); + this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + + this.fontRendererObj.drawString(StatCollector.translateToLocal("|"+-1), 80, 35, 2); + + short sr = 3; + int size = sr; + int startX = 16; + int startY = 16; + int i = 0; + for (i = 0; i < 9; i++) + { + int x = i % size; + int y = i / size; + this.fontRendererObj.drawString(StatCollector.translateToLocal("|"+i), startX + 18 * x, startY + 18 * y, 4210752); + //addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); + } + startX = 108; + startY = 16; + for (i = 9; i < 18; i++) + { + int x = i % size; + int y = (i-9) / size; + this.fontRendererObj.drawString(StatCollector.translateToLocal("|"+i), startX + 18 * x, startY + 18 * y, 4210752); + // addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); + } + + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(collectorGuiTexture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java new file mode 100644 index 0000000000..86507a2d64 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java @@ -0,0 +1,78 @@ +package gtPlusPlus.core.block.machine.heliumgen.slots; + +import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator; +import ic2.core.block.invslot.InvSlot; +import net.minecraft.item.ItemStack; + +public class InvSlotRadiation extends InvSlot +{ + public InvSlotRadiation(TileEntityHeliumGenerator base, String name1, int oldStartIndex1, int count) + { + super(base, name1, oldStartIndex1, InvSlot.Access.IO, count); + + setStackSizeLimit(1); + } + + @Override + public boolean accepts(ItemStack itemStack) + { + return ((TileEntityHeliumGenerator)this.base).isUsefulItem(itemStack, true); + } + + @Override + public int size() + { + //Utils.LOG_INFO("InvSlotRadiation/Size"); + return 3 * 6; + } + + public int rawSize() + { + return super.size(); + } + + @Override + public ItemStack get(int index) + { + return super.get(mapIndex(index)); + } + + public ItemStack get(int x, int y) + { + return super.get(y * 9 + x); + } + + @Override + public void put(int index, ItemStack content) + { + super.put(mapIndex(index), content); + } + + public void put(int x, int y, ItemStack content) + { + super.put(y * 9 + x, content); + } + + private int mapIndex(int index) + { + int size = size(); + int cols = size / 6; + if (index < size) + { + int row = index / cols; + int col = index % cols; + + return row * 9 + col; + } + index -= size; + int remCols = 9 - cols; + + int row = index / remCols; + int col = cols + index % remCols; + + return row * 9 + col; + } + + private final int rows = 6; + private final int maxCols = 9; +} diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java new file mode 100644 index 0000000000..06c13f997a --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java @@ -0,0 +1,648 @@ +package gtPlusPlus.core.block.machine.heliumgen.tileentity; + +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.block.machine.heliumgen.slots.InvSlotRadiation; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import ic2.api.Direction; +import ic2.api.reactor.IReactor; +import ic2.api.reactor.IReactorComponent; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.IC2DamageSource; +import ic2.core.Ic2Items; +import ic2.core.block.TileEntityInventory; +import ic2.core.init.MainConfig; +import ic2.core.item.reactor.ItemReactorHeatStorage; +import ic2.core.network.NetworkManager; +import ic2.core.util.ConfigUtil; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +public class TileEntityHeliumGenerator extends TileEntityInventory implements IInventory ,IReactor, IWrenchable { + + private ItemStack heliumStack; + private int facing = 2; + private int progress; + + + public void update2Entity(){ + Utils.LOG_WARNING("updateEntity"); + if(++progress >= 40){ + //if(++progress >= 300){ + if(heliumStack == null) + heliumStack = UtilsItems.getSimpleStack(ModItems.itemHeliumBlob); + else if(heliumStack.getItem() == ModItems.itemHeliumBlob && heliumStack.stackSize < 64) + heliumStack.stackSize++; + progress = 0; + markDirty(); + } + } + + @Override + public short getFacing(){ + return (short) facing; + } + + @Override + public void setFacing(short dir){ + facing = dir; + } + + /*@Override + public void readCustomNBT(NBTTagCompound tag) + { + this.heliumStack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Helium")); + this.progress = tag.getInteger("Progress"); + this.facing = tag.getShort("Facing"); + this.heat = tag.getInteger("heat"); + this.prevActive = (this.active = tag.getBoolean("active")); + } + + @Override + public void writeCustomNBT(NBTTagCompound tag) + { + tag.setInteger("Progress", this.progress); + tag.setShort("Facing", (short) this.facing); + tag.setInteger("heat", this.heat); + tag.setBoolean("active", this.active); + if(heliumStack != null) { + NBTTagCompound produce = new NBTTagCompound(); + heliumStack.writeToNBT(produce); + tag.setTag("Helium", produce); + } + else + tag.removeTag("Helium"); + }*/ + + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + + //this.heliumStack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Helium")); + NBTTagList list = nbttagcompound.getTagList("Items", 10); + for (int i = 0; i < list.tagCount(); ++i) { + NBTTagCompound stackTag = list.getCompoundTagAt(i); + int slot = stackTag.getByte("Slot") & 255; + this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag)); + } + this.progress = nbttagcompound.getInteger("Progress"); + this.facing = nbttagcompound.getShort("Facing"); + this.heat = nbttagcompound.getInteger("heat"); + this.output = nbttagcompound.getShort("output"); + this.prevActive = (this.active = nbttagcompound.getBoolean("active")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + + nbttagcompound.setInteger("Progress", this.progress); + nbttagcompound.setShort("Facing", (short) this.facing); + nbttagcompound.setInteger("heat", this.heat); + nbttagcompound.setShort("output", (short)(int)getReactorEnergyOutput()); + nbttagcompound.setBoolean("active", this.active); + /*if(heliumStack != null) { + NBTTagCompound produce = new NBTTagCompound(); + heliumStack.writeToNBT(produce); + nbttagcompound.setTag("Helium", produce); + } + else + nbttagcompound.removeTag("Helium");*/ + NBTTagList list = new NBTTagList(); + for (int i = 0; i < this.getSizeInventory(); ++i) { + if (this.getStackInSlot(i) != null) { + NBTTagCompound stackTag = new NBTTagCompound(); + stackTag.setByte("Slot", (byte) i); + this.getStackInSlot(i).writeToNBT(stackTag); + list.appendTag(stackTag); + } + } + nbttagcompound.setTag("Items", list); + } + + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, tag); + } + + @Override + public void onDataPacket(net.minecraft.network.NetworkManager net, S35PacketUpdateTileEntity packet) { + super.onDataPacket(net, packet); + readFromNBT(packet.func_148857_g()); + } + + + @Override + public int getSizeInventory() + { + return 19; + } + + @Override + public ItemStack getStackInSlot(int slot){ + return heliumStack; + } + + @Override + public ItemStack decrStackSize(int slot, int decrement){ + Utils.LOG_WARNING("decrStackSize"); + if(heliumStack == null) + return null; + if(decrement < heliumStack.stackSize){ + ItemStack take = heliumStack.splitStack(decrement); + if(heliumStack.stackSize <= 0) + heliumStack = null; + return take; + } + ItemStack take = heliumStack; + heliumStack = null; + return take; + } + + @Override + public void openInventory() {} + @Override + public void closeInventory() {} + + @Override + public boolean isUseableByPlayer(EntityPlayer player) + { + return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this && player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack){ + return false; + } + + @Override + public int getInventoryStackLimit(){ + return 64; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack){ + heliumStack = stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot){ + return null; + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + //return "container.helium_collector"; + return "container.helium_collector"; + } + + /** + * Returns if the inventory is named + */ + @Override + public boolean hasCustomInventoryName() + { + return false; + } + + //IC2 Nuclear Code + + + public Block[][][] surroundings = new Block[5][5][5]; + public final InvSlotRadiation reactorSlot; + public float output = 0.0F; + public int updateTicker; + public int heat = 5000; + public int maxHeat = 100000; + public float hem = 1.0F; + private int EmitHeatbuffer = 0; + public int EmitHeat = 0; + private boolean redstone = false; + private boolean fluidcoolreactor = false; + private boolean active = true; + public boolean prevActive = false; + + + public short getReactorSize() + { + //Utils.LOG_WARNING("getReactorSize"); + if (this.worldObj == null) { + Utils.LOG_WARNING("getReactorSize == 9"); + return 9; + } + short cols = 3; + //Utils.LOG_WARNING("getReactorSize == "+cols); + for (Direction direction : Direction.directions) + { + TileEntity target = direction.applyToTileEntity(this); + if ((target instanceof TileEntityHeliumGenerator)) { + cols = (short)(cols + 1); + Utils.LOG_WARNING("getReactorSize =1= "+cols); + } + } + //Utils.LOG_WARNING("getReactorSize == "+cols); + return cols; + } + + protected void updateEntityServer() + { + 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/gtPlusPlus/core/commands/CommandMath.java b/src/Java/gtPlusPlus/core/commands/CommandMath.java new file mode 100644 index 0000000000..2a726dd8b1 --- /dev/null +++ b/src/Java/gtPlusPlus/core/commands/CommandMath.java @@ -0,0 +1,205 @@ +package gtPlusPlus.core.commands; + +import gtPlusPlus.core.util.Utils; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + + +public class CommandMath implements ICommand +{ + private final List<String> aliases; + + protected String fullEntityName; + protected Entity conjuredEntity; + + public CommandMath() + { + aliases = new ArrayList<String>(); + + aliases.add("hometele"); + + aliases.add("warphome"); + + } + + @Override + public int compareTo(Object o) + { + return 0; + + } + + @Override + public String getCommandName() + { + return "bed"; + + } + + @Override + public String getCommandUsage(ICommandSender var1) + { + return "/bed [Teleports you to your bed for XP]"; + + } + + @Override + public List<String> getCommandAliases() + { + return this.aliases; + + } + + public void processCommand(ICommandSender S, String[] argString) + { + World W = S.getEntityWorld(); + CommandUtils C = new CommandUtils(); + EntityPlayer P = C.getPlayer(S); + //System.out.println(P.getCommandSenderName()); + //System.out.println(P.getDisplayName()); + if (W.isRemote) + + { + + System.out.println("Not processing on Client side"); + + } + + else + + { + + System.out.println("Processing on Server side - Home Teleport engaged by: "+P.getDisplayName()); + + int XP_TOTAL = P.experienceTotal; + Utils.LOG_WARNING("Total Xp:" + XP_TOTAL); + ChunkCoordinates X = P.getPlayerCoordinates(); + Utils.LOG_WARNING("Player Location: "+X); + ChunkCoordinates Y = null; + Utils.LOG_WARNING("Bed Location: "+Y); + try { + if (P.getBedLocation(0).equals(null)){ + Y = W.getSpawnPoint(); + Utils.LOG_WARNING("Spawn Location: "+Y); + } + else if (!P.getBedLocation(0).equals(null)){ + Y = P.getBedLocation(0); + Utils.LOG_WARNING("Bed Location: "+Y); + } + else { + Y = W.getSpawnPoint(); + Utils.LOG_WARNING("Spawn Location: "+Y); + } + } + catch(NullPointerException e) { + Utils.messagePlayer(P, "You do not have a spawn, so..."); + } + if (Y == null || Y.equals(null)) { + Y = W.getSpawnPoint(); + Utils.LOG_WARNING("Spawn Location: "+Y); + } + + int x1 = X.posX; + Utils.LOG_WARNING("X1: "+x1); + int x2 = Y.posX; + Utils.LOG_WARNING("X2: "+x2); + int y1 = X.posY; + Utils.LOG_WARNING("Y1: "+y1); + int y2 = Y.posY; + Utils.LOG_WARNING("Y2: "+y2); + int z1 = X.posZ; + Utils.LOG_WARNING("Z1: "+z1); + int z2 = Y.posZ; + Utils.LOG_WARNING("Z2: "+z2); + + + double d = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)); + String xpCost = String.valueOf((int)(d*0.15)); + + Utils.LOG_WARNING("d:" + d); + Utils.LOG_WARNING("-----------------------------------------"); + Utils.LOG_WARNING("Actual math formulae"); + Utils.LOG_WARNING(String.valueOf(d)); + Utils.LOG_WARNING("-----------------------------------------"); + Utils.LOG_WARNING("Xp Cost based on answer B."); + Utils.LOG_WARNING(String.valueOf(d*0.15) + " | " + String.valueOf(xpCost)); + Utils.LOG_WARNING("-----------------------------------------"); + Utils.LOG_WARNING("Xp Total"); + Utils.LOG_WARNING(String.valueOf(XP_TOTAL)); + Utils.LOG_WARNING("-----------------------------------------"); + + + + if ((XP_TOTAL-Float.valueOf(xpCost)) > 0){ + EntityXPOrb E = new EntityXPOrb(W, P.posX, P.posY + 1.62D - (double) P.yOffset, P.posZ, 1); + //E.moveTowards((double) Y.posX + 0.5D, (int) Y.posY + 3, (double) Y.posZ + 0.5D); + E.setVelocity((double) Y.posX + 0.5D, (int) Y.posY + 0.1, (double) Y.posZ + 0.5D); + W.spawnEntityInWorld(E); + W.playAuxSFXAtEntity((EntityPlayer) null, 1002, (int) P.posX, (int) P.posY, (int) P.posZ, 0); + P.setPositionAndUpdate(x2, y2+1, z2); + + //gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Movement | X:"+x2+" | Y:"+y2+" | Z:"+z2); + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Distance Traveled | "+String.valueOf((int)(d)) + " Blocks & " + xpCost + "xp"); + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "You suddenly feel at home."); + P.experienceTotal = (int) (XP_TOTAL-Float.valueOf(xpCost)); + if (!xpCost.equals("0") && Float.valueOf(xpCost) > 0){ + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "...At the loss of "+xpCost+" xp."); + } + else if (xpCost.equals("0")){ + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "...At the loss of very little xp."); + } + else { + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Something went wrong with the math, have this one on the house. :)"); + } + } + + else { + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "You don't feel you're able to do this yet."); + } + + } + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender var1) + { + return true; + + } + + @Override + public List<?> addTabCompletionOptions(ICommandSender var1, String[] var2) + { + // TODO Auto-generated method stub + + return null; + + } + + @Override + public boolean isUsernameIndex(String[] var1, int var2) + { + // TODO Auto-generated method stub + + return false; + + } + + public boolean playerUsesCommand(World W, EntityPlayer P, int cost) + { + + + return true; + } + +} + diff --git a/src/Java/gtPlusPlus/core/commands/CommandUtils.java b/src/Java/gtPlusPlus/core/commands/CommandUtils.java new file mode 100644 index 0000000000..32e7a75370 --- /dev/null +++ b/src/Java/gtPlusPlus/core/commands/CommandUtils.java @@ -0,0 +1,20 @@ +package gtPlusPlus.core.commands; + +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; + +public class CommandUtils { + + public EntityPlayer getPlayer(ICommandSender icommandsender){ + EntityPlayer player; + + if(icommandsender instanceof EntityPlayer){ + player = (EntityPlayer)icommandsender; + return player; + } + else { + return null; + } + } + +} diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java new file mode 100644 index 0000000000..f3ed741bf0 --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -0,0 +1,132 @@ +package gtPlusPlus.core.common; + +import static gtPlusPlus.core.lib.CORE.DEBUG; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.COMPAT_HANDLER; +import gtPlusPlus.core.handler.COMPAT_IntermodStaging; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.handler.events.PickaxeBlockBreakEventHandler; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.recipe.RECIPE_CONSTANTS; +import gtPlusPlus.core.tileentities.ModTileEntities; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.debug.DEBUG_INIT; +import gtPlusPlus.core.util.player.PlayerCache; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; + +import java.util.Iterator; + +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.FMLCommonHandler; +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 { + + public CommonProxy(){ + //Should Register Gregtech Materials I've Made + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + if (LoadedMods.Gregtech){ + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + Utils.LOG_INFO("We're using Gregtech 5.09 Experimental."); + } + else { + Utils.LOG_INFO("We're using Gregtech 5.08 or an equivalent fork."); + } + } + if (LoadedMods.Gregtech){ + for (String tOreName : OreDictionary.getOreNames()) { + ItemStack tOreStack; + for (Iterator i$ = OreDictionary.getOres(tOreName).iterator(); i$.hasNext(); Meta_GT_Proxy.registerOre(new OreDictionary.OreRegisterEvent(tOreName, tOreStack))) { + Utils.LOG_INFO("Iterating Material"); + tOreStack = (ItemStack) i$.next(); + } + } + new Meta_GT_Proxy(); + } + } + + public void preInit(FMLPreInitializationEvent e) { + Utils.LOG_INFO("Doing some house cleaning."); + LoadedMods.checkLoaded(); + Utils.LOG_INFO("Making sure we're ready to party!"); + + + if (!DEBUG){ + Utils.LOG_WARNING("Development mode not enabled."); + } + else if (DEBUG){ + Utils.LOG_INFO("Development mode enabled."); + } + else { + Utils.LOG_WARNING("Development mode not set."); + } + AddToCreativeTab.initialiseTabs(); + COMPAT_IntermodStaging.preInit(); + //Apparently I should do this here. Might put it in Init for a test. + //Growthcraft_Handler.run(); + } + + public void init(FMLInitializationEvent e) { + //Debug Loading + if (CORE.DEBUG){ + DEBUG_INIT.registerHandlers(); + } + ModItems.init(); + ModBlocks.init(); + RECIPE_CONSTANTS.initialise(); + MinecraftForge.EVENT_BUS.register(new PickaxeBlockBreakEventHandler()); + + //Compat Handling + COMPAT_HANDLER.registerMyModsOreDictEntries(); + COMPAT_HANDLER.registerGregtechMachines(); + COMPAT_HANDLER.intermodOreDictionarySupport(); + COMPAT_IntermodStaging.init(); + } + + public void postInit(FMLPostInitializationEvent e) { + Utils.LOG_INFO("Cleaning up, doing postInit."); + PlayerCache.initCache(); + //Compat Handling + COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); + COMPAT_HANDLER.RemoveRecipesFromOtherMods(); + COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); + COMPAT_IntermodStaging.postInit(); + } + + + public void serverStarting(FMLServerStartingEvent e) + { + COMPAT_HANDLER.InitialiseLateHandlerThenAddRecipes(); + } + + public void registerNetworkStuff(){ + GuiHandler.init(); + } + + public void registerTileEntities(){ + ModTileEntities.init(); + } + + public void registerRenderThings() { + + } + + @SuppressWarnings("static-method") + public int addArmor(String armor) { + return 0; + } + + public void generateMysteriousParticles(Entity theEntity) { } + + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_BigReactors.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_BigReactors.java new file mode 100644 index 0000000000..7f4aa0541a --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_BigReactors.java @@ -0,0 +1,19 @@ +package gtPlusPlus.core.common.compat; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; +import net.minecraft.item.ItemStack; + +public class COMPAT_BigReactors { + + public static void OreDict(){ + run(); + } + + private static final void run(){ + GT_OreDictUnificator.registerOre("plateBlutonium", new ItemStack(ModItems.itemPlateBlutonium)); + GT_OreDictUnificator.registerOre("plateCyanite", new ItemStack(ModItems.itemPlateCyanite)); + GT_OreDictUnificator.registerOre("plateLudicrite", new ItemStack(ModItems.itemPlateLudicrite)); + } + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java new file mode 100644 index 0000000000..efa86f0009 --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java @@ -0,0 +1,171 @@ +package gtPlusPlus.core.common.compat; + +import static gtPlusPlus.core.handler.COMPAT_HANDLER.AddRecipeQueue; +import static gtPlusPlus.core.handler.COMPAT_HANDLER.RemoveRecipeQueue; +import gtPlusPlus.core.recipe.ShapedRecipeObject; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.item.ItemStack; + + + +public class COMPAT_CompactWindmills { + + //Change IC2 Upgrades + public static ItemStack kineticWind = UtilsItems.simpleMetaStack("IC2:blockKineticGenerator", 0, 1); + public static ItemStack shaftIron = UtilsItems.simpleMetaStack("IC2:itemRecipePart", 11, 1); + public static ItemStack cableCopper = UtilsItems.simpleMetaStack("gregtech:gt.blockmachines", 1367, 1); + public static String plateRubber = "ore:plateRubber"; + + //Machine Casings + public static ItemStack elvCasing = UtilsItems.simpleMetaStack("gregtech:gt.blockcasings", 0, 1); + public static ItemStack lvCasing = UtilsItems.simpleMetaStack("gregtech:gt.blockcasings", 1, 1); + public static ItemStack mvCasing = UtilsItems.simpleMetaStack("gregtech:gt.blockcasings", 2, 1); + public static ItemStack hvCasing = UtilsItems.simpleMetaStack("gregtech:gt.blockcasings", 3, 1); + public static ItemStack evCasing = UtilsItems.simpleMetaStack("gregtech:gt.blockcasings", 4, 1); + public static ItemStack ivCasing = UtilsItems.simpleMetaStack("gregtech:gt.blockcasings", 5, 1); + + //GT Transformers + public static ItemStack elvTransformer = UtilsItems.simpleMetaStack("gregtech:gt.blockmachines", 20, 1); + public static ItemStack lvTransformer = UtilsItems.simpleMetaStack("gregtech:gt.blockmachines", 21, 1); + public static ItemStack mvTransformer = UtilsItems.simpleMetaStack("gregtech:gt.blockmachines", 22, 1); + public static ItemStack hvTransformer = UtilsItems.simpleMetaStack("gregtech:gt.blockmachines", 23, 1); + public static ItemStack evTransformer = UtilsItems.simpleMetaStack("gregtech:gt.blockmachines", 24, 1); + + //Compact Windmills + public static ItemStack elvWindmill = UtilsItems.simpleMetaStack("CompactWindmills:blockCompactWindmill", 0, 1); + public static ItemStack lvWindmill = UtilsItems.simpleMetaStack("CompactWindmills:blockCompactWindmill", 1, 1); + public static ItemStack mvWindmill = UtilsItems.simpleMetaStack("CompactWindmills:blockCompactWindmill", 2, 1); + public static ItemStack hvWindmill = UtilsItems.simpleMetaStack("CompactWindmills:blockCompactWindmill", 3, 1); + public static ItemStack evWindmill = UtilsItems.simpleMetaStack("CompactWindmills:blockCompactWindmill", 4, 1); + + //Compact Rotors + public static ItemStack rotor2 = UtilsItems.getItemStack("CompactWindmills:WOOL", 1); + public static ItemStack rotor1 = UtilsItems.getItemStack("CompactWindmills:WOOD", 1); + public static ItemStack rotor3 = UtilsItems.getItemStack("CompactWindmills:ALLOY", 1); + public static ItemStack rotor4 = UtilsItems.getItemStack("CompactWindmills:CARBON", 1); + public static ItemStack rotor5 = UtilsItems.getItemStack("CompactWindmills:IRIDIUM", 1); + + //IC2 Rotors + public static ItemStack rotorIC1 = UtilsItems.getItemStack("IC2:itemwoodrotor", 1); + public static ItemStack rotorIC2 = UtilsItems.getItemStack("IC2:itemironrotor", 1); + public static ItemStack rotorIC3 = UtilsItems.getItemStack("IC2:itemsteelrotor", 1); + public static ItemStack rotorIC4 = UtilsItems.getItemStack("IC2:itemwcarbonrotor", 1); + public static ItemStack rotorBlade1 = UtilsItems.simpleMetaStack("IC2:itemRecipePart", 7, 1); + public static ItemStack rotorBlade2 = UtilsItems.simpleMetaStack("IC2:itemRecipePart", 8, 1); + public static ItemStack rotorBlade3 = UtilsItems.simpleMetaStack("IC2:itemRecipePart", 10, 1); + public static ItemStack rotorBlade4 = UtilsItems.simpleMetaStack("IC2:itemRecipePart", 9, 1); + + //Plates + public static String plateTier1 = "ore:plateMagnalium"; + public static String plateTier2 = "ore:plateStainlessSteel"; + public static String plateTier3 = "ore:plateTitanium"; + public static String plateTier4 = "ore:plateTungstenSteel"; + public static String plateTier5 = "ore:plateNichrome"; + public static String plateCarbon = "ore:plateAlloyCarbon"; + public static String plateAlloy = "ore:plateAlloyAdvanced"; + + //Circuits + public static String circuitTier1 = "ore:circuitGood"; + public static String circuitTier2 = "ore:circuitAdvanced"; + public static String circuitTier3 = "ore:circuitData"; + public static String circuitTier4 = "ore:circuitElite"; + public static String circuitTier5 = "ore:circuitMaster"; + + //Wooden Rotor + public static ShapedRecipeObject Wooden_Rotor = new ShapedRecipeObject( + rotorBlade1, "ore:plateAnyIron", "ore:plateAnyIron", + "ore:screwAluminium", rotorIC1, "ore:screwAluminium", + rotorBlade1, "plateAnyIron", rotorBlade1, + rotor1); + //Alloy Rotor + public static ShapedRecipeObject Alloy_Rotor = new ShapedRecipeObject( + plateAlloy, plateAlloy, plateAlloy, + plateAlloy, rotorIC3, plateAlloy, + plateAlloy,plateAlloy, plateAlloy, + rotor3); + //Carbon Rotor + public static ShapedRecipeObject Carbon_Rotor = new ShapedRecipeObject( + plateCarbon, rotorBlade4, plateCarbon, + rotorBlade4, rotor3, rotorBlade4, + plateCarbon, rotorBlade4, plateCarbon, + rotor4); + + //Kinetic Wind Turbine + public static ShapedRecipeObject KWT = new ShapedRecipeObject( + plateCarbon, shaftIron, plateCarbon, + cableCopper, mvCasing, cableCopper, + plateRubber, plateCarbon, plateRubber, + kineticWind); + + //ELV Windmill + public static ShapedRecipeObject WM_ELV = new ShapedRecipeObject( + + circuitTier1, elvTransformer, circuitTier1, + plateTier1, lvCasing, plateTier1, + plateTier1, rotor1, plateTier1, + elvWindmill); + + + //LV Windmill + public static ShapedRecipeObject WM_LV = new ShapedRecipeObject( + circuitTier2, lvTransformer, circuitTier2, + plateTier2, mvCasing, plateTier2, + plateTier2, rotor2, plateTier2, + lvWindmill); + + //MV Windmill + public static ShapedRecipeObject WM_MV = new ShapedRecipeObject( + circuitTier3, mvTransformer, circuitTier3, + plateTier3, hvCasing, plateTier3, + plateTier3, rotor3, plateTier3, + mvWindmill); + + //HV Windmill + public static ShapedRecipeObject WM_HV = new ShapedRecipeObject( + circuitTier4, hvTransformer, circuitTier4, + plateTier4, evCasing, plateTier4, + plateTier4, rotor4, plateTier4, + hvWindmill); + + //EV Windmill + public static ShapedRecipeObject WM_EV = new ShapedRecipeObject( + circuitTier5, evTransformer, circuitTier5, + plateTier5, ivCasing, plateTier5, + plateTier5, rotor5, plateTier5, + evWindmill); + + public static void OreDict(){ + run(); + } + + private static final void run(){ + //RemoveRecipeQueue.add("CompactWindmills:WOOL"); + //RemoveRecipeQueue.add("CompactWindmills:WOOD"); + //RemoveRecipeQueue.add("CompactWindmills:ALLOY"); + //RemoveRecipeQueue.add("CompactWindmills:CARBON"); + //RemoveRecipeQueue.add("CompactWindmills:IRIDIUM"); + + //Remove Recipes + RemoveRecipeQueue.add(kineticWind); + RemoveRecipeQueue.add(elvWindmill); + RemoveRecipeQueue.add(lvWindmill); + RemoveRecipeQueue.add(mvWindmill); + RemoveRecipeQueue.add(hvWindmill); + RemoveRecipeQueue.add(evWindmill); + RemoveRecipeQueue.add(rotor1); + RemoveRecipeQueue.add(rotor3); + RemoveRecipeQueue.add(rotor4); + + //Add Recipes + AddRecipeQueue.add(Wooden_Rotor); + AddRecipeQueue.add(Alloy_Rotor); + AddRecipeQueue.add(Carbon_Rotor); + AddRecipeQueue.add(KWT); + AddRecipeQueue.add(WM_ELV); + AddRecipeQueue.add(WM_LV); + AddRecipeQueue.add(WM_MV); + AddRecipeQueue.add(WM_HV); + AddRecipeQueue.add(WM_EV); + + } +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_EnderIO.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_EnderIO.java new file mode 100644 index 0000000000..d538b2df3d --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_EnderIO.java @@ -0,0 +1,26 @@ +package gtPlusPlus.core.common.compat; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.item.ItemStack; + +public class COMPAT_EnderIO { + + public static void OreDict(){ + run(); + } + + private static final void run(){ + UtilsItems.getItemForOreDict("EnderIO:itemAlloy", "ingotVibrantAlloy", "Vibrant Alloy Ingot", 2); + GT_OreDictUnificator.registerOre("plateConductiveIron", new ItemStack(ModItems.itemPlateConductiveIron)); + GT_OreDictUnificator.registerOre("plateDarkSteel", new ItemStack(ModItems.itemPlateDarkSteel)); + GT_OreDictUnificator.registerOre("plateElectricalSteel", new ItemStack(ModItems.itemPlateElectricalSteel)); + GT_OreDictUnificator.registerOre("plateEnergeticAlloy", new ItemStack(ModItems.itemPlateEnergeticAlloy)); + GT_OreDictUnificator.registerOre("platePulsatingIron", new ItemStack(ModItems.itemPlatePulsatingIron)); + GT_OreDictUnificator.registerOre("plateRedstoneAlloy", new ItemStack(ModItems.itemPlateRedstoneAlloy)); + GT_OreDictUnificator.registerOre("plateSoularium", new ItemStack(ModItems.itemPlateSoularium)); + GT_OreDictUnificator.registerOre("plateVibrantAlloy", new ItemStack(ModItems.itemPlateVibrantAlloy)); + } + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java new file mode 100644 index 0000000000..c77f1475b9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java @@ -0,0 +1,33 @@ +package gtPlusPlus.core.common.compat; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE.configSwitches; +import gtPlusPlus.core.recipe.RECIPES_Tools; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import net.minecraft.item.ItemStack; + +public class COMPAT_ExtraUtils { + + public static void OreDict(){ + RECIPES_Tools.RECIPE_DivisionSigil = new ItemStack(UtilsItems.getItem("ExtraUtilities:divisionSigil")); + run(); + + } + + private static final void run(){ + UtilsItems.getItemForOreDict("ExtraUtilities:bedrockiumIngot", "ingotBedrockium", "Bedrockium Ingot", 0); + GT_OreDictUnificator.registerOre("plateBedrockium", new ItemStack(ModItems.itemPlateBedrockium)); + + if (configSwitches.enableAlternativeDivisionSigilRecipe){ + //Division Sigil + UtilsRecipe.recipeBuilder( + "plateNetherStar", "gemIridium", "plateNetherStar", + "plateIridium", RECIPES_Tools.craftingToolHardHammer, "plateIridium", + "plateNetherStar", "gemIridium", "plateNetherStar", + RECIPES_Tools.RECIPE_DivisionSigil); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_IC2.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_IC2.java new file mode 100644 index 0000000000..14ec5dfd4d --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_IC2.java @@ -0,0 +1,62 @@ +package gtPlusPlus.core.common.compat; + + +import static gtPlusPlus.core.handler.COMPAT_HANDLER.RemoveRecipeQueue; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.lib.CORE.configSwitches; +import gtPlusPlus.core.recipe.ShapedRecipeObject; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.item.ItemStack; + + +public class COMPAT_IC2 { + + private static ItemStack itemCropnalyzer = UtilsItems.simpleMetaStack("IC2:itemCropnalyzer", 0, 1); + private static ItemStack itemSolarHelmet = UtilsItems.simpleMetaStack("IC2:itemSolarHelmet", 0, 1); + + public static ShapedRecipeObject Cropnalyzer = new ShapedRecipeObject( + "ore:cableGt02Copper", "ore:cableGt02Copper", null, + "minecraft:redstone", "ore:blockGlass", "minecraft:redstone", + "minecraft:redstone", "ore:circuitBasic", "minecraft:redstone", + itemCropnalyzer); + public static ShapedRecipeObject SolarHelmet = new ShapedRecipeObject( + "ore:plateIron", "ore:plateIron", "ore:plateIron", + "ore:plateIron", "gregtech:gt.metaitem.01:32750", "ore:plateIron", + "ore:craftingWireCopper", "ore:craftingWireCopper", "ore:craftingWireCopper", + itemSolarHelmet); + + + + public static void OreDict(){ + //Get ItemStacks for results + /*itemCropnalyzer = UtilsItems.getItemStack("IC2:itemCropnalyzer", 1); + itemSolarHelmet = UtilsItems.getItemStack("IC2:itemSolarHelmet", 1); */ + run(); + } + + private static final void run(){ + + if (configSwitches.disableIC2Recipes){ + + + + if (LoadedMods.Gregtech){ + //Fuck these right off. + RemoveRecipeQueue.add("IC2:itemCable"); + RemoveRecipeQueue.add("IC2:itemCable:1"); + RemoveRecipeQueue.add("IC2:itemCable:2"); + RemoveRecipeQueue.add("IC2:itemCable:3"); + RemoveRecipeQueue.add("IC2:itemCable:5"); + RemoveRecipeQueue.add("IC2:itemCable:6"); + RemoveRecipeQueue.add("IC2:itemCable:10"); + RemoveRecipeQueue.add("IC2:itemCable:13"); + //RemoveRecipeQueue.add(itemCropnalyzer); + //RemoveRecipeQueue.add(itemSolarHelmet); + + //AddRecipeQueue.add(Cropnalyzer); + //AddRecipeQueue.add(SolarHelmet); + } + } + } + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_MorePlanets.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_MorePlanets.java new file mode 100644 index 0000000000..3a996ed849 --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_MorePlanets.java @@ -0,0 +1,37 @@ +package gtPlusPlus.core.common.compat; + +import gtPlusPlus.core.util.item.UtilsItems; + +public class COMPAT_MorePlanets { + + + public static void OreDict(){ + run(); + } + + private final static void run(){ + //Metals + UtilsItems.getItemForOreDict("MorePlanet:kapteyn-b_item", "ingotFrozenIron", "Frozen Iron Ingot", 0); + UtilsItems.getItemForOreDict("MorePlanet:kapteyn-b_item", "ingotAnyIron", "Frozen Iron Ingot", 0); + UtilsItems.getItemForOreDict("MorePlanet:polongnius_item", "ingotPalladium", "Palladium Ingot", 5); + UtilsItems.getItemForOreDict("MorePlanet:fronos_item", "ingotIridium", "Iridium Ingot", 3); + UtilsItems.getItemForOreDict("MorePlanet:nibiru_item", "ingotNorium", "Norium Ingot", 1); + UtilsItems.getItemForOreDict("MorePlanet:venus_item", "ingotLead", "Lead Ingot", 0); + UtilsItems.getItemForOreDict("MorePlanet:diona_item", "ingotQuontonium", "Quontonium Ingot", 0); + UtilsItems.getItemForOreDict("MorePlanet:diona_item", "ingotFronisium", "Fronisium Ingot", 1); + UtilsItems.getItemForOreDict("MorePlanet:sirius-b_item", "ingotSulfur", "Sulfur Ingot", 3); + UtilsItems.getItemForOreDict("MorePlanet:koentus_item", "ingotKoentusMeteoricIron", "Koentus Meteoric Iron Ingot", 4); + UtilsItems.getItemForOreDict("MorePlanet:mercury_item", "ingotMetallic", "Metallic Ingot", 2); + UtilsItems.getItemForOreDict("MorePlanet:polongnius_item", "ingotPolongiusMeteoricIron", "Polongius Meteoric Iron Ingot", 4); + UtilsItems.getItemForOreDict("MorePlanet:mercury_item", "ingotMeteoricSteel", "Meteoric Steel Ingot", 3); + UtilsItems.getItemForOreDict("MorePlanet:sirius-b_item", "dustSulfur", "Sulfur Dust", 2); + + //Gems + UtilsItems.getItemForOreDict("MorePlanet:fronos_item", "gemBlackDiamond", "Black Diamond Gem", 2); + UtilsItems.getItemForOreDict("MorePlanet:koentus_item", "gemWhiteCrystal", "White Crystal", 0); + UtilsItems.getItemForOreDict("MorePlanet:nibiru_item", "gemRedCrystal", "Red Crystal", 0); + UtilsItems.getItemForOreDict("MorePlanet:pluto_item", "gemXeonius", "Xeonius Gem", 0); + UtilsItems.getItemForOreDict("MorePlanet:kapteyn-b_item", "gemUranium", "Uranium Gem", 1); + } + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_PneumaticCraft.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_PneumaticCraft.java new file mode 100644 index 0000000000..d471535e81 --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_PneumaticCraft.java @@ -0,0 +1,17 @@ +package gtPlusPlus.core.common.compat; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; +import net.minecraft.item.ItemStack; + +public class COMPAT_PneumaticCraft { + + public static void OreDict(){ + run(); + } + + private static final void run(){ + GT_OreDictUnificator.registerOre("plateCompressedIron", new ItemStack(ModItems.itemPlateCompressedIron)); + } + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_RFTools.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_RFTools.java new file mode 100644 index 0000000000..4db8006a89 --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_RFTools.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.common.compat; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; +import net.minecraft.item.ItemStack; + +public class COMPAT_RFTools { + + public static void OreDict(){ + run(); + } + + private static final void run(){ + GT_OreDictUnificator.registerOre("plateDimensionShard", new ItemStack(ModItems.itemPlateDimensionShard)); + + } + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_SimplyJetpacks.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_SimplyJetpacks.java new file mode 100644 index 0000000000..6d7f08b55d --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_SimplyJetpacks.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.common.compat; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; +import net.minecraft.item.ItemStack; + +public class COMPAT_SimplyJetpacks { + + public static void OreDict(){ + run(); + } + + private static final void run(){ + GT_OreDictUnificator.registerOre("plateEnrichedSoularium", new ItemStack(ModItems.itemPlateEnrichedSoularium)); + + } + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java new file mode 100644 index 0000000000..87fde9fa96 --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java @@ -0,0 +1,47 @@ +package gtPlusPlus.core.common.compat; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.lib.CORE.configSwitches; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.item.ItemStack; + +public class COMPAT_Thaumcraft { + + public static void OreDict(){ + UtilsItems.getItemForOreDict("Thaumcraft:ItemResource", "ingotVoidMetal", "Void Metal Ingot", 16); + GT_OreDictUnificator.registerOre("plateVoidMetal", new ItemStack(ModItems.itemPlateVoidMetal)); + if (configSwitches.enableThaumcraftShardUnification){ + run(); + } + } + + private static final void run(){ + + for(int i=0; i<=6; i++){ + //Utils.LOG_INFO(""+i); + UtilsItems.getItemForOreDict("Thaumcraft:ItemShard", "shardAny", "TC Shard "+i, i); + GT_OreDictUnificator.registerOre("shardAny", UtilsItems.getItemStack("Thaumcraft:ItemShard:"+i, 1)); + UtilsItems.getItemForOreDict("Thaumcraft:ItemShard", "gemInfusedAnything", "TC Shard "+i, i); + GT_OreDictUnificator.registerOre("gemInfusedAnything", UtilsItems.getItemStack("Thaumcraft:ItemShard:"+i, 1)); + //System.out.println("TC Shard registration count is: "+i); + } + + if (LoadedMods.ForbiddenMagic){ + for(int i=0; i<=6; i++){ + //Utils.LOG_INFO(""+i); + UtilsItems.getItemForOreDict("ForbiddenMagic:NetherShard", "shardAny", "FM Shard "+i, i); + GT_OreDictUnificator.registerOre("shardAny", UtilsItems.getItemStack("ForbiddenMagic:NetherShard:"+i, 1)); + UtilsItems.getItemForOreDict("ForbiddenMagic:NetherShard", "gemInfusedAnything", "FM Shard "+i, i); + GT_OreDictUnificator.registerOre("gemInfusedAnything", UtilsItems.getItemStack("ForbiddenMagic:NetherShard:"+i, 1)); + //System.out.println("TC Shard registration count is: "+i); + } + UtilsItems.getItemForOreDict("ForbiddenMagic:GluttonyShard", "shardAny", "FM Gluttony Shard", 0); + GT_OreDictUnificator.registerOre("shardAny", UtilsItems.getItemStack("ForbiddenMagic:GluttonyShard", 1)); + UtilsItems.getItemForOreDict("ForbiddenMagic:GluttonyShard", "gemInfusedAnything", "FM Gluttony Shard", 0); + GT_OreDictUnificator.registerOre("gemInfusedAnything", UtilsItems.getItemStack("ForbiddenMagic:GluttonyShard", 1)); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/container/Container_BackpackBase.java b/src/Java/gtPlusPlus/core/container/Container_BackpackBase.java new file mode 100644 index 0000000000..f156f6dcaf --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_BackpackBase.java @@ -0,0 +1,206 @@ +package gtPlusPlus.core.container; + +import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.slots.SlotItemBackpackInv; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class Container_BackpackBase extends Container +{ + /** The Item Inventory for this Container, only needed if you want to reference isUseableByPlayer */ + public final BaseInventoryBackpack inventory; + + /** Using these will make transferStackInSlot easier to understand and implement + * INV_START is the index of the first slot in the Player's Inventory, so our + * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4, so start at 5) + * Notice how we don't have to remember how many slots we made? We can just use + * BaseInventoryBackpack.INV_SIZE and if we ever change it, the Container updates automatically. */ + private static final int INV_START = BaseInventoryBackpack.INV_SIZE, INV_END = INV_START+26, + HOTBAR_START = INV_END+1, HOTBAR_END = HOTBAR_START+8; + + // If you're planning to add armor slots, put those first like this: + // ARMOR_START = BaseInventoryBackpack.INV_SIZE, ARMOR_END = ARMOR_START+3, + // INV_START = ARMOR_END+1, and then carry on like above. + + public Container_BackpackBase(EntityPlayer par1Player, InventoryPlayer inventoryPlayer, BaseInventoryBackpack inventoryItem) + { + this.inventory = inventoryItem; + + int i; + + // ITEM INVENTORY - you'll need to adjust the slot locations to match your texture file + // I have them set vertically in columns of 4 to the right of the player model + for (i = 0; i < BaseInventoryBackpack.INV_SIZE; ++i) + { + // You can make a custom Slot if you need different behavior, + // such as only certain item types can be put into this slot + // We made a custom slot to prevent our inventory-storing item + // from being stored within itself, but if you want to allow that and + // you followed my advice at the end of the above step, then you + // could get away with using the vanilla Slot class + this.addSlotToContainer(new SlotItemBackpackInv(this.inventory, i, 80 + (18 * (int)(i/4)), 8 + (18*(i%4)))); + } + + // If you want, you can add ARMOR SLOTS here as well, but you need to + // make a public version of SlotArmor. I won't be doing that in this tutorial. + /* + for (i = 0; i < 4; ++i) + { + // These are the standard positions for survival inventory layout + this.addSlotToContainer(new SlotArmor(this.player, inventoryPlayer, inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18, i)); + } + */ + + // PLAYER INVENTORY - uses default locations for standard inventory texture file + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + // PLAYER ACTION BAR - uses default locations for standard action bar texture file + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + // be sure to return the inventory's isUseableByPlayer method + // if you defined special behavior there: + return inventory.isUseableByPlayer(entityplayer); + } + + /** + * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. + */ + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int index) + { + ItemStack itemstack = null; + Slot slot = (Slot) this.inventorySlots.get(index); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + // If item is in our custom Inventory or armor slot + if (index < INV_START) + { + // try to place in player inventory / action bar + if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END+1, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + // Item is in inventory / hotbar, try to place in custom inventory or armor slots + else + { + /* + If your inventory only stores certain instances of Items, + you can implement shift-clicking to your inventory like this: + + // Check that the item is the right type + if (itemstack1.getItem() instanceof ItemCustom) + { + // Try to merge into your custom inventory slots + // We use 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case + // you also add armor or other custom slots + if (!this.mergeItemStack(itemstack1, 0, BaseInventoryBackpack.INV_SIZE, false)) + { + return null; + } + } + // If you added armor slots, check them here as well: + // Item being shift-clicked is armor - try to put in armor slot + if (itemstack1.getItem() instanceof ItemArmor) + { + int type = ((ItemArmor) itemstack1.getItem()).armorType; + if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false)) + { + return null; + } + } + Otherwise, you have basically 2 choices: + 1. shift-clicking between player inventory and custom inventory + 2. shift-clicking between action bar and inventory + + Be sure to choose only ONE of the following implementations!!! + */ + /** + * Implementation number 1: Shift-click into your custom inventory + */ + if (index >= INV_START) + { + // place in custom inventory + if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) + { + return null; + } + } + + /** + * Implementation number 2: Shift-click items between action bar and inventory + */ + // item is in player's inventory, but not in action bar + if (index >= INV_START && index < HOTBAR_START) + { + // place in action bar + if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END+1, false)) + { + return null; + } + } + // item in action bar - place in player inventory + else if (index >= HOTBAR_START && index < HOTBAR_END+1) + { + if (!this.mergeItemStack(itemstack1, INV_START, INV_END+1, false)) + { + return null; + } + } + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + /** + * You should override this method to prevent the player from moving the stack that + * opened the inventory, otherwise if the player moves it, the inventory will not + * be able to save properly + */ + @Override + public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) { + // this will prevent the player from interacting with the item that opened the inventory: + if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) { + return null; + } + return super.slotClick(slot, button, flag, player); + } +} diff --git a/src/Java/gtPlusPlus/core/container/Container_Charger.java b/src/Java/gtPlusPlus/core/container/Container_Charger.java new file mode 100644 index 0000000000..4b6c43ada6 --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_Charger.java @@ -0,0 +1,81 @@ +package gtPlusPlus.core.container; + +import gtPlusPlus.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/gtPlusPlus/core/container/Container_NHG.java b/src/Java/gtPlusPlus/core/container/Container_NHG.java new file mode 100644 index 0000000000..64a84ce680 --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_NHG.java @@ -0,0 +1,104 @@ +package gtPlusPlus.core.container; + +import gtPlusPlus.core.tileentities.machines.TileEntityNHG; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.inventory.SlotFurnace; +import net.minecraft.item.ItemStack; + +public class Container_NHG extends Container +{ + private TileEntityNHG te; + + public static final int INPUT_1 = 0, INPUT_2 = 1, INPUT_3 = 2, + INPUT_4 = 3, INPUT_5 = 4, INPUT_6 = 5, + INPUT_7 = 6, INPUT_8 = 7, INPUT_9 = 8, + INPUT_10 = 9, INPUT_11 = 10, INPUT_12 = 11, + INPUT_13 = 12, INPUT_14 = 13, INPUT_15 = 14, + INPUT_16 = 15, INPUT_17 = 16, INPUT_18 = 17, + OUTPUT = 18; + + private int slotID = 0; + + public Container_NHG(TileEntityNHG te, EntityPlayer player) + { + this.te = te; + + + //Fuel Rods A + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + addSlotToContainer(new Slot(te, slotID++, 8 + j * 18, 17 + i * 18)); + } + } + //Fuel Rods B + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + addSlotToContainer(new Slot(te, slotID++, 116 + j * 18, 17 + i * 18)); + } + } + + //Output + addSlotToContainer(new SlotFurnace(player, te, OUTPUT, 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/gtPlusPlus/core/creative/AddToCreativeTab.java b/src/Java/gtPlusPlus/core/creative/AddToCreativeTab.java new file mode 100644 index 0000000000..31613f2b85 --- /dev/null +++ b/src/Java/gtPlusPlus/core/creative/AddToCreativeTab.java @@ -0,0 +1,31 @@ +package gtPlusPlus.core.creative; + +import gtPlusPlus.core.creative.tabs.MiscUtilCreativeTabBlock; +import gtPlusPlus.core.creative.tabs.MiscUtilCreativeTabMachines; +import gtPlusPlus.core.creative.tabs.MiscUtilCreativeTabMisc; +import gtPlusPlus.core.creative.tabs.MiscUtilCreativeTabOther; +import gtPlusPlus.core.creative.tabs.MiscUtilCreativeTabTools; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.creativetab.CreativeTabs; + +public class AddToCreativeTab { + + public static CreativeTabs tabBlock; + public static CreativeTabs tabMisc; + public static CreativeTabs tabCombat; + public static CreativeTabs tabTools; + public static CreativeTabs tabMachines; + public static CreativeTabs tabOther; + + public static void initialiseTabs(){ + tabBlock = new MiscUtilCreativeTabBlock("MiscUtilBlockTab"); + tabMisc = new MiscUtilCreativeTabMisc("MiscUtilMiscTab"); + tabTools = new MiscUtilCreativeTabTools("MiscUtilToolsTab"); + tabMachines = new MiscUtilCreativeTabMachines("MiscUtilMachineTab"); + tabOther = new MiscUtilCreativeTabOther("MiscUtilOtherTab"); + + if (CORE.DEBUG){ + //tabCombat = new MiscUtilCreativeTabCombat("MiscUtilCombatTab"); + } + } +} diff --git a/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabBlock.java b/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabBlock.java new file mode 100644 index 0000000000..1220fb1af8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabBlock.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.creative.tabs; + +import gtPlusPlus.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.MatterFabricatorEffectBlock); + } + +} diff --git a/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMachines.java b/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMachines.java new file mode 100644 index 0000000000..932f80ed7f --- /dev/null +++ b/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMachines.java @@ -0,0 +1,19 @@ +package gtPlusPlus.core.creative.tabs; + +import gtPlusPlus.core.item.ModItems; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class MiscUtilCreativeTabMachines extends CreativeTabs { + + + public MiscUtilCreativeTabMachines(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return ModItems.itemPLACEHOLDER_Circuit; + } + +} diff --git a/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMisc.java b/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMisc.java new file mode 100644 index 0000000000..619803e6e1 --- /dev/null +++ b/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMisc.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.creative.tabs; + +import gtPlusPlus.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.itemFoodCurriedSausages; + } + +} diff --git a/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabOther.java b/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabOther.java new file mode 100644 index 0000000000..6b7c55fcb8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabOther.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.creative.tabs; + +import gtPlusPlus.core.item.ModItems; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class MiscUtilCreativeTabOther extends CreativeTabs { + + public MiscUtilCreativeTabOther(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return ModItems.backpack_Green; + } + +} diff --git a/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabTools.java b/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabTools.java new file mode 100644 index 0000000000..fe61ea6f11 --- /dev/null +++ b/src/Java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabTools.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.creative.tabs; + +import gtPlusPlus.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/gtPlusPlus/core/entity/EntityTeleportFX.java b/src/Java/gtPlusPlus/core/entity/EntityTeleportFX.java new file mode 100644 index 0000000000..eff516c289 --- /dev/null +++ b/src/Java/gtPlusPlus/core/entity/EntityTeleportFX.java @@ -0,0 +1,236 @@ +package gtPlusPlus.core.entity; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class EntityTeleportFX extends Entity +{ + /** 'x' location the eye should float towards. */ + private double targetX; + /** 'y' location the eye should float towards. */ + private double targetY; + /** 'z' location the eye should float towards. */ + private double targetZ; + private int despawnTimer; + private boolean shatterOrDrop; + private static final String __OBFID = "CL_00001716"; + + public EntityTeleportFX(World p_i1757_1_) + { + super(p_i1757_1_); + this.setSize(0.25F, 0.25F); + } + + protected void entityInit() {} + + /** + * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge + * length * 64 * renderDistanceWeight Args: distance + */ + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double p_70112_1_) + { + double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return p_70112_1_ < d1 * d1; + } + + public EntityTeleportFX(World p_i1758_1_, double p_i1758_2_, double p_i1758_4_, double p_i1758_6_) + { + super(p_i1758_1_); + this.despawnTimer = 0; + this.setSize(0.25F, 0.25F); + this.setPosition(p_i1758_2_, p_i1758_4_, p_i1758_6_); + this.yOffset = 0.0F; + } + + /** + * The location the eye should float/move towards. Currently used for moving towards the nearest stronghold. Args: + * strongholdX, strongholdY, strongholdZ + */ + public void moveTowards(double p_70220_1_, int p_70220_3_, double p_70220_4_) + { + double d2 = p_70220_1_ - this.posX; + double d3 = p_70220_4_ - this.posZ; + float f = MathHelper.sqrt_double(d2 * d2 + d3 * d3); + + if (f > 12.0F) + { + this.targetX = this.posX + d2 / (double)f * 12.0D; + this.targetZ = this.posZ + d3 / (double)f * 12.0D; + this.targetY = this.posY + 8.0D; + } + else + { + this.targetX = p_70220_1_; + this.targetY = (double)p_70220_3_; + this.targetZ = p_70220_4_; + } + + this.despawnTimer = 0; + this.shatterOrDrop = this.rand.nextInt(5) > 0; + } + + /** + * Sets the velocity to the args. Args: x, y, z + */ + @SideOnly(Side.CLIENT) + public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) + { + this.motionX = p_70016_1_; + this.motionY = p_70016_3_; + this.motionZ = p_70016_5_; + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI); + } + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + this.lastTickPosX = this.posX; + this.lastTickPosY = this.posY; + this.lastTickPosZ = this.posZ; + super.onUpdate(); + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + + for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + + if (!this.worldObj.isRemote) + { + double d0 = this.targetX - this.posX; + double d1 = this.targetZ - this.posZ; + float f1 = (float)Math.sqrt(d0 * d0 + d1 * d1); + float f2 = (float)Math.atan2(d1, d0); + double d2 = (double)f + (double)(f1 - f) * 0.0025D; + + if (f1 < 1.0F) + { + d2 *= 0.8D; + this.motionY *= 0.8D; + } + + this.motionX = Math.cos((double)f2) * d2; + this.motionZ = Math.sin((double)f2) * d2; + + if (this.posY < this.targetY) + { + this.motionY += (1.0D - this.motionY) * 0.014999999664723873D; + } + else + { + this.motionY += (-1.0D - this.motionY) * 0.014999999664723873D; + } + } + + float f3 = 0.25F; + + if (this.isInWater()) + { + for (int i = 0; i < 4; ++i) + { + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ); + } + } + else + { + this.worldObj.spawnParticle("portal", this.posX - this.motionX * (double)f3 + this.rand.nextDouble() * 0.6D - 0.3D, this.posY - this.motionY * (double)f3 - 0.5D, this.posZ - this.motionZ * (double)f3 + this.rand.nextDouble() * 0.6D - 0.3D, this.motionX, this.motionY, this.motionZ); + } + + if (!this.worldObj.isRemote) + { + this.setPosition(this.posX, this.posY, this.posZ); + ++this.despawnTimer; + + if (this.despawnTimer > 80 && !this.worldObj.isRemote) + { + this.setDead(); + + if (this.shatterOrDrop) + { + this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(Items.ender_eye))); + } + else + { + this.worldObj.playAuxSFX(2003, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), 0); + } + } + } + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT(NBTTagCompound p_70014_1_) {} + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT(NBTTagCompound p_70037_1_) {} + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + /** + * Gets how bright this entity is. + */ + public float getBrightness(float p_70013_1_) + { + return 1.0F; + } + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float p_70070_1_) + { + return 15728880; + } + + /** + * If returns false, the item will not inflict any damage against entities. + */ + public boolean canAttackWithItem() + { + return false; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/gui/beta/Gui_ID_Registry.java b/src/Java/gtPlusPlus/core/gui/beta/Gui_ID_Registry.java new file mode 100644 index 0000000000..b3531ceb3e --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/beta/Gui_ID_Registry.java @@ -0,0 +1,56 @@ +package gtPlusPlus.core.gui.beta; + +import gtPlusPlus.core.interfaces.IGuiManagerMiscUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Gui_ID_Registry +{ + private static final Map<Class<? extends IGuiManagerMiscUtils>, MU_GuiId> classMap = new HashMap(); + private static final Map<Integer, MU_GuiId> idMap = new HashMap(); + private static int nextId = 0; + + static + { + //registerGuiHandlers(Gui_Types.Tile, Arrays.asList(new Class[] {TileAlveary.class})); + //registerGuiHandlers(MU_GuiType.Item, Arrays.asList(new Class[] { ItemBackpack.class, ItemBackpackNaturalist.class, ItemBeealyzer.class, ItemCatalogue.class, ItemFlutterlyzer.class, ItemHabitatLocator.class, ItemImprinter.class, ItemInfuser.class, ItemLetter.class, ItemSolderingIron.class, ItemTreealyzer.class })); + //registerGuiHandlers(MU_GuiType.Entity, Arrays.asList(new Class[] { EntityMinecartApiary.class, EntityMinecartBeehouse.class })); + } + + private static void registerGuiHandlers(Gui_Types MU_GuiType, List<Class<? extends IGuiManagerMiscUtils>> guiHandlerClasses) + { + for (Class<? extends IGuiManagerMiscUtils> tileGuiHandlerClass : guiHandlerClasses) + { + MU_GuiId guiId = new MU_GuiId(nextId++, MU_GuiType, tileGuiHandlerClass); + classMap.put(tileGuiHandlerClass, guiId); + idMap.put(Integer.valueOf(guiId.getId()), guiId); + } + } + + public static MU_GuiId getGuiIdForGuiHandler(IGuiManagerMiscUtils guiHandler) + { + Class<? extends IGuiManagerMiscUtils> guiHandlerClass = guiHandler.getClass(); + MU_GuiId guiId = (MU_GuiId)classMap.get(guiHandlerClass); + if (guiId == null) { + for (Map.Entry<Class<? extends IGuiManagerMiscUtils>, MU_GuiId> classGuiIdEntry : classMap.entrySet()) { + if (((Class)classGuiIdEntry.getKey()).isAssignableFrom(guiHandlerClass)) + { + guiId = (MU_GuiId)classGuiIdEntry.getValue(); + break; + } + } + } + if (guiId == null) { + throw new IllegalStateException("No gui ID for gui handler: " + guiHandler); + } + return guiId; + } + + public static MU_GuiId getGuiId(int id) + { + return (MU_GuiId)idMap.get(Integer.valueOf(id)); + } + +} diff --git a/src/Java/gtPlusPlus/core/gui/beta/Gui_Types.java b/src/Java/gtPlusPlus/core/gui/beta/Gui_Types.java new file mode 100644 index 0000000000..428cae93d5 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/beta/Gui_Types.java @@ -0,0 +1,8 @@ +package gtPlusPlus.core.gui.beta; + +public enum Gui_Types + { + Item, Tile, Entity; + + private Gui_Types() {} + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/gui/beta/MU_GuiId.java b/src/Java/gtPlusPlus/core/gui/beta/MU_GuiId.java new file mode 100644 index 0000000000..7d17870743 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/beta/MU_GuiId.java @@ -0,0 +1,32 @@ +package gtPlusPlus.core.gui.beta; +import gtPlusPlus.core.interfaces.IGuiManagerMiscUtils; + +public class MU_GuiId + { + private final int id; + private final Gui_Types MU_GuiType; + private final Class<? extends IGuiManagerMiscUtils> guiHandlerClass; + + MU_GuiId(int id, Gui_Types MU_GuiType, Class<? extends IGuiManagerMiscUtils> guiHandlerClass) + { + this.id = id; + this.MU_GuiType = MU_GuiType; + this.guiHandlerClass = guiHandlerClass; + } + + public Gui_Types getGuiType() + { + return this.MU_GuiType; + } + + public Class<? extends IGuiManagerMiscUtils> getGuiHandlerClass() + { + return this.guiHandlerClass; + } + + public int getId() + { + return this.id; + } + } + diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiBaseBackpack.java b/src/Java/gtPlusPlus/core/gui/item/GuiBaseBackpack.java new file mode 100644 index 0000000000..9f1b775fb0 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/item/GuiBaseBackpack.java @@ -0,0 +1,122 @@ +package gtPlusPlus.core.gui.item; + +import gtPlusPlus.core.container.Container_BackpackBase; +import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import com.sun.org.apache.xml.internal.security.utils.I18n; + +public class GuiBaseBackpack extends GuiContainer +{ + /** x and y size of the inventory window in pixels. Defined as float, passed as int + * These are used for drawing the player model. */ + private float xSize_lo; + private float ySize_lo; + + /** The FontRenderer used by GuiScreen */ + protected FontRenderer fontRenderer; + + /** ResourceLocation takes 2 parameters: ModId, path to texture at the location: + * "src/minecraft/assets/modid/" + * + * I have provided a sample texture file that works with this tutorial. Download it + * from Forge_Tutorials/textures/gui/ + */ + private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID, "textures/gui/itemBackpack.png"); + + /** The inventory to render on screen */ + private final BaseInventoryBackpack inventory; + + public GuiBaseBackpack(Container_BackpackBase containerItem) + { + super(containerItem); + this.inventory = containerItem.inventory; + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(int par1, int par2, float par3) + { + super.drawScreen(par1, par2, par3); + this.xSize_lo = (float)par1; + this.ySize_lo = (float)par2; + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + String s = this.inventory.hasCustomInventoryName() ? this.inventory.getInventoryName() : I18n.translate(this.inventory.getInventoryName()); + //this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 0, 4210752); + //this.fontRenderer.drawString(I18n.translate("container.inventory"), 26, this.ySize - 96 + 4, 4210752); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + int i1; + drawPlayerModel(k + 51, l + 75, 30, (float)(k + 51) - this.xSize_lo, (float)(l + 75 - 50) - this.ySize_lo, this.mc.thePlayer); + } + + /** + * This renders the player model in standard inventory position (in later versions of Minecraft / Forge, you can + * simply call GuiInventory.drawEntityOnScreen directly instead of copying this code) + */ + public static void drawPlayerModel(int x, int y, int scale, float yaw, float pitch, EntityLivingBase entity) { + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, 50.0F); + GL11.glScalef(-scale, scale, scale); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + float f2 = entity.renderYawOffset; + float f3 = entity.rotationYaw; + float f4 = entity.rotationPitch; + float f5 = entity.prevRotationYawHead; + float f6 = entity.rotationYawHead; + GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F); + entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F; + entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F; + entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F; + entity.rotationYawHead = entity.rotationYaw; + entity.prevRotationYawHead = entity.rotationYaw; + GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); + RenderManager.instance.playerViewY = 180.0F; + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); + entity.renderYawOffset = f2; + entity.rotationYaw = f3; + entity.rotationPitch = f4; + entity.prevRotationYawHead = f5; + entity.rotationYawHead = f6; + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } +} diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_Charger.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_Charger.java new file mode 100644 index 0000000000..c1f687c554 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_Charger.java @@ -0,0 +1,50 @@ +package gtPlusPlus.core.gui.machine; + +import gtPlusPlus.core.container.Container_Charger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.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/gtPlusPlus/core/gui/machine/GUI_NHG.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_NHG.java new file mode 100644 index 0000000000..09b2ee93d8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_NHG.java @@ -0,0 +1,50 @@ +package gtPlusPlus.core.gui.machine; + +import gtPlusPlus.core.container.Container_NHG; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityNHG; +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_NHG extends GuiContainer +{ + private ResourceLocation texture = new ResourceLocation(CORE.MODID, "textures/gui/helium_collector_gui_12.png"); + + private InventoryPlayer inventory; + private TileEntityNHG te; + + public GUI_NHG(TileEntityNHG te, EntityPlayer player) + { + super(new Container_NHG(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("CoreTemp:"+te.getCoreTemp()+"K"), 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/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java new file mode 100644 index 0000000000..92003cbcad --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -0,0 +1,155 @@ +package gtPlusPlus.core.handler; + +import static gtPlusPlus.core.lib.LoadedMods.Gregtech; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.common.compat.COMPAT_BigReactors; +import gtPlusPlus.core.common.compat.COMPAT_CompactWindmills; +import gtPlusPlus.core.common.compat.COMPAT_EnderIO; +import gtPlusPlus.core.common.compat.COMPAT_ExtraUtils; +import gtPlusPlus.core.common.compat.COMPAT_IC2; +import gtPlusPlus.core.common.compat.COMPAT_MorePlanets; +import gtPlusPlus.core.common.compat.COMPAT_PneumaticCraft; +import gtPlusPlus.core.common.compat.COMPAT_RFTools; +import gtPlusPlus.core.common.compat.COMPAT_SimplyJetpacks; +import gtPlusPlus.core.common.compat.COMPAT_Thaumcraft; +import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; +import gtPlusPlus.core.handler.Recipes.RegistrationHandler; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.recipe.RECIPES_GREGTECH; +import gtPlusPlus.core.recipe.RECIPES_LaserEngraver; +import gtPlusPlus.core.recipe.ShapedRecipeObject; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechDehydrator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechEnergyBuffer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialCentrifuge; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialCokeOven; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialElectrolyzer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMacerator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMassFabricator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialPlatePress; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialWiremill; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIronBlastFurnace; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechPowerSubStation; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRocketFuelGenerator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSafeBlock; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSolarGenerators; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSteamCondenser; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSuperConductionPoint; + +import java.util.LinkedList; +import java.util.Queue; + +import net.minecraft.item.ItemStack; + +public class COMPAT_HANDLER { + + public static Queue<Object> RemoveRecipeQueue = new LinkedList<Object>(); + public static Queue<ShapedRecipeObject> AddRecipeQueue = new LinkedList<ShapedRecipeObject>(); + public static Boolean areInitItemsLoaded = false; + + + public static void registerMyModsOreDictEntries(){ + + Utils.LOG_INFO("Registering Materials with OreDict."); + //In-house + + //tools + GT_OreDictUnificator.registerOre("craftingToolSandHammer", new ItemStack(ModItems.itemSandstoneHammer)); + GT_OreDictUnificator.registerOre("ingotBloodSteel", new ItemStack(ModItems.itemIngotBloodSteel)); + GT_OreDictUnificator.registerOre("ingotStaballoy", new ItemStack(ModItems.itemIngotStaballoy)); + + //Plates + GT_OreDictUnificator.registerOre("plateBloodSteel", new ItemStack(ModItems.itemPlateBloodSteel)); + GT_OreDictUnificator.registerOre("plateStaballoy", new ItemStack(ModItems.itemPlateStaballoy)); + + //Blocks + //GT_OreDictUnificator.registerOre("blockStaballoy", new ItemStack(Item.getItemFromBlock(ModBlocks.blockStaballoy))); + //OreDictionary.registerOre("blockBloodSteel", new ItemStack(ModBlocks.blockBloodSteel)); + + + for(int i=1; i<=10; i++){ + GT_OreDictUnificator.registerOre("bufferCore_"+CORE.VOLTAGES[i-1], new ItemStack(UtilsItems.getItem("miscutils:item.itemBufferCore"+i))); + } + } + + public static void registerGregtechMachines() { + if (Gregtech) { + new RECIPES_LaserEngraver(); + GregtechEnergyBuffer.run(); + GregtechSteamCondenser.run(); + GregtechSafeBlock.run(); + GregtechSuperConductionPoint.run(); + GregtechIronBlastFurnace.run(); + GregtechIndustrialCentrifuge.run(); + GregtechIndustrialCokeOven.run(); + GregtechIndustrialPlatePress.run(); + GregtechRocketFuelGenerator.run(); + GregtechIndustrialElectrolyzer.run(); + GregtechIndustrialMacerator.run(); + GregtechIndustrialWiremill.run(); + GregtechIndustrialMassFabricator.run(); + //GregtechIndustrialSinter.run(); + GregtechSolarGenerators.run(); + GregtechPowerSubStation.run(); + GregtechDehydrator.run(); + } + + } + + //InterMod + public static void intermodOreDictionarySupport(){ + + if (LoadedMods.Big_Reactors){ + COMPAT_BigReactors.OreDict(); + } + if (LoadedMods.EnderIO){ + COMPAT_EnderIO.OreDict(); + } + if (LoadedMods.MorePlanets){ + COMPAT_MorePlanets.OreDict(); + } + if (LoadedMods.Simply_Jetpacks){ + COMPAT_SimplyJetpacks.OreDict(); + } + if (LoadedMods.RFTools){ + COMPAT_RFTools.OreDict(); + } + if (LoadedMods.Thaumcraft){ + COMPAT_Thaumcraft.OreDict(); + } + if (LoadedMods.Extra_Utils){ + COMPAT_ExtraUtils.OreDict(); + } + if (LoadedMods.PneumaticCraft){ + COMPAT_PneumaticCraft.OreDict(); + } + if (LoadedMods.CompactWindmills){ + COMPAT_CompactWindmills.OreDict(); + } + if (LoadedMods.IndustrialCraft2){ + COMPAT_IC2.OreDict(); + } + } + + public static void RemoveRecipesFromOtherMods(){ + //Removal of Recipes + for(Object item : RemoveRecipeQueue){ + UtilsRecipe.removeCraftingRecipe(item); + } + } + + public static void InitialiseHandlerThenAddRecipes(){ + RegistrationHandler.run(); + } + public static void InitialiseLateHandlerThenAddRecipes(){ + LateRegistrationHandler.run(); + } + + public static void startLoadingGregAPIBasedRecipes(){ + RECIPES_GREGTECH.run(); + } +} diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java new file mode 100644 index 0000000000..97b7369134 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -0,0 +1,41 @@ +package gtPlusPlus.core.handler; + +import gtPlusPlus.xmod.forestry.HANDLER_FR; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; +import gtPlusPlus.xmod.growthcraft.HANDLER_GC; +import gtPlusPlus.xmod.ic2.HANDLER_IC2; +import gtPlusPlus.xmod.psychedelicraft.HANDLER_Psych; +import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; + +public class COMPAT_IntermodStaging { + + public static void preInit(){ + HANDLER_GT.preInit(); + HANDLER_GC.preInit(); + HANDLER_TF.preInit(); + HANDLER_FR.preInit(); + HANDLER_Psych.preInit(); + HANDLER_IC2.preInit(); + + } + + public static void init(){ + HANDLER_GT.init(); + HANDLER_GC.init(); + HANDLER_TF.init(); + HANDLER_FR.Init(); + HANDLER_Psych.init(); + HANDLER_IC2.init(); + } + + public static void postInit(){ + HANDLER_GT.postInit(); + HANDLER_GC.postInit(); + HANDLER_TF.postInit(); + HANDLER_FR.postInit(); + HANDLER_Psych.postInit(); + HANDLER_IC2.postInit(); + } + + +} diff --git a/src/Java/gtPlusPlus/core/handler/CraftingManager.java b/src/Java/gtPlusPlus/core/handler/CraftingManager.java new file mode 100644 index 0000000000..bd0f114b1a --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/CraftingManager.java @@ -0,0 +1,17 @@ +package gtPlusPlus.core.handler; + +public class CraftingManager { + + public static void mainRegistry() { + addCraftingRecipies(); + addSmeltingRecipies(); + } + + public static void addCraftingRecipies() { + + } + + public static void addSmeltingRecipies() { + + } +} diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java new file mode 100644 index 0000000000..7c9c7a7625 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -0,0 +1,128 @@ +package gtPlusPlus.core.handler; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.container.Container_BackpackBase; +import gtPlusPlus.core.gui.beta.Gui_ID_Registry; +import gtPlusPlus.core.gui.beta.MU_GuiId; +import gtPlusPlus.core.gui.item.GuiBaseBackpack; +import gtPlusPlus.core.interfaces.IGuiManager; +import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.forestry.bees.alveary.TileAlvearyFrameHousing; +import gtPlusPlus.xmod.forestry.bees.alveary.gui.CONTAINER_FrameHousing; +import gtPlusPlus.xmod.forestry.bees.alveary.gui.GUI_FrameHousing; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.network.NetworkRegistry; + +public class GuiHandler implements IGuiHandler { + + public static final int GUI1 = 0; //Frame Alveary + public static final int GUI2 = 1; //RTG + public static final int GUI3 = 2; //BackpackHandler + public static final int GUI4 = 3; // + public static final int GUI5 = 4; // + public static final int GUI6 = 5; // + public static final int GUI7 = 6; // + public static final int GUI8 = 7; // + + + + public static void init(){ + + Utils.LOG_INFO("Registering GUIs."); + NetworkRegistry.INSTANCE.registerGuiHandler(GTplusplus.instance, new GuiHandler()); + //Register GuiHandler + //NetworkRegistry.INSTANCE.registerGuiHandler(GTplusplus.instance, new GuiHandler()); + } + + + @Override //ContainerModTileEntity + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + + if (te != null){ + if (ID == GUI1){ + if (CORE.configSwitches.enableCustomAlvearyBlocks){ + return new CONTAINER_FrameHousing((TileAlvearyFrameHousing)te, player); + } + } + else if (ID == GUI2){ + //return new CONTAINER_RTG(player, (TileEntityRTG)te); + } + + + } + + if (ID == GUI3) + { + // Use the player's held item to create the inventory + return new Container_BackpackBase(player, player.inventory, new BaseInventoryBackpack(player.getHeldItem())); + } + return null; + } + + @Override //GuiModTileEntity + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + Utils.LOG_WARNING("getClientGuiElement Called by: "+player+", in world: "+player.dimension+" at x:"+x+", y:"+y+", z:"+z+"."); + TileEntity te = world.getTileEntity(x, y, z); + if (te != null){ + if (ID == GUI1){ + if (CORE.configSwitches.enableCustomAlvearyBlocks){ + Utils.LOG_WARNING("Opening Gui with Id: "+ID+" Alveary Frame Housing"); + return new GUI_FrameHousing((TileAlvearyFrameHousing) te, player); + } + } + else if (ID == GUI2){ + Utils.LOG_WARNING("Opening Gui with Id: "+ID+" RTG"); + //return new GUI_RTG((TileEntityRTG) te.); + } + } + + if (ID == GUI3) + { + // We have to cast the new container as our custom class + // and pass in currently held item for the inventory + return new GuiBaseBackpack((Container_BackpackBase) new Container_BackpackBase(player, player.inventory, new BaseInventoryBackpack(player.getHeldItem()))); + } + + return null; + } + + + + //New Methods + public static void openGui(EntityPlayer entityplayer, IGuiManager guiHandler) + { + openGui(entityplayer, guiHandler, (short)0); + } + + public static void openGui(EntityPlayer entityplayer, IGuiManager guiHandler, short data) + { + int guiData = encodeGuiData(guiHandler, data); + ChunkCoordinates coordinates = guiHandler.getCoordinates(); + entityplayer.openGui(GTplusplus.instance, guiData, entityplayer.worldObj, coordinates.posX, coordinates.posY, coordinates.posZ); + } + + private static int encodeGuiData(IGuiManager guiHandler, short data) + { + MU_GuiId guiId = Gui_ID_Registry.getGuiIdForGuiHandler(guiHandler); + return data << 16 | guiId.getId(); + } + + private static MU_GuiId decodeGuiID(int guiData) + { + int guiId = guiData & 0xFF; + return Gui_ID_Registry.getGuiId(guiId); + } + + private static short decodeGuiData(int guiId) + { + return (short)(guiId >> 16); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java b/src/Java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java new file mode 100644 index 0000000000..7d739bdca3 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.handler.Recipes; + +import gtPlusPlus.core.handler.COMPAT_HANDLER; +import gtPlusPlus.core.recipe.ShapedRecipeObject; +import gtPlusPlus.core.util.Utils; + +public class LateRegistrationHandler { + + public static int recipesSuccess = 0; + public static int recipesFailed = 0; + + public static void run(){ + init(); + } + + private final static void init(){ + for(ShapedRecipeObject item : COMPAT_HANDLER.AddRecipeQueue){ + item.buildRecipe(); + } + try { + Thread.sleep(10); + } catch (InterruptedException e) { + Utils.LOG_INFO(e.toString()); + } + Utils.LOG_INFO("Late Recipes Loaded: "+recipesSuccess+" Failed: "+recipesFailed); + } + +} diff --git a/src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java b/src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java new file mode 100644 index 0000000000..affb56566d --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java @@ -0,0 +1,32 @@ +package gtPlusPlus.core.handler.Recipes; + +import gtPlusPlus.core.handler.COMPAT_HANDLER; +import gtPlusPlus.core.recipe.RECIPES_MachineComponents; +import gtPlusPlus.core.recipe.RECIPES_Machines; +import gtPlusPlus.core.recipe.RECIPES_Shapeless; +import gtPlusPlus.core.recipe.RECIPES_Tools; +import gtPlusPlus.core.recipe.RECIPE_Batteries; +import gtPlusPlus.core.util.Utils; + +public class RegistrationHandler { + + public static int recipesSuccess = 0; + public static int recipesFailed = 0; + + public static void run(){ + init(); + } + + private final static void init(){ + RECIPES_Tools.RECIPES_LOAD(); + RECIPES_Machines.RECIPES_LOAD(); + RECIPES_Shapeless.RECIPES_LOAD(); + RECIPES_MachineComponents.RECIPES_LOAD(); + RECIPE_Batteries.RECIPES_LOAD(); + //RECIPES_MTWRAPPER.run(); + Utils.LOG_INFO("Loaded: "+recipesSuccess+" Failed: "+recipesFailed); + COMPAT_HANDLER.areInitItemsLoaded = true; + //Utils.LOG_INFO("MT Loaded: "+RECIPES_MTWRAPPER.MT_RECIPES_LOADED+" MT Failed: "+RECIPES_MTWRAPPER.MT_RECIPES_FAILED); + } + +} diff --git a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java new file mode 100644 index 0000000000..9cf0cb8bb7 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java @@ -0,0 +1,84 @@ +package gtPlusPlus.core.handler.events; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerCache; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; + +public class LoginEventHandler { + + public String localPlayersName; + public UUID localPlayersUUID; + private EntityPlayer localPlayerRef; + + @SubscribeEvent + public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) { + + this.localPlayerRef = event.player; + this.localPlayersName = event.player.getDisplayName(); + this.localPlayersUUID = event.player.getUniqueID(); + + try { + + + if (localPlayerRef instanceof EntityPlayerMP && localPlayerRef != null){ + + //Populates player cache + if (!localPlayerRef.worldObj.isRemote){ + PlayerCache.appendParamChanges(localPlayersName, localPlayersUUID.toString()); + } + + + /*if (localPlayerRef.getCommandSenderName().toLowerCase().equalsIgnoreCase("ImQ009") || localPlayerRef.getCommandSenderName().toLowerCase().contains("player")){ + Utils.LOG_INFO("Spawning a new Santa Thread."); + Thread t = new Thread() { + UUID threadHandlerIDthing = localPlayersUUID; + @Override + public void run() { + while(true && Minecraft.getMinecraft().getIntegratedServer() != null) { + try { + if(localPlayerRef == null){ + localPlayerRef = Utils.getPlayerOnServerFromUUID(threadHandlerIDthing); + } + + + //ImQ009 is a legend. + if (localPlayerRef.getCommandSenderName().toLowerCase().equalsIgnoreCase("ImQ009")){ + Utils.messagePlayer(localPlayerRef, "Enjoy some complimentary Raisin Bread."); + localPlayerRef.inventory.addItemStackToInventory(UtilsItems.getSimpleStack(ModItems.itemIngotRaisinBread, MathUtils.randInt(1, 5))); + } + + + if (localPlayerRef.getCommandSenderName().toLowerCase().contains("player")){ + Utils.messagePlayer(localPlayerRef, "Enjoy some complimentary Raisin Bread."); + localPlayerRef.inventory.addItemStackToInventory(UtilsItems.getSimpleStack(ModItems.itemIngotRaisinBread, MathUtils.randInt(1, 5))); + } + Thread.sleep(1000*60*MathUtils.randInt(15, 90)); + } catch (InterruptedException ie) { + Utils.LOG_INFO("Santa Mode Disabled."); + } + } + + Utils.LOG_INFO("Thread Stopped. Handler Closed."); + + } + }; + //t.start(); + + + }*/ + + + } + } catch (Throwable errr){ + Utils.LOG_INFO("Login Handler encountered an error."); + + } + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java new file mode 100644 index 0000000000..a7c689a79a --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java @@ -0,0 +1,71 @@ +package gtPlusPlus.core.handler.events; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.BaseTileEntity; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase; + +import java.util.UUID; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.world.BlockEvent.BreakEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class PickaxeBlockBreakEventHandler { + @SubscribeEvent + public void onBreakBlock(BreakEvent event) { + try{ + TileEntity entity = event.world.getTileEntity(event.x, event.y, event.z); + if (entity != null && !entity.equals(null)){ + EntityPlayer playerInternal = event.getPlayer(); + Utils.LOG_WARNING(entity.getClass().getSimpleName()); + if (entity.getClass().getSimpleName().equals("")){ + + } + if (entity instanceof BaseTileEntity && !(entity instanceof BaseMetaPipeEntity)){ + IMetaTileEntity X = ((BaseMetaTileEntity)entity).getMetaTileEntity(); + Block ThisBlock = X.getBaseMetaTileEntity().getBlock(event.x, event.y, event.z); + if (X instanceof GregtechMetaSafeBlockBase){ + + UUID ownerUUID = ((GregtechMetaSafeBlockBase)X).ownerUUID; + UUID accessorUUID = playerInternal.getUniqueID(); + Utils.LOG_WARNING("Owner UUID: "+ownerUUID); + Utils.LOG_WARNING("Accessor UUID: "+accessorUUID); + + if (((GregtechMetaSafeBlockBase)X).bUnbreakable){ + + Utils.LOG_INFO("UUID info. Accessor: "+accessorUUID + " | Owner: "+ownerUUID); + + if (accessorUUID == ownerUUID){ + Utils.messagePlayer(playerInternal, "Since you own this block, it has been destroyed."); + event.setCanceled(false); + } + else { + event.setCanceled(true); + Utils.messagePlayer(playerInternal, "Since you do not own this block, it has not been destroyed."); + } + // + } + } + } + } + + } + catch (NullPointerException e) { + System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "+e.getCause()); + } + } + + + @SubscribeEvent + public void onPlayerInteraction(PlayerInteractEvent aEvent) { + if (aEvent.entityPlayer != null && aEvent.entityPlayer.worldObj != null && aEvent.action != null && aEvent.world.provider != null && !aEvent.entityPlayer.worldObj.isRemote && aEvent.action != null && aEvent.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR) { + //Utils.LOG_ERROR("Test"); + } + } +} diff --git a/src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java b/src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java new file mode 100644 index 0000000000..3e126d4463 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java @@ -0,0 +1,138 @@ +package gtPlusPlus.core.handler.events; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.BaseTileEntity; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GregtechMetaSafeBlock; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class UnbreakableBlockManager{ + + private static boolean hasRun = false; + + public final BaseMetaTileEntity getmTileEntity() { + return mTileEntity; + } + + + public final void setmTileEntity(BaseMetaTileEntity mTileEntity/*, EntityPlayer aPlayer*/) { + UnbreakableBlockManager.mTileEntity = mTileEntity; + if (!hasRun){ + hasRun = true; + makeIndestructible(/*aPlayer*/); + } + else { + Utils.LOG_WARNING("Why do you run twice?"); + } + } + + + //BaseMetaTileEntity + //GregtechMetaSafeBlock + private static BaseMetaTileEntity mTileEntity = null; + + + private void makeIndestructible(/*EntityPlayer aPlayer*/){ + + + Utils.LOG_WARNING("Initializing the code to set this TE to -1 hardness and make it indestructible."); + int X = ((BaseMetaTileEntity)mTileEntity).xCoord; //(GregtechMetaSafeBlock) this.mTileEntity.getXCoord(); + int Y = ((BaseMetaTileEntity)mTileEntity).yCoord; + int Z = ((BaseMetaTileEntity)mTileEntity).zCoord; + Utils.LOG_WARNING("Grabbing TileEntity @ [x,y,z] |"+X+"|"+Y+"|"+Z+"|"); + + + + try{ + GregtechMetaSafeBlock MetaSafeBlock = ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()); + TileEntity BaseMetaTileEntity = ((BaseMetaTileEntity)mTileEntity).getTileEntity(X, Y, Z); + //MetaSafeBlockBase. + World TE_WORLD = MetaSafeBlock.getBaseMetaTileEntity().getWorld(); + Utils.LOG_WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); + TileEntity entity = BaseMetaTileEntity; + innerInvincible(MetaSafeBlock, entity, TE_WORLD, /*aPlayer,*/ X, Y, Z); + } + catch (NullPointerException e) { + System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "); + e.printStackTrace(); + } + } + + + private static void innerInvincible(GregtechMetaSafeBlock MetaSafeBlock, TileEntity entity, World TE_WORLD, /*EntityPlayer aPlayer,*/ int X, int Y, int Z){ + if (entity != null && !entity.equals(null)){ + Utils.LOG_WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); + Utils.LOG_WARNING("Grabbed TE: "+entity.toString()); + + + + + if (entity instanceof BaseTileEntity && !(entity instanceof BaseMetaPipeEntity)){ + IMetaTileEntity I = ((BaseMetaTileEntity)entity).getMetaTileEntity(); + Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); + Utils.LOG_WARNING("I Details: "+I.getMetaName()+" | "+I.getTileEntityBaseType()+" | "+I.toString()); + + + + + + if (I instanceof GregtechMetaSafeBlock){ + Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); + + Block ThisBlock = I.getBaseMetaTileEntity().getBlock(X, Y, Z); + Utils.LOG_WARNING("Block Details: "+ThisBlock.toString()); + + + if (((GregtechMetaSafeBlock)I).bUnbreakable){ + ThisBlock.setHardness(Integer.MAX_VALUE); + //ThisBlock.setResistance(18000000.0F); + ThisBlock.setResistance(-1); + ThisBlock.setBlockUnbreakable(); + Utils.LOG_WARNING("Changing State of Flag. Old Value="+MetaSafeBlock.bUnbreakable+" Expected Value=true"); + MetaSafeBlock.bUnbreakable = true; + //entity.markDirty(); + Utils.LOG_WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); + Utils.LOG_ERROR("New Indestructible Flag enabled."); + //GT_Utility.sendChatToPlayer(aPlayer, "Block is now unbreakable."); + } + + + + + else { + ThisBlock.setHardness(1); + ThisBlock.setResistance(1.0F); + Utils.LOG_WARNING("Changing State of Flag. Old Value="+MetaSafeBlock.bUnbreakable+" Expected Value=false"); + MetaSafeBlock.bUnbreakable = false; + //entity.markDirty(); + Utils.LOG_WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); + Utils.LOG_ERROR("New Indestructible Flag disabled."); + //GT_Utility.sendChatToPlayer(aPlayer, "Block is now breakable."); + } + + //entity.markDirty(); + + Utils.LOG_WARNING("Block Hardness: "+ThisBlock.getBlockHardness(TE_WORLD, X, Y, Z)); + Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); + hasRun = false; + + } + else { + Utils.LOG_WARNING("I is not an instanceof MetaSafeBlockBase"); + Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); + } + } else { + Utils.LOG_WARNING("TE is not an instanceof BaseTileEntity or may be a pipe."); + Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); + } + }else { + Utils.LOG_WARNING("Did not grab a TE instance to make a block instance from."); + Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/interfaces/IGuiManager.java b/src/Java/gtPlusPlus/core/interfaces/IGuiManager.java new file mode 100644 index 0000000000..1d0ad9ed87 --- /dev/null +++ b/src/Java/gtPlusPlus/core/interfaces/IGuiManager.java @@ -0,0 +1,16 @@ +package gtPlusPlus.core.interfaces; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +public abstract interface IGuiManager extends IGuiManagerMiscUtils{ + + public abstract ChunkCoordinates getCoordinates(); + + public abstract World getWorld(); + + public abstract Object getGui(EntityPlayer paramEntityPlayer, int paramInt); + + public abstract Object getContainer(EntityPlayer paramEntityPlayer, int paramInt); +} diff --git a/src/Java/gtPlusPlus/core/interfaces/IGuiManagerMiscUtils.java b/src/Java/gtPlusPlus/core/interfaces/IGuiManagerMiscUtils.java new file mode 100644 index 0000000000..cf46c67a54 --- /dev/null +++ b/src/Java/gtPlusPlus/core/interfaces/IGuiManagerMiscUtils.java @@ -0,0 +1,3 @@ +package gtPlusPlus.core.interfaces; + +public abstract interface IGuiManagerMiscUtils {}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/inventories/BaseInventoryBackpack.java b/src/Java/gtPlusPlus/core/inventories/BaseInventoryBackpack.java new file mode 100644 index 0000000000..59fe8aa4fa --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/BaseInventoryBackpack.java @@ -0,0 +1,241 @@ +package gtPlusPlus.core.inventories; + +import gtPlusPlus.core.item.base.BaseItemBackpack; + +import java.util.UUID; + +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.minecraftforge.common.util.Constants; + +public class BaseInventoryBackpack implements IInventory{ + + private String name = "Inventory Item"; + + /** Provides NBT Tag Compound to reference */ + private final ItemStack invItem; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 8; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + // declaration of variable: + protected String uniqueID; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public BaseInventoryBackpack(ItemStack stack) + { + invItem = stack; + + /** initialize variable within the constructor: */ + uniqueID = ""; + + if (!stack.hasTagCompound()) + { + stack.setTagCompound(new NBTTagCompound()); + // no tag compound means the itemstack does not yet have a UUID, so assign one: + uniqueID = UUID.randomUUID().toString(); + } + + // Create a new NBT Tag Compound if one doesn't already exist, or you will crash + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + } + // note that it's okay to use stack instead of invItem right there + // both reference the same memory location, so whatever you change using + // either reference will change in the other + + // Read the inventory contents from NBT + readFromNBT(stack.getTagCompound()); + } + @Override + public int getSizeInventory() + { + return inventory.length; + } + + @Override + public ItemStack getStackInSlot(int slot) + { + return inventory[slot]; + } + + @Override + public ItemStack decrStackSize(int slot, int amount) + { + ItemStack stack = getStackInSlot(slot); + if(stack != null) + { + if(stack.stackSize > amount) + { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + ItemStack stack = getStackInSlot(slot); + setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) + { + inventory[slot] = stack; + + if (stack != null && stack.stackSize > getInventoryStackLimit()) + { + stack.stackSize = getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return name.length() > 0; + } + + @Override + public int getInventoryStackLimit() + { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() + { + for (int i = 0; i < getSizeInventory(); ++i) + { + if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { + inventory[i] = null; + } + } + + // This line here does the work: + writeToNBT(invItem.getTagCompound()); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) + { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemstack) + { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return !(itemstack.getItem() instanceof BaseItemBackpack); + } + + /** + * A custom method to read our inventory from an ItemStack's NBT compound + */ + public void readFromNBT(NBTTagCompound compound) + { + // Gets the custom taglist we wrote to this compound, if any + // 1.7.2+ change to compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + + if ("".equals(uniqueID)) + { + // try to read unique ID from NBT + uniqueID = compound.getString("uniqueID"); + // if it's still "", assign a new one: + if ("".equals(uniqueID)) + { + uniqueID = UUID.randomUUID().toString(); + } + } + + for (int i = 0; i < items.tagCount(); ++i) + { + // 1.7.2+ change to items.getCompoundTagAt(i) + NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i); + int slot = item.getInteger("Slot"); + + // Just double-checking that the saved slot index is within our inventory array bounds + if (slot >= 0 && slot < getSizeInventory()) { + inventory[slot] = ItemStack.loadItemStackFromNBT(item); + } + } + } + + /** + * A custom method to write our inventory to an ItemStack's NBT compound + */ + public void writeToNBT(NBTTagCompound tagcompound) + { + // Create a new NBT Tag List to store itemstacks as NBT Tags + NBTTagList items = new NBTTagList(); + + for (int i = 0; i < getSizeInventory(); ++i) + { + // Only write stacks that contain items + if (getStackInSlot(i) != null) + { + // Make a new NBT Tag Compound to write the itemstack and slot index to + NBTTagCompound item = new NBTTagCompound(); + item.setInteger("Slot", i); + // Writes the itemstack in slot(i) to the Tag Compound we just made + getStackInSlot(i).writeToNBT(item); + + // add the tag compound to our tag list + items.appendTag(item); + } + } + tagcompound.setString("uniqueID", this.uniqueID); + // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" + tagcompound.setTag("ItemInventory", items); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java new file mode 100644 index 0000000000..3ceaf84228 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -0,0 +1,488 @@ +package gtPlusPlus.core.item; +import static gtPlusPlus.core.creative.AddToCreativeTab.tabMachines; +import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; +import static gtPlusPlus.core.lib.CORE.LOAD_ALL_CONTENT; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.BaseItemBackpack; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.item.base.bolts.BaseItemBolt; +import gtPlusPlus.core.item.base.foods.BaseItemFood; +import gtPlusPlus.core.item.base.foods.BaseItemHotFood; +import gtPlusPlus.core.item.base.gears.BaseItemGear; +import gtPlusPlus.core.item.base.ingots.BaseItemIngot; +import gtPlusPlus.core.item.base.ingots.BaseItemIngotHot; +import gtPlusPlus.core.item.base.plates.BaseItemPlate; +import gtPlusPlus.core.item.base.rings.BaseItemRing; +import gtPlusPlus.core.item.base.rods.BaseItemRod; +import gtPlusPlus.core.item.base.rotors.BaseItemRotor; +import gtPlusPlus.core.item.base.screws.BaseItemScrew; +import gtPlusPlus.core.item.effects.RarityUncommon; +import gtPlusPlus.core.item.general.BufferCore; +import gtPlusPlus.core.item.general.ItemCloakingDevice; +import gtPlusPlus.core.item.general.ItemHealingDevice; +import gtPlusPlus.core.item.general.RF2EU_Battery; +import gtPlusPlus.core.item.general.fuelrods.FuelRod_Base; +import gtPlusPlus.core.item.init.ItemsFoods; +import gtPlusPlus.core.item.tool.misc.SandstoneHammer; +import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; +import gtPlusPlus.core.item.tool.staballoy.StaballoyAxe; +import gtPlusPlus.core.item.tool.staballoy.StaballoyPickaxe; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.lib.MaterialInfo; +import gtPlusPlus.core.lib.CORE.configSwitches; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.debug.DEBUG_INIT; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.item.Item; +import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.item.ItemFood; +import net.minecraftforge.common.util.EnumHelper; +import cpw.mods.fml.common.registry.GameRegistry; +public final class ModItems { + + public static ToolMaterial STABALLOY = EnumHelper.addToolMaterial("Staballoy", 3, 2500, 7, 1.0F, 18); + + public static Item AAA_Broken; + + public static Item itemDebugShapeSpawner; + + public static Item itemBaseSpawnEgg; + + + //Tantaloy60(789, TextureSet.SET_DULL, 8.0F, 5120, 3, 1 | 2 | 16 | 32 | 64 | 128, 213, 231, 237, 0, "Tantaloy 60", 0, 0, 3035, 2200, true, false, 1, 2, 1, Dyes.dyeLightGray, 2, Arrays.asList(new MaterialStack(Tungsten, 1), new MaterialStack(Tantalum, 9)), Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 8), new TC_AspectStack(TC_Aspects.STRONTIO, 3))), + //Tantaloy61(790, TextureSet.SET_DULL, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 193, 211, 217, 0, "Tantaloy 61", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightGray, 2, Arrays.asList(new MaterialStack(Tungsten, 1), new MaterialStack(Tantalum, 9), new MaterialStack(Titanium, 1)), Arrays.asList(new TC_AspectStack(TC_Aspects.METALLUM, 8), new TC_AspectStack(TC_Aspects.STRONTIO, 3))), + + + //EnderIO + public static Item itemPlateSoularium; + public static Item itemPlateRedstoneAlloy; + public static Item itemPlateElectricalSteel; + public static Item itemPlatePulsatingIron; + public static Item itemPlateEnergeticAlloy; + public static Item itemPlateVibrantAlloy; + public static Item itemPlateConductiveIron; + public static Item itemPlateDarkSteel; + //Big Reactors + public static Item itemPlateBlutonium; + public static Item itemPlateCyanite; + public static Item itemPlateLudicrite; + //Thaumcraft + public static Item itemPlateVoidMetal; + //ExtraUtils + public static Item itemPlateBedrockium; + //Pneumaticraft + public static Item itemPlateCompressedIron; + //SimplyJetpacks + public static Item itemPlateEnrichedSoularium; + //rfTools + public static Item itemPlateDimensionShard; + //Blood Steel Items + public static Item itemIngotBloodSteel; + public static Item itemPlateBloodSteel; + //Staballoy + public static Item itemStaballoyPickaxe; + public static Item itemStaballoyAxe; + public static Item itemPlateStaballoy; + public static Item itemIngotStaballoy; + public static Item itemDustStaballoy; + public static Item itemDustTinyStaballoy; + public static Item itemDustSmallStaballoy; + public static Item itemDustBloodSteel; + public static Item itemDustTinyBloodSteel; + public static Item itemDustSmallBloodSteel; + //Tools + public static Item itemSandstoneHammer; + //Machine Related + public static Item itemBufferCore0; + //Material related + public static Item itemStickyRubber; + public static Item itemIngotBatteryAlloy; + public static Item itemPlateBatteryAlloy; + public static Item itemHeliumBlob; + public static Item itemPLACEHOLDER_Circuit; + + public static Item FuelRod_Empty; + public static Item FuelRod_Thorium; + public static Item FuelRod_Uranium; + public static Item FuelRod_Plutonium; + + public static Item itemBedLocator_Base; + public static Item itemBaseItemWithCharge; + + public static Item itemHotIngotStaballoy; + + public static Item itemIngotRaisinBread; + public static Item itemHotIngotRaisinBread; + + public static BaseItemIngot itemIngotTantalloy60; + public static BaseItemIngotHot itemHotIngotTantalloy60; + public static BaseItemPlate itemPlateTantalloy60; + public static BaseItemIngot itemIngotTantalloy61; + public static BaseItemIngotHot itemHotIngotTantalloy61; + public static BaseItemPlate itemPlateTantalloy61; + + public static ItemFood itemFoodRaisinToast; + public static BaseItemHotFood itemHotFoodRaisinToast; + public static BaseItemFood itemFoodCurriedSausages; + public static BaseItemHotFood itemHotFoodCurriedSausages; + + public static Item itemDustTantalloy60; + public static Item itemDustSmallTantalloy60; + public static Item itemDustTinyTantalloy60; + + public static Item itemDustTantalloy61; + public static Item itemDustSmallTantalloy61; + public static Item itemDustTinyTantalloy61; + + public static BaseItemGear itemGearStaballoy; + public static BaseItemGear itemGearBloodSteel; + public static BaseItemGear itemGearTantalloy60; + public static BaseItemGear itemGearTantalloy61; + + public static BaseItemRotor itemRotorStaballoy; + public static BaseItemRotor itemRotorBloodSteel; + public static BaseItemRotor itemRotorTantalloy60; + public static BaseItemRotor itemRotorTantalloy61; + + public static BaseItemRod itemRodStaballoy; + public static BaseItemRod itemRodBloodSteel; + public static BaseItemRod itemRodTantalloy60; + public static BaseItemRod itemRodTantalloy61; + + public static BaseItemScrew itemScrewStaballoy; + public static BaseItemScrew itemScrewBloodSteel; + public static BaseItemScrew itemScrewTantalloy60; + public static BaseItemScrew itemScrewTantalloy61; + + public static BaseItemRing itemRingStaballoy; + public static BaseItemRing itemRingBloodSteel; + public static BaseItemRing itemRingTantalloy60; + public static BaseItemRing itemRingTantalloy61; + + public static BaseItemBolt itemBoltStaballoy; + public static BaseItemBolt itemBoltBloodSteel; + public static BaseItemBolt itemBoltTantalloy60; + public static BaseItemBolt itemBoltTantalloy61; + + public static Item RfEuBattery; + public static Item itemPersonalCloakingDevice; + public static Item itemPersonalCloakingDeviceCharged; + public static Item itemPersonalHealingDevice; + + public static MultiPickaxeBase MP_Iron; + public static MultiPickaxeBase MP_Gold; + public static MultiPickaxeBase MP_Diamond; + public static MultiPickaxeBase MP_Wood; + public static MultiPickaxeBase MP_Stone; + public static MultiPickaxeBase MP_Quartz; + public static MultiPickaxeBase MP_Obsidian; + public static MultiPickaxeBase MP_Redstone; + + + public static BaseItemBackpack backpack_Red; + public static BaseItemBackpack backpack_Green; + public static BaseItemBackpack backpack_Blue; + public static BaseItemBackpack backpack_Yellow; + public static BaseItemBackpack backpack_Purple; + public static BaseItemBackpack backpack_Cyan; + + + public static BaseItemBackpack backpack_Maroon; + public static BaseItemBackpack backpack_Olive; + public static BaseItemBackpack backpack_DarkGreen; + public static BaseItemBackpack backpack_DarkPurple; + public static BaseItemBackpack backpack_Teal; + public static BaseItemBackpack backpack_Navy; + + + public static BaseItemBackpack backpack_Silver; + public static BaseItemBackpack backpack_Gray; + public static BaseItemBackpack backpack_Black; + public static BaseItemBackpack backpack_White; + + + //@SuppressWarnings("unused") + public static final void init(){ + + AAA_Broken = new BaseItemIngot("AAA_Broken", "Errors - Tell Alkalus", Utils.rgbtoHexValue(128, 128, 128), 0); + + //Debug Loading + if (CORE.DEBUG){ + DEBUG_INIT.registerItems(); + } + + + //Make some backpacks + //Primary colours + backpack_Red = new BaseItemBackpack("backpackRed", Utils.rgbtoHexValue(200, 0, 0)); + backpack_Green = new BaseItemBackpack("backpackGreen", Utils.rgbtoHexValue(0, 200, 0)); + backpack_Blue = new BaseItemBackpack("backpackBlue", Utils.rgbtoHexValue(0, 0, 200)); + //Secondary Colours + backpack_Yellow = new BaseItemBackpack("backpackYellow", Utils.rgbtoHexValue(200, 200, 0)); + backpack_Purple = new BaseItemBackpack("backpackPurple", Utils.rgbtoHexValue(200, 0, 200)); + backpack_Cyan = new BaseItemBackpack("backpackCyan", Utils.rgbtoHexValue(0, 200, 200)); + //Tertiary Colours + backpack_Maroon = new BaseItemBackpack("backpackMaroon", Utils.rgbtoHexValue(128, 0, 0)); + backpack_Olive = new BaseItemBackpack("backpackOlive", Utils.rgbtoHexValue(128, 128, 0)); + backpack_DarkGreen = new BaseItemBackpack("backpackDarkGreen", Utils.rgbtoHexValue(0, 128, 0)); + backpack_DarkPurple = new BaseItemBackpack("backpackDarkPurple", Utils.rgbtoHexValue(128, 0, 128)); + backpack_Teal = new BaseItemBackpack("backpackTeal", Utils.rgbtoHexValue(0, 128, 128)); + backpack_Navy = new BaseItemBackpack("backpackNavy", Utils.rgbtoHexValue(0, 0, 128)); + //Shades + backpack_Silver = new BaseItemBackpack("backpackSilver", Utils.rgbtoHexValue(192, 192, 192)); + backpack_Gray = new BaseItemBackpack("backpackGray", Utils.rgbtoHexValue(128, 128, 128)); + backpack_Black = new BaseItemBackpack("backpackBlack", Utils.rgbtoHexValue(20, 20, 20)); + backpack_White = new BaseItemBackpack("backpackWhite", Utils.rgbtoHexValue(240, 240, 240)); + + + /*ItemsIngots.load(); + ItemsPlates.load(); + ItemsDusts.load(); + ItemsRods.load(); + ItemsGears.load(); + ItemsRotors.load(); + ItemsRings.load(); + ItemsBolts.load(); + ItemsScrews.load();*/ + + + //Start meta Item Generation + ItemsFoods.load(); + + UtilsItems.generateItemsFromMaterial("EnergyCrystal", "Energy Crystal", 8, MaterialInfo.ENERGYCRYSTAL, Utils.rgbtoHexValue(228, 225, 0), true); + UtilsItems.generateItemsFromMaterial("BloodSteel", "Blood Steel", 3, MaterialInfo.BLOODSTEEL, Utils.rgbtoHexValue(142, 28, 0), false); + UtilsItems.generateItemsFromMaterial("Staballoy", "Staballoy", 6, MaterialInfo.STABALLOY, Utils.rgbtoHexValue(68, 75, 66), true); + UtilsItems.generateItemsFromMaterial("Tantalloy60", "Tantalloy-60", 5, MaterialInfo.TANTALLOY60, Utils.rgbtoHexValue(68, 75, 166), true); + UtilsItems.generateItemsFromMaterial("Tantalloy61", "Tantalloy-61", 6, MaterialInfo.TANTALLOY61, Utils.rgbtoHexValue(122, 135, 196), true); + UtilsItems.generateItemsFromMaterial("Bedrockium", "Bedrockium", 9, MaterialInfo.BEDROCKIUM, Utils.rgbtoHexValue(32, 32, 32), false); + UtilsItems.generateItemsFromMaterial("Quantum", "Quantum", 10, MaterialInfo.QUANTUM, Utils.rgbtoHexValue(128, 128, 128), true); + + + UtilsItems.generateItemsFromMaterial("Inconel625", "Inconel-625", 4, MaterialInfo.INCONEL625, Utils.rgbtoHexValue(128, 200, 128), true); //Inconel 625: Acid resistant, good weldability. The LCF version is typically used in bellows. + UtilsItems.generateItemsFromMaterial("Inconel690", "Inconel-690", 6, MaterialInfo.INCONEL690, Utils.rgbtoHexValue(118, 220, 138), true); //Inconel 690: Low cobalt content for nuclear applications, and low resistivity. + UtilsItems.generateItemsFromMaterial("Inconel792", "Inconel-792", 5, MaterialInfo.INCONEL792, Utils.rgbtoHexValue(108, 240, 118), true); //Inconel 792: Increased aluminium content for improved high temperature corrosion properties, used especially in gas turbines. + + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + UtilsItems.generateItemsFromMaterial("TungstenCarbide", "Tungsten Carbide", 5, MaterialInfo.TUNGSTENCARBIDE, Utils.rgbtoHexValue(44, 44, 44), true); + } + UtilsItems.generateItemsFromMaterial("SiliconCarbide", "Silicon Carbide", 4, MaterialInfo.SILICONCARBIDE, Utils.rgbtoHexValue(32, 32, 32), false); + UtilsItems.generateItemsFromMaterial("Zeron100", "Zeron-100", 8, MaterialInfo.ZERON100, Utils.rgbtoHexValue(180, 180, 20), true); + UtilsItems.generateItemsFromMaterial("MaragingSteel250", "Maraging Steel 250", 4, MaterialInfo.MARAGING250, Utils.rgbtoHexValue(140, 140, 140), true); + UtilsItems.generateItemsFromMaterial("MaragingSteel300", "Maraging Steel 300", 5, MaterialInfo.MARAGING300, Utils.rgbtoHexValue(150, 150, 150), true); + UtilsItems.generateItemsFromMaterial("MaragingSteel350", "Maraging Steel 350", 6, MaterialInfo.MARAGING350, Utils.rgbtoHexValue(160, 160, 160), true); + UtilsItems.generateItemsFromMaterial("Stellite", "Stellite", 7, MaterialInfo.STELLITE, Utils.rgbtoHexValue(129, 75, 120), true); + UtilsItems.generateItemsFromMaterial("Talonite", "Talonite", 8, MaterialInfo.TALONITE, Utils.rgbtoHexValue(228, 75, 120), false); + + UtilsItems.generateItemsFromMaterial("Tumbaga", "Tumbaga", 2, MaterialInfo.TUMBAGA, Utils.rgbtoHexValue(255,178,15), false); //Tumbaga was the name given by Spaniards to a non-specific alloy of gold and copper + UtilsItems.generateItemsFromMaterial("Potin", "Potin", 4, MaterialInfo.POTIN, Utils.rgbtoHexValue(201,151,129), false); //Potin is traditionally an alloy of bronze, tin and lead, with varying quantities of each possible + + + UtilsItems.generateItemsFromMaterial("HastelloyW", "Hastelloy-W", 6, MaterialInfo.HASTELLOY_W, Utils.rgbtoHexValue(218, 165, 32), false); + UtilsItems.generateItemsFromMaterial("HastelloyX", "Hastelloy-X", 6, MaterialInfo.HASTELLOY_X, Utils.rgbtoHexValue(255, 193, 37), false); + UtilsItems.generateItemsFromMaterial("HastelloyC276", "Hastelloy-C276", 7, MaterialInfo.HASTELLOY_C276, Utils.rgbtoHexValue(238, 180, 34), true); + UtilsItems.generateItemsFromMaterial("HastelloyN", "Hastelloy-N", 8, MaterialInfo.HASTELLOY_N, Utils.rgbtoHexValue(155, 223, 237), true); + + UtilsItems.generateItemsFromMaterial("Incoloy020", "Incoloy-020", 7, MaterialInfo.INCOLOY020, Utils.rgbtoHexValue(81, 81, 81), false); + UtilsItems.generateItemsFromMaterial("IncoloyDS", "Incoloy-DS", 7, MaterialInfo.INCOLOYDS, Utils.rgbtoHexValue(91, 91, 91), false); + UtilsItems.generateItemsFromMaterial("IncoloyMA956", "Incoloy-MA956", 8, MaterialInfo.INCOLOYMA956, Utils.rgbtoHexValue(101, 101, 101), true); + + + UtilsItems.generateItemsFromMaterial("Zirconium", "Zirconium", 6, MaterialInfo.ZIRCONIUM, Utils.rgbtoHexValue(255, 250, 205), false); + UtilsItems.generateItemsFromMaterial("ZirconiumCarbide", "Zirconium Carbide", 7, MaterialInfo.ZIRCONIUMCARBIDE, Utils.rgbtoHexValue(222, 202, 180), true); + UtilsItems.generateItemsFromMaterial("TantalumCarbide", "Tantalum Carbide", 7, MaterialInfo.TANTALUMCARBIDE, Utils.rgbtoHexValue(139, 136, 120), true); + UtilsItems.generateItemsFromMaterial("NiobiumCarbide", "Niobium Carbide", 6, MaterialInfo.NIOMBIUMCARBIDE, Utils.rgbtoHexValue(205, 197, 191), true); + + + //Uranium-233if + UtilsItems.generateItemsFromMaterial("Uranium233", "Uranium 233", 4, MaterialInfo.INCONEL792, Utils.rgbtoHexValue(73, 220, 83), false); //Uranium-233 is a fissile isotope of uranium that is bred from thorium-232 as part of the thorium fuel cycle. + + MP_Wood = new MultiPickaxeBase("Wooden Multipick", ToolMaterial.WOOD, ToolMaterial.WOOD.getMaxUses(), Utils.rgbtoHexValue(139,90,43)); + MP_Stone = new MultiPickaxeBase("Cobblestone Multipick", ToolMaterial.STONE, ToolMaterial.STONE.getMaxUses(), Utils.rgbtoHexValue(161,161,161)); + MP_Iron = new MultiPickaxeBase("Iron Multipick", ToolMaterial.IRON, ToolMaterial.IRON.getMaxUses(), Utils.rgbtoHexValue(110,123,139)); + MP_Gold = new MultiPickaxeBase("Gold Multipick", ToolMaterial.GOLD, ToolMaterial.GOLD.getMaxUses(), Utils.rgbtoHexValue(238,221,130)); + MP_Diamond = new MultiPickaxeBase("Diamond Multipick", ToolMaterial.EMERALD, ToolMaterial.EMERALD.getMaxUses(), Utils.rgbtoHexValue(191,239,255)); + + MP_Redstone = UtilsItems.generateMultiPick(Materials.Redstone); + MP_Obsidian = UtilsItems.generateMultiPick(Materials.Obsidian); + MP_Obsidian = UtilsItems.generateMultiPick(Materials.Abyssal); + MP_Obsidian = UtilsItems.generateMultiPick(Materials.NetherStar); + MP_Obsidian = UtilsItems.generateMultiPick(Materials.Neutronium); + + //EnderIO Resources + if (LoadedMods.EnderIO || LOAD_ALL_CONTENT){ + Utils.LOG_INFO("EnderIO Found - Loading Resources."); + //Item Init + itemPlateSoularium = new Item().setUnlocalizedName("itemPlateSoularium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateSoularium"); + itemPlateRedstoneAlloy = new Item().setUnlocalizedName("itemPlateRedstoneAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateRedstoneAlloy"); + itemPlateElectricalSteel = new Item().setUnlocalizedName("itemPlateElectricalSteel").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateElectricalSteel"); + itemPlatePulsatingIron = new Item().setUnlocalizedName("itemPlatePulsatingIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlatePulsatingIron"); + itemPlateEnergeticAlloy = new Item().setUnlocalizedName("itemPlateEnergeticAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateEnergeticAlloy"); + itemPlateVibrantAlloy = new Item().setUnlocalizedName("itemPlateVibrantAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateVibrantAlloy"); + itemPlateConductiveIron = new Item().setUnlocalizedName("itemPlateConductiveIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateConductiveIron"); + itemPlateDarkSteel = new Item().setUnlocalizedName("itemPlateDarkSteel").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateDarkSteel"); + //Registry + GameRegistry.registerItem(itemPlateSoularium, "itemPlateSoularium"); + GameRegistry.registerItem(itemPlateRedstoneAlloy, "itemPlateRedstoneAlloy"); + GameRegistry.registerItem(itemPlateElectricalSteel, "itemPlateElectricalSteel"); + GameRegistry.registerItem(itemPlatePulsatingIron, "itemPlatePulsatingIron"); + GameRegistry.registerItem(itemPlateEnergeticAlloy, "itemPlateEnergeticAlloy"); + GameRegistry.registerItem(itemPlateVibrantAlloy, "itemPlateVibrantAlloy"); + GameRegistry.registerItem(itemPlateConductiveIron, "itemPlateConductiveIron"); + GameRegistry.registerItem(itemPlateDarkSteel, "itemPlateDarkSteel"); + } + else { + Utils.LOG_WARNING("EnderIO not Found - Skipping Resources."); + } + //Big Reactors + if (LoadedMods.Big_Reactors|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("BigReactors Found - Loading Resources."); + //Item Init + itemPlateBlutonium = new Item().setUnlocalizedName("itemPlateBlutonium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateBlutonium"); + itemPlateCyanite = new Item().setUnlocalizedName("itemPlateCyanite").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateCyanite"); + itemPlateLudicrite = new Item().setUnlocalizedName("itemPlateLudicrite").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateLudicrite"); + //Registry + GameRegistry.registerItem(itemPlateBlutonium, "itemPlateBlutonium"); + GameRegistry.registerItem(itemPlateCyanite, "itemPlateCyanite"); + GameRegistry.registerItem(itemPlateLudicrite, "itemPlateLudicrite"); + } + else { + Utils.LOG_WARNING("BigReactors not Found - Skipping Resources."); + } + //Thaumcraft + if (LoadedMods.Thaumcraft|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("Thaumcraft Found - Loading Resources."); + //Item Init + try { + itemPlateVoidMetal = new Item().setUnlocalizedName("itemPlateVoidMetal").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateVoidMetal"); + } catch (NullPointerException e){ + e.getClass(); + } + //Registry + GameRegistry.registerItem(itemPlateVoidMetal, "itemPlateVoidMetal"); + } + else { + Utils.LOG_WARNING("Thaumcraft not Found - Skipping Resources."); + } + //ExtraUtils + if (LoadedMods.Extra_Utils|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("ExtraUtilities Found - Loading Resources."); + //Item Init + try { + //itemPlateBedrockium = new Item().setUnlocalizedName("itemPlateBedrockium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateBedrockium"); + } catch (NullPointerException e){ + e.getClass(); + } + //Registry + //GameRegistry.registerItem(itemPlateBedrockium, "itemPlateBedrockium"); + } + else { + Utils.LOG_WARNING("ExtraUtilities not Found - Skipping Resources."); + } + //Pneumaticraft + if (LoadedMods.PneumaticCraft|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("PneumaticCraft Found - Loading Resources."); + //Item Init + itemPlateCompressedIron = new Item().setUnlocalizedName("itemPlateCompressedIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateCompressedIron"); + //Registry + GameRegistry.registerItem(itemPlateCompressedIron, "itemPlateCompressedIron"); + } + else { + Utils.LOG_WARNING("PneumaticCraft not Found - Skipping Resources."); + } + //Simply Jetpacks + if (LoadedMods.Simply_Jetpacks|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("SimplyJetpacks Found - Loading Resources."); + //Item Init + itemPlateEnrichedSoularium = new RarityUncommon().setUnlocalizedName("itemPlateEnrichedSoularium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateSoularium"); + //Registry + GameRegistry.registerItem(itemPlateEnrichedSoularium, "itemPlateEnrichedSoularium"); + } + else { + Utils.LOG_WARNING("SimplyJetpacks not Found - Skipping Resources."); + } + //rfTools + if (LoadedMods.RFTools|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("rfTools Found - Loading Resources."); + //Item Init + itemPlateDimensionShard = new Item().setUnlocalizedName("itemPlateDimensionShard").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateDimensionShard"); + //Registry + GameRegistry.registerItem(itemPlateDimensionShard, "itemPlateDimensionShard"); + } + else { + Utils.LOG_WARNING("rfTools not Found - Skipping Resources."); + } + //IC2 Exp + if (LoadedMods.IndustrialCraft2|| LOAD_ALL_CONTENT){ + Utils.LOG_INFO("IndustrialCraft2 Found - Loading Resources."); + //Item Init + FuelRod_Empty = new FuelRod_Base("itemFuelRod_Empty", "Empty", 0, 1000); + FuelRod_Thorium = new FuelRod_Base("itemFuelRod_Thorium", "Thorium", 1000, 1000); + FuelRod_Uranium = new FuelRod_Base("itemFuelRod_Uranium", "Uranium", 2500, 2500); + FuelRod_Plutonium = new FuelRod_Base("itemFuelRod_Plutonium", "Plutonium", 5000, 5000); + RfEuBattery = new RF2EU_Battery(); + itemPersonalCloakingDevice = new ItemCloakingDevice(0); + //itemPersonalCloakingDeviceCharged = new ItemCloakingDevice(0).set; + itemPersonalHealingDevice = new ItemHealingDevice(); + //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"); + } + else { + Utils.LOG_WARNING("IndustrialCraft2 not Found - Skipping Resources."); + } + + + //Special Item Handling Case + if (configSwitches.enableAlternativeBatteryAlloy) { + ModItems.itemIngotBatteryAlloy = new BaseItemIngot("itemIngotBatteryAlloy", "Battery Alloy", Utils.rgbtoHexValue(35, 228, 141), 0); + ModItems.itemPlateBatteryAlloy = new BaseItemPlate("itemPlateBatteryAlloy", "Battery Alloy", Utils.rgbtoHexValue(35, 228, 141), 2, 0); + } + + + //UtilsItems.generateSpawnEgg("ic2", "boatcarbon", Utils.generateSingularRandomHexValue(), Utils.generateSingularRandomHexValue()); + + + + /* + * Misc Items + */ + + //Staballoy Equipment + itemStaballoyPickaxe = new StaballoyPickaxe("itemStaballoyPickaxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(itemStaballoyPickaxe, itemStaballoyPickaxe.getUnlocalizedName()); + itemStaballoyAxe = new StaballoyAxe("itemStaballoyAxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(itemStaballoyAxe, itemStaballoyAxe.getUnlocalizedName()); + + //Sandstone Hammer + itemSandstoneHammer = new SandstoneHammer("itemSandstoneHammer").setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(itemSandstoneHammer, itemSandstoneHammer.getUnlocalizedName()); + + //Buffer Cores! + Item itemBufferCore; + for(int i=1; i<=10; i++){ + //Utils.LOG_INFO(""+i); + itemBufferCore = new BufferCore("itemBufferCore", i).setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerItem(itemBufferCore, itemBufferCore.getUnlocalizedName()+i); + //System.out.println("Buffer Core registration count is: "+i); + } + + itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMachines).setTextureName(CORE.MODID + ":itemStickyRubber"); + GameRegistry.registerItem(itemStickyRubber, "itemStickyRubber"); + GT_OreDictUnificator.registerOre("ingotRubber", UtilsItems.getItemStack(CORE.MODID+":itemStickyRubber", 1)); + + itemHeliumBlob = new CoreItem("itemHeliumBlob", tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob"); + //GameRegistry.registerItem(itemHeliumBlob, "itemHeliumBlob"); + + itemPLACEHOLDER_Circuit = new Item().setUnlocalizedName("itemPLACEHOLDER_Circuit").setTextureName(CORE.MODID + ":itemPLACEHOLDER_Circuit"); + GameRegistry.registerItem(itemPLACEHOLDER_Circuit, "itemPLACEHOLDER_Circuit"); + + //ItemBlockGtFrameBox = new ItemBlockGtFrameBox(ModBlocks.blockGtFrameSet1); + //GameRegistry.registerItem(ItemBlockGtFrameBox, "itemGtFrameBoxSet1"); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemBackpack.java b/src/Java/gtPlusPlus/core/item/base/BaseItemBackpack.java new file mode 100644 index 0000000000..316f922639 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemBackpack.java @@ -0,0 +1,89 @@ +package gtPlusPlus.core.item.base; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BaseItemBackpack extends Item{ + + protected final int colourValue; + protected final String unlocalName; + + + public BaseItemBackpack(String unlocalizedName, int colour){ + this.unlocalName = unlocalizedName; + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + "itemBackpack"); + this.colourValue = colour; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre("storageBackpack", UtilsItems.getSimpleStack(this)); + setMaxStackSize(1); + setCreativeTab(AddToCreativeTab.tabOther); + } + + // Without this method, your inventory will NOT work!!! + @Override + public int getMaxItemUseDuration(ItemStack stack) { + return 1; // return any value greater than zero + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) + { + if (!world.isRemote) + { + // If player not sneaking, open the inventory gui + if (!player.isSneaking()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI3, world, 0, 0, 0); + } + + // Otherwise, stealthily place some diamonds in there for a nice surprise next time you open it up :) + else { + // Utils.LOG_INFO("Player is Sneaking, giving them sneaky diamonds."); + // new BaseInventoryBackpack(player.getHeldItem()).setInventorySlotContents(0, new ItemStack(Items.diamond,4)); + } + } + + return itemstack; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colourValue == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colourValue; + + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + //Name Formatting. + String temp = unlocalName.replace("backpack", ""); + //Lets find the colour. + if (temp.toLowerCase().contains("dark")){ + temp = unlocalName.substring(12, unlocalName.length()); + temp = "Dark "+ temp; + } + return (temp+" Backpack"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemBackpack"); + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java b/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java new file mode 100644 index 0000000000..a6cc29497e --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java @@ -0,0 +1,30 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +public class BaseItemGeneric extends Item +{ + public BaseItemGeneric(String unlocalizedName, CreativeTabs c, int stackSize, int maxDmg) + { + setUnlocalizedName(CORE.MODID + "_" + unlocalizedName); + setTextureName(CORE.MODID + ":" + unlocalizedName); + setCreativeTab(c); + setMaxStackSize(stackSize); + setMaxDamage(maxDmg); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+""); + super.addInformation(stack, aPlayer, list, bool); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemWithCharge.java b/src/Java/gtPlusPlus/core/item/base/BaseItemWithCharge.java new file mode 100644 index 0000000000..c793776e37 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemWithCharge.java @@ -0,0 +1,75 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +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/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java b/src/Java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java new file mode 100644 index 0000000000..ec052ef1f9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java @@ -0,0 +1,29 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +public class BaseItemWithDamageValue extends Item{ + public BaseItemWithDamageValue(String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(100); + } + @Override + public void setDamage(ItemStack stack, int damage) { + super.setDamage(stack, damage); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+""); + super.addInformation(stack, aPlayer, list, bool); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/BasicSpawnEgg.java b/src/Java/gtPlusPlus/core/item/base/BasicSpawnEgg.java new file mode 100644 index 0000000000..9407689cfc --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BasicSpawnEgg.java @@ -0,0 +1,259 @@ +package gtPlusPlus.core.item.base; + + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + + + +public class BasicSpawnEgg extends ItemMonsterPlacer +{ + @SideOnly(Side.CLIENT) + private IIcon theIcon; + protected int colorBase = 0x000000; + protected int colorSpots = 0xFFFFFF; + protected String entityMODID = ""; + protected String entityToSpawnName = ""; + protected String entityToSpawnNameFull = ""; + protected EntityLiving entityToSpawn = null; + + public BasicSpawnEgg(){ + super(); + } + + public BasicSpawnEgg(String MODID, String parEntityToSpawnName, int parPrimaryColor, int parSecondaryColor){ + setHasSubtypes(false); + maxStackSize = 64; + setCreativeTab(AddToCreativeTab.tabOther); + setEntityToSpawnName(parEntityToSpawnName); + colorBase = parPrimaryColor; + colorSpots = parSecondaryColor; + entityMODID = MODID; + + // DEBUG + Utils.LOG_WARNING("Spawn egg constructor for "+entityToSpawnName); + } + + /** + * Callback for item usage. If the item does something special on right clicking, + + * he will have one of those. Return + * True if something happen and false if it don't. This is for ITEMS, not BLOCKS + */ + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10){ + if (par3World.isRemote) + { + return true; + } + Block block = par3World.getBlock(par4, par5, par6); + par4 += Facing.offsetsXForSide[par7]; + par5 += Facing.offsetsYForSide[par7]; + par6 += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if (par7 == 1 && block.getRenderType() == 11) + { + d0 = 0.5D; + } + + Entity entity = spawnEntity(par3World, par4 + 0.5D, par5 + d0, par6 + 0.5D); + + if (entity != null) + { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) + { + ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par2EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + + return true; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. + + *Args: itemStack, world, entityPlayer + */ + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){ + if (par2World.isRemote) + { + return par1ItemStack; + } + MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) + { + return par1ItemStack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition + + .MovingObjectType.BLOCK) + + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) + { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + if (par2World.getBlock(i, j, k) instanceof BlockLiquid) + { + Entity entity = spawnEntity(par2World, i, j, k); + + if (entity != null) + { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) + { + ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + } + } + + return par1ItemStack; + } + + /** + * Spawns the creature specified by the egg's type in the location specified by + + * the last three parameters. + * Parameters: world, entityID, x, y, z. + */ + public Entity spawnEntity(World parWorld, double parX, double parY, double parZ){ + + if (!parWorld.isRemote) // never spawn entity on client side + { + entityToSpawnNameFull = entityMODID+"."+entityToSpawnName; + if (EntityList.stringToClassMapping.containsKey(entityToSpawnNameFull)) + { + entityToSpawn = (EntityLiving) EntityList + + .createEntityByName(entityToSpawnNameFull, parWorld); + entityToSpawn.setLocationAndAngles(parX, parY, parZ, + + MathHelper.wrapAngleTo180_float(parWorld.rand.nextFloat() + + * 360.0F), 0.0F); + parWorld.spawnEntityInWorld(entityToSpawn); + entityToSpawn.onSpawnWithEgg((IEntityLivingData)null); + entityToSpawn.playLivingSound(); + } + else + { + //DEBUG + Utils.LOG_WARNING("Entity not found "+entityToSpawnName); + } + } + + return entityToSpawn; + } + + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item parItem, CreativeTabs parTab, List parList){ + parList.add(new ItemStack(parItem, 1, 0)); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int parColorType){ + return (parColorType == 0) ? colorBase : colorSpots; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses(){ + return true; + } + + @Override + // Doing this override means that there is no localization for language + // unless you specifically check for localization here and convert + public String getItemStackDisplayName(ItemStack par1ItemStack){ + return "Spawn "+entityToSpawnName; + } + + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister){ + super.registerIcons(par1IconRegister); + theIcon = par1IconRegister.registerIcon(getIconString() + "_overlay"); + } + + /** + * Gets an icon index based on an item's damage value and the given render pass + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int parDamageVal, int parRenderPass){ + return parRenderPass > 0 ? theIcon : super.getIconFromDamageForRenderPass(parDamageVal, parRenderPass); + } + + public void setColors(int parColorBase, int parColorSpots){ + colorBase = parColorBase; + colorSpots = parColorSpots; + } + + public int getColorBase(){ + return colorBase; + } + + public int getColorSpots(){ + return colorSpots; + } + + public void setEntityToSpawnName(String parEntityToSpawnName){ + entityToSpawnName = parEntityToSpawnName; + entityToSpawnNameFull = entityMODID+"."+entityToSpawnName; + } + +} + diff --git a/src/Java/gtPlusPlus/core/item/base/CoreItem.java b/src/Java/gtPlusPlus/core/item/base/CoreItem.java new file mode 100644 index 0000000000..b77b2d336e --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/CoreItem.java @@ -0,0 +1,118 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CoreItem extends Item +{ + + private final EnumRarity rarity; + private final EnumChatFormatting descColour; + private final String itemDescription; + private final boolean hasEffect; + + //0 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab) + { + this(unlocalizedName, creativeTab, 64, 0); //Calls 3 + } + //1 + /* + * Name, Tab, Stack - 0 Dmg + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize) + { + this(unlocalizedName, creativeTab, stackSize, 0); //Calls 3 + } + //2 + /* + * Name, Tab, Stack, Description - 0 Dmg + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, String description) + { + this(unlocalizedName, creativeTab, stackSize, 0, description); //Calls 4 + } + //3 + /* + * Name, Tab, Stack, Dmg - Description + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, ""); //Calls 4 + } + //4 //Not Rare + basic tooltip + /* + * Name, Tab, Stack, Dmg, Description + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, description, EnumRarity.common, EnumChatFormatting.GRAY, false); //Calls 4.5 + } + //4.5 + /* + * Name, Tab, Stack, Dmg, Description, Text Colour - Common + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description, EnumChatFormatting colour) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, description, EnumRarity.common, colour, false); //Calls 5 + } + + //4.75 + /* + * Name, Tab, Stack, Dmg, Description, Rarity - Gray text + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description, EnumRarity rarity) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, description, rarity, EnumChatFormatting.GRAY, false); //Calls 5 + } + + //5 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description, EnumRarity regRarity, EnumChatFormatting colour, boolean Effect) + { + setUnlocalizedName(unlocalizedName); + setTextureName(CORE.MODID + ":" + unlocalizedName); + setCreativeTab(creativeTab); + setMaxStackSize(stackSize); + setMaxDamage(maxDmg); + this.rarity = regRarity; + this.itemDescription = description; + this.descColour = colour; + this.hasEffect = Effect; + GameRegistry.registerItem(this, unlocalizedName); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(descColour+itemDescription); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return rarity; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return hasEffect; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java b/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java new file mode 100644 index 0000000000..0f56730177 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java @@ -0,0 +1,82 @@ +package gtPlusPlus.core.item.base.bolts; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemBolt extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemBolt(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemBolt"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemB", "b"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Bolt"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A small Bolt, constructed from " + materialName + "."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Bolts"); + String tempIngot = unlocalName.replace("itemBolt", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Bolt.get(1), + UtilsItems.getSimpleStack(this, 8), + 30*mTier*20, + 24*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java new file mode 100644 index 0000000000..6d12624487 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -0,0 +1,352 @@ +package gtPlusPlus.core.item.base.dusts; + +import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.MaterialInfo; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemDust extends Item{ + + protected int colour; + protected String materialName; + protected String pileType; + protected boolean useBlastFurnace; + String name = ""; + private int mTier; + private MaterialInfo dustInfo; + + public BaseItemDust(String unlocalizedName, String materialName, MaterialInfo matInfo, int colour, String pileSize, boolean blastFurnaceRequired, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(64); + if (pileSize == "dust" || pileSize == "Dust"){ + this.setTextureName(CORE.MODID + ":" + "dust");} + else{ + this.setTextureName(CORE.MODID + ":" + "dust"+pileSize);} + this.setCreativeTab(tabMisc); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.useBlastFurnace = blastFurnaceRequired; + this.dustInfo = matInfo; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + + String temp = ""; + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = getUnlocalizedName(); + } + if (temp.contains("DustTiny")){ + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else if (temp.contains("DustSmall")){ + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + if (temp != null && temp != ""){ + GT_OreDictUnificator.registerOre(temp, UtilsItems.getSimpleStack(this)); + } + addMixerRecipe(); + addFurnaceRecipe(); + addMacerationRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack iStack) { + + if (getUnlocalizedName().contains("DustTiny")){ + name = "Tiny Pile of "+materialName + " Dust"; + } + else if (getUnlocalizedName().contains("DustSmall")){ + name = "Small Pile of "+materialName + " Dust"; + } + else { + name = materialName + " Dust"; + } + return name; + } + + protected final int sRadiation; + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + //if (pileType != null && materialName != null && pileType != "" && materialName != "" && !pileType.equals("") && !materialName.equals("")){ + if (getUnlocalizedName().contains("DustTiny")){ + list.add(EnumChatFormatting.GRAY+"A tiny pile of " + materialName + " dust."); + } + else if (getUnlocalizedName().contains("DustSmall")){ + list.add(EnumChatFormatting.GRAY+"A small pile of " + materialName + " dust."); + } + else { + list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); + } + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + //} + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + + + private void addMixerRecipe(){ + ItemStack tempStack = UtilsItems.getSimpleStack(this); + ItemStack tempOutput = null; + ItemStack[] inputStacks = dustInfo.getInputs(); + ItemStack[] outputStacks = dustInfo.getOutputs(); + String temp = ""; + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = getUnlocalizedName(); + } + if (temp.contains("DustTiny")){ + temp = temp.replace("itemDustTiny", "dust"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else if (temp.contains("DustSmall")){ + temp = temp.replace("itemDustSmall", "dust"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + if (temp != null && temp != ""){ + + if (getUnlocalizedName().contains("DustTiny") || getUnlocalizedName().contains("DustSmall")){ + tempOutput = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + } + else { + if (outputStacks[0] != null){ + Utils.LOG_WARNING("Getting output dusts for mixer recipe. Checking ENUM, got: "+outputStacks[0].toString()); + tempOutput = outputStacks[0]; + } + else { + Utils.LOG_WARNING("Getting output dusts for mixer recipe. Enum check failed, failback item is: "+temp); + tempOutput = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + } + } + + } + + if (tempOutput != null){ + if (getUnlocalizedName().contains("DustTiny")){ + Utils.LOG_WARNING("Generating a 9 Tiny dust to 1 Dust recipe for "+materialName); + UtilsRecipe.addShapelessGregtechRecipe(tempOutput, + tempStack, tempStack, tempStack, + tempStack, tempStack, tempStack, + tempStack, tempStack, tempStack); + } + else if (getUnlocalizedName().contains("DustSmall")){ + Utils.LOG_WARNING("Generating a 4 Small dust to 1 Dust recipe for "+materialName); + UtilsRecipe.addShapelessGregtechRecipe(tempOutput, + tempStack, tempStack, null, + tempStack, tempStack, null, + null, null, null); + } + else { + Utils.LOG_WARNING("Generating a Dust recipe for "+materialName+" in the mixer."); + + + int i = 0; + if (inputStacks.length >= 2){ + for (ItemStack is : inputStacks){ + if (is != null){ + Utils.LOG_WARNING("Found "+is.getDisplayName()+" as an input for mixer recipe."); + if (is.getDisplayName().toLowerCase().contains("tell alkalus")){ + ItemStack tempStackForAName = inputStacks[i]; + String[] inputList = dustInfo.getInputItemsAsList(); + int[] inputSizes = dustInfo.getInputStackSizesAsList(); + inputStacks[i] = UtilsItems.getItemStackOfAmountFromOreDict(inputList[i], inputSizes[i]); + Utils.LOG_WARNING("Swapping input slot "+i+" which contains "+tempStackForAName.getDisplayName()+" with "+inputStacks[i].getDisplayName()+"."); + } + + } + + else { + Utils.LOG_WARNING("Input "+i+" was null."); + } + + i++; + } + } + + GT_Values.RA.addMixerRecipe( + inputStacks[0], inputStacks[1], + inputStacks[2], inputStacks[3], + null, null, + tempOutput, + 8*mTier*20, 8*mTier*2); + + /*GT_Values.RA.addMixerRecipe( + GT_Utility.copyAmount(inputStacks[0].stackSize, new Object[]{inputStacks[0]}), GT_Utility.copyAmount(inputStacks[1].stackSize, new Object[]{inputStacks[1]}), + GT_Utility.copyAmount(inputStacks[2].stackSize, new Object[]{inputStacks[2]}), GT_Utility.copyAmount(inputStacks[3].stackSize, new Object[]{inputStacks[3]}), + null, null, + tempOutput, + 8*mTier*20, 8*mTier*2);*/ + + } + } + + } + + private void addMacerationRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Dusts"); + + String tempIngot = getUnlocalizedName().replace("item.itemDust", "ingot"); + String tempDust = getUnlocalizedName().replace("item.itemDust", "dust"); + ItemStack tempInputStack; + ItemStack tempOutputStack; + + if (getUnlocalizedName().contains("DustSmall") || getUnlocalizedName().contains("DustTiny")){ + return; + } + + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + tempIngot = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+tempIngot); + } + else { + tempIngot = getUnlocalizedName(); + } + + tempIngot = tempIngot.replace("itemDust", "ingot"); + Utils.LOG_WARNING("Generating OreDict Name: "+tempIngot); + ItemStack[] outputStacks = dustInfo.getOutputs(); + if (tempIngot != null && tempIngot != ""){ + tempInputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempDust, 1); + ItemStack tempStackOutput2; + int chance = mTier*10/MathUtils.randInt(10, 20); + if (outputStacks[1] != null && !outputStacks[1].getUnlocalizedName().toLowerCase().contains("aaa_broken")){ + tempStackOutput2 = outputStacks[1]; + tempOutputStack = outputStacks[0]; + } + else { + tempStackOutput2 = null; + } + if (null != tempOutputStack && null != tempInputStack){ + GT_ModHandler.addPulverisationRecipe(tempInputStack, tempOutputStack.splitStack(1), tempStackOutput2, chance); + } + } + } + + private void addFurnaceRecipe(){ + + String temp = ""; + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + } + else { + temp = getUnlocalizedName(); + } + if (temp.contains("DustTiny") || temp.contains("DustSmall")){ + return; + } + temp = temp.replace("itemDust", "ingot"); + if (temp != null && temp != ""){ + + if (this.useBlastFurnace){ + Utils.LOG_WARNING("Adding recipe for Hot "+materialName+" Ingots in a Blast furnace."); + String tempIngot = temp.replace("ingot", "ingotHot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + Utils.LOG_WARNING("This will produce "+tempOutputStack.getDisplayName() + " Debug: "+tempIngot); + if (null != tempOutputStack){ + addBlastFurnaceRecipe(UtilsItems.getSimpleStack(this), null, tempOutputStack, null, 350*mTier); + } + return; + } + Utils.LOG_WARNING("Adding recipe for "+materialName+" Ingots in a furnace."); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + Utils.LOG_WARNING("This will produce an ingot of "+tempOutputStack.getDisplayName() + " Debug: "+temp); + if (null != tempOutputStack){ + if (mTier < 5){ + CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(UtilsItems.getSimpleStack(this), tempOutputStack); + } + else if (mTier >= 5){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Ingots in a Blast furnace."); + Utils.LOG_WARNING("This will produce "+tempOutputStack.getDisplayName()); + if (null != tempOutputStack){ + addBlastFurnaceRecipe(UtilsItems.getSimpleStack(this), null, tempOutputStack, null, 350*mTier); + } + return; + } + } + + } + } + + private void addBlastFurnaceRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tempRequired){ + //Special Cases + /*if (input1.getUnlocalizedName().toLowerCase().contains("tantalloy61")){ + Utils.LOG_INFO("Adding Special handler for Staballoy-61 in the Blast Furnace"); + input2 = UtilsItems.getItemStackOfAmountFromOreDict("dustTantalloy60", 2); + if (input2 == null){ + Utils.LOG_INFO("invalid itemstack."); + } + else { + Utils.LOG_INFO("Found "+input2.getDisplayName()); + } + }*/ + GT_Values.RA.addBlastRecipe( + input1, + input2, + GT_Values.NF, GT_Values.NF, + output1, + output2, + 250*mTier*20, + mTier*64, + tempRequired); + + + + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java new file mode 100644 index 0000000000..a49dc58188 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java @@ -0,0 +1,42 @@ +package gtPlusPlus.core.item.base.dusts; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; + +public abstract class BaseItemDustAbstract extends Item{ + + protected int colour = 0; + protected String materialName; + protected String pileType; + + public BaseItemDustAbstract(String unlocalizedName, String materialName, int colour, String pileSize) { + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(64); + if (pileSize == "dust" || pileSize == "Dust"){ + this.setTextureName(CORE.MODID + ":" + "dust"); + } + else{ + this.setTextureName(CORE.MODID + ":" + "dust"+pileSize); + } + this.setMaxStackSize(64); + this.colour = colour; + this.materialName = materialName; + setUnlocalizedName(unlocalizedName); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public abstract void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool); + + public abstract String getMaterialName(); + + @Override + public abstract int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF); + +} diff --git a/src/Java/gtPlusPlus/core/item/base/foods/BaseItemFood.java b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemFood.java new file mode 100644 index 0000000000..7b0663d9cf --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemFood.java @@ -0,0 +1,47 @@ +package gtPlusPlus.core.item.base.foods; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemFood extends ItemFood { + + private PotionEffect[] effects; + protected String localName; + + public BaseItemFood(String unlocalizedName, String localizedName, int healAmount, float saturationModifier, boolean wolvesFavorite, PotionEffect... effects) { + super(healAmount, saturationModifier, wolvesFavorite); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName.replace("Hot", "")); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.effects = effects; + this.localName = localizedName; + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) { + super.onFoodEaten(stack, world, player); + + for (int i = 0; i < effects.length; i ++) { + if (!world.isRemote && effects[i] != null && effects[i].getPotionID() > 0) + player.addPotionEffect(new PotionEffect(this.effects[i].getPotionID(), + this.effects[i].getDuration(), this.effects[i].getAmplifier(), + this.effects[i].getIsAmbient() + ) + ); + } + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("A Serving of "+localName); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java new file mode 100644 index 0000000000..aaad22be9c --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java @@ -0,0 +1,78 @@ +package gtPlusPlus.core.item.base.foods; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BaseItemHotFood extends BaseItemFood{ + + protected String materialName; + protected String unlocalName; + protected int cooldownTime; + protected Item output; + + public BaseItemHotFood(String unlocalizedName, int healAmount, float healSaturation, String foodName, int timeToCoolInSeconds, Item cooledFood) { + super(unlocalizedName, "Hot "+foodName, healAmount, healSaturation, false); + this.unlocalName = unlocalizedName; + this.cooldownTime = timeToCoolInSeconds * 20; + this.materialName = foodName; + this.output = cooledFood; + this.setMaxStackSize(1); + } + + @Override + public ItemStack onEaten(ItemStack iStack, World world, EntityPlayer player) { + return super.onEaten(iStack, world, player); + } + + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + //Utils.LOG_INFO("Item Damage: "+iStack.getItemDamage()+" Max Damage: "+iStack.getMaxDamage()); + if (!world.isRemote){ + if(iStack.getItemDamage() == cooldownTime) { + if (entityHolding instanceof EntityPlayer){ + Utils.LOG_INFO("Foods Done."); + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory(UtilsItems.getSimpleStack(output)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + }else if(iStack.getItemDamage() < cooldownTime){ + iStack.setItemDamage(iStack.getItemDamage() + 1); + } + if(MathUtils.divideXintoY(iStack.getItemDamage(), 150)){ + entityHolding.attackEntityFrom(DamageSource.onFire, 1); + } + + + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.RED+"Very hot!"+EnumChatFormatting.GRAY+" Avoid direct handling.."); + list.add(EnumChatFormatting.GRAY+"This food has "+((cooldownTime-(int) stack.getItemDamage())/20)+" seconds left, until it is cool."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + return Utils.rgbtoHexValue(230, 96, 96); + + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java b/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java new file mode 100644 index 0000000000..ba41625b25 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java @@ -0,0 +1,82 @@ +package gtPlusPlus.core.item.base.gears; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemGear extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemGear(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemGear"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemG", "g"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Gear"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A large Gear, constructed from " + materialName + "."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Gears"); + String tempIngot = unlocalName.replace("itemGear", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 8); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Gear.get(1), + UtilsItems.getSimpleStack(this), + 40*mTier*20, + 24*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java new file mode 100644 index 0000000000..e193636043 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java @@ -0,0 +1,118 @@ +package gtPlusPlus.core.item.base.ingots; + +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemIngot extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + + public BaseItemIngot(String unlocalizedName, String materialName, int colour, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemIngot"); + this.setMaxStackSize(64); + this.colour = colour; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + String temp = ""; + if (unlocalName.contains("itemIngot")){ + temp = unlocalName.replace("itemI", "i"); + } + else if (unlocalName.contains("itemHotIngot")){ + temp = unlocalName.replace("itemHotIngot", "ingotHot"); + } + if (temp != null && temp != ""){ + GT_OreDictUnificator.registerOre(temp, UtilsItems.getSimpleStack(this)); + } + generateCompressorRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Ingot"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("") && !unlocalName.contains("HotIngot")){ + list.add(EnumChatFormatting.GRAY+"A solid ingot of " + materialName + "."); + } + else if (materialName != null && materialName != "" && !materialName.equals("") && unlocalName.toLowerCase().contains("ingothot")){ + list.add(EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.RED+"Very hot! "+EnumChatFormatting.GRAY+" Avoid direct handling.."); + } + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void generateCompressorRecipe(){ + if (unlocalName.contains("itemIngot")){ + ItemStack tempStack = UtilsItems.getSimpleStack(this, 9); + ItemStack tempOutput = null; + String temp = getUnlocalizedName().replace("item.itemIngot", "block"); + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + temp = temp.replace("itemIngot", "block"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + if (temp != null && temp != ""){ + tempOutput = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + if (tempOutput != null){ + GT_ModHandler.addCompressionRecipe(tempStack, tempOutput); + } + + } + } + else if (unlocalName.contains("itemHotIngot")){ + return; + } + + + } + + + protected final int sRadiation; + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java new file mode 100644 index 0000000000..6fa358f36f --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java @@ -0,0 +1,73 @@ +package gtPlusPlus.core.item.base.ingots; + +import gregtech.api.enums.GT_Values; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BaseItemIngotHot extends BaseItemIngot{ + + private ItemStack outputIngot; + private int tickCounter = 0; + private int tickCounterMax = 200; + private int mTier; + + public BaseItemIngotHot(String unlocalizedName, String materialName, ItemStack coldIngot, int tier) { + super(unlocalizedName, materialName, Utils.rgbtoHexValue(225, 225, 225), 0); + this.setTextureName(CORE.MODID + ":" + "itemIngotHot"); + this.outputIngot = coldIngot; + this.mTier = tier; + generateRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("Hot "+materialName+ " Ingot"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A "+EnumChatFormatting.RED+"burning hot"+EnumChatFormatting.GRAY+" ingot of " + materialName + "."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + return Utils.rgbtoHexValue(225, 225, 225); + } + + private void generateRecipe(){ + Utils.LOG_WARNING("Adding Vacuum Freezer recipe for a Hot Ingot of "+materialName+"."); + GT_Values.RA.addVacuumFreezerRecipe(UtilsItems.getSimpleStack(this), outputIngot.copy(), 60*mTier); + + + } + + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + if (!world.isRemote){ + if(tickCounter < tickCounterMax){ + tickCounter++; + } + else if(tickCounter == tickCounterMax){ + entityHolding.attackEntityFrom(DamageSource.onFire, 1); + tickCounter = 0; + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } + } + + +} diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java new file mode 100644 index 0000000000..488f9a6f60 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.item.base.itemblock; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class ItemBlockBase extends ItemBlock { + + public ItemBlockBase(Block block) { + super(block); + this.setCreativeTab(AddToCreativeTab.tabBlock); + } + + @Override + public int getColorFromItemStack(ItemStack p_82790_1_, int p_82790_2_) { + + return super.getColorFromItemStack(p_82790_1_, p_82790_2_); + } + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java new file mode 100644 index 0000000000..04d01c2c97 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java @@ -0,0 +1,51 @@ +package gtPlusPlus.core.item.base.itemblock; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ItemBlockGtBlock extends ItemBlock{ + + protected final int blockColour; + protected final int sRadiation; + + public ItemBlockGtBlock(Block block) { + super(block); + this.blockColour = block.getBlockColor(); + if (block.getLocalizedName().toLowerCase().contains("uranium") || block.getLocalizedName().toLowerCase().contains("plutonium") || block.getLocalizedName().toLowerCase().contains("thorium")){ + sRadiation = 2; + } + else { + sRadiation = 0; + } + GT_OreDictUnificator.registerOre("block"+block.getUnlocalizedName().replace("tile.block", "").replace("tile.", "").replace("of", "").replace("Of", "").replace("Block", "").replace("-", "").replace("_", "").replace(" ", ""), UtilsItems.getSimpleStack(this)); + } + + public int getRenderColor(int aMeta) { + return blockColour; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java new file mode 100644 index 0000000000..c8d791b905 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.item.base.itemblock; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; + +public class ItemBlockGtFrameBox extends ItemBlock{ + + protected int blockColour; + + public ItemBlockGtFrameBox(Block block) { + super(block); + this.blockColour = block.getBlockColor(); + GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", ""), UtilsItems.getSimpleStack(this)); + } + + public int getRenderColor(int aMeta) { + return blockColour; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java new file mode 100644 index 0000000000..9d21198033 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java @@ -0,0 +1,92 @@ +package gtPlusPlus.core.item.base.plates; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemPlate extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemPlate(String unlocalizedName, String materialName, int colour, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemPlate"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemP", "p"), UtilsItems.getSimpleStack(this)); + addBendingRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Plate"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A flat plate of " + materialName + "."); + } + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + protected final int sRadiation; + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + + private void addBendingRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Plates"); + String tempIngot = unlocalName.replace("itemPlate", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + if (null != tempOutputStack){ + GT_Values.RA.addBenderRecipe(tempOutputStack, + UtilsItems.getSimpleStack(this), + 14*mTier*20, + 64*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java b/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java new file mode 100644 index 0000000000..d5c513c37d --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java @@ -0,0 +1,82 @@ +package gtPlusPlus.core.item.base.rings; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemRing extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemRing(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemRing"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Ring"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A " + materialName + " Ring."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Rings"); + String tempIngot = unlocalName.replace("itemRing", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Ring.get(1), + UtilsItems.getSimpleStack(this, 4), + 12*mTier*20, + 24*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java new file mode 100644 index 0000000000..befe7552ec --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java @@ -0,0 +1,100 @@ +package gtPlusPlus.core.item.base.rods; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemRod extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemRod(String unlocalizedName, String materialName, int colour, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setTextureName(CORE.MODID + ":" + "itemRod"); + this.setMaxStackSize(64); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemRod", "stick"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Rod"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A 40cm Rod of " + materialName + "."); + } + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + protected final int sRadiation; + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Rods"); + String tempIngot = unlocalName.replace("itemRod", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Rod.get(1), + UtilsItems.getSimpleStack(this, 2), + 12*mTier*20, 24*mTier); + } + ItemStack rods = UtilsItems.getSimpleStack(this, 1); + UtilsRecipe.addShapedGregtechRecipe( + rods, rods, rods, + rods, "craftingToolWrench", rods, + rods, rods, rods, + UtilsItems.getItemStackOfAmountFromOreDict(unlocalName.replace("itemRod", "frameGt"), 2)); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java new file mode 100644 index 0000000000..4e157d22b1 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java @@ -0,0 +1,99 @@ +package gtPlusPlus.core.item.base.rods; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemRodLong extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemRodLong(String unlocalizedName, String materialName, int colour, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setTextureName(CORE.MODID + ":" + "itemRodLong"); + this.setMaxStackSize(64); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemRod", "stick"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("Long "+materialName+ " Rod"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A 80cm Rod of " + materialName + "."); + } + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + protected final int sRadiation; + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for Long "+materialName+" Rods"); + String tempIngot = unlocalName.replace("itemRodLong", "stick"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 2); + if (null != tempOutputStack){ + GT_Values.RA.addForgeHammerRecipe(tempOutputStack, + UtilsItems.getSimpleStack(this, 1), + 12*mTier*20, 24*mTier); + } + ItemStack rods = UtilsItems.getSimpleStack(this, 1); + ItemStack tempOutputStack2 = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + UtilsRecipe.addShapedGregtechRecipe( + tempOutputStack2, "craftingToolHardHammer", tempOutputStack2, + null, null, null, + null, null, null, + rods); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java b/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java new file mode 100644 index 0000000000..d8ecea32bd --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java @@ -0,0 +1,93 @@ +package gtPlusPlus.core.item.base.rotors; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemRotor extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + + public BaseItemRotor(String unlocalizedName, String materialName, int colour) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemRotor"); + this.colour = colour; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); + generateRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Rotor"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A spindley Rotor made out of " + materialName + ". "); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + public static boolean getValidItemStack(ItemStack validStack){ + if (validStack != null){ + return true; + } + return false; + } + + public void generateRecipe(){ + + Utils.LOG_WARNING("Adding recipe for "+materialName+" Rotors"); + String tempIngot = unlocalName.replace("itemRotor", "plate"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + Utils.LOG_WARNING("Found for recipe:"+tempIngot+ "isValidStack()="+getValidItemStack(tempOutputStack)); + String screw = unlocalName.replace("itemRotor", "screw"); + ItemStack screwStack = UtilsItems.getItemStackOfAmountFromOreDict(screw, 1); + Utils.LOG_WARNING("Found for recipe:"+screw+ "isValidStack()="+getValidItemStack(screwStack)); + String ring = unlocalName.replace("itemRotor", "ring"); + ItemStack ringStack = UtilsItems.getItemStackOfAmountFromOreDict(ring, 1); + Utils.LOG_WARNING("Found for recipe:"+ring+ "isValidStack()="+getValidItemStack(ringStack)); + + UtilsRecipe.addShapedGregtechRecipe( + tempOutputStack, "craftingToolHardHammer", tempOutputStack, + screwStack, ringStack, "craftingToolFile", + tempOutputStack, "craftingToolScrewdriver", tempOutputStack, + UtilsItems.getSimpleStack(this)); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java new file mode 100644 index 0000000000..953c3a99a3 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java @@ -0,0 +1,85 @@ +package gtPlusPlus.core.item.base.screws; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemScrew extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemScrew(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemScrew"); + this.setMaxStackSize(64); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemS", "s"), UtilsItems.getSimpleStack(this)); + addLatheRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Screw"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A 8mm Screw, fabricated out of some " + materialName + "."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addLatheRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Screws"); + ItemStack boltStack = UtilsItems.getItemStackOfAmountFromOreDict(unlocalName.replace("itemScrew", "bolt"), 1); + if (null != boltStack){ + GT_Values.RA.addLatheRecipe(boltStack, + UtilsItems.getSimpleStack(this), null, + 60*mTier, 16*mTier); + UtilsRecipe.addShapedGregtechRecipe( + "craftingToolFile", boltStack, null, + boltStack, null, null, + null, null, null, + UtilsItems.getSimpleStack(this)); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/effects/RarityEffect.java b/src/Java/gtPlusPlus/core/item/effects/RarityEffect.java new file mode 100644 index 0000000000..cd5149b622 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/effects/RarityEffect.java @@ -0,0 +1,41 @@ +package gtPlusPlus.core.item.effects; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/* + * +This determines the name colour. EnumRarity can be: +EnumRarity.common - the standard white colour. +EnumRarity.uncommon - a yellow colour. +EnumRarity.rare - a light blue colour. This is used for enchanted items. +EnumRarity.epic - the purple colour used on the Golden Apple. +@SideOnly is an FML annotation. It marks the method below it for existing only on one side. Possible values are: +Side.CLIENT is probably the most common one. This marks the method as existing only on the client side. +Side.SERVER marks the method as existing only on the server side. + * + */ + +public class RarityEffect extends Item { + + public RarityEffect(int par1){ + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.common; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/effects/RarityEpic.java b/src/Java/gtPlusPlus/core/item/effects/RarityEpic.java new file mode 100644 index 0000000000..35c5527d16 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/effects/RarityEpic.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.item.effects; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RarityEpic extends Item { + + public RarityEpic(int par1){ + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.epic; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/effects/RarityRare.java b/src/Java/gtPlusPlus/core/item/effects/RarityRare.java new file mode 100644 index 0000000000..c64accb7aa --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/effects/RarityRare.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.item.effects; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RarityRare extends Item { + + public RarityRare(int par1){ + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.rare; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/effects/RarityUncommon.java b/src/Java/gtPlusPlus/core/item/effects/RarityUncommon.java new file mode 100644 index 0000000000..398217a24a --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/effects/RarityUncommon.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.item.effects; + +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RarityUncommon extends Item { + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java b/src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java new file mode 100644 index 0000000000..5a05ac7655 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/BedLocator_Base.java @@ -0,0 +1,107 @@ +package gtPlusPlus.core.item.general; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +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/gtPlusPlus/core/item/general/BufferCore.java b/src/Java/gtPlusPlus/core/item/general/BufferCore.java new file mode 100644 index 0000000000..6343ede855 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/BufferCore.java @@ -0,0 +1,93 @@ +package gtPlusPlus.core.item.general; + +import gtPlusPlus.core.item.base.BaseItemWithDamageValue; +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BufferCore extends BaseItemWithDamageValue{ + + public int coreTier = 0; + + public BufferCore(String unlocalizedName, int i) { + super(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(2); + this.coreTier = i; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return super.getItemStackDisplayName(stack)+" ["+CORE.VOLTAGES[this.coreTier-1]+"]."; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY+"A key crafting component for making energy buffers."); + super.addInformation(stack, aPlayer, list, bool); + } + + public final int getCoreTier() { + return coreTier; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + //Figure Out Damage + String s = String.format("%X", HEX_OxFFFFFF); + //Utils.LOG_INFO(s); + //String rgb = Utils.hex2Rgb(s); + //Utils.LOG_INFO(rgb); + if (coreTier == 1){ + HEX_OxFFFFFF = 0x4d4d4d; + } + else if (coreTier == 2){ + HEX_OxFFFFFF = 0x666666; + } + else if (coreTier == 3){ + HEX_OxFFFFFF = 0x8c8c8c; + } + else if (coreTier == 4){ + HEX_OxFFFFFF = 0xa6a6a6; + } + else if (coreTier == 5){ + HEX_OxFFFFFF = 0xcccccc; + } + else if (coreTier == 6){ + HEX_OxFFFFFF = 0xe6e6e6; + } + else if (coreTier == 7){ + HEX_OxFFFFFF = 0xffffcc; + } + else if (coreTier == 8){ + HEX_OxFFFFFF = 0xace600; + } + else if (coreTier == 9){ + HEX_OxFFFFFF = 0xffff00; + } + else if (coreTier == 10){ + HEX_OxFFFFFF = 0xff0000; + } + else { + HEX_OxFFFFFF = 0xffffff; + } + + + return HEX_OxFFFFFF; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java b/src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java new file mode 100644 index 0000000000..22b6ed27f1 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/ItemCloakingDevice.java @@ -0,0 +1,256 @@ +package gtPlusPlus.core.item.general; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import baubles.api.BaubleType; +import baubles.api.IBauble; +import cpw.mods.fml.common.registry.GameRegistry; + +public class ItemCloakingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble{ + + private final String unlocalizedName = "personalCloakingDevice"; + private final ItemStack thisStack; + private final static int maxValueEU = 10000*20*500; + protected double chargeEU = 0; + + public ItemCloakingDevice(double charge){ + this.chargeEU = charge; + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "personalCloakingDevice"); + this.thisStack = UtilsItems.getSimpleStack(this); + this.charge(thisStack, charge, 3, true, false); + if (charge == 10000*20*500){ + this.setDamage(thisStack, 13); + } + GameRegistry.registerItem(this, unlocalizedName+"-"+charge); + } + + @Override + public void onUpdate(ItemStack itemStack, World worldObj, Entity player, int p_77663_4_, boolean p_77663_5_) { + if (worldObj.isRemote) { + return; + } + + if (player instanceof EntityPlayer){ + for (ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { + if (is == itemStack) { + continue; + } + if (is != null) { + if (is.getItem() instanceof IElectricItem) { + IElectricItem electricItem = (IElectricItem) is.getItem(); + chargeEU = ElectricItem.manager.getCharge(is); + } + + } + } + } + + + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(ItemStack itemStack) { + return 5; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return 8196; + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (EnumChatFormatting.BLUE+"Personal Cloaking Device"+EnumChatFormatting.GRAY); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) + { + //return 1.0D - getEnergyStored(stack) / this.capacity; + return 1.0D - (double)getCharge(stack) / (double)getMaxCharge(stack); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return true; + } + + public int secondsLeft(ItemStack stack){ + double r = 0; + r = getCharge(stack)/(10000*20); + return (int) MathUtils.decimalRounding(r); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(""); + list.add(EnumChatFormatting.GREEN+"Worn as a Belt within Baubles."+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN+"Drains 10,000EU/t to provide invisibility."+EnumChatFormatting.GRAY); + list.add(""); + list.add(EnumChatFormatting.GOLD+"IC2/EU Information"+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY+"Tier: ["+EnumChatFormatting.YELLOW+getTier(thisStack)+EnumChatFormatting.GRAY+"] Input Limit: ["+EnumChatFormatting.YELLOW+getTransferLimit(thisStack)+EnumChatFormatting.GRAY +"EU/t]"); + list.add(EnumChatFormatting.GRAY+"Current Power: ["+EnumChatFormatting.YELLOW+(long) getCharge(stack)+EnumChatFormatting.GRAY+"EU] ["+EnumChatFormatting.YELLOW+MathUtils.findPercentage(getCharge(stack), getMaxCharge(stack))+EnumChatFormatting.GRAY +"%]"); + list.add(EnumChatFormatting.GRAY+"Time Remaining: ["+EnumChatFormatting.YELLOW+secondsLeft(stack)+ EnumChatFormatting.GRAY +" seconds]"); + super.addInformation(stack, aPlayer, list, bool); + } + + /*@Override + public ItemStack getContainerItem(ItemStack itemStack) + { + ItemStack newItem = itemStack.copy(); + newItem.stackSize = 1; + extractEnergy(newItem, 150000, false); + return newItem; + }*/ + + /*@Override + public boolean hasContainerItem(ItemStack stack) + { + return true; + }*/ + + /*@Override + public int getBurnTime(ItemStack fuel) { + if ((fuel == null) || (fuel.getItem() != this)) { + return 0; + } + return extractEnergy(fuel, 150000, true) / 50 / 100; + }*/ + + @Override + public double charge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean simulate) { + + if (!simulate) + { + ElectricItem.manager.charge(stack, amount, tier, true, simulate); + + } + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public double discharge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean externally, boolean simulate) { + if (!simulate) + { + ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(ItemStack stack, double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(ItemStack stack, double amount, EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(ItemStack stack, EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(ItemStack arg0, EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(ItemStack arg0, EntityLivingBase arg1) { + return true; + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.BELT; + } + + @Override //TODO + public void onEquipped(ItemStack arg0, EntityLivingBase arg1) { + + } + + @Override //TODO + public void onUnequipped(ItemStack arg0, EntityLivingBase arg1) { + + } + + @Override //TODO + public void onWornTick(ItemStack arg0, EntityLivingBase arg1) { + //Utils.LOG_INFO("Trying to Tick Belt. 1"); + if (!arg1.worldObj.isRemote){ + if (getCharge(arg0) >= 10000){ + arg1.addPotionEffect(new PotionEffect(Potion.invisibility.id, 10, 2)); + discharge(arg0, 10000, 5, true, true, false); + } + else { + if (arg1.isPotionActive((Potion.invisibility))){ + arg1.removePotionEffect(Potion.invisibility.id); + } + } + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java new file mode 100644 index 0000000000..728d498e2b --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java @@ -0,0 +1,228 @@ +package gtPlusPlus.core.item.general; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import baubles.api.BaubleType; +import baubles.api.IBauble; +import cpw.mods.fml.common.registry.GameRegistry; + +public class ItemHealingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble{ + + private final String unlocalizedName = "personalHealingDevice"; + private final ItemStack thisStack; + private final static int maxValueEU = 1000000000; + protected double chargeEU = 0; + + public ItemHealingDevice(){ + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "personalCloakingDevice"); + this.thisStack = UtilsItems.getSimpleStack(this); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void onUpdate(ItemStack itemStack, World worldObj, Entity player, int p_77663_4_, boolean p_77663_5_) { + if (worldObj.isRemote) { + return; + } + + if (player instanceof EntityPlayer){ + for (ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { + if (is == itemStack) { + continue; + } + if (is != null) { + if (is.getItem() instanceof IElectricItem) { + IElectricItem electricItem = (IElectricItem) is.getItem(); + chargeEU = ElectricItem.manager.getCharge(is); + } + + } + } + } + + + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(ItemStack itemStack) { + return 5; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return 32784; + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (EnumChatFormatting.BLUE+"Personal Healing NanoBooster"+EnumChatFormatting.RESET); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) + { + //return 1.0D - getEnergyStored(stack) / this.capacity; + return 1.0D - (double)getCharge(stack) / (double)getMaxCharge(stack); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return true; + } + + public double secondsLeft(ItemStack stack){ + + double r = 0; + r = getCharge(stack)/(1638400/4); + return (int) r; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(""); + list.add(EnumChatFormatting.GREEN+"Worn as a Necklace within Baubles."+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN+"Drains 1638400eu to restore hunger."+EnumChatFormatting.GRAY); + list.add(""); + list.add(EnumChatFormatting.GOLD+"IC2/EU Information"+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY+"Tier: ["+EnumChatFormatting.YELLOW+getTier(thisStack)+EnumChatFormatting.GRAY+"] Transfer Limit: ["+EnumChatFormatting.YELLOW+getTransferLimit(thisStack)+EnumChatFormatting.GRAY +"Eu/t]"); + list.add(EnumChatFormatting.GRAY+"Current Power: ["+EnumChatFormatting.YELLOW+(long) getCharge(stack)+EnumChatFormatting.GRAY+"Eu] ["+EnumChatFormatting.YELLOW+MathUtils.findPercentage(getCharge(stack), getMaxCharge(stack))+EnumChatFormatting.GRAY +"%]"); + list.add(EnumChatFormatting.GRAY+"Uses Remaining: ["+EnumChatFormatting.YELLOW+secondsLeft(stack)+ EnumChatFormatting.GRAY +"]"); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public double charge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean simulate) { + + if (!simulate) + { + ElectricItem.manager.charge(stack, amount, tier, true, simulate); + + } + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public double discharge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean externally, boolean simulate) { + if (!simulate) + { + ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(ItemStack stack, double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(ItemStack stack, double amount, EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(ItemStack stack, EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(ItemStack arg0, EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(ItemStack arg0, EntityLivingBase arg1) { + return true; + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override //TODO + public void onEquipped(ItemStack arg0, EntityLivingBase arg1) { + + } + + @Override //TODO + public void onUnequipped(ItemStack arg0, EntityLivingBase arg1) { + + } + + @Override //TODO + public void onWornTick(ItemStack arg0, EntityLivingBase arg1) { + if (!arg1.worldObj.isRemote){ + if (getCharge(arg0) >= 1638400/4){ + if (arg1.getHealth() < arg1.getMaxHealth()){ + float rx = arg1.getMaxHealth()-arg1.getHealth(); + Utils.LOG_INFO("rx:"+rx); + arg1.heal(rx*2); + discharge(arg0, (1638400/4)*rx, 6, true, true, false); + Utils.messagePlayer((EntityPlayer) arg1, "Your NanoBooster Whirs! Leaving you feeling stronger. It Healed "+rx+" hp."); + Utils.messagePlayer((EntityPlayer) arg1, "You check it's remaining uses, it has "+secondsLeft(arg0)+"."); + } + } + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java b/src/Java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java new file mode 100644 index 0000000000..f452b83a73 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java @@ -0,0 +1,210 @@ +package gtPlusPlus.core.item.general; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import cpw.mods.fml.common.eventhandler.Event; + +public class NuclearFuelRodBase extends Item +{ + /** field for checking if the bucket has been filled. */ + private Block isFull; + public NuclearFuelRodBase(Block p_i45331_1_) + { + this.maxStackSize = 1; + this.isFull = p_i45331_1_; + this.setCreativeTab(CreativeTabs.tabMisc); + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) + { + boolean flag = this.isFull == Blocks.air; + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(p_77659_2_, p_77659_3_, flag); + + if (movingobjectposition == null) + { + return p_77659_1_; + } + FillBucketEvent event = new FillBucketEvent(p_77659_3_, p_77659_1_, p_77659_2_, movingobjectposition); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return p_77659_1_; + } + + if (event.getResult() == Event.Result.ALLOW) + { + if (p_77659_3_.capabilities.isCreativeMode) + { + return p_77659_1_; + } + + if (--p_77659_1_.stackSize <= 0) + { + return event.result; + } + + if (!p_77659_3_.inventory.addItemStackToInventory(event.result)) + { + p_77659_3_.dropPlayerItemWithRandomChoice(event.result, false); + } + + return p_77659_1_; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!p_77659_2_.canMineBlock(p_77659_3_, i, j, k)) + { + return p_77659_1_; + } + + if (flag) + { + if (!p_77659_3_.canPlayerEdit(i, j, k, movingobjectposition.sideHit, p_77659_1_)) + { + return p_77659_1_; + } + + Material material = p_77659_2_.getBlock(i, j, k).getMaterial(); + int l = p_77659_2_.getBlockMetadata(i, j, k); + + if (material == Material.water && l == 0) + { + p_77659_2_.setBlockToAir(i, j, k); + return this.func_150910_a(p_77659_1_, p_77659_3_, Items.water_bucket); + } + + if (material == Material.lava && l == 0) + { + p_77659_2_.setBlockToAir(i, j, k); + return this.func_150910_a(p_77659_1_, p_77659_3_, Items.lava_bucket); + } + } + else + { + if (this.isFull == Blocks.air) + { + return new ItemStack(Items.bucket); + } + + if (movingobjectposition.sideHit == 0) + { + --j; + } + + if (movingobjectposition.sideHit == 1) + { + ++j; + } + + if (movingobjectposition.sideHit == 2) + { + --k; + } + + if (movingobjectposition.sideHit == 3) + { + ++k; + } + + if (movingobjectposition.sideHit == 4) + { + --i; + } + + if (movingobjectposition.sideHit == 5) + { + ++i; + } + + if (!p_77659_3_.canPlayerEdit(i, j, k, movingobjectposition.sideHit, p_77659_1_)) + { + return p_77659_1_; + } + + if (this.tryPlaceContainedLiquid(p_77659_2_, i, j, k) && !p_77659_3_.capabilities.isCreativeMode) + { + return new ItemStack(Items.bucket); + } + } + } + + return p_77659_1_; + } + + @SuppressWarnings("static-method") + private ItemStack func_150910_a(ItemStack p_150910_1_, EntityPlayer p_150910_2_, Item p_150910_3_) + { + if (p_150910_2_.capabilities.isCreativeMode) + { + return p_150910_1_; + } + else if (--p_150910_1_.stackSize <= 0) + { + return new ItemStack(p_150910_3_); + } + else + { + if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) + { + p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); + } + + return p_150910_1_; + } + } + + /** + * Attempts to place the liquid contained inside the bucket. + */ + public boolean tryPlaceContainedLiquid(World p_77875_1_, int p_77875_2_, int p_77875_3_, int p_77875_4_) + { + if (this.isFull == Blocks.air) + { + return false; + } + Material material = p_77875_1_.getBlock(p_77875_2_, p_77875_3_, p_77875_4_).getMaterial(); + boolean flag = !material.isSolid(); + + if (!p_77875_1_.isAirBlock(p_77875_2_, p_77875_3_, p_77875_4_) && !flag) + { + return false; + } + if (p_77875_1_.provider.isHellWorld && this.isFull == Blocks.flowing_water) + { + p_77875_1_.playSoundEffect((double)((float)p_77875_2_ + 0.5F), (double)((float)p_77875_3_ + 0.5F), (double)((float)p_77875_4_ + 0.5F), "random.fizz", 0.5F, 2.6F + (p_77875_1_.rand.nextFloat() - p_77875_1_.rand.nextFloat()) * 0.8F); + + for (int l = 0; l < 8; ++l) + { + p_77875_1_.spawnParticle("largesmoke", (double)p_77875_2_ + Math.random(), (double)p_77875_3_ + Math.random(), (double)p_77875_4_ + Math.random(), 0.0D, 0.0D, 0.0D); + } + } + else + { + if (!p_77875_1_.isRemote && flag && !material.isLiquid()) + { + p_77875_1_.func_147480_a(p_77875_2_, p_77875_3_, p_77875_4_, true); + } + + p_77875_1_.setBlock(p_77875_2_, p_77875_3_, p_77875_4_, this.isFull, 0, 3); + } + + return true; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/general/RF2EU_Battery.java b/src/Java/gtPlusPlus/core/item/general/RF2EU_Battery.java new file mode 100644 index 0000000000..f1141e1ef4 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/RF2EU_Battery.java @@ -0,0 +1,314 @@ +package gtPlusPlus.core.item.general; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; + +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +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.util.MathHelper; +import net.minecraft.world.World; +import cofh.api.energy.ItemEnergyContainer; +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, IElectricItemManager, IFuelHandler{ + + public static int rfPerEU = 4; + private final String unlocalizedName = "rfEUBattery"; + private final ItemStack thisStack; + private final static int maxValueEU = 100000000; + private final static int maxValueRF = maxValueEU * rfPerEU; + protected double chargeEU = 0; + + public RF2EU_Battery(){ + super(maxValueRF, maxValueRF, maxValueRF); + GameRegistry.registerFuelHandler(this); + //this.setMaxDamage(Integer.MAX_VALUE); + //this.setDamage(UtilsItems.getSimpleStack(this), 0); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "itemIngot"); + this.thisStack = UtilsItems.getSimpleStack(this); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void onUpdate(ItemStack itemStack, World worldObj, Entity player, int p_77663_4_, boolean p_77663_5_) { + getEnergyStored(itemStack); + if (worldObj.isRemote) { + return; + } + + if (player instanceof EntityPlayer){ + for (ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { + if (is == itemStack) { + continue; + } + if (is != null) { + if (is.getItem() instanceof IElectricItem) { + IElectricItem electricItem = (IElectricItem) is.getItem(); + chargeEU = ElectricItem.manager.getCharge(is); + } + + } + } + } + + + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(ItemStack itemStack) { + return 3; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return 8196; + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("Universally Chargeable Battery"); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) + { + //return 1.0D - getEnergyStored(stack) / this.capacity; + return MathUtils.findPercentage(getEnergyStored(stack), getMaxEnergyStored(stack)); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + int i = 30; + + float f13 = (float)(Minecraft.getSystemTime() % 6000L) / 3000.0F * 3.141592F * 2.0F; + + float t = 0.9F + 0.1F * MathHelper.cos(f13); + + double v = 1.0D - getDurabilityForDisplay(par1ItemStack); + + int r = i + (int)(v * (255 - i) * t); + if (r > 255) { + r = 255; + } + int g = i + (int)(v * (64 - i) * t); + + return r << 16 | g << 8 | i; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return false; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.YELLOW+"IC2/EU Information"+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY+"Tier: ["+EnumChatFormatting.YELLOW+getTier(thisStack)+EnumChatFormatting.GRAY+"] Current Power: ["+EnumChatFormatting.YELLOW+(long) getCharge(stack)+EnumChatFormatting.GRAY+"/EU]"); + list.add(EnumChatFormatting.GRAY+"Transfer Limit: ["+EnumChatFormatting.YELLOW+getTransferLimit(thisStack)+ EnumChatFormatting.GRAY +"Eu/t]" +"Burn Time: ["+EnumChatFormatting.YELLOW+getBurnTime(stack)/20+EnumChatFormatting.GRAY+"s]"); + list.add(""); + list.add(EnumChatFormatting.RED+"RF Information"); + list.add(EnumChatFormatting.GRAY+"Extraction Rate: [" +EnumChatFormatting.RED+ this.maxExtract + EnumChatFormatting.GRAY + "Rf/t]" + " Insert Rate: [" +EnumChatFormatting.RED+ this.maxReceive+EnumChatFormatting.GRAY+"Rf/t]"); + list.add(EnumChatFormatting.GRAY+"Current Charge: ["+EnumChatFormatting.RED+getEnergyStored(stack) + EnumChatFormatting.GRAY + "Rf / " + getMaxEnergyStored(stack)+"Rf] "+EnumChatFormatting.RED+MathUtils.findPercentage(getEnergyStored(stack), getMaxEnergyStored(stack))+EnumChatFormatting.GRAY+"%"); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) + { + ItemStack newItem = itemStack.copy(); + newItem.stackSize = 1; + extractEnergy(newItem, 150000, false); + return newItem; + } + + @Override + public boolean hasContainerItem(ItemStack stack) + { + return true; + } + + @Override + public int getBurnTime(ItemStack fuel) { + if ((fuel == null) || (fuel.getItem() != this)) { + return 0; + } + return extractEnergy(fuel, 150000, true) / 50 / 100; + } + + @Override + public double charge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean simulate) { + if (stack.stackTagCompound == null) { + stack.stackTagCompound = new NBTTagCompound(); + } + int energy = stack.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) + { + energy += energyReceived; + stack.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(stack, ElectricItem.manager.getCharge(stack), 3, true, true, false); + ElectricItem.manager.charge(stack, energy/rfPerEU, 3, true, false); + + } + return ElectricItem.manager.charge(stack, amount, tier, ignoreTransferLimit, simulate); + } + + @Override + public double discharge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean externally, boolean simulate) { + if ((stack.stackTagCompound == null) || (!stack.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } + return 0; + } + int energy = stack.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (!simulate) + { + energy -= energyExtracted; + stack.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(stack, ElectricItem.manager.getCharge(stack), 3, true, true, false); + ElectricItem.manager.charge(stack, energy/rfPerEU, 3, true, false); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(ItemStack stack, double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(ItemStack stack, double amount, EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(ItemStack stack, EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) + { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) + { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy/rfPerEU, 3, true, false); + + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) + { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (!simulate) + { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy/rfPerEU, 3, true, false); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) + { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy/rfPerEU, 3, true, false); + return energy; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java b/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java new file mode 100644 index 0000000000..36e6c66df8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java @@ -0,0 +1,223 @@ +package gtPlusPlus.core.item.general.fuelrods; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +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 FuelRod_Base extends Item{ + + public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = getMaxHeat(); + public FuelRod_Base(String unlocalizedName, String type, int fuelLeft, int maxFuel) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(maxFuel); + this.maximumFuel = maxFuel; + this.fuelRemaining = fuelLeft; + this.fuelType = type; + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + private float getMaxHeat(){ + float tempvar; + if (fuelType == "Thorium"){ + tempvar = 2500; + } + + else if (fuelType == "Uranium"){ + tempvar = 5000; + } + + else if (fuelType == "Plutonium"){ + tempvar = 10000; + } + + else { + tempvar = 5000; + } + return tempvar; + + } + + 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) { + + Float NBT_Heat = heat; + Float NBT_MaxHeat = maxHeat; + int NBT_Fuel = fuelRemaining; + String NBT_Type= fuelType; + + 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"); + } + + String tempHeat = String.valueOf(NBT_Heat); + String tempMaxHeat = String.valueOf(NBT_MaxHeat); + String tempFuel = String.valueOf(NBT_Fuel); + String formattedType = EnumChatFormatting.DARK_RED+NBT_Type+EnumChatFormatting.GRAY; + String formattedHeat = EnumChatFormatting.RED+tempHeat+EnumChatFormatting.GRAY; + String formattedMaxHeat = EnumChatFormatting.RED+tempMaxHeat+EnumChatFormatting.GRAY; + String formattedFuelLeft = tempFuel+EnumChatFormatting.GRAY; + + int tempMax = maximumFuel; + float tempCurrentHeat = heat; + int tempFuelLeft = fuelRemaining; + + //Fuel Usage Formatting + if (tempFuelLeft <= maximumFuel/3){ + formattedFuelLeft = EnumChatFormatting.RED+tempFuel+EnumChatFormatting.GRAY; + } + else if (tempFuelLeft >= maximumFuel/3 && tempFuelLeft <= (maximumFuel/3)*2){ + formattedFuelLeft = EnumChatFormatting.YELLOW+tempFuel+EnumChatFormatting.GRAY; + } + else if (tempFuelLeft >= (maximumFuel/3)*2 && tempFuelLeft <= maximumFuel){ + formattedFuelLeft = EnumChatFormatting.GREEN+tempFuel+EnumChatFormatting.GRAY; + } + else { + formattedFuelLeft = EnumChatFormatting.GRAY+tempFuel+EnumChatFormatting.GRAY; + } + + //Heat Formatting + if (tempCurrentHeat <= 200 && tempCurrentHeat >= 0){ + formattedHeat = EnumChatFormatting.GRAY+tempHeat+EnumChatFormatting.GRAY; + } + else if (tempCurrentHeat <= maxHeat/3 && tempCurrentHeat > 200){ + formattedHeat = EnumChatFormatting.YELLOW+tempHeat+EnumChatFormatting.GRAY; + } + 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(ItemStack stack){ + if (stack.stackTagCompound != null){ + return stack.stackTagCompound.getString("fuelType"); + } + return fuelType; + } + + public int getFuelRemaining(ItemStack stack){ + if (stack.stackTagCompound != null){ + return stack.stackTagCompound.getInteger("fuelRemaining"); + } + return 0; + } + + public int getMaxFuel(){ + return maximumFuel; + } + + public int getFuel(ItemStack stack){ + if (stack != null){ + int i = stack.getItemDamage(); + int r = maximumFuel - i; + return r; + } + return getFuelRemaining(stack); + } + + public boolean setFuelRemainingExplicitly(int i){ + int tempFuel = fuelRemaining; + fuelRemaining = i; + if (i != tempFuel){ + return true; + } + return false; + } + + public boolean addFuel(int i){ + int tempFuel = fuelRemaining; + fuelRemaining = tempFuel+i; + if (fuelRemaining != tempFuel){ + return true; + } + return false; + } + + public float getHeat(ItemStack value){ + if (value.stackTagCompound != null){ + return value.stackTagCompound.getFloat("heat"); + } + return 0f; + } + + public boolean addHeat(float i){ + float tempFuel = heat; + heat = tempFuel+i; + if (heat != tempFuel){ + return true; + } + return false; + } + + + //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(); + itemStack.stackTagCompound.setInteger("fuelRemaining", getFuelRemaining(itemStack)); + itemStack.stackTagCompound.setInteger("maximumFuel", maximumFuel); + 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)); + itemStack.stackTagCompound.setInteger("maximumFuel", maximumFuel); + itemStack.stackTagCompound.setFloat("heat", getHeat(itemStack)); + itemStack.stackTagCompound.setFloat("maxHeat", getMaxHeat()); + itemStack.stackTagCompound.setString("fuelType", getType(itemStack)); + updateVars(itemStack); + } + + + +} diff --git a/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java b/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java new file mode 100644 index 0000000000..9b852cb1ea --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java @@ -0,0 +1,13 @@ +package gtPlusPlus.core.item.general.fuelrods; + +public class FuelRod_Thorium extends FuelRod_Base{ + + public FuelRod_Thorium(String unlocalizedName, String type, int fuelLeft, int maxFuel) { + super(unlocalizedName, type, fuelLeft, maxFuel); + this.setMaxDamage(maxFuel); + this.maximumFuel = maxFuel; + this.fuelRemaining = fuelLeft; + this.fuelType = type; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java b/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java new file mode 100644 index 0000000000..8f1a2083ac --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java @@ -0,0 +1,43 @@ +package gtPlusPlus.core.item.init; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.base.foods.BaseItemFood; +import gtPlusPlus.core.item.base.foods.BaseItemHotFood; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; + +public class ItemsFoods { + + public static void load(){ + run(); + } + + private static void run(){ + + //Raisin Bread + ModItems.itemIngotRaisinBread = new BaseItemFood("itemIngotRaisinBread", "Raisin Bread", 3, 1.5f, false, new PotionEffect(Potion.weakness.id, 40, 1)).setAlwaysEdible(); + GT_OreDictUnificator.registerOre("foodRaisinBread", UtilsItems.getItemStack(CORE.MODID+":itemIngotRaisinBread", 1)); + //Hot Raisin Bread + ModItems.itemHotIngotRaisinBread = new BaseItemHotFood("itemHotIngotRaisinBread", 1, 0.5f, "Raisin Bread", 120, ModItems.itemIngotRaisinBread); + GT_OreDictUnificator.registerOre("foodHotRaisinBread", UtilsItems.getItemStack(CORE.MODID+":itemHotIngotRaisinBread", 1)); + + //Raisin Bread + ModItems.itemFoodRaisinToast = new BaseItemFood("itemFoodRaisinToast", "Raisin Toast", 1, 0.5f, false).setAlwaysEdible(); + GT_OreDictUnificator.registerOre("foodRaisinToast", UtilsItems.getItemStack(CORE.MODID+":itemFoodRaisinToast", 1)); + //Hot Raisin Bread + ModItems.itemHotFoodRaisinToast = new BaseItemHotFood("itemHotFoodRaisinToast", 1, 0.5f, "Raisin Toast", 20, ModItems.itemFoodRaisinToast); + GT_OreDictUnificator.registerOre("foodHotRaisinToast", UtilsItems.getItemStack(CORE.MODID+":itemHotFoodRaisinToast", 1)); + + //Raisin Bread + ModItems.itemFoodCurriedSausages = new BaseItemFood("itemFoodCurriedSausages", "Curried Sausages", 5, 2f, false); + GT_OreDictUnificator.registerOre("foodCurriedSausages", UtilsItems.getItemStack(CORE.MODID+":itemFoodCurriedSausages", 1)); + //Hot Raisin Bread + ModItems.itemHotFoodCurriedSausages = new BaseItemHotFood("itemHotFoodCurriedSausages", 1, 0.5f, "Curried Sausages", 240, ModItems.itemFoodCurriedSausages); + GT_OreDictUnificator.registerOre("foodHotCurriedSausages", UtilsItems.getItemStack(CORE.MODID+":itemHotFoodCurriedSausages", 1)); + + } + +} diff --git a/src/Java/gtPlusPlus/core/item/materials/MaterialHandler.java b/src/Java/gtPlusPlus/core/item/materials/MaterialHandler.java new file mode 100644 index 0000000000..0f89f2a0ff --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/materials/MaterialHandler.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.item.materials; + +public class MaterialHandler { + + @SuppressWarnings("unused") + private String Staballoy; + + + +} diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java b/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java new file mode 100644 index 0000000000..108ac4b83d --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java @@ -0,0 +1,79 @@ +package gtPlusPlus.core.item.tool.misc; + +import gtPlusPlus.core.item.base.BaseItemWithDamageValue; +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SandstoneHammer extends BaseItemWithDamageValue{ + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getColorFromItemStack(net.minecraft.item.ItemStack, int) + */ + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + //Figure Out Damage + + + return super.getColorFromItemStack(stack, HEX_OxFFFFFF); + } + + public SandstoneHammer(String unlocalizedName) { + super(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(2500); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY+"Allows you to craft sand from cobble, or sandstone from sand."); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) + { + return false; + } + + @Override + public boolean getShareTag() + { + return true; + } + + @Override + public boolean hasContainerItem(ItemStack itemStack) + { + return true; + } + @Override + public ItemStack getContainerItem(ItemStack itemStack) + { + itemStack.setItemDamage(itemStack.getItemDamage() + 8); + + return itemStack; + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return false; + } + + +} diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java new file mode 100644 index 0000000000..ea59ed2b7e --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java @@ -0,0 +1,179 @@ +package gtPlusPlus.core.item.tool.staballoy; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.player.UtilsMining; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class MultiPickaxeBase extends StaballoyPickaxe{ + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0){ + return super.getDurabilityForDisplay(stack);} + return 0; + } + + protected Boolean FACING_HORIZONTAL = true; + protected String FACING = "north"; + protected EntityPlayer localPlayer; + protected String lookingDirection; + protected World localWorld; + protected ItemStack thisPickaxe = null; + protected final int colour; + protected final String materialName; + + public MultiPickaxeBase(String unlocalizedName, ToolMaterial material, int materialDurability, int colour) { + super(Utils.sanitizeString(unlocalizedName), material); + this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); + this.setTextureName(CORE.MODID + ":" + "itemPickaxe"); + this.FACING_HORIZONTAL=true; + this.setMaxStackSize(1); + this.setMaxDamage(materialDurability); + this.colour = colour; + this.materialName = material.name(); + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + this.setCreativeTab(AddToCreativeTab.tabTools); + } + + /* + * + * + * + * Methods + * + * + * + */ + + public final String getMaterialName() { + return materialName; + } + + @Override + public String getItemStackDisplayName(ItemStack iStack) { + + String name; + if (getUnlocalizedName().toLowerCase().contains("wood")){ + name = "Wooden"; + } + else if (getUnlocalizedName().toLowerCase().contains("cobblestone")){ + name = "Cobblestone"; + } + else if (getUnlocalizedName().toLowerCase().contains("iron")){ + name = "Iron"; + } + else if (getUnlocalizedName().toLowerCase().contains("gold")){ + name = "Gold"; + } + else if (getUnlocalizedName().toLowerCase().contains("diamond")){ + name = "Diamond"; + } + else { + name = materialName; + } + return name+" Multipickaxe"; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + @SuppressWarnings("static-method") + private float calculateDurabilityLoss(World world, int X, int Y, int Z){ + float bDurabilityLoss = 0; + Boolean correctTool = false; + float bHardness = 0; + if (!world.isRemote){ + try { + Block removalist = world.getBlock(X, Y, Z); + //Utils.LOG_WARNING(removalist.toString()); + + bHardness = removalist.getBlockHardness(world, X, Y, Z); + Utils.LOG_WARNING("Hardness: "+bHardness); + + bDurabilityLoss = (bDurabilityLoss + bHardness); + //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); + + correctTool = canPickaxeBlock(removalist, world); + Utils.LOG_WARNING(""+correctTool); + + if (!correctTool){ + return 0; + } + + } catch (NullPointerException e){ + + } + } + return bDurabilityLoss; + } + + @Override + public int doDurabilityDamage(int x){ + return x; + } + + //Should clear up blocks quicker if I chain it. + @Override + public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; + try { + Block block = world.getBlock(X, Y, Z); + float dur = calculateDurabilityLoss(world, X, Y, Z); + Utils.LOG_WARNING(block.toString()); + String removalTool = ""; + removalTool = block.getHarvestTool(1); + + if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block)){ + if (canPickaxeBlock(block, world)){ + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + + if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ + + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + + } + + } + } + else { + Utils.LOG_WARNING("Incorrect Tool for mining this block."); + } + } + } catch (NullPointerException e){ + + } + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return false; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java new file mode 100644 index 0000000000..07c5800a1f --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java @@ -0,0 +1,279 @@ +package gtPlusPlus.core.item.tool.staballoy; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockCocoa; +import net.minecraft.block.BlockDirt; +import net.minecraft.block.BlockDoublePlant; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.BlockGrass; +import net.minecraft.block.BlockHugeMushroom; +import net.minecraft.block.BlockLeavesBase; +import net.minecraft.block.BlockLog; +import net.minecraft.block.BlockMushroom; +import net.minecraft.block.BlockSand; +import net.minecraft.block.BlockSnow; +import net.minecraft.block.BlockSnowBlock; +import net.minecraft.block.BlockTallGrass; +import net.minecraft.block.BlockVine; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class StaballoyAxe extends ItemAxe{ + public String mat; + + public StaballoyAxe(String unlocalizedName, ToolMaterial material) { + super(material); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + } + + // EXPLODE TREE + byte[] tre= new byte[32000]; + byte unchecked=0; + byte needcheck=1; + byte ignore =2; + byte harvest =3; + + private boolean setcheck(int x, int y, int z) { + if(x<0 || x>19 || z<0 || z>19 || y<0 || y>79) return false; + int o=x+z*20+y*400; + if (tre[o]==unchecked) tre[o]=needcheck; + return true; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+"Fells entire trees in a single swipe!.."); + list.add(EnumChatFormatting.GRAY+"Ask Alkalus for new trees to be supported."); + super.addInformation(stack, aPlayer, list, bool); + } + + public boolean canIgnore(Block bit){ + if (bit instanceof BlockAir)return true; + if (bit instanceof BlockGrass)return true; + if (bit instanceof BlockSand)return true; + if (bit instanceof BlockDirt)return true; + if (bit instanceof BlockCocoa)return true; + if (bit instanceof BlockVine)return true; + if (bit instanceof BlockMushroom)return true; + if (bit instanceof BlockSnow)return true; + if (bit instanceof BlockSnowBlock)return true; + if (bit instanceof BlockFlower)return true; + if (bit instanceof BlockTallGrass)return true; + if (bit instanceof BlockDoublePlant)return true; + + //LoonTools.log("Found uncuttable "+bit.getClass().getSimpleName()); + return false; + } + + private int check(World par1World, int x, int y, int z, int xo, int yo,int zo) { + int f=0; + int o=x+z*20+y*400; + if (tre[o]==needcheck){ + tre[o]=ignore; + Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase)||(bit instanceof BlockHugeMushroom) || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ + f=1; + tre[o]=harvest; + //if (bit instanceof BlockLog){ + // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" "); + //} + for(int xb=-1;xb<2;xb++) + for(int yb=-1;yb<2;yb++) + for(int zb=-1;zb<2;zb++) + if (!setcheck(x+xb,y+yb,z+zb))return 3; + }else{ + if (!canIgnore(bit)) return 2; + } + } + return f; + } + + public int checkTree(World par1World,int xo,int yo,int zo){ + boolean f; + for (f=true;f==true;){ + f=false; + for (int y=0;y<80;y++) + for(int z=0;z<20;z++) + for(int x=0;x<20;x++){ + int r=check(par1World,x,y,z,xo,yo,zo); + if (r==3) return 3; + if (r==2) return 2; + if (r==1) f=true; + } + + for (int y=79;y>=0;y--) + for(int z=19;z>=0;z--) + for(int x=19;x>=0;x--){ + int r=check(par1World,x,y,z,xo,yo,zo); + if (r==2) return 3; + if (r==2) return 2; + if (r==1) f=true; + } + } + return 1; + } + + private int check2(World par1World, int x, int y, int z, int xo, int yo,int zo) { + int f=0; + int o=x+z*20+y*400; + if (tre[o]==needcheck){ + tre[o]=ignore; + Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + if (bit instanceof BlockLog){ + f=1; + tre[o]=harvest; + //if (bit instanceof BlockLog){ + // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" "); + //} + for(int xb=-1;xb<2;xb++) + for(int yb=-1;yb<2;yb++) + for(int zb=-1;zb<2;zb++) + if (!setcheck(x+xb,y+yb,z+zb))return 3; + }else if (bit instanceof BlockLeavesBase){ + }else{ + if (!canIgnore(bit)) return 2; + } + } + return f; + } + + public int checkTree2(World par1World,int xo,int yo,int zo){ + boolean f; + for (f=true;f==true;){ + f=false; + for (int y=0;y<80;y++) + for(int z=0;z<20;z++) + for(int x=0;x<20;x++){ + int r=check2(par1World,x,y,z,xo,yo,zo); + if (r==3) return 3; + if (r==2) return 2; + if (r==1) f=true; + } + + for (int y=79;y>=0;y--) + for(int z=19;z>=0;z--) + for(int x=19;x>=0;x--){ + int r=check2(par1World,x,y,z,xo,yo,zo); + if (r==2) return 3; + if (r==2) return 2; + if (r==1) f=true; + } + } + return 1; + } + + public void exploadTree(World par1World,int xo,int yo,int zo, EntityPlayer plr){ + for (int y=0;y<80;y++) + for(int z=0;z<20;z++) + for(int x=0;x<20;x++){ + int o=x+z*20+y*400; + if (tre[o]==harvest){ + Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo); + + if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase) || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ + bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met); + par1World.setBlockToAir(x+xo, y+yo, z+zo); + } + } + } + } + + private void breakMushroom(World wld, Block bit, EntityPlayer plr, boolean silk, int x, int y, int z, int met) { + if (silk){ + ItemStack stk = null; //TODO + /*if (bit==Blocks.brown_mushroom_block) stk = new ItemStack(LoonToolItems.brown_mushroom_block,1,met); + else if (bit==Blocks.red_mushroom_block) stk = new ItemStack(LoonToolItems.red_mushroom_block,1,met); + else stk = new ItemStack(bit,1,met);*/ + EntityItem entityitem = new EntityItem(wld, x+0.5, y+0.5, z+0.5, stk); + entityitem.delayBeforeCanPickup = 10; + wld.spawnEntityInWorld(entityitem); + }else{ + bit.harvestBlock(wld, plr, x, y, z, met); + } + wld.setBlockToAir(x, y, z); + } + + public void exploadMushroom(World par1World,int xo,int yo,int zo, EntityPlayer plr, boolean silk){ + for (int y=0;y<80;y++) + for(int z=0;z<20;z++) + for(int x=0;x<20;x++){ + int o=x+z*20+y*400; + if (tre[o]==harvest){ + Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo); + if (bit instanceof BlockHugeMushroom){ + breakMushroom(par1World, bit, plr, silk, x+xo, y+yo, z+zo,met); + }else{ + bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met); + par1World.setBlockToAir(x+xo, y+yo, z+zo); + } + } + } + } + + + @Override + public boolean onBlockDestroyed(ItemStack itm, World wld,Block blk, int x, int y,int z, EntityLivingBase plr) { + if (!wld.isRemote){ + Block bit = wld.getBlock(x, y, z); + boolean silk=EnchantmentHelper.getSilkTouchModifier(plr); + if ((bit instanceof BlockHugeMushroom)){ + for (int n=0;n<32000;n++) tre[n]=unchecked; + int met = wld.getBlockMetadata(x, y, z); + breakMushroom(wld, bit, (EntityPlayer) plr, silk, x, y, z,met); + wld.setBlockToAir(x,y,z); + tre[2210]=needcheck; + if (checkTree(wld,x-10,y-4,z-10)==1){ + exploadMushroom(wld,x-10,y-4,z-10,(EntityPlayer) plr,silk); + } + } + + if (bit instanceof BlockLog || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ + //LoonTools.log("cutting tree @ "+x+" "+y+" "+z+" "); + for (int n=0;n<32000;n++) tre[n]=unchecked; + int met = wld.getBlockMetadata(x, y, z); + bit.harvestBlock(wld, (EntityPlayer) plr, x, y, z,met); + wld.setBlockToAir(x,y,z); + tre[2210]=needcheck; + if (checkTree(wld,x-10,y-4,z-10)==1){ + exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr); + }else{ + for (int n=0;n<32000;n++) tre[n]=unchecked; + tre[2210]=needcheck; + if (checkTree2(wld,x-10,y-4,z-10)==1){ + exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr); + } + } + } + } + return super.onBlockDestroyed(itm, wld, blk, x, y, z, plr); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.rare; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java new file mode 100644 index 0000000000..a21ee7e6ad --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java @@ -0,0 +1,310 @@ +package gtPlusPlus.core.item.tool.staballoy; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.UtilsMining; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class StaballoyPickaxe extends ItemPickaxe{ + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0){ + return super.getDurabilityForDisplay(stack);} + return 0; + } + + protected Boolean FACING_HORIZONTAL = true; + protected String FACING = "north"; + protected EntityPlayer localPlayer; + protected String lookingDirection; + protected World localWorld; + public ItemStack thisPickaxe = null; + + /* + * + * + * + * Methods + * + * + * + */ + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer aPlayer) { + localPlayer = aPlayer; + localWorld = world; + thisPickaxe = stack; + return super.onItemRightClick(stack, world, aPlayer); + } + + + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int X, int Y, int Z, EntityLivingBase entity) { + //super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); + localWorld = world; + thisPickaxe = stack; + //checkFacing(world); + if (!world.isRemote){ + GetDestroyOrientation(lookingDirection, world, X, Y, Z, stack); + } + + return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); + } + + @SuppressWarnings("static-method") + private float calculateDurabilityLoss(World world, int X, int Y, int Z){ + float bDurabilityLoss = 0; + Boolean correctTool = false; + float bHardness = 0; + if (!world.isRemote){ + try { + Block removalist = world.getBlock(X, Y, Z); + //Utils.LOG_WARNING(removalist.toString()); + + bHardness = removalist.getBlockHardness(world, X, Y, Z); + Utils.LOG_WARNING("Hardness: "+bHardness); + + bDurabilityLoss = (bDurabilityLoss + bHardness); + //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); + + correctTool = canPickaxeBlock(removalist, world); + Utils.LOG_WARNING(""+correctTool); + + if (!correctTool){ + return 0; + } + + } catch (NullPointerException e){ + + } + } + return bDurabilityLoss; + } + + public Boolean canPickaxeBlock(Block currentBlock, World currentWorld){ + String correctTool = ""; + if (!currentWorld.isRemote){ + try { + correctTool = currentBlock.getHarvestTool(0); + //Utils.LOG_WARNING(correctTool); + if (UtilsMining.getBlockType(currentBlock) || correctTool.equals("pickaxe")){ + return true;} + } catch (NullPointerException e){ + return false;} + } + return false; + } + + private void GetDestroyOrientation(String FACING, World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; + float DURABILITY_LOSS = 0; + if (!world.isRemote){ + + if (FACING.equals("below") || FACING.equals("above")){ + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + float dur = calculateDurabilityLoss(world, X + i, Y, Z + j); + DURABILITY_LOSS = (DURABILITY_LOSS + calculateDurabilityLoss(world, X + i, Y, Z + j)); + Utils.LOG_WARNING("Added Loss: "+dur); + removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem); + } + } + } + + else if (FACING.equals("facingEast") || FACING.equals("facingWest")){ + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + float dur = calculateDurabilityLoss(world, X, Y + i, Z + j); + DURABILITY_LOSS = (DURABILITY_LOSS + calculateDurabilityLoss(world, X, Y + i, Z + j)); + Utils.LOG_WARNING("Added Loss: "+dur); + removeBlockAndDropAsItem(world, X , Y + i, Z + j, heldItem); + } + } + } + + else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){ + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + float dur = calculateDurabilityLoss(world, X + j, Y + i, Z); + DURABILITY_LOSS = (DURABILITY_LOSS + dur); + Utils.LOG_WARNING("Added Loss: "+dur); + removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem); + } + } + } + + //int heldItemDurability = heldItem.getDamage(1); + Utils.LOG_WARNING("Total Loss: "+(int)DURABILITY_LOSS); + //heldItem.setDamage(heldStack, DURABILITY_LOSS); + //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); + //Utils.LOG_WARNING("Durability: "+heldStack.getDamage(heldStack)); + if (heldItem.getItemDamage() < (heldItem.getMaxDamage()-DURABILITY_LOSS)){ + heldItem.damageItem((int) DURABILITY_LOSS, localPlayer); + } + //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); + DURABILITY_LOSS = 0; + + } + } + + public int doDurabilityDamage(int x){ + return x; + } + + //Should clear up blocks quicker if I chain it. + public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; + try { + Block block = world.getBlock(X, Y, Z); + float dur = calculateDurabilityLoss(world, X, Y, Z); + Utils.LOG_WARNING(block.toString()); + String removalTool = ""; + removalTool = block.getHarvestTool(1); + + if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block)){ + if (canPickaxeBlock(block, world)){ + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + + if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ + + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + + } + + } + } + else { + Utils.LOG_WARNING("Incorrect Tool for mining this block."); + } + } + } catch (NullPointerException e){ + + } + } + + public boolean checkFacing(World world){ + localWorld = world; + if (localPlayer != null){ + int direction = MathHelper.floor_double((double)((localPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3; + //Utils.LOG_WARNING("Player - F: "+direction); + //Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord); + + /*if (localPlayer.getLookVec().yCoord > 0){ + localPlayer.getLookVec().yCoord; + }*/ + + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, (EntityPlayer) localPlayer, false); + if (movingobjectposition != null){ + int sideHit = movingobjectposition.sideHit; + String playerStandingPosition = ""; + if (movingobjectposition != null) { + //System.out.println("Side Hit: "+movingobjectposition.sideHit); + } + + if (sideHit == 0){ + playerStandingPosition = "above"; + FACING_HORIZONTAL = false; + } + else if (sideHit == 1){ + playerStandingPosition = "below"; + FACING_HORIZONTAL = false; + } + else if (sideHit == 2){ + playerStandingPosition = "facingSouth"; + FACING_HORIZONTAL = true; + } + else if (sideHit == 3){ + playerStandingPosition = "facingNorth"; + FACING_HORIZONTAL = true; + } + else if (sideHit == 4){ + playerStandingPosition = "facingEast"; + FACING_HORIZONTAL = true; + } + else if (sideHit == 5){ + playerStandingPosition = "facingWest"; + FACING_HORIZONTAL = true; + } + lookingDirection = playerStandingPosition; + + if (direction == 0){ + FACING = "south"; + } + else if (direction == 1){ + FACING = "west"; + } + else if (direction == 2){ + FACING = "north"; + } + else if (direction == 3){ + FACING = "east"; + } + } + + + return true; + } + return false; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + thisPickaxe = stack; + list.add(EnumChatFormatting.GOLD+"Mines a 3x3 area in the direction you are facing."); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.rare; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + + + @Override + public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer aPlayer) { + thisPickaxe = itemstack; + localPlayer = aPlayer; + checkFacing(localPlayer.worldObj); + return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer); + } + public StaballoyPickaxe(String unlocalizedName, ToolMaterial material) { + super(material); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.FACING_HORIZONTAL=true; + this.setMaxStackSize(1); + this.setMaxDamage(3200); + } +} diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java new file mode 100644 index 0000000000..262f46b831 --- /dev/null +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -0,0 +1,96 @@ +package gtPlusPlus.core.lib; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.gregtech.recipehandlers.GregtechRecipe; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.config.Configuration; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CORE { + + public static final String name = "GT++"; + public static final String MODID = "miscutils"; + public static final String VERSION = "1.4.4.2-release"; + public static boolean DEBUG = false; + public static final boolean LOAD_ALL_CONTENT = false; + public static final int GREG_FIRST_ID = 760; + public static Map PlayerCache; + public static final String[] VOLTAGES = {"ULV","LV","MV","HV","EV","IV","LuV","ZPM","UV","MAX"}; + public static final boolean MAIN_GREGTECH_5U_EXPERIMENTAL_FORK = Meta_GT_Proxy.areWeUsingGregtech5uExperimental(); + public static IGregtech_RecipeAdder RA; + @Deprecated + public static IGregtech_RecipeAdder sRecipeAdder; + public static GregtechRecipe GT_Recipe = new GregtechRecipe(); + + @SideOnly(Side.CLIENT) + public static IIconRegister GT_BlockIcons, GT_ItemIcons; + public static List<Runnable> GT_BlockIconload = new ArrayList<Runnable>(); + public static final Class<AddToCreativeTab> TAB = AddToCreativeTab.class; + public static Configuration Config; + public static final String GT_Tooltip = "Added by: " + EnumChatFormatting.DARK_GREEN+"Alkalus "+EnumChatFormatting.GRAY+"- "+EnumChatFormatting.RED+"[GT++]"; + public static final String GT_Tooltip_Radioactive = EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.GREEN+"Radioactive! "+EnumChatFormatting.GOLD+" Avoid direct handling without hazmat protection."; + public static final String noItem = ""; + + /** + * A List containing all the Materials, which are somehow in use by GT and therefor receive a specific Set of Items. + */ + public static final GT_Materials[] sMU_GeneratedMaterials = new GT_Materials[1000]; + + //GUIS + public enum GUI_ENUM + { + ENERGYBUFFER, TOOLBUILDER, NULL, NULL1, NULL2 + } + + /** + * File Paths and Resource Paths + */ + public static final String + TEX_DIR = "textures/", + TEX_DIR_GUI = TEX_DIR + "gui/", + TEX_DIR_ITEM = TEX_DIR + "items/", + 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_FLUIDS = MODID + ":" + TEX_DIR_FLUIDS; + + + //public static final Materials2[] MiscGeneratedMaterials = new Materials2[1000]; + + public static class configSwitches { + + //Debug + public static boolean disableEnderIOIntegration = false; + public static boolean disableStaballoyBlastFurnaceRecipe = false; + public static boolean disableCentrifugeFormation = false; + + //Machine Related + public static boolean enableSolarGenerators = false; + public static boolean enableAlternativeBatteryAlloy = false; + public static boolean enableThaumcraftShardUnification = false; + public static boolean disableIC2Recipes = false; + public static boolean enableAlternativeDivisionSigilRecipe = false; + + //Feature Related + public static boolean enableCustomAlvearyBlocks = false; + + } + +} diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java new file mode 100644 index 0000000000..f1cc7eb830 --- /dev/null +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -0,0 +1,174 @@ +package gtPlusPlus.core.lib; + +import gtPlusPlus.core.lib.CORE.configSwitches; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechTextures; +import gtPlusPlus.xmod.gregtech.recipes.GregtechRecipeAdder; +import cpw.mods.fml.common.Loader; + +public class LoadedMods { + + + //Initialize Variables + public static boolean Gregtech = false; + public static boolean EnderIO = false; + public static boolean Big_Reactors = false; + public static boolean IndustrialCraft2 = false; + public static boolean Simply_Jetpacks = false; + public static boolean RFTools = false; + public static boolean Thaumcraft = false; + public static boolean Extra_Utils = false; + public static boolean PneumaticCraft = false; + public static boolean MorePlanets = false; + public static boolean ForbiddenMagic = false; + public static boolean CompactWindmills = false; + public static boolean Railcraft = false; + public static boolean ImmersiveEngineering = false; + public static boolean Growthcraft = false; + public static boolean CoFHCore = false; + public static boolean Forestry = false; + public static boolean MagicBees = false; + public static boolean ExtraBees = false; + public static boolean Psychedelicraft = false; + public static boolean MiscUtils = true; //Dummy For MetaData Lookups in MT Wrapper + public static boolean ThermalFoundation = false; + public static boolean IHL = false; + + + + private static int totalMods; + @SuppressWarnings("deprecation") + public static void checkLoaded(){ + Utils.LOG_INFO("Looking for optional mod prereqs."); + if (Loader.isModLoaded("gregtech") == true ){ + Gregtech = true; + Utils.LOG_INFO("Components enabled for: Gregtech"); + if (Gregtech){ + try { + CORE.sRecipeAdder = CORE.RA = new GregtechRecipeAdder(); + Utils.LOG_INFO("Created Gregtech recipe handler."); + GregtechTextures.BlockIcons.VOID.name(); + GregtechTextures.ItemIcons.VOID.name(); + Utils.LOG_INFO("Created Gregtech texture handler."); + } catch (NullPointerException e){ + Utils.LOG_INFO("Could NOT create a Gregtech recipe handler."); + } + } + + totalMods++; + } + if (Loader.isModLoaded("EnderIO") == true && !configSwitches.disableEnderIOIntegration){ + EnderIO = true; + Utils.LOG_INFO("Components enabled for: EnderIO"); + totalMods++; + } + if (Loader.isModLoaded("BigReactors") == true){ + Big_Reactors = true; + Utils.LOG_INFO("Components enabled for: Big Reactors"); + totalMods++; + } + if (Loader.isModLoaded("IC2") == true){ + IndustrialCraft2 = true; + Utils.LOG_INFO("Components enabled for: IndustrialCraft2"); + totalMods++; + } + if (Loader.isModLoaded("simplyjetpacks") == true){ + Simply_Jetpacks = true; + Utils.LOG_INFO("Components enabled for: Simply Jetpacks"); + totalMods++; + } + if (Loader.isModLoaded("rftools") == true){ + RFTools = true; + Utils.LOG_INFO("Components enabled for: RFTools"); + totalMods++; + } + if (Loader.isModLoaded("Thaumcraft") == true){ + Thaumcraft = true; + Utils.LOG_INFO("Components enabled for: Thaumcraft"); + totalMods++; + } + if (Loader.isModLoaded("ExtraUtilities") == true){ + Extra_Utils = true; + Utils.LOG_INFO("Components enabled for: Extra_Utils"); + totalMods++; + } + if (Loader.isModLoaded("PneumaticCraft") == true){ + PneumaticCraft = true; + Utils.LOG_INFO("Components enabled for: PneumaticCraft"); + totalMods++; + } + if (Loader.isModLoaded("MorePlanet") == true){ + MorePlanets = true; + Utils.LOG_INFO("Components enabled for: MorePlanets"); + totalMods++; + } + if (Loader.isModLoaded("ForbiddenMagic") == true){ + ForbiddenMagic = true; + Utils.LOG_INFO("Components enabled for: ForbiddenMagic"); + totalMods++; + } + if (Loader.isModLoaded("CompactWindmills") == true){ + CompactWindmills = true; + Utils.LOG_INFO("Components enabled for: CompactWindmills"); + totalMods++; + } + if (Loader.isModLoaded("Railcraft") == true){ + Railcraft = true; + Utils.LOG_INFO("Components enabled for: Railcraft"); + totalMods++; + } + if (Loader.isModLoaded("Growthcraft") == true){ + Growthcraft = true; + Utils.LOG_INFO("Components enabled for: Growthcraft"); + totalMods++; + } + if (Loader.isModLoaded("CoFHCore") == true){ + CoFHCore = true; + Utils.LOG_INFO("Components enabled for: CoFHCore"); + totalMods++; + } + if (Loader.isModLoaded("Forestry") == true){ + Forestry = true; + Utils.LOG_INFO("Components enabled for: Forestry"); + totalMods++; + } + if (Loader.isModLoaded("MagicBees") == true){ + MagicBees = true; + Utils.LOG_INFO("Components enabled for: MagicBees"); + totalMods++; + } + if (Loader.isModLoaded("psychedelicraft") == true){ + Psychedelicraft = true; + Utils.LOG_INFO("Components enabled for: Psychedelicraft"); + totalMods++; + } + if (Loader.isModLoaded("ImmersiveEngineering") == true){ + ImmersiveEngineering = true; + Utils.LOG_INFO("Components enabled for: ImmersiveEngineering"); + totalMods++; + } + if (Loader.isModLoaded("ExtraBees") == true){ + ExtraBees = true; + Utils.LOG_INFO("Components enabled for: ExtraBees"); + totalMods++; + } + if (Loader.isModLoaded("ThermalFoundation") == false){ + ThermalFoundation = false; + Utils.LOG_INFO("Components enabled for: ThermalFoundation - This feature will disable itself if you add TF."); + totalMods++; + } + else if (Loader.isModLoaded("ThermalFoundation") == true){ + ThermalFoundation = true; + Utils.LOG_INFO("Components disabled for: ThermalFoundation - This feature will enable itself if you remove TF."); + //totalMods++; + } + if (Loader.isModLoaded("ihl") == true){ + IHL = true; + Utils.LOG_INFO("Components enabled for: IHL"); + totalMods++; + } + + Utils.LOG_INFO("Content found for "+totalMods+" mods"); + + } +} diff --git a/src/Java/gtPlusPlus/core/lib/MaterialInfo.java b/src/Java/gtPlusPlus/core/lib/MaterialInfo.java new file mode 100644 index 0000000000..5f80224bca --- /dev/null +++ b/src/Java/gtPlusPlus/core/lib/MaterialInfo.java @@ -0,0 +1,149 @@ +package gtPlusPlus.core.lib; + +import static gtPlusPlus.core.lib.CORE.noItem; +import static gtPlusPlus.core.util.item.UtilsItems.getItemStackOfAmountFromOreDict; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TextureSet; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.util.materials.MaterialUtils; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public enum MaterialInfo { + + ENERGYCRYSTAL(GTplusplus.randomDust_A, 8, GTplusplus.randomDust_B, 8, GTplusplus.randomDust_C, 8, GTplusplus.randomDust_D, 8, "dustEnergyCrystal", 1, noItem, 0), + BLOODSTEEL(noItem, 0, noItem, 0, noItem, 0, noItem, 0, noItem, 0, noItem, 0), + STABALLOY("dustTitanium", 1, "dustUranium", 8, noItem, 0, noItem, 0, "dustStaballoy", 1, noItem, 0), + TANTALLOY60("dustTungsten", 1, "dustTantalum", 8, "dustTinyTitanium", 5, noItem, 0, "dustTantalloy60", 1, noItem, 0), + TANTALLOY61("dustTungsten", 1, "dustSmallTitanium", 3, "dustSmallYttrium", 2, "dustTantalum", 9, "dustTantalloy61", 1, noItem, 0), + QUANTUM(noItem, 0, noItem, 0, noItem, 0, noItem, 0, noItem, 0, noItem, 0), + TUMBAGA("dustGold", 6, "dustCopper", 3, noItem, 0, noItem, 0, "dustTumbaga", 2, noItem, 0), + POTIN("dustBronze", 3, "dustTin", 2, "dustLead", 4, noItem, 0, "dustPotin", 3, noItem, 0), + BEDROCKIUM(noItem, 0, noItem, 0, noItem, 0, noItem, 0, noItem, 0, noItem, 0), + INCONEL625("dustNickel", 5, "dustChrome", 2, "dustWroughtIron", 1, "dustMolybdenum", 1, "dustInconel625", 4, "dustTinyDarkAsh", 1), + INCONEL690("dustNickel", 5, "dustChrome", 2, "dustNiobium", 1, "dustMolybdenum", 1, "dustInconel690", 2, "dustTinyDarkAsh", 1), + INCONEL792("dustNickel", 5, "dustChrome", 1, "dustAluminium", 2, "dustNiobium", 1, "dustInconel792", 2, "dustTinyDarkAsh", 1), + TUNGSTENCARBIDE("dustTungsten", 16, "dustCarbon", 16, noItem, 0, noItem, 0, "dustTungstenCarbide", 4, noItem, 0), + SILICONCARBIDE("dustSilicon", 16, "dustCarbon", 16, noItem, 0, noItem, 0, "dustSiliconCarbide", 4, noItem, 0), + ZERON100("dustChrome", 5, "dustSmallNickel", 6, "dustSmallMolybdenum", 3, "dustSteel", 14, "dustZeron100", 5, noItem, 0), + MARAGING250("dustSteel", 4, "dustNickel", 2, "dustCobalt", 1, "dustTinyTitanium", 1, "dustMaragingSteel250", 6, noItem, 0), + MARAGING300("dustSteel", 5, "dustNickel", 2, "dustCobalt", 2, "dustSmallTitanium", 1, "dustMaragingSteel300", 5, noItem, 0), + MARAGING350("dustSteel", 6, "dustNickel", 3, "dustCobalt", 3, "dustTitanium", 1, "dustMaragingSteel350", 4, noItem, 0), + STELLITE("dustCobalt", 4, "dustChrome", 4, "dustManganese", 2, "dustTitanium", 1, "dustStellite", 2, noItem, 0), + TALONITE("dustCobalt", 4, "dustChrome", 4, "dustPhosphorus", 1, "dustMolybdenum", 1, "dustTalonite", 2, noItem, 0), + HASTELLOY_W("dustSmallCobalt", 1, "dustSmallChrome", 4, "dustMolybdenum", 2, "dustNickel", 6, "dustHastelloyW", 2, noItem, 0), + HASTELLOY_X("dustTinyCobalt", 6, "dustChrome", 2, "dustMolybdenum", 1, "dustNickel", 5, "dustHastelloyX", 2, noItem, 0), + HASTELLOY_C276("dustSmallCobalt", 1, "dustSmallChrome", 14, "dustSmallMolybdenum", 14, "dustNickel", 5, "dustHastelloyC276", 2, noItem, 0), + INCOLOY020("dustIron", 4, "dustChrome", 2, "dustTinyCarbon", 2, "dustSmallCopper", 4, "dustIncoloy020", 1, noItem, 0), + INCOLOYDS("dustIron", 4, "dustChrome", 2, "dustTinyTitanium", 2, "dustSmallManganese", 1, "dustIncoloyDS", 1, noItem, 0), + INCOLOYMA956("dustIron", 6, "dustChrome", 2, "dustSmallAluminium", 5, "dustTinyYttrium", 1, "dustIncoloyMA956", 1, noItem, 0), + TANTALUMCARBIDE("dustTantalum", 4, "dustCarbon", 2, noItem, 0, noItem, 0, "dustTantalumCarbide", 1, noItem, 0), + ZIRCONIUM(noItem, 0, noItem, 0, noItem, 0, noItem, 0, "dustZirconium", 1, noItem, 0), + ZIRCONIUMCARBIDE("dustZirconium", 2, "dustCarbon", 2, noItem, 0, noItem, 0, "dustZirconiumCarbide", 1, noItem, 0), + NIOMBIUMCARBIDE("dustNiobium", 2, "dustCarbon", 2, noItem, 0, noItem, 0, "dustNiobiumCarbide", 1, noItem, 0), + HASTELLOY_N("dustIron", 1, "dustSmallChrome", 7, "dustSmallMolybdenum", 12, "dustNickel", 4, "dustHastelloyN", 1, noItem, 0); + + + + private String input1; + private String input2; + private String input3; + private String input4; + private int inputAmount1; + private int inputAmount2; + private int inputAmount3; + private int inputAmount4; + private String out1; + private String out2; + private int outAmount1; + private int outAmount2; + public static List<String> nonLoadedInputs; + public final Materials materialGT; + + private MaterialInfo ( + String inputMaterial_1, int amountIn1, + String inputMaterial_2, int amountIn2, + String inputMaterial_3, int amountIn3, + String inputMaterial_4, int amountIn4, + String output_A,int amount1, String output_B, int amount2) + { + this.input1 = inputMaterial_1; + this.input2 = inputMaterial_2; + this.input3 = inputMaterial_3; + this.input4 = inputMaterial_4; + this.inputAmount1 = amountIn1; + this.inputAmount2 = amountIn2; + this.inputAmount3 = amountIn3; + this.inputAmount4 = amountIn4; + this.out1 = output_A; + this.out2 = output_B; + this.outAmount1 = amount1; + this.outAmount2 = amount2; + + + + this.materialGT = MaterialUtils.addGtMaterial( + getMaterialName().toLowerCase(), TextureSet.SET_DULL, 2f, 512, 2, + 1 | 2 | 16 | 32 | 64 | 128, + 193, 211, 217, 0, getMaterialName(), 0, 0, 3015, 2150, true, + false, 1, 2, 1, Dyes.dyeWhite, 2, null, null); + } + + public ItemStack[] getInputs() { + return new ItemStack[]{ + getStack(input1, inputAmount1), + getStack(input2, inputAmount2), + getStack(input3, inputAmount3), + getStack(input4, inputAmount4) + }; + } + + public ItemStack[] getOutputs() { + return new ItemStack[]{ + getStack(out1, outAmount1), + getStack(out2, outAmount2) + }; + } + + public String[] getInputItemsAsList(){ + String[] inputArray = { + input1, + input2, + input3, + input4 + }; + return inputArray; + } + + public int[] getInputStackSizesAsList(){ + int[] inputArray = { + inputAmount1, + inputAmount2, + inputAmount3, + inputAmount4 + }; + return inputArray; + } + + @SuppressWarnings("static-method") + public ItemStack getStack(String i, int r){ + if (i == ""){ + return null; + } + ItemStack temp = getItemStackOfAmountFromOreDict(i,r); + if (temp.getDisplayName().toLowerCase().contains("tell alkalus")){ + //temp = null; + } + return temp; + } + + public String getMaterialName(){ + String x = this.name(); + return x; + } + + +} diff --git a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java new file mode 100644 index 0000000000..3019a71266 --- /dev/null +++ b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java @@ -0,0 +1,86 @@ +package gtPlusPlus.core.proxy; + +import gtPlusPlus.core.common.CommonProxy; +import gtPlusPlus.core.util.particles.EntityParticleFXMysterious; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.entity.Entity; +import cpw.mods.fml.client.registry.RenderingRegistry; +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 ClientProxy extends CommonProxy{ + + @Override + public void preInit(FMLPreInitializationEvent e) { + // TODO Auto-generated method stub + super.preInit(e); + } + + @Override + public void init(FMLInitializationEvent e) { + // TODO Auto-generated method stub + super.init(e); + } + + @Override + public void postInit(FMLPostInitializationEvent e) { + // TODO Auto-generated method stub + super.postInit(e); + } + + @Override + public void registerRenderThings(){ + //RenderingRegistry.registerEntityRenderingHandler(EntityBloodSteelMob.class, new RenderBloodSteelMob(new ModelBloodSteelMob(), 0)); + //RenderingRegistry.registerEntityRenderingHandler(EntityBloodSteelHostileMob.class, new RenderBloodSteelMobHostile(new ModelBloodSteelMob(), 0)); + //RenderingRegistry.registerEntityRenderingHandler(EntityGrenade.class, new RenderSnowball(ModItems.tutGrenade)); + + //ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBloodSteelChest.class, new BloodSteelChestRenderer()); + //MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.tutChest), new ItemRenderBloodSteelChest()); + } + + @Override + public int addArmor(String armor){ + return RenderingRegistry.addNewArmourRendererPrefix(armor); + } + + + + @Override + public void generateMysteriousParticles(Entity theEntity) + { + double motionX = theEntity.worldObj.rand.nextGaussian() * 0.02D; + double motionY = theEntity.worldObj.rand.nextGaussian() * 0.02D; + double motionZ = theEntity.worldObj.rand.nextGaussian() * 0.02D; + EntityFX particleMysterious = new EntityParticleFXMysterious( + + theEntity.worldObj, + theEntity.posX + theEntity.worldObj.rand.nextFloat() * theEntity.width + + * 2.0F - theEntity.width, + theEntity.posY + 0.5D + theEntity.worldObj.rand.nextFloat() + + * theEntity.height, + theEntity.posZ + theEntity.worldObj.rand.nextFloat() * theEntity.width + + * 2.0F - theEntity.width, + + motionX, + + motionY, + + motionZ); + Minecraft.getMinecraft().effectRenderer.addEffect(particleMysterious); + } + + @Override + public void serverStarting(FMLServerStartingEvent e) + { + + } + + + +} diff --git a/src/Java/gtPlusPlus/core/proxy/ServerProxy.java b/src/Java/gtPlusPlus/core/proxy/ServerProxy.java new file mode 100644 index 0000000000..1f912b9022 --- /dev/null +++ b/src/Java/gtPlusPlus/core/proxy/ServerProxy.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.proxy; + +import gtPlusPlus.core.common.CommonProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class ServerProxy extends CommonProxy{ + + @Override + public void preInit(FMLPreInitializationEvent e) { + // TODO Auto-generated method stub + super.preInit(e); + } + + @Override + public void init(FMLInitializationEvent e) { + // TODO Auto-generated method stub + super.init(e); + } + + @Override + public void postInit(FMLPostInitializationEvent e) { + // TODO Auto-generated method stub + super.postInit(e); + } + +} diff --git a/src/Java/gtPlusPlus/core/recipe/Gregtech_Recipe_Adder.java b/src/Java/gtPlusPlus/core/recipe/Gregtech_Recipe_Adder.java new file mode 100644 index 0000000000..0f31c4c61d --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/Gregtech_Recipe_Adder.java @@ -0,0 +1,98 @@ +package gtPlusPlus.core.recipe; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class Gregtech_Recipe_Adder { + + private static int euT; + private static int ticks; + private static ItemStack inputStack1; + private static ItemStack inputStack2; + private static ItemStack outputStack1; + private static ItemStack outputStack2; + + public static void addRecipe( + Item maceratorInput, int maceratorInputAmount1, + Item maceratorOutput, int maceratorOutputAmount1, + Item compressorInput, int compressorInputAmount1, + Item compressorOutput, int compressorOutputAmount1, + Item blastFurnaceInput, int blastFurnaceInputAmount1, + Item blastFurnaceOutput, int blastFurnaceOutputAmount1, + Item blastFurnaceInput2, int blastFurnaceInputAmount2, + Item blastFurnaceOutput2, int blastFurnaceOutputAmount2, + Item smeltingInput, int smeltingInputAmount1, + Item smeltingOutput, int smeltingOutputAmount1, + + int euPerTick, int timeInTicks, + boolean addMaceratorRecipe, boolean addCompressorRecipe, boolean addBlastFurnaceRecipe, int blastFurnaceTemp, boolean addSmeltingRecipe, boolean addMixerRecipe){ + euT = euPerTick; + ticks = timeInTicks; + + resetVars(); + if (addMaceratorRecipe){ + inputStack1 = UtilsItems.getSimpleStack(maceratorInput, maceratorInputAmount1); + outputStack1 = UtilsItems.getSimpleStack(maceratorOutput, maceratorOutputAmount1); + addMaceratorRecipe(inputStack1, outputStack1); + } + resetVars(); + if (addCompressorRecipe){ + inputStack1 = UtilsItems.getSimpleStack(compressorInput, compressorInputAmount1); + outputStack1 = UtilsItems.getSimpleStack(compressorOutput, compressorOutputAmount1); + addCompressorRecipe(inputStack1, outputStack1); + } + resetVars(); + if (addBlastFurnaceRecipe){ + inputStack1 = UtilsItems.getSimpleStack(blastFurnaceInput, blastFurnaceInputAmount1); + inputStack2 = UtilsItems.getSimpleStack(blastFurnaceInput2, blastFurnaceInputAmount2); + outputStack1 = UtilsItems.getSimpleStack(blastFurnaceOutput, blastFurnaceOutputAmount1); + outputStack2 = UtilsItems.getSimpleStack(blastFurnaceOutput2, blastFurnaceOutputAmount2); + addBlastFurnaceRecipe(inputStack1, inputStack2, outputStack1, outputStack2, blastFurnaceTemp); + } + resetVars(); + if (addSmeltingRecipe){ + inputStack1 = UtilsItems.getSimpleStack(smeltingInput, smeltingInputAmount1); + outputStack1 = UtilsItems.getSimpleStack(smeltingOutput, smeltingOutputAmount1); + addSmeltingRecipe(inputStack1, outputStack1); + } + resetVars(); + + } + + private static void resetVars(){ + inputStack1 = null; + inputStack2 = null; + outputStack1 = null; + outputStack2 = null; + } + + private static void addMaceratorRecipe(ItemStack input1, ItemStack output1){ + GT_ModHandler.addPulverisationRecipe(input1, output1); + } + + private static void addCompressorRecipe(ItemStack input1, ItemStack output1){ + GT_ModHandler.addCompressionRecipe(input1, output1); + } + + private static void addBlastFurnaceRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tempRequired){ + Utils.LOG_INFO("Registering Blast Furnace Recipes."); + GT_Values.RA.addBlastRecipe( + input1, + input2, + GT_Values.NF, GT_Values.NF, + output1, + output2, + ticks, + euT, + tempRequired); + } + + private static void addSmeltingRecipe(ItemStack input1, ItemStack output1){ + GT_ModHandler.addSmeltingRecipe(input1, output1); + } + +} diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java new file mode 100644 index 0000000000..addeb8b74a --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -0,0 +1,233 @@ +package gtPlusPlus.core.recipe; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.fluid.FluidUtils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.item.ItemStack; + +public class RECIPES_GREGTECH { + + public static void run(){ + Utils.LOG_INFO("Loading Recipes through GregAPI for Industrial Multiblocks."); + execute(); + } + + private static void execute(){ + cokeOvenRecipes(); + matterFabRecipes(); + assemblerRecipes(); + distilleryRecipes(); + extractorRecipes(); + chemicalBathRecipes(); + dehydratorRecipes(); + addFuels(); + } + + private static void cokeOvenRecipes(){ + Utils.LOG_INFO("Loading Recipes for Industrial Coking Oven."); + + try { + + //GT Logs to Charcoal Recipe + //With Sulfuric Acid + CORE.RA.addCokeOvenRecipe( + GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 1L), //Input 1 + GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 1L), //Input 2 + Materials.SulfuricAcid.getFluid(20L), //Fluid Input + Materials.Creosote.getFluid(175L), //Fluid Output + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 2L), //Item Output + 800, //Time in ticks + 30); //EU + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + try { + + //Coal -> Coke Recipe + //With Sulfuric Acid + CORE.RA.addCokeOvenRecipe( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 1L), //Input 1 + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 1L), //Input 2 + Materials.SulfuricAcid.getFluid(60L), //Fluid Input + Materials.Creosote.getFluid(250L), //Fluid Output + UtilsItems.getItemStack("Railcraft:fuel.coke", 2), //Item Output + 600, //Time in ticks + 120); //EU + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + + try { + //GT Logs to Charcoal Recipe + //Without Sulfuric Acid + CORE.RA.addCokeOvenRecipe( + GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 1L), //Input 1 + GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 1L), //Input 2 + FluidUtils.getFluidStack("oxygen", 80), //Fluid Input + Materials.Creosote.getFluid(145L), //Fluid Output + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 2L), //Item Output + 1200, //Time in ticks + 30); //EU + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + + try { + //Coal -> Coke Recipe + //Without Sulfuric Acid + CORE.RA.addCokeOvenRecipe( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 1L), //Input 1 + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 1L), //Input 2 + FluidUtils.getFluidStack("oxygen", 185), //Fluid Input + Materials.Creosote.getFluid(200L), //Fluid Output + UtilsItems.getItemStack("Railcraft:fuel.coke", 2), //Item Output + 900, //Time in ticks + 120); //EU + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + } + + private static void matterFabRecipes(){ + Utils.LOG_INFO("Loading Recipes for Matter Fabricator."); + + try { + + CORE.RA.addMatterFabricatorRecipe( + Materials.UUAmplifier.getFluid(1L), //Fluid Input + Materials.UUMatter.getFluid(1L), //Fluid Output + 800, //Time in ticks + 32); //EU + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + try { + + CORE.RA.addMatterFabricatorRecipe( + null, //Fluid Input + Materials.UUMatter.getFluid(1L), //Fluid Output + 3200, //Time in ticks + 32); //EU + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + + } + + private static void dehydratorRecipes(){ + Utils.LOG_INFO("Loading Recipes for Chemical Dehydrator."); + + try { + + //Makes Lithium Carbonate + CORE.RA.addDehydratorRecipe( + FluidUtils.getFluidStack("sulfuriclithium", 1000), //Item input (slot 1) + null, //Fluid Input + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("dustSodium", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustCarbon", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustLithium", 1) + }, //Output Array of Items - Upto 9 + 10*20, //Time in ticks + 30); //EU + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + try { + + CORE.RA.addDehydratorRecipe( + UtilsItems.getItemStackOfAmountFromOreDict("cellEmpty", 1), //Item input (slot 1) + FluidUtils.getFluidStack("sulfuriclithium", 1000), //Fluid Input + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("dustSodium", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustCarbon", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustLithium", 1) + }, //Output Array of Items - Upto 9 + 10*20, //Time in ticks + 30); //EU + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + try { + CORE.RA.addDehydratorRecipe( + UtilsItems.getItemStackOfAmountFromOreDict("cellEmpty", 1), //Item input (slot 1) + UtilsItems.getItemStackOfAmountFromOreDict("cellWater", 1), //Item input (slot 2) + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("dustSodium", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustCarbon", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustLithium", 1) + }, //Output Array of Items - Upto 9 + 10*20, //Time in ticks + 30); //EU + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + try { + CORE.RA.addDehydratorRecipe( + UtilsItems.getItemStackOfAmountFromOreDict("cellEmpty", 1), + null, + FluidUtils.getFluidStack("sulfuriclithium", 1000), + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("dustSodium", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustCarbon", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustLithium", 1) + }, //Output Array of Items - Upto 9 + FluidUtils.getFluidStack("water", 1000), + 10*20, //Time in ticks + 30); //EU + + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + + try { + CORE.RA.addDehydratorRecipe( + null, //Item input (slot 1) + null, //Item input (slot 2) + FluidUtils.getFluidStack("sulfuriclithium", 1000), //Fluid input (slot 1) + null, //Fluid output (slot 1) + new ItemStack[]{ + UtilsItems.getItemStackOfAmountFromOreDict("dustSodium", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustCarbon", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustLithium", 1) + }, //Output Array of Items - Upto 9, + new int[]{0}, + 10*20, //Time in ticks + 30); //EU + + }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} + } + + private static void assemblerRecipes(){ + //GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 6L), ItemList.Casing_Turbine.get(1L, new Object[0]), ItemList.Casing_Turbine2.get(1L, new Object[0]), 50, 16); + //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 distilleryRecipes(){ + Utils.LOG_INFO("Registering Distillery/Distillation Tower Recipes."); + GT_Values.RA.addDistilleryRecipe(ItemList.Circuit_Integrated.getWithDamage(0L, 4L, new Object[0]), FluidUtils.getFluidStack("air", 1000), FluidUtils.getFluidStack("helium", 1), 400, 30, false); + GT_Values.RA.addDistillationTowerRecipe(FluidUtils.getFluidStack("air", 20000), FluidUtils.getFluidStackArray("helium", 25), UtilsItems.getSimpleStack(ModItems.itemHeliumBlob, 1), 200, 60); + } + + private static void addFuels(){ + Utils.LOG_INFO("Registering New Fuels."); + GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketFire_water", 0, 1), null, 120, 0); + GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketRocket_fuel", 0, 1), null, 112, 0); + GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketHootch", 0, 1), null, 36, 0); + //System.exit(1); + } + + private static void extractorRecipes(){ + Utils.LOG_INFO("Registering Extractor Recipes."); + GT_ModHandler.addExtractionRecipe(GregtechItemList.Battery_RE_EV_Sodium.get(1L, new Object[0]), ItemList.Battery_Hull_HV.get(4L, new Object[0])); + GT_ModHandler.addExtractionRecipe(GregtechItemList.Battery_RE_EV_Cadmium.get(1L, new Object[0]), ItemList.Battery_Hull_HV.get(4L, new Object[0])); + GT_ModHandler.addExtractionRecipe(GregtechItemList.Battery_RE_EV_Lithium.get(1L, new Object[0]), ItemList.Battery_Hull_HV.get(4L, new Object[0])); + } + + private static void chemicalBathRecipes(){ + int[] chances = {10000, 5000, 2500}; + GT_Values.RA.addChemicalBathRecipe(UtilsItems.getItemStackOfAmountFromOreDict("dustTin", 12), FluidUtils.getFluidStack("chlorine", 2400), + UtilsItems.getItemStackOfAmountFromOreDict("dustZirconium", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustZirconium", 1), + UtilsItems.getItemStackOfAmountFromOreDict("dustZirconium", 1), + chances, + 30*20, + 240); + } + + private static void registerSkookumChoocher(){ + //GT_ModHandler.addCraftingRecipe(GT_OreDictUnificator.get(OrePrefixes.toolHeadUniversalSpade, aMaterial, 1L), tBits, new Object[]{"fX", Character.valueOf('X'), OrePrefixes.toolHeadShovel.get(aMaterial)}); + } + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_LaserEngraver.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_LaserEngraver.java new file mode 100644 index 0000000000..94a1d85ae3 --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_LaserEngraver.java @@ -0,0 +1,32 @@ +package gtPlusPlus.core.recipe; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OreDictNames; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IOreRecipeRegistrator; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.item.ItemStack; + +public class RECIPES_LaserEngraver implements IOreRecipeRegistrator { + public RECIPES_LaserEngraver() { + OrePrefixes.crafting.add(this); + } + + @Override + public void registerOre(OrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack) { + if (aOreDictName.equals(OreDictNames.craftingLensBlue.toString())) { + GT_Values.RA.addLaserEngraverRecipe(GT_OreDictUnificator.get(OrePrefixes.foil, Materials.YttriumBariumCuprate, 2L), GT_Utility.copyAmount(0L, new Object[]{aStack}), GregtechItemList.Circuit_Parts_Wiring_IV.get(1L, new Object[0]), 64, 480); + } else if (aOreDictName.equals(OreDictNames.craftingLensYellow.toString())) { + GT_Values.RA.addLaserEngraverRecipe(GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Osmium, 2L), GT_Utility.copyAmount(0L, new Object[]{aStack}), GregtechItemList.Circuit_Parts_Wiring_LuV.get(1L, new Object[0]), 64, 1024); + } else if (aOreDictName.equals(OreDictNames.craftingLensCyan.toString())) { + } else if (aOreDictName.equals(OreDictNames.craftingLensRed.toString())) { + } else if (aOreDictName.equals(OreDictNames.craftingLensGreen.toString())) { + GT_Values.RA.addLaserEngraverRecipe(GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Naquadah, 2L), GT_Utility.copyAmount(0L, new Object[]{aStack}), GregtechItemList.Circuit_Parts_Wiring_ZPM.get(1L, new Object[0]), 64, 2000); + } else if (aOreDictName.equals(OreDictNames.craftingLensWhite.toString())) { + + } + } +} diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_MTWRAPPER.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_MTWRAPPER.java new file mode 100644 index 0000000000..6d81ba42ad --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_MTWRAPPER.java @@ -0,0 +1,115 @@ +package gtPlusPlus.core.recipe; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import gtPlusPlus.core.util.wrapper.var; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +public class RECIPES_MTWRAPPER { + + public static int MT_RECIPES_LOADED = 0; + public static int MT_RECIPES_FAILED = 0; + + static var chestWood = new var("minecraft:chest>"); + static var slabWood = new var("ore:slabWood>"); + static var gemNetherQuartz = new var("ore:gemNetherQuartz>"); + static var glass = new var("ore:blockGlass>"); + static var sensorDaylight = new var("minecraft:daylight_detector>"); + static var blazeRod = new var("minecraft:blaze_rod>"); + static var saw = new var("ore:craftingToolSaw>"); + static var logWood = new var("ore:logWood>"); + static var button = new var("minecraft:stone_button>"); + static var stoneBlock = new var("minecraft:stone>"); + + public static void run(){ + /*addShaped(button.getStack(2), + null, stoneBlock, null, + null, stoneBlock, null, + null, null, null);*/ + /*addShaped(stoneStick.getStack(1), + stoneBlock, null, null, + stoneBlock, null, null, + null, null, null);*/ + addShaped(chestWood.getStack(2), + logWood, logWood, logWood, + logWood, null, logWood, + logWood, logWood, logWood); + addShaped(chestWood.getStack(4), + logWood, logWood, logWood, + logWood, saw, logWood, + logWood, logWood, logWood); + //Recipe Fixes + //remove(sensorDaylight); + addShaped(sensorDaylight.getStack(1), + glass, glass, glass, + gemNetherQuartz, gemNetherQuartz, gemNetherQuartz, + slabWood, slabWood, slabWood); + /*addShaped(ironBars .getStack( 8), + null, "<ore:craftingToolWrench>", null, + "<ore:stickAnyIron>", "<ore:stickAnyIron>", "<ore:stickAnyIron>", + "<ore:stickAnyIron>", "<ore:stickAnyIron>", "<ore:stickAnyIron>");*/ + } + + + public static void addShaped(Object item_Output, + Object item_1, Object item_2, Object item_3, + Object item_4, Object item_5, Object item_6, + Object item_7, Object item_8, Object item_9){ + + + /* + * + * var item_1, var item_2, var item_3, + var item_4, var item_5, var item_6, + var item_7, var item_8, var item_9 + * + * + */ + + ItemStack outputItem = UtilsItems.getCorrectStacktype(item_Output, 1); + + ArrayList<Object> validSlots = new ArrayList<Object>(); + String a,b,c,d,e,f,g,h,i; + if (item_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(item_1);} + if (item_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(item_2);} + if (item_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(item_3);} + if (item_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(item_4);} + if (item_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(item_5);} + if (item_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(item_6);} + if (item_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(item_7);} + if (item_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(item_8);} + if (item_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(item_9);} + + String lineOne = a+b+c; + String lineTwo = d+e+f; + String lineThree = g+h+i; + validSlots.add(0, lineOne); + validSlots.add(1, lineTwo); + validSlots.add(2, lineThree); + + try { + UtilsRecipe.recipeBuilder((Object[]) validSlots.toArray(), outputItem.copy()); + MT_RECIPES_LOADED++; + } + catch(NullPointerException | ClassCastException k){ + k.getMessage(); + k.getClass(); + k.printStackTrace(); + k.getLocalizedMessage(); + Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+((var) item_Output).getsanitizedName()); + MT_RECIPES_FAILED++; + } + } + + public static void addShapeless(){ + + } + + + +} + diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java new file mode 100644 index 0000000000..f5e3fd1ad5 --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java @@ -0,0 +1,299 @@ +package gtPlusPlus.core.recipe; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + +public class RECIPES_MachineComponents { + + //Wire + static String wireTier6 = "wireGt08NiobiumTitanium"; + static String wireTier7 = "wireGt08Osmium"; + static String wireTier8 = "wireGt08Naquadah"; + static String wireTier9 = "wireGt08Superconductor"; + static String wireTier10 = "wireGt16Superconductor"; + + //Wire + static String cableTier6 = "cableGt04Tungsten"; + static String cableTier7 = "cableGt04NiobiumTitanium"; + static String cableTier8 = "cableGt04Osmium"; + static String cableTier9 = "cableGt04Naquadah"; + static String cableTier10 = "wireGt08Superconductor"; + + //Plates + static String plateTier7 = "plateChrome"; + static String plateTier8 = "plateIridium"; + static String plateTier9 = "plateOsmium"; + static String plateTier10 = "plateNeutronium"; + + //rods + static String rodTier7a = "stickChrome"; + static String rodTier8a = "stickIridium"; + static String rodTier9a = "stickOsmium"; + static String rodTier10a = "stickNeutronium"; + static String rodTier7b = "stickPlatinum"; + static String rodTier8b = "stickChrome"; + static String rodTier9b = "stickIridium"; + static String rodTier10b = "stickOsmium"; + static String rodTier7c = "stickTitanium"; + static String rodTier8c = "stickTungstenSteel"; + static String rodTier9c = "stickNaquadah"; + static String rodTier10c = "stickOsmium"; + + //Screws + static String screwTier7 = "screwChrome"; + static String screwTier8 = "screwIridium"; + static String screwTier9 = "screwOsmium"; + static String screwTier10 = "screwNeutronium"; + + //Rotors + static String rotorTier7 = "rotorChrome"; + static String rotorTier8 = "rotorIridium"; + static String rotorTier9 = "rotorOsmium"; + static String rotorTier10 = "rotorNeutronium"; + + //Fluid Pipe + static String pipeTier7 = "pipeHugeSteel"; + static String pipeTier8 = "pipeHugeStainlessSteel"; + static String pipeTier9 = "pipeHugeTitanium"; + static String pipeTier10 = "pipeHugeTungstenSteel"; + + //Rubber Ring/Plate + static String itemRubberRing = "ringRubber"; + static String plateRubber = "plateRubber"; + + //Circuits + static String circuitTier6 = "circuitMaster"; + static String circuitTier7 = "circuitUltimate"; + static String circuitTier8 = "circuitSymbiotic"; + static String circuitTier9 = "circuitNeutronic"; + static String circuitTier10 = "circuitQuantum"; + + //small gears + static String smallGearTier7 = "gearGtSmallChrome"; + static String smallGearTier8 = "gearGtSmallIridium"; + static String smallGearTier9 = "gearGtSmallOsmium"; + static String smallGearTier10 = "gearGtSmallNeutronium"; + + //Crafting Tools + static String craftingToolWrench = "craftingToolWrench"; + static String craftingToolScrewdriver = "craftingToolScrewdriver"; + + public static final void RECIPES_LOAD(){ + Utils.LOG_INFO("Loading Recipes for the Various Circuits and Machine components."); + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + run(); + } + GregtechMachinePhase(); + } + + private static void run(){ + //Electric Motors + UtilsRecipe.addShapedGregtechRecipe( + cableTier7, wireTier7, rodTier7a, + wireTier7, rodTier7b, wireTier7, + rodTier7a, wireTier7, cableTier7, + RECIPE_CONSTANTS.electricMotor_LuV); + UtilsRecipe.addShapedGregtechRecipe( + cableTier8, wireTier8, rodTier8a, + wireTier8, rodTier8b, wireTier8, + rodTier8a, wireTier8, cableTier8, + RECIPE_CONSTANTS.electricMotor_ZPM); + UtilsRecipe.addShapedGregtechRecipe( + cableTier9, wireTier9, rodTier9a, + wireTier9, rodTier9b, wireTier9, + rodTier9a, wireTier9, cableTier9, + RECIPE_CONSTANTS.electricMotor_UV); + UtilsRecipe.addShapedGregtechRecipe( + cableTier10, wireTier10, rodTier10a, + wireTier10, rodTier10b, wireTier10, + rodTier10a, wireTier10, cableTier10, + RECIPE_CONSTANTS.electricMotor_MAX); + + //Electric Pump + UtilsRecipe.addShapedGregtechRecipe( + cableTier7, rotorTier7, itemRubberRing, + craftingToolScrewdriver, pipeTier7, craftingToolWrench, + itemRubberRing, RECIPE_CONSTANTS.electricMotor_LuV, cableTier7, + RECIPE_CONSTANTS.electricPump_LuV); + UtilsRecipe.addShapedGregtechRecipe( + cableTier8, rotorTier8, itemRubberRing, + craftingToolScrewdriver, pipeTier8, craftingToolWrench, + itemRubberRing, RECIPE_CONSTANTS.electricMotor_ZPM, cableTier8, + RECIPE_CONSTANTS.electricPump_ZPM); + UtilsRecipe.addShapedGregtechRecipe( + cableTier9, rotorTier9, itemRubberRing, + craftingToolScrewdriver, pipeTier9, craftingToolWrench, + itemRubberRing, RECIPE_CONSTANTS.electricMotor_UV, cableTier9, + RECIPE_CONSTANTS.electricPump_UV); + UtilsRecipe.addShapedGregtechRecipe( + cableTier10, rotorTier10, itemRubberRing, + craftingToolScrewdriver, pipeTier10, craftingToolWrench, + itemRubberRing, RECIPE_CONSTANTS.electricMotor_MAX, cableTier10, + RECIPE_CONSTANTS.electricPump_MAX); + + //Electric Pump + UtilsRecipe.addShapedGregtechRecipe( + plateTier7, plateTier7, plateTier7, + cableTier7, rodTier7a, rodTier7a, + cableTier7, RECIPE_CONSTANTS.electricMotor_LuV, smallGearTier7, + RECIPE_CONSTANTS.electricPiston_LuV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier8, plateTier8, plateTier8, + cableTier8, rodTier8a, rodTier8a, + cableTier8, RECIPE_CONSTANTS.electricMotor_ZPM, smallGearTier8, + RECIPE_CONSTANTS.electricPiston_ZPM); + UtilsRecipe.addShapedGregtechRecipe( + plateTier9, plateTier9, plateTier9, + cableTier9, rodTier9a, rodTier9a, + cableTier9, RECIPE_CONSTANTS.electricMotor_UV, smallGearTier9, + RECIPE_CONSTANTS.electricPiston_UV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier10, plateTier10, plateTier10, + cableTier10, rodTier10a, rodTier10a, + cableTier10, RECIPE_CONSTANTS.electricMotor_MAX, smallGearTier10, + RECIPE_CONSTANTS.electricPiston_MAX); + + //Robot Arms + UtilsRecipe.addShapedGregtechRecipe( + cableTier7, cableTier7, cableTier7, + RECIPE_CONSTANTS.electricMotor_LuV, rodTier7a, RECIPE_CONSTANTS.electricMotor_LuV, + RECIPE_CONSTANTS.electricPiston_LuV, circuitTier7, rodTier7a, + RECIPE_CONSTANTS.robotArm_LuV); + UtilsRecipe.addShapedGregtechRecipe( + cableTier8, cableTier8, cableTier8, + RECIPE_CONSTANTS.electricMotor_ZPM, rodTier8a, RECIPE_CONSTANTS.electricMotor_ZPM, + RECIPE_CONSTANTS.electricPiston_ZPM, circuitTier8, rodTier8a, + RECIPE_CONSTANTS.robotArm_ZPM); + UtilsRecipe.addShapedGregtechRecipe( + cableTier9, cableTier9, cableTier9, + RECIPE_CONSTANTS.electricMotor_UV, rodTier9a, RECIPE_CONSTANTS.electricMotor_UV, + RECIPE_CONSTANTS.electricPiston_UV, circuitTier9, rodTier9a, + RECIPE_CONSTANTS.robotArm_UV); + UtilsRecipe.addShapedGregtechRecipe( + cableTier10, cableTier10, cableTier10, + RECIPE_CONSTANTS.electricMotor_MAX, rodTier10a, RECIPE_CONSTANTS.electricMotor_MAX, + RECIPE_CONSTANTS.electricPiston_MAX, circuitTier10, rodTier10a, + RECIPE_CONSTANTS.robotArm_MAX); + + //Conveyor Modules + UtilsRecipe.addShapedGregtechRecipe( + plateRubber, plateRubber, plateRubber, + RECIPE_CONSTANTS.electricMotor_LuV, cableTier7, RECIPE_CONSTANTS.electricMotor_LuV, + plateRubber, plateRubber, plateRubber, + RECIPE_CONSTANTS.conveyorModule_LuV); + UtilsRecipe.addShapedGregtechRecipe( + plateRubber, plateRubber, plateRubber, + RECIPE_CONSTANTS.electricMotor_ZPM, cableTier8, RECIPE_CONSTANTS.electricMotor_ZPM, + plateRubber, plateRubber, plateRubber, + RECIPE_CONSTANTS.conveyorModule_ZPM); + UtilsRecipe.addShapedGregtechRecipe( + plateRubber, plateRubber, plateRubber, + RECIPE_CONSTANTS.electricMotor_UV, cableTier9, RECIPE_CONSTANTS.electricMotor_UV, + plateRubber, plateRubber, plateRubber, + RECIPE_CONSTANTS.conveyorModule_UV); + UtilsRecipe.addShapedGregtechRecipe( + plateRubber, plateRubber, plateRubber, + RECIPE_CONSTANTS.electricMotor_MAX, cableTier10, RECIPE_CONSTANTS.electricMotor_MAX, + plateRubber, plateRubber, plateRubber, + RECIPE_CONSTANTS.conveyorModule_MAX); + + //Emitter Modules + UtilsRecipe.addShapedGregtechRecipe( + rodTier7c, rodTier7c, circuitTier7, + cableTier7, circuitTier6, rodTier7c, + circuitTier7, cableTier7, rodTier7c, + RECIPE_CONSTANTS.emitter_LuV); + UtilsRecipe.addShapedGregtechRecipe( + rodTier8c, rodTier8c, circuitTier8, + cableTier8, circuitTier7, rodTier8c, + circuitTier8, cableTier8, rodTier8c, + RECIPE_CONSTANTS.emitter_ZPM); + UtilsRecipe.addShapedGregtechRecipe( + rodTier9c, rodTier9c, circuitTier9, + cableTier9, circuitTier8, rodTier9c, + circuitTier9, cableTier9, rodTier9c, + RECIPE_CONSTANTS.emitter_UV); + UtilsRecipe.addShapedGregtechRecipe( + rodTier10c, rodTier10c, circuitTier10, + cableTier10, circuitTier9, rodTier10c, + circuitTier10, cableTier10, rodTier10c, + RECIPE_CONSTANTS.emitter_MAX); + + //Field Generator Modules + UtilsRecipe.addShapedGregtechRecipe( + wireTier7, circuitTier7, wireTier7, + circuitTier7, circuitTier6, circuitTier7, + wireTier7, circuitTier7, wireTier7, + RECIPE_CONSTANTS.fieldGenerator_LuV); + UtilsRecipe.addShapedGregtechRecipe( + wireTier8, circuitTier8, wireTier8, + circuitTier8, circuitTier7, circuitTier8, + wireTier8, circuitTier8, wireTier8, + RECIPE_CONSTANTS.fieldGenerator_ZPM); + UtilsRecipe.addShapedGregtechRecipe( + wireTier9, circuitTier9, wireTier9, + circuitTier9, circuitTier8, circuitTier9, + wireTier9, circuitTier9, wireTier9, + RECIPE_CONSTANTS.fieldGenerator_UV); + UtilsRecipe.addShapedGregtechRecipe( + wireTier10, circuitTier10, wireTier10, + circuitTier10, circuitTier9, circuitTier10, + wireTier10, circuitTier10, wireTier10, + RECIPE_CONSTANTS.fieldGenerator_MAX); + + //Sensor Modules + UtilsRecipe.addShapedGregtechRecipe( + plateTier7, null, circuitTier6, + plateTier7, rodTier7c, null, + circuitTier7, plateTier7, plateTier7, + RECIPE_CONSTANTS.sensor_LuV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier8, null, circuitTier7, + plateTier8, rodTier8c, null, + circuitTier8, plateTier8, plateTier8, + RECIPE_CONSTANTS.sensor_ZPM); + UtilsRecipe.addShapedGregtechRecipe( + plateTier9, null, circuitTier8, + plateTier9, rodTier9c, null, + circuitTier9, plateTier9, plateTier9, + RECIPE_CONSTANTS.sensor_UV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier10, null, circuitTier9, + plateTier10, rodTier10c, null, + circuitTier10, plateTier10, plateTier10, + RECIPE_CONSTANTS.sensor_MAX); + + Utils.LOG_INFO("Done loading recipes for the Various machine components."); + + } + + private static void GregtechMachinePhase(){ + Utils.LOG_INFO("Adding Gregtech machine recipes for the circuits."); + GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 1L), GregtechItemList.Circuit_Parts_Wiring_IV.get(4L, new Object[0]), GregtechItemList.Circuit_Board_IV.get(1L, new Object[0]), 32, 256); + GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 1L), GregtechItemList.Circuit_Parts_Wiring_LuV.get(4L, new Object[0]), GregtechItemList.Circuit_Board_LuV.get(1L, new Object[0]), 64, 512); + GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 2L), GregtechItemList.Circuit_Parts_Wiring_ZPM.get(4L, new Object[0]), GregtechItemList.Circuit_Board_ZPM.get(1L, new Object[0]), 96, 1024); + GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), GregtechItemList.Circuit_Parts_Crystal_Chip_IV.get(3L, new Object[0]), GregtechItemList.Circuit_Parts_IV.get(1L, new Object[0]), 32, 512); + GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.get(3L, new Object[0]), GregtechItemList.Circuit_Parts_LuV.get(1L, new Object[0]), 64, 1024); + GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.get(3L, new Object[0]), GregtechItemList.Circuit_Parts_ZPM.get(1L, new Object[0]), 96, 2048); + GT_Values.RA.addForgeHammerRecipe(ItemList.Circuit_Master.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_Crystal_Chip_IV.get(5L, new Object[0]), 32, 256); + GT_Values.RA.addForgeHammerRecipe(GregtechItemList.Circuit_IV.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.get(5L, new Object[0]), 64, 512); + GT_Values.RA.addForgeHammerRecipe(GregtechItemList.Circuit_LuV.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.get(5L, new Object[0]), 128, 1024); + for (Materials tMat : Materials.VALUES) { + if ((tMat.mStandardMoltenFluid != null) && (tMat.contains(SubTag.SOLDERING_MATERIAL))) { + int tMultiplier = tMat.contains(SubTag.SOLDERING_MATERIAL_GOOD) ? 1 : tMat.contains(SubTag.SOLDERING_MATERIAL_BAD) ? 4 : 2; + GT_Values.RA.addAssemblerRecipe(GregtechItemList.Circuit_Board_IV.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_IV.get(1L, new Object[0]), tMat.getMolten(144L * tMultiplier / 4L), GregtechItemList.Circuit_IV.get(1L, new Object[0]), 32, 512); + GT_Values.RA.addAssemblerRecipe(GregtechItemList.Circuit_Board_LuV.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_LuV.get(1L, new Object[0]), tMat.getMolten(144L * tMultiplier / 4L), GregtechItemList.Circuit_LuV.get(1L, new Object[0]), 64, 1024); + GT_Values.RA.addAssemblerRecipe(GregtechItemList.Circuit_Board_ZPM.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_ZPM.get(1L, new Object[0]), tMat.getMolten(144L * tMultiplier / 4L), GregtechItemList.Circuit_ZPM.get(1L, new Object[0]), 96, 2048); + + } + } + } +} diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java new file mode 100644 index 0000000000..a0d244ea85 --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -0,0 +1,601 @@ +package gtPlusPlus.core.recipe; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import net.minecraft.item.ItemStack; + +public class RECIPES_Machines { + + //Outputs + //static ItemStack RECIPE_BufferCore_ULV = new ItemStack(GregtechEnergyBuffer.itemBufferCore); + static ItemStack RECIPE_SteamCondenser = GregtechItemList.Condensor_MAX.get(1); + static ItemStack RECIPE_IronBlastFurnace = GregtechItemList.Machine_Iron_BlastFurnace.get(1); + static ItemStack RECIPE_IronPlatedBricks = GregtechItemList.Casing_IronPlatedBricks.get(1); + static ItemStack RECIPE_Buffer_ULV = GregtechItemList.Energy_Buffer_1by1_ULV.get(1); + static ItemStack RECIPE_Buffer_LV = GregtechItemList.Energy_Buffer_1by1_LV.get(1); + static ItemStack RECIPE_Buffer_MV = GregtechItemList.Energy_Buffer_1by1_MV.get(1); + static ItemStack RECIPE_Buffer_HV = GregtechItemList.Energy_Buffer_1by1_HV.get(1); + static ItemStack RECIPE_Buffer_EV = GregtechItemList.Energy_Buffer_1by1_EV.get(1); + static ItemStack RECIPE_Buffer_IV = GregtechItemList.Energy_Buffer_1by1_IV.get(1); + static ItemStack RECIPE_Buffer_LuV = GregtechItemList.Energy_Buffer_1by1_LuV.get(1); + static ItemStack RECIPE_Buffer_ZPM = GregtechItemList.Energy_Buffer_1by1_ZPM.get(1); + static ItemStack RECIPE_Buffer_UV = GregtechItemList.Energy_Buffer_1by1_UV.get(1); + static ItemStack RECIPE_Buffer_MAX = GregtechItemList.Energy_Buffer_1by1_MAX.get(1); + //Industrial Centrifuge + static ItemStack RECIPE_IndustrialCentrifugeController = GregtechItemList.Industrial_Centrifuge.get(1); + static ItemStack RECIPE_IndustrialCentrifugeCasing = GregtechItemList.Casing_Centrifuge1.get(1); + //Industrial Coke Oven + static ItemStack RECIPE_IndustrialCokeOvenController = GregtechItemList.Industrial_CokeOven.get(1); + static ItemStack RECIPE_IndustrialCokeOvenFrame = GregtechItemList.Casing_CokeOven.get(1); + static ItemStack RECIPE_IndustrialCokeOvenCasingA = GregtechItemList.Casing_CokeOven_Coil1.get(1); + static ItemStack RECIPE_IndustrialCokeOvenCasingB = GregtechItemList.Casing_CokeOven_Coil2.get(1); + // + static ItemStack RECIPE_IndustrialElectrolyzerController = GregtechItemList.Industrial_Electrolyzer.get(1); + static ItemStack RECIPE_IndustrialElectrolyzerFrame = GregtechItemList.Casing_Electrolyzer.get(1); + // + static ItemStack RECIPE_IndustrialMaterialPressController = GregtechItemList.Industrial_PlatePress.get(1); + static ItemStack RECIPE_IndustrialMaterialPressFrame = GregtechItemList.Casing_MaterialPress.get(1); + // + static ItemStack RECIPE_IndustrialMacerationStackController = GregtechItemList.Industrial_MacerationStack.get(1); + static ItemStack RECIPE_IndustrialMacerationStackFrame = GregtechItemList.Casing_MacerationStack.get(1); + // + static ItemStack RECIPE_IndustrialWireFactoryController = GregtechItemList.Industrial_WireFactory.get(1); + static ItemStack RECIPE_IndustrialWireFactoryFrame = GregtechItemList.Casing_WireFactory.get(1); + + + //Buffer Cores + static ItemStack RECIPE_BufferCore_ULV = UtilsItems.getItemStack("miscutils:item.itemBufferCore1", 1); + static ItemStack RECIPE_BufferCore_LV = UtilsItems.getItemStack("miscutils:item.itemBufferCore2", 1); + static ItemStack RECIPE_BufferCore_MV = UtilsItems.getItemStack("miscutils:item.itemBufferCore3", 1); + static ItemStack RECIPE_BufferCore_HV = UtilsItems.getItemStack("miscutils:item.itemBufferCore4", 1); + static ItemStack RECIPE_BufferCore_EV = UtilsItems.getItemStack("miscutils:item.itemBufferCore5", 1); + static ItemStack RECIPE_BufferCore_IV = UtilsItems.getItemStack("miscutils:item.itemBufferCore6", 1); + static ItemStack RECIPE_BufferCore_LuV = UtilsItems.getItemStack("miscutils:item.itemBufferCore7", 1); + static ItemStack RECIPE_BufferCore_ZPM = UtilsItems.getItemStack("miscutils:item.itemBufferCore8", 1); + static ItemStack RECIPE_BufferCore_UV = UtilsItems.getItemStack("miscutils:item.itemBufferCore9", 1); + static ItemStack RECIPE_BufferCore_MAX = UtilsItems.getItemStack("miscutils:item.itemBufferCore10", 1); + + + //Wire + static String wireTier1 = "wireGt08Lead"; + static String wireTier2 = "wireGt08Tin"; + static String wireTier3 = "wireGt08Copper"; + static String wireTier4 = "wireGt08Gold"; + static String wireTier5 = "wireGt08Aluminium"; + static String wireTier6 = "wireGt08Tungsten"; + static String wireTier7 = "wireGt08Naquadah"; + static String wireTier8 = "wireGt08Osmium"; + static String wireTier9 = "wireGt08Superconductor"; + static String wireTier10 = "wireGt16Superconductor"; + + //Wire + static String cableTier1 = "cableGt04Lead"; + static String cableTier2 = "cableGt04Tin"; + static String cableTier3 = "cableGt04Copper"; + static String cableTier4 = "cableGt04Gold"; + static String cableTier5 = "cableGt04Aluminium"; + static String cableTier6 = "cableGt04Tungsten"; + static String cableTier7 = "cableGt04Naquadah"; + static String cableTier8 = "cableGt04Osmium"; + static String cableTier9 = "cableGt04NiobiumTitanium"; + static String cableTier10 = "cableGt08NiobiumTitanium"; + + + //Plates + static String plateTier1 = "plateLead"; + static String plateTier2 = "plateTin"; + static String plateTier3 = "plateCopper"; + static String plateTier4 = "plateGold"; + static String plateTier5 = "plateAluminium"; + static String plateTier6 = "plateMaragingSteel250"; + static String plateTier7 = "plateTungsten"; + static String plateTier8 = "plateTungstenSteel"; + static String plateTier9 = "plateZeron100"; + static String plateTier10 = "plateNaquadah"; + static String plateTier11 = "plateNeutronium"; + + //rods + static String rodTier1 = "stickLead"; + static String rodTier2 = "stickTin"; + static String rodTier3 = "stickCopper"; + static String rodTier4 = "stickGold"; + static String rodTier5 = "stickAluminium"; + static String rodTier6 = "stickMaragingSteel250"; + static String rodTier7 = "stickTungsten"; + static String rodTier8 = "stickTungstenSteel"; + static String rodTier9 = "stickZeron100"; + static String rodTier10 = "stickNaquadah"; + static String rodTier11 = "stickNeutronium"; + + + //Machine Casings + static ItemStack machineCasing_ULV; + static ItemStack machineCasing_LV; + static ItemStack machineCasing_MV; + static ItemStack machineCasing_HV; + static ItemStack machineCasing_EV; + static ItemStack machineCasing_IV; + static ItemStack machineCasing_LuV; + static ItemStack machineCasing_ZPM; + static ItemStack machineCasing_UV; + static ItemStack machineCasing_MAX; + + //Gearbox Casings + static ItemStack gearboxCasing_Tier_1; + static ItemStack gearboxCasing_Tier_2; + static ItemStack gearboxCasing_Tier_3; + static ItemStack gearboxCasing_Tier_4; + + //IV MACHINES + public static ItemStack IV_MACHINE_Electrolyzer; + public static ItemStack IV_MACHINE_Centrifuge; + public static ItemStack IV_MACHINE_BendingMachine; + public static ItemStack IV_MACHINE_Wiremill; + public static ItemStack IV_MACHINE_Macerator; + public static ItemStack IV_MACHINE_MassFabricator; + + + //Cables + static String cableGt02Electrum = "cableGt02Electrum"; + + + //Plates + static String plateElectricalSteel= "plateElectricalSteel"; + static String plateEnergeticAlloy= "plateEnergeticAlloy"; + static String plateCobalt = "plateCobalt"; + static String plateBronze = "plateBronze"; + static String plateSteel = "plateSteel"; + + //Pipes + static String pipeLargeCopper="pipeLargeCopper"; + static String pipeHugeSteel="pipeHugeSteel"; + static String pipeHugeStainlessSteel="pipeHugeStainlessSteel"; + static String pipeHugeTitanium="pipeHugeTitanium"; + + //Lava Boiler + static ItemStack boiler_Coal; + static ItemStack blockBricks = UtilsItems.getItemStack("minecraft:brick_block", 1); + + //Batteries + static String batteryBasic = "batteryBasic"; + static String batteryAdvanced = "batteryAdvanced"; + static String batteryElite = "batteryElite"; + static String batteryMaster = "batteryMaster"; + static String batteryUltimate = "batteryUltimate"; + static ItemStack IC2MFE; + static ItemStack IC2MFSU; + + //Circuits + static String circuitPrimitive = "circuitBasic"; + static String circuitTier1 = "circuitGood"; + static String circuitTier2 = "circuitAdvanced"; + static String circuitTier3 = "circuitData"; + static String circuitTier4 = "circuitElite"; + static String circuitTier5 = "circuitMaster"; + static String circuitTier6 = "circuitUltimate"; + static String circuitTier7 = "circuitSymbiotic"; + static String circuitTier8 = "circuitNeutronic"; + static String circuitTier9 = "circuitQuantum"; + + //Machine Components + static ItemStack electricMotor_LV; + static ItemStack electricMotor_MV; + static ItemStack electricMotor_HV; + static ItemStack electricMotor_EV; + static ItemStack electricMotor_IV; + static ItemStack electricPump_LV; + static ItemStack electricPump_MV; + static ItemStack electricPump_HV; + static ItemStack electricPump_EV; + static ItemStack electricPump_IV; + static ItemStack electricPiston_LV; + static ItemStack electricPiston_MV; + static ItemStack electricPiston_HV; + static ItemStack electricPiston_EV; + static ItemStack electricPiston_IV; + static ItemStack robotArm_LV; + static ItemStack robotArm_MV; + static ItemStack robotArm_HV; + static ItemStack robotArm_EV; + static ItemStack robotArm_IV; + static ItemStack conveyorModule_LV; + static ItemStack conveyorModule_MV; + static ItemStack conveyorModule_HV; + static ItemStack conveyorModule_EV; + static ItemStack conveyorModule_IV; + static ItemStack emitter_LV; + static ItemStack emitter_MV; + static ItemStack emitter_HV; + static ItemStack emitter_EV; + static ItemStack emitter_IV; + static ItemStack fieldGenerator_LV; + static ItemStack fieldGenerator_MV; + static ItemStack fieldGenerator_HV; + static ItemStack fieldGenerator_EV; + static ItemStack fieldGenerator_IV; + static ItemStack sensor_LV; + static ItemStack sensor_MV; + static ItemStack sensor_HV; + static ItemStack sensor_EV; + static ItemStack sensor_IV; + + //Misc + static ItemStack INPUT_RCCokeOvenBlock; + static ItemStack INPUT_IECokeOvenBlock; + + + + //RobotArm, Conveyor, Emitter, Sensor, Field Generator + + + public static final void RECIPES_LOAD(){ + run(); + Utils.LOG_INFO("Loading Recipes for the Various machine blocks."); + } + + private static void run(){ + initModItems(); + } + + private static void initModItems(){ + if (LoadedMods.IndustrialCraft2){ + IC2MFE = UtilsItems.getItemStackWithMeta(LoadedMods.IndustrialCraft2, "IC2:blockElectric", "IC2_MFE", 1, 1); + IC2MFSU = UtilsItems.getItemStackWithMeta(LoadedMods.IndustrialCraft2, "IC2:blockElectric", "IC2_MFSU", 2, 1); + } + if (LoadedMods.Gregtech){ + RECIPES_Shapeless.dustStaballoy = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, "gregtech:gt.metaitem.01", "Staballoy Dust", 2319, 2); + machineCasing_ULV = ItemList.Casing_ULV.get(1); + machineCasing_LV = ItemList.Casing_LV.get(1); + machineCasing_MV = ItemList.Casing_MV.get(1); + machineCasing_HV = ItemList.Casing_HV.get(1); + machineCasing_EV = ItemList.Casing_EV.get(1); + machineCasing_IV = ItemList.Casing_IV.get(1); + machineCasing_LuV = ItemList.Casing_LuV.get(1); + machineCasing_ZPM = ItemList.Casing_ZPM.get(1); + machineCasing_UV = ItemList.Casing_UV.get(1); + machineCasing_MAX = ItemList.Casing_MAX.get(1); + + //Gearbox Casings + gearboxCasing_Tier_1 = ItemList.Casing_Gearbox_Bronze.get(1); + gearboxCasing_Tier_2 = ItemList.Casing_Gearbox_Steel.get(1); + gearboxCasing_Tier_3 = ItemList.Casing_Gearbox_Titanium.get(1); + gearboxCasing_Tier_4 = ItemList.Casing_Gearbox_TungstenSteel.get(1); + + //Lava Boiler + boiler_Coal = ItemList.Machine_Bronze_Boiler.get(1); + + //Machine Components + electricMotor_LV = ItemList.Electric_Motor_LV.get(1); + electricMotor_MV = ItemList.Electric_Motor_MV.get(1); + electricMotor_HV = ItemList.Electric_Motor_HV.get(1); + electricMotor_EV = ItemList.Electric_Motor_EV.get(1); + electricMotor_IV = ItemList.Electric_Motor_IV.get(1); + electricPump_LV = ItemList.Electric_Pump_LV.get(1); + electricPump_MV = ItemList.Electric_Pump_MV.get(1); + electricPump_HV = ItemList.Electric_Pump_HV.get(1); + electricPump_EV = ItemList.Electric_Pump_EV.get(1); + electricPump_IV = ItemList.Electric_Pump_IV.get(1); + electricPiston_LV = ItemList.Electric_Piston_LV.get(1); + electricPiston_MV = ItemList.Electric_Piston_MV.get(1); + electricPiston_HV = ItemList.Electric_Piston_HV.get(1); + electricPiston_EV = ItemList.Electric_Piston_EV.get(1); + electricPiston_IV = ItemList.Electric_Piston_IV.get(1); + robotArm_LV = ItemList.Robot_Arm_LV.get(1); + robotArm_MV = ItemList.Robot_Arm_MV.get(1); + robotArm_HV = ItemList.Robot_Arm_HV.get(1); + robotArm_EV = ItemList.Robot_Arm_EV.get(1); + robotArm_IV = ItemList.Robot_Arm_IV.get(1); + conveyorModule_LV = ItemList.Conveyor_Module_LV.get(1); + conveyorModule_MV = ItemList.Conveyor_Module_MV.get(1); + conveyorModule_HV = ItemList.Conveyor_Module_HV.get(1); + conveyorModule_EV = ItemList.Conveyor_Module_EV.get(1); + conveyorModule_IV = ItemList.Conveyor_Module_IV.get(1); + emitter_LV = ItemList.Emitter_LV.get(1); + emitter_MV = ItemList.Emitter_MV.get(1); + emitter_HV = ItemList.Emitter_HV.get(1); + emitter_EV = ItemList.Emitter_EV.get(1); + emitter_IV = ItemList.Emitter_IV.get(1); + fieldGenerator_LV = ItemList.Field_Generator_LV.get(1); + fieldGenerator_MV = ItemList.Field_Generator_MV.get(1); + fieldGenerator_HV = ItemList.Field_Generator_HV.get(1); + fieldGenerator_EV = ItemList.Field_Generator_EV.get(1); + fieldGenerator_IV = ItemList.Field_Generator_IV.get(1); + sensor_LV = ItemList.Sensor_LV.get(1); + sensor_MV = ItemList.Sensor_MV.get(1); + sensor_HV = ItemList.Sensor_HV.get(1); + sensor_EV = ItemList.Sensor_EV.get(1); + sensor_IV = ItemList.Sensor_IV.get(1); + + + //IV MACHINES + IV_MACHINE_Electrolyzer = ItemList.Machine_IV_Electrolyzer.get(1); + IV_MACHINE_BendingMachine= ItemList.Machine_IV_Bender.get(1); + IV_MACHINE_Wiremill= ItemList.Machine_IV_Wiremill.get(1); + IV_MACHINE_Macerator= ItemList.Machine_IV_Macerator.get(1); + IV_MACHINE_MassFabricator= ItemList.Machine_IV_Massfab.get(1); + IV_MACHINE_Centrifuge= ItemList.Machine_IV_Centrifuge.get(1); + + + } + + if(LoadedMods.Railcraft){ + //Misc + INPUT_RCCokeOvenBlock = UtilsItems.getItemStackWithMeta(LoadedMods.Railcraft, "Railcraft:machine.alpha", "Coke_Oven_RC", 7, 1); + } + if(LoadedMods.ImmersiveEngineering){ + //Misc + INPUT_IECokeOvenBlock = UtilsItems.getItemStackWithMeta(LoadedMods.ImmersiveEngineering, "ImmersiveEngineering:stoneDecoration", "Coke_Oven_IE", 1, 1); + } + runModRecipes(); + } + + private static void runModRecipes(){ + if (LoadedMods.Gregtech){ + + UtilsRecipe.addShapedGregtechRecipe( + ItemList.Electric_Piston_EV, GregtechOrePrefixes.circuit.get(Materials.Ultimate), ItemList.Electric_Piston_EV, + ItemList.Electric_Motor_EV, machineCasing_EV, ItemList.Electric_Motor_EV, + "gearGtTitanium", "cableGt02Aluminium", "gearGtTitanium", + UtilsItems.simpleMetaStack("gregtech:gt.blockmachines", 793, 1)); + UtilsRecipe.addShapedGregtechRecipe( + ItemList.Electric_Piston_IV, GregtechOrePrefixes.circuit.get(GT_Materials.Symbiotic), ItemList.Electric_Piston_IV, + ItemList.Electric_Motor_IV, machineCasing_IV, ItemList.Electric_Motor_IV, + "gearGtTungstenSteel", "cableGt02Platinum", "gearGtTungstenSteel", + UtilsItems.simpleMetaStack("gregtech:gt.blockmachines", 794, 1)); + UtilsRecipe.addShapedGregtechRecipe( + RECIPE_CONSTANTS.electricPiston_LuV, GregtechOrePrefixes.circuit.get(GT_Materials.Neutronic), RECIPE_CONSTANTS.electricPiston_LuV, + RECIPE_CONSTANTS.electricMotor_LuV, machineCasing_LuV, RECIPE_CONSTANTS.electricMotor_LuV, + "gearGtChrome", "cableGt02Tungsten", "gearGtChrome", + UtilsItems.simpleMetaStack("gregtech:gt.blockmachines", 795, 1)); + + //Buffer Core + UtilsRecipe.addShapedGregtechRecipe( + plateTier1, cableTier1, plateTier1, + circuitPrimitive, IC2MFE, circuitPrimitive, + plateTier1, cableTier1, plateTier1, + RECIPE_BufferCore_ULV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier2, cableTier2, plateTier2, + circuitTier1, IC2MFE, circuitTier1, + plateTier2, cableTier2, plateTier2, + RECIPE_BufferCore_LV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier3, cableTier3, plateTier3, + RECIPE_BufferCore_LV, circuitTier2, RECIPE_BufferCore_LV, + plateTier3, cableTier3, plateTier3, + RECIPE_BufferCore_MV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier4, cableTier4, plateTier4, + RECIPE_BufferCore_MV, circuitTier3, RECIPE_BufferCore_MV, + plateTier4, cableTier4, plateTier4, + RECIPE_BufferCore_HV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier5, cableTier5, plateTier5, + RECIPE_BufferCore_HV, circuitTier4, RECIPE_BufferCore_HV, + plateTier5, cableTier5, plateTier5, + RECIPE_BufferCore_EV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier6, cableTier6, plateTier6, + RECIPE_BufferCore_EV, circuitTier5, RECIPE_BufferCore_EV, + plateTier6, cableTier6, plateTier6, + RECIPE_BufferCore_IV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier7, cableTier7, plateTier7, + RECIPE_BufferCore_IV, circuitTier6, RECIPE_BufferCore_IV, + plateTier7, cableTier7, plateTier7, + RECIPE_BufferCore_LuV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier8, cableTier8, plateTier8, + RECIPE_BufferCore_LuV, circuitTier7, RECIPE_BufferCore_LuV, + plateTier8, cableTier8, plateTier8, + RECIPE_BufferCore_ZPM); + UtilsRecipe.addShapedGregtechRecipe( + plateTier9, cableTier9, plateTier9, + RECIPE_BufferCore_ZPM, circuitTier8, RECIPE_BufferCore_ZPM, + plateTier9, cableTier9, plateTier9, + RECIPE_BufferCore_UV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier10, cableTier10, plateTier10, + RECIPE_BufferCore_UV, circuitTier9, RECIPE_BufferCore_UV, + plateTier10, cableTier10, plateTier10, + RECIPE_BufferCore_MAX); + + + UtilsRecipe.addShapedGregtechRecipe( + wireTier1, RECIPE_BufferCore_ULV, wireTier1, + wireTier1, machineCasing_ULV, wireTier1, + circuitPrimitive, circuitTier1, circuitPrimitive, + RECIPE_Buffer_ULV); + UtilsRecipe.addShapedGregtechRecipe( + wireTier2, RECIPE_BufferCore_LV, wireTier2, + wireTier2, machineCasing_LV, wireTier2, + circuitTier1, RECIPE_BufferCore_LV, circuitTier1, + RECIPE_Buffer_LV); + UtilsRecipe.addShapedGregtechRecipe( + wireTier3, RECIPE_BufferCore_MV, wireTier3, + wireTier3, machineCasing_MV, wireTier3, + circuitTier2, RECIPE_BufferCore_MV, circuitTier2, + RECIPE_Buffer_MV); + UtilsRecipe.addShapedGregtechRecipe( + wireTier4, RECIPE_BufferCore_HV, wireTier4, + wireTier4, machineCasing_HV, wireTier4, + circuitTier3, RECIPE_BufferCore_HV, circuitTier3, + RECIPE_Buffer_HV); + UtilsRecipe.addShapedGregtechRecipe( + wireTier5, RECIPE_BufferCore_EV, wireTier5, + wireTier5, machineCasing_EV, wireTier5, + circuitTier4, RECIPE_BufferCore_EV, circuitTier4, + RECIPE_Buffer_EV); + UtilsRecipe.addShapedGregtechRecipe( + wireTier6, RECIPE_BufferCore_IV, wireTier6, + wireTier6, machineCasing_IV, wireTier6, + circuitTier5, RECIPE_BufferCore_IV, circuitTier5, + RECIPE_Buffer_IV); + UtilsRecipe.addShapedGregtechRecipe( + wireTier7, RECIPE_BufferCore_LuV, wireTier7, + wireTier7, machineCasing_LuV, wireTier7, + circuitTier6, RECIPE_BufferCore_LuV, circuitTier6, + RECIPE_Buffer_LuV); + UtilsRecipe.addShapedGregtechRecipe( + wireTier8, RECIPE_BufferCore_ZPM, wireTier8, + wireTier8, machineCasing_ZPM, wireTier8, + circuitTier7, RECIPE_BufferCore_ZPM, circuitTier7, + RECIPE_Buffer_ZPM); + UtilsRecipe.addShapedGregtechRecipe( + wireTier9, RECIPE_BufferCore_UV, wireTier9, + wireTier9, machineCasing_UV, wireTier9, + circuitTier8, RECIPE_BufferCore_UV, circuitTier8, + RECIPE_Buffer_UV); + UtilsRecipe.addShapedGregtechRecipe( + plateTier11, RECIPE_BufferCore_MAX, plateTier11, + wireTier10, machineCasing_MAX, wireTier10, + circuitTier9, RECIPE_BufferCore_MAX, circuitTier9, + RECIPE_Buffer_MAX); + + //Steam Condenser + UtilsRecipe.addShapedGregtechRecipe( + pipeLargeCopper, pipeHugeSteel, pipeLargeCopper, + plateEnergeticAlloy, electricPump_HV, plateEnergeticAlloy, + plateEnergeticAlloy, pipeLargeCopper, plateEnergeticAlloy, + RECIPE_SteamCondenser); + + //Iron BF + UtilsRecipe.addShapedGregtechRecipe( + "plateDoubleAnyIron", "craftingFurnace", "plateDoubleAnyIron", + boiler_Coal, machineCasing_ULV, boiler_Coal, + "plateDoubleAnyIron", "bucketLava", "plateDoubleAnyIron", + RECIPE_IronBlastFurnace); + //Iron plated Bricks + UtilsRecipe.addShapedGregtechRecipe( + "plateAnyIron", RECIPES_Tools.craftingToolHardHammer, "plateAnyIron", + "plateAnyIron", blockBricks, "plateAnyIron", + "plateAnyIron", RECIPES_Tools.craftingToolWrench, "plateAnyIron", + RECIPE_IronPlatedBricks); + + /*//Electrolyzer Frame Casing + UtilsRecipe.addShapedGregtechRecipe( + "platePotin", "stickLongChrome", "platePotin", + "stickLongPotin", "frameGtPotin", "stickLongPotin", + "platePotin", "stickLongPotin", "platePotin", + RECIPE_IndustrialCentrifugeCasing); + //Industrial Electrolyzer + UtilsRecipe.addShapedGregtechRecipe( + "plateStellite", circuitTier6, "plateStellite", + machineCasing_EV, IV_MACHINE_Electrolyzer, machineCasing_EV, + "plateStellite", "rotorStellite", "plateStellite", + RECIPE_IndustrialCentrifugeController);*/ + + //Industrial Centrifuge + UtilsRecipe.addShapedGregtechRecipe( + circuitTier6, pipeHugeStainlessSteel, circuitTier6, + plateTier6, IV_MACHINE_Centrifuge, plateTier6, + plateTier8, machineCasing_IV, plateTier8, + RECIPE_IndustrialCentrifugeController); + //Centrifuge Casing + UtilsRecipe.addShapedGregtechRecipe( + plateTier6, "stickTumbaga", plateTier6, + plateTier8, "stickTumbaga", plateTier8, + plateTier6, "stickTumbaga", plateTier6, + RECIPE_IndustrialCentrifugeCasing); + + if (LoadedMods.Railcraft){ + //Industrial Coke Oven + UtilsRecipe.addShapedGregtechRecipe( + plateCobalt, circuitTier4, plateCobalt, + machineCasing_HV, INPUT_RCCokeOvenBlock, machineCasing_HV, + plateCobalt, circuitTier5, plateCobalt, + RECIPE_IndustrialCokeOvenController); + } + if (LoadedMods.ImmersiveEngineering){ + //Industrial Coke Oven + UtilsRecipe.addShapedGregtechRecipe( + plateCobalt, circuitTier4, plateCobalt, + machineCasing_HV, INPUT_IECokeOvenBlock, machineCasing_HV, + plateCobalt, circuitTier5, plateCobalt, + RECIPE_IndustrialCokeOvenController); + } + //Coke Oven Frame Casing + UtilsRecipe.addShapedGregtechRecipe( + plateTier8, rodTier8, plateTier8, + rodTier8, "frameGtTantalloy61", rodTier8, + plateTier8, rodTier8, plateTier8, + RECIPE_IndustrialCokeOvenFrame); + //Coke Oven Coil 1 + UtilsRecipe.addShapedGregtechRecipe( + plateBronze, plateBronze, plateBronze, + "frameGtBronze", gearboxCasing_Tier_1, "frameGtBronze", + plateBronze, plateBronze, plateBronze, + RECIPE_IndustrialCokeOvenCasingA); + //Coke Oven Coil 2 + UtilsRecipe.addShapedGregtechRecipe( + plateSteel, plateSteel, plateSteel, + "frameGtSteel", gearboxCasing_Tier_2, "frameGtSteel", + plateSteel, plateSteel, plateSteel, + RECIPE_IndustrialCokeOvenCasingB); + + //Electrolyzer Frame Casing + UtilsRecipe.addShapedGregtechRecipe( + "platePotin", "stickLongChrome", "platePotin", + "stickLongPotin", "frameGtPotin", "stickLongPotin", + "platePotin", "stickLongPotin", "platePotin", + RECIPE_IndustrialElectrolyzerFrame); + //Industrial Electrolyzer + UtilsRecipe.addShapedGregtechRecipe( + "plateStellite", circuitTier6, "plateStellite", + machineCasing_EV, IV_MACHINE_Electrolyzer, machineCasing_EV, + "plateStellite", "rotorStellite", "plateStellite", + RECIPE_IndustrialElectrolyzerController); + + //Material Press Frame Casing + UtilsRecipe.addShapedGregtechRecipe( + "plateTitanium", "stickLongTumbaga", "plateTitanium", + "stickTantalloy60", "frameGtTumbaga", "stickTantalloy60", + "plateTitanium", "stickLongTumbaga", "plateTitanium", + RECIPE_IndustrialMaterialPressFrame); + //Industrial Material Press + UtilsRecipe.addShapedGregtechRecipe( + "plateTitanium", circuitTier5, "plateTitanium", + machineCasing_EV, IV_MACHINE_BendingMachine, machineCasing_EV, + "plateTitanium", circuitTier5, "plateTitanium", + RECIPE_IndustrialMaterialPressController); + + //Maceration Frame Casing + UtilsRecipe.addShapedGregtechRecipe( + "platePalladium", "platePalladium", "platePalladium", + "stickPlatinum", "frameGtInconel625", "stickPlatinum", + "platePalladium", "stickLongPalladium", "platePalladium", + RECIPE_IndustrialMacerationStackFrame); + //Industrial Maceration stack + UtilsRecipe.addShapedGregtechRecipe( + "plateTungstenCarbide", IV_MACHINE_Macerator, "plateTungstenCarbide", + IV_MACHINE_Macerator, circuitTier8, IV_MACHINE_Macerator, + "plateTungstenCarbide", machineCasing_IV, "plateTungstenCarbide", + RECIPE_IndustrialMacerationStackController); + + //Wire Factory Frame Casing + UtilsRecipe.addShapedGregtechRecipe( + "plateBlueSteel", "stickBlueSteel", "plateBlueSteel", + "stickBlueSteel", "frameGtBlueSteel", "stickBlueSteel", + "plateBlueSteel", "stickBlueSteel", "plateBlueSteel", + RECIPE_IndustrialWireFactoryFrame); + //Industrial Wire Factory + UtilsRecipe.addShapedGregtechRecipe( + "plateZeron100", machineCasing_IV, "plateZeron100", + circuitTier6, IV_MACHINE_Wiremill, circuitTier6, + "plateZeron100", machineCasing_IV, "plateZeron100", + RECIPE_IndustrialWireFactoryController); + + + } + + + Utils.LOG_INFO("Done loading recipes for the Various machine blocks."); + } +} diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Shapeless.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Shapeless.java new file mode 100644 index 0000000000..2a79aa92c9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Shapeless.java @@ -0,0 +1,46 @@ +package gtPlusPlus.core.recipe; + +import gregtech.api.enums.ItemList; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import net.minecraft.item.ItemStack; + +public class RECIPES_Shapeless { + + static ItemStack dustStaballoy; + + //Circuits + static String circuitPrimitive = "circuitPrimitive"; + static String circuitBasic = "circuitBasic"; + static String circuitGood = "circuitGood"; + static String circuitAdvanced = "circuitAdvanced"; + static String circuitData = "circuitData"; + static String circuitElite = "circuitElite"; + static String circuitMaster = "circuitMaster"; + static String circuitUltimate = "circuitUltimate"; + static ItemStack gearboxCasing_Tier_1; + + public static final void RECIPES_LOAD(){ + //run(); + Utils.LOG_INFO("Loading Shapeless Recipes."); + } + + private static void run(){ + //Gregtech items + if (LoadedMods.Gregtech){ + gearboxCasing_Tier_1 = ItemList.Casing_Gearbox_Bronze.get(1); + + UtilsRecipe.shapelessBuilder(dustStaballoy, + "dustTitanium", "dustUranium", "dustUranium", + "dustUranium", "dustUranium", "dustUranium", + "dustUranium", "dustUranium", "dustUranium"); + + UtilsRecipe.shapelessBuilder(gearboxCasing_Tier_1, + circuitPrimitive, circuitPrimitive, circuitPrimitive, + circuitPrimitive, circuitPrimitive, circuitPrimitive, + circuitPrimitive, circuitPrimitive, circuitPrimitive); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java new file mode 100644 index 0000000000..2f97d7e7ff --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java @@ -0,0 +1,177 @@ +package gtPlusPlus.core.recipe; + +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class RECIPES_Tools { + + //Outputs + public static ItemStack RECIPE_StaballoyPickaxe = new ItemStack(ModItems.itemStaballoyPickaxe); + public static ItemStack RECIPE_StaballoyAxe = new ItemStack(ModItems.itemStaballoyAxe); + public static ItemStack RECIPE_SandstoneHammer = new ItemStack(ModItems.itemSandstoneHammer); + public static ItemStack RECIPE_StaballoyIngot = new ItemStack(ModItems.itemIngotStaballoy); + public static ItemStack RECIPE_SandStone = new ItemStack(Blocks.sandstone, 2); + public static ItemStack RECIPE_Sand = new ItemStack(Blocks.sand, 4); + + public static ItemStack RECIPE_DivisionSigil; + + //MC Items + public static Item Apple = Items.apple; + + //MC Blocks + public static Block CobbleStone = Blocks.cobblestone; + public static Block Dirt = Blocks.dirt; + public static Block Sand = Blocks.sand; + public static Block Gravel = Blocks.gravel; + public static Block Sandstone = Blocks.sandstone; + + //null + public static String empty = " "; + + //Batteries + public static String batteryBasic = "batteryBasic"; + public static String batteryAdvanced = "batteryAdvanced"; + public static String batteryElite = "batteryElite"; + public static String batteryMaster = "batteryMaster"; + public static String batteryUltimate = "batteryUltimate"; + + //Circuits + public static String circuitPrimitive = "circuitPrimitive"; + public static String circuitBasic = "circuitBasic"; + public static String circuitGood = "circuitGood"; + public static String circuitAdvanced = "circuitAdvanced"; + public static String circuitElite = "circuitElite"; + public static String circuitMaster = "circuitMaster"; + public static String circuitUltimate = "circuitUltimate"; + + //Cables + public static String cableGt01Electrum = "cableGt01Electrum"; + public static String cableGt02Electrum = "cableGt02Electrum"; + public static String cableGt01RedstoneAlloy = "cableGt01RedstoneAlloy"; + public static String cableGt02RedstoneAlloy = "cableGt02RedstoneAlloy"; + public static String cableGt01Copper = "cableGt01Copper"; + public static String cableGt02Copper = "cableGt02Copper"; + public static String cableGt01AnnealedCopper = "cableGt01AnnealedCopper"; + public static String cableGt02AnnealedCopper = "cableGt02AnnealedCopper"; + + //Rods + public static String stickStaballoy= "stickStaballoy"; + public static String stickTitanium= "stickTitanium"; + public static String stickIron= "stickIron"; + public static String stickGold= "stickGold"; + public static String stickSilver= "stickSilver"; + public static String stickSteel= "stickSteel"; + public static String stickBronze= "stickBronze"; + public static String stickTungsten= "stickTungsten"; + public static String stickRedAlloy= "stickRedAlloy"; + public static String stickInvar= "stickInvar"; + public static String stickElectrum= "stickElectrum"; + public static String stickElectricalSteel= "stickElectricalSteel"; + + //Plates + public static String plateStaballoy= "plateStaballoy"; + public static String plateTitanium= "plateTitanium"; + public static String plateIron= "plateIron"; + public static String plateGold= "plateGold"; + public static String plateSilver= "plateSilver"; + public static String plateSteel= "plateSteel"; + public static String plateBronze= "plateBronze"; + public static String plateTungsten= "plateTungsten"; + public static String plateRedAlloy= "plateRedAlloy"; + public static String plateInvar= "plateInvar"; + public static String plateElectrum= "plateElectrum"; + public static String plateElectricalSteel= "plateElectricalSteel"; + + //Ingots + public static String ingotStaballoy= "ingotStaballoy"; + public static String ingotTitanium= "ingotTitanium"; + public static String ingotIron= "ingotIron"; + public static String ingotGold= "ingotGold"; + public static String ingotSilver= "ingotSilver"; + public static String ingotSteel= "ingotSteel"; + public static String ingotBronze= "ingotBronze"; + public static String ingotTungsten= "ingotTungsten"; + public static String ingotRedAlloy= "ingotRedAlloy"; + public static String ingotInvar= "ingotInvar"; + public static String ingotElectrum= "ingotElectrum"; + public static String ingotUranium= "ingotUranium"; + public static String ingotElectricalSteel= "ingotElectricalSteel"; + + //Crafting Tools + public static String craftingToolHardHammer = "craftingToolHardHammer"; + public static String craftingToolSoftHammer = "craftingToolSoftHammer"; + public static String craftingToolFile = "craftingToolFile"; + public static String craftingToolSaw = "craftingToolSaw"; + public static String craftingToolPickaxe = "craftingToolPickaxe"; + public static String craftingToolWrench = "craftingToolWrench"; + public static String craftingToolCrowbar = "craftingToolCrowbar"; + public static String craftingToolKnife = "craftingToolKnife"; + public static String craftingToolScrewdriver = "craftingToolScrewdriver"; + + public static ItemStack sandHammer = new ItemStack (ModItems.itemSandstoneHammer, 1, OreDictionary.WILDCARD_VALUE); + public static String craftingToolSandHammer = "craftingToolSandHammer"; + + public static ItemStack personalCloakingDevice = UtilsItems.getSimpleStack(ModItems.itemPersonalCloakingDevice); + public static String plateDoubleNiChrome = "plateDoubleNichrome"; + public static String plateIridiumAlloy = "plateAlloyIridium"; + + public static final void RECIPES_LOAD(){ + + + run(); + + } + + private static void run(){ + //Staballoy Pickaxe + UtilsRecipe.recipeBuilder( + plateStaballoy, plateStaballoy, ingotStaballoy, + craftingToolFile, stickTungsten, craftingToolHardHammer, + craftingToolWrench, stickTungsten, craftingToolHardHammer, + RECIPE_StaballoyPickaxe); + + //Staballoy Axe + UtilsRecipe.recipeBuilder( + plateStaballoy, ingotStaballoy, craftingToolHardHammer, + plateStaballoy, stickTungsten, craftingToolHardHammer, + craftingToolFile, stickTungsten, craftingToolWrench, + RECIPE_StaballoyAxe); + + //Cobble to Sand + UtilsRecipe.recipeBuilder( + CobbleStone, CobbleStone, CobbleStone, + CobbleStone, sandHammer, CobbleStone, + CobbleStone, CobbleStone, CobbleStone, + RECIPE_Sand); + + //Cloaking Device + UtilsRecipe.recipeBuilder( + plateDoubleNiChrome, plateIridiumAlloy, plateDoubleNiChrome, + plateIridiumAlloy, batteryUltimate, plateIridiumAlloy, + plateDoubleNiChrome, plateIridiumAlloy, plateDoubleNiChrome, + personalCloakingDevice); + + //Sand to Sandstone + UtilsRecipe.recipeBuilder( + Sand, Sand, Sand, + Sand, sandHammer, Sand, + Sand, Sand, Sand, + RECIPE_SandStone); + + //Sandstone Hammer + UtilsRecipe.recipeBuilder( + plateElectrum, ingotElectrum, plateElectrum, + craftingToolScrewdriver, stickBronze, craftingToolHardHammer, + null, stickSteel, null, + RECIPE_SandstoneHammer); + + } + +} diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPE_Batteries.java b/src/Java/gtPlusPlus/core/recipe/RECIPE_Batteries.java new file mode 100644 index 0000000000..80ee79e292 --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPE_Batteries.java @@ -0,0 +1,49 @@ +package gtPlusPlus.core.recipe; + +import gregtech.api.enums.ItemList; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.item.ItemStack; + +public class RECIPE_Batteries { + + static ItemStack RECIPE_Battery_Sodium = GregtechItemList.Battery_RE_EV_Sodium.get(1); + static ItemStack RECIPE_Battery_Cadmium = GregtechItemList.Battery_RE_EV_Cadmium.get(1); + static ItemStack RECIPE_Battery_Lithium = GregtechItemList.Battery_RE_EV_Lithium.get(1); + static ItemStack GT_Battery_Sodium = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32539, 1); + static ItemStack GT_Battery_Cadmium = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32537, 1); + static ItemStack GT_Battery_Lithium = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32538, 1); + static ItemStack machineTransformer_EV; + + public static void RECIPES_LOAD(){ + + if (LoadedMods.Gregtech){ + machineTransformer_EV = ItemList.Transformer_EV_HV.get(1); + run(); + } + } + + private static void run(){ + + + UtilsRecipe.addShapedGregtechRecipe( + GT_Battery_Sodium, RECIPES_Machines.cableTier4, GT_Battery_Sodium, + RECIPES_Machines.circuitTier3, machineTransformer_EV, RECIPES_Machines.circuitTier3, + GT_Battery_Sodium, RECIPES_Machines.cableTier4, GT_Battery_Sodium, + RECIPE_Battery_Sodium); + UtilsRecipe.addShapedGregtechRecipe( + GT_Battery_Cadmium, RECIPES_Machines.cableTier4, GT_Battery_Cadmium, + RECIPES_Machines.circuitTier3, machineTransformer_EV, RECIPES_Machines.circuitTier3, + GT_Battery_Cadmium, RECIPES_Machines.cableTier4, GT_Battery_Cadmium, + RECIPE_Battery_Cadmium); + UtilsRecipe.addShapedGregtechRecipe( + GT_Battery_Lithium, RECIPES_Machines.cableTier4, GT_Battery_Lithium, + RECIPES_Machines.circuitTier3, machineTransformer_EV, RECIPES_Machines.circuitTier3, + GT_Battery_Lithium, RECIPES_Machines.cableTier4, GT_Battery_Lithium, + RECIPE_Battery_Lithium); + + } + +} diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPE_CONSTANTS.java b/src/Java/gtPlusPlus/core/recipe/RECIPE_CONSTANTS.java new file mode 100644 index 0000000000..df945bf9ec --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPE_CONSTANTS.java @@ -0,0 +1,116 @@ +package gtPlusPlus.core.recipe; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.item.ItemStack; + +public class RECIPE_CONSTANTS { + + //Machine Components + public static ItemStack electricMotor_LuV; + public static ItemStack electricMotor_ZPM; + public static ItemStack electricMotor_UV; + public static ItemStack electricMotor_MAX; + public static ItemStack electricPump_LuV; + public static ItemStack electricPump_ZPM; + public static ItemStack electricPump_UV; + public static ItemStack electricPump_MAX; + public static ItemStack electricPiston_LuV; + public static ItemStack electricPiston_ZPM; + public static ItemStack electricPiston_UV ; + public static ItemStack electricPiston_MAX; + public static ItemStack robotArm_LuV; + public static ItemStack robotArm_ZPM; + public static ItemStack robotArm_UV; + public static ItemStack robotArm_MAX; + public static ItemStack conveyorModule_LuV; + public static ItemStack conveyorModule_ZPM; + public static ItemStack conveyorModule_UV; + public static ItemStack conveyorModule_MAX; + public static ItemStack emitter_LuV; + public static ItemStack emitter_ZPM; + public static ItemStack emitter_UV; + public static ItemStack emitter_MAX; + public static ItemStack fieldGenerator_LuV; + public static ItemStack fieldGenerator_ZPM; + public static ItemStack fieldGenerator_UV; + public static ItemStack fieldGenerator_MAX; + public static ItemStack sensor_LuV; + public static ItemStack sensor_ZPM; + public static ItemStack sensor_UV; + public static ItemStack sensor_MAX; + + public static void initialise(){ + if(CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + registerGTExperimentalComponents(); + } + else { + registerGTStandardComponents(); + } + } + + private static void registerGTExperimentalComponents(){ + //Machine Components + electricMotor_LuV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32606, 1); + electricMotor_ZPM = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32607, 1); + electricMotor_UV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32608, 1); + electricPump_LuV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32620, 1); + electricPump_ZPM = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32621, 1); + electricPump_UV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32622, 1); + electricPiston_LuV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32645, 1); + electricPiston_ZPM = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32646, 1); + electricPiston_UV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32647, 1); + robotArm_LuV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32655, 1); + robotArm_ZPM = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32656, 1); + robotArm_UV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32657, 1); + conveyorModule_LuV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32636, 1); + conveyorModule_ZPM = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32637, 1); + conveyorModule_UV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32638, 1); + emitter_LuV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32685, 1); + emitter_ZPM = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32686, 1); + emitter_UV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32687, 1); + fieldGenerator_LuV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32675, 1); + fieldGenerator_ZPM = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32676, 1); + fieldGenerator_UV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32677, 1); + sensor_LuV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32695, 1); + sensor_ZPM = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32696, 1); + sensor_UV = UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 32697, 1); + } + + private static void registerGTStandardComponents(){ + electricMotor_LuV = GregtechItemList.Electric_Motor_LuV.get(1); + electricMotor_ZPM = GregtechItemList.Electric_Motor_ZPM.get(1); + electricMotor_UV = GregtechItemList.Electric_Motor_UV.get(1); + electricMotor_MAX = GregtechItemList.Electric_Motor_MAX.get(1); + electricPump_LuV = GregtechItemList.Electric_Pump_LuV.get(1); + electricPump_ZPM = GregtechItemList.Electric_Pump_ZPM.get(1); + electricPump_UV = GregtechItemList.Electric_Pump_UV.get(1); + electricPump_MAX = GregtechItemList.Electric_Pump_MAX.get(1); + electricPiston_LuV = GregtechItemList.Electric_Piston_LuV.get(1); + electricPiston_ZPM = GregtechItemList.Electric_Piston_ZPM.get(1); + electricPiston_UV = GregtechItemList.Electric_Piston_UV.get(1); + electricPiston_MAX = GregtechItemList.Electric_Piston_MAX.get(1); + robotArm_LuV = GregtechItemList.Robot_Arm_LuV.get(1); + robotArm_ZPM = GregtechItemList.Robot_Arm_ZPM.get(1); + robotArm_UV = GregtechItemList.Robot_Arm_UV.get(1); + robotArm_MAX = GregtechItemList.Robot_Arm_MAX.get(1); + conveyorModule_LuV = GregtechItemList.Conveyor_Module_LuV.get(1); + conveyorModule_ZPM = GregtechItemList.Conveyor_Module_ZPM.get(1); + conveyorModule_UV = GregtechItemList.Conveyor_Module_UV.get(1); + conveyorModule_MAX = GregtechItemList.Conveyor_Module_MAX.get(1); + emitter_LuV = GregtechItemList.Emitter_LuV.get(1); + emitter_ZPM = GregtechItemList.Emitter_ZPM.get(1); + emitter_UV = GregtechItemList.Emitter_UV.get(1); + emitter_MAX = GregtechItemList.Emitter_MAX.get(1); + fieldGenerator_LuV = GregtechItemList.Field_Generator_LuV.get(1); + fieldGenerator_ZPM = GregtechItemList.Field_Generator_ZPM.get(1); + fieldGenerator_UV = GregtechItemList.Field_Generator_UV.get(1); + fieldGenerator_MAX = GregtechItemList.Field_Generator_MAX.get(1); + sensor_LuV = GregtechItemList.Sensor_LuV.get(1); + sensor_ZPM = GregtechItemList.Sensor_ZPM.get(1); + sensor_UV = GregtechItemList.Sensor_UV.get(1); + sensor_MAX = GregtechItemList.Sensor_MAX.get(1); + } + +} diff --git a/src/Java/gtPlusPlus/core/recipe/ShapedRecipeObject.java b/src/Java/gtPlusPlus/core/recipe/ShapedRecipeObject.java new file mode 100644 index 0000000000..c6dc1ede1b --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/ShapedRecipeObject.java @@ -0,0 +1,42 @@ +package gtPlusPlus.core.recipe; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import net.minecraft.item.ItemStack; + +public class ShapedRecipeObject { + + public Object object_A; + public Object object_B; + public Object object_C; + public Object object_D; + public Object object_E; + public Object object_F; + public Object object_G; + public Object object_H; + public Object object_I; + public ItemStack object_OUTPUT; + + public ShapedRecipeObject( + Object input_A,Object input_B,Object input_C, + Object input_D,Object input_E,Object input_F, + Object input_G,Object input_H,Object input_I, + ItemStack input_Output){ + this.object_A = input_A; + this.object_B = input_B; + this.object_C = input_C; + this.object_D = input_D; + this.object_E = input_E; + this.object_F = input_F; + this.object_G = input_G; + this.object_H = input_H; + this.object_I = input_I; + this.object_OUTPUT = input_Output; + Utils.LOG_SPECIFIC_WARNING("ShapedRecipeObject", "New object created.", 36); + } + + public void buildRecipe(){ + UtilsRecipe.recipeBuilder(object_A, object_B, object_C, object_D, object_E, object_F, object_G, object_H, object_I, object_OUTPUT); + } + +} diff --git a/src/Java/gtPlusPlus/core/slots/SlotFrame.java b/src/Java/gtPlusPlus/core/slots/SlotFrame.java new file mode 100644 index 0000000000..13bc8fa717 --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotFrame.java @@ -0,0 +1,25 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import forestry.api.apiculture.IHiveFrame; + +public class SlotFrame extends Slot{ + + public SlotFrame(IInventory inventory, int x, int y, int z) { + super(inventory, x, y, z); + + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return itemstack.getItem() instanceof IHiveFrame; + } + + @Override + public int getSlotStackLimit() { + return 1; + } + +} diff --git a/src/Java/gtPlusPlus/core/slots/SlotItemBackpackInv.java b/src/Java/gtPlusPlus/core/slots/SlotItemBackpackInv.java new file mode 100644 index 0000000000..7a22086949 --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotItemBackpackInv.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.slots; + +import gtPlusPlus.core.item.base.BaseItemBackpack; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotItemBackpackInv extends Slot +{ + public SlotItemBackpackInv(IInventory inv, int index, int xPos, int yPos) + { + super(inv, index, xPos, yPos); + } + + // This is the only method we need to override so that + // we can't place our inventory-storing Item within + // its own inventory (thus making it permanently inaccessible) + // as well as preventing abuse of storing backpacks within backpacks + /** + * Check if the stack is a valid item for this slot. + */ + @Override + public boolean isItemValid(ItemStack itemstack) + { + // Everything returns true except an instance of our Item + return !(itemstack.getItem() instanceof BaseItemBackpack); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/slots/SlotRTG.java b/src/Java/gtPlusPlus/core/slots/SlotRTG.java new file mode 100644 index 0000000000..1f16463de2 --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotRTG.java @@ -0,0 +1,25 @@ +package gtPlusPlus.core.slots; + +import ic2.core.Ic2Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotRTG extends Slot{ + + public SlotRTG(IInventory inventory, int x, int y, int z) { + super(inventory, x, y, z); + + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return itemstack.getItem().getClass() == Ic2Items.RTGPellets.getItem().getClass(); + } + + @Override + public int getSlotStackLimit() { + return 1; + } + +} diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java new file mode 100644 index 0000000000..246c7ff285 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -0,0 +1,17 @@ +package gtPlusPlus.core.tileentities; + +import gtPlusPlus.core.util.Utils; + +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(TileEntityCharger.class, "TE_Charger"); + // GameRegistry.registerTileEntity(TileEntityHeliumGenerator.class, "Helium"); + } + +} diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java b/src/Java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java new file mode 100644 index 0000000000..67c592c79c --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java @@ -0,0 +1,39 @@ +package gtPlusPlus.core.tileentities.base; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; + +public class TILE_ENTITY_BASE extends TileEntity { + + @Override + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); + writeCustomNBT(tag); + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + readCustomNBT(tag); + } + + public void writeCustomNBT(NBTTagCompound tag) {} + public void readCustomNBT(NBTTagCompound tag) {} + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeCustomNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, tag); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { + super.onDataPacket(net, packet); + readCustomNBT(packet.func_148857_g()); + } + +} diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java new file mode 100644 index 0000000000..8767b6607c --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java @@ -0,0 +1,310 @@ +package gtPlusPlus.core.tileentities.general; + +import gtPlusPlus.core.block.ModBlocks; + +import java.util.Random; + +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/gtPlusPlus/core/tileentities/machines/TileEntityCharger.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityCharger.java new file mode 100644 index 0000000000..9ec6aa3b24 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityCharger.java @@ -0,0 +1,186 @@ +package gtPlusPlus.core.tileentities.machines; + +import gtPlusPlus.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/gtPlusPlus/core/tileentities/machines/TileEntityNHG.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityNHG.java new file mode 100644 index 0000000000..3a9dbbd4c7 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityNHG.java @@ -0,0 +1,502 @@ +package gtPlusPlus.core.tileentities.machines; + +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.general.fuelrods.FuelRod_Base; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +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 (MathUtils.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/gtPlusPlus/core/util/BaseHandler.java b/src/Java/gtPlusPlus/core/util/BaseHandler.java new file mode 100644 index 0000000000..63f22f3763 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/BaseHandler.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.util; + +public abstract class BaseHandler { + + public abstract void preInit(); + + public abstract void init(); + + public abstract void postInit(); + +} diff --git a/src/Java/gtPlusPlus/core/util/ClassUtils.java b/src/Java/gtPlusPlus/core/util/ClassUtils.java new file mode 100644 index 0000000000..ba3db748f9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/ClassUtils.java @@ -0,0 +1,78 @@ +package gtPlusPlus.core.util; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class ClassUtils { + + + /*@ if (isPresent("com.optionaldependency.DependencyClass")) { + // This block will never execute when the dependency is not present + // There is therefore no more risk of code throwing NoClassDefFoundException. + executeCodeLinkingToDependency(); + }*/ + public static boolean isPresent(String className) { + try { + Class.forName(className); + return true; + } catch (Throwable ex) { + // Class or one of its dependencies is not present... + return false; + } + } + + public static Method getMethodViaReflection(Class<?> lookupClass, String methodName, boolean invoke) throws Exception{ + Class<? extends Class> lookup = lookupClass.getClass(); + Method m = lookup.getDeclaredMethod(methodName); + m.setAccessible(true);// Abracadabra + if (invoke){ + m.invoke(lookup);// now its OK + } + return m; + } + + public static Class getNonPublicClass(String className){ + Class<?> c = null; + try { + c = Class.forName(className); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //full package name --------^^^^^^^^^^ + //or simpler without Class.forName: + //Class<package1.A> c = package1.A.class; + + if (null != c){ + //In our case we need to use + Constructor<?> constructor = null; + try { + constructor = c.getDeclaredConstructor(); + } catch (NoSuchMethodException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //note: getConstructor() can return only public constructors + //so we needed to search for any Declared constructor + + //now we need to make this constructor accessible + if (null != constructor){ + constructor.setAccessible(true);//ABRACADABRA! + + try { + Object o = constructor.newInstance(); + return (Class) o; + } catch (InstantiationException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return null; + } + + + +} diff --git a/src/Java/gtPlusPlus/core/util/Log.java b/src/Java/gtPlusPlus/core/util/Log.java new file mode 100644 index 0000000000..ea7076e453 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/Log.java @@ -0,0 +1,29 @@ +package gtPlusPlus.core.util; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public final class Log +{ + public static final Logger LOGGER = LogManager.getLogger("MiscUtils"); + + public static void warn(String msg) + { + LOGGER.warn(msg); + } + + public static void error(String msg) + { + LOGGER.error(msg); + } + + public static void info(String msg) + { + LOGGER.info(msg); + } + + public static void debug(String msg) + { + LOGGER.debug(msg); + } +} diff --git a/src/Java/gtPlusPlus/core/util/LoggingUtils.java b/src/Java/gtPlusPlus/core/util/LoggingUtils.java new file mode 100644 index 0000000000..7783577ee2 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/LoggingUtils.java @@ -0,0 +1,54 @@ +package gtPlusPlus.core.util; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Date; + +public class LoggingUtils { + + public static void profileLog(Object o){ + try { + String content; + File file = new File("GregtechTimingsTC.txt"); + // if file doesnt exists, then create it + if (!file.exists()) { + file.createNewFile(); + FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); + BufferedWriter bw = new BufferedWriter(fw); + bw.write("============================================================"); + bw.write(System.lineSeparator()); + bw.close(); + } + if (o instanceof String){ + content = (String) o; + } + else { + content = o.toString(); + } + FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); + BufferedWriter bw = new BufferedWriter(fw); + bw.write(content); + bw.write(System.lineSeparator()); + bw.close(); + System.out.println("Data Logged."); + + } catch (IOException e) { + System.out.println("Data logging failed."); + } + } + + public static boolean logCurrentSystemTime(String message){ + Date date = new Date(System.currentTimeMillis()); + try { + profileLog(message+" | "+date.toString()); + return true; + } + catch (Throwable r) { + return false; + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java new file mode 100644 index 0000000000..f6430cc75d --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -0,0 +1,539 @@ +package gtPlusPlus.core.util; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.TC_Aspects; +import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.fluid.FluidUtils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import ic2.core.IC2Potion; +import ic2.core.Ic2Items; +import ic2.core.init.InternalName; +import ic2.core.item.armor.ItemArmorHazmat; +import ic2.core.item.resources.ItemCell; + +import java.awt.Color; +import java.awt.Graphics; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; +import java.util.UUID; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.util.EnumHelper; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.registry.EntityRegistry; + +public class Utils { + + public static final int WILDCARD_VALUE = Short.MAX_VALUE; + + static class ShortTimerTask extends TimerTask { + @Override + public void run() { + Utils.LOG_WARNING("Timer expired."); + } + } + + public static TC_AspectStack getTcAspectStack (TC_Aspects aspect, int size){ + + TC_AspectStack returnValue = null; + + if (aspect.name().toUpperCase() == "COGNITIO"){ + //Adds in Compat for older GT Versions which Misspell aspects. + try { + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); + } catch (NoSuchFieldError r){ + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect.name()+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); + + } + } + else if (aspect.name().toUpperCase() == "EXANIMUS"){ + //Adds in Compat for older GT Versions which Misspell aspects. + try { + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); + } catch (NoSuchFieldError r){ + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect.name()+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); + } + } + else if (aspect.name().toUpperCase() == "PRAECANTATIO"){ + //Adds in Compat for older GT Versions which Misspell aspects. + try { + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); + } catch (NoSuchFieldError r){ + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect.name()+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); + } + } + else { + returnValue = new TC_AspectStack(aspect, size); + } + + return returnValue; + } + + public static boolean containsMatch(boolean strict, ItemStack[] inputs, ItemStack... targets) + { + for (ItemStack input : inputs) + { + for (ItemStack target : targets) + { + if (itemMatches(target, input, strict)) + { + return true; + } + } + } + return false; + } + + public static boolean itemMatches(ItemStack target, ItemStack input, boolean strict) + { + if (input == null || target == null) + { + return false; + } + return (target.getItem() == input.getItem() && ((target.getItemDamage() == WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage())); + } + + //TODO + public static void registerEntityToBiomeSpawns(Class<EntityLiving> classy, EnumCreatureType EntityType, BiomeGenBase baseBiomeGen){ + EntityRegistry.addSpawn(classy, 6, 1, 5, EntityType, baseBiomeGen); //change the values to vary the spawn rarity, biome, etc. + } + + //Non-Dev Comments + public static void LOG_INFO(String s){ + //if (CORE.DEBUG){ + FMLLog.info("GT++: "+s); + //} + } + + //Developer Comments + public static void LOG_WARNING(String s){ + if (CORE.DEBUG){ + FMLLog.warning("GT++: "+s); + } + } + + //Errors + public static void LOG_ERROR(String s){ + if (CORE.DEBUG){ + FMLLog.severe("GT++: "+s); + } + } + + //Developer Logger + public static void LOG_SPECIFIC_WARNING(String whatToLog, String msg, int line){ + if (CORE.DEBUG){ + FMLLog.warning("GT++ |"+line+"| "+whatToLog+" | "+msg); + } + } + + public static void paintBox(Graphics g, int MinA, int MinB, int MaxA, int MaxB){ + g.drawRect (MinA, MinB, MaxA, MaxB); + } + + public static void messagePlayer(EntityPlayer P, String S){ + gregtech.api.util.GT_Utility.sendChatToPlayer(P, S); + } + + /** + * Returns if that Liquid is IC2Steam. + */ + public static boolean isIC2Steam(FluidStack aFluid) { + if (aFluid == null) return false; + return aFluid.isFluidEqual(getIC2Steam(1)); + } + + /** + * Returns a Liquid Stack with given amount of IC2Steam. + */ + public static FluidStack getIC2Steam(long aAmount) { + return FluidRegistry.getFluidStack("ic2steam", (int)aAmount); + } + + + + /*public static void recipeBuilderBlock(ItemStack slot_1, ItemStack slot_2, ItemStack slot_3, ItemStack slot_4, ItemStack slot_5, ItemStack slot_6, ItemStack slot_7, ItemStack slot_8, ItemStack slot_9, Block resultBlock){ + GameRegistry.addRecipe(new ItemStack(resultBlock), + new Object[] {"ABC", "DEF", "GHI", + 'A',slot_1,'B',slot_2,'C',slot_3, + 'D',slot_4,'E',slot_5,'F',slot_6, + 'G',slot_7,'H',slot_8,'I',slot_9 + }); + }*/ + + public static String checkCorrectMiningToolForBlock(Block currentBlock, World currentWorld){ + String correctTool = ""; + if (!currentWorld.isRemote){ + try { + correctTool = currentBlock.getHarvestTool(0); + Utils.LOG_WARNING(correctTool); + + } catch (NullPointerException e){ + + } + } + + return correctTool; + } + + /** + * + * @param colorStr e.g. "#FFFFFF" + * @return String - formatted "rgb(0,0,0)" + */ + public static String hex2Rgb(String hexString) { + Color c = new Color( + Integer.valueOf(hexString.substring(1, 3), 16), + Integer.valueOf(hexString.substring(3, 5), 16), + Integer.valueOf(hexString.substring(5, 7), 16)); + + StringBuffer sb = new StringBuffer(); + sb.append("rgb("); + sb.append(c.getRed()); + sb.append(","); + sb.append(c.getGreen()); + sb.append(","); + sb.append(c.getBlue()); + sb.append(")"); + return sb.toString(); + } + + public static Timer ShortTimer(int seconds) { + Timer timer; + timer = new Timer(); + timer.schedule(new ShortTimerTask(), seconds * 1000); + return timer; + } + + public static String byteToHex(byte b) { + int i = b & 0xFF; + return Integer.toHexString(i); + } + + public static Object[] convertListToArray(List<Object> sourceList) { + Object[] targetArray = sourceList.toArray(new Object[sourceList.size()]); + return targetArray; + } + + public static List<Object> convertArrayToListFixed(Object[] sourceArray) { + List<Object> targetList = Arrays.asList(sourceArray); + return targetList; + } + + public static List<Object> convertArrayToList(Object[] sourceArray) { + List<Object> targetList = new ArrayList<Object>(Arrays.asList(sourceArray)); + return targetList; + } + + public static EntityPlayer getPlayerOnServerFromUUID(UUID parUUID){ + if (parUUID == null) + { + return null; + } + List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayerMP player : allPlayers) + { + if (player.getUniqueID().equals(parUUID)) + { + return player; + } + } + return null; + } + + @Deprecated + public static Block findBlockUnderEntityNonBoundingBox(Entity parEntity){ + int blockX = MathHelper.floor_double(parEntity.posX); + int blockY = MathHelper.floor_double(parEntity.posY-0.2D - (double)parEntity.yOffset); + int blockZ = MathHelper.floor_double(parEntity.posZ); + return parEntity.worldObj.getBlock(blockX, blockY, blockZ); + } + + public static Block findBlockUnderEntity(Entity parEntity){ + int blockX = MathHelper.floor_double(parEntity.posX); + int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1; + int blockZ = MathHelper.floor_double(parEntity.posZ); + return parEntity.worldObj.getBlock(blockX, blockY, blockZ); + } + + public static int getFacingDirection(Entity entity){ + int d = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360) + 0.50) & 3; + return d; + } + + public static boolean isPlayerOP(EntityPlayer player){ + if (player.canCommandSenderUseCommand(2, "")){ + return true; + } + return false; + } + + public static void setEntityOnFire(Entity entity, int length){ + entity.setFire(length); + } + + public static void spawnCustomParticle(Entity entity){ + GTplusplus.proxy.generateMysteriousParticles(entity); + } + + public static void spawnFX(World world, int x, int y, int z, String particleName, Object particleName2){ + if (!world.isRemote){ + if (particleName2 == null || particleName2.equals("")){ + particleName2 = particleName; + } + int l = MathUtils.randInt(0, 4); + double d0 = (double)((float)x + 0.5F); + double d1 = (double)((float)y + 0.7F); + double d2 = (double)((float)z + 0.5F); + double d3 = 0.2199999988079071D; + double d4 = 0.27000001072883606D; + + if (l == 1) + { + world.spawnParticle(particleName, d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } + else if (l == 2) + { + world.spawnParticle((String) particleName2, d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } + else if (l == 3) + { + world.spawnParticle(particleName, d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); + } + else if (l == 4) + { + world.spawnParticle((String) particleName2, d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); + } + else + { + world.spawnParticle(particleName, d0, d1, d2, 0.0D, 0.0D, 0.0D); + if (particleName2 != null){ + world.spawnParticle((String) particleName2, d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } + } + } + + public static int rgbtoHexValue(int r, int g, int b){ + Color c = new Color(r,g,b); + String temp = Integer.toHexString( c.getRGB() & 0xFFFFFF ).toUpperCase(); + + //System.out.println( "hex: " + Integer.toHexString( c.getRGB() & 0xFFFFFF ) + " hex value:"+temp); + temp = Utils.appenedHexNotationToString(String.valueOf(temp)); + Utils.LOG_WARNING("Made "+temp+" - Hopefully it's not a mess."); + Utils.LOG_WARNING("It will decode into "+Integer.decode(temp)+"."); + return Integer.decode(temp); + } + + /* + * http://javadevnotes.com/java-left-pad-string-with-zeros-examples + */ + public static String leftPadWithZeroes(String originalString, int length) { + StringBuilder sb = new StringBuilder(); + while (sb.length() + originalString.length() < length) { + sb.append('0'); + } + sb.append(originalString); + String paddedString = sb.toString(); + return paddedString; + } + + /* + * Original Code by Chandana Napagoda - https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator.html + */ + public static Map<Integer, String> hexColourGenerator(int colorCount){ + int maxColorValue = 16777215; + // this is decimal value of the "FFFFFF" + int devidedvalue = maxColorValue/colorCount; + int countValue = 0; + HashMap<Integer, String> hexColorMap = new HashMap<Integer, String>(); + for(int a=0; a < colorCount && maxColorValue >= countValue ; a++){ + if(a != 0){ + countValue+=devidedvalue; + hexColorMap.put(a,Integer.toHexString( 0x10000 | countValue).substring(1).toUpperCase()); + } + else { + hexColorMap.put(a,Integer.toHexString( 0x10000 | countValue).substring(1).toUpperCase()); + } + } + return hexColorMap; + } + + /* + * Original Code by Chandana Napagoda - https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator.html + */ + public static Map<Integer, String> hexColourGeneratorRandom(int colorCount){ + HashMap<Integer, String> hexColorMap = new HashMap<Integer, String>(); + for(int a=0;a < colorCount; a++){ + String code = ""+(int)(Math.random()*256); + code = code+code+code; + int i = Integer.parseInt(code); + hexColorMap.put(a,Integer.toHexString( 0x1000000 | i).substring(1).toUpperCase()); + Utils.LOG_INFO(""+Integer.toHexString( 0x1000000 | i).substring(1).toUpperCase()); + } + return hexColorMap; + } + + public static String appenedHexNotationToString(Object hexAsStringOrInt){ + String hexChar = "0x"; + String result; + if (hexAsStringOrInt.getClass() == String.class){ + + if (((String) hexAsStringOrInt).length() != 6){ + String temp = leftPadWithZeroes((String) hexAsStringOrInt, 6); + result = temp; + } + result = hexChar+hexAsStringOrInt; + return result; + } + else if (hexAsStringOrInt.getClass() == Integer.class){ + ; + if (((String) hexAsStringOrInt).length() != 6){ + String temp = leftPadWithZeroes((String) hexAsStringOrInt, 6); + result = temp; + } + result = hexChar+String.valueOf(hexAsStringOrInt); + return result; + } + else { + return null; + } + } + + public static Integer appenedHexNotationToInteger(int hexAsStringOrInt){ + String hexChar = "0x"; + String result; + Utils.LOG_INFO(String.valueOf(hexAsStringOrInt)); + result = hexChar+String.valueOf(hexAsStringOrInt); + return Integer.getInteger(result); + } + + public static boolean doesEntryExistAlreadyInOreDictionary(String OreDictName){ + if (OreDictionary.getOres(OreDictName).size() != 0) { + return true; + } + return false; + } + + public static boolean invertBoolean(boolean booleans){ + if (booleans == true){ + return false; + } + return true; + } + + public static boolean applyRadiationDamageToEntity(int damage, World world, Entity entityHolding){ + if (!world.isRemote){ + if (damage > 0 && (entityHolding instanceof EntityLivingBase)) { + EntityLivingBase entityLiving = (EntityLivingBase) entityHolding; + if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving)) { + int duration; + if (entityLiving.getActivePotionEffect(IC2Potion.radiation) != null){ + //Utils.LOG_INFO("t"); + duration = (damage*5)+entityLiving.getActivePotionEffect(IC2Potion.radiation).getDuration(); + } + else { + //Utils.LOG_INFO("f"); + duration = damage*30; + } + IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15); + } + } + return true; + } + return false; + } + + private static short cellID = 15; + public static ItemStack createInternalNameAndFluidCell(String s){ + Utils.LOG_WARNING("1"); + InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); + Utils.LOG_WARNING("2 "+yourName.name()); + ItemCell item = (ItemCell)Ic2Items.cell.getItem(); + Utils.LOG_WARNING("3 "+item.getUnlocalizedName()); + try + { + Utils.LOG_WARNING("4"); + Class<? extends ItemCell> clz = item.getClass(); + Utils.LOG_WARNING("5 "+clz.getSimpleName()); + Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); + Utils.LOG_WARNING("6 "+methode.getName()); + methode.setAccessible(true); + Utils.LOG_WARNING("7 "+methode.isAccessible()); + ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); + Utils.LOG_INFO("Successfully created "+temp.getDisplayName()+"s."); + FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 0), temp.copy(), Ic2Items.cell.copy()); + UtilsItems.addItemToOreDictionary(temp.copy(), "cell"+s); + return temp; + } + catch(Exception e){ + e.printStackTrace(); + } + return null; + } + + public static String sanitizeString(String input){ + String temp; + String output; + + temp = input.replace(" ", ""); + temp = temp.replace("-", ""); + temp = temp.replace("_", ""); + temp = temp.replace("?", ""); + temp = temp.replace("!", ""); + temp = temp.replace("@", ""); + temp = temp.replace("#", ""); + temp = temp.replace("(", ""); + temp = temp.replace(")", ""); + temp = temp.replace("{", ""); + temp = temp.replace("}", ""); + temp = temp.replace("[", ""); + temp = temp.replace("]", ""); + output = temp; + return output; + + } + + public static ToolMaterial generateMaterialFromGT(Materials gtMaterial){ + String name = gtMaterial.name(); + int harvestLevel = gtMaterial.mToolQuality; + int durability = gtMaterial.mDurability; + float damage = gtMaterial.mToolQuality; + int efficiency = (int) gtMaterial.mToolSpeed; + int enchantability = gtMaterial.mEnchantmentToolsLevel; + ToolMaterial temp = EnumHelper.addToolMaterial(name, harvestLevel, durability, efficiency, damage, enchantability); + return temp; + + } + + +} + + diff --git a/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java b/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java new file mode 100644 index 0000000000..9e358b3074 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java @@ -0,0 +1,156 @@ +package gtPlusPlus.core.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public enum UtilsChatFormatting +{ + BLACK('0'), + DARK_BLUE('1'), + DARK_GREEN('2'), + DARK_AQUA('3'), + DARK_RED('4'), + DARK_PURPLE('5'), + GOLD('6'), + GRAY('7'), + DARK_GRAY('8'), + BLUE('9'), + GREEN('a'), + AQUA('b'), + RED('c'), + LIGHT_PURPLE('d'), + YELLOW('e'), + WHITE('f'), + OBFUSCATED('k', true), + BOLD('l', true), + STRIKETHROUGH('m', true), + UNDERLINE('n', true), + ITALIC('o', true), + RESET('r'); + /** Maps a formatting code (e.g., 'f') to its corresponding enum value (e.g., WHITE). */ + private static final Map<Character, UtilsChatFormatting> formattingCodeMapping = new HashMap<Character, UtilsChatFormatting>(); + /** Maps a name (e.g., 'underline') to its corresponding enum value (e.g., UNDERLINE). */ + private static final Map<String, UtilsChatFormatting> nameMapping = new HashMap<String, UtilsChatFormatting>(); + /** + * Matches formatting codes that indicate that the client should treat the following text as bold, recolored, + * obfuscated, etc. + */ + private static final Pattern formattingCodePattern = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]"); + /** The formatting code that produces this format. */ + private final char formattingCode; + private final boolean fancyStyling; + /** + * The control string (section sign + formatting code) that can be inserted into client-side text to display + * subsequent text in this format. + */ + private final String controlString; + + private UtilsChatFormatting(char p_i1336_3_) + { + this(p_i1336_3_, false); + } + + private UtilsChatFormatting(char p_i1337_3_, boolean p_i1337_4_) + { + this.formattingCode = p_i1337_3_; + this.fancyStyling = p_i1337_4_; + this.controlString = "\u00a7" + p_i1337_3_; + } + + /** + * Gets the formatting code that produces this format. + */ + public char getFormattingCode() + { + return this.formattingCode; + } + + /** + * False if this is just changing the color or resetting; true otherwise. + */ + public boolean isFancyStyling() + { + return this.fancyStyling; + } + + /** + * Checks if typo is a color. + */ + public boolean isColor() + { + return !this.fancyStyling && this != RESET; + } + + /** + * Gets the friendly name of this value. + */ + public String getFriendlyName() + { + return this.name().toLowerCase(); + } + + @Override + public String toString() + { + return this.controlString; + } + + /** + * Returns a copy of the given string, with formatting codes stripped away. + */ + @SideOnly(Side.CLIENT) + public static String getTextWithoutFormattingCodes(String p_110646_0_) + { + return p_110646_0_ == null ? null : formattingCodePattern.matcher(p_110646_0_).replaceAll(""); + } + + /** + * Gets a value by its friendly name; null if the given name does not map to a defined value. + */ + public static UtilsChatFormatting getValueByName(String p_96300_0_) + { + return p_96300_0_ == null ? null : (UtilsChatFormatting)nameMapping.get(p_96300_0_.toLowerCase()); + } + + /** + * Gets all the valid values. Args: @param par0: Whether or not to include color values. @param par1: Whether or not + * to include fancy-styling values (anything that isn't a color value or the "reset" value). + */ + public static Collection<String> getValidValues(boolean p_96296_0_, boolean p_96296_1_) + { + ArrayList<String> arraylist = new ArrayList<String>(); + UtilsChatFormatting[] aenumchatformatting = values(); + int i = aenumchatformatting.length; + + for (int j = 0; j < i; ++j) + { + UtilsChatFormatting enumchatformatting = aenumchatformatting[j]; + + if ((!enumchatformatting.isColor() || p_96296_0_) && (!enumchatformatting.isFancyStyling() || p_96296_1_)) + { + arraylist.add(enumchatformatting.getFriendlyName()); + } + } + + return arraylist; + } + + static + { + UtilsChatFormatting[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + UtilsChatFormatting var3 = var0[var2]; + formattingCodeMapping.put(Character.valueOf(var3.getFormattingCode()), var3); + nameMapping.put(var3.getFriendlyName(), var3); + } + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/UtilsRarity.java b/src/Java/gtPlusPlus/core/util/UtilsRarity.java new file mode 100644 index 0000000000..19339b7717 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/UtilsRarity.java @@ -0,0 +1,23 @@ +package gtPlusPlus.core.util; + +import net.minecraft.util.EnumChatFormatting; + +public enum UtilsRarity +{ + T1_poor(EnumChatFormatting.GRAY, "Poor"), + T2_normal(EnumChatFormatting.WHITE, "Common"), + T3_uncommon(EnumChatFormatting.GREEN, "Uncommon"), + T4_magic(EnumChatFormatting.BLUE, "Magic"), + T5_rare(EnumChatFormatting.LIGHT_PURPLE, "Rare"), + T6_epic(EnumChatFormatting.YELLOW, "Epic"), + T8_unique(EnumChatFormatting.GOLD, "Unique"); + + public final EnumChatFormatting rarityColor; + public final String rarityName; + + private UtilsRarity(EnumChatFormatting rarity, String name) + { + this.rarityColor = rarity; + this.rarityName = name; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/UtilsText.java b/src/Java/gtPlusPlus/core/util/UtilsText.java new file mode 100644 index 0000000000..e91fa95e4c --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/UtilsText.java @@ -0,0 +1,32 @@ +package gtPlusPlus.core.util; + +public enum UtilsText { + + blue('1'), + green('2'), + teal('3'), + maroon('4'), + purple('5'), + orange('6'), + lightGray('7'), + darkGray('8'), + lightBlue('9'), + black('0'), + lime('a'), + aqua('b'), + red('c'), + pink('d'), + yellow('e'), + white('f'); + + private char colourValue; + private UtilsText (char value) + { + this.colourValue = value; + } + + public String colour() { + return "§"+colourValue; + } + +} diff --git a/src/Java/gtPlusPlus/core/util/debug/DEBUG_BLOCK_ShapeSpawner.java b/src/Java/gtPlusPlus/core/util/debug/DEBUG_BLOCK_ShapeSpawner.java new file mode 100644 index 0000000000..74df9f90ba --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/debug/DEBUG_BLOCK_ShapeSpawner.java @@ -0,0 +1,139 @@ +package gtPlusPlus.core.util.debug; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.util.Utils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +public class DEBUG_BLOCK_ShapeSpawner extends DEBUG_MULTIBLOCK_ShapeSpawner { + + private static boolean controller; + + public DEBUG_BLOCK_ShapeSpawner(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public DEBUG_BLOCK_ShapeSpawner(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new DEBUG_BLOCK_ShapeSpawner(this.mName); + } + + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Testing", + "Create the shapes for Multiblocks.",}; + } + + + @Override + public ITexture[] getTexture(IGregTechTileEntity arg0, byte arg1, + byte arg2, byte arg3, boolean arg4, boolean arg5) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + + int stepX = aBaseMetaTileEntity.getXCoord(); + int stepY = aBaseMetaTileEntity.getYCoord(); + int stepZ = aBaseMetaTileEntity.getZCoord(); + int temp = 0; + + Utils.LOG_INFO("Starting Block located @ "+"[X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + + int tAmount = 0; + switch (xDir) { + case -1: + stepX++; + Utils.LOG_INFO("Modifying stepX + accomodate a "+xDir+" xDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + + case 1: + stepX--; + Utils.LOG_INFO("Modifying stepX - accomodate a "+xDir+" xDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + } + switch (zDir) { + case -1: + stepZ++; + Utils.LOG_INFO("Modifying stepZ + accomodate a "+zDir+" zDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + + case 1: + stepZ--; + Utils.LOG_INFO("Modifying stepZ - accomodate a "+zDir+" zDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + } + + for (int i = stepX-1; i <= stepX+1; i++){ + for (int j = stepZ-1; j <= stepZ+1; j++){ + for (int h = stepY-1; h <= stepY+1; h++){ + + + Utils.LOG_INFO("Block Facing - X:"+xDir+" Z:"+zDir); + Utils.LOG_INFO("(h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))"); + Utils.LOG_INFO(" "+(h != 0)+" || "+(((xDir + i != 0)+" || "+(zDir + j != 0))+" && "+((i != 0)+" || "+(j != 0)))); + } + } + } + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getAmountOfOutputs() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/Java/gtPlusPlus/core/util/debug/DEBUG_INIT.java b/src/Java/gtPlusPlus/core/util/debug/DEBUG_INIT.java new file mode 100644 index 0000000000..440949471c --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/debug/DEBUG_INIT.java @@ -0,0 +1,43 @@ +package gtPlusPlus.core.util.debug; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.base.BaseItemWithCharge; +import gtPlusPlus.core.item.general.BedLocator_Base; +import gtPlusPlus.core.lib.CORE; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.common.registry.GameRegistry; + +public class DEBUG_INIT { + + public static void registerBlocks(){ + //Debug Loading + if (CORE.DEBUG){ + + } + } + + public static void registerItems(){ + ModItems.itemDebugShapeSpawner = new DEBUG_ITEM_ShapeSpawner("itemDebugShapeSpawner", AddToCreativeTab.tabMisc, 1, 500); + GameRegistry.registerItem(ModItems.itemDebugShapeSpawner, "itemDebugShapeSpawner"); + ModItems.itemBedLocator_Base = new BedLocator_Base("itemBedLocator_Base"); + GameRegistry.registerItem(ModItems.itemBedLocator_Base, "itemBedLocator_Base"); + ModItems.itemBaseItemWithCharge = new BaseItemWithCharge("itemBaseItemWithCharge", 0, 1000); + GameRegistry.registerItem(ModItems.itemBaseItemWithCharge, "itemBaseItemWithCharge"); + } + + public static void registerTEs(){ + + } + + public static void registerMisc(){ + + + + } + + public static void registerHandlers(){ + MinecraftForge.EVENT_BUS.register(new DEBUG_ScreenOverlay()); + } + +} diff --git a/src/Java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java b/src/Java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java new file mode 100644 index 0000000000..bfaa7404e1 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java @@ -0,0 +1,55 @@ +package gtPlusPlus.core.util.debug; + +import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.BaseItemGeneric; +import gtPlusPlus.core.util.Utils; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class DEBUG_ITEM_ShapeSpawner extends BaseItemGeneric{ + + public DEBUG_ITEM_ShapeSpawner(String s, CreativeTabs c, int stackSize, int maxDmg) { + super(s, c, stackSize, maxDmg); + s = "itemDebugShapeSpawner"; + c = AddToCreativeTab.tabMisc; + stackSize = 1; + maxDmg = 500; + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ + + if (!world.isRemote){ + Utils.LOG_INFO("Constructing the shape for the "+"VACUUM FREEZER"); + Thread thread = new Thread(new DEBUG_TimerThread(world, player)); + thread.start(); + } + return stack; + } + + + + @SuppressWarnings("static-method") + @SubscribeEvent + public void playerInteractEventHandler(PlayerInteractEvent event) + { + if (event.isCanceled() || event.world.isRemote || event.action != RIGHT_CLICK_BLOCK) return; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+"For Testing Gregtech Shapes!"); + super.addInformation(stack, aPlayer, list, bool); + } + +} diff --git a/src/Java/gtPlusPlus/core/util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java b/src/Java/gtPlusPlus/core/util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java new file mode 100644 index 0000000000..78acb27cfb --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java @@ -0,0 +1,805 @@ +package gtPlusPlus.core.util.debug; + +import static gregtech.api.enums.GT_Values.V; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_Container_MultiMachine; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; + +import java.util.ArrayList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public abstract class DEBUG_MULTIBLOCK_ShapeSpawner extends MetaTileEntity { + + public static boolean disableMaintenance; + public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false, mRunningOnLoad = false; + public int mPollution = 0, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mUpdate = 0, mStartUpCheck = 100, mRuntime = 0, mEfficiency = 0; + public ItemStack[] mOutputItems = null; + public FluidStack[] mOutputFluids = null; + public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Input>(); + public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Output>(); + public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>(); + public ArrayList<GT_MetaTileEntity_Hatch_OutputBus> mOutputBusses = new ArrayList<GT_MetaTileEntity_Hatch_OutputBus>(); + public ArrayList<GT_MetaTileEntity_Hatch_Dynamo> mDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch_Dynamo>(); + public ArrayList<GT_MetaTileEntity_Hatch_Muffler> mMufflerHatches = new ArrayList<GT_MetaTileEntity_Hatch_Muffler>(); + public ArrayList<GT_MetaTileEntity_Hatch_Energy> mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>(); + public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<GT_MetaTileEntity_Hatch_Maintenance>(); + + public DEBUG_MULTIBLOCK_ShapeSpawner(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 2); + this.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); + } + + public DEBUG_MULTIBLOCK_ShapeSpawner(String aName) { + super(aName, 2); + this.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); + } + + public static boolean isValidMetaTileEntity(MetaTileEntity aMetaTileEntity) { + return aMetaTileEntity.getBaseMetaTileEntity() != null && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex > 0; + } + + @Override + public int getProgresstime() { + return mProgresstime; + } + + @Override + public int maxProgresstime() { + return mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + return aProgress; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setInteger("mEfficiency", mEfficiency); + aNBT.setInteger("mPollution", mPollution); + aNBT.setInteger("mRuntime", mRuntime); + + if (mOutputItems != null) for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + if (mOutputFluids != null) for (int i = 0; i < mOutputFluids.length; i++) + if (mOutputFluids[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputFluids[i].writeToNBT(tNBT); + aNBT.setTag("mOutputFluids" + i, tNBT); + } + + aNBT.setBoolean("mWrench", mWrench); + aNBT.setBoolean("mScrewdriver", mScrewdriver); + aNBT.setBoolean("mSoftHammer", mSoftHammer); + aNBT.setBoolean("mHardHammer", mHardHammer); + aNBT.setBoolean("mSolderingTool", mSolderingTool); + aNBT.setBoolean("mCrowbar", mCrowbar); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mEUt = aNBT.getInteger("mEUt"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + if (mMaxProgresstime > 0) mRunningOnLoad = true; + mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + mEfficiency = aNBT.getInteger("mEfficiency"); + mPollution = aNBT.getInteger("mPollution"); + mRuntime = aNBT.getInteger("mRuntime"); + mOutputItems = new ItemStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + mOutputFluids = new FluidStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputFluids.length; i++) + mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); + mWrench = aNBT.getBoolean("mWrench"); + mScrewdriver = aNBT.getBoolean("mScrewdriver"); + mSoftHammer = aNBT.getBoolean("mSoftHammer"); + mHardHammer = aNBT.getBoolean("mHardHammer"); + mSolderingTool = aNBT.getBoolean("mSolderingTool"); + mCrowbar = aNBT.getBoolean("mCrowbar"); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiblockDisplay.png"); + } + + @Override + public byte getTileEntityBaseType() { + return 2; + } + + @Override + public void onMachineBlockUpdate() { + mUpdate = 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (mEfficiency < 0) mEfficiency = 0; + if (--mUpdate == 0 || --mStartUpCheck == 0) { + mInputHatches.clear(); + mInputBusses.clear(); + mOutputHatches.clear(); + mOutputBusses.clear(); + mDynamoHatches.clear(); + mEnergyHatches.clear(); + mMufflerHatches.clear(); + mMaintenanceHatches.clear(); + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + } + if (mStartUpCheck < 0) { + if (mMachine) { + for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (!this.disableMaintenance) { + if (tHatch.mWrench) mWrench = true; + if (tHatch.mScrewdriver) mScrewdriver = true; + if (tHatch.mSoftHammer) mSoftHammer = true; + if (tHatch.mHardHammer) mHardHammer = true; + if (tHatch.mSolderingTool) mSolderingTool = true; + if (tHatch.mCrowbar) mCrowbar = true; + } else { + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + } + + tHatch.mWrench = false; + tHatch.mScrewdriver = false; + tHatch.mSoftHammer = false; + tHatch.mHardHammer = false; + tHatch.mSolderingTool = false; + tHatch.mCrowbar = false; + } + } + if (getRepairStatus() > 0) { + if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) { + if (onRunningTick(mInventory[1])) { + if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) { + stopMachine(); + } + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputItems != null) for (ItemStack tStack : mOutputItems) + if (tStack != null) { + try { + GT_Mod.instance.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack); + } catch (Exception e) { + } + addOutput(tStack); + } + if (mOutputFluids != null && mOutputFluids.length == 1) { + for (FluidStack tStack : mOutputFluids) + if (tStack != null) { + addOutput(tStack); + } + } else if (mOutputFluids != null && mOutputFluids.length > 1) { + addFluidOutputs(mOutputFluids); + } + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + mOutputItems = null; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(mInventory[1]); + if (mOutputFluids != null && mOutputFluids.length > 0) { + if (mOutputFluids.length > 1) { + GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "oilplant"); + } + } + } + } + } else { + if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { + + if (aBaseMetaTileEntity.isAllowedToWork()) { + checkRecipe(mInventory[1]); + } + if (mMaxProgresstime <= 0) mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } else { + stopMachine(); + } + } else { + stopMachine(); + } + } + aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + public boolean polluteEnvironment(int aPollutionLevel) { + mPollution += aPollutionLevel; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (mPollution >= 10000) { + if (tHatch.polluteEnvironment()) { + mPollution -= 10000; + } + } else { + break; + } + } + } + return mPollution < 10000; + } + + /** + * Called every tick the Machine runs + */ + public boolean onRunningTick(ItemStack aStack) { + if (mEUt > 0) { + addEnergyOutput(((long) mEUt * mEfficiency) / 10000); + return true; + } + if (mEUt < 0) { + if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + stopMachine(); + return false; + } + } + return true; + } + + /** + * Checks if this is a Correct Machine Part for this kind of Machine (Turbine Rotor for example) + */ + public abstract boolean isCorrectMachinePart(ItemStack aStack); + + /** + * Checks the Recipe + */ + public abstract boolean checkRecipe(ItemStack aStack); + + /** + * Checks the Machine. You have to assign the MetaTileEntities for the Hatches here. + */ + public abstract boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack); + + /** + * Gets the maximum Efficiency that spare Part can get (0 - 10000) + */ + public abstract int getMaxEfficiency(ItemStack aStack); + + /** + * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) + */ + public abstract int getPollutionPerTick(ItemStack aStack); + + /** + * Gets the damage to the ItemStack, usually 0 or 1. + */ + public abstract int getDamageToComponent(ItemStack aStack); + + /** + * Gets the Amount of possibly outputted Items for loading the Output Stack Array from NBT. + * This should be the largest Amount that can ever happen legitimately. + */ + public abstract int getAmountOfOutputs(); + + /** + * If it explodes when the Component has to be replaced. + */ + public abstract boolean explodesOnComponentBreak(ItemStack aStack); + + public void stopMachine() { + mOutputItems = null; + mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + } + + public int getRepairStatus() { + return (mWrench ? 1 : 0) + (mScrewdriver ? 1 : 0) + (mSoftHammer ? 1 : 0) + (mHardHammer ? 1 : 0) + (mSolderingTool ? 1 : 0) + (mCrowbar ? 1 : 0); + } + + public int getIdealStatus() { + return 6; + } + + public boolean doRandomMaintenanceDamage() { + if (!isCorrectMachinePart(mInventory[1]) || getRepairStatus() == 0) { + stopMachine(); + return false; + } + if (mRuntime++ > 1000) { + mRuntime = 0; + if (getBaseMetaTileEntity().getRandomNumber(6000) == 0) { + switch (getBaseMetaTileEntity().getRandomNumber(6)) { + case 0: + mWrench = false; + break; + case 1: + mScrewdriver = false; + break; + case 2: + mSoftHammer = false; + break; + case 3: + mHardHammer = false; + break; + case 4: + mSolderingTool = false; + break; + case 5: + mCrowbar = false; + break; + } + } + if (mInventory[1] != null && getBaseMetaTileEntity().getRandomNumber(2) == 0 && !mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) { + if (mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { + NBTTagCompound tNBT = mInventory[1].getTagCompound(); + if (tNBT != null) { + NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents"); + if (!tNBT.getBoolean("mDis")) { + tNBT2 = new NBTTagCompound(); + Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]); + ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1); + int i = mInventory[1].getItemDamage(); + if (i == 170) { + ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Magnalium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 172) { + ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Titanium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 174) { + ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TungstenSteel, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 176) { + ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Americium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } + tNBT.setTag("GT.CraftingComponents", tNBT2); + tNBT.setBoolean("mDis", true); + mInventory[1].setTagCompound(tNBT); + + } + } + + ((GT_MetaGenerated_Tool) mInventory[1].getItem()).doDamage(mInventory[1], (long) Math.min(mEUt / 5, Math.pow(mEUt, 0.7))); + if (mInventory[1].stackSize == 0) mInventory[1] = null; + } + } + } + return true; + } + + public void explodeMultiblock() { + mInventory[1] = null; + for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mDynamoHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mEnergyHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mMaintenanceHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + getBaseMetaTileEntity().doExplosion(V[8]); + } + + public boolean addEnergyOutput(long aEU) { + if (aEU <= 0) return true; + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) { + return true; + } + } + } + return false; + } + + public long getMaxInputVoltage() { + long rVoltage = 0; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); + return rVoltage; + } + + public boolean drainEnergyInput(long aEU) { + if (aEU <= 0) return true; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) { + if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) return true; + } + return false; + } + + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) return false; + FluidStack tLiquid = aLiquid.copy(); + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? tHatch.outputsSteam() : tHatch.outputsLiquids()) { + int tAmount = tHatch.fill(tLiquid, false); + if (tAmount >= tLiquid.amount) { + return tHatch.fill(tLiquid, true) >= tLiquid.amount; + } else if (tAmount > 0) { + tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); + } + } + } + return false; + } + + private void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length; i++) { + if (mOutputHatches.size() > i && mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity(mOutputHatches.get(i))) { + mOutputHatches.get(i).fill(mOutputFluids2[i], true); + } + } + + } + + public boolean depleteInput(FluidStack aLiquid) { + if (aLiquid == null) return false; + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid != null && tLiquid.isFluidEqual(aLiquid)) { + tLiquid = tHatch.drain(aLiquid.amount, false); + if (tLiquid != null && tLiquid.amount >= aLiquid.amount) { + tLiquid = tHatch.drain(aLiquid.amount, true); + return tLiquid != null && tLiquid.amount >= aLiquid.amount; + } + } + } + } + return false; + } + + public boolean addOutput(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + aStack = GT_Utility.copy(aStack); +// FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); +// if (aLiquid == null) { + for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getSizeInventory() - 1; i >= 0; i--) { + if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, aStack)) return true; + } + } + } + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if (isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) { + if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, aStack)) return true; + } + } +// }else { +// for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { +// if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid)?tHatch.outputsSteam():tHatch.outputsLiquids()) { +// int tAmount = tHatch.fill(aLiquid, false); +// if (tAmount >= aLiquid.amount) { +// return tHatch.fill(aLiquid, true) >= aLiquid.amount; +// } +// } +// } +// } + return false; + } + + public boolean depleteInput(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); + if (aLiquid != null) return depleteInput(aLiquid); + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { + tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); + return true; + } + } + } + } + for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { + tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); + return true; + } + } + } + } + } + return false; + } + + public ArrayList<ItemStack> getStoredOutputs() { + ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if (isValidMetaTileEntity(tHatch)) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1)); + } + } + for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + return rList; + } + + public ArrayList<FluidStack> getStoredFluids() { + ArrayList<FluidStack> rList = new ArrayList<FluidStack>(); + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { + rList.add(tHatch.getFillableStack()); + } + } + return rList; + } + + public ArrayList<ItemStack> getStoredInputs() { + ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(0)); + } + } + for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + return rList; + } + + public GT_Recipe_Map getRecipeMap() { + return null; + } + + public void updateSlots() { + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + } + + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + return false; + } + + public boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + return false; + } + + public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + return false; + } + + public boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + return false; + } + + public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + return false; + } + + public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + } + return false; + } + + public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } + return false; + } + + @Override + public String[] getInfoData() { + return new String[]{"Progress:", (mProgresstime / 20) + "secs", (mMaxProgresstime / 20) + "secs", "Efficiency:", (mEfficiency / 100.0F) + "%", "Problems:", "" + (getIdealStatus() - getRepairStatus())}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/core/util/debug/DEBUG_ScreenOverlay.java b/src/Java/gtPlusPlus/core/util/debug/DEBUG_ScreenOverlay.java new file mode 100644 index 0000000000..9153543eaf --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/debug/DEBUG_ScreenOverlay.java @@ -0,0 +1,45 @@ +package gtPlusPlus.core.util.debug; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.item.Item; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class DEBUG_ScreenOverlay extends Gui { + + int width, height; + Minecraft mc = Minecraft.getMinecraft(); + + @SubscribeEvent + public void eventHandler(RenderGameOverlayEvent.Text event) + { + + //if (mc.thePlayer.getHeldItem().equals(ModItems.itemStaballoyPickaxe)){ + ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); + FontRenderer fontRender = mc.fontRenderer; + this.width = res.getScaledWidth(); + this.height = res.getScaledHeight(); + Minecraft.getMinecraft().entityRenderer.setupOverlayRendering(); + String str = "Words"; + Item heldItem = null; + + try{heldItem = mc.thePlayer.getHeldItem().getItem(); + + if (heldItem != null){ + /*if (heldItem instanceof StaballoyPickaxe){ + + int dmg =((StaballoyPickaxe) heldItem).getDamage(((StaballoyPickaxe) heldItem).thisPickaxe); + + ((StaballoyPickaxe) heldItem).checkFacing(((StaballoyPickaxe) heldItem).localWorld); + str = "DAMAGE: "+ dmg +" | FACING: "+((StaballoyPickaxe) heldItem).FACING+" | FACING_HORIZONTAL: "+((StaballoyPickaxe) heldItem).FACING_HORIZONTAL+" | LOOKING DIRECTION: "+((StaballoyPickaxe) heldItem).lookingDirection; + + drawString(fontRender, str, (this.width - fontRender.getStringWidth(str)) / 2, this.height / 10, 0xFFAA00); + }*/ + } + }catch(NullPointerException e){} + + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java b/src/Java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java new file mode 100644 index 0000000000..1eb69eb11b --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java @@ -0,0 +1,64 @@ +package gtPlusPlus.core.util.debug; + +import gtPlusPlus.core.util.Utils; + +import java.util.concurrent.TimeUnit; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class DEBUG_TimerThread implements Runnable { + + private World world; + private EntityPlayer player; + + + public DEBUG_TimerThread(World WORLD, EntityPlayer PLAYER) { + world = WORLD; + player = PLAYER; + } + + @Override + public void run(){ + int xDir = ForgeDirection.getOrientation(player.getPlayerCoordinates().posX).offsetX; + int zDir = ForgeDirection.getOrientation(player.getPlayerCoordinates().posZ).offsetZ; + + int stepX = Minecraft.getMinecraft().objectMouseOver.blockX; + int stepY = Minecraft.getMinecraft().objectMouseOver.blockY; + int stepZ = Minecraft.getMinecraft().objectMouseOver.blockZ; + Utils.LOG_INFO("Clicked on a Block @ "+"[X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"+" with xDir:"+xDir+" zDir:"+zDir); + world.setBlock(stepX, stepY, stepZ, Blocks.bedrock,0,3); + Utils.LOG_INFO("Makng it Bedrock for future investment."); + //for (int i = -1; i <= 1; i++) { + //stepX = stepX+i; + for (int i = stepX-1; i <= stepX+1; i++){ + for (int j = stepZ-1; j <= stepZ+1; j++){ + for (int h = stepY-1; h <= stepY+1; h++){ + + xDir = ForgeDirection.getOrientation(player.getPlayerCoordinates().posX).offsetX; + zDir = ForgeDirection.getOrientation(player.getPlayerCoordinates().posZ).offsetZ; + + //for (int j = -1; j <= 1; j++) { + //stepZ = stepZ+j; + //for (int h = -1; h <= 1; h++) { + //stepY = stepY+h; + Utils.LOG_INFO("Placing Block @ "+"[X:"+i+"][Y:"+h+"][Z:"+j+"]"+" with xDir:"+xDir+" zDir:"+zDir); + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + world.setBlock(i, h, j, Blocks.stone,0,3); + } + else { + Utils.LOG_INFO("Not even sure what this is for, but I got here."); + } + try { + TimeUnit.MILLISECONDS.sleep(500); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + } + } + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/debug/UtilityGL11Debug.java b/src/Java/gtPlusPlus/core/util/debug/UtilityGL11Debug.java new file mode 100644 index 0000000000..59c652d73b --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/debug/UtilityGL11Debug.java @@ -0,0 +1,343 @@ +package gtPlusPlus.core.util.debug; + +import java.nio.ByteBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + + +/** + * User: The Grey Ghost + * Date: 9/02/14 + */ +public class UtilityGL11Debug +{ + public class GLproperty + { + public GLproperty(int init_gLconstant, String init_name, String init_description, String init_category, String init_fetchCommand) { + gLconstant = init_gLconstant; + name = init_name; + description = init_description; + category = init_category; + fetchCommand = init_fetchCommand; + } + + public int gLconstant; + public String name; + public String description; + public String category; + public String fetchCommand; + } + + public static UtilityGL11Debug instance = new UtilityGL11Debug(); + + public GLproperty[] propertyList = + + { + new GLproperty(GL11.GL_CURRENT_COLOR, "GL_CURRENT_COLOR", "Current color", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_INDEX, "GL_CURRENT_INDEX", "Current color index", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_TEXTURE_COORDS, "GL_CURRENT_TEXTURE_COORDS", "Current texture coordinates", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_NORMAL, "GL_CURRENT_NORMAL", "Current normal", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_POSITION, "GL_CURRENT_RASTER_POSITION", "Current raster position", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_DISTANCE, "GL_CURRENT_RASTER_DISTANCE", "Current raster distance", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_COLOR, "GL_CURRENT_RASTER_COLOR", "Color associated with raster position", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_INDEX, "GL_CURRENT_RASTER_INDEX", "Color index associated with raster position", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_TEXTURE_COORDS, "GL_CURRENT_RASTER_TEXTURE_COORDS", "Texture coordinates associated with raster position", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_POSITION_VALID, "GL_CURRENT_RASTER_POSITION_VALID", "Raster position valid bit", "current", "glGetBooleanv()"), + new GLproperty(GL11.GL_EDGE_FLAG, "GL_EDGE_FLAG", "Edge flag", "current", "glGetBooleanv()"), + new GLproperty(GL11.GL_VERTEX_ARRAY, "GL_VERTEX_ARRAY", "Vertex array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_VERTEX_ARRAY_SIZE, "GL_VERTEX_ARRAY_SIZE", "Coordinates per vertex", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_VERTEX_ARRAY_TYPE, "GL_VERTEX_ARRAY_TYPE", "Type of vertex coordinates", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_VERTEX_ARRAY_STRIDE, "GL_VERTEX_ARRAY_STRIDE", "Stride between vertices", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_VERTEX_ARRAY_POINTER, "GL_VERTEX_ARRAY_POINTER", "Pointer to the vertex array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_NORMAL_ARRAY, "GL_NORMAL_ARRAY", "Normal array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_NORMAL_ARRAY_TYPE, "GL_NORMAL_ARRAY_TYPE", "Type of normal coordinates", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_NORMAL_ARRAY_STRIDE, "GL_NORMAL_ARRAY_STRIDE", "Stride between normals", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_NORMAL_ARRAY_POINTER, "GL_NORMAL_ARRAY_POINTER", "Pointer to the normal array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_COLOR_ARRAY, "GL_COLOR_ARRAY", "RGBA color array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_COLOR_ARRAY_SIZE, "GL_COLOR_ARRAY_SIZE", "Colors per vertex", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_COLOR_ARRAY_TYPE, "GL_COLOR_ARRAY_TYPE", "Type of color components", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_COLOR_ARRAY_STRIDE, "GL_COLOR_ARRAY_STRIDE", "Stride between colors", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_COLOR_ARRAY_POINTER, "GL_COLOR_ARRAY_POINTER", "Pointer to the color array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_INDEX_ARRAY, "GL_INDEX_ARRAY", "Color-index array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_INDEX_ARRAY_TYPE, "GL_INDEX_ARRAY_TYPE", "Type of color indices", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_INDEX_ARRAY_STRIDE, "GL_INDEX_ARRAY_STRIDE", "Stride between color indices", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_INDEX_ARRAY_POINTER, "GL_INDEX_ARRAY_POINTER", "Pointer to the index array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY, "GL_TEXTURE_COORD_ARRAY", "Texture coordinate array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_SIZE, "GL_TEXTURE_COORD_ARRAY_SIZE", "Texture coordinates per element", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_TYPE, "GL_TEXTURE_COORD_ARRAY_TYPE", "Type of texture coordinates", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_STRIDE, "GL_TEXTURE_COORD_ARRAY_STRIDE", "Stride between texture coordinates", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_POINTER, "GL_TEXTURE_COORD_ARRAY_POINTER", "Pointer to the texture coordinate array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_EDGE_FLAG_ARRAY, "GL_EDGE_FLAG_ARRAY", "Edge flag array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_EDGE_FLAG_ARRAY_STRIDE, "GL_EDGE_FLAG_ARRAY_STRIDE", "Stride between edge flags", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_EDGE_FLAG_ARRAY_POINTER, "GL_EDGE_FLAG_ARRAY_POINTER", "Pointer to the edge flag array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_MODELVIEW_MATRIX, "GL_MODELVIEW_MATRIX", "Modelview matrix stack", "matrix", "glGetFloatv()"), + new GLproperty(GL11.GL_PROJECTION_MATRIX, "GL_PROJECTION_MATRIX", "Projection matrix stack", "matrix", "glGetFloatv()"), + new GLproperty(GL11.GL_TEXTURE_MATRIX, "GL_TEXTURE_MATRIX", "Texture matrix stack", "matrix", "glGetFloatv()"), + new GLproperty(GL11.GL_VIEWPORT, "GL_VIEWPORT", "Viewport origin and extent", "viewport", "glGetIntegerv()"), + new GLproperty(GL11.GL_DEPTH_RANGE, "GL_DEPTH_RANGE", "Depth range near and far", "viewport", "glGetFloatv()"), + new GLproperty(GL11.GL_MODELVIEW_STACK_DEPTH, "GL_MODELVIEW_STACK_DEPTH", "Modelview matrix stack pointer", "matrix", "glGetIntegerv()"), + new GLproperty(GL11.GL_PROJECTION_STACK_DEPTH, "GL_PROJECTION_STACK_DEPTH", "Projection matrix stack pointer", "matrix", "glGetIntegerv()"), + new GLproperty(GL11.GL_TEXTURE_STACK_DEPTH, "GL_TEXTURE_STACK_DEPTH", "Texture matrix stack pointer", "matrix", "glGetIntegerv()"), + new GLproperty(GL11.GL_MATRIX_MODE, "GL_MATRIX_MODE", "Current matrix mode", "transform", "glGetIntegerv()"), + new GLproperty(GL11.GL_NORMALIZE, "GL_NORMALIZE", "Current normal normalization on/off", "transform/ enable", "glIsEnabled()"), + new GLproperty(GL11.GL_FOG_COLOR, "GL_FOG_COLOR", "Fog color", "fog", "glGetFloatv()"), + new GLproperty(GL11.GL_FOG_INDEX, "GL_FOG_INDEX", "Fog index", "fog", "glGetFloatv()"), + new GLproperty(GL11.GL_FOG_DENSITY, "GL_FOG_DENSITY", "Exponential fog density", "fog", "glGetFloatv()"), + new GLproperty(GL11.GL_FOG_START, "GL_FOG_START", "Linear fog start", "fog", "glGetFloatv()"), + new GLproperty(GL11.GL_FOG_END, "GL_FOG_END", "Linear fog end", "fog", "glGetFloatv()"), + new GLproperty(GL11.GL_FOG_MODE, "GL_FOG_MODE", "Fog mode", "fog", "glGetIntegerv()"), + new GLproperty(GL11.GL_FOG, "GL_FOG", "True if fog enabled", "fog/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_SHADE_MODEL, "GL_SHADE_MODEL", "glShadeModel() setting", "lighting", "glGetIntegerv()"), + new GLproperty(GL11.GL_LIGHTING, "GL_LIGHTING", "True if lighting is enabled", "lighting/e nable", "glIsEnabled()"), + new GLproperty(GL11.GL_COLOR_MATERIAL, "GL_COLOR_MATERIAL", "True if color tracking is enabled", "lighting", "glIsEnabled()"), + new GLproperty(GL11.GL_COLOR_MATERIAL_PARAMETER, "GL_COLOR_MATERIAL_PARAMETER", "Material properties tracking current color", "lighting", "glGetIntegerv()"), + new GLproperty(GL11.GL_COLOR_MATERIAL_FACE, "GL_COLOR_MATERIAL_FACE", "Face(s) affected by color tracking", "lighting", "glGetIntegerv()"), + new GLproperty(GL11.GL_AMBIENT, "GL_AMBIENT", "Ambient material color", "lighting", "glGetMaterialfv()"), + new GLproperty(GL11.GL_DIFFUSE, "GL_DIFFUSE", "Diffuse material color", "lighting", "glGetMaterialfv()"), + new GLproperty(GL11.GL_SPECULAR, "GL_SPECULAR", "Specular material color", "lighting", "glGetMaterialfv()"), + new GLproperty(GL11.GL_EMISSION, "GL_EMISSION", "Emissive material color", "lighting", "glGetMaterialfv()"), + new GLproperty(GL11.GL_SHININESS, "GL_SHININESS", "Specular exponent of material", "lighting", "glGetMaterialfv()"), + new GLproperty(GL11.GL_LIGHT_MODEL_AMBIENT, "GL_LIGHT_MODEL_AMBIENT", "Ambient scene color", "lighting", "glGetFloatv()"), + new GLproperty(GL11.GL_LIGHT_MODEL_LOCAL_VIEWER, "GL_LIGHT_MODEL_LOCAL_VIEWER", "Viewer is local", "lighting", "glGetBooleanv()"), + new GLproperty(GL11.GL_LIGHT_MODEL_TWO_SIDE, "GL_LIGHT_MODEL_TWO_SIDE", "Use two-sided lighting", "lighting", "glGetBooleanv()"), + new GLproperty(GL11.GL_AMBIENT, "GL_AMBIENT", "Ambient intensity of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_DIFFUSE, "GL_DIFFUSE", "Diffuse intensity of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_SPECULAR, "GL_SPECULAR", "Specular intensity of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_POSITION, "GL_POSITION", "Position of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_CONSTANT_ATTENUATION, "GL_CONSTANT_ATTENUATION", "Constant attenuation factor", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_LINEAR_ATTENUATION, "GL_LINEAR_ATTENUATION", "Linear attenuation factor", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_QUADRATIC_ATTENUATION, "GL_QUADRATIC_ATTENUATION", "Quadratic attenuation factor", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_SPOT_DIRECTION, "GL_SPOT_DIRECTION", "Spotlight direction of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_SPOT_EXPONENT, "GL_SPOT_EXPONENT", "Spotlight exponent of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_SPOT_CUTOFF, "GL_SPOT_CUTOFF", "Spotlight angle of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_LIGHT0, "GL_LIGHT0", "True if light 0 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT1, "GL_LIGHT1", "True if light 1 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT2, "GL_LIGHT2", "True if light 2 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT3, "GL_LIGHT3", "True if light 3 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT4, "GL_LIGHT4", "True if light 4 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT5, "GL_LIGHT5", "True if light 5 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT6, "GL_LIGHT6", "True if light 6 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT7, "GL_LIGHT7", "True if light 7 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_COLOR_INDEXES, "GL_COLOR_INDEXES", "ca, cd, and cs for color-index lighting", "lighting/e nable", "glGetMaterialfv()"), + new GLproperty(GL11.GL_POINT_SIZE, "GL_POINT_SIZE", "Point size", "point", "glGetFloatv()"), + new GLproperty(GL11.GL_POINT_SMOOTH, "GL_POINT_SMOOTH", "Point antialiasing on", "point/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LINE_WIDTH, "GL_LINE_WIDTH", "Line width", "line", "glGetFloatv()"), + new GLproperty(GL11.GL_LINE_SMOOTH, "GL_LINE_SMOOTH", "Line antialiasing on", "line/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LINE_STIPPLE_PATTERN, "GL_LINE_STIPPLE_PATTERN", "Line stipple", "line", "glGetIntegerv()"), + new GLproperty(GL11.GL_LINE_STIPPLE_REPEAT, "GL_LINE_STIPPLE_REPEAT", "Line stipple repeat", "line", "glGetIntegerv()"), + new GLproperty(GL11.GL_LINE_STIPPLE, "GL_LINE_STIPPLE", "Line stipple enable", "line/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_CULL_FACE, "GL_CULL_FACE", "Polygon culling enabled", "polygon/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_CULL_FACE_MODE, "GL_CULL_FACE_MODE", "Cull front-/back-facing polygons", "polygon", "glGetIntegerv()"), + new GLproperty(GL11.GL_FRONT_FACE, "GL_FRONT_FACE", "Polygon front-face CW/CCW indicator", "polygon", "glGetIntegerv()"), + new GLproperty(GL11.GL_POLYGON_SMOOTH, "GL_POLYGON_SMOOTH", "Polygon antialiasing on", "polygon/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_POLYGON_MODE, "GL_POLYGON_MODE", "Polygon rasterization mode (front and back)", "polygon", "glGetIntegerv()"), + new GLproperty(GL11.GL_POLYGON_OFFSET_FACTOR, "GL_POLYGON_OFFSET_FACTOR", "Polygon offset factor", "polygon", "glGetFloatv()"), + new GLproperty(GL11.GL_POLYGON_OFFSET_POINT, "GL_POLYGON_OFFSET_POINT", "Polygon offset enable for GL_POINT mode rasterization", "polygon/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_POLYGON_OFFSET_LINE, "GL_POLYGON_OFFSET_LINE", "Polygon offset enable for GL_LINE mode rasterization", "polygon/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_POLYGON_OFFSET_FILL, "GL_POLYGON_OFFSET_FILL", "Polygon offset enable for GL_FILL mode rasterization", "polygon/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_POLYGON_STIPPLE, "GL_POLYGON_STIPPLE", "Polygon stipple enable", "polygon/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_TEXTURE_1D, "GL_TEXTURE_1D", "True if 1-D texturing enabled ", "texture/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_TEXTURE_2D, "GL_TEXTURE_2D", "True if 2-D texturing enabled ", "texture/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_TEXTURE_BINDING_1D, "GL_TEXTURE_BINDING_1D", "Texture object bound to GL_TEXTURE_1D", "texture", "glGetIntegerv()"), + new GLproperty(GL11.GL_TEXTURE_BINDING_2D, "GL_TEXTURE_BINDING_2D", "Texture object bound to GL_TEXTURE_2D", "texture", "glGetIntegerv()"), + new GLproperty(GL11.GL_TEXTURE, "GL_TEXTURE", "x-D texture image at level of detail i", "UNUSED", "glGetTexImage()"), + new GLproperty(GL11.GL_TEXTURE_WIDTH, "GL_TEXTURE_WIDTH", "x-D texture image i's width", "UNUSED", "glGetTexLevelParameter*()"), + new GLproperty(GL11.GL_TEXTURE_HEIGHT, "GL_TEXTURE_HEIGHT", "x-D texture image i's height", "UNUSED", "glGetTexLevelParameter*()"), + new GLproperty(GL11.GL_TEXTURE_BORDER, "GL_TEXTURE_BORDER", "x-D texture image i's border width", "UNUSED", "glGetTexLevelParameter*()"), + new GLproperty(GL11.GL_TEXTURE_RED_SIZE, "GL_TEXTURE_RED_SIZE", "x-D texture image i's red resolution", "UNUSED", "glGetTexLevelParameter*()"), + new GLproperty(GL11.GL_TEXTURE_GREEN_SIZE, "GL_TEXTURE_GREEN_SIZE", "x-D texture image i's green resolution", "UNUSED", "glGetTexLevelParameter*()"), + new GLproperty(GL11.GL_TEXTURE_BLUE_SIZE, "GL_TEXTURE_BLUE_SIZE", "x-D texture image i's blue resolution", "UNUSED", "glGetTexLevelParameter*()"), + new GLproperty(GL11.GL_TEXTURE_ALPHA_SIZE, "GL_TEXTURE_ALPHA_SIZE", "x-D texture image i's alpha resolution", "UNUSED", "glGetTexLevelParameter*()"), + new GLproperty(GL11.GL_TEXTURE_LUMINANCE_SIZE, "GL_TEXTURE_LUMINANCE_SIZE", "x-D texture image i's luminance resolution", "UNUSED", "glGetTexLevelParameter*()"), + new GLproperty(GL11.GL_TEXTURE_INTENSITY_SIZE, "GL_TEXTURE_INTENSITY_SIZE", "x-D texture image i's intensity resolution", "UNUSED", "glGetTexLevelParameter*()"), + new GLproperty(GL11.GL_TEXTURE_BORDER_COLOR, "GL_TEXTURE_BORDER_COLOR", "Texture border color", "texture", "glGetTexParameter*()"), + new GLproperty(GL11.GL_TEXTURE_MIN_FILTER, "GL_TEXTURE_MIN_FILTER", "Texture minification function", "texture", "glGetTexParameter*()"), + new GLproperty(GL11.GL_TEXTURE_MAG_FILTER, "GL_TEXTURE_MAG_FILTER", "Texture magnification function", "texture", "glGetTexParameter*()"), + new GLproperty(GL11.GL_TEXTURE_WRAP_S, "GL_TEXTURE_WRAP_S", "Texture wrap mode (x is S or T)", "texture", "glGetTexParameter*()"), + new GLproperty(GL11.GL_TEXTURE_WRAP_T, "GL_TEXTURE_WRAP_T", "Texture wrap mode (x is S or T)", "texture", "glGetTexParameter*()"), + new GLproperty(GL11.GL_TEXTURE_PRIORITY, "GL_TEXTURE_PRIORITY", "Texture object priority", "texture", "glGetTexParameter*()"), + new GLproperty(GL11.GL_TEXTURE_ENV_MODE, "GL_TEXTURE_ENV_MODE", "Texture application function", "texture", "glGetTexEnviv()"), + new GLproperty(GL11.GL_TEXTURE_ENV_COLOR, "GL_TEXTURE_ENV_COLOR", "Texture environment color", "texture", "glGetTexEnvfv()"), + new GLproperty(GL11.GL_TEXTURE_GEN_S, "GL_TEXTURE_GEN_S", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_TEXTURE_GEN_T, "GL_TEXTURE_GEN_T", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_TEXTURE_GEN_R, "GL_TEXTURE_GEN_R", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_TEXTURE_GEN_Q, "GL_TEXTURE_GEN_Q", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_EYE_PLANE, "GL_EYE_PLANE", "Texgen plane equation coefficients", "texture", "glGetTexGenfv()"), + new GLproperty(GL11.GL_OBJECT_PLANE, "GL_OBJECT_PLANE", "Texgen object linear coefficients", "texture", "glGetTexGenfv()"), + new GLproperty(GL11.GL_TEXTURE_GEN_MODE, "GL_TEXTURE_GEN_MODE", "Function used for texgen", "texture", "glGetTexGeniv()"), + new GLproperty(GL11.GL_SCISSOR_TEST, "GL_SCISSOR_TEST", "Scissoring enabled", "scissor/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_SCISSOR_BOX, "GL_SCISSOR_BOX", "Scissor box", "scissor", "glGetIntegerv()"), + new GLproperty(GL11.GL_ALPHA_TEST, "GL_ALPHA_TEST", "Alpha test enabled", "color-buffer/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_ALPHA_TEST_FUNC, "GL_ALPHA_TEST_FUNC", "Alpha test function", "color-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_ALPHA_TEST_REF, "GL_ALPHA_TEST_REF", "Alpha test reference value", "color-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_STENCIL_TEST, "GL_STENCIL_TEST", "Stenciling enabled", "stencil-buffer/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_STENCIL_FUNC, "GL_STENCIL_FUNC", "Stencil function", "stencil-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_STENCIL_VALUE_MASK, "GL_STENCIL_VALUE_MASK", "Stencil mask", "stencil-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_STENCIL_REF, "GL_STENCIL_REF", "Stencil reference value", "stencil-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_STENCIL_FAIL, "GL_STENCIL_FAIL", "Stencil fail action", "stencil-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_STENCIL_PASS_DEPTH_FAIL, "GL_STENCIL_PASS_DEPTH_FAIL", "Stencil depth buffer fail action", "stencil-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_STENCIL_PASS_DEPTH_PASS, "GL_STENCIL_PASS_DEPTH_PASS", "Stencil depth buffer pass action", "stencil-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_DEPTH_TEST, "GL_DEPTH_TEST", "Depth buffer enabled", "depth-buffer/ena ble", "glIsEnabled()"), + new GLproperty(GL11.GL_DEPTH_FUNC, "GL_DEPTH_FUNC", "Depth buffer test function", "depth-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_BLEND, "GL_BLEND", "Blending enabled", "color-buffer/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_BLEND_SRC, "GL_BLEND_SRC", "Blending source function", "color-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_BLEND_DST, "GL_BLEND_DST", "Blending destination function", "color-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_DITHER, "GL_DITHER", "Dithering enabled", "color-buffer/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_INDEX_LOGIC_OP, "GL_INDEX_LOGIC_OP", "Color index logical operation enabled", "color-buffer/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_COLOR_LOGIC_OP, "GL_COLOR_LOGIC_OP", "RGBA color logical operation enabled", "color-buffer/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LOGIC_OP_MODE, "GL_LOGIC_OP_MODE", "Logical operation function", "color-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_DRAW_BUFFER, "GL_DRAW_BUFFER", "Buffers selected for drawing", "color-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_INDEX_WRITEMASK, "GL_INDEX_WRITEMASK", "Color-index writemask", "color-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_COLOR_WRITEMASK, "GL_COLOR_WRITEMASK", "Color write enables; R, G, B, or A", "color-buffer", "glGetBooleanv()"), + new GLproperty(GL11.GL_DEPTH_WRITEMASK, "GL_DEPTH_WRITEMASK", "Depth buffer enabled for writing", "depth-buffer", "glGetBooleanv()"), + new GLproperty(GL11.GL_STENCIL_WRITEMASK, "GL_STENCIL_WRITEMASK", "Stencil-buffer writemask", "stencil-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_COLOR_CLEAR_VALUE, "GL_COLOR_CLEAR_VALUE", "Color-buffer clear value (RGBA mode)", "color-buffer", "glGetFloatv()"), + new GLproperty(GL11.GL_INDEX_CLEAR_VALUE, "GL_INDEX_CLEAR_VALUE", "Color-buffer clear value (color-index mode)", "color-buffer", "glGetFloatv()"), + new GLproperty(GL11.GL_DEPTH_CLEAR_VALUE, "GL_DEPTH_CLEAR_VALUE", "Depth-buffer clear value", "depth-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_STENCIL_CLEAR_VALUE, "GL_STENCIL_CLEAR_VALUE", "Stencil-buffer clear value", "stencil-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_ACCUM_CLEAR_VALUE, "GL_ACCUM_CLEAR_VALUE", "Accumulation-buffer clear value", "accum-buffer", "glGetFloatv()"), + new GLproperty(GL11.GL_UNPACK_SWAP_BYTES, "GL_UNPACK_SWAP_BYTES", "Value of GL_UNPACK_SWAP_BYTES", "pixel-store", "glGetBooleanv()"), + new GLproperty(GL11.GL_UNPACK_LSB_FIRST, "GL_UNPACK_LSB_FIRST", "Value of GL_UNPACK_LSB_FIRST", "pixel-store", "glGetBooleanv()"), + new GLproperty(GL11.GL_UNPACK_ROW_LENGTH, "GL_UNPACK_ROW_LENGTH", "Value of GL_UNPACK_ROW_LENGTH", "pixel-store", "glGetIntegerv()"), + new GLproperty(GL11.GL_UNPACK_SKIP_ROWS, "GL_UNPACK_SKIP_ROWS", "Value of GL_UNPACK_SKIP_ROWS", "pixel-store", "glGetIntegerv()"), + new GLproperty(GL11.GL_UNPACK_SKIP_PIXELS, "GL_UNPACK_SKIP_PIXELS", "Value of GL_UNPACK_SKIP_PIXELS", "pixel-store", "glGetIntegerv()"), + new GLproperty(GL11.GL_UNPACK_ALIGNMENT, "GL_UNPACK_ALIGNMENT", "Value of GL_UNPACK_ALIGNMENT", "pixel-store", "glGetIntegerv()"), + new GLproperty(GL11.GL_PACK_SWAP_BYTES, "GL_PACK_SWAP_BYTES", "Value of GL_PACK_SWAP_BYTES", "pixel-store", "glGetBooleanv()"), + new GLproperty(GL11.GL_PACK_LSB_FIRST, "GL_PACK_LSB_FIRST", "Value of GL_PACK_LSB_FIRST", "pixel-store", "glGetBooleanv()"), + new GLproperty(GL11.GL_PACK_ROW_LENGTH, "GL_PACK_ROW_LENGTH", "Value of GL_PACK_ROW_LENGTH", "pixel-store", "glGetIntegerv()"), + new GLproperty(GL11.GL_PACK_SKIP_ROWS, "GL_PACK_SKIP_ROWS", "Value of GL_PACK_SKIP_ROWS", "pixel-store", "glGetIntegerv()"), + new GLproperty(GL11.GL_PACK_SKIP_PIXELS, "GL_PACK_SKIP_PIXELS", "Value of GL_PACK_SKIP_PIXELS", "pixel-store", "glGetIntegerv()"), + new GLproperty(GL11.GL_PACK_ALIGNMENT, "GL_PACK_ALIGNMENT", "Value of GL_PACK_ALIGNMENT", "pixel-store", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAP_COLOR, "GL_MAP_COLOR", "True if colors are mapped", "pixel", "glGetBooleanv()"), + new GLproperty(GL11.GL_MAP_STENCIL, "GL_MAP_STENCIL", "True if stencil values are mapped", "pixel", "glGetBooleanv()"), + new GLproperty(GL11.GL_INDEX_SHIFT, "GL_INDEX_SHIFT", "Value of GL_INDEX_SHIFT", "pixel", "glGetIntegerv()"), + new GLproperty(GL11.GL_INDEX_OFFSET, "GL_INDEX_OFFSET", "Value of GL_INDEX_OFFSET", "pixel", "glGetIntegerv()"), + new GLproperty(GL11.GL_ZOOM_X, "GL_ZOOM_X", "x zoom factor", "pixel", "glGetFloatv()"), + new GLproperty(GL11.GL_ZOOM_Y, "GL_ZOOM_Y", "y zoom factor", "pixel", "glGetFloatv()"), + new GLproperty(GL11.GL_READ_BUFFER, "GL_READ_BUFFER", "Read source buffer", "pixel", "glGetIntegerv()"), + new GLproperty(GL11.GL_ORDER, "GL_ORDER", "1D map order", "capability", "glGetMapiv()"), + new GLproperty(GL11.GL_ORDER, "GL_ORDER", "2D map orders", "capability", "glGetMapiv()"), + new GLproperty(GL11.GL_COEFF, "GL_COEFF", "1D control points", "capability", "glGetMapfv()"), + new GLproperty(GL11.GL_COEFF, "GL_COEFF", "2D control points", "capability", "glGetMapfv()"), + new GLproperty(GL11.GL_DOMAIN, "GL_DOMAIN", "1D domain endpoints", "capability", "glGetMapfv()"), + new GLproperty(GL11.GL_DOMAIN, "GL_DOMAIN", "2D domain endpoints", "capability", "glGetMapfv()"), + new GLproperty(GL11.GL_MAP1_GRID_DOMAIN, "GL_MAP1_GRID_DOMAIN", "1D grid endpoints", "eval", "glGetFloatv()"), + new GLproperty(GL11.GL_MAP2_GRID_DOMAIN, "GL_MAP2_GRID_DOMAIN", "2D grid endpoints", "eval", "glGetFloatv()"), + new GLproperty(GL11.GL_MAP1_GRID_SEGMENTS, "GL_MAP1_GRID_SEGMENTS", "1D grid divisions", "eval", "glGetFloatv()"), + new GLproperty(GL11.GL_MAP2_GRID_SEGMENTS, "GL_MAP2_GRID_SEGMENTS", "2D grid divisions", "eval", "glGetFloatv()"), + new GLproperty(GL11.GL_AUTO_NORMAL, "GL_AUTO_NORMAL", "True if automatic normal generation enabled", "eval", "glIsEnabled()"), + new GLproperty(GL11.GL_PERSPECTIVE_CORRECTION_HINT, "GL_PERSPECTIVE_CORRECTION_HINT", "Perspective correction hint", "hint", "glGetIntegerv()"), + new GLproperty(GL11.GL_POINT_SMOOTH_HINT, "GL_POINT_SMOOTH_HINT", "Point smooth hint", "hint", "glGetIntegerv()"), + new GLproperty(GL11.GL_LINE_SMOOTH_HINT, "GL_LINE_SMOOTH_HINT", "Line smooth hint", "hint", "glGetIntegerv()"), + new GLproperty(GL11.GL_POLYGON_SMOOTH_HINT, "GL_POLYGON_SMOOTH_HINT", "Polygon smooth hint", "hint", "glGetIntegerv()"), + new GLproperty(GL11.GL_FOG_HINT, "GL_FOG_HINT", "Fog hint", "hint", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_LIGHTS, "GL_MAX_LIGHTS", "Maximum number of lights", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_CLIP_PLANES, "GL_MAX_CLIP_PLANES", "Maximum number of user clipping planes", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_MODELVIEW_STACK_DEPTH, "GL_MAX_MODELVIEW_STACK_DEPTH", "Maximum modelview-matrix stack depth", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH", "Maximum projection-matrix stack depth", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_TEXTURE_STACK_DEPTH, "GL_MAX_TEXTURE_STACK_DEPTH", "Maximum depth of texture matrix stack", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_SUBPIXEL_BITS, "GL_SUBPIXEL_BITS", "Number of bits of subpixel precision in x and y", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_TEXTURE_SIZE, "GL_MAX_TEXTURE_SIZE", "See discussion in Texture Proxy in Chapter 9", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_PIXEL_MAP_TABLE, "GL_MAX_PIXEL_MAP_TABLE", "Maximum size of a glPixelMap() translation table", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_NAME_STACK_DEPTH, "GL_MAX_NAME_STACK_DEPTH", "Maximum selection-name stack depth", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_LIST_NESTING, "GL_MAX_LIST_NESTING", "Maximum display-list call nesting", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_EVAL_ORDER, "GL_MAX_EVAL_ORDER", "Maximum evaluator polynomial order", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_VIEWPORT_DIMS, "GL_MAX_VIEWPORT_DIMS", "Maximum viewport dimensions", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_ATTRIB_STACK_DEPTH, "GL_MAX_ATTRIB_STACK_DEPTH", "Maximum depth of the attribute stack", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", "Maximum depth of the client attribute stack", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_AUX_BUFFERS, "GL_AUX_BUFFERS", "Number of auxiliary buffers", "capability", "glGetBooleanv()"), + new GLproperty(GL11.GL_RGBA_MODE, "GL_RGBA_MODE", "True if color buffers store RGBA", "capability", "glGetBooleanv()"), + new GLproperty(GL11.GL_INDEX_MODE, "GL_INDEX_MODE", "True if color buffers store indices", "capability", "glGetBooleanv()"), + new GLproperty(GL11.GL_DOUBLEBUFFER, "GL_DOUBLEBUFFER", "True if front and back buffers exist", "capability", "glGetBooleanv()"), + new GLproperty(GL11.GL_STEREO, "GL_STEREO", "True if left and right buffers exist", "capability", "glGetBooleanv()"), + new GLproperty(GL11.GL_POINT_SIZE_RANGE, "GL_POINT_SIZE_RANGE", "Range (low to high) of antialiased point sizes", "capability", "glGetFloatv()"), + new GLproperty(GL11.GL_POINT_SIZE_GRANULARITY, "GL_POINT_SIZE_GRANULARITY", "Antialiased point-size granularity", "capability", "glGetFloatv()"), + new GLproperty(GL11.GL_LINE_WIDTH_RANGE, "GL_LINE_WIDTH_RANGE", "Range (low to high) of antialiased line widths", "capability", "glGetFloatv()"), + new GLproperty(GL11.GL_LINE_WIDTH_GRANULARITY, "GL_LINE_WIDTH_GRANULARITY", "Antialiased line-width granularity", "capability", "glGetFloatv()"), + new GLproperty(GL11.GL_RED_BITS, "GL_RED_BITS", "Number of bits per red component in color buffers", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_GREEN_BITS, "GL_GREEN_BITS", "Number of bits per green component in color buffers", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_BLUE_BITS, "GL_BLUE_BITS", "Number of bits per blue component in color buffers", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_ALPHA_BITS, "GL_ALPHA_BITS", "Number of bits per alpha component in color buffers", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_INDEX_BITS, "GL_INDEX_BITS", "Number of bits per index in color buffers", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_DEPTH_BITS, "GL_DEPTH_BITS", "Number of depth-buffer bitplanes", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_STENCIL_BITS, "GL_STENCIL_BITS", "Number of stencil bitplanes", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_ACCUM_RED_BITS, "GL_ACCUM_RED_BITS", "Number of bits per red component in the accumulation buffer", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_ACCUM_GREEN_BITS, "GL_ACCUM_GREEN_BITS", "Number of bits per green component in the accumulation buffer", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_ACCUM_BLUE_BITS, "GL_ACCUM_BLUE_BITS", "Number of bits per blue component in the accumulation buffer", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_ACCUM_ALPHA_BITS, "GL_ACCUM_ALPHA_BITS", "Number of bits per alpha component in the accumulation buffer", "capability", "glGetIntegerv()"), + new GLproperty(GL11.GL_LIST_BASE, "GL_LIST_BASE", "Setting of glListBase()", "list", "glGetIntegerv()"), + new GLproperty(GL11.GL_LIST_INDEX, "GL_LIST_INDEX", "Number of display list under construction; 0 if none", "current", "glGetIntegerv()"), + new GLproperty(GL11.GL_LIST_MODE, "GL_LIST_MODE", "Mode of display list under construction; undefined if none", "current", "glGetIntegerv()"), + new GLproperty(GL11.GL_ATTRIB_STACK_DEPTH, "GL_ATTRIB_STACK_DEPTH", "Attribute stack pointer", "current", "glGetIntegerv()"), + new GLproperty(GL11.GL_CLIENT_ATTRIB_STACK_DEPTH, "GL_CLIENT_ATTRIB_STACK_DEPTH", "Client attribute stack pointer", "current", "glGetIntegerv()"), + new GLproperty(GL11.GL_NAME_STACK_DEPTH, "GL_NAME_STACK_DEPTH", "Name stack depth", "current", "glGetIntegerv()"), + new GLproperty(GL11.GL_RENDER_MODE, "GL_RENDER_MODE", "glRenderMode() setting", "current", "glGetIntegerv()"), + new GLproperty(GL11.GL_SELECTION_BUFFER_POINTER, "GL_SELECTION_BUFFER_POINTER", "Pointer to selection buffer", "select", "glGetPointerv()"), + new GLproperty(GL11.GL_SELECTION_BUFFER_SIZE, "GL_SELECTION_BUFFER_SIZE", "Size of selection buffer", "select", "glGetIntegerv()"), + new GLproperty(GL11.GL_FEEDBACK_BUFFER_POINTER, "GL_FEEDBACK_BUFFER_POINTER", "Pointer to feedback buffer", "feedback", "glGetPointerv()"), + new GLproperty(GL11.GL_FEEDBACK_BUFFER_SIZE, "GL_FEEDBACK_BUFFER_SIZE", "Size of feedback buffer", "feedback", "glGetIntegerv()"), + new GLproperty(GL11.GL_FEEDBACK_BUFFER_TYPE, "GL_FEEDBACK_BUFFER_TYPE", "Type of feedback buffer", "feedback", "glGetIntegerv()"), + }; + + public static void dumpOpenGLstate() + { + } + + public static void dumpAllIsEnabled() //Call This + { + for (int i = 0; i < instance.propertyList.length; ++i) + + { + if (instance.propertyList[i].fetchCommand == "glIsEnabled()") + + { + System.out.print(instance.propertyList[i].name + ":"); + System.out.print(GL11.glIsEnabled(instance.propertyList[i].gLconstant)); + System.out.println(" (" + instance.propertyList[i].description + ")"); + } + } + } + + public static void dumpAllType(String type) + + { + for (int i = 0; i < instance.propertyList.length; ++i) + + { + if (instance.propertyList[i].category.equals(type)) + + { + System.out.print(instance.propertyList[i].name + ":"); + System.out.println(getPropertyAsString(i)); + System.out.println(" (" + instance.propertyList[i].description + ")"); + } + } + } + + private static String getPropertyAsString(int propertyListIndex) + { + int gLconstant = instance.propertyList[propertyListIndex].gLconstant; + if (instance.propertyList[propertyListIndex].fetchCommand.equals("glIsEnabled()")) { + return "" + GL11.glIsEnabled(gLconstant); + } + + if (instance.propertyList[propertyListIndex].fetchCommand == "glGetBooleanv()") + + { + ByteBuffer params = BufferUtils.createByteBuffer(16); + + GL11.glGetBoolean(gLconstant, params); + String out = ""; + for (int i = 0; i < params.capacity(); ++i) + + { + out += (i == 0 ? "" : ", ") + params.get(i); + } + return out; + } + + return ""; + } +} + diff --git a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java new file mode 100644 index 0000000000..53873c6e4e --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java @@ -0,0 +1,44 @@ +package gtPlusPlus.core.util.fluid; + +import gtPlusPlus.core.util.Utils; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class FluidUtils { + + public static FluidStack getFluidStack(String fluidName, int amount){ + Utils.LOG_WARNING("Trying to get a fluid stack of "+fluidName); + try { + return FluidRegistry.getFluidStack(fluidName, amount).copy(); + } + catch (Throwable e){ + return null; + } + + } + + public static FluidStack[] getFluidStackArray(String fluidName, int amount){ + Utils.LOG_WARNING("Trying to get a fluid stack of "+fluidName); + try { + FluidStack[] singleFluid = {FluidRegistry.getFluidStack(fluidName, amount)}; + return singleFluid; + } + catch (Throwable e){ + return null; + } + + } + + public static FluidStack[] getFluidStackArray(FluidStack fluidName, int amount){ + Utils.LOG_WARNING("Trying to get a fluid stack of "+fluidName); + try { + FluidStack[] singleFluid = {FluidRegistry.getFluidStack(fluidName.getLocalizedName(), amount)}; + return singleFluid; + } + catch (Throwable e){ + return null; + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java b/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java new file mode 100644 index 0000000000..d1857ffefc --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java @@ -0,0 +1,87 @@ +package gtPlusPlus.core.util.gregtech.recipehandlers; + +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; + +import java.lang.reflect.Method; + +import net.minecraft.item.ItemStack; + +public final class GregtechRecipe { + + public LibraryProxy ourProxy; + public GregtechRecipe(){ + Utils.LOG_INFO("Initializing a recipe handler for different versions of Gregtech 5."); + try { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + this.ourProxy = new LibProxy1(); + Utils.LOG_INFO("Selecting GT 5.7/5.8 Recipe Set"); + } + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + this.ourProxy = new LibProxy2(); + Utils.LOG_INFO("Selecting GT 5.9 Recipe Set"); + } + } catch (NoSuchMethodException e) { + this.ourProxy = null; + } + } + + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput) { + Utils.LOG_INFO("Adding a GT Furnace/Alloy Smelter Recipe"); + return ourProxy.addSmeltingAndAlloySmeltingRecipe(aInput, aOutput); + } + +} + +abstract class LibraryProxy { // can also be interface unless you want to have common code here + abstract public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput); +} + +class LibProxy1 extends LibraryProxy { + final Method m1; + + public LibProxy1() throws NoSuchMethodException { + m1 = GT_ModHandler.class.getDeclaredMethod("addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class); + } + + @Override + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput) { + try { + Utils.LOG_INFO("Trying with Gt 5.7/5.8 Method."); + return (boolean) m1.invoke(null, aInput, aOutput); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} + +class LibProxy2 extends LibraryProxy { + final Method m2; + + public LibProxy2() throws NoSuchMethodException { + m2 = GT_ModHandler.class.getDeclaredMethod("addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class, boolean.class); + } + + @Override + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput) { + try { + Utils.LOG_INFO("Trying with Gt 5.9 Method."); + return (boolean) m2.invoke(null, aInput, aOutput, true); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} + +/*class Lib { // v1 + public static void addRecipe(ItemStack aInput, ItemStack aOutput) { + System.out.println("shit totally happened v1"); + } +} + +class Lib2 { // v2 + public static void addRecipe(ItemStack aInput, ItemStack aOutput, boolean hidden) { + System.out.println("shit totally happened v2"); + } +}*/
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java new file mode 100644 index 0000000000..623fc1707c --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java @@ -0,0 +1,361 @@ +package gtPlusPlus.core.util.item; + +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.block.base.BlockBaseModular; +import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.base.BasicSpawnEgg; +import gtPlusPlus.core.item.base.bolts.BaseItemBolt; +import gtPlusPlus.core.item.base.dusts.BaseItemDust; +import gtPlusPlus.core.item.base.gears.BaseItemGear; +import gtPlusPlus.core.item.base.ingots.BaseItemIngot; +import gtPlusPlus.core.item.base.ingots.BaseItemIngotHot; +import gtPlusPlus.core.item.base.plates.BaseItemPlate; +import gtPlusPlus.core.item.base.rings.BaseItemRing; +import gtPlusPlus.core.item.base.rods.BaseItemRod; +import gtPlusPlus.core.item.base.rods.BaseItemRodLong; +import gtPlusPlus.core.item.base.rotors.BaseItemRotor; +import gtPlusPlus.core.item.base.screws.BaseItemScrew; +import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.lib.MaterialInfo; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.wrapper.var; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.item.Item; +import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.registry.GameRegistry; + +public class UtilsItems { + + public static ItemStack getItemStackOfItem(Boolean modToCheck, String mod_itemname_meta){ + if (modToCheck){ + try{ + Item em = null; + + Item em1 = getItem(mod_itemname_meta); + Utils.LOG_WARNING("Found: "+em1.toString()); + if (em1 != null){ + em = em1; + } + if (em != null ){ + ItemStack returnStack = new ItemStack(em,1); + return returnStack; + } + Utils.LOG_WARNING(mod_itemname_meta+" not found."); + return null; + } catch (NullPointerException e) { + Utils.LOG_ERROR(mod_itemname_meta+" not found. [NULL]"); + return null; + } + } + return null; + } + + public static ItemStack getSimpleStack(Item x){ + return getSimpleStack(x, 1); + } + + public static ItemStack getSimpleStack(Item x, int i){ + try { + ItemStack r = new ItemStack(x, i); + return r; + } catch(Throwable e){ + return null; + } + } + + public static ItemStack getSimpleStack(ItemStack x, int i){ + try { + ItemStack r = x.copy(); + r.stackSize = i; + return r; + } catch(Throwable e){ + return null; + } + } + + + public static void getItemForOreDict(String FQRN, String oreDictName, String itemName, int meta){ + try { + Item em = null; + Item em1 = getItem(FQRN); + Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null){ + em = em1; + } + if (em != null){ + + ItemStack metaStack = new ItemStack(em,1,meta); + GT_OreDictUnificator.registerOre(oreDictName, metaStack); + + /*ItemStack itemStackWithMeta = new ItemStack(em,1,meta); + GT_OreDictUnificator.registerOre(oreDictName, new ItemStack(itemStackWithMeta.getItem()));*/ + } + } catch (NullPointerException e) { + Utils.LOG_ERROR(itemName+" not found. [NULL]"); + } + } + + public static void addItemToOreDictionary(ItemStack stack, String oreDictName){ + try { + GT_OreDictUnificator.registerOre(oreDictName, stack); + } catch (NullPointerException e) { + Utils.LOG_ERROR(stack.getDisplayName()+" not registered. [NULL]"); + } + } + + @SuppressWarnings("unused") + public static ItemStack getItemStackWithMeta(boolean MOD, String FQRN, String itemName, int meta, int itemstackSize){ + if (MOD){ + try { + Item em = null; + Item em1 = getItem(FQRN); + Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null){ + if (null == em){ + em = em1; + } + if (em != null){ + ItemStack metaStack = new ItemStack(em,itemstackSize,meta); + return metaStack; + } + } + return null; + } catch (NullPointerException e) { + Utils.LOG_ERROR(itemName+" not found. [NULL]"); + return null; + } + } + return null; + } + + @SuppressWarnings("unused") + public static ItemStack simpleMetaStack(String FQRN, int meta, int itemstackSize){ + try { + Item em = null; + Item em1 = getItem(FQRN); + Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null){ + if (null == em){ + em = em1; + } + if (em != null){ + ItemStack metaStack = new ItemStack(em,itemstackSize,meta); + return metaStack; + } + } + return null; + } catch (NullPointerException e) { + Utils.LOG_ERROR(FQRN+" not found. [NULL]"); + return null; + } + } + + @SuppressWarnings("unused") + public static ItemStack simpleMetaStack(Item item, int meta, int itemstackSize){ + try { + Item em = item; + Item em1 = item; + Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null){ + if (null == em){ + em = em1; + } + if (em != null){ + ItemStack metaStack = new ItemStack(em,itemstackSize,meta); + return metaStack; + } + } + return null; + } catch (NullPointerException e) { + Utils.LOG_ERROR(item.getUnlocalizedName()+" not found. [NULL]"); + return null; + } + } + + public static ItemStack getCorrectStacktype(String fqrn, int stackSize){ + String oreDict = "ore:"; + ItemStack temp; + if (fqrn.toLowerCase().contains(oreDict.toLowerCase())){ + String sanitizedName = fqrn.replace(oreDict, ""); + temp = UtilsItems.getItemStack(sanitizedName, stackSize); + return temp; + } + String[] fqrnSplit = fqrn.split(":"); + if(fqrnSplit[2] == null){fqrnSplit[2] = "0";} + temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(fqrnSplit[2]), stackSize); + return temp; + } + + public static ItemStack getCorrectStacktype(Object item_Input, int stackSize) { + if (item_Input instanceof String){ + return getCorrectStacktype(item_Input, stackSize); + } + else if (item_Input instanceof ItemStack){ + return (ItemStack) item_Input; + } + if (item_Input instanceof var){ + return ((var) item_Input).getStack(stackSize); + } + return null; + } + + public static Item getItem(String fqrn) // fqrn = fully qualified resource name + { + String[] fqrnSplit = fqrn.split(":"); + return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); + } + + public static ItemStack getItemStack(String fqrn, int Size) // fqrn = fully qualified resource name + { + String[] fqrnSplit = fqrn.split(":"); + return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + } + + // TODO + /*public static FluidStack getFluidStack(Materials m, int Size) // fqrn = fully qualified resource name + { + String[] fqrnSplit = fqrn.split(":"); + + FluidStack x = (FluidStack) "Materials."+m+".getFluid"(Size); + + return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + }*/ + + public static Item getItemInPlayersHand(){ + Minecraft mc = Minecraft.getMinecraft(); + Item heldItem = null; + + try{heldItem = mc.thePlayer.getHeldItem().getItem(); + }catch(NullPointerException e){return null;} + + if (heldItem != null){ + return heldItem; + } + + return null; + } + + public static void generateSpawnEgg(String entityModID, String parSpawnName, int colourEgg, int colourOverlay){ + Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay).setUnlocalizedName("spawn_egg_"+parSpawnName.toLowerCase()).setTextureName(CORE.MODID+":spawn_egg"); + GameRegistry.registerItem(itemSpawnEgg, "spawnEgg"+parSpawnName); + } + + public static ItemStack getItemStackOfAmountFromOreDict(String oredictName, int amount){ + ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); + if (!oreDictList.isEmpty()){ + ItemStack returnValue = oreDictList.get(0).copy(); + returnValue.stackSize = amount; + return returnValue; + } + return getSimpleStack(ModItems.AAA_Broken, amount); + } + + public static void generateItemsFromMaterial(String unlocalizedName, String materialName, int materialTier, MaterialInfo matInfo, int Colour, boolean hotIngot){ + if (materialTier > 10 || materialTier <= 0){ + materialTier = 2; + } + int sRadiation = 0; + + if (materialName.toLowerCase().contains("uranium")){ + sRadiation = 2; + } + else if (materialName.toLowerCase().contains("plutonium")){ + sRadiation = 4; + } + else if (materialName.toLowerCase().contains("thorium")){ + sRadiation = 1; + } + if (sRadiation >= 1){ + Item temp; + Block tempBlock; + tempBlock = new BlockBaseModular(unlocalizedName, materialName,BlockTypes.STANDARD, Colour); + temp = new BaseItemIngot("itemIngot"+unlocalizedName, materialName, Colour, sRadiation); + + temp = new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", hotIngot, materialTier, sRadiation); + temp = new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", hotIngot, materialTier, sRadiation); + temp = new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", hotIngot, materialTier, sRadiation); + + temp = new BaseItemPlate("itemPlate"+unlocalizedName, materialName, Colour, materialTier, sRadiation); + temp = new BaseItemRod("itemRod"+unlocalizedName, materialName, Colour, materialTier, sRadiation); + temp = new BaseItemRodLong("itemRodLong"+unlocalizedName, materialName, Colour, materialTier, sRadiation); + } + + else { + Item temp; + Block tempBlock; + tempBlock = new BlockBaseModular(unlocalizedName, materialName,BlockTypes.STANDARD, Colour); + tempBlock = new BlockBaseModular(unlocalizedName, materialName,BlockTypes.FRAME, Colour); + temp = new BaseItemIngot("itemIngot"+unlocalizedName, materialName, Colour, sRadiation); + if (hotIngot){ + Item tempIngot = temp; + temp = new BaseItemIngotHot("itemHotIngot"+unlocalizedName, materialName, UtilsItems.getSimpleStack(tempIngot, 1), materialTier); + } + temp = new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", hotIngot, materialTier, sRadiation); + temp = new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", hotIngot, materialTier, sRadiation); + temp = new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", hotIngot, materialTier, sRadiation); + + temp = new BaseItemPlate("itemPlate"+unlocalizedName, materialName, Colour, materialTier, sRadiation); + temp = new BaseItemRod("itemRod"+unlocalizedName, materialName, Colour, materialTier, sRadiation); + temp = new BaseItemRodLong("itemRodLong"+unlocalizedName, materialName, Colour, materialTier, sRadiation); + temp = new BaseItemRing("itemRing"+unlocalizedName, materialName, Colour, materialTier); + temp = new BaseItemBolt("itemBolt"+unlocalizedName, materialName, Colour, materialTier); + temp = new BaseItemScrew("itemScrew"+unlocalizedName, materialName, Colour, materialTier); + temp = new BaseItemRotor("itemRotor"+unlocalizedName, materialName, Colour); + temp = new BaseItemGear("itemGear"+unlocalizedName, materialName, Colour, materialTier); + } + + } + + public static MultiPickaxeBase generateMultiPick(Materials material){ + ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); + short[] rgb; + rgb = material.getRGBA(); + int dur = customMaterial.getMaxUses(); + + if (dur <= 0){ + dur = material.mDurability; + } + + MultiPickaxeBase MP_Redstone = new MultiPickaxeBase( + material.name()+" Multipick", + (customMaterial), + dur, + Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) + ); + + return MP_Redstone; + + } + + public static String getArrayStackNames(ItemStack[] aStack){ + String itemNames = "Item Array: "; + for (ItemStack alph : aStack){ + String temp = itemNames; + itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize; + } + return itemNames; + + } + + public static String getFluidArrayStackNames(FluidStack[] aStack){ + String itemNames = "Fluid Array: "; + for (FluidStack alph : aStack){ + String temp = itemNames; + itemNames = temp + ", " + alph.getFluid().getName() + " x" + alph.amount; + } + return itemNames; + + } + +} diff --git a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java new file mode 100644 index 0000000000..69548eb49a --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java @@ -0,0 +1,87 @@ +package gtPlusPlus.core.util.materials; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gregtech.api.enums.TextureSet; +import gregtech.api.objects.MaterialStack; +import gtPlusPlus.core.lib.MaterialInfo; +import gtPlusPlus.core.util.Utils; + +import java.util.List; + +import net.minecraftforge.common.util.EnumHelper; + +public class MaterialUtils { + + public static short firstID = 791; + + private static Class[][] commonTypes = + {{Materials.class, int.class, TextureSet.class, float.class, int.class, + int.class, int.class, int.class, int.class, int.class, int.class, + String.class, int.class, int.class, int.class, int.class, boolean.class, + boolean.class, int.class, int.class, int.class, Dyes.class, int.class, + List.class , List.class}}; + + public static Materials addGtMaterial(String enumNameForMaterial, TextureSet aIconSet, float aToolSpeed, int aToolDurability, int aToolQuality, int aTypes, int aR, int aG, int aB, int aA, String aLocalName, int aFuelType, int aFuelPower, int aMeltingPoint, int aBlastFurnaceTemp, boolean aBlastFurnaceRequired, boolean aTransparent, int aOreValue, int aDensityMultiplier, int aDensityDivider, Dyes aColor, int aExtraData, List<MaterialStack> aMaterialList, List<TC_AspectStack> aAspects) + { + Utils.LOG_INFO("Attempting to add GT material: "+enumNameForMaterial); + return EnumHelper.addEnum(Materials.class, enumNameForMaterial, commonTypes, firstID++, aIconSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, aR, aG, aB, aA, aLocalName, + aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, + aColor, aExtraData, aMaterialList, aAspects); + } + + + /* + * That's shown, many times, in the EnumHelper code, all the add functions just wrap the addEnum function. + You need the target enum class, and 2 arrays, 1 holding the types for the constructor arguments, + and the other holding the constructor argument values (the things being passed to the constructor) + + The 'decompiled' Boolean should be set to true if the class you're adding to has been decompiled/recompiled again. + (it adds a 2nd enum arguments that need to be accounted for, but isn't actually useful to you) + + * + *new Class[{int.class, TextureSet.class, float.class, int.class, + int.class, int.class, int.class, int.class, int.class, int.class, + String.class, int.class, int.class, int.class, int.class, boolean.class, + boolean.class, int.class, int.class, int.class, Dyes.class, int.class, + List.class , List.class}], + */ + + + + public static Materials GenerateGtMaterialForSingleUse(MaterialInfo s){ + + Materials yourName = EnumHelper.addEnum( + + Materials.class, s.name(), + + + + new Object[0] + + ); + try + { + + + + /*Class<? extends ItemCell> clz = item.getClass(); + Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); + methode.setAccessible(true); + ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]);*/ + + + + + + + return Materials.Abyssal; + } + catch(Exception e){ + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java new file mode 100644 index 0000000000..3df5693bc3 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -0,0 +1,213 @@ +package gtPlusPlus.core.util.math; + +import gtPlusPlus.core.util.Utils; + +import java.util.Map; +import java.util.Random; + +public class MathUtils { + + /** + * Returns a psuedo-random number between min and max, inclusive. + * The difference between min and max can be at most + * Integer.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Integer between min and max, inclusive. + * @see java.util.Random#nextInt(int) + */ + public static int randInt(int min, int max) { + + // Usually this can be a field rather than a method variable + Random rand = new Random(); + + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + int randomNum = rand.nextInt((max - min) + 1) + min; + + return randomNum; + } + + + /** + * Returns a psuedo-random number between min and max, inclusive. + * The difference between min and max can be at most + * Long.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Long between min and max, inclusive. + * @see java.util.Random#nextLong(long) + */ + public static long randLong(long min, long max) { + // Usually this can be a field rather than a method variable + Random rand = new Random(); + + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + long randomNum = MathUtils.nextLong(rand,(max - min) + 1) + min; + + return randomNum; + } + private static long nextLong(Random rng, long n) { + // error checking and 2^x checking removed for simplicity. + long bits, val; + do { + bits = (rng.nextLong() << 1) >>> 1; + val = bits % n; + } while (bits-val+(n-1) < 0L); + return val; + } + + + /** + * Returns a percentage. + * The returned number is the % of X in Y. + * Supports Doubles. + * + * @param current Current value. + * @param max Maximim value. Must be greater than min. + * @return double between min and max, inclusive. + */ + public static double findPercentage(double current, double max){ + double c = ((double) current / max) * 100; + double roundOff = Math.round(c * 100.00) / 100.00; + return roundOff; + } + + + //Smooth Rounding Function + /** + * Returns a double. + * The returned number is d rounded to the nearest d.01. + * Supports Doubles. + * + * @param current Current value. + * @return double Rounded value. + */ + public static double decimalRounding(double d) { + return Math.round(d * 2) / 2.0; + } + + + //Smooth Rounding Function (Nearest 5) + /** + * Returns a double. + * The returned number is d rounded to the nearest d.5. + * Supports Doubles. + * + * @param current Current value. + * @return double Rounded value. + */ + public static double decimalRoundingToWholes(double d) { + return 5*(Math.round(d/5)); + } + + + /** + * Returns a boolean. + * The returned boolean is wether or not X evenly fits in to Y. + * Supports ints. + * + * @param x Value A. + * @param y Value B. Must be greater than min. + * @return boolean Whether or not it divides evenly. + */ + public static boolean divideXintoY(int x, int y){ + if ((x % y) == 0) + { + return true; + } + return false; + } + + + /** + * Returns a boolean. + * The returned boolean is based on the odd/eveness of the input. + * Supports ints. + * + * @param x Value A. + * @return boolean Whether or not it divides evenly. + */ + public static boolean isNumberEven(int x){ + if ((x % 2) == 0) + { + return true; + } + return false; + } + + + + /** + * Returns an int. + * The returned number is the value on i + 273.15F. + * Supports ints. + * + * @param i Temp in Celcius. + * @return int The celcius temp returned as Kelvin, rounded to the readest whole. + */ + public static float celsiusToKelvin(int i){ + double f = i + 273.15F; + return (int)decimalRoundingToWholes(f); + } + + + /** + * Returns a hexInteger. + * The returned number is the hex value of the input. + * Supports ints. + * + * @param input Current value. + * @return hexInteger. + */ + public static int getHexNumberFromInt(int input){ + String result = Integer.toHexString(input); + int resultINT = Integer.getInteger(result); + return resultINT; + } + + + /** + * Returns a hexInteger. + * The returned value is between min and max. + * Supports ints. + * + * @param min Minimum value. + * @param max Maximium value. Must be greater than min. + * @return hexInteger between min and max, inclusive. + */ + public static int generateRandomHexValue(int min, int max){ + int result = getHexNumberFromInt(randInt(min, max)); + return result; + } + + + /** + * Returns a random hex value. + * The returned value is between 000000-ffffff. + * + * @return hexInteger between min and max, inclusive. + */ + public static int generateSingularRandomHexValue(){ + String temp; + int randomInt = randInt(1, 5); + final Map<Integer, String> colours = Utils.hexColourGeneratorRandom(5); + + if (colours.get(randomInt) != null && colours.size() > 0){ + temp = colours.get(randomInt); + } + else { + temp = "0F0F0F"; + } + + Utils.LOG_WARNING("Operating with "+temp); + temp = Utils.appenedHexNotationToString(String.valueOf(temp)); + Utils.LOG_WARNING("Made "+temp+" - Hopefully it's not a mess."); + Utils.LOG_WARNING("It will decode into "+Integer.decode(temp)+"."); + return Integer.decode(temp); + } + +} diff --git a/src/Java/gtPlusPlus/core/util/particles/EntityParticleFXMysterious.java b/src/Java/gtPlusPlus/core/util/particles/EntityParticleFXMysterious.java new file mode 100644 index 0000000000..2c704e48a6 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/particles/EntityParticleFXMysterious.java @@ -0,0 +1,17 @@ +package gtPlusPlus.core.util.particles; + +import net.minecraft.client.particle.EntityAuraFX; +import net.minecraft.world.World; + +public class EntityParticleFXMysterious extends EntityAuraFX +{ + public EntityParticleFXMysterious(World parWorld, + double parX, double parY, double parZ, + double parMotionX, double parMotionY, double parMotionZ) + { + super(parWorld, parX, parY, parZ, parMotionX, parMotionY, parMotionZ); + setParticleTextureIndex(82); // same as happy villager + particleScale = 2.0F; + setRBGColorF(0x88, 0x00, 0x88); + } +} diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerCache.java b/src/Java/gtPlusPlus/core/util/player/PlayerCache.java new file mode 100644 index 0000000000..095eb543db --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/player/PlayerCache.java @@ -0,0 +1,190 @@ +package gtPlusPlus.core.util.player; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Properties; +import java.util.UUID; + +import net.minecraft.client.Minecraft; +import net.minecraft.world.World; + +public class PlayerCache { + + private static final File cache = new File("PlayerCache.dat"); + + public static final void initCache() { + if (CORE.PlayerCache == null || CORE.PlayerCache.equals(null)){ + try { + + if (cache != null){ + CORE.PlayerCache = PlayerCache.readPropertiesFileAsMap(); + Utils.LOG_INFO("Loaded PlayerCache.dat"); + } + + + } catch (Exception e) { + Utils.LOG_INFO("Failed to initialise PlayerCache.dat"); + PlayerCache.createPropertiesFile("PLAYER_", "DATA"); + //e.printStackTrace(); + } + } + } + + public static void createPropertiesFile(String playerName, String playerUUIDasString) { + try { + Properties props = new Properties(); + props.setProperty(playerName+" ", playerUUIDasString); + OutputStream out = new FileOutputStream(cache); + props.store(out, "Player Cache."); + Utils.LOG_INFO("PlayerCache.dat created for future use."); + } + catch (Exception e ) { + e.printStackTrace(); + } + } + + public static void appendParamChanges(String playerName, String playerUUIDasString) { + HashMap<String, UUID> playerInfo = new HashMap<String, UUID>(); + playerInfo.put(playerName, UUID.fromString(playerUUIDasString)); + + /*try { + Utils.LOG_INFO("Attempting to load "+cache.getName()); + properties.load(new FileInputStream(cache)); + if (properties == null || properties.equals(null)){ + Utils.LOG_INFO("Please wait."); + } + else { + Utils.LOG_INFO("Loaded PlayerCache.dat"); + properties.setProperty(playerName+"_", playerUUIDasString); + FileOutputStream fr=new FileOutputStream(cache); + properties.store(fr, "Player Cache."); + fr.close(); + } + + } */ + + try + { + FileOutputStream fos = new FileOutputStream("PlayerCache.dat"); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(playerInfo); + oos.close(); + fos.close(); + Utils.LOG_INFO("Serialized Player data saved in PlayerCache.dat"); + } + + catch (IOException e) { + Utils.LOG_INFO("No PlayerCache file found, creating one."); + createPropertiesFile(playerName, playerUUIDasString); + } + } + + /** + * Reads a "properties" file, and returns it as a Map + * (a collection of key/value pairs). + * + * Credit due to Alvin Alexander - http://alvinalexander.com/java/java-properties-file-map-example?nocache=1#comment-8215 + * Changed slightly as the filename and delimiter are constant in my case. + * + * @param filename The properties filename to read. + * @param delimiter The string (or character) that separates the key + * from the value in the properties file. + * @return The Map that contains the key/value pairs. + * @throws Exception + */ + @Deprecated + public static Map<String, String> readPropertiesFileAsMapOld() throws Exception { + String delimiter = "="; + @SuppressWarnings({ "rawtypes", "unchecked" }) + Map<String, String> map = new HashMap<String, String>(); + BufferedReader reader = new BufferedReader(new FileReader(cache)); + String line; + while ((line = reader.readLine()) != null) + { + if (line.trim().length()==0) continue; + if (line.charAt(0)=='#') continue; + // assumption here is that proper lines are like "String : <a href="http://xxx.yyy.zzz/foo/bar"" title="http://xxx.yyy.zzz/foo/bar"">http://xxx.yyy.zzz/foo/bar"</a>, + // and the ":" is the delimiter + int delimPosition = line.indexOf(delimiter); + String key = line.substring(0, delimPosition-1).trim(); + String value = line.substring(delimPosition+1).trim(); + map.put(key, value); + } + reader.close(); + CORE.PlayerCache = map; + return map; + } + + public static HashMap<String, UUID> readPropertiesFileAsMap() { + HashMap<String, UUID> map = null; + try + { + FileInputStream fis = new FileInputStream(cache); + ObjectInputStream ois = new ObjectInputStream(fis); + map = (HashMap<String, UUID>) ois.readObject(); + ois.close(); + fis.close(); + }catch(IOException ioe) + { + ioe.printStackTrace(); + return null; + }catch(ClassNotFoundException c) + { + Utils.LOG_INFO("Class not found"); + c.printStackTrace(); + return null; + } + Utils.LOG_WARNING("Deserialized PlayerCache.."); + return map; + } + + public static String lookupPlayerByUUID(UUID UUID){ + + try { + World worldw = Minecraft.getMinecraft().thePlayer.worldObj; + //if (!worldw.isRemote){ + + + try { + Map<String, UUID> map = null; + try { + map = readPropertiesFileAsMap(); + } catch (Exception e) { + Utils.LOG_INFO("With "+e.getCause()+" as cause, Caught Exception: "+e.toString()); + //e.printStackTrace(); + } + for (Entry<String, UUID> entry : map.entrySet()) { + if (Objects.equals(UUID, entry.getValue())) { + return entry.getKey(); + } + } + return null; + } catch (NullPointerException e) { + Utils.LOG_INFO("With "+e.getCause()+" as cause, Caught Exception: "+e.toString()); + //e.printStackTrace(); + } + + + //} + + + } catch (Throwable r){ + Utils.LOG_INFO("With "+r.getCause()+" as cause, Caught Exception: "+r.toString()); + } + return null; + } +} diff --git a/src/Java/gtPlusPlus/core/util/player/UtilsMining.java b/src/Java/gtPlusPlus/core/util/player/UtilsMining.java new file mode 100644 index 0000000000..1b6b957b32 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/player/UtilsMining.java @@ -0,0 +1,180 @@ +package gtPlusPlus.core.util.player; + +import gtPlusPlus.core.util.Utils; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class UtilsMining { + + private static boolean durabilityDamage = false; + private static ItemStack stack; + + public static Boolean canPickaxeBlock(Block currentBlock, World currentWorld){ + String correctTool = ""; + if (!currentWorld.isRemote){ + try { + correctTool = currentBlock.getHarvestTool(0); + //Utils.LOG_WARNING(correctTool); + if (correctTool.equals("pickaxe")){ + return true;} + } catch (NullPointerException e){ + return false;} + } + return false; + } + + private static void removeBlockAndDropAsItem(World world, int X, int Y, int Z){ + try { + Block block = world.getBlock(X, Y, Z); + if (canPickaxeBlock(block, world)){ + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + + } + else { + Utils.LOG_WARNING("Incorrect Tool for mining this block."); + } + } + } catch (NullPointerException e){ + + } + } + + public static void customMine(World world, String FACING, EntityPlayer aPlayer){ + + float DURABILITY_LOSS = 0; + if (!world.isRemote){ + int X = 0; + int Y = 0; + int Z = 0; + + if (FACING.equals("below") || FACING.equals("above")){ + + //Set Player Facing + X = (int) aPlayer.posX; + Utils.LOG_WARNING("Setting Variable X: "+X); + if (FACING.equals("above")){ + Z = (int) aPlayer.posY + 1; + Utils.LOG_WARNING("Setting Variable Y: "+Y); + } + else { + Z = (int) aPlayer.posY - 1; + Utils.LOG_WARNING("Setting Variable Y: "+Y);} + Z = (int) aPlayer.posZ; + Utils.LOG_WARNING("Setting Variable Z: "+Z); + + DURABILITY_LOSS = 0; + for(int i = -2; i < 3; i++) { + for(int j = -2; j < 3; j++) { + for(int k = -2; k < 3; k++) { +/*// float dur = calculateDurabilityLoss(world, X + i, Y + k, Z + j); +// DURABILITY_LOSS = (DURABILITY_LOSS + dur); +// Utils.LOG_WARNING("Added Loss: "+dur); +*/ removeBlockAndDropAsItem(world, X + i, Y + k, Z + j); + } + } + } + } + + else if (FACING.equals("facingEast") || FACING.equals("facingWest")){ + + //Set Player Facing + Z = (int) aPlayer.posZ; + Y = (int) aPlayer.posY; + if (FACING.equals("facingEast")){ + X = (int) aPlayer.posX + 1;} + else { + X = (int) aPlayer.posX - 1;} + + + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + for(int k = -1; k < 2; k++) { + /*float dur = calculateDurabilityLoss(world, X+k, Y + i, Z + j); + DURABILITY_LOSS = (DURABILITY_LOSS + dur); + Utils.LOG_WARNING("Added Loss: "+dur);*/ + removeBlockAndDropAsItem(world, X+k, Y + i, Z + j); + } + } + } + } + + else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){ + + //Set Player Facing + X = (int) aPlayer.posX; + Y = (int) aPlayer.posY; + + if (FACING.equals("facingNorth")){ + Z = (int) aPlayer.posZ + 1;} + else { + Z = (int) aPlayer.posZ - 1;} + + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + for(int k = -1; k < 2; k++) { + /*float dur = calculateDurabilityLoss(world, X + j, Y + i, Z+k); + DURABILITY_LOSS = (DURABILITY_LOSS + dur); + Utils.LOG_WARNING("Added Loss: "+dur);*/ + removeBlockAndDropAsItem(world, X + j, Y + i, Z+k); + } + } + } + } + + //Set Durability damage to the item + if (durabilityDamage == true){ + Utils.LOG_WARNING("Total Loss: "+(int)DURABILITY_LOSS); + if (stack.getItemDamage() < (stack.getMaxDamage()-DURABILITY_LOSS)){ + stack.damageItem((int) DURABILITY_LOSS, aPlayer); + } + } + DURABILITY_LOSS = 0; + } + } + + + public static boolean getBlockType(Block block){ + final String LIQUID = "liquid"; + final String BLOCK = "block"; + final String ORE = "ore"; + final String AIR = "air"; + String blockClass = ""; + + try { + blockClass = block.getClass().toString().toLowerCase(); + Utils.LOG_WARNING(blockClass); + if (blockClass.toLowerCase().contains(LIQUID)){ + Utils.LOG_WARNING(block.toString()+" is a Liquid."); + return false; + } + else if (blockClass.toLowerCase().contains(ORE)){ + Utils.LOG_WARNING(block.toString()+" is an Ore."); + return true; + } + else if (blockClass.toLowerCase().contains(AIR)){ + Utils.LOG_WARNING(block.toString()+" is Air."); + return false; + } + else if (blockClass.toLowerCase().contains(BLOCK)){ + Utils.LOG_WARNING(block.toString()+" is a block of some kind."); + return false; + } + else { + Utils.LOG_WARNING(block.toString()+" is mystery."); + return false; + } + } + catch(NullPointerException e){ + return false; + } + } + + +} diff --git a/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java b/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java new file mode 100644 index 0000000000..997aaa95c9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java @@ -0,0 +1,370 @@ +package gtPlusPlus.core.util.recipe; + +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.core.handler.COMPAT_HANDLER; +import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; +import gtPlusPlus.core.handler.Recipes.RegistrationHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; +import cpw.mods.fml.common.registry.GameRegistry; + +public class UtilsRecipe { + + public static void recipeBuilder(Object slot_1, Object slot_2, Object slot_3, Object slot_4, Object slot_5, Object slot_6, Object slot_7, Object slot_8, Object slot_9, ItemStack resultItem){ + + ArrayList<Object> validSlots = new ArrayList<Object>(); + + Utils.LOG_INFO("Trying to add a recipe for "+resultItem.toString()); + String a,b,c,d,e,f,g,h,i; + if (slot_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(slot_1);} + Utils.LOG_WARNING(a); + if (slot_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(slot_2);} + Utils.LOG_WARNING(b); + if (slot_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(slot_3);} + Utils.LOG_WARNING(c); + if (slot_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(slot_4);} + Utils.LOG_WARNING(d); + if (slot_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(slot_5);} + Utils.LOG_WARNING(e); + if (slot_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(slot_6);} + Utils.LOG_WARNING(f); + if (slot_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(slot_7);} + Utils.LOG_WARNING(g); + if (slot_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(slot_8);} + Utils.LOG_WARNING(h); + if (slot_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(slot_9);} + Utils.LOG_WARNING(i); + + + Utils.LOG_ERROR("_______"); + String lineOne = a+b+c; + Utils.LOG_ERROR("|"+a+"|"+b+"|"+c+"|"); + Utils.LOG_ERROR("_______"); + String lineTwo = d+e+f; + Utils.LOG_ERROR("|"+d+"|"+e+"|"+f+"|"); + Utils.LOG_ERROR("_______"); + String lineThree = g+h+i; + Utils.LOG_ERROR("|"+g+"|"+h+"|"+i+"|"); + Utils.LOG_ERROR("_______"); + + validSlots.add(0, lineOne); + validSlots.add(1, lineTwo); + validSlots.add(2, lineThree); + boolean advancedLog = false; + if (CORE.DEBUG){ + advancedLog = true; + } + if (advancedLog){ + int j = 0; + int l = validSlots.size(); + Utils.LOG_WARNING("l:"+l); + while (j <= l) { + Utils.LOG_WARNING("j:"+j); + if (j <= 2){ + Utils.LOG_WARNING("ArrayList Values: "+validSlots.get(j)); + Utils.LOG_WARNING("Adding 1."); + j++; + } + else if (j >= 3){ + Utils.LOG_WARNING("ArrayList Values: '"+validSlots.get(j)+"' "+validSlots.get(j+1)); + if (j < (l-2)){ + Utils.LOG_WARNING("Adding 2."); + j=j+2; + } + else { + Utils.LOG_WARNING("Done iteration."); + break; + } + } + else if (j == l){ + Utils.LOG_WARNING("Done iteration."); + break; + } + if (validSlots.get(j) instanceof String || validSlots.get(j) instanceof ItemStack){ + //Utils.LOG_WARNING("Is Valid: "+validSlots.get(j)); + } + } + } + + try { + GameRegistry.addRecipe(new ShapedOreRecipe(resultItem.copy(), (Object[]) validSlots.toArray())); + Utils.LOG_INFO("Success! Added a recipe for "+resultItem.toString()); + if (!COMPAT_HANDLER.areInitItemsLoaded){ + RegistrationHandler.recipesSuccess++; + } + else { + LateRegistrationHandler.recipesSuccess++; + } + } + catch(NullPointerException | ClassCastException k){ + k.getMessage(); + k.getClass(); + k.printStackTrace(); + k.getLocalizedMessage(); + Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName()); + if (!COMPAT_HANDLER.areInitItemsLoaded){ + RegistrationHandler.recipesFailed++; + } + else { + LateRegistrationHandler.recipesFailed++; + } + } + } + + public static void shapelessBuilder(ItemStack Output, Object slot_1, Object slot_2, Object slot_3, Object slot_4, Object slot_5, Object slot_6, Object slot_7, Object slot_8, Object slot_9){ + //Item output_ITEM = Output.getItem(); + + ArrayList<Object> validSlots = new ArrayList<Object>(); + + Utils.LOG_INFO("Trying to add a recipe for "+Output.toString()); + String a,b,c,d,e,f,g,h,i; + if (slot_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(slot_1);} + Utils.LOG_WARNING(a); + if (slot_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(slot_2);} + Utils.LOG_WARNING(b); + if (slot_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(slot_3);} + Utils.LOG_WARNING(c); + if (slot_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(slot_4);} + Utils.LOG_WARNING(d); + if (slot_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(slot_5);} + Utils.LOG_WARNING(e); + if (slot_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(slot_6);} + Utils.LOG_WARNING(f); + if (slot_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(slot_7);} + Utils.LOG_WARNING(g); + if (slot_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(slot_8);} + Utils.LOG_WARNING(h); + if (slot_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(slot_9);} + Utils.LOG_WARNING(i); + + + Utils.LOG_ERROR("_______"); + Utils.LOG_ERROR("|"+a+"|"+b+"|"+c+"|"); + Utils.LOG_ERROR("_______"); + Utils.LOG_ERROR("|"+d+"|"+e+"|"+f+"|"); + Utils.LOG_ERROR("_______"); + Utils.LOG_ERROR("|"+g+"|"+h+"|"+i+"|"); + Utils.LOG_ERROR("_______"); + + validSlots.add(0, a); + validSlots.add(1, b); + validSlots.add(2, c); + validSlots.add(3, d); + validSlots.add(4, e); + validSlots.add(5, f); + validSlots.add(6, g); + validSlots.add(7, h); + validSlots.add(8, i); + + try { + //GameRegistry.addRecipe(new ShapelessOreRecipe(Output, outputAmount), (Object[]) validSlots.toArray()); + GameRegistry.addRecipe(new ShapelessOreRecipe(Output, (Object[]) validSlots.toArray())); + //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); + Utils.LOG_INFO("Success! Added a recipe for "+Output.toString()); + RegistrationHandler.recipesSuccess++; + } + catch(RuntimeException k){ + k.getMessage(); + k.getClass(); + k.printStackTrace(); + k.getLocalizedMessage(); + Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+Output.getUnlocalizedName()); + RegistrationHandler.recipesFailed++; + } + + + //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); + } + + public static void recipeBuilder(Object[] array, ItemStack outPut) { + Utils.LOG_SPECIFIC_WARNING("object Array - recipeBuilder", "Attempting to build a recipe using an object array as an input, splitting it, then running the normal recipeBuilder() method.", 396); + Object a=null; + Object b=null; + Object c=null; + Object d=null; + Object e=null; + Object f=null; + Object g=null; + Object h=null; + Object i=null; + for(int z =0; z <= array.length; z++){ + array[z].toString(); + switch(z) + { + case 0: + a = array[z]; + break; + case 1: + b = array[z]; + break; + case 2: + c = array[z]; + break; + case 3: + d = array[z]; + break; + case 4: + e = array[z]; + break; + case 5: + f = array[z]; + break; + case 6: + g = array[z]; + break; + case 7: + h = array[z]; + break; + case 8: + i = array[z]; + break; + default: + break; + } + recipeBuilder(a, b, c, d, e, f, g, h, i, outPut); + } + } + + public static boolean removeCraftingRecipe(Object x){ + if (null == x){return false;} + if (x instanceof String){ + Item R = UtilsItems.getItem((String) x); + if (R != null){ + x = R; + } + else { + return false; + } + } + if (x instanceof Item || x instanceof ItemStack){ + if (x instanceof Item){ + ItemStack r = new ItemStack((Item) x); + Utils.LOG_INFO("Removing Recipe for "+r.getUnlocalizedName()); + } + else { + Utils.LOG_INFO("Removing Recipe for "+((ItemStack) x).getUnlocalizedName()); + } + if (x instanceof ItemStack){ + Item r = ((ItemStack) x).getItem(); + if (null != r){ + x = r; + } + else { + Utils.LOG_INFO("Recipe removal failed - Tell Alkalus."); + return false; + } + } + if (UtilsRecipe.attemptRecipeRemoval((Item) x)){ + Utils.LOG_INFO("Recipe removal successful"); + return true; + } + Utils.LOG_INFO("Recipe removal failed - Tell Alkalus."); + return false; + } + return false; + } + + private static boolean attemptRecipeRemoval(Item I){ + Utils.LOG_WARNING("Create list of recipes."); + List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList(); + Iterator<IRecipe> items = recipes.iterator(); + Utils.LOG_WARNING("Begin list iteration."); + while (items.hasNext()) { + ItemStack is = items.next().getRecipeOutput(); + if (is != null && is.getItem() == I){ + items.remove(); + Utils.LOG_INFO("Remove a recipe with "+I.getUnlocalizedName()+" as output."); + continue; + } + } + Utils.LOG_WARNING("All recipes should be gone?"); + if (!items.hasNext()){ + Utils.LOG_WARNING("We iterated once, let's try again to double check."); + Iterator<IRecipe> items2 = recipes.iterator(); + while (items2.hasNext()) { + ItemStack is = items2.next().getRecipeOutput(); + if (is != null && is.getItem() == I){ + items.remove(); + Utils.LOG_WARNING("REMOVING MISSED RECIPE - RECHECK CONSTRUCTORS"); + return true; + } + } + Utils.LOG_WARNING("Should be all gone now after double checking, so return true."); + return true; + } + Utils.LOG_INFO("Return false, because something went wrong."); + return false; + } + + + + + + + public static void addShapedGregtechRecipe( + Object InputItem1, Object InputItem2, Object InputItem3, + Object InputItem4, Object InputItem5, Object InputItem6, + Object InputItem7, Object InputItem8, Object InputItem9, + ItemStack OutputItem){ + + if ((!(InputItem1 instanceof ItemStack) && !(InputItem1 instanceof String) && (InputItem1 != null)) || + (!(InputItem2 instanceof ItemStack) && !(InputItem2 instanceof String) && (InputItem2 != null)) || + (!(InputItem3 instanceof ItemStack) && !(InputItem3 instanceof String) && (InputItem3 != null)) || + (!(InputItem4 instanceof ItemStack) && !(InputItem4 instanceof String) && (InputItem4 != null)) || + (!(InputItem5 instanceof ItemStack) && !(InputItem5 instanceof String) && (InputItem5 != null)) || + (!(InputItem6 instanceof ItemStack) && !(InputItem6 instanceof String) && (InputItem6 != null)) || + (!(InputItem7 instanceof ItemStack) && !(InputItem7 instanceof String) && (InputItem7 != null)) || + (!(InputItem8 instanceof ItemStack) && !(InputItem8 instanceof String) && (InputItem8 != null)) || + (!(InputItem9 instanceof ItemStack) && !(InputItem9 instanceof String) && (InputItem9 != null))){ + Utils.LOG_INFO("One Input item was not an ItemStack of an OreDict String."); + return; + } + + GT_ModHandler.addCraftingRecipe(OutputItem, + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | + GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"ABC", "DEF", "GHI", + 'A', InputItem1, + 'B', InputItem2, + 'C', InputItem3, + 'D', InputItem4, + 'E', InputItem5, + 'F', InputItem6, + 'G', InputItem7, + 'H', InputItem8, + 'I', InputItem9}); + } + + public static void addShapelessGregtechRecipe(ItemStack OutputItem, Object... inputItems){ + + for(Object whatever : inputItems){ + if (!(whatever instanceof ItemStack) && !(whatever instanceof String)){ + Utils.LOG_INFO("One Input item was not an ItemStack of an OreDict String."); + return; + } + } + + GT_ModHandler.addShapelessCraftingRecipe(OutputItem, + GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{inputItems}); + } + + public static ItemStack getItemStackFromOreDict(String oredictName){ + ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); + return oreDictList.get(0); + } + +} diff --git a/src/Java/gtPlusPlus/core/util/wrapper/var.java b/src/Java/gtPlusPlus/core/util/wrapper/var.java new file mode 100644 index 0000000000..d5e55bd658 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/wrapper/var.java @@ -0,0 +1,67 @@ +package gtPlusPlus.core.util.wrapper; + +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.item.ItemStack; + +public class var{ + + private ItemStack temp = null; + private String sanitizedName; + private String fqrn; + + public var(String o){ + String t = sanitize('<', o); + String t2 = sanitize('>', t); + sanitizedName = t2; + o = sanitize('"', t2); + fqrn = o; + } + + private String sanitize(char token, String input){ + for (int i=0;i<input.length();i++) { + if (input.charAt(i) == token) { + input = input.replace(input.charAt(i), ' '); + Utils.LOG_WARNING("MATCH FOUND"); + } + input = input.replaceAll(" ", ""); + } + String output = input; + return output; + } + + public String getFQRN(){ + String s = fqrn; + return s; + } + + public String getsanitizedName(){ + String s = sanitizedName; + return s; + } + + private ItemStack getOreDictStack(int stackSize){ + ItemStack v = UtilsItems.getItemStack(sanitizedName, stackSize); + return v; + } + + public ItemStack getStack(int stackSize){ + String oreDict = "ore:"; + if (fqrn.toLowerCase().contains(oreDict.toLowerCase())){ + ItemStack v = getOreDictStack(stackSize); + return v; + } + String[] fqrnSplit = fqrn.split(":"); + String meta = "0"; + try { + if(fqrnSplit[2] != null){meta = fqrnSplit[2];} + temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(meta), stackSize); + } + catch (ArrayIndexOutOfBoundsException a){ + temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(meta), stackSize); + } + return temp; + } + + }
\ No newline at end of file |