diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core')
98 files changed, 8478 insertions, 2102 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index b904b04556..a448e313ac 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -18,8 +18,10 @@ import gtPlusPlus.core.block.machine.DecayablesChest; import gtPlusPlus.core.block.machine.FishTrap; import gtPlusPlus.core.block.machine.HeliumGenerator; import gtPlusPlus.core.block.machine.Machine_ModularityTable; +import gtPlusPlus.core.block.machine.Machine_PestKiller; import gtPlusPlus.core.block.machine.Machine_PooCollector; import gtPlusPlus.core.block.machine.Machine_ProjectTable; +import gtPlusPlus.core.block.machine.Machine_RoundRobinator; import gtPlusPlus.core.block.machine.Machine_SuperJukebox; import gtPlusPlus.core.block.machine.Machine_TradeTable; import gtPlusPlus.core.block.machine.Machine_Workbench; @@ -33,6 +35,7 @@ import net.minecraftforge.fluids.Fluid; public final class ModBlocks { + public static Block blockRoundRobinator; public static Block blockCircuitProgrammer; public static Block blockFakeMiningPipe; public static Block blockFakeMiningHead; @@ -91,6 +94,8 @@ public final class ModBlocks { public static Block blockCustomJukebox; public static Block blockPooCollector; + + public static Block blockPestKiller; public static void init() { Logger.INFO("Initializing Blocks."); @@ -142,6 +147,10 @@ public final class ModBlocks { blockCustomJukebox = new Machine_SuperJukebox(); blockPooCollector = new Machine_PooCollector(); + + blockPestKiller = new Machine_PestKiller(); + + blockRoundRobinator = new Machine_RoundRobinator(); new BlockGenericRedstoneDetector(); new BlockGenericRedstoneTest(); diff --git a/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java b/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java new file mode 100644 index 0000000000..6166835f31 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java @@ -0,0 +1,315 @@ +package gtPlusPlus.core.block.base; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.CubicObject; +import gtPlusPlus.api.objects.minecraft.SafeTexture; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +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.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class BasicTileBlockWithTooltip extends BlockContainer implements ITileTooltip { + + /** + * Each mapped object holds the data for the six sides. + */ + @SideOnly(Side.CLIENT) + private AutoMap<CubicObject<SafeTexture>> mSidedTextureArray; + + /** + * Holds the data for the six sides, each side holds an array of data for each respective meta. + */ + @SideOnly(Side.CLIENT) + private AutoMap<CubicObject<String>> mSidedTexturePathArray; + + /** + * Does this block have any meta at all? + * @return + */ + public final boolean hasMeta() { + return getMetaCount() > 0; + } + + /** + * The amount of meta this block has. + * @return + */ + public abstract int getMetaCount(); + + /** + * Does this {@link Block} require special {@link ItemBlock} handling? + * @return The {@link Class} that will be used for this {@link Block}. + */ + public Class<? extends ItemBlock> getItemBlockClass() { + return ItemBlock.class; + } + + /** + * A lazy way to declare the unlocal name for the block, makes boilerplating easy. + * @return The internal name for this block. + */ + public abstract String getUnlocalBlockName(); + + /** + * Does this Block have {@link ITileTooltip} support? + * @return {@link boolean} that represents if this block supports {@link ITileTooltip} or not. + */ + public final boolean hasTooltip() { + return getTooltipID() >= -1; + } + + /** + * Lazy Boilerplating. + * @return Block Hardness. + */ + protected abstract float initBlockHardness(); + + /** + * Lazy Boilerplating. + * @return Block Resistance. + */ + protected abstract float initBlockResistance(); + + /** + * Lazy Boilerplating. + * @return The {@link CreativeTab} this Block is shown on. + */ + protected abstract CreativeTabs initCreativeTab(); + + /** + * The ID used by the {@link ITileTooltip} handler. Return -1 if you are not providing a custom {@link ItemBlock} in {@link #getItemBlockClass}(). + * @return + */ + @Override + public abstract int getTooltipID(); + + public BasicTileBlockWithTooltip(Material aBlockMat){ + super(aBlockMat); + //Use Abstract method values + this.setHardness(initBlockHardness()); + this.setResistance(initBlockResistance()); + this.setBlockName(getUnlocalBlockName()); + this.setCreativeTab(initCreativeTab()); + // Register the block last. + GameRegistry.registerBlock(this, getItemBlockClass(), getUnlocalBlockName()); + Logger.INFO("Registered "+getTileEntityName()+"."); + if (Utils.isClient()) { + // Handle Textures + handleTextures(); + } + } + + /** + * The name of the Tile Entity. + * @return + */ + protected abstract String getTileEntityName(); + + /** + * The String used for texture pathing. + * @return Sanitized {@link String}, containing no spaces or illegal characters. + */ + private final String getTileEntityNameForTexturePathing() { + return Utils.sanitizeString(getTileEntityName().replace(" ", "")); + } + + /** + * An array of CubicObjects, one for each meta, else just a single cell array. + * Expected to be null regularly, as the default texture handling should suffice. + * Handy if re-using textures or using a non-standard structure for them. FULL texture path must be used, + * inclusive of the MODID and a colon. + * @return + */ + public CubicObject<String>[] getCustomTextureDirectoryObject(){ + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public final IIcon getIcon(final int aSide, final int aMeta) { + return mSidedTextureArray.get(aMeta).get(aSide).getIcon(); + } + + @Override + public IIcon getIcon(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + return super.getIcon(aWorld, aX, aY, aZ, aSide); + } + + @SideOnly(Side.CLIENT) + private final void handleTextures() { + + Logger.INFO("[TeTexture] Building Texture Maps for "+getTileEntityName()+"."); + + // Init on the Client side only, to prevent Field initialisers existing in the Server side bytecode. + mSidedTextureArray = new AutoMap<CubicObject<SafeTexture>>(); + mSidedTexturePathArray = new AutoMap<CubicObject<String>>(); + + + //Store them in forge order + //DOWN, UP, NORTH, SOUTH, WEST, EAST + + // Default Path Name, this will make us look inside 'miscutils\textures\blocks' + final String aPrefixTexPath = CORE.MODID + ":"; + // Default Path Name, this will make us look in the sub-directory for this Tile Entity. + final String aTexPathMid = "TileEntities"+CORE.SEPERATOR+getTileEntityNameForTexturePathing()+CORE.SEPERATOR; + // Construct a full path + String aTexPathBuilt = aPrefixTexPath + aTexPathMid; + // File Name Suffixes, without meta tags + String aStringBot; + String aStringTop; + String aStringBack; + String aStringFront; + String aStringLeft; + String aStringRight; + // Do we provide a matrix of custom data to be used for texture processing instead? + if (getCustomTextureDirectoryObject() != null) { + // Get custom provided texture data. + CubicObject<String>[] aDataMap = getCustomTextureDirectoryObject(); + Logger.INFO("[TeTexture] Found custom texture data, using this instead. Size: "+aDataMap.length); + // Map each meta string data to the main map. + for (int i=0;i<aDataMap.length;i++) { + mSidedTexturePathArray.put(aDataMap[i]); + Logger.INFO("Mapped value for meta "+i+"."); + } + } + else { + Logger.INFO("[TeTexture] Processing "+(1+getMetaCount())+" sets."); + // Iterate once for each meta + for (int i=0;i<(1+getMetaCount());i++) { + + // File Name Suffixes, without meta tags + aStringBot = "Bottom"; + aStringTop = "Top"; + aStringBack = "Back"; + aStringFront = "Front"; + aStringLeft = "Left"; + aStringRight = "Right"; + + // Add tails if we have meta + if (hasMeta()) { + aStringBot = aStringBot + "_"+i; + aStringTop = aStringTop + "_"+i; + aStringBack = aStringBack + "_"+i; + aStringFront = aStringFront + "_"+i; + aStringLeft = aStringLeft + "_"+i; + aStringRight = aStringRight + "_"+i; + } + // Append the full path + aStringBot = aTexPathBuilt + aStringBot; + aStringTop = aTexPathBuilt + aStringTop; + aStringBack = aTexPathBuilt + aStringBack; + aStringFront = aTexPathBuilt + aStringFront; + aStringLeft = aTexPathBuilt + aStringLeft; + aStringRight = aTexPathBuilt + aStringRight; + // Convenience Blob + CubicObject<String> aMetaBlob = new CubicObject<String>(aStringBot, aStringTop, aStringBack, aStringFront, aStringLeft, aStringRight); + mSidedTexturePathArray.put(aMetaBlob); + Logger.INFO("[TeTexture] Added Texture Path data to map for meta "+i); + } + } + Logger.INFO("[TeTexture] Map size for pathing: "+mSidedTexturePathArray.size()); + + // Iteration Index + int aIndex = 0; + + // Iterate each CubicObject, holding the six texture paths for each meta. + for (CubicObject<String> aMetaBlob : mSidedTexturePathArray) { + // Make a Safe Texture for each side + SafeTexture aBottom = SafeTexture.register(aMetaBlob.DOWN); + SafeTexture aTop = SafeTexture.register(aMetaBlob.UP); + SafeTexture aBack = SafeTexture.register(aMetaBlob.NORTH); + SafeTexture aFont = SafeTexture.register(aMetaBlob.SOUTH); + SafeTexture aWest = SafeTexture.register(aMetaBlob.WEST); + SafeTexture aEast = SafeTexture.register(aMetaBlob.EAST); + // Store them in an Array + SafeTexture[] aInjectBlob = new SafeTexture[] { + aBottom, + aTop, + aBack, + aFont, + aWest, + aEast + }; + // Convenience Blob + CubicObject<SafeTexture> aMetaBlob2 = new CubicObject<SafeTexture>(aInjectBlob); + // Store this Blob into + mSidedTextureArray.put(aMetaBlob2); + Logger.INFO("[TeTexture] Added SafeTexture data to map for meta "+(aIndex++)); + } + Logger.INFO("[TeTexture] Map size for registration: "+mSidedTextureArray.size()); + + + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerBlockIcons(final IIconRegister aRegisterer){ + this.blockIcon = aRegisterer.registerIcon(CORE.MODID + ":" + "net"); + } + + @Override + public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); + + /** + * Called when {@link #breakBlock}() is called, but before {@link InventoryUtils#dropInventoryItems} and the super call. + */ + public void onBlockBreak() { + + } + + @Override + public final void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + onBlockBreak(); + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public final void getSubBlocks(Item aItem, CreativeTabs p_149666_2_, List aList) { + if (hasMeta()) { + for (int i=0;i<getMetaCount();i++) { + aList.add(ItemUtils.simpleMetaStack(aItem, i, 1)); + } + } + else { + aList.add(ItemUtils.getSimpleStack(aItem)); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + + + /** + * Get the block's damage value (for use with pick block). + */ + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + int l = aWorld.getBlockMetadata(aX, aY, aZ); + return l; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java index 8310fa3c23..c0113e869b 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -175,7 +175,7 @@ public class BlockBaseModular extends BasicBlock { } } metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); - int tier = this.blockMaterial.vTier; + int tier = blockMaterial != null ? this.blockMaterial.vTier : 0; String aType = (this.thisBlock == BlockTypes.FRAME) ? "frameGt" : (tier <= 4 ? "block1" : "block5"); this.blockIcon = iIcon.registerIcon("gregtech" + ":" + "materialicons/"+ metType +"/" + aType); } diff --git a/src/Java/gtPlusPlus/core/block/general/MiningExplosives.java b/src/Java/gtPlusPlus/core/block/general/MiningExplosives.java index 45345ef176..8925962e4e 100644 --- a/src/Java/gtPlusPlus/core/block/general/MiningExplosives.java +++ b/src/Java/gtPlusPlus/core/block/general/MiningExplosives.java @@ -165,8 +165,8 @@ public class MiningExplosives extends BlockTNT { /*this.blockIcon = iconRegister.registerIcon(this.getTextureName() + "_side"); this.textureTop = iconRegister.registerIcon(this.getTextureName() + "_top"); this.textureBottom = iconRegister.registerIcon(this.getTextureName() + "_bottom");*/ - this.blockIcon = iconRegister.registerIcon(CORE.MODID + ":" + "Chrono/" + "MetalSheet2"); - this.textureTop = iconRegister.registerIcon(CORE.MODID + ":" + "Chrono/" + "MetalFunnel"); - this.textureBottom = iconRegister.registerIcon(CORE.MODID + ":" + "Chrono/" + "MetalPanel"); + this.blockIcon = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalSheet2"); + this.textureTop = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalFunnel"); + this.textureBottom = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalPanel"); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/CircuitProgrammer.java b/src/Java/gtPlusPlus/core/block/machine/CircuitProgrammer.java index 6ae1a52aba..7d8b3eb708 100644 --- a/src/Java/gtPlusPlus/core/block/machine/CircuitProgrammer.java +++ b/src/Java/gtPlusPlus/core/block/machine/CircuitProgrammer.java @@ -1,42 +1,27 @@ package gtPlusPlus.core.block.machine; -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; import gregtech.common.items.GT_MetaGenerated_Tool_01; -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.minecraft.CubicObject; +import gtPlusPlus.core.block.base.BasicTileBlockWithTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; +import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.GTplusplus; -import gtPlusPlus.api.interfaces.ITileTooltip; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.handler.GuiHandler; -import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; -import gtPlusPlus.core.util.minecraft.InventoryUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; - -public class CircuitProgrammer extends BlockContainer implements ITileTooltip -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; +public class CircuitProgrammer extends BasicTileBlockWithTooltip { /** * Determines which tooltip is displayed within the itemblock. @@ -51,33 +36,7 @@ public class CircuitProgrammer extends BlockContainer implements ITileTooltip @SuppressWarnings("deprecation") public CircuitProgrammer(){ super(Material.iron); - this.setHardness(5f); - this.setResistance(1f); - this.setBlockName("blockCircuitProgrammer"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockCircuitProgrammer"); LanguageRegistry.addName(this, "Circuit Programmer"); - - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) - { - return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : (this.textureFront)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_G"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I"); } /** @@ -142,12 +101,6 @@ public class CircuitProgrammer extends BlockContainer implements ITileTooltip } @Override - public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { - InventoryUtils.dropInventoryItems(world, x, y, z, block); - super.breakBlock(world, x, y, z, block, number); - } - - @Override public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { if (stack.hasDisplayName()) { ((TileEntityCircuitProgrammer) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); @@ -159,4 +112,48 @@ public class CircuitProgrammer extends BlockContainer implements ITileTooltip return false; } + @Override + public int getMetaCount() { + return 0; + } + + @Override + public String getUnlocalBlockName() { + return "blockCircuitProgrammer"; + } + + @Override + protected float initBlockHardness() { + return 5f; + } + + @Override + protected float initBlockResistance() { + return 1f; + } + + @Override + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; + } + + @Override + protected String getTileEntityName() { + return "Circuit Programmer"; + } + + @Override + public CubicObject<String>[] getCustomTextureDirectoryObject() { + String[] aTexData = new String[] { + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_G", + CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I" + }; + CubicObject<String>[] aTextureData = new CubicObject[] {new CubicObject<String>(aTexData)}; + return aTextureData; + } + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_PestKiller.java b/src/Java/gtPlusPlus/core/block/machine/Machine_PestKiller.java new file mode 100644 index 0000000000..11fa80f439 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_PestKiller.java @@ -0,0 +1,137 @@ +package gtPlusPlus.core.block.machine; + +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; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +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.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class Machine_PestKiller extends BlockContainer implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 6; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public Machine_PestKiller() + { + super(Material.wood); + this.setBlockName("blockPestKiller"); + this.setHardness(5f); + this.setResistance(1f); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockPestKiller"); + LanguageRegistry.addName(this, "Pest Killer"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int aSide, final int p_149691_2_) + { + return aSide == 1 ? this.textureTop : (aSide == 0 ? this.textureBottom : this.textureFront); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_PESTKILLER_TOP"); + this.textureBottom = p_149651_1_.registerIcon("planks_acacia"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityPestKiller)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI15, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityPestKiller(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityPestKiller) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java b/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java new file mode 100644 index 0000000000..dc87b885b9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java @@ -0,0 +1,131 @@ +package gtPlusPlus.core.block.machine; + +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.CubicObject; +import gtPlusPlus.core.block.base.BasicTileBlockWithTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockRoundRobinator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class Machine_RoundRobinator extends BasicTileBlockWithTooltip { + + + public Machine_RoundRobinator(){ + super(Material.iron); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + else { + + boolean mDidScrewDriver = false; + // Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + if (ItemUtils.isToolScrewdriver(mHandStack)) { + final TileEntityRoundRobinator tile = (TileEntityRoundRobinator) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + } + } + catch (final Throwable t) {} + + if (!mDidScrewDriver) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityRoundRobinator)){ + return ((TileEntityRoundRobinator) te).onRightClick((byte) side, player, x, y, z); + } + return false; + } + else { + return true; + } + } + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityRoundRobinator(); + } + + @Override + public int getMetaCount() { + return 5; + } + + @Override + public String getUnlocalBlockName() { + return "blockRoundRobinator"; + } + + @Override + protected float initBlockHardness() { + return 1; + } + + @Override + protected float initBlockResistance() { + return 1; + } + + @Override + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; + } + + @Override + public int getTooltipID() { + return -1; + } + + @Override + protected String getTileEntityName() { + return "Round Robinator"; + } + + @Override + public Class<? extends ItemBlock> getItemBlockClass() { + return ItemBlockRoundRobinator.class; + } + + @Override + public CubicObject<String>[] getCustomTextureDirectoryObject() { + AutoMap<String[]> aTemp = new AutoMap<String[]>(); + for (int i=0;i<5;i++) { + String[] aTexData = new String[] { + CORE.MODID + ":" + "TileEntities/RoundRobinator/Top_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Top_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + }; + aTemp.put(aTexData); + } + AutoMap<CubicObject<String>> aTemp2 = new AutoMap<CubicObject<String>>(); + for (String[] y : aTemp) { + aTemp2.put(new CubicObject<String>(y)); + } + CubicObject<String>[] aTextureData = new CubicObject[] {aTemp2.get(0), aTemp2.get(1), aTemp2.get(2), aTemp2.get(3), aTemp2.get(4)}; + return aTextureData; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/client/model/ModelBatKing.java b/src/Java/gtPlusPlus/core/client/model/ModelBatKing.java new file mode 100644 index 0000000000..ac64dee26a --- /dev/null +++ b/src/Java/gtPlusPlus/core/client/model/ModelBatKing.java @@ -0,0 +1,120 @@ +package gtPlusPlus.core.client.model; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.entity.monster.EntityBatKing; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelBatKing extends ModelBase +{ + private ModelRenderer batHead; + /** The body box of the bat model. */ + private ModelRenderer batBody; + /** The inner right wing box of the bat model. */ + private ModelRenderer batRightWing; + /** The inner left wing box of the bat model. */ + private ModelRenderer batLeftWing; + /** The outer right wing box of the bat model. */ + private ModelRenderer batOuterRightWing; + /** The outer left wing box of the bat model. */ + private ModelRenderer batOuterLeftWing; + + public ModelBatKing() + { + this.textureWidth = 64; + this.textureHeight = 64; + + this.batHead = new ModelRenderer(this, 0, 0); + this.batHead.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6); + ModelRenderer modelrenderer = new ModelRenderer(this, 24, 0); + modelrenderer.addBox(-4.0F, -6.0F, -2.0F, 3, 4, 1); + this.batHead.addChild(modelrenderer); + ModelRenderer modelrenderer1 = new ModelRenderer(this, 24, 0); + modelrenderer1.mirror = true; + modelrenderer1.addBox(1.0F, -6.0F, -2.0F, 3, 4, 1); + this.batHead.addChild(modelrenderer1); + this.batBody = new ModelRenderer(this, 0, 16); + this.batBody.addBox(-3.0F, 4.0F, -3.0F, 6, 12, 6); + this.batBody.setTextureOffset(0, 34).addBox(-5.0F, 16.0F, 0.0F, 10, 6, 1); + this.batRightWing = new ModelRenderer(this, 42, 0); + this.batRightWing.addBox(-12.0F, 1.0F, 1.5F, 10, 16, 1); + this.batOuterRightWing = new ModelRenderer(this, 24, 16); + this.batOuterRightWing.setRotationPoint(-12.0F, 1.0F, 1.5F); + this.batOuterRightWing.addBox(-8.0F, 1.0F, 0.0F, 8, 12, 1); + this.batLeftWing = new ModelRenderer(this, 42, 0); + this.batLeftWing.mirror = true; + this.batLeftWing.addBox(2.0F, 1.0F, 1.5F, 10, 16, 1); + this.batOuterLeftWing = new ModelRenderer(this, 24, 16); + this.batOuterLeftWing.mirror = true; + this.batOuterLeftWing.setRotationPoint(12.0F, 1.0F, 1.5F); + this.batOuterLeftWing.addBox(0.0F, 1.0F, 0.0F, 8, 12, 1); + this.batBody.addChild(this.batRightWing); + this.batBody.addChild(this.batLeftWing); + this.batRightWing.addChild(this.batOuterRightWing); + this.batLeftWing.addChild(this.batOuterLeftWing); + } + + /** + * not actually sure this is size, is not used as of now, but the model would be recreated if the value changed and + * it seems a good match for a bats size + */ + public int getBatSize() + { + return 72; + } + + /** + * Sets the models various rotation angles then renders the model. + */ + public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) + { + EntityBatKing entitybat = (EntityBatKing)p_78088_1_; + float f6; + + if (entitybat.getIsBatHanging()) + { + f6 = (180F / (float)Math.PI); + this.batHead.rotateAngleX = p_78088_6_ / (180F / (float)Math.PI); + this.batHead.rotateAngleY = (float)Math.PI - p_78088_5_ / (180F / (float)Math.PI); + this.batHead.rotateAngleZ = (float)Math.PI; + this.batHead.setRotationPoint(0.0F, -2.0F, 0.0F); + this.batRightWing.setRotationPoint(-3.0F, 0.0F, 3.0F); + this.batLeftWing.setRotationPoint(3.0F, 0.0F, 3.0F); + this.batBody.rotateAngleX = (float)Math.PI; + this.batRightWing.rotateAngleX = -0.15707964F; + this.batRightWing.rotateAngleY = -((float)Math.PI * 2F / 5F); + this.batOuterRightWing.rotateAngleY = -1.7278761F; + this.batLeftWing.rotateAngleX = this.batRightWing.rotateAngleX; + this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY; + this.batOuterLeftWing.rotateAngleY = -this.batOuterRightWing.rotateAngleY; + } + else + { + f6 = (180F / (float)Math.PI); + this.batHead.rotateAngleX = p_78088_6_ / (180F / (float)Math.PI); + this.batHead.rotateAngleY = p_78088_5_ / (180F / (float)Math.PI); + this.batHead.rotateAngleZ = 0.0F; + this.batHead.setRotationPoint(0.0F, 0.0F, 0.0F); + this.batRightWing.setRotationPoint(0.0F, 0.0F, 0.0F); + this.batLeftWing.setRotationPoint(0.0F, 0.0F, 0.0F); + this.batBody.rotateAngleX = ((float)Math.PI / 4F) + MathHelper.cos(p_78088_4_ * 0.1F) * 0.15F; + this.batBody.rotateAngleY = 0.0F; + this.batRightWing.rotateAngleY = MathHelper.cos(p_78088_4_ * 1.3F) * (float)Math.PI * 0.25F; + this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY; + this.batOuterRightWing.rotateAngleY = this.batRightWing.rotateAngleY * 0.5F; + this.batOuterLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY * 0.5F; + } + + + GL11.glScalef(4, 4, 4); + this.batHead.render(p_78088_7_); + this.batBody.render(p_78088_7_); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java b/src/Java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java new file mode 100644 index 0000000000..f40357495a --- /dev/null +++ b/src/Java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java @@ -0,0 +1,85 @@ +package gtPlusPlus.core.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + + +/** + * Easy way of rendering an item which should look like a block. + * Borrowed. + * + * @author King Lemming + * + */ +public class CustomItemBlockRenderer implements IItemRenderer { + + public static CustomItemBlockRenderer instance = new CustomItemBlockRenderer(); + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return true; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + + double offset = -0.5; + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + offset = 0; + } else if (type == ItemRenderType.ENTITY) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + renderItemAsBlock((RenderBlocks) data[0], item, offset, offset, offset); + } + + public static void renderItemAsBlock(RenderBlocks renderer, ItemStack item, double translateX, double translateY, double translateZ) { + + renderTextureAsBlock(renderer, item.getIconIndex(), translateX, translateY, translateZ); + } + + public static void renderTextureAsBlock(RenderBlocks renderer, IIcon texture, double translateX, double translateY, double translateZ) { + + Tessellator tessellator = Tessellator.instance; + Block block = Blocks.stone; + + if (texture == null) { + return; + } + renderer.setRenderBoundsFromBlock(block); + GL11.glTranslated(translateX, translateY, translateZ); + tessellator.startDrawingQuads(); + + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.draw(); + } + +} diff --git a/src/Java/gtPlusPlus/core/client/renderer/RenderBatKing.java b/src/Java/gtPlusPlus/core/client/renderer/RenderBatKing.java index fb260eedeb..000badb80f 100644 --- a/src/Java/gtPlusPlus/core/client/renderer/RenderBatKing.java +++ b/src/Java/gtPlusPlus/core/client/renderer/RenderBatKing.java @@ -1,21 +1,23 @@ package gtPlusPlus.core.client.renderer; +import org.lwjgl.opengl.GL11; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.model.ModelBat; +import gtPlusPlus.core.client.model.ModelBatKing; +import gtPlusPlus.core.entity.monster.EntityBatKing; +import gtPlusPlus.core.lib.CORE; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.passive.EntityBat; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class RenderBatKing extends RenderLiving { - private static final ResourceLocation batTextures = new ResourceLocation("textures/entity/bat.png"); + private static final ResourceLocation batTextures = new ResourceLocation(CORE.MODID+":"+"textures/entity/batKing.png"); /** * not actually sure this is size, is not used as of now, but the model would be @@ -24,8 +26,8 @@ public class RenderBatKing extends RenderLiving { private int renderedBatSize; public RenderBatKing() { - super(new ModelBat(), 1F); - this.renderedBatSize = ((ModelBat) this.mainModel).getBatSize(); + super(new ModelBatKing(), 0.7F); + this.renderedBatSize = (((ModelBatKing) this.mainModel).getBatSize()); } /** @@ -36,13 +38,13 @@ public class RenderBatKing extends RenderLiving { * func_76986_a(T entity, double d, double d1, double d2, float f, float f1). * But JAD is pre 1.5 so doesn't do that. */ - public void doRender(EntityBat p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, + public void doRender(EntityBatKing p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - int i = ((ModelBat) this.mainModel).getBatSize(); + int i = ((ModelBatKing) this.mainModel).getBatSize(); if (i != this.renderedBatSize) { this.renderedBatSize = i; - this.mainModel = new ModelBat(); + this.mainModel = new ModelBatKing(); } super.doRender((EntityLiving) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); @@ -52,7 +54,7 @@ public class RenderBatKing extends RenderLiving { * Returns the location of an entity's texture. Doesn't seem to be called unless * you call Render.bindEntityTexture. */ - protected ResourceLocation getEntityTexture(EntityBat p_110775_1_) { + protected ResourceLocation getEntityTexture(EntityBatKing p_110775_1_) { return batTextures; } @@ -60,18 +62,18 @@ public class RenderBatKing extends RenderLiving { * Allows the render to do any OpenGL state modifications necessary before the * model is rendered. Args: entityLiving, partialTickTime */ - protected void preRenderCallback(EntityBat p_77041_1_, float p_77041_2_) { + protected void preRenderCallback(EntityBatKing p_77041_1_, float p_77041_2_) { GL11.glScalef(0.35F, 0.35F, 0.35F); } /** * Sets a simple glTranslate on a LivingEntity. */ - protected void renderLivingAt(EntityBat p_77039_1_, double p_77039_2_, double p_77039_4_, double p_77039_6_) { + protected void renderLivingAt(EntityBatKing p_77039_1_, double p_77039_2_, double p_77039_4_, double p_77039_6_) { super.renderLivingAt(p_77039_1_, p_77039_2_, p_77039_4_, p_77039_6_); } - protected void rotateCorpse(EntityBat p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { + protected void rotateCorpse(EntityBatKing p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { if (!p_77043_1_.getIsBatHanging()) { GL11.glTranslatef(0.0F, MathHelper.cos(p_77043_2_ * 0.3F) * 0.1F, 0.0F); } else { @@ -91,7 +93,7 @@ public class RenderBatKing extends RenderLiving { */ public void doRender(EntityLiving p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - this.doRender((EntityBat) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + this.doRender((EntityBatKing) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } /** @@ -99,11 +101,11 @@ public class RenderBatKing extends RenderLiving { * model is rendered. Args: entityLiving, partialTickTime */ protected void preRenderCallback(EntityLivingBase p_77041_1_, float p_77041_2_) { - this.preRenderCallback((EntityBat) p_77041_1_, p_77041_2_); + this.preRenderCallback((EntityBatKing) p_77041_1_, p_77041_2_); } protected void rotateCorpse(EntityLivingBase p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { - this.rotateCorpse((EntityBat) p_77043_1_, p_77043_2_, p_77043_3_, p_77043_4_); + this.rotateCorpse((EntityBatKing) p_77043_1_, p_77043_2_, p_77043_3_, p_77043_4_); } /** @@ -111,7 +113,7 @@ public class RenderBatKing extends RenderLiving { */ protected void renderLivingAt(EntityLivingBase p_77039_1_, double p_77039_2_, double p_77039_4_, double p_77039_6_) { - this.renderLivingAt((EntityBat) p_77039_1_, p_77039_2_, p_77039_4_, p_77039_6_); + this.renderLivingAt((EntityBatKing) p_77039_1_, p_77039_2_, p_77039_4_, p_77039_6_); } /** @@ -124,7 +126,7 @@ public class RenderBatKing extends RenderLiving { */ public void doRender(EntityLivingBase p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - this.doRender((EntityBat) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + this.doRender((EntityBatKing) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } /** @@ -132,7 +134,7 @@ public class RenderBatKing extends RenderLiving { * you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return this.getEntityTexture((EntityBat) p_110775_1_); + return this.getEntityTexture((EntityBatKing) p_110775_1_); } /** @@ -145,6 +147,6 @@ public class RenderBatKing extends RenderLiving { */ public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - this.doRender((EntityBat) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + this.doRender((EntityBatKing) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java b/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java index 3a7d4461f4..5b9c17bacf 100644 --- a/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java +++ b/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java @@ -7,6 +7,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.preloader.asm.AsmConfig; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; @@ -33,6 +34,9 @@ public class CommandEnableDebugWhileRunning implements ICommand } + + // Use '/debugmodegtpp' along with 'logging' or 'debug' to toggle Debug mode and Logging. + // Using nothing after the command toggles both to their opposite states respectively. @Override public String getCommandUsage(final ICommandSender var1){ return "/debugmodegtpp"; @@ -47,16 +51,44 @@ public class CommandEnableDebugWhileRunning implements ICommand @Override public void processCommand(final ICommandSender S, final String[] argString){ - Logger.INFO("Toggling Debug Mode"); - final World W = S.getEntityWorld(); - final EntityPlayer P = CommandUtils.getPlayer(S); - - if (PlayerUtils.isPlayerOP(P)) { - CORE.DEBUG = Utils.invertBoolean(CORE.DEBUG); - PlayerUtils.messagePlayer(P, "Toggled GT++ Debug Mode - Enabled: "+CORE.DEBUG); + if (argString == null || argString.length == 0 || argString.length > 1) { + Logger.INFO("Toggling Debug Mode & Logging."); + final EntityPlayer P = CommandUtils.getPlayer(S); + if (PlayerUtils.isPlayerOP(P)) { + CORE.DEBUG = Utils.invertBoolean(CORE.DEBUG); + PlayerUtils.messagePlayer(P, "Toggled GT++ Debug Mode - Enabled: "+CORE.DEBUG); + AsmConfig.disableAllLogging = Utils.invertBoolean(AsmConfig.disableAllLogging); + PlayerUtils.messagePlayer(P, "Toggled GT++ Logging - Enabled: "+(!AsmConfig.disableAllLogging)); + } + } + else { + if (argString[0].toLowerCase().equals("debug")) { + Logger.INFO("Toggling Debug Mode."); + final EntityPlayer P = CommandUtils.getPlayer(S); + if (PlayerUtils.isPlayerOP(P)) { + CORE.DEBUG = Utils.invertBoolean(CORE.DEBUG); + PlayerUtils.messagePlayer(P, "Toggled GT++ Debug Mode - Enabled: "+CORE.DEBUG); + } + } + else if (argString[0].toLowerCase().equals("logging")) { + Logger.INFO("Toggling Logging."); + final EntityPlayer P = CommandUtils.getPlayer(S); + if (PlayerUtils.isPlayerOP(P)) { + AsmConfig.disableAllLogging = Utils.invertBoolean(AsmConfig.disableAllLogging); + PlayerUtils.messagePlayer(P, "Toggled GT++ Logging - Enabled: "+(!AsmConfig.disableAllLogging)); + } + } + else { + final EntityPlayer P = CommandUtils.getPlayer(S); + if (PlayerUtils.isPlayerOP(P)) { + PlayerUtils.messagePlayer(P, "Invalid command, use 'debug' or 'logging'"); + } + } } + + } @Override diff --git a/src/Java/gtPlusPlus/core/common/BasePlayer.java b/src/Java/gtPlusPlus/core/common/BasePlayer.java index 1b3f67b8d6..4686f34207 100644 --- a/src/Java/gtPlusPlus/core/common/BasePlayer.java +++ b/src/Java/gtPlusPlus/core/common/BasePlayer.java @@ -1,19 +1,14 @@ package gtPlusPlus.core.common; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.entity.EntityClientPlayerMP; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.network.play.client.C0BPacketEntityAction; -import net.minecraft.potion.Potion; -import net.minecraft.util.MovementInputFromOptions; -import net.minecraft.util.ResourceLocation; - import api.player.client.ClientPlayerAPI; import api.player.client.ClientPlayerBase; import gtPlusPlus.core.handler.events.CustomMovementHandler; import gtPlusPlus.core.handler.events.SneakManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.util.MovementInputFromOptions; public class BasePlayer extends ClientPlayerBase { @@ -30,8 +25,17 @@ public class BasePlayer extends ClientPlayerBase * EntityPlayerSP.onLivingUpdate() - Adapted to PlayerAPI */ @Override - public void onLivingUpdate() - { + public void onLivingUpdate() { + + super.onLivingUpdate(); + EntityPlayer aPlayer = this.player; + if (aPlayer != null) { + SneakManager aSneak = SneakManager.get(aPlayer); + if (!aSneak.isWearingRing()) { + return; + } + } + if(this.player.sprintingTicksLeft > 0) { --this.player.sprintingTicksLeft; @@ -57,54 +61,9 @@ public class BasePlayer extends ClientPlayerBase } else { - this.player.prevTimeInPortal = this.player.timeInPortal; - if(this.playerAPI.getInPortalField()) - { - if(this.mc.currentScreen != null) - { - this.mc.displayGuiScreen((GuiScreen)null); - } - if(this.player.timeInPortal == 0.0F) - { - this.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("portal.trigger"), (this.player.getRNG().nextFloat() * 0.4F) + 0.8F)); - } - this.player.timeInPortal += 0.0125F; - - if(this.player.timeInPortal >= 1.0F) - { - this.player.timeInPortal = 1.0F; - } - - this.playerAPI.setInPortalField(false); - } - else if(this.player.isPotionActive(Potion.confusion) && (this.player.getActivePotionEffect(Potion.confusion).getDuration() > 60)) - { - this.player.timeInPortal += 0.006666667F; - if(this.player.timeInPortal > 1.0F) - { - this.player.timeInPortal = 1.0F; - } - } - else - { - if(this.player.timeInPortal > 0.0F) - { - this.player.timeInPortal -= 0.05F; - } - - if(this.player.timeInPortal < 0.0F) - { - this.player.timeInPortal = 0.0F; - } - } - - - if(this.player.timeUntilPortal > 0) - { - --this.player.timeUntilPortal; - } + final boolean isJumping = this.player.movementInput.jump; @@ -112,44 +71,29 @@ public class BasePlayer extends ClientPlayerBase final boolean isMovingForward = this.player.movementInput.moveForward >= minSpeed; this.customMovementInput.update(this.mc, (MovementInputFromOptions)this.player.movementInput, this.player); - if(this.player.isUsingItem() && !this.player.isRiding()) - { - this.player.movementInput.moveStrafe *= 0.2F; - this.player.movementInput.moveForward *= 0.2F; - this.playerAPI.setSprintToggleTimerField(0); - } - - if(this.player.movementInput.sneak && (this.player.ySize < 0.2F)) - { - this.player.ySize = 0.2F; - } - - this.playerAPI.localPushOutOfBlocks(this.player.posX - (this.player.width * 0.35D), this.player.boundingBox.minY + 0.5D, this.player.posZ + (this.player.width * 0.35D)); - this.playerAPI.localPushOutOfBlocks(this.player.posX - (this.player.width * 0.35D), this.player.boundingBox.minY + 0.5D, this.player.posZ - (this.player.width * 0.35D)); - this.playerAPI.localPushOutOfBlocks(this.player.posX + (this.player.width * 0.35D), this.player.boundingBox.minY + 0.5D, this.player.posZ - (this.player.width * 0.35D)); - this.playerAPI.localPushOutOfBlocks(this.player.posX + (this.player.width * 0.35D), this.player.boundingBox.minY + 0.5D, this.player.posZ + (this.player.width * 0.35D)); - final boolean enoughHunger = (this.player.getFoodStats().getFoodLevel() > 6.0F) || this.player.capabilities.isFlying; /* * Begin ToggleSneak Changes - ToggleSprint */ + SneakManager aSneak = SneakManager.get(this.player); final boolean isSprintDisabled = false; - final boolean canDoubleTap = SneakManager.optionDoubleTap; + final boolean canDoubleTap = aSneak.optionDoubleTap; + // Detect when ToggleSprint was disabled in the in-game options menu - if(SneakManager.wasSprintDisabled) + if(aSneak.wasSprintDisabled) { this.player.setSprinting(false); - this.customMovementInput.UpdateSprint(false, false); - SneakManager.wasSprintDisabled = false; + this.customMovementInput.UpdateSprint(false, false, aSneak); + aSneak.wasSprintDisabled = false; } // Default Sprint routine converted to PlayerAPI, use if ToggleSprint is disabled - TODO - Disable sprinting as a whole if(isSprintDisabled) { //Utils.LOG_INFO("Sprint pressed"); - if(SneakManager.optionDoubleTap && this.player.onGround && !isMovingForward && (this.player.movementInput.moveForward >= minSpeed) && !this.player.isSprinting() && enoughHunger && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness)) + if(aSneak.optionDoubleTap && this.player.onGround && !isMovingForward && (this.player.movementInput.moveForward >= minSpeed) && !this.player.isSprinting() && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness)) { if((this.playerAPI.getSprintToggleTimerField() <= 0) && !this.settings.keyBindSprint.getIsKeyPressed()) { @@ -157,26 +101,26 @@ public class BasePlayer extends ClientPlayerBase } else { - if (SneakManager.Sprinting()){ + if (aSneak.Sprinting()){ this.player.setSprinting(true); - this.customMovementInput.UpdateSprint(true, false); + this.customMovementInput.UpdateSprint(true, false, aSneak); } else { this.player.setSprinting(false); - this.customMovementInput.UpdateSprint(false, false); + this.customMovementInput.UpdateSprint(false, false, aSneak); } } } - if(!this.player.isSprinting() && (this.player.movementInput.moveForward >= minSpeed) && enoughHunger && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness) && this.settings.keyBindSprint.getIsKeyPressed()) + if(!this.player.isSprinting() && (this.player.movementInput.moveForward >= minSpeed) && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness) && this.settings.keyBindSprint.getIsKeyPressed()) { - if (SneakManager.Sprinting()){ + if (aSneak.Sprinting()){ this.player.setSprinting(true); - this.customMovementInput.UpdateSprint(true, false); + this.customMovementInput.UpdateSprint(true, false, aSneak); } else { this.player.setSprinting(false); - this.customMovementInput.UpdateSprint(false, false); + this.customMovementInput.UpdateSprint(false, false, aSneak); } } } @@ -190,11 +134,11 @@ public class BasePlayer extends ClientPlayerBase // 5/6/14 - onGround check removed to match vanilla's 'start sprint while jumping' behavior. //if(this.player.onGround && enoughHunger && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness) && !this.customMovementInput.sprintHeldAndReleased) - if(enoughHunger && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness) && !this.customMovementInput.sprintHeldAndReleased) + if(!this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness) && !this.customMovementInput.sprintHeldAndReleased) { if((canDoubleTap && !this.player.isSprinting()) || !canDoubleTap) { - if (SneakManager.Sprinting()){ + if (aSneak.Sprinting()){ this.player.setSprinting(state); } else { this.player.setSprinting(false); @@ -202,7 +146,7 @@ public class BasePlayer extends ClientPlayerBase } } - if(canDoubleTap && !state && this.player.onGround && !isMovingForward && (this.player.movementInput.moveForward >= minSpeed) && !this.player.isSprinting() && enoughHunger && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness)) + if(canDoubleTap && !state && this.player.onGround && !isMovingForward && (this.player.movementInput.moveForward >= minSpeed) && !this.player.isSprinting() && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness)) { if(this.playerAPI.getSprintToggleTimerField() == 0) { @@ -210,9 +154,9 @@ public class BasePlayer extends ClientPlayerBase } else { - if (SneakManager.Sprinting()){ + if (aSneak.Sprinting()){ this.player.setSprinting(true); - this.customMovementInput.UpdateSprint(true, true); + this.customMovementInput.UpdateSprint(true, true, aSneak); this.playerAPI.setSprintToggleTimerField(0); } } @@ -221,14 +165,14 @@ public class BasePlayer extends ClientPlayerBase // If sprinting, break the sprint in appropriate circumstances: // Player stops moving forward, runs into something, or gets too hungry - if(this.player.isSprinting() && ((this.player.movementInput.moveForward < minSpeed) || this.player.isCollidedHorizontally || !enoughHunger)) + if(this.player.isSprinting() && ((this.player.movementInput.moveForward < minSpeed) || this.player.isCollidedHorizontally)) { this.player.setSprinting(false); // Undo toggle if we resumed vanilla operation due to Hold&Release, DoubleTap, Fly, Ride if ((this.customMovementInput.sprintHeldAndReleased == true) || isSprintDisabled || this.customMovementInput.sprintDoubleTapped || this.player.capabilities.isFlying || this.player.isRiding()) { - this.customMovementInput.UpdateSprint(false, false); + this.customMovementInput.UpdateSprint(false, false, aSneak); } } @@ -263,87 +207,6 @@ public class BasePlayer extends ClientPlayerBase // this.handledDebugPress = false; // } - // - // Fly Speed Boosting - Added 5/7/2014 - // - if(this.player.capabilities.getFlySpeed() != 0.05F) - { - this.player.capabilities.setFlySpeed(0.05F); - } - - - if(this.player.capabilities.allowFlying && !isJumping && this.player.movementInput.jump) - { - if(this.playerAPI.getFlyToggleTimerField() == 0) - { - this.playerAPI.setFlyToggleTimerField(7); - } - else - { - this.player.capabilities.isFlying = !this.player.capabilities.isFlying; - this.player.sendPlayerAbilities(); - this.playerAPI.setFlyToggleTimerField(0); - } - } - - if(this.player.capabilities.isFlying) - { - if(this.player.movementInput.sneak) - { - this.player.motionY -= 0.15D; - } - if(this.player.movementInput.jump) - { - this.player.motionY += 0.15D; - } - } - - if(this.player.isRidingHorse()) - { - if(this.playerAPI.getHorseJumpPowerCounterField() < 0) - { - this.playerAPI.setHorseJumpPowerCounterField(this.playerAPI.getHorseJumpPowerCounterField() + 1); - if(this.playerAPI.getHorseJumpPowerCounterField() == 0) - { - this.playerAPI.setHorseJumpPowerField(0.0F); - } - } - - if(isJumping && !this.player.movementInput.jump) - { - this.playerAPI.setHorseJumpPowerCounterField(this.playerAPI.getHorseJumpPowerCounterField() - 10); - this.playerAPI.setHorseJumpPowerCounterField(-10); - ((EntityClientPlayerMP)this.player).sendQueue.addToSendQueue(new C0BPacketEntityAction(this.player, 6, (int)(this.player.getHorseJumpPower() * 100.0F))); - } - else if(!isJumping && this.player.movementInput.jump) - { - this.playerAPI.setHorseJumpPowerCounterField(0); - this.playerAPI.setHorseJumpPowerField(0.0F); - } - else if(isJumping) - { - this.playerAPI.setHorseJumpPowerCounterField(this.playerAPI.getHorseJumpPowerCounterField() + 1); - if(this.playerAPI.getHorseJumpPowerCounterField() < 10) - { - this.playerAPI.setHorseJumpPowerField(this.playerAPI.getHorseJumpPowerCounterField() * 0.1F); - } - else - { - this.playerAPI.setHorseJumpPowerField(0.8F + ((2.0F / (this.playerAPI.getHorseJumpPowerCounterField() - 9)) * 0.1F)); - } - } - } - else - { - this.playerAPI.setHorseJumpPowerField(0.0F); - } - - this.playerAPI.superOnLivingUpdate(); - if(this.player.onGround && this.player.capabilities.isFlying) - { - this.player.capabilities.isFlying = false; - this.player.sendPlayerAbilities(); - } } } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 03b0f944b7..1ce16bf4de 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -12,6 +12,8 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.OrePrefixes; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.minecraft.ChunkManager; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.creative.AddToCreativeTab; @@ -51,12 +53,14 @@ import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner; import gtPlusPlus.xmod.eio.handler.HandlerTooltip_EIO; import gtPlusPlus.xmod.galacticraft.handler.HandlerTooltip_GC; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.thermalfoundation.item.TF_Items; +import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.common.ForgeChunkManager; public class CommonProxy { @@ -144,6 +148,8 @@ public class CommonProxy { // Block Handler for all events. Utils.registerEvent(new BlockEventHandler()); Utils.registerEvent(new GeneralTooltipEventHandler()); + // Handles Tooltips for items giving custom multiblock behaviour + Utils.registerEvent(new SpecialBehaviourTooltipHandler()); // Handles Custom tooltips for EIO. Utils.registerEvent(new HandlerTooltip_EIO()); // Handles Custom Tooltips for GC @@ -187,12 +193,22 @@ public class CommonProxy { } // Compat Handling + Logger.INFO("Removing recipes from other mods."); COMPAT_HANDLER.RemoveRecipesFromOtherMods(); + Logger.INFO("Initialising Handler, Then Adding Recipes"); COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); - COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); + Logger.INFO("Loading Intermod staging."); COMPAT_IntermodStaging.postInit(e); + Logger.INFO("Loading queued recipes."); COMPAT_HANDLER.runQueuedRecipes(); + Logger.INFO("Registering custom mob drops."); registerCustomMobDrops(); + + // Moved last in postInit(). + // 12/12/19 - Alkalus + // Moved last, to prevent recipes being generated post initialisation. + Logger.INFO("Loading Gregtech API recipes."); + COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); } public void serverStarting(final FMLServerStartingEvent e) { @@ -258,7 +274,7 @@ public class CommonProxy { //Special mobs Support if (ReflectionUtils.doesClassExist("toast.specialMobs.entity.zombie.EntityBrutishZombie")) { - Class aBrutishZombie = ReflectionUtils.getClass("toast.specialMobs.entity.zombie.EntityBrutishZombie"); + Class<?> aBrutishZombie = ReflectionUtils.getClass("toast.specialMobs.entity.zombie.EntityBrutishZombie"); ItemStack aFortune1 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); ItemStack aFortune2 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); ItemStack aFortune3 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); @@ -268,8 +284,45 @@ public class CommonProxy { EntityUtils.registerDropsForMob(aBrutishZombie, ItemUtils.getItemStackOfAmountFromOreDict("ingotRedAlloy", 1), 3, 200); } + //GalaxySpace Support + if (ReflectionUtils.doesClassExist("galaxyspace.SolarSystem.moons.europa.entities.EntityEvolvedColdBlaze")) { + Class<?> aColdBlaze = ReflectionUtils.getClass("galaxyspace.SolarSystem.moons.europa.entities.EntityEvolvedColdBlaze"); + ItemStack aSmallBlizz, aTinyBlizz, aSmallCryo, aTinyCryo; + aSmallBlizz = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallBlizz", 1); + aTinyBlizz = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyBlizz", 1); + aSmallCryo = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallCryotheum", 1); + aTinyCryo = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyCryotheum", 1); + EntityUtils.registerDropsForMob(aColdBlaze, ItemUtils.getItemStackOfAmountFromOreDict("stickBlizz", 1), 2, 500); + if (aSmallBlizz != null) { + EntityUtils.registerDropsForMob(aColdBlaze, aSmallBlizz, 2, 750); + } + if (aTinyBlizz != null) { + EntityUtils.registerDropsForMob(aColdBlaze, aTinyBlizz, 4, 1500); + } + if (aSmallCryo != null) { + EntityUtils.registerDropsForMob(aColdBlaze, aSmallCryo, 1, 50); + } + if (aTinyCryo != null) { + EntityUtils.registerDropsForMob(aColdBlaze, aTinyCryo, 2, 100); + } + } - + } + + protected final AutoMap<Pair<Item, IItemRenderer>> mItemRenderMappings = new AutoMap<Pair<Item, IItemRenderer>>(); + + + public static void registerItemRendererGlobal(Item aItem, IItemRenderer aRenderer) { + GTplusplus.proxy.registerItemRenderer(aItem, aRenderer); + } + + public void registerItemRenderer(Item aItem, IItemRenderer aRenderer) { + if (Utils.isServer()) { + return; + } + else { + mItemRenderMappings.add(new Pair<Item, IItemRenderer>(aItem, aRenderer)); + } } } diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java index 06467503d8..12b3a94083 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java @@ -23,7 +23,7 @@ public class COMPAT_PlayerAPI { public static class clientProxy{ public static void initPre(){ - Utils.registerEvent(SneakManager.instance); + //Utils.registerEvent(SneakManager.instance); } public static void Init(){ diff --git a/src/Java/gtPlusPlus/core/config/ConfigHandler.java b/src/Java/gtPlusPlus/core/config/ConfigHandler.java index 89c1324a54..ecaf031030 100644 --- a/src/Java/gtPlusPlus/core/config/ConfigHandler.java +++ b/src/Java/gtPlusPlus/core/config/ConfigHandler.java @@ -176,6 +176,7 @@ public class ConfigHandler { "Enables Custom GT++ Cape."); disableZombieReinforcement = config.getBoolean("disableZombieReinforcement", "features", false, "Disables Zombie Reinforcement on hard difficutly."); + enableWatchdogBGM = config.getInt("enableWatchdogBGM", "features", 0, 0, Short.MAX_VALUE, "Set to a value greater than 0 to reduce the ticks taken to delay between BGM tracks. Acceptable Values are 1-32767, where 0 is disabled. Vanilla Uses 12,000 & 24,000. 200 is 10s."); //Biomes EVERGLADES_ID = config.getInt("darkworld_ID", "worldgen", 227, 1, 254, "The ID of the Dark Dimension."); diff --git a/src/Java/gtPlusPlus/core/container/Container_PestKiller.java b/src/Java/gtPlusPlus/core/container/Container_PestKiller.java new file mode 100644 index 0000000000..2f25c5aace --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_PestKiller.java @@ -0,0 +1,154 @@ +package gtPlusPlus.core.container; + +import gregtech.api.gui.GT_Slot_Render; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.InventoryPestKiller; +import gtPlusPlus.core.slots.SlotGeneric; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +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; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidStack; + +public class Container_PestKiller extends Container { + + public TileEntityPestKiller tile_entity; + public final InventoryPestKiller inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static int StorageSlotNumber = 3; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots + + public Container_PestKiller(final InventoryPlayer inventory, final TileEntityPestKiller te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + te.openInventory(); + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + int o = 0; + + int aSlotX = 134; + + this.addSlotToContainer(new SlotGeneric(this.inventoryChest, o++, aSlotX, 10)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, aSlotX, 60)); + addSlotToContainer(new GT_Slot_Render(tile_entity, o++, aSlotX, 35)); + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + + } + + public FluidStack getFluidOfStoredTank() { + if (tile_entity != null) { + if (tile_entity.getTank() != null) { + return tile_entity.getTank().getFluid(); + } + } + return null; + } + + public int getFluidStoredAmount() { + FluidStack f = getFluidOfStoredTank(); + return f == null ? 0 : f.amount; + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + boolean fluid = false; + if (aSlotIndex == 2) { + fluid = true; + } + if (!fluid) { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + else { + return null; + } + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + tile_entity.closeInventory(); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockPestKiller) { + return false; + } + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java b/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java new file mode 100644 index 0000000000..cbd08c2cca --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java @@ -0,0 +1,246 @@ +package gtPlusPlus.core.container; + +import java.util.Iterator; + +import org.apache.commons.lang3.ArrayUtils; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.Inventory_RoundRobinator; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class Container_RoundRobinator extends Container { + + public TileEntityRoundRobinator tile_entity; + public final Inventory_RoundRobinator inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + private final boolean[] mActiveData = new boolean[] {false, false, false, false}; + + public static int mStorageSlotNumber = 4; // Number of slots in storage area + public static int mInventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int mFullSlotNumber = mInventorySlotNumber + mStorageSlotNumber; // All + // slots + + public Container_RoundRobinator(final InventoryPlayer inventory, final TileEntityRoundRobinator te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + boolean [] aTemp = te.getActiveSides(); + if (aTemp != null && aTemp.length == 4) { + for (int i=0;i<4;i++) { + mActiveData[i] = aTemp[i]; + } + } + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + + int o = 0; + int xStart = 134; + int yStart = 32; + + try { + //0 + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart, yStart)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart+18, yStart)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart, yStart+17)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart+18, yStart+17)); + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + } + catch (Throwable t) { + t.printStackTrace(); + } + this.detectAndSendChanges(); + + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if (aSlotIndex < 4) { + this.tile_entity.toggleSide(aSlotIndex+2); + //Logger.INFO("Toggling side: "+(aSlotIndex+2)+" | Active: "+this.tile_entity.getSideActive(aSlotIndex+2)+" | Data:"+this.tile_entity.getDataString()); + } + } + return GT_Values.NI; + //return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockRoundRobinator) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + + + public final void addCraftingToCrafters(ICrafting par1ICrafting) { + try { + super.addCraftingToCrafters(par1ICrafting); + } catch (Throwable var3) { + var3.printStackTrace(); + } + } + + public final void removeCraftingFromCrafters(ICrafting par1ICrafting) { + try { + super.removeCraftingFromCrafters(par1ICrafting); + } catch (Throwable var3) { + var3.printStackTrace(); + } + } + + public final void detectAndSendChanges() { + try { + super.detectAndSendChanges(); + detectAndSendChangesEx(); + } catch (Throwable var2) { + var2.printStackTrace(); + } + } + + public final void updateProgressBar(int par1, int par2) { + try { + super.updateProgressBar(par1, par2); + updateProgressBarEx(par1, par2); + } catch (Throwable var4) { + var4.printStackTrace(); + } + } + + + public int mSide_1 = 0; + public int mSide_2 = 0; + public int mSide_3 = 0; + public int mSide_4 = 0; + public int mTier = 1; + public int mTickRate = 50; + + private int oSide_1 = 0; + private int oSide_2 = 0; + private int oSide_3 = 0; + private int oSide_4 = 0; + private int oTier = 1; + private int oTickRate = 50; + + private int mTimer = 0; + + + + public void detectAndSendChangesEx() { + super.detectAndSendChanges(); + if (!this.tile_entity.getWorldObj().isRemote) { + boolean [] aTemp = tile_entity.getActiveSides(); + for (int i=0;i<4;i++) { + mActiveData[i] = aTemp[i]; + } + this.mSide_1 = aTemp[0] ? 1 : 0; + this.mSide_2 = aTemp[1] ? 1 : 0; + this.mSide_3 = aTemp[2] ? 1 : 0; + this.mSide_4 = aTemp[3] ? 1 : 0; + this.mTier = this.tile_entity.getTier(); + this.mTickRate = this.tile_entity.getTickRate(); + ++this.mTimer; + Iterator var2 = this.crafters.iterator(); + + while (true) { + ICrafting var1; + do { + if (!var2.hasNext()) { + this.oSide_1 = this.mSide_1; + this.oSide_2 = this.mSide_2; + this.oSide_3 = this.mSide_3; + this.oSide_4 = this.mSide_4; + this.oTier = this.mTier; + this.oTickRate = this.mTickRate; + return; + } + var1 = (ICrafting) var2.next(); + if (this.mTimer % 500 == 10 || this.oSide_1 != this.mSide_1) { + var1.sendProgressBarUpdate(this, 2, this.mSide_1); + } + if (this.mTimer % 500 == 10 || this.oSide_2 != this.mSide_2) { + var1.sendProgressBarUpdate(this, 4, this.mSide_2); + } + if (this.mTimer % 500 == 10 || this.oSide_3 != this.mSide_3) { + var1.sendProgressBarUpdate(this, 6, this.mSide_3); + } + if (this.mTimer % 500 == 10 || this.oSide_4 != this.mSide_4) { + var1.sendProgressBarUpdate(this, 8, this.mSide_4); + } + if (this.mTimer % 500 == 10 || this.oTier != this.mTier) { + var1.sendProgressBarUpdate(this, 10, this.mTier); + } + if (this.mTimer % 500 == 10 || this.oTickRate != this.mTickRate) { + var1.sendProgressBarUpdate(this, 12, this.mTickRate); + } + } while (this.mTimer % 500 != 10); + + } + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBarEx(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 2 : + this.mSide_1 = par2; + break; + case 4 : + this.mSide_2 = par2; + break; + case 6 : + this.mSide_3 = par2; + case 8 : + this.mSide_4 = par2; + case 10 : + this.mTier = par2; + case 12 : + this.mTickRate = par2; + break; + } + + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java b/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java index 34a4e9fa97..f9bf617e1b 100644 --- a/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java +++ b/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java @@ -191,7 +191,7 @@ public class Container_SuperJukebox extends Container { @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (tile_entity.getWorldObj().isRemote || tile_entity == null) return null; + if (tile_entity == null || tile_entity.getWorldObj().isRemote) return null; switch (aSlotIndex) { case SLOT_HOLO_PLAY: if (tile_entity == null) return null; @@ -217,7 +217,7 @@ public class Container_SuperJukebox extends Container { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if (tile_entity.getWorldObj().isRemote || tile_entity == null) return; + if (tile_entity == null || tile_entity.getWorldObj().isRemote) return; isPlaying = tile_entity.mIsPlaying; isLooping = tile_entity.mIsLooping; diff --git a/src/Java/gtPlusPlus/core/entity/ai/batking/EntityAIBatKingAttack.java b/src/Java/gtPlusPlus/core/entity/ai/batking/EntityAIBatKingAttack.java new file mode 100644 index 0000000000..52d1d6100c --- /dev/null +++ b/src/Java/gtPlusPlus/core/entity/ai/batking/EntityAIBatKingAttack.java @@ -0,0 +1,406 @@ +package gtPlusPlus.core.entity.ai.batking; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.entity.monster.EntityBatKing; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IRangedAttackMob; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.pathfinding.PathPoint; +import net.minecraft.util.MathHelper; + +public class EntityAIBatKingAttack extends EntityAIBase { + + private final Ranged mRangedAI; + private final Melee mMeleeAI; + private boolean mIsMelee = false; + + /** The Bat King in control of this AI. */ + private final EntityBatKing mAttackingEntity; + + /** The PathEntity of our entity. */ + private PathEntity mEntityPathEntity; + + /** The current target of Bat King in control of this AI. */ + private EntityLivingBase mEntityTarget; + + private final Class mClassTarget; + + public EntityAIBatKingAttack(EntityBatKing aAttacker, Class aClassTarget, + double aMovementSpeed, int someInt, int aMaxRangedAttackTime, float someFloat, boolean aLongMemory) { + mRangedAI = new Ranged(this, aMovementSpeed, someInt, 5, someFloat); + mMeleeAI = new Melee(this, aClassTarget, aMovementSpeed, aLongMemory); + mAttackingEntity = aAttacker; + mClassTarget = aClassTarget; + } + + @Override + public boolean shouldExecute() { + determineCombatStyle(); + EntityLivingBase entitylivingbase = this.mAttackingEntity.getAttackTarget(); + if (entitylivingbase == null) { + this.mEntityTarget = null; + return false; + } else if (!entitylivingbase.isEntityAlive()) { + return false; + } else if (this.mClassTarget != null && !this.mClassTarget.isAssignableFrom(entitylivingbase.getClass())) { + return false; + } else { + if (this.mIsMelee) { + return this.mMeleeAI.shouldExecute(); + } + else { + this.mEntityTarget = entitylivingbase; + this.mEntityPathEntity = this.mAttackingEntity.getNavigator().getPathToEntityLiving(entitylivingbase); + return mRangedAI != null && mMeleeAI != null && hasValidTarget(); + } + } + } + + public EntityBatKing getBatKing() { + return this.mAttackingEntity; + } + + public IRangedAttackMob getBatKingAsIRangedAttackMob() { + return this.mAttackingEntity; + } + + public boolean hasValidTarget() { + return this.mEntityTarget != null; + } + + public EntityLivingBase getTarget() { + return mEntityTarget; + } + + @Override + public boolean continueExecuting() { + determineCombatStyle(); + if (mIsMelee) { + return mMeleeAI.continueExecuting(); + } else { + return mRangedAI.continueExecuting(); + } + } + + @Override + public boolean isInterruptible() { + if (mIsMelee) { + + } else { + + } + return super.isInterruptible(); + } + + @Override + public void startExecuting() { + determineCombatStyle(); + if (mIsMelee) { + mMeleeAI.startExecuting(); + } else { + mRangedAI.startExecuting(); + } + } + + @Override + public void resetTask() { + determineCombatStyle(); + if (mIsMelee) { + mMeleeAI.resetTask(); + } else { + mRangedAI.resetTask(); + } + } + + @Override + public void updateTask() { + determineCombatStyle(); + if (mIsMelee) { + mMeleeAI.updateTask(); + } else { + mRangedAI.updateTask(); + } + } + + + private final void determineCombatStyle() { + boolean aisMeleeNow = this.mIsMelee; + if (this.mEntityTarget != null && EntityUtils.getDistance(getBatKing(), mEntityTarget) < 4) { + this.mIsMelee = true; + } + else { + this.mIsMelee = false; + } + if (aisMeleeNow != this.mIsMelee) { + Logger.INFO("Bat King changed combat style from "+(aisMeleeNow ? "Melee" : "Ranged")+" to "+(this.mIsMelee ? "Melee" : "Ranged")); + } + } + + private class Ranged { + + private final EntityAIBatKingAttack parentAI; + + /** + * A decrementing tick that spawns a ranged attack once this value reaches 0. It + * is then set back to the maxRangedAttackTime. + */ + private int rangedAttackTime; + private double entityMoveSpeed; + private int mCooldownTime; + private int field_96561_g; + /** + * The maximum time the AI has to wait before performing another ranged attack. + */ + private int maxRangedAttackTime; + private float field_96562_i; + private float field_82642_h; //Max range + + public Ranged(EntityAIBatKingAttack aParent, double aMovementSpeed, int someInt, + int aMaxRangedAttackTime, float someFloat) { + this.rangedAttackTime = -1; + this.parentAI = aParent; + this.entityMoveSpeed = aMovementSpeed; + this.field_96561_g = someInt; + this.maxRangedAttackTime = aMaxRangedAttackTime; + this.field_96562_i = someFloat; + this.field_82642_h = someFloat * someFloat * 8; + parentAI.setMutexBits(3); + + } + + /** + * Execute a one shot task or start executing a continuous task + */ + public void startExecuting() { + parentAI.getBatKing().getNavigator().setPath(parentAI.mEntityPathEntity, this.entityMoveSpeed); + } + + /** + * Returns whether an in-progress EntityAIBase should continue executing + */ + public boolean continueExecuting() { + return parentAI.shouldExecute() || !parentAI.getBatKing().getNavigator().noPath(); + } + + /** + * Resets the task + */ + public void resetTask() { + parentAI.mEntityTarget = null; + this.mCooldownTime = 0; + this.rangedAttackTime = -1; + } + + /** + * Updates the task + */ + public void updateTask() { + + if (MathUtils.randInt(0, 100) == 0) { + maxRangedAttackTime = MathUtils.balance(maxRangedAttackTime, 20, 40); + } + + double d0 = parentAI.getBatKing().getDistanceSq(parentAI.mEntityTarget.posX, parentAI.mEntityTarget.boundingBox.minY, + parentAI.mEntityTarget.posZ); + boolean flag = parentAI.getBatKing().getEntitySenses().canSee(parentAI.mEntityTarget); + + if (flag) { + ++this.mCooldownTime; + } else { + this.mCooldownTime = 0; + } + + if (d0 <= (double) this.field_82642_h && this.mCooldownTime >= 20) { + parentAI.getBatKing().getNavigator().clearPathEntity(); + } else { + if (parentAI.getBatKing().getNavigator().tryMoveToEntityLiving(parentAI.mEntityTarget, this.entityMoveSpeed)) { + Logger.INFO("Doing Ranged Ai Task."); + } + else { + Logger.INFO("Not Doing Ranged Ai Task."); + } + } + + parentAI.getBatKing().getLookHelper().setLookPositionWithEntity(parentAI.mEntityTarget, 30.0F, 30.0F); + float f; + Logger.INFO("Ranged AI - "+rangedAttackTime); + + if (--this.rangedAttackTime == 0) { + if (d0 > (double) this.field_82642_h || !flag) { + Logger.INFO("Stopping ranged attack. "+flag+"|"+(d0 > (double) this.field_82642_h)+"|"+d0+"|"+(double) this.field_82642_h); + return; + } + + f = MathHelper.sqrt_double(d0) / this.field_96562_i; + float f1 = f; + + if (f < 0.1F) { + f1 = 0.1F; + } + + if (f1 > 1.0F) { + f1 = 1.0F; + } + Logger.INFO("Trying to do a ranged attack."); + parentAI.getBatKingAsIRangedAttackMob().attackEntityWithRangedAttack(parentAI.mEntityTarget, f1); + this.rangedAttackTime = MathHelper.floor_float( + f * (float) (this.maxRangedAttackTime - this.field_96561_g) + (float) this.field_96561_g); + } else if (this.rangedAttackTime < 0) { + f = MathHelper.sqrt_double(d0) / this.field_96562_i; + this.rangedAttackTime = MathHelper.floor_float( + f * (float) (this.maxRangedAttackTime - this.field_96561_g) + (float) this.field_96561_g); + } + } + + } + + private class Melee { + + private final EntityAIBatKingAttack parentAI; + + /** + * An amount of decrementing ticks that allows the entity to attack once the + * tick reaches 0. + */ + int attackTick; + /** The speed with which the mob will approach the target */ + double speedTowardsTarget; + /** + * When true, the mob will continue chasing its target, even if it can't find a + * path to them right now. + */ + boolean longMemory; + Class classTarget; + private int field_75445_i; + private double field_151497_i; + private double field_151495_j; + private double field_151496_k; + + private int failedPathFindingPenalty; + + public Melee(EntityAIBatKingAttack aParent, Class aClassTarget, + double aMoveToTargetSpeed, boolean aLongMemory) { + this.parentAI = aParent; + this.classTarget = aClassTarget; + this.speedTowardsTarget = aMoveToTargetSpeed; + this.longMemory = aLongMemory; + parentAI.setMutexBits(3); + } + + /** + * Returns whether the EntityAIBase should begin execution. + */ + public boolean shouldExecute() { + if (!parentAI.hasValidTarget()) { + return false; + } + EntityLivingBase entitylivingbase = parentAI.getTarget(); + + if (entitylivingbase == null) { + return false; + } else if (!entitylivingbase.isEntityAlive()) { + return false; + } else if (this.classTarget != null && !this.classTarget.isAssignableFrom(entitylivingbase.getClass())) { + return false; + } else { + if (--this.field_75445_i <= 0) { + parentAI.mEntityPathEntity = parentAI.mAttackingEntity.getNavigator().getPathToEntityLiving(entitylivingbase); + this.field_75445_i = 4 + parentAI.mAttackingEntity.getRNG().nextInt(7); + return parentAI.mEntityPathEntity != null; + } else { + return true; + } + } + } + + /** + * Returns whether an in-progress EntityAIBase should continue executing + */ + public boolean continueExecuting() { + EntityLivingBase entitylivingbase = parentAI.mAttackingEntity.getAttackTarget(); + return entitylivingbase == null ? false + : (!entitylivingbase.isEntityAlive() ? false + : (!this.longMemory ? !parentAI.mAttackingEntity.getNavigator().noPath() + : parentAI.mAttackingEntity.isWithinHomeDistance(MathHelper.floor_double(entitylivingbase.posX), + MathHelper.floor_double(entitylivingbase.posY), + MathHelper.floor_double(entitylivingbase.posZ)))); + } + + /** + * Execute a one shot task or start executing a continuous task + */ + public void startExecuting() { + parentAI.mAttackingEntity.getNavigator().setPath(parentAI.mEntityPathEntity, this.speedTowardsTarget); + this.field_75445_i = 0; + } + + /** + * Resets the task + */ + public void resetTask() { + parentAI.mAttackingEntity.getNavigator().clearPathEntity(); + } + + /** + * Updates the task + */ + public void updateTask() { + EntityLivingBase entitylivingbase = parentAI.mAttackingEntity.getAttackTarget(); + parentAI.mAttackingEntity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F); + double d0 = parentAI.mAttackingEntity.getDistanceSq(entitylivingbase.posX, entitylivingbase.boundingBox.minY, + entitylivingbase.posZ); + double d1 = (double) (parentAI.mAttackingEntity.width * 2.0F * parentAI.mAttackingEntity.width * 2.0F + entitylivingbase.width); + --this.field_75445_i; + + if ((this.longMemory || parentAI.mAttackingEntity.getEntitySenses().canSee(entitylivingbase)) && this.field_75445_i <= 0 + && (this.field_151497_i == 0.0D && this.field_151495_j == 0.0D && this.field_151496_k == 0.0D + || entitylivingbase.getDistanceSq(this.field_151497_i, this.field_151495_j, + this.field_151496_k) >= 1.0D + || parentAI.mAttackingEntity.getRNG().nextFloat() < 0.05F)) { + this.field_151497_i = entitylivingbase.posX; + this.field_151495_j = entitylivingbase.boundingBox.minY; + this.field_151496_k = entitylivingbase.posZ; + this.field_75445_i = failedPathFindingPenalty + 4 + parentAI.mAttackingEntity.getRNG().nextInt(7); + + if (parentAI.mAttackingEntity.getNavigator().getPath() != null) { + PathPoint finalPathPoint = parentAI.mAttackingEntity.getNavigator().getPath().getFinalPathPoint(); + if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.xCoord, + finalPathPoint.yCoord, finalPathPoint.zCoord) < 1) { + failedPathFindingPenalty = 0; + } else { + failedPathFindingPenalty += 10; + } + } else { + failedPathFindingPenalty += 10; + } + + if (d0 > 1024.0D) { + this.field_75445_i += 10; + } else if (d0 > 256.0D) { + this.field_75445_i += 5; + } + + if (!parentAI.mAttackingEntity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) { + this.field_75445_i += 15; + } + } + + this.attackTick = Math.max(this.attackTick - 1, 0); + + if (d0 <= d1 && this.attackTick <= 20) { + this.attackTick = 20; + + if (parentAI.mAttackingEntity.getHeldItem() != null) { + parentAI.mAttackingEntity.swingItem(); + } + + parentAI.mAttackingEntity.attackEntityAsMob(entitylivingbase); + } + } + + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntityBatKing.java b/src/Java/gtPlusPlus/core/entity/monster/EntityBatKing.java index 114ca50b4b..55e0f4c571 100644 --- a/src/Java/gtPlusPlus/core/entity/monster/EntityBatKing.java +++ b/src/Java/gtPlusPlus/core/entity/monster/EntityBatKing.java @@ -1,228 +1,712 @@ package gtPlusPlus.core.entity.monster; -import java.util.Calendar; +import java.lang.reflect.Field; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.entity.ai.batking.EntityAIBatKingAttack; +import gtPlusPlus.core.entity.projectile.EntityThrowableBomb; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIAttackOnCollide; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.RandomPositionGenerator; +import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.passive.EntityBat; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityLargeFireball; +import net.minecraft.init.Items; +import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; -public class EntityBatKing extends EntityBat -{ - /** Coordinates of where the bat spawned. */ - private ChunkCoordinates spawnPosition; - - public EntityBatKing(World p_i1680_1_) - { - super(p_i1680_1_); - this.setSize(2F, 3.6F); - this.setIsBatHanging(false); - } - - protected void entityInit() - { - super.entityInit(); - } - - /** - * Returns the volume for the sounds this mob makes. - */ - protected float getSoundVolume() - { - return 0.3F; - } - - /** - * Gets the pitch of living sounds in living entities. - */ - protected float getSoundPitch() - { - return super.getSoundPitch() * 0.35F; - } - - /** - * Returns the sound this mob makes while it's alive. - */ - protected String getLivingSound() - { - return this.getIsBatHanging() && this.rand.nextInt(4) != 0 ? null : "mob.bat.idle"; - } - - /** - * Returns the sound this mob makes when it is hurt. - */ - protected String getHurtSound() - { - return "mob.bat.hurt"; - } - - /** - * Returns the sound this mob makes on death. - */ - protected String getDeathSound() - { - return "mob.bat.death"; - } - - /** - * Returns true if this entity should push and be pushed by other entities when colliding. - */ - public boolean canBePushed() - { - return false; - } - - protected void collideWithEntity(Entity p_82167_1_) {} - - protected void collideWithNearbyEntities() {} - - protected void applyEntityAttributes() - { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(60.0D); - } - - public boolean getIsBatHanging() - { - return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; - } - - public void setIsBatHanging(boolean p_82236_1_) - { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (p_82236_1_) - { - this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); - } - else - { - this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); - } - } - - /** - * Returns true if the newer Entity AI code should be run - */ - protected boolean isAIEnabled() - { - return true; - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() - { - super.onUpdate(); - } - - protected void updateAITasks() - { - super.updateAITasks(); - - } - - /** - * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to - * prevent them from trampling crops - */ - protected boolean canTriggerWalking() - { - return false; - } - - /** - * Called when the mob is falling. Calculates and applies fall damage. - */ - protected void fall(float p_70069_1_) {} - - /** - * Takes in the distance the entity has fallen this tick and whether its on the ground to update the fall distance - * and deal fall damage if landing on the ground. Args: distanceFallenThisTick, onGround - */ - protected void updateFallState(double p_70064_1_, boolean p_70064_3_) {} - - /** - * Return whether this entity should NOT trigger a pressure plate or a tripwire. - */ - public boolean doesEntityNotTriggerPressurePlate() - { - return true; - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) - { - if (this.isEntityInvulnerable()) - { - return false; - } - else - { - if (!this.worldObj.isRemote && this.getIsBatHanging()) - { - this.setIsBatHanging(false); - } - - return super.attackEntityFrom(p_70097_1_, p_70097_2_); - } - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound p_70037_1_) - { - super.readEntityFromNBT(p_70037_1_); - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound p_70014_1_) - { - super.writeEntityToNBT(p_70014_1_); - } - - /** - * Checks if the entity's current position is a valid location to spawn this entity. - */ - public boolean getCanSpawnHere() - { - int i = MathHelper.floor_double(this.boundingBox.minY); - - if (i >= 63) - { - return false; - } - else - { - int j = MathHelper.floor_double(this.posX); - int k = MathHelper.floor_double(this.posZ); - int l = this.worldObj.getBlockLightValue(j, i, k); - byte b0 = 4; - Calendar calendar = this.worldObj.getCurrentDate(); - - if ((calendar.get(2) + 1 != 10 || calendar.get(5) < 20) && (calendar.get(2) + 1 != 11 || calendar.get(5) > 3)) - { - if (this.rand.nextBoolean()) - { - return false; - } - } - else - { - b0 = 7; - } - - return l > this.rand.nextInt(b0) ? false : super.getCanSpawnHere(); - } - } +public class EntityBatKing extends EntityMob implements IRangedAttackMob { + + public int courseChangeCooldown; + public double waypointX; + public double waypointY; + public double waypointZ; + private Entity targetedEntity; + private int aggroCooldown; + public int prevAttackCounter; + public int attackCounter; + private int explosionStrength = 1; + + private EntityAIBatKingAttack aiAttack = new EntityAIBatKingAttack(this, null, 1.0D, 20, 60, 15.0F, true); + private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, + false); + + public EntityBatKing(World p_i1680_1_) { + super(p_i1680_1_); + this.setSize(2.5F, 1.5F); + + this.setIsBatHanging(false); + this.isImmuneToFire = true; + this.experienceValue = 1000; + + this.tasks.addTask(3, this.aiAttack); + //this.tasks.addTask(4, this.aiAttackOnCollide); + //this.tasks.addTask(4, new EntityAIRestrictSun(this)); + //this.tasks.addTask(5, new EntityAIFleeSun(this, 1.0D)); + this.tasks.addTask(4, new EntityAIWander(this, 1.0D)); + //this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + //this.tasks.addTask(6, new EntityAILookIdle(this)); + + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); + //this.targetTasks.addTask(2, this.aiAttack); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); + this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityBat.class, 0, false)); + + } + + protected void entityInit() { + super.entityInit(); + } + + /** + * Get this Entity's EnumCreatureAttribute + */ + public EnumCreatureAttribute getCreatureAttribute() { + return EnumCreatureAttribute.UNDEAD; + } + + /** + * Gets the pitch of living sounds in living entities. + */ + protected float getSoundPitch() { + return super.getSoundPitch() * 0.15F; + } + + /** + * Returns the sound this mob makes while it's alive. + */ + protected String getLivingSound() { + int aRand = MathUtils.randInt(0, 10); + if (aRand < 6) { + return null; + } else if (aRand <= 8) { + return "mob.bat.idle"; + } else { + return "mob.blaze.breathe"; + } + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + protected String getHurtSound() { + return "mob.blaze.hit"; + } + + /** + * Returns the sound this mob makes on death. + */ + protected String getDeathSound() { + return "mob.bat.death"; + } + + /** + * Returns true if this entity should push and be pushed by other entities when + * colliding. + */ + public boolean canBePushed() { + return true; + } + + protected void collideWithEntity(Entity aEntity) { + if (aEntity != null) { + if (aEntity instanceof EntityPlayer) { + EntityUtils.doDamage(aEntity, DamageSource.magic, (int) (((EntityPlayer) aEntity).getHealth() / 20)); + } + } + } + + protected void collideWithNearbyEntities() { + } + + protected void applyEntityAttributes() { + + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.maxHealth); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.knockbackResistance); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.movementSpeed); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.followRange); + + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(250.0D); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1D); + this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(120.0D); + } + + public boolean getIsBatHanging() { + return false; + } + + public void setIsBatHanging(boolean p_82236_1_) { + generateParticles(this); + generateParticles(this); + generateParticles(this); + for (int i = 0; i < 32; ++i) { + // + String particleName = "lava"; + if (MathUtils.randInt(0, 3) <= 2) { + particleName = "crit"; + } + this.worldObj.spawnParticle(particleName, + this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.width, + this.posY + this.rand.nextDouble() * (double) this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.width, 0.0D, 0.0D, 0.0D); + } + + } + + /** + * Returns true if the newer Entity AI code should be run + */ + protected boolean isAIEnabled() { + return true; + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() { + super.onUpdate(); + generateParticles(this); + + if (!this.worldObj.isRemote && (this.targetedEntity == null || this.aggroCooldown-- <= 0)) { + this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D); + + if (this.targetedEntity != null) { + this.aggroCooldown = 30; + if (aiAttack.hasValidTarget()) { + this.setAttackTarget(aiAttack.getTarget()); + } + else { + Logger.INFO("No valid target."); + if (ReflectionUtils.doesFieldExist(aiAttack.getClass(), "mEntityTarget")) { + Logger.INFO("Found field."); + } + else { + Logger.INFO("Did not find field."); + } + Field target = ReflectionUtils.getField(EntityAIBatKingAttack.class, "mEntityTarget"); + if (target != null) { + ReflectionUtils.setField(aiAttack, target, this.targetedEntity); + Logger.INFO("Set target."); + } + else { + Logger.INFO("Could not set via reflection."); + } + + + } + } + else { + Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this, 32, 20); + if (vec3 != null) { + double xPosition = vec3.xCoord; + double yPosition = vec3.yCoord; + double zPosition = vec3.zCoord; + this.getNavigator().tryMoveToXYZ(xPosition, yPosition, zPosition, 3); + } + } + } + + } + + private static void generateParticles(EntityBatKing aKing) { + for (int i = 0; i < 20; ++i) { + // + if (MathUtils.randInt(0, 50) <= 1) { + String particleName = "smoke"; + if (MathUtils.randInt(0, 3) <= 2) { + particleName = "largesmoke"; + } + aKing.worldObj.spawnParticle(particleName, + aKing.posX + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, + aKing.posY + aKing.rand.nextDouble() * (double) aKing.height, + aKing.posZ + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, 0.0D, 0.0D, 0.0D); + } + if (MathUtils.randInt(0, 100) <= 1) { + String particleName = "smoke"; + int test2 = MathUtils.randInt(0, 3); + if (test2 == 2) { + particleName = "dripLava"; + } else if (test2 == 3) { + particleName = "portal"; + } + aKing.worldObj.spawnParticle(particleName, + aKing.posX + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, + aKing.posY + aKing.rand.nextDouble() * (double) aKing.height, + aKing.posZ + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, 0.0D, 0.0D, 0.0D); + } + } + } + + protected void updateAITasks() { + super.updateAITasks(); + } + + private boolean isFlying() { + if (this.onGround) { + return false; + } + return true; + } + + private boolean hasAir() { + BlockPos p = EntityUtils.findBlockPosUnderEntity(this); + int y = p.yPos; + int yOriginal = p.yPos; + + for (int u = 0; u<5;u++) { + if (u > 50 || y <= 0) { + break; + } + if (!this.worldObj.isAirBlock(p.xPos, y, p.zPos)) { + break; + } + y--; + } + if (yOriginal != y) { + for (int i = 0; i < y; y++) { + this.jump(); + } + return true; + } + return false; + } + + /** + * returns if this entity triggers Block.onEntityWalking on the blocks they walk + * on. used for spiders and wolves to prevent them from trampling crops + */ + protected boolean canTriggerWalking() { + return false; + } + + /** + * Return whether this entity should NOT trigger a pressure plate or a tripwire. + */ + public boolean doesEntityNotTriggerPressurePlate() { + return true; + } + + /** + * Called when the entity is attacked. + */ + public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { + if (this.isEntityInvulnerable()) { + return false; + } else { + if (!this.worldObj.isRemote && this.getIsBatHanging()) { + this.setIsBatHanging(false); + } + + return super.attackEntityFrom(p_70097_1_, p_70097_2_); + } + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT(NBTTagCompound p_70037_1_) { + super.readEntityFromNBT(p_70037_1_); + if (p_70037_1_.hasKey("ExplosionPower", 99)) { + this.explosionStrength = p_70037_1_.getInteger("ExplosionPower"); + } + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT(NBTTagCompound p_70014_1_) { + super.writeEntityToNBT(p_70014_1_); + p_70014_1_.setInteger("ExplosionPower", this.explosionStrength); + } + + /** + * Attack the specified entity using a ranged attack. + */ + @Override + public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { + Logger.INFO("Trying to do ranged attack 1 |"+(this.targetedEntity != null)+"|"); + + if (!this.isFlying() || !this.isAirBorne) { + //this.hasAir(); + /* + * for (int i=0;i<3;i++) { this.jump(); } + */ + } + + + double d4 = 64.0D; + if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4 * 8) { + Logger.INFO("Trying to do ranged attack 2"); + double d5 = this.targetedEntity.posX - this.posX; + double d6 = this.targetedEntity.boundingBox.minY + (double) (this.targetedEntity.height / 2.0F) + - (this.posY + (double) (this.height / 2.0F)); + double d7 = this.targetedEntity.posZ - this.posZ; + this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(d5, d7)) * 180.0F / (float) Math.PI; + + ++this.attackCounter; + + if (this.canEntityBeSeen(this.targetedEntity)) { + Logger.INFO("Trying to do ranged attack 3a | "+attackCounter); + + + if (this.attackCounter >= 2) { + Logger.INFO("Trying to do ranged attack 3a1"); + + this.worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1008, (int) this.posX, (int) this.posY, + (int) this.posZ, 0); + setIsBatHanging(true); + + EntityThrowableBomb entitylargefireball = new EntityThrowableBomb(this.worldObj, this/*d5, d6, d7*/); + //entitylargefireball.field_92057_e = this.explosionStrength; + //entitylargefireball.accelerationX *= 2; + //entitylargefireball.accelerationY *= 2; + //entitylargefireball.accelerationZ *= 2; + double d8 = 4.0D; + Vec3 vec3 = this.getLook(1.0F); + entitylargefireball.posX = this.posX + vec3.xCoord * d8; + entitylargefireball.posY = this.posY + (double) (this.height / 2.0F) + 0.5D; + entitylargefireball.posZ = this.posZ + vec3.zCoord * d8; + this.worldObj.spawnEntityInWorld(entitylargefireball); + + for (int u=0; u<MathUtils.randInt(2, 10);u++) { + if (this.attackCounter > 0) { + Logger.INFO("Trying to do ranged attack 5a"); + --this.attackCounter; + EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, MathUtils.randFloat(1f, 3f), + (float) (14 - this.worldObj.difficultySetting.getDifficultyId() * 4)); + int i = MathUtils.randInt(0, 4); + int j = MathUtils.randInt(0, 3); + int k = MathUtils.randInt(0, 3); + entityarrow.setDamage((double) (p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + + (double) ((float) this.worldObj.difficultySetting.getDifficultyId() * 0.11F)); + + boolean boostAttack = MathUtils.randInt(0, 100) <= 21; + if (boostAttack) { + if (i > 0) { + entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); + } + + if (j > 0) { + entityarrow.setKnockbackStrength(j); + } + if (k > 0) { + entityarrow.setFire(50 * k); + } + } + + this.playSound("mob.skeleton.say", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.worldObj.spawnEntityInWorld(entityarrow); + Logger.INFO("Trying to do ranged attack 5a done"); + } + } + + + + + this.attackCounter = 0; + } + } else if (this.attackCounter > 0) { + Logger.INFO("Trying to do ranged attack 3b"); + --this.attackCounter; + } + } else { + Logger.INFO("Trying to do ranged attack 4a"); + this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(this.motionX, this.motionZ)) * 180.0F + / (float) Math.PI; + + if (this.attackCounter > 0) { + Logger.INFO("Trying to do ranged attack 5a"); + --this.attackCounter; + EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, + (float) (14 - this.worldObj.difficultySetting.getDifficultyId() * 4)); + int i = MathUtils.randInt(0, 4); + int j = MathUtils.randInt(0, 3); + int k = MathUtils.randInt(0, 3); + entityarrow.setDamage((double) (p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + + (double) ((float) this.worldObj.difficultySetting.getDifficultyId() * 0.11F)); + + boolean boostAttack = MathUtils.randInt(0, 100) <= 21; + if (boostAttack) { + if (i > 0) { + entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); + } + + if (j > 0) { + entityarrow.setKnockbackStrength(j); + } + if (k > 0) { + entityarrow.setFire(50 * k); + } + } + + this.playSound("mob.skeleton.say", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.worldObj.spawnEntityInWorld(entityarrow); + Logger.INFO("Trying to do ranged attack 5a done"); + } + + } + + } + + /** + * Returns the volume for the sounds this mob makes. + */ + protected float getSoundVolume() { + return 10.0F; + } + + /** + * Checks if the entity's current position is a valid location to spawn this + * entity. + */ + public boolean getCanSpawnHere() { + return super.getCanSpawnHere() && this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL; + } + + /** + * Will return how many at most can spawn in a chunk at once. + */ + public int getMaxSpawnedInChunk() { + return 1; + } + + protected Item getDropItem() { + return Items.gunpowder; + } + + /** + * Drop 0-2 items of this living's type. @param par1 - Whether this entity has + * recently been hit by a player. @param par2 - Level of Looting used to kill + * this mob. + */ + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { + int j = this.rand.nextInt(2) + this.rand.nextInt(1 + p_70628_2_); + int k; + + for (k = 0; k < j; ++k) { + this.dropItem(Items.ghast_tear, 1); + } + + j = this.rand.nextInt(3) + this.rand.nextInt(1 + p_70628_2_); + + for (k = 0; k < j; ++k) { + this.dropItem(Items.gunpowder, 1); + } + } + + @Override + protected void updateEntityActionState() { + if (!this.worldObj.isRemote && this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { + this.setDead(); + } + + this.despawnEntity(); + this.prevAttackCounter = this.attackCounter; + double d0 = this.waypointX - this.posX; + double d1 = this.waypointY - this.posY; + double d2 = this.waypointZ - this.posZ; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + if (d3 < 1.0D || d3 > 3600.0D) { + this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + } + + if (this.courseChangeCooldown-- <= 0) { + this.courseChangeCooldown += this.rand.nextInt(5) + 2; + d3 = (double) MathHelper.sqrt_double(d3); + + if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, d3)) { + this.motionX += d0 / d3 * 0.1D; + this.motionY += d1 / d3 * 0.1D; + this.motionZ += d2 / d3 * 0.1D; + } else { + this.waypointX = this.posX; + this.waypointY = this.posY; + this.waypointZ = this.posZ; + } + } + + if (this.targetedEntity != null && this.targetedEntity.isDead) { + this.targetedEntity = null; + } + + if (this.targetedEntity == null || this.aggroCooldown-- <= 0) { + this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D); + + if (this.targetedEntity != null) { + this.aggroCooldown = 20; + } + } + + double d4 = 64.0D; + + if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4) { + double d5 = this.targetedEntity.posX - this.posX; + double d6 = this.targetedEntity.boundingBox.minY + (double) (this.targetedEntity.height / 2.0F) + - (this.posY + (double) (this.height / 2.0F)); + double d7 = this.targetedEntity.posZ - this.posZ; + this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(d5, d7)) * 180.0F / (float) Math.PI; + + if (this.canEntityBeSeen(this.targetedEntity)) { + if (this.attackCounter == 10) { + this.worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1007, (int) this.posX, (int) this.posY, + (int) this.posZ, 0); + } + + ++this.attackCounter; + + if (this.attackCounter == 20) { + this.worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1008, (int) this.posX, (int) this.posY, + (int) this.posZ, 0); + EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.worldObj, this, d5, d6, d7); + entitylargefireball.field_92057_e = this.explosionStrength; + double d8 = 4.0D; + Vec3 vec3 = this.getLook(1.0F); + entitylargefireball.posX = this.posX + vec3.xCoord * d8; + entitylargefireball.posY = this.posY + (double) (this.height / 2.0F) + 0.5D; + entitylargefireball.posZ = this.posZ + vec3.zCoord * d8; + this.worldObj.spawnEntityInWorld(entitylargefireball); + this.attackCounter = -40; + } + } else if (this.attackCounter > 0) { + --this.attackCounter; + } + } else { + this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(this.motionX, this.motionZ)) * 180.0F + / (float) Math.PI; + + if (this.attackCounter > 0) { + --this.attackCounter; + } + } + + if (!this.worldObj.isRemote) { + byte b1 = this.dataWatcher.getWatchableObjectByte(16); + byte b0 = (byte) (this.attackCounter > 10 ? 1 : 0); + + if (b1 != b0) { + this.dataWatcher.updateObject(16, Byte.valueOf(b0)); + } + } + } + + /** + * True if the ghast has an unobstructed line of travel to the waypoint. + */ + private boolean isCourseTraversable(double p_70790_1_, double p_70790_3_, double p_70790_5_, double p_70790_7_) { + double d4 = (this.waypointX - this.posX) / p_70790_7_; + double d5 = (this.waypointY - this.posY) / p_70790_7_; + double d6 = (this.waypointZ - this.posZ) / p_70790_7_; + AxisAlignedBB axisalignedbb = this.boundingBox.copy(); + + for (int i = 1; (double) i < p_70790_7_; ++i) { + axisalignedbb.offset(d4, d5, d6); + + /* + * if (!this.worldObj.getCollidingBoundingBoxes(this, axisalignedbb).isEmpty()) + * { return false; } + */ + } + + return true; + } + + /** + * Called when the mob is falling. Calculates and applies fall damage. + */ + protected void fall(float p_70069_1_) { + } + + /** + * Takes in the distance the entity has fallen this tick and whether its on the + * ground to update the fall distance and deal fall damage if landing on the + * ground. Args: distanceFallenThisTick, onGround + */ + protected void updateFallState(double p_70064_1_, boolean p_70064_3_) { + } + + /** + * Moves the entity based on the specified heading. Args: strafe, forward + */ + public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { + if (this.isInWater()) { + this.moveFlying(p_70612_1_, p_70612_2_, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.800000011920929D; + this.motionY *= 0.800000011920929D; + this.motionZ *= 0.800000011920929D; + } else if (this.handleLavaMovement()) { + this.moveFlying(p_70612_1_, p_70612_2_, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.5D; + this.motionY *= 0.5D; + this.motionZ *= 0.5D; + } else { + float f2 = 0.91F; + + if (this.onGround) { + f2 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), + MathHelper.floor_double(this.boundingBox.minY) - 1, + MathHelper.floor_double(this.posZ)).slipperiness * 0.91F; + } + + float f3 = 0.16277136F / (f2 * f2 * f2); + this.moveFlying(p_70612_1_, p_70612_2_, this.onGround ? 0.1F * f3 : 0.02F); + f2 = 0.91F; + + if (this.onGround) { + f2 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), + MathHelper.floor_double(this.boundingBox.minY) - 1, + MathHelper.floor_double(this.posZ)).slipperiness * 0.91F; + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= (double) f2; + this.motionY *= (double) f2; + this.motionZ *= (double) f2; + } + + this.prevLimbSwingAmount = this.limbSwingAmount; + double d1 = this.posX - this.prevPosX; + double d0 = this.posZ - this.prevPosZ; + float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F; + + if (f4 > 1.0F) { + f4 = 1.0F; + } + + this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F; + this.limbSwing += this.limbSwingAmount; + } + + /** + * returns true if this entity is by a ladder, false otherwise + */ + public boolean isOnLadder() { + return false; + } + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java b/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java index 3359f18f7d..e3383aee91 100644 --- a/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java +++ b/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java @@ -43,7 +43,7 @@ public class FactoryFluid extends Fluid implements Runnable { @Override public void run() { - this.setIcons(GregTech_API.sBlockIcons.registerIcon(CORE.MODID+ ":" + "fluids/fluid." + this.mTextureName)); + this.setIcons(GregTech_API.sBlockIcons.registerIcon(this.mTextureName)); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java new file mode 100644 index 0000000000..881c6c82a1 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java @@ -0,0 +1,159 @@ +package gtPlusPlus.core.gui.machine; + +import java.awt.Color; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.container.Container_PestKiller; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.IFluidTank; + +@SideOnly(Side.CLIENT) +public class GUI_PestKiller extends GuiContainer { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/PestKiller.png"); + private final TileEntityPestKiller mTileKiller; + + public GUI_PestKiller(final InventoryPlayer player_inventory, final TileEntityPestKiller te) { + super(new Container_PestKiller(player_inventory, te)); + mTileKiller = te; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + if (mTileKiller != null) { + this.fontRendererObj.drawString(I18n.format(mTileKiller.getInventoryName(), new Object[0]), 4, 6, 4210752); + drawFluidTank(mTileKiller.getTank(), 134, 35); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + // This method is called when the Gui is first called! + @Override + public void initGui() { + super.initGui(); + } + + private void drawFluidTank(IFluidTank tank, int x, int y) { + Color startGrad = new Color(50, 50, 50); + Color endGrad = new Color(20, 20, 20); + Container_PestKiller aCont = (Container_PestKiller) this.inventorySlots; + + double aPercentage = 0; + double aDivisor = (100/16); + int aFrameHeight = 16; + + boolean didRender = false; + if (aCont != null) { + TileEntityPestKiller aTile = mTileKiller; + if (aTile != null) { + FluidTank aTank = aTile.getTank(); + int aTier = aTile.getTier(); + drawGradientRect(x, y, x+16, y+16, startGrad.getRGB(), endGrad.getRGB()); + if (aTier <= 0 || aTier > 2) { + if (aTank != null && aTank.getFluidAmount() > 0) { + aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity()); + //Logger.INFO("Percent = "+aPercentage); + aFrameHeight = (int) (aPercentage / aDivisor); + //Logger.INFO("Frame Height = "+aFrameHeight); + } + this.fontRendererObj.drawString("Tier: 0", 4, 18, 4210752); + this.fontRendererObj.drawString("Range: 1x1", 4, 30, 4210752); + this.fontRendererObj.drawString("Poison: None", 4, 42, 4210752); + this.fontRendererObj.drawString("Amount: 0", 4, 64, 4210752); + didRender = true; + } + else if (aTier == 1) { + if (aTank != null && aTank.getFluidAmount() > 0) { + aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity()); + //Logger.INFO("Percent = "+aPercentage); + aFrameHeight = (int) (aPercentage / aDivisor); + //Logger.INFO("Frame Height = "+aFrameHeight); + } + startGrad = new Color(240, 50, 240); + endGrad = new Color(130, 30, 130); + drawGradientRect(x, y+(16-aFrameHeight), x+16, y+16, startGrad.getRGB(), endGrad.getRGB()); + this.fontRendererObj.drawString("Tier: 1", 4, 18, 4210752); + this.fontRendererObj.drawString("Range: 5x5", 4, 30, 4210752); + this.fontRendererObj.drawString("Poison: ", 4, 42, 4210752); + this.fontRendererObj.drawString(""+aTile.getTank().getFluid().getLocalizedName(), 4, 54, 4210752); + this.fontRendererObj.drawString("Amount: "+aTile.getTank().getFluidAmount(), 4, 64, 4210752); + didRender = true; + } + else if (aTier == 2) { + if (aTank != null && aTank.getFluidAmount() > 0) { + aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity()); + //Logger.INFO("Percent = "+aPercentage); + aFrameHeight = (int) (aPercentage / aDivisor); + //Logger.INFO("Frame Height = "+aFrameHeight); + } + short[] aRGB = MISC_MATERIALS.HYDROGEN_CYANIDE.getRGB(); + startGrad = new Color(aRGB[0], aRGB[1], aRGB[2]); + endGrad = new Color(Math.max(aRGB[0], 0), Math.max(aRGB[1], 0), Math.max(aRGB[2], 0)); + drawGradientRect(x, y+(16-aFrameHeight), x+16, y+16, startGrad.getRGB(), endGrad.getRGB()); + this.fontRendererObj.drawString("Tier: 2", 4, 18, 4210752); + this.fontRendererObj.drawString("Range: 9x9", 4, 30, 4210752); + this.fontRendererObj.drawString("Poison: ", 4, 42, 4210752); + this.fontRendererObj.drawString(""+aTile.getTank().getFluid().getLocalizedName(), 4, 54, 4210752); + this.fontRendererObj.drawString("Amount: "+aTile.getTank().getFluidAmount(), 4, 64, 4210752); + didRender = true; + } + } + } + if (!didRender) { + startGrad = new Color(255, 30, 120); + endGrad = new Color(255, 0, 50); + drawGradientRect(x, y, x+16, y+16, startGrad.getRGB(), endGrad.getRGB()); + this.fontRendererObj.drawString("Tier: 0", 4, 18, 4210752); + } + + + + + + + /* + * FluidStack fluid = tank.getFluid(); TextureManager manager = + * mc.getTextureManager(); if (fluid != null) { + * manager.bindTexture(manager.getResourceLocation(0)); float amount = + * fluid.amount; float capacity = tank.getCapacity(); float scale = amount / + * capacity; int fluidTankHeight = 60; int fluidAmount = (int) (scale * + * fluidTankHeight); drawFluid(x, y + fluidTankHeight - fluidAmount, + * fluid.getFluid().getIcon(fluid), 16, fluidAmount); } + */ + } + + private void drawFluid(int x, int y, IIcon icon, int width, int height) { + int i = 0; + int j = 0; + int drawHeight = 0; + int drawWidth = 0; + for (i = 0; i < width; i += 16) { + for (j = 0; j < height; j += 16) { + drawWidth = Math.min(width - i, 16); + drawHeight = Math.min(height - j, 16); + drawTexturedModelRectFromIcon(x + i, y + j, icon, drawWidth, drawHeight); + } + } + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java new file mode 100644 index 0000000000..edb53e8ec0 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java @@ -0,0 +1,120 @@ +package gtPlusPlus.core.gui.machine; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.container.Container_RoundRobinator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class GUI_RoundRobinator extends GuiContainer { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/RoundRobinator.png"); + private TileEntityRoundRobinator mTile; + private Container_RoundRobinator mContainer; + private static final Method mDrawItemStack; + + static { + mDrawItemStack = ReflectionUtils.getMethod(GuiContainer.class, "drawItemStack", new Class[] {ItemStack.class, int.class, int.class, String.class}); + } + + public GUI_RoundRobinator(final InventoryPlayer player_inventory, final TileEntityRoundRobinator te){ + this(new Container_RoundRobinator(player_inventory, te)); + mTile = te; + } + + private GUI_RoundRobinator(final Container_RoundRobinator aContainer){ + super(aContainer); + mContainer = aContainer; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j){ + super.drawGuiContainerForegroundLayer(i, j); + + int xStart = 134; + int yStart = 31; + mTile = this.mContainer.tile_entity; + + int tier = mContainer.mTier; + int aTickRate = mContainer.mTickRate; + + fontRendererObj.drawString("Round Robinator", 85, 4, Utils.rgbtoHexValue(50, 150, 50)); + fontRendererObj.drawString("Tier: "+tier, 85, 12, Utils.rgbtoHexValue(50, 150, 50)); + fontRendererObj.drawString("Rate: 1 Item/"+aTickRate+"t", 85, 20, Utils.rgbtoHexValue(50, 150, 50)); + + boolean[] aStates = new boolean[] {mContainer.mSide_1 == 0 ? false : true, mContainer.mSide_2 == 0 ? false : true, mContainer.mSide_3 == 0 ? false : true,mContainer.mSide_4 == 0 ? false : true}; + + fontRendererObj.drawString("West: "+(aStates[0] ? "Active" : "Disabled"), 5, 5, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString("North: "+(aStates[1] ? "Active" : "Disabled"), 5, 15, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString("South: "+(aStates[2] ? "Active" : "Disabled"), 5, 25, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString("East: "+(aStates[3] ? "Active" : "Disabled"), 5, 35, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString("Toggling South will visually", 5, 65, Utils.rgbtoHexValue(150, 50, 50)); + fontRendererObj.drawString("toggle East, This is a visual bug.", 5, 74, Utils.rgbtoHexValue(150, 50, 50)); + drawStatus(aStates[0], xStart, yStart); + drawStatus(aStates[1], xStart+18, yStart); + drawStatus(aStates[2], xStart, yStart+18); + drawStatus(aStates[3], xStart+18, yStart+18); + + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + + + + } + + private static ItemStack aGreenGlass; + private static ItemStack aRedGlass; + + private void drawStatus(boolean aStateActive, int x, int y) { + if (aGreenGlass == null) { + Item pane = ItemUtils.getSimpleStack(Blocks.stained_glass_pane).getItem(); + aGreenGlass = ItemUtils.simpleMetaStack(pane, 5, 1); + } + if (aRedGlass == null) { + Item pane = ItemUtils.getSimpleStack(Blocks.stained_glass_pane).getItem(); + aRedGlass = ItemUtils.simpleMetaStack(pane, 14, 1); + } + if (mDrawItemStack != null) { + try { + if (aStateActive) { + mDrawItemStack.invoke(this, new Object[]{aGreenGlass, x, y, ""}); + } + else { + mDrawItemStack.invoke(this, new Object[]{aRedGlass, x, y, ""}); + } + } + catch (Throwable t) { + t.printStackTrace(); + } + } + } + + //This method is called when the Gui is first called! + @Override + public void initGui(){ + super.initGui(); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java index 9053875058..fa10f4def3 100644 --- a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java +++ b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java @@ -17,6 +17,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; @@ -74,7 +75,9 @@ public class AchievementHandler { this.registerAchievement("semifluid", -14, -10, GregtechItemList.Generator_SemiFluid_HV.get(1), aBaseAchievementName, false); this.registerAchievement("earlywasher", -13, -10, GregtechItemList.SimpleDustWasher_ULV.get(1), aBaseAchievementName, false); this.registerAchievement("advancedsteam", -12, -10, GregtechItemList.Boiler_Advanced_MV.get(1), aBaseAchievementName, false); - this.registerAchievement("pollutionremoval", -11, -10, GregtechItemList.Pollution_Cleaner_IV.get(1), aBaseAchievementName, false); + if (PollutionUtils.isPollutionEnabled()) { + this.registerAchievement("pollutionremoval", -11, -10, GregtechItemList.Pollution_Cleaner_IV.get(1), aBaseAchievementName, false); + } this.registerAchievement("hiampxform", -10, -10, GregtechItemList.Transformer_HA_HV_MV.get(1), aBaseAchievementName, false); diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index fd30457b46..be02e352c7 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -2,7 +2,9 @@ package gtPlusPlus.core.handler; import static gtPlusPlus.core.lib.LoadedMods.Gregtech; -import java.util.*; +import java.util.LinkedList; +import java.util.Queue; +import java.util.Set; import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gregtech.api.enums.GT_Values; @@ -11,22 +13,99 @@ import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.ItemPackage; -import gtPlusPlus.core.common.compat.*; +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_HarvestCraft; +import gtPlusPlus.core.common.compat.COMPAT_IC2; +import gtPlusPlus.core.common.compat.COMPAT_MorePlanets; +import gtPlusPlus.core.common.compat.COMPAT_OpenBlocks; +import gtPlusPlus.core.common.compat.COMPAT_PneumaticCraft; +import gtPlusPlus.core.common.compat.COMPAT_RFTools; +import gtPlusPlus.core.common.compat.COMPAT_Railcraft; +import gtPlusPlus.core.common.compat.COMPAT_SimplyJetpacks; +import gtPlusPlus.core.common.compat.COMPAT_Thaumcraft; +import gtPlusPlus.core.common.compat.COMPAT_Witchery; import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialGenerator; -import gtPlusPlus.core.recipe.*; +import gtPlusPlus.core.recipe.RECIPES_Extruder; +import gtPlusPlus.core.recipe.RECIPES_GREGTECH; +import gtPlusPlus.core.recipe.RECIPES_LaserEngraver; +import gtPlusPlus.core.recipe.ShapedRecipeObject; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; -import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaGarbageCollector; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaPollutionCreator; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_FluidCanning; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; -import gtPlusPlus.xmod.gregtech.registration.gregtech.*; +import gtPlusPlus.xmod.gregtech.registration.gregtech.Gregtech4Content; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechAdvancedBoilers; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechAdvancedMixer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechAlgaeContent; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechAmazonWarehouse; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechBedrockPlatforms; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechBufferDynamos; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechComponentAssembler; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechCustomHatches; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechCyclotron; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechDehydrator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechEnergyBuffer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechFactoryGradeReplacementMultis; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechFluidReactor; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechGeneratorsULV; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechGeothermalThermalGenerator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechHiAmpTransformer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialArcFurnace; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialBlastSmelter; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialCentrifuge; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialCokeOven; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialCuttingFactory; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialElectrolyzer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialExtruder; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialFishPond; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialFuelRefinery; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialGeneratorArray; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMacerator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMassFabricator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMixer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMultiMachine; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMultiTank; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialPlatePress; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialSifter; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialThermalCentrifuge; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialTreeFarm; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialWashPlant; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialWiremill; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIronBlastFurnace; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechLFTR; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechLargeTurbinesAndHeatExchanger; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechMiniRaFusion; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechNaqReactor; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechPollutionDevices; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechPowerBreakers; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechPowerSubStation; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRTG; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRocketFuelGenerator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSafeBlock; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSemiFluidgenerators; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSimpleWasher; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSolarGenerators; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSolarTower; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSteamCondenser; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSuperChests; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechTeslaTower; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechThaumcraftDevices; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechThreadedBuffers; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechTieredChunkloaders; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechTieredFluidTanks; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechTreeFarmerTE; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechWirelessChargers; +import gtPlusPlus.xmod.gregtech.registration.gregtech.NewHorizonsAccelerator; import net.minecraft.item.ItemStack; public class COMPAT_HANDLER { @@ -135,6 +214,8 @@ public class COMPAT_HANDLER { GregtechSolarTower.run(); GregtechLargeTurbinesAndHeatExchanger.run(); GregtechPowerBreakers.run(); + GregtechFluidReactor.run(); + GregtechAlgaeContent.run(); //New Horizons Content NewHorizonsAccelerator.run(); @@ -211,6 +292,7 @@ public class COMPAT_HANDLER { for (RunnableWithInfo<Material> r : m) { try { r.run(); + Logger.INFO("[FIND] "+r.getInfoData().getLocalizedName()+" recipes generated."); } catch (Throwable t) { t.printStackTrace(); @@ -220,6 +302,9 @@ public class COMPAT_HANDLER { } RecipeGen_Recycling.executeGenerators(); runQueuedMisc(); + + // Do Fluid Canning Last, because they're not executed on demand, but rather queued. + RecipeGen_FluidCanning.init(); } diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index 0f689325a3..b7efcf08ea 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -12,6 +12,8 @@ import gtPlusPlus.xmod.galacticraft.HANDLER_GalactiCraft; import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.growthcraft.HANDLER_GC; import gtPlusPlus.xmod.ic2.HANDLER_IC2; +import gtPlusPlus.xmod.railcraft.HANDLER_Railcraft; +import gtPlusPlus.xmod.reliquary.HANDLER_Reliquary; import gtPlusPlus.xmod.sc2.HANDLER_SC2; import gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft; import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; @@ -33,6 +35,8 @@ public class COMPAT_IntermodStaging { HANDLER_SC2.preInit(); HANDLER_GalactiCraft.preInit(); HANDLER_CropsPlusPlus.preInit(preinit); + HANDLER_Railcraft.preInit(); + HANDLER_Reliquary.preInit(); } public static void init(FMLInitializationEvent init){ @@ -49,6 +53,8 @@ public class COMPAT_IntermodStaging { HANDLER_SC2.init(); HANDLER_GalactiCraft.init(); HANDLER_CropsPlusPlus.init(init); + HANDLER_Railcraft.init(); + HANDLER_Reliquary.init(); } public static void postInit(FMLPostInitializationEvent postinit){ @@ -65,6 +71,8 @@ public class COMPAT_IntermodStaging { HANDLER_SC2.postInit(); HANDLER_GalactiCraft.postInit(); HANDLER_CropsPlusPlus.postInit(postinit); + HANDLER_Railcraft.postInit(); + HANDLER_Reliquary.postInit(); } public static void onLoadComplete(FMLLoadCompleteEvent event) { diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 8448b738a2..e44c9a8f20 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -2,16 +2,22 @@ package gtPlusPlus.core.handler; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.World; - import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox; -import gtPlusPlus.core.container.*; +import gtPlusPlus.core.container.Container_BackpackBase; +import gtPlusPlus.core.container.Container_CircuitProgrammer; +import gtPlusPlus.core.container.Container_DecayablesChest; +import gtPlusPlus.core.container.Container_FishTrap; +import gtPlusPlus.core.container.Container_Grindle; +import gtPlusPlus.core.container.Container_ModularityTable; +import gtPlusPlus.core.container.Container_PestKiller; +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.container.Container_RoundRobinator; +import gtPlusPlus.core.container.Container_SuperJukebox; +import gtPlusPlus.core.container.Container_TradeTable; +import gtPlusPlus.core.container.Container_Workbench; +import gtPlusPlus.core.container.Container_WorkbenchAdvanced; import gtPlusPlus.core.container.box.LunchBoxContainer; import gtPlusPlus.core.container.box.MagicBagContainer; import gtPlusPlus.core.container.box.ToolBoxContainer; @@ -22,20 +28,38 @@ import gtPlusPlus.core.gui.item.GuiBaseGrindle; import gtPlusPlus.core.gui.item.box.LunchBoxGui; import gtPlusPlus.core.gui.item.box.MagicBagGui; import gtPlusPlus.core.gui.item.box.ToolBoxGui; -import gtPlusPlus.core.gui.machine.*; +import gtPlusPlus.core.gui.machine.GUI_CircuitProgrammer; +import gtPlusPlus.core.gui.machine.GUI_DecayablesChest; +import gtPlusPlus.core.gui.machine.GUI_FishTrap; +import gtPlusPlus.core.gui.machine.GUI_ModularityTable; +import gtPlusPlus.core.gui.machine.GUI_PestKiller; +import gtPlusPlus.core.gui.machine.GUI_ProjectTable; +import gtPlusPlus.core.gui.machine.GUI_RoundRobinator; +import gtPlusPlus.core.gui.machine.GUI_SuperJukebox; +import gtPlusPlus.core.gui.machine.GUI_TradeTable; +import gtPlusPlus.core.gui.machine.GUI_Workbench; +import gtPlusPlus.core.gui.machine.GUI_WorkbenchAdvanced; import gtPlusPlus.core.interfaces.IGuiManager; import gtPlusPlus.core.inventories.BaseInventoryBackpack; import gtPlusPlus.core.inventories.BaseInventoryGrindle; import gtPlusPlus.core.inventories.box.LunchBoxInventory; import gtPlusPlus.core.inventories.box.MagicBagInventory; import gtPlusPlus.core.inventories.box.ToolBoxInventory; -import gtPlusPlus.core.item.tool.misc.box.ContainerBoxBase; -import gtPlusPlus.core.item.tool.misc.box.CustomBoxInventory; import gtPlusPlus.core.tileentities.base.TileEntityBase; import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; -import gtPlusPlus.core.tileentities.machines.*; +import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; +import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; +import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; +import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; public class GuiHandler implements IGuiHandler { @@ -53,6 +77,8 @@ public class GuiHandler implements IGuiHandler { public static final int GUI12 = 11; // Bag for Magic Tools public static final int GUI13 = 12; // Decayables Chest public static final int GUI14 = 13; // Super Jukebox + public static final int GUI15 = 14; // Pest Killer + public static final int GUI16 = 15; // Round-Robinator public static void init() { @@ -97,9 +123,13 @@ public class GuiHandler implements IGuiHandler { return new Container_CircuitProgrammer(player.inventory, (TileEntityCircuitProgrammer) te); } else if (ID == GUI13) { return new Container_DecayablesChest(player.inventory, (TileEntityDecayablesChest) te); - }else if (ID == GUI14) { + } else if (ID == GUI14) { return new Container_SuperJukebox(player.inventory, (TileEntitySuperJukebox) te); - } + } else if (ID == GUI15) { + return new Container_PestKiller(player.inventory, (TileEntityPestKiller) te); + } else if (ID == GUI16) { + return new Container_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); + } } if (ID == GUI9) { @@ -157,7 +187,11 @@ public class GuiHandler implements IGuiHandler { return new GUI_DecayablesChest(player.inventory, (TileEntityDecayablesChest) te); } else if (ID == GUI14) { return new GUI_SuperJukebox(player.inventory, (TileEntitySuperJukebox) te); - } + } else if (ID == GUI15) { + return new GUI_PestKiller(player.inventory, (TileEntityPestKiller) te); + } else if (ID == GUI16) { + return new GUI_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); + } } if (ID == GUI9) { diff --git a/src/Java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java b/src/Java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java new file mode 100644 index 0000000000..360b0440a2 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java @@ -0,0 +1,39 @@ +package gtPlusPlus.core.handler.Recipes; + +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; + +public class DecayableRecipe { + + public static final AutoMap<DecayableRecipe> mRecipes = new AutoMap<DecayableRecipe>(); + + + public final int mTime; + public final ItemStack mInput; + public final ItemStack mOutput; + + public DecayableRecipe(int time, ItemStack input, ItemStack output) { + mTime = time; + mInput = input; + mOutput = output; + mRecipes.put(this); + } + + @Override + public boolean equals(Object o) { + if (o instanceof DecayableRecipe) { + DecayableRecipe i = (DecayableRecipe) o; + if (i.mTime == this.mTime && GT_Utility.areStacksEqual(mInput, i.mInput) && GT_Utility.areStacksEqual(mOutput, i.mOutput)) { + return true; + } + } + return false; + } + + public boolean isValid() { + return (mTime > 0 && ItemUtils.checkForInvalidItems(mInput) && ItemUtils.checkForInvalidItems(mOutput)); + } + +} diff --git a/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java index b10e67aeaf..8853acd4b7 100644 --- a/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java +++ b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java @@ -1,8 +1,8 @@ package gtPlusPlus.core.handler; +import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.client.Minecraft; import net.minecraft.stats.AchievementList; import net.minecraftforge.event.entity.player.AchievementEvent; @@ -12,12 +12,15 @@ public class StopAnnoyingFuckingAchievements { * Stops me getting fireworks every fucking time I open my inventory upon first loading a dev client. * @param event */ - @SubscribeEvent + @SubscribeEvent(priority=EventPriority.HIGHEST) public void FUCK_OFF(AchievementEvent event) { if (event.achievement.equals(AchievementList.openInventory)) { - if (MathUtils.randInt(0, 10) >= 9) - PlayerUtils.messagePlayer(event.entityPlayer, "Bang! Nah, Just joking, there's no fireworks. :)"); event.setCanceled(true); + if (Minecraft.getMinecraft() != null) { + if (Minecraft.getMinecraft().gameSettings != null) { + Minecraft.getMinecraft().gameSettings.showInventoryAchievementHint = false; + } + } } } diff --git a/src/Java/gtPlusPlus/core/handler/events/CustomMovementHandler.java b/src/Java/gtPlusPlus/core/handler/events/CustomMovementHandler.java index f1587fa82a..b70e58d009 100644 --- a/src/Java/gtPlusPlus/core/handler/events/CustomMovementHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/CustomMovementHandler.java @@ -61,7 +61,7 @@ public class CustomMovementHandler { // // Check to see if Enabled - Added 6/17/14 to provide option to disable Sneak Toggle - final boolean isSneaking = SneakManager.Sneaking(); + final boolean isSneaking = SneakManager.get(thisPlayer).Sneaking(); //Utils.LOG_INFO("Can sneak: "+isSneaking); //Utils.LOG_INFO("Can sprint: "+SneakManager.Sprinting()); if (isSneaking) @@ -107,7 +107,7 @@ public class CustomMovementHandler { options.sneak = settings.keyBindSneak.getIsKeyPressed(); } - if(options.sneak || SneakManager.Sneaking()) + if(options.sneak || SneakManager.get(thisPlayer).Sneaking()) { options.moveStrafe = (float)(options.moveStrafe * 0.3D); options.moveForward = (float)(options.moveForward * 0.3D); @@ -121,8 +121,8 @@ public class CustomMovementHandler { final boolean enoughHunger = (thisPlayer.getFoodStats().getFoodLevel() > 6.0F) || thisPlayer.capabilities.isFlying; final boolean canSprint = !options.sneak && !thisPlayer.isRiding() && !thisPlayer.capabilities.isFlying && enoughHunger; - this.isDisabled = !SneakManager.Sprinting(); - this.canDoubleTap = SneakManager.optionDoubleTap; + this.isDisabled = !SneakManager.get(thisPlayer).Sprinting(); + this.canDoubleTap = SneakManager.get(thisPlayer).optionDoubleTap; // Key Pressed if((canSprint || this.isDisabled) && settings.keyBindSprint.getIsKeyPressed() && !this.handledSprintPress) @@ -149,8 +149,8 @@ public class CustomMovementHandler { } - public void UpdateSprint(final boolean newValue, final boolean doubleTapped){ - if (!SneakManager.Sprinting()){ + public void UpdateSprint(final boolean newValue, final boolean doubleTapped, SneakManager aSneak){ + if (!aSneak.Sprinting()){ this.sprint = false; this.sprintDoubleTapped = doubleTapped; } diff --git a/src/Java/gtPlusPlus/core/handler/events/SneakManager.java b/src/Java/gtPlusPlus/core/handler/events/SneakManager.java index e9c8c72934..3e51c6488a 100644 --- a/src/Java/gtPlusPlus/core/handler/events/SneakManager.java +++ b/src/Java/gtPlusPlus/core/handler/events/SneakManager.java @@ -1,47 +1,77 @@ package gtPlusPlus.core.handler.events; -import net.minecraft.client.Minecraft; +import java.util.concurrent.ConcurrentHashMap; import gtPlusPlus.api.objects.Logger; +import net.minecraft.entity.player.EntityPlayer; public class SneakManager { //We make this a singleton for clientside data storage. - public static SneakManager instance = new SneakManager(); - protected static final Minecraft mc = Minecraft.getMinecraft(); - public static boolean canSprint = true; - public static boolean isSneaking = true; - public static boolean optionDoubleTap = true; - public static boolean wasSprintDisabled = false; - private static State Sprinting = State.ON; - private static State Crouching = State.OFF; + public static ConcurrentHashMap<String, SneakManager> mPlayerCache = new ConcurrentHashMap<String, SneakManager>(); + + private static void addPlayer(EntityPlayer aPlayer) { + String aKey = getKey(aPlayer); + if (!mPlayerCache.containsKey(aKey)) { + mPlayerCache.put(aKey, new SneakManager(aPlayer)); + } + } + + public static SneakManager get(EntityPlayer aPlayer) { + + String aKey = getKey(aPlayer); + if (!mPlayerCache.containsKey(aKey)) { + addPlayer(aPlayer); + } + return mPlayerCache.get(aKey); + } + + private static String getKey(EntityPlayer aPlayer) { + return ""+aPlayer.getGameProfile().getId().toString(); + } + + + public SneakManager instance; + public EntityPlayer owner; + public boolean canSprint = true; + public boolean isSneaking = true; + public boolean optionDoubleTap = true; + public boolean wasSprintDisabled = false; + public boolean mIsWearingRing = false; + + private State Sprinting = State.ON; + private State Crouching = State.OFF; + + public SneakManager(EntityPlayer aPlayer) { + owner = aPlayer; + } - public static boolean Sneaking(){ + public boolean Sneaking(){ return Crouching.getState(); } - public static boolean Sprinting(){ + public boolean Sprinting(){ return Sprinting.getState(); } - public static State getSneakingState(){ + public State getSneakingState(){ return Crouching; } - public static State getSprintingDisabledState(){ + public State getSprintingDisabledState(){ return Sprinting; } - public static void toggleSneaking(){ + public void toggleSneaking(){ toggleState(Crouching); } - public static void toggleSprinting(){ + public void toggleSprinting(){ toggleState(Sprinting); } - private static State toggleState(final State state){ + private State toggleState(final State state){ Logger.INFO("State Toggle"); if (state == State.ON) { return State.OFF; @@ -49,22 +79,38 @@ public class SneakManager { return State.ON; } - public static State setCrouchingStateON(){ + private State setCrouchingStateON(){ return Crouching = State.ON; } - public static State setCrouchingStateOFF(){ + private State setCrouchingStateOFF(){ return Crouching = State.OFF; } - public static State setSprintingStateON(){ + private State setSprintingStateON(){ return Sprinting = State.ON; } - public static State setSprintingStateOFF(){ + private State setSprintingStateOFF(){ return Sprinting = State.OFF; } - + + public void putRingOn() { + mIsWearingRing = true; + setSprintingStateOFF(); + setCrouchingStateON(); + } + + public void takeRingOff() { + mIsWearingRing = false; + setSprintingStateON(); + setCrouchingStateOFF(); + } + + public boolean isWearingRing() { + return mIsWearingRing; + } + public static enum State { ON(true), OFF(false); diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java b/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java index 4cdbb72c6e..da45b5a988 100644 --- a/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java +++ b/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java @@ -1,6 +1,6 @@ package gtPlusPlus.core.inventories; -import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.slots.SlotIntegratedCircuit; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -167,7 +167,7 @@ public class InventoryCircuitProgrammer implements IInventory{ */ @Override public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return (itemstack.getItem() == CI.getNumberedCircuit(0).getItem()); + return SlotIntegratedCircuit.isItemValidForSlot(itemstack); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryPestKiller.java b/src/Java/gtPlusPlus/core/inventories/InventoryPestKiller.java new file mode 100644 index 0000000000..1c5d98f7d2 --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/InventoryPestKiller.java @@ -0,0 +1,176 @@ +package gtPlusPlus.core.inventories; + +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; + +public class InventoryPestKiller implements IInventory{ + + private final String name = "Pest Killer"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 3; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt){ + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for(int i = 0;i<list.tagCount();i++){ + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if((slot >= 0) && (slot < INV_SIZE)){ + //Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt){ + final NBTTagList list = new NBTTagList(); + for(int i = 0;i<INV_SIZE;i++){ + final ItemStack stack = this.inventory[i]; + if(stack != null){ + //Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() + { + return this.inventory.length; + } + + public ItemStack[] getInventory(){ + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) + { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) + { + ItemStack stack = this.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! + this.markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) + { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) + { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) + { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return this.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 < this.getSizeInventory(); ++i) + { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null){ + //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final 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(final int slot, final 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 true; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java b/src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java new file mode 100644 index 0000000000..a47f250c39 --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java @@ -0,0 +1,172 @@ +package gtPlusPlus.core.inventories; + +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; + +public class Inventory_RoundRobinator implements IInventory{ + + private final String name = "Round Robinator"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 4; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt){ + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for(int i = 0;i<list.tagCount();i++){ + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if((slot >= 0) && (slot < INV_SIZE)){ + //Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt){ + final NBTTagList list = new NBTTagList(); + for(int i = 0;i<INV_SIZE;i++){ + final ItemStack stack = this.inventory[i]; + if(stack != null){ + //Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() + { + return this.inventory.length; + } + + public ItemStack[] getInventory(){ + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) + { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) + { + ItemStack stack = this.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! + this.markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) + { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) + { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) + { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return this.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 < this.getSizeInventory(); ++i) + { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null){ + //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final 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(final int slot, final ItemStack itemstack) { + return true; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index de22821127..8bfcfe2d70 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -288,6 +288,10 @@ public final class ModItems { public static Item itemAirFilter; public static Item itemCoalCoke; + public static Item itemCactusCharcoal; + public static Item itemSugarCharcoal; + public static Item itemCactusCoke; + public static Item itemSugarCoke; public static Item itemCircuitLFTR; @@ -394,11 +398,8 @@ public final class ModItems { //Some Simple forms of materials itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMachines).setTextureName(CORE.MODID + ":itemStickyRubber"); GameRegistry.registerItem(itemStickyRubber, "itemStickyRubber"); - GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemStickyRubber", 1)); - - - itemCoalCoke = new BaseItemBurnable("itemCoalCoke", "Coking Coal", tabMisc, 64, 0, "Used for metallurgy.", "fuelCoke", 3200, 0).setTextureName(CORE.MODID + ":itemCoalCoke"); - + GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemStickyRubber", 1)); + //Register Hydrogen Blobs first, so we can replace old helium blobs. itemHydrogenBlob = new CoreItem("itemHydrogenBlob", "Mysterious Hydrogen Blob", tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob"); //Register Old Helium Blob, this will be replaced when held by a player. @@ -564,9 +565,9 @@ public final class ModItems { MaterialGenerator.generate(ALLOY.TUNGSTEN_TITANIUM_CARBIDE); //LFTR Fuel components - MaterialGenerator.generate(FLUORIDES.HYDROXIDE); //LFTR fuel component - MaterialGenerator.generate(FLUORIDES.AMMONIA); //LFTR fuel component - MaterialGenerator.generate(FLUORIDES.AMMONIUM); //LFTR fuel component + MaterialGenerator.generate(MISC_MATERIALS.HYDROXIDE); //LFTR fuel component + MaterialGenerator.generate(MISC_MATERIALS.AMMONIA); //LFTR fuel component + MaterialGenerator.generate(MISC_MATERIALS.AMMONIUM); //LFTR fuel component MaterialGenerator.generate(FLUORIDES.AMMONIUM_BIFLUORIDE); //LFTR fuel component MaterialGenerator.generate(FLUORIDES.BERYLLIUM_HYDROXIDE); //LFTR fuel component MaterialGenerator.generate(FLUORIDES.AMMONIUM_TETRAFLUOROBERYLLATE); //LFTR fuel component @@ -1054,10 +1055,10 @@ public final class ModItems { GT_OreDictUnificator.registerOre("platePhasedIron", ItemUtils.getSimpleStack(itemPlatePulsatingIron)); GT_OreDictUnificator.registerOre("blockVibrantAlloy", ItemUtils.getItemStackOfAmountFromOreDict("blockPhasedGold", 1)); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getPlate(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(144), 10000, 16, 4*9); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getIngot(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(144), 10000, 16, 4*9); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getNugget(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(16), 10000, 16, 4); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getBlock(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(1294), 10000, 16, 4*9*9); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getPlate(1), MaterialEIO.REDSTONE_ALLOY.getFluid(144), 16, 4*9); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getIngot(1), MaterialEIO.REDSTONE_ALLOY.getFluid(144), 16, 4*9); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getNugget(1), MaterialEIO.REDSTONE_ALLOY.getFluid(16), 16, 4); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getBlock(1), MaterialEIO.REDSTONE_ALLOY.getFluid(1294), 16, 4*9*9); } else { diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index 90e831cbb4..9b732e38e1 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -96,7 +96,7 @@ public class BaseItemComponent extends Item{ this.extraData = RGBA; this.setTextureName(CORE.MODID + ":" + "item"+ComponentTypes.CELL.COMPONENT_NAME); GameRegistry.registerItem(this, aFormattedNameForFluids); - GT_OreDictUnificator.registerOre(ComponentTypes.CELL.getOreDictName()+aFormattedNameForFluids, ItemUtils.getSimpleStack(this)); + GT_OreDictUnificator.registerOre(ComponentTypes.CELL.getOreDictName()+Utils.sanitizeStringKeepBrackets(localName), ItemUtils.getSimpleStack(this)); registerComponent(); } @@ -165,13 +165,32 @@ public class BaseItemComponent extends Item{ public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { try { + + + if (this.componentMaterial == null){ + if (this.materialName != null){ + //list.add(Utils.sanitizeStringKeepBrackets(materialName)); + } + } + if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("") && (this.componentMaterial != null)){ if (this.componentMaterial != null){ - if ((!this.componentMaterial.vChemicalFormula.equals("??")) && (!this.componentMaterial.vChemicalFormula.equals("?")) && (this.componentMaterial.getState() != MaterialState.PURE_LIQUID)) { + if (!this.componentMaterial.vChemicalFormula.contains("?") && this.componentMaterial.getState() != MaterialState.PURE_LIQUID) { list.add(Utils.sanitizeStringKeepBrackets(this.componentMaterial.vChemicalFormula)); } + else if (this.componentMaterial.vChemicalFormula.contains("?") && this.componentMaterial.getState() != MaterialState.PURE_LIQUID) { + String temp = componentMaterial.vChemicalFormula; + temp = temp.replace(" ", ""); + temp = temp.replace("-", ""); + temp = temp.replace("_", ""); + temp = temp.replace("!", ""); + temp = temp.replace("@", ""); + temp = temp.replace("#", ""); + temp = temp.replace(" ", ""); + list.add(temp); + } if (this.componentMaterial.isRadioactive){ list.add(CORE.GT_Tooltip_Radioactive); diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java index afc4b17354..9022f864cb 100644 --- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -1,14 +1,10 @@ package gtPlusPlus.core.item.base.dusts; import gtPlusPlus.core.item.base.BaseItemComponent; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; public class BaseItemDust extends BaseItemComponent { - - - private Material dustInfo; private BaseItemComponent[] mSizedDusts = new BaseItemComponent[2]; public BaseItemDust(Material aMat) { @@ -33,127 +29,10 @@ public class BaseItemDust extends BaseItemComponent { } } - private BaseItemDust(final String unlocalizedName, final String materialName, final Material matInfo, final int colour, final String pileSize, final int tier){ - this(unlocalizedName, materialName, matInfo, colour, pileSize, tier, true); - } - private BaseItemDust(String unlocalizedName, String materialName, Material matInfo, int colour, String pileSize, int tier, boolean addRecipes) { super(matInfo, ComponentTypes.DUST); - - try {/* - this.setUnlocalizedName(unlocalizedName); - this.setMaxStackSize(64); - - this.setCreativeTab(tabMisc); - this.colour = colour; - this.mTier = tier; - this.materialName = materialName; - this.dustInfo = matInfo; - this.setTextureName(this.getCorrectTexture(pileSize)); - GameRegistry.registerItem(this, unlocalizedName); - - String temp = ""; - Logger.WARNING("Unlocalized name for OreDict nameGen: "+this.getUnlocalizedName()); - if (this.getUnlocalizedName().contains("item.")){ - temp = this.getUnlocalizedName().replace("item.", ""); - Logger.WARNING("Generating OreDict Name: "+temp); - } - else { - temp = this.getUnlocalizedName(); - } - if (temp.contains("DustTiny")){ - temp = temp.replace("itemD", "d"); - Logger.WARNING("Generating OreDict Name: "+temp); - } - else if (temp.contains("DustSmall")){ - temp = temp.replace("itemD", "d"); - Logger.WARNING("Generating OreDict Name: "+temp); - } - else { - temp = temp.replace("itemD", "d"); - Logger.WARNING("Generating OreDict Name: "+temp); - } - if ((temp != null) && !temp.equals("")){ - GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this)); - } - if (addRecipes){ - this.addFurnaceRecipe(); - this.addMacerationRecipe(); - } - */} - catch (Throwable t) { - t.printStackTrace(); - } } - private String getCorrectTexture(final String pileSize){ - - if (!CORE.ConfigSwitches.useGregtechTextures || this.dustInfo.getTextureSet() == null){ - if ((pileSize == "dust") || (pileSize == "Dust")){ - this.setTextureName(CORE.MODID + ":" + "dust");} - else{ - this.setTextureName(CORE.MODID + ":" + "dust"+pileSize); - } - } - - - if (pileSize.toLowerCase().contains("small")){ - return "gregtech" + ":" + "materialicons/"+this.dustInfo.getTextureSet().mSetName+"/dustSmall"; - } - else if (pileSize.toLowerCase().contains("tiny")){ - return "gregtech" + ":" + "materialicons/"+this.dustInfo.getTextureSet().mSetName+"/dustTiny"; - } - return "gregtech" + ":" + "materialicons/"+this.dustInfo.getTextureSet().mSetName+"/dust"; - } - - /* @Override - public String getItemStackDisplayName(final ItemStack iStack) { - - String unlocal = super.getItemStackDisplayName(iStack); - if (!unlocal.toLowerCase().contains(".name")) { - return unlocal; - } - else { - return unlocal; - } - - }*/ - - /* @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - try { - if (this.dustInfo != null){ - if (entityHolding instanceof EntityPlayer){ - if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode){ - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.dustInfo.vRadiationLevel, world, entityHolding); - } - } - } - } - catch (Throwable t) { - t.printStackTrace(); - } - }*/ - - /*@SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - - if (stack.getDisplayName().toLowerCase().contains("fluorite")){ - list.add("Mined from Sandstone and Limestone."); - } - if (this.dustInfo != null){ - list.add(this.dustInfo.vChemicalFormula); - } - if (this.dustInfo.vRadiationLevel > 0){ - list.add(CORE.GT_Tooltip_Radioactive); - } - - - //} - super.addInformation(stack, aPlayer, list, bool); - }*/ - public static class DustState { static final int NORMAL = (1); static final int SMALL = (10); @@ -208,8 +87,7 @@ public class BaseItemDust extends BaseItemComponent { else if (amount == 10) { doesThings[0] = false; doesThings[1] = true; - doesThings[2] = false; - + doesThings[2] = false; } else if (amount == 100) { doesThings[0] = false; diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java index e1c3e179ee..e4fa06c58e 100644 --- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java @@ -118,7 +118,7 @@ public class BaseItemDustUnique extends Item{ private String getCorrectTexture(final String pileSize){ if (!CORE.ConfigSwitches.useGregtechTextures){ - if ((pileSize == "dust") || (pileSize == "Dust")){ + if ((pileSize.equals("dust")) || (pileSize.equals("Dust"))){ this.setTextureName(CORE.MODID + ":" + "dust");} else{ this.setTextureName(CORE.MODID + ":" + "dust"+pileSize); diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java index 51b133241b..251230932c 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java @@ -9,10 +9,10 @@ import net.minecraft.item.ItemStack; import gtPlusPlus.api.interfaces.ITileTooltip; -public class ItemBlockBasicTile extends ItemBlock{ +public class ItemBlockBasicTile extends ItemBlock { private final int mID; - + public ItemBlockBasicTile(final Block block) { super(block); this.mID = ((ITileTooltip) block).getTooltipID(); @@ -21,37 +21,50 @@ public class ItemBlockBasicTile extends ItemBlock{ @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.mID == 0){ //Fish trap - list.add("This trap catches fish faster if surrounded by more water blocks"); - list.add("Can also be placed beside upto 4 other fish traps"); - list.add("Requires at least two faces touching water"); - list.add("1/1000 chance to produce triple loot."); - } - else if (this.mID == 1){ //Modularity - list.add("Used to construct modular armour & bauble upgrades.."); - } - else if (this.mID == 2){ //Trade - list.add("Allows for SMP trade-o-mat type trading."); - } - else if (this.mID == 3){ //Project - list.add("Scan any crafting recipe in this to mass fabricate them in the Autocrafter.."); - } - else if (this.mID == 4){ //Circuit Table + if (this.mID == 0) { // Fish trap + list.add("This trap catches fish faster if surrounded by more water blocks"); + list.add("Can also be placed beside upto 4 other fish traps"); + list.add("Requires at least two faces touching water"); + list.add("1/1000 chance to produce triple loot."); + } + else if (this.mID == 1) { // Modularity + list.add("Used to construct modular armour & bauble upgrades.."); + } + else if (this.mID == 2) { // Trade + list.add("Allows for SMP trade-o-mat type trading."); + } + else if (this.mID == 3) { // Project + list.add("Scan any crafting recipe in this to mass fabricate them in the Autocrafter.."); + } + else if (this.mID == 4) { // Circuit Table list.add("Easy Circuit Configuration"); list.add("Change default setting with a Screwdriver"); - list.add("Default is used to select slot for auto-insertion"); + list.add("Default is used to select slot for auto-insertion"); + } + else if (this.mID == 5) { // Decayables Chest + list.add("Chest which holds radioactive materials"); + list.add("Items which decay will tick while inside"); + list.add("Place with right click"); + } + else if (this.mID == 6) { // Butterfly Killer + list.add("Kills Forestry Butterflies, Bats and other pests"); + list.add("Use either Formaldehyde or Hydrogen cyanide"); + list.add("Be weary of your neighbours"); + } + else if (this.mID == 7) { + + } + else if (this.mID == 8){ + } - else if (this.mID == 5){ //Decayables Chest - list.add("Chest which holds radioactive materials"); - list.add("Items which decay will tick while inside"); - list.add("Place with right click"); + else if (this.mID == 9){ + } + else { - list.add("Bad Tooltip ID - "+mID); - + list.add("Bad Tooltip ID - " + mID); } super.addInformation(stack, aPlayer, list, bool); } - } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTooltip.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTooltip.java deleted file mode 100644 index 9badd384d8..0000000000 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTooltip.java +++ /dev/null @@ -1,34 +0,0 @@ -package gtPlusPlus.core.item.base.itemblock; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; - -import gtPlusPlus.api.interfaces.ITileTooltip; - -public class ItemBlockBasicTooltip extends ItemBlock{ - - protected final int mID; - - public ItemBlockBasicTooltip(final Block block) { - super(block); - this.mID = ((ITileTooltip) block).getTooltipID(); - } - - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.mID == 0){ //blockDarkWorldPortalFrame - list.add("Assembled in the same shape as the Nether Portal."); - } - else if (this.mID == 1){ //Modularity - list.add("Used to construct modular armour & bauble upgrades.."); - } - } - - -} diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java new file mode 100644 index 0000000000..2d0fd00dd9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java @@ -0,0 +1,110 @@ +package gtPlusPlus.core.item.base.itemblock; +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlockWithMetadata; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class ItemBlockRoundRobinator extends ItemBlockWithMetadata +{ + private final Block mBlock; + + public ItemBlockRoundRobinator(final Block aBlock){ + super(aBlock, aBlock); + this.mBlock = aBlock; + } + + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add("Attempts to output items evenly on all four horizontal planes"); + if (stack.getItemDamage() == 0) { + list.add("1 Item per enabled side every 400 ticks"); + } + else if (stack.getItemDamage() == 1) { + list.add("1 Item per enabled side every 100 ticks"); + } + else if (stack.getItemDamage() == 2) { + list.add("1 Item per enabled side every 20 ticks"); + } + else if (stack.getItemDamage() == 3) { + list.add("1 Item per enabled side every 10 ticks"); + } + else if (stack.getItemDamage() == 4) { + list.add("1 Item per enabled side every tick"); + } + list.add("Top and bottom do not pull, so you must push items in"); + list.add("Sides can also be disabled with a screwdriver"); + list.add("Shift+RMB with empty hand to view inventory contents"); + super.addInformation(stack, aPlayer, list, bool); + } + + /** + * Gets an icon index based on an item's damage value + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(final int p_77617_1_) + { + return this.mBlock.getIcon(0, p_77617_1_); + } + + /** + * Returns the metadata of the block which this Item (ItemBlock) can place + */ + @Override + public int getMetadata(final int p_77647_1_) + { + return p_77647_1_; + } + + @Override + public String getUnlocalizedName(final ItemStack stack) { + return this.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return 0; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java index 277114a6ae..c5b7191ddd 100644 --- a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java @@ -128,10 +128,20 @@ public class BaseOreComponent extends Item{ public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { if (this.materialName != null && !this.materialName.equals("")){ if (this.componentMaterial != null){ - if (!this.componentMaterial.vChemicalFormula.equals("??") && !this.componentMaterial.vChemicalFormula.equals("?") && this.componentMaterial.getState() != MaterialState.PURE_LIQUID) { + if (!this.componentMaterial.vChemicalFormula.contains("?") && this.componentMaterial.getState() != MaterialState.PURE_LIQUID) { list.add(Utils.sanitizeStringKeepBrackets(this.componentMaterial.vChemicalFormula)); } - + else if (this.componentMaterial.vChemicalFormula.contains("?") && this.componentMaterial.getState() != MaterialState.PURE_LIQUID) { + String temp = componentMaterial.vChemicalFormula; + temp = temp.replace(" ", ""); + temp = temp.replace("-", ""); + temp = temp.replace("_", ""); + temp = temp.replace("!", ""); + temp = temp.replace("@", ""); + temp = temp.replace("#", ""); + temp = temp.replace(" ", ""); + list.add(temp); + } if (this.componentMaterial.isRadioactive){ list.add(CORE.GT_Tooltip_Radioactive+" | Level: "+this.componentMaterial.vRadiationLevel); } diff --git a/src/Java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java b/src/Java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java index 2e40d86473..70de4603e7 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java @@ -90,7 +90,7 @@ public class BatteryPackBaseBauble extends ElectricBaseBauble { String aString2 = StatCollector.translateToLocal("GTPP.battpack.tooltip.2"); String aString3 = StatCollector.translateToLocal("GTPP.battpack.tooltip.3"); String aString4 = StatCollector.translateToLocal("GTPP.battpack.tooltip.4"); - + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); String aEUT = aEU+"/t"; @@ -128,31 +128,34 @@ public class BatteryPackBaseBauble extends ElectricBaseBauble { @Override // TODO public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { if (!aPlayer.worldObj.isRemote) { - if (this.getCharge(aBaubleStack) >= getTransferLimit(aBaubleStack)) { - // Try Iterate Armour Slots of Player - if (aPlayer instanceof EntityPlayer) { - - // amour - for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.armorInventory) { - if (aInvStack != null) { - if (aInvStack == aBaubleStack) { - continue; - } - if (ChargingHelper.isItemValid(aInvStack)) { - double aTransferRate = 0; - final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); - if (electricItem != null) { - aTransferRate = electricItem.getTransferLimit(aInvStack); - double aItemCharge = ElectricItem.manager.getCharge(aInvStack); - if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { - if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + + try { + + if (this.getCharge(aBaubleStack) >= getTransferLimit(aBaubleStack)) { + // Try Iterate Armour Slots of Player + if (aPlayer instanceof EntityPlayer) { + + // amour + for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.armorInventory) { + if (aInvStack != null) { + if (aInvStack == aBaubleStack) { + continue; + } + if (ChargingHelper.isItemValid(aInvStack)) { + double aTransferRate = 0; + final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); + if (electricItem != null) { + aTransferRate = electricItem.getTransferLimit(aInvStack); + double aItemCharge = ElectricItem.manager.getCharge(aInvStack); + if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { + if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { if (ElectricItem.manager.getCharge(aInvStack) <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { double d = ElectricItem.manager.charge(aInvStack, aTransferRate * 16, mTier, false, true); if (d > 0) { - d = ElectricItem.manager.charge(aInvStack, aTransferRate * 16, mTier, false, false); - ElectricItem.manager.discharge(aBaubleStack, d, mTier, false, true, false); - //Logger.INFO("Charging " + aInvStack.getDisplayName() + " | " + d + " | "+electricItem.getMaxCharge(aInvStack)); + d = ElectricItem.manager.charge(aInvStack, aTransferRate * 16, mTier, false, false); + ElectricItem.manager.discharge(aBaubleStack, d, mTier, false, true, false); + //Logger.INFO("Charging " + aInvStack.getDisplayName() + " | " + d + " | "+electricItem.getMaxCharge(aInvStack)); } } else { @@ -167,29 +170,29 @@ public class BatteryPackBaseBauble extends ElectricBaseBauble { //Logger.INFO("3"); } + } + else { + //Logger.INFO("1"); + } } - else { - //Logger.INFO("1"); - } - } + } + } + if (this.getCharge(aBaubleStack) > 0) { + continue; + } else { + break; } } - if (this.getCharge(aBaubleStack) > 0) { - continue; - } else { - break; - } - } - // Hotbar Slots - int aSlotCounter = 0; - for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.mainInventory) { - if (aSlotCounter > (InventoryPlayer.getHotbarSize() - 1)) { - break; - } - aSlotCounter++; - if (aInvStack != null) { + // Hotbar Slots + int aSlotCounter = 0; + for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.mainInventory) { + if (aSlotCounter > (InventoryPlayer.getHotbarSize() - 1)) { + break; + } + aSlotCounter++; + if (aInvStack != null) { if (aInvStack == aBaubleStack) { continue; } @@ -201,26 +204,26 @@ public class BatteryPackBaseBauble extends ElectricBaseBauble { double aItemCharge = ElectricItem.manager.getCharge(aInvStack); if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { - if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { - if (ElectricItem.manager.getCharge(aInvStack) <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { - double d = ElectricItem.manager.charge(aInvStack, aTransferRate, mTier, false, true); - if (d > 0) { + if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { + if (ElectricItem.manager.getCharge(aInvStack) <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + double d = ElectricItem.manager.charge(aInvStack, aTransferRate, mTier, false, true); + if (d > 0) { d = ElectricItem.manager.charge(aInvStack, aTransferRate, mTier, false, false); ElectricItem.manager.discharge(aBaubleStack, d, mTier, false, true, false); //Logger.INFO("Charging " + aInvStack.getDisplayName() + " | " + d + " | "+electricItem.getMaxCharge(aInvStack)); - } - } - else { - //Logger.INFO("5"); } } else { - //Logger.INFO("4"); + //Logger.INFO("5"); } } else { - //Logger.INFO("3"); + //Logger.INFO("4"); } + } + else { + //Logger.INFO("3"); + } } else { @@ -228,16 +231,24 @@ public class BatteryPackBaseBauble extends ElectricBaseBauble { } } } - } - if (this.getCharge(aBaubleStack) > 0) { - continue; - } else { - break; + } + if (this.getCharge(aBaubleStack) > 0) { + continue; + } else { + break; + } } } - } + } } + catch (Throwable t) { + + } } + + + + } @Override diff --git a/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java b/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java index 04467091c0..6a8751b682 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java @@ -11,6 +11,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.DevHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -28,7 +29,7 @@ public class FireProtectionBauble extends BaseBauble { private static Field isImmuneToFire; static { - isImmuneToFire = ReflectionUtils.getField(Entity.class, "isImmuneToFire"); + isImmuneToFire = ReflectionUtils.getField(Entity.class, DevHelper.isObfuscatedEnvironment() ? "func_70045_F" : "isImmuneToFire"); } public static boolean fireImmune(Entity aEntity) { @@ -36,7 +37,11 @@ public class FireProtectionBauble extends BaseBauble { } public static boolean setEntityImmuneToFire(Entity aEntity, boolean aImmune) { - return ReflectionUtils.setField(aEntity, isImmuneToFire, aImmune); + try { + return ReflectionUtils.setField(aEntity, isImmuneToFire, aImmune); + } + catch (Throwable t) {} + return false; } public FireProtectionBauble() { diff --git a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java index 0c2bdaa3ef..0e23e9a845 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -1,10 +1,12 @@ package gtPlusPlus.core.item.chemistry; +import java.lang.reflect.Field; import java.util.ArrayList; +import java.util.List; -import forestry.plugins.PluginCore; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; +import gtPlusPlus.api.helpers.MaterialHelper; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.ItemPackage; @@ -14,6 +16,12 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.plugin.agrichem.BioRecipes; +import gtPlusPlus.plugin.agrichem.item.algae.ItemAgrichemBase; +import gtPlusPlus.plugin.agrichem.item.algae.ItemAlgaeBase; +import gtPlusPlus.plugin.agrichem.item.algae.ItemBioChip; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -40,7 +48,8 @@ public class AgriculturalChem extends ItemPackage { public static Fluid FertileManureSlurry; // Blood public static Fluid CustomBlood; - + // Red Mud + public static Fluid RedMud; /** * Items */ @@ -70,6 +79,64 @@ public class AgriculturalChem extends ItemPackage { // Fertilizer + + public static Item mAlgae; + public static Item mBioCircuit; + public static Item mAgrichemItem1; + + /* + * 0 - Algae Biomass + * 1 - Green Algae Biomass + * 2 - Brown Algae Biomass + * 3 - Golden-Brown Algae Biomass + * 4 - Red Algae Biomass + * 5 - Cellulose Fiber + * 6 - Golden-Brown Cellulose Fiber + * 7 - Red Cellulose Fiber + * 8 - Compost + * 9 - Wood Pellet + * 10 - Wood Brick + * 11 - Cellulose Pulp + * 12 - Raw Bio Resin + * 13 - Catalyst Carrier + * 14 - Green Metal Catalyst + * 15 - Alginic Acid + * 16 - Alumina + * 17 - Aluminium Pellet + * 18 - Sodium Aluminate + * 19 - Sodium Hydroxide // Exists in Newer GT + * 20 - Sodium Carbonate + * 21 - Lithium Chloride + * 22 - Pellet Mold + * 23 - Clean Aluminium Mix + */ + + public static ItemStack mAlgaeBiosmass; + public static ItemStack mGreenAlgaeBiosmass; + public static ItemStack mBrownAlgaeBiosmass; + public static ItemStack mGoldenBrownAlgaeBiosmass; + public static ItemStack mRedAlgaeBiosmass; + public static ItemStack mCelluloseFiber; + public static ItemStack mGoldenBrownCelluloseFiber; + public static ItemStack mRedCelluloseFiber; + public static ItemStack mCompost; + public static ItemStack mWoodPellet; + public static ItemStack mWoodBrick; + public static ItemStack mCellulosePulp; + public static ItemStack mRawBioResin; + public static ItemStack mCatalystCarrier; + public static ItemStack mGreenCatalyst; + public static ItemStack mAlginicAcid; + public static ItemStack mAlumina; + public static ItemStack mAluminiumPellet; + public static ItemStack mSodiumAluminate; + public static ItemStack mSodiumHydroxide; + public static ItemStack mSodiumCarbonate; + public static ItemStack mLithiumChloride; + public static ItemStack mPelletMold; + public static ItemStack mCleanAluminiumMix; + + @Override public void items() { // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon @@ -81,7 +148,100 @@ public class AgriculturalChem extends ItemPackage { "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; // Dirt Dust :) - dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + + mAlgae = new ItemAlgaeBase(); + mAgrichemItem1 = new ItemAgrichemBase(); + mBioCircuit = new ItemBioChip(); + GregtechItemList.Circuit_BioRecipeSelector.set(mBioCircuit); + + + + mAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 0, 1); + mGreenAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 1, 1); + mBrownAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 2, 1); + mGoldenBrownAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 3, 1); + mRedAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 4, 1); + mCelluloseFiber = ItemUtils.simpleMetaStack(mAgrichemItem1, 5, 1); + mGoldenBrownCelluloseFiber = ItemUtils.simpleMetaStack(mAgrichemItem1, 6, 1); + mRedCelluloseFiber = ItemUtils.simpleMetaStack(mAgrichemItem1, 7, 1); + mCompost = ItemUtils.simpleMetaStack(mAgrichemItem1, 8, 1); + mWoodPellet = ItemUtils.simpleMetaStack(mAgrichemItem1, 9, 1); + mWoodBrick = ItemUtils.simpleMetaStack(mAgrichemItem1, 10, 1); + mCellulosePulp = ItemUtils.simpleMetaStack(mAgrichemItem1, 11, 1); + mRawBioResin = ItemUtils.simpleMetaStack(mAgrichemItem1, 12, 1); + mCatalystCarrier = ItemUtils.simpleMetaStack(mAgrichemItem1, 13, 1); + mGreenCatalyst = ItemUtils.simpleMetaStack(mAgrichemItem1, 14, 1); + mAlginicAcid = ItemUtils.simpleMetaStack(mAgrichemItem1, 15, 1); + mAlumina = ItemUtils.simpleMetaStack(mAgrichemItem1, 16, 1); + mAluminiumPellet = ItemUtils.simpleMetaStack(mAgrichemItem1, 17, 1); + mSodiumAluminate = ItemUtils.simpleMetaStack(mAgrichemItem1, 18, 1); + + /** + * If It exists, don't add a new one. + */ + if (OreDictionary.doesOreNameExist("dustSodiumHydroxide_GT5U") || OreDictionary.doesOreNameExist("dustSodiumHydroxide")) { + List<ItemStack> aTest = OreDictionary.getOres("dustSodiumHydroxide", false); + ItemStack aTestStack; + if (aTest.isEmpty()) { + aTest = OreDictionary.getOres("dustSodiumHydroxide_GT5U", false); + if (aTest.isEmpty()) { + aTestStack = ItemUtils.simpleMetaStack(mAgrichemItem1, 19, 1); + } + else { + aTestStack = aTest.get(0); + } + } + else { + aTestStack = aTest.get(0); + } + mSodiumHydroxide = aTestStack; + } + else { + mSodiumHydroxide = ItemUtils.simpleMetaStack(mAgrichemItem1, 19, 1); + } + mSodiumCarbonate = ItemUtils.simpleMetaStack(mAgrichemItem1, 20, 1); + mLithiumChloride = ItemUtils.simpleMetaStack(mAgrichemItem1, 21, 1); + mPelletMold = ItemUtils.simpleMetaStack(mAgrichemItem1, 22, 1); + mCleanAluminiumMix = ItemUtils.simpleMetaStack(mAgrichemItem1, 23, 1); + + ItemUtils.addItemToOreDictionary(mGreenAlgaeBiosmass, "biomassGreenAlgae"); + ItemUtils.addItemToOreDictionary(mBrownAlgaeBiosmass, "biomassBrownAlgae"); + ItemUtils.addItemToOreDictionary(mGoldenBrownAlgaeBiosmass, "biomassGoldenBrownAlgae"); + ItemUtils.addItemToOreDictionary(mRedAlgaeBiosmass, "biomassRedAlgae"); + + ItemUtils.addItemToOreDictionary(mCelluloseFiber, "fiberCellulose"); + ItemUtils.addItemToOreDictionary(mGoldenBrownCelluloseFiber, "fiberCellulose"); + ItemUtils.addItemToOreDictionary(mGoldenBrownCelluloseFiber, "fiberGoldenBrownCellulose"); + ItemUtils.addItemToOreDictionary(mRedCelluloseFiber, "fiberCellulose"); + ItemUtils.addItemToOreDictionary(mRedCelluloseFiber, "fiberRedCellulose"); + + ItemUtils.addItemToOreDictionary(mWoodPellet, "pelletWood"); + ItemUtils.addItemToOreDictionary(mWoodBrick, "brickWood"); + ItemUtils.addItemToOreDictionary(mCellulosePulp, "pulpCellulose"); + + ItemUtils.addItemToOreDictionary(mCatalystCarrier, "catalystEmpty"); + ItemUtils.addItemToOreDictionary(mGreenCatalyst, "catalystAluminiumSilver"); + ItemUtils.addItemToOreDictionary(mAlginicAcid, "dustAlginicAcid"); + ItemUtils.addItemToOreDictionary(mAlumina, "dustAlumina"); + ItemUtils.addItemToOreDictionary(mAluminiumPellet, "pelletAluminium"); + + ItemUtils.addItemToOreDictionary(mSodiumAluminate, "dustSodiumAluminate"); + ItemUtils.addItemToOreDictionary(mSodiumHydroxide, "dustSodiumHydroxide"); + ItemUtils.addItemToOreDictionary(mSodiumCarbonate, "dustSodiumCarbonate"); + ItemUtils.addItemToOreDictionary(mLithiumChloride, "dustLithiumChloride"); + + //Handle GT NaOH dusts + List<ItemStack> NaOHSmall = OreDictionary.getOres("dustSmallSodiumHydroxide_GT5U", false); + if (!NaOHSmall.isEmpty()) { + ItemUtils.addItemToOreDictionary(NaOHSmall.get(0), "dustSmallSodiumHydroxide"); + } + List<ItemStack> NaOHTiny = OreDictionary.getOres("dustTinySodiumHydroxide_GT5U", false); + if (!NaOHTiny.isEmpty()) { + ItemUtils.addItemToOreDictionary(NaOHTiny.get(0), "dustTinySodiumHydroxide"); + } + + } @Override @@ -101,7 +261,10 @@ public class AgriculturalChem extends ItemPackage { // Sewage FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", - 45 + 175, new short[] { 65, 50, 15, 100 }, null, null, 0, true); + 45 + 175, new short[] { 65, 50, 15, 100 }, null, null, 0, true); + + RedMud = FluidUtils.generateFluidNoPrefix("mud.red.slurry", "Red Mud Slurry", 32 + 175, new short[] { 180, 35, 25, 100 }, true); + } @@ -155,20 +318,20 @@ public class AgriculturalChem extends ItemPackage { } - private static AutoMap<ItemStack> mMeats = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mFish = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mFruits = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mVege = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mNuts = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mSeeds = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mPeat = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mBones = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mBoneMeal = new AutoMap<ItemStack>(); - - private static AutoMap<ItemStack> mList_Master_Meats = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mList_Master_FruitVege = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mList_Master_Bones = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mList_Master_Seeds = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mMeats = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mFish = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mFruits = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mVege = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mNuts = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mSeeds = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mPeat = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mBones = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mBoneMeal = new AutoMap<ItemStack>(); + + private final static AutoMap<ItemStack> mList_Master_Meats = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mList_Master_FruitVege = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mList_Master_Seeds = new AutoMap<ItemStack>(); + private final static AutoMap<ItemStack> mList_Master_Bones = new AutoMap<ItemStack>(); private static void processAllOreDict() { processOreDict("listAllmeatraw", mMeats); @@ -322,6 +485,10 @@ public class AgriculturalChem extends ItemPackage { } } } + + public static ItemStack aFertForestry; + public static ItemStack aFertIC2; + private static void addMiscRecipes() { @@ -334,19 +501,32 @@ public class AgriculturalChem extends ItemPackage { * Forestry Support */ if (LoadedMods.Forestry) { - - Item aForestryFert = PluginCore.items.fertilizerCompound; - - CORE.RA.addDehydratorRecipe( - new ItemStack[] { CI.getNumberedCircuit(11), ItemUtils.getSimpleStack(aDustOrganicFert, 4) }, null, - null, new ItemStack[] { ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod }, - new int[] { 10000, 2000, 2000 }, 20 * 20, 240); + Field aItemField = ReflectionUtils.getField(ReflectionUtils.getClass("forestry.plugins.PluginCore"), "items"); + try { + Object aItemRegInstance = aItemField != null ? aItemField.get(aItemField) : null; + if (aItemRegInstance != null) { + Field aFertField = ReflectionUtils.getField(aItemRegInstance.getClass(), "fertilizerCompound"); + Object aItemInstance = aFertField.get(aItemRegInstance); + if (aItemInstance instanceof Item) { + aFertForestry = ItemUtils.getSimpleStack((Item) aItemInstance); + Item aForestryFert = (Item) aItemInstance; + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedCircuit(11), ItemUtils.getSimpleStack(aDustOrganicFert, 4) }, null, + null, new ItemStack[] { ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod }, + new int[] { 10000, 2000, 2000 }, 20 * 20, 240); + } + } + } + catch (IllegalArgumentException | IllegalAccessException e) { + + } } /** * IC2 Support */ if (LoadedMods.IndustrialCraft2) { + aFertIC2 = ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 1); CORE.RA.addDehydratorRecipe( new ItemStack[] { CI.getNumberedCircuit(12), ItemUtils.getSimpleStack(aDustOrganicFert, 4) }, null, null, new ItemStack[] { ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 3), aManureByprod, @@ -364,8 +544,8 @@ public class AgriculturalChem extends ItemPackage { GT_Values.RA.addCentrifugeRecipe(CI.getNumberedCircuit(20), ItemUtils.getSimpleStack(aManureByprod, 4), FluidUtils.getFluidStack("sulfuricacid", 250), // In Fluid FluidUtils.getFluidStack("sulfuricapatite", 50), // Out Fluid - Materials.Phosphorus.getDustSmall(2), Materials.Calcium.getDustSmall(2), - Materials.Copper.getDustTiny(1), Materials.Carbon.getDust(1), ItemUtils.getSimpleStack(dustDirt, 1), + MaterialHelper.getDustSmall(Materials.Phosphorus, 2), MaterialHelper.getDustSmall(Materials.Calcium, 2), + MaterialHelper.getDustTiny(Materials.Copper, 1), MaterialHelper.getDust(Materials.Carbon, 1), ItemUtils.getSimpleStack(dustDirt, 1), ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAmmoniumNitrate", 1), new int[] { 2500, 2500, 750, 1000, 5000, 250 }, // Chances 20 * 20, // Time @@ -380,7 +560,6 @@ public class AgriculturalChem extends ItemPackage { @Override public String errorMessage() { - // TODO Auto-generated method stub return "Failed to generate recipes for AgroChem."; } @@ -403,6 +582,9 @@ public class AgriculturalChem extends ItemPackage { addAdvancedOrganiseFertRecipes(); addMiscRecipes(); + + BioRecipes.init(); + return true; } } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java index e060723afd..8428328f37 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java @@ -1,23 +1,18 @@ package gtPlusPlus.core.item.chemistry; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.ModItems; -import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.AddGregtechRecipe; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -26,7 +21,6 @@ public class CoalTar extends ItemPackage { public static Fluid Coal_Gas; public static Fluid Coal_Oil; public static Fluid Ethylene; - public static Fluid Benzene; public static Fluid Ethylbenzene; public static Fluid Anthracene; public static Fluid Toluene; @@ -35,10 +29,6 @@ public class CoalTar extends ItemPackage { public static Fluid Sulfuric_Coal_Tar_Oil; public static Fluid Naphthalene; public static Fluid Phthalic_Acid; - public static Fluid Ethylanthraquinone2; - public static Fluid Ethylanthrahydroquinone2; - public static Fluid Hydrogen_Peroxide; - public static Fluid Lithium_Peroxide; private static void recipeEthylBenzineFuelsIntoHeavyFuel() { CORE.RA.addChemicalRecipe( @@ -264,85 +254,8 @@ public class CoalTar extends ItemPackage { } - private static void recipe2Ethylanthraquinone() { - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("dustPhthalicAnhydride", 4), - ItemUtils.getItemStackOfAmountFromOreDict("cellEthylbenzene", 2), - null, - FluidUtils.getFluidStack("fluid.2ethylanthraquinone", 2000+(144*4)), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), - 20*16); - - } - - private static void recipe2Ethylanthrahydroquinone() { - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("platePalladium", 0), - ItemUtils.getItemStackOfAmountFromOreDict("cell2Ethylanthraquinone", 1), - FluidUtils.getFluidStack("hydrogen", 500), - FluidUtils.getFluidStack("fluid.2ethylanthrahydroquinone", 1200), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1), - 20*40); - - } - - private static void recipeHydrogenPeroxide() { - GT_Values.RA.addElectrolyzerRecipe( - GT_ModHandler.getAirCell(15), - ItemUtils.getItemStackOfAmountFromOreDict("cell2Ethylanthrahydroquinone", 5), - FluidUtils.getFluidStack("fluid.anthracene", 50), - FluidUtils.getFluidStack("fluid.2ethylanthrahydroquinone", 4450), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 2), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 18), - null, - null, - null, - null, - new int[]{10000, 10000}, - 20*90, - 240); - } - - - private static void recipeLithiumHydroperoxide() { - GT_Values.RA.addElectrolyzerRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 7), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 1), - FluidUtils.getFluidStack("fluid.cellhydrogenperoxide", 50), - null, - ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 14), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1), - null, - null, - null, - null, - new int[]{10000, 10000}, - 20*60, - 240); - } - - - private static void recipeLithiumPeroxide() { - CORE.RA.addDehydratorRecipe( - new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 2), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 3) - }, - null, - null, - new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumPeroxide", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellWater", 2) - }, - new int[]{10000, 10000, 10000}, - 20*100, - 240); - } - @Override public String errorMessage() { - // TODO Auto-generated method stub return "Bad Coal Science!"; } @@ -357,11 +270,6 @@ public class CoalTar extends ItemPackage { recipeCoalTarOilToSulfuricOilToNaphthalene(); recipeNaphthaleneToPhthalicAcid(); recipePhthalicAcidToPhthalicAnhydride(); - recipe2Ethylanthraquinone(); - recipe2Ethylanthrahydroquinone(); - recipeHydrogenPeroxide(); - recipeLithiumHydroperoxide(); - recipeLithiumPeroxide(); recipeEthylBenzineFuelsIntoHeavyFuel(); @@ -390,7 +298,6 @@ public class CoalTar extends ItemPackage { @Override public void blocks() { - // TODO Auto-generated method stub } @@ -407,19 +314,11 @@ public class CoalTar extends ItemPackage { //Create Ethylene - if (!FluidUtils.doesFluidExist("Ethylene")){ - Ethylene = FluidUtils.generateFluidNonMolten("Ethylene", "Ethylene", -103, new short[]{255, 255, 255, 100}, null, null); - } - else { - Ethylene = FluidUtils.getWildcardFluidStack("Ethylene", 1).getFluid(); - } - - //Create Benzene - (Toluene + Hydrogen | 95% Benzene / 5% methane) - if (!FluidUtils.doesFluidExist("NitrousOxide")){ - Benzene = FluidUtils.generateFluidNonMolten("Benzene", "Benzene", 81, new short[]{150, 75, 0, 100}, null, null); + if (!FluidUtils.doesFluidExist("ethylene")){ + Ethylene = FluidUtils.generateFluidNonMolten("ethylene", "Ethylene", -103, new short[]{255, 255, 255, 100}, null, null); } else { - Benzene = FluidUtils.getWildcardFluidStack("Benzene", 1).getFluid(); + Ethylene = FluidUtils.getWildcardFluidStack("ethylene", 1).getFluid(); } //Create Ethylbenzene - Ethylbenzene is produced in on a large scale by combining benzene and ethylene in an acid-catalyzed chemical reaction @@ -428,13 +327,11 @@ public class CoalTar extends ItemPackage { //Create Anthracene Anthracene = FluidUtils.generateFluidNonMolten("Anthracene", "Anthracene", 340, new short[]{255, 255, 255, 100}, null, null); //Toluene - if (!FluidUtils.doesFluidExist("Toluene")){ - Toluene = FluidUtils.generateFluidNonMolten("Toluene", "Toluene", -95, new short[]{140, 70, 20, 100}, null, null); + if (!FluidUtils.doesFluidExist("liquid_toluene")){ + Toluene = FluidUtils.generateFluidNonMolten("liquid_toluene", "Toluene", -95, new short[]{140, 70, 20, 100}, null, null); } else { - Toluene = FluidUtils.getWildcardFluidStack("Toluene", 1).getFluid(); - Item itemCellToluene = new BaseItemComponent("Toluene", "Toluene", new short[]{140, 70, 20, 100}); - MaterialGenerator.addFluidCannerRecipe(ItemUtils.getEmptyCell(), ItemUtils.getSimpleStack(itemCellToluene), FluidUtils.getFluidStack(Toluene, 1000), null); + Toluene = FluidUtils.getWildcardFluidStack("liquid_toluene", 1).getFluid(); } //Create Coal Tar @@ -457,23 +354,6 @@ public class CoalTar extends ItemPackage { - //Create 2-Ethylanthraquinone - //2-Ethylanthraquinone is prepared from the reaction of phthalic anhydride and ethylbenzene - Ethylanthraquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthraquinone", "2-Ethylanthraquinone", 415, new short[]{227, 255, 159, 100}, null, null); - //Create 2-Ethylanthrahydroquinone - //Palladium plate + Hydrogen(250) + 2-Ethylanthraquinone(500) = 600 Ethylanthrahydroquinone - Ethylanthrahydroquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthrahydroquinone", "2-Ethylanthrahydroquinone", 415, new short[]{207, 225, 129, 100}, null, null); - //Create Hydrogen Peroxide - //Compressed Air(1500) + Ethylanthrahydroquinone(500) + Anthracene(5) = 450 Ethylanthraquinone && 200 Peroxide - Hydrogen_Peroxide = FluidUtils.generateFluidNonMolten("HydrogenPeroxide", "Hydrogen Peroxide", 150, new short[]{210, 255, 255, 100}, null, null); - - - - //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O - //ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); - // v - Dehydrate - //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O - Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java index c64ad07d2a..35d2066793 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java @@ -1,19 +1,29 @@ package gtPlusPlus.core.item.chemistry; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.TextureSet; +import gregtech.api.util.GT_ModHandler; import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.material.NONMATERIAL; import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.plugin.agrichem.item.algae.ItemAgrichemBase; +import net.minecraft.block.Block; +import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; public class GenericChem extends ItemPackage { @@ -66,12 +76,18 @@ public class GenericChem extends ItemPackage { public Fluid Putrescine; //https://en.wikipedia.org/wiki/Putrescine + public static Fluid Ethylanthraquinone2; + public static Fluid Ethylanthrahydroquinone2; + public static Fluid Hydrogen_Peroxide; + public static Fluid Lithium_Peroxide; + /** * Items */ // Phenol Byproducts public Item PhenolicResins; //https://en.wikipedia.org/wiki/Phenol_formaldehyde_resin + public ItemGenericChemBase mGenericChemItem1; @@ -80,7 +96,46 @@ public class GenericChem extends ItemPackage { PhenolicResins = ItemUtils.generateSpecialUseDusts("phenolicresins", "Phenolic Resin", "HOC6H4CH2OH", Utils.rgbtoHexValue(80, 40, 40))[0]; MaterialGenerator.generate(BAKELITE, false); MaterialGenerator.generate(NYLON, false); - MaterialGenerator.generate(TEFLON, false); + MaterialGenerator.generate(TEFLON, false); + + mGenericChemItem1 = new ItemGenericChemBase(); + + registerItemStacks(); + registerOreDict(); + } + + private ItemStack mCatalystCarrier; + + public ItemStack mRedCatalyst; + public ItemStack mYellowCatalyst; + public ItemStack mBlueCatalyst; + public ItemStack mOrangeCatalyst; + public ItemStack mPurpleCatalyst; + public ItemStack mBrownCatalyst; + + + public void registerItemStacks() { + + mCatalystCarrier = ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 13, 1); + + mRedCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 0, 1); + mYellowCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 1, 1); + mBlueCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 2, 1); + mOrangeCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 3, 1); + mPurpleCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 4, 1); + mBrownCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 5, 1); + + } + + public void registerOreDict() { + + ItemUtils.addItemToOreDictionary(mRedCatalyst, "catalystIronCopper"); + ItemUtils.addItemToOreDictionary(mYellowCatalyst, "catalystTungstenNickel"); + ItemUtils.addItemToOreDictionary(mBlueCatalyst, "catalystCobaltTitanium"); + ItemUtils.addItemToOreDictionary(mOrangeCatalyst, "catalystVanadiumPalladium"); + ItemUtils.addItemToOreDictionary(mPurpleCatalyst, "catalystIridiumRuthenium"); + ItemUtils.addItemToOreDictionary(mBrownCatalyst, "catalystNickelAluminium"); + } @Override @@ -115,18 +170,500 @@ public class GenericChem extends ItemPackage { Cadaverine = FluidUtils.generateFluidNoPrefix("cadaverine", "Cadaverine", 32 + 175, new short[] { 100, 70, 30, 100 }, true); Putrescine = FluidUtils.generateFluidNoPrefix("putrescine", "Putrescine", 32 + 175, new short[] { 100, 70, 30, 100 }, true); + //Create 2-Ethylanthraquinone + //2-Ethylanthraquinone is prepared from the reaction of phthalic anhydride and ethylbenzene + Ethylanthraquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthraquinone", "2-Ethylanthraquinone", 415, new short[]{227, 255, 159, 100}, null, null); + //Create 2-Ethylanthrahydroquinone + //Palladium plate + Hydrogen(250) + 2-Ethylanthraquinone(500) = 600 Ethylanthrahydroquinone + Ethylanthrahydroquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthrahydroquinone", "2-Ethylanthrahydroquinone", 415, new short[]{207, 225, 129, 100}, null, null); + //Create Hydrogen Peroxide + //Compressed Air(1500) + Ethylanthrahydroquinone(500) + Anthracene(5) = 450 Ethylanthraquinone && 200 Peroxide + Hydrogen_Peroxide = FluidUtils.generateFluidNonMolten("HydrogenPeroxide", "Hydrogen Peroxide", 150, new short[]{210, 255, 255, 100}, null, null); + + + + //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + //ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); + // v - Dehydrate + //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O + Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); + + + } @Override public String errorMessage() { - // TODO Auto-generated method stub - return "Failed to generate recipes for AgroChem."; + return "Failed to generate recipes for GenericChem."; } @Override - public boolean generateRecipes() { - + public boolean generateRecipes() { + + recipeCatalystRed(); + recipeCatalystYellow(); + recipeCatalystBlue(); + recipeCatalystOrange(); + recipeCatalystPurple(); + recipeCatalystBrown(); + + recipeNitroBenzene(); + recipeAniline(); + recipeCadaverineAndPutrescine(); + recipeCyclohexane(); + recipeCyclohexanone(); + + recipe2Ethylanthraquinone(); + recipe2Ethylanthrahydroquinone(); + recipeHydrogenPeroxide(); + recipeLithiumHydroperoxide(); + recipeLithiumPeroxide(); return true; } + + private void recipeCyclohexane() { + + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + getTierTwoChip(), + ItemUtils.getSimpleStack(mBrownCatalyst, 1) + }, + new FluidStack[] { + FluidUtils.getFluidStack(Benzene, 2000), + FluidUtils.getFluidStack("hydrogen", 10000) + }, + new ItemStack[] { + ItemUtils.getSimpleStack(mCatalystCarrier, 1) + + }, + new FluidStack[] { + FluidUtils.getFluidStack(Cyclohexane, 1000), + }, + 20 * 120, + 120, + 2); + + } + + private void recipeCyclohexanone() { + + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + getTierTwoChip(), + ItemUtils.getSimpleStack(mBlueCatalyst, 1) + }, + new FluidStack[] { + FluidUtils.getFluidStack(Cyclohexane, 2000), + FluidUtils.getFluidStack("air", 10000) + }, + new ItemStack[] { + ItemUtils.getSimpleStack(mCatalystCarrier, 1) + + }, + new FluidStack[] { + FluidUtils.getFluidStack(Cyclohexanone, 2000), + }, + 20 * 120, + 120, + 2); + + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + getTierTwoChip(), + }, + new FluidStack[] { + FluidUtils.getFluidStack(Phenol, 2000), + FluidUtils.getFluidStack("oxygen", 5000) + }, + new ItemStack[] { + + }, + new FluidStack[] { + FluidUtils.getFluidStack(Cyclohexanone, 2000), + }, + 20 * 120, + 120, + 2); + + + + + } + + private void recipeCatalystRed() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + getTierOneChip(), + ItemUtils.getSimpleStack(AgriculturalChem.mCatalystCarrier, 10), + ELEMENT.getInstance().IRON.getDust(2), + ELEMENT.getInstance().COPPER.getDust(2), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mRedCatalyst, 10), + 20 * 20, + 30); + + } + + private void recipeCatalystYellow() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + getTierThreeChip(), + ItemUtils.getSimpleStack(AgriculturalChem.mCatalystCarrier, 10), + ELEMENT.getInstance().TUNGSTEN.getDust(4), + ELEMENT.getInstance().NICKEL.getDust(4), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mYellowCatalyst, 10), + 60 * 20, + 2000); + + } + + private void recipeCatalystBlue() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + getTierTwoChip(), + ItemUtils.getSimpleStack(AgriculturalChem.mCatalystCarrier, 10), + ELEMENT.getInstance().COBALT.getDust(3), + ELEMENT.getInstance().TITANIUM.getDust(3), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mBlueCatalyst, 10), + 40 * 20, + 500); + + } + + private void recipeCatalystOrange() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + getTierTwoChip(), + ItemUtils.getSimpleStack(AgriculturalChem.mCatalystCarrier, 10), + ELEMENT.getInstance().VANADIUM.getDust(5), + ELEMENT.getInstance().PALLADIUM.getDust(5), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mOrangeCatalyst, 10), + 40 * 20, + 500); + + } + + private void recipeCatalystPurple() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + getTierFourChip(), + ItemUtils.getSimpleStack(AgriculturalChem.mCatalystCarrier, 10), + ELEMENT.getInstance().IRIDIUM.getDust(6), + ELEMENT.getInstance().RUTHENIUM.getDust(6), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mPurpleCatalyst, 10), + 120 * 20, + 8000); + + } + + private void recipeCatalystBrown() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + getTierOneChip(), + ItemUtils.getSimpleStack(AgriculturalChem.mCatalystCarrier, 10), + ELEMENT.getInstance().NICKEL.getDust(4), + ELEMENT.getInstance().ALUMINIUM.getDust(4), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mBrownCatalyst, 10), + 15 * 20, + 30); + + } + + private void recipeCadaverineAndPutrescine() { + + // Basic Recipe + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + getTierOneChip(), + ItemUtils.getSimpleStack(Items.rotten_flesh, 64) + }, + new FluidStack[] { + FluidUtils.getHotWater(2000) + }, + new ItemStack[] { + + }, + new FluidStack[] { + FluidUtils.getFluidStack(Cadaverine, 250), + FluidUtils.getFluidStack(Putrescine, 250), + }, + 20 * 120, + 120, + 1); + + // Advanced Recipe + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + getTierTwoChip(), + ItemUtils.getSimpleStack(Items.rotten_flesh, 128), + ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 8, 32) + }, + new FluidStack[] { + FluidUtils.getHotWater(3000) + }, + new ItemStack[] { + + }, + new FluidStack[] { + FluidUtils.getFluidStack(Cadaverine, 750), + FluidUtils.getFluidStack(Putrescine, 750), + }, + 20 * 120, + 240, + 2); + + } + + private void recipeAniline() { + + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + getTierThreeChip(), + ItemUtils.getSimpleStack(mBlueCatalyst, 1) + }, + new FluidStack[] { + FluidUtils.getFluidStack(NitroBenzene, 2000), + FluidUtils.getFluidStack("hydrogen", 10000) + }, + new ItemStack[] { + ItemUtils.getSimpleStack(mCatalystCarrier, 1) + + }, + new FluidStack[] { + FluidUtils.getFluidStack(Aniline, 2000), + }, + 20 * 30, + 500, + 3); + + } + + private void recipeNitroBenzene() { + + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + getTierThreeChip(), + }, + new FluidStack[] { + FluidUtils.getFluidStack(Benzene, 5000), + FluidUtils.getFluidStack("sulfuricacid", 3000), + FluidUtils.getFluidStack("nitricacid", 3000), + FluidUtils.getDistilledWater(10000) + }, + new ItemStack[] { + + }, + new FluidStack[] { + FluidUtils.getFluidStack("dilutedsulfuricacid", 3000), + FluidUtils.getFluidStack(NitroBenzene, 5000), + }, + 20 * 30, + 500, + 3); + + } + + private void recipe2Ethylanthraquinone() { + + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + CI.getNumberedCircuit(4), + ItemUtils.getItemStackOfAmountFromOreDict("dustPhthalicAnhydride", 4), + }, + new FluidStack[] { + FluidUtils.getFluidStack(CoalTar.Ethylbenzene, 2000), + }, + new ItemStack[] { + + }, + new FluidStack[] { + FluidUtils.getFluidStack(Ethylanthraquinone2, 2000+(144*4)), + }, + 20 * 15, + 120, + 1); + + /*GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustPhthalicAnhydride", 4), + ItemUtils.getItemStackOfAmountFromOreDict("cellEthylbenzene", 2), + null, + FluidUtils.getFluidStack("fluid.2ethylanthraquinone", 2000+(144*4)), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + 20*16);*/ + + } + + private void recipe2Ethylanthrahydroquinone() { + + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + CI.getNumberedCircuit(4), + ItemUtils.getSimpleStack(mOrangeCatalyst, 1), + }, + new FluidStack[] { + FluidUtils.getFluidStack(Ethylanthraquinone2, 4000), + FluidUtils.getFluidStack("hydrogen", 2000), + }, + new ItemStack[] { + + }, + new FluidStack[] { + FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 5000), + }, + 20 * 40, + 120, + 1); + + /*GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("platePalladium", 0), + ItemUtils.getItemStackOfAmountFromOreDict("cell2Ethylanthraquinone", 1), + FluidUtils.getFluidStack("hydrogen", 500), + FluidUtils.getFluidStack("fluid.2ethylanthrahydroquinone", 1200), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1), + 20*40);*/ + + } + + private void recipeLithiumPeroxide() { + CORE.RA.addDehydratorRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 2), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 3) + }, + null, + null, + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumPeroxide", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellWater", 2) + }, + new int[]{10000, 10000, 10000}, + 20*100, + 120); + } + + private void recipeLithiumHydroperoxide() { + + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + CI.getNumberedCircuit(4), + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 7), + }, + new FluidStack[] { + FluidUtils.getFluidStack("fluid.hydrogenperoxide", 2000), + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 14), + }, + new FluidStack[] { + + }, + 20 * 30, + 240, + 1); + + + + /*CORE.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 7), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 1), + 20, + FluidUtils.getFluidStack("fluid.cellhydrogenperoxide", 50), + null, + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 14), + CI.emptyCells(1), + 20*30, + 240); */ + } + + private void recipeHydrogenPeroxide() { + + CORE.RA.addFluidReactorRecipe( + new ItemStack[] { + CI.getNumberedCircuit(4), + }, + new FluidStack[] { + FluidUtils.getFluidStack("air", 15000), + FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 5000), + FluidUtils.getFluidStack("fluid.anthracene", 50), + }, + new ItemStack[] { + }, + new FluidStack[] { + FluidUtils.getFluidStack(Ethylanthraquinone2, 4000), + FluidUtils.getFluidStack("fluid.hydrogenperoxide", 2000), + }, + 20 * 30, + 240, + 1); + + /* CORE.RA.addChemicalRecipe( + GT_ModHandler.getAirCell(15), + ItemUtils.getItemStackOfAmountFromOreDict("cell2Ethylanthrahydroquinone", 5), + 20, + FluidUtils.getFluidStack("fluid.anthracene", 50), + FluidUtils.getFluidStack("fluid.2ethylanthrahydroquinone", 4450), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 2), + CI.emptyCells(18), + 20*30, + 240);*/ + + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + private static final ItemStack getTierOneChip() { + return CI.getNumberedBioCircuit(4); + } + private static final ItemStack getTierTwoChip() { + return CI.getNumberedBioCircuit(8); + } + private static final ItemStack getTierThreeChip() { + return CI.getNumberedBioCircuit(12); + } + private static final ItemStack getTierFourChip() { + return CI.getNumberedBioCircuit(16); + } + + + } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java b/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java index cb7e32eaf0..4406995d27 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java @@ -1,16 +1,6 @@ package gtPlusPlus.core.item.chemistry; -import java.util.ArrayList; - -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.ItemPackage; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.oredict.OreDictionary; public class OilChem extends ItemPackage { @@ -18,54 +8,16 @@ public class OilChem extends ItemPackage { * Fluids */ - // Poop Juice - public static Fluid PoopJuice; - // Manure Slurry - public static Fluid ManureSlurry; - // Fertile Manure Slurry - public static Fluid FertileManureSlurry; /** * Items */ - // Manure Byproducts - public static Item dustManureByproducts; - // Organic Fertilizer - public static Item dustOrganicFertilizer; - // Dirt - public static Item dustDirt; - - // Poop Juice - // vv - Centrifuge - // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny - // piles - // vv - Chem Reactor - Add Peat, Meat - // Organic Fertilizer - // vv - Dehydrate - // Fertilizer - - // Poop Juice - // vv - Mixer - Add Blood, Bone, Meat (1000L Poo, 200L Blood, x2 Bone, x3 Meat) - // Fertile Manure Slurry - // vv - Chem Reactor - Add Peat x1.5 - // Organic Fertilizer x3 - // vv - Dehydrate - // Fertilizer @Override public void items() { - // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon - dustManureByproducts = ItemUtils.generateSpecialUseDusts("ManureByproducts", "Manure Byproduct", - "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; - - // Basically Guano - dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts("OrganicFertilizer", "Organic Fertilizer", - "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; - - // Dirt Dust :) - dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + } @Override @@ -75,127 +27,19 @@ public class OilChem extends ItemPackage { @Override public void fluids() { - // Sewage - PoopJuice = FluidUtils.generateFluidNonMolten("raw.waste", "Raw Animal Waste", 32 + 175, - new short[] { 100, 70, 30, 100 }, null, null, 0, true); - - // Sewage - ManureSlurry = FluidUtils.generateFluidNonMolten("manure.slurry", "Manure Slurry", 39 + 175, - new short[] { 75, 45, 15, 100 }, null, null, 0, true); - - // Sewage - FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", - 45 + 175, new short[] { 65, 50, 15, 100 }, null, null, 0, true); - } - - private static AutoMap<ItemStack> mMeats = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mFish = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mFruits = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mVege = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mNuts = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mSeeds = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mPeat = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mBones = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mBoneMeal = new AutoMap<ItemStack>(); - - private static AutoMap<ItemStack> mList_Master_Meats = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mList_Master_FruitVege = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mList_Master_Bones = new AutoMap<ItemStack>(); - private static AutoMap<ItemStack> mList_Master_Seeds = new AutoMap<ItemStack>(); - - private static void processAllOreDict() { - processOreDict("listAllmeatraw", mMeats); - processOreDict("listAllfishraw", mFish); - processOreDict("listAllfruit", mFruits); - processOreDict("listAllVeggie", mVege); - processOreDict("listAllnut", mNuts); - processOreDict("listAllSeed", mSeeds); - processOreDict("brickPeat", mPeat); - processOreDict("bone", mBones); - processOreDict("dustBone", mBoneMeal); - // Just make a mega list, makes life easier. - if (!mMeats.isEmpty()) { - for (ItemStack g : mMeats) { - mList_Master_Meats.put(g); - } - } - if (!mFish.isEmpty()) { - for (ItemStack g : mFish) { - mList_Master_Meats.put(g); - } - } - if (!mFruits.isEmpty()) { - for (ItemStack g : mFruits) { - mList_Master_FruitVege.put(g); - } - } - if (!mVege.isEmpty()) { - for (ItemStack g : mVege) { - mList_Master_FruitVege.put(g); - } - } - if (!mNuts.isEmpty()) { - for (ItemStack g : mNuts) { - mList_Master_FruitVege.put(g); - } - } - if (!mSeeds.isEmpty()) { - for (ItemStack g : mSeeds) { - mList_Master_Seeds.put(g); - } - } - if (!mBoneMeal.isEmpty()) { - for (ItemStack g : mBoneMeal) { - mList_Master_Bones.put(g); - } - } - if (!mBones.isEmpty()) { - for (ItemStack g : mBones) { - mList_Master_Bones.put(g); - } - } - } - - private static void processOreDict(String aOreName, AutoMap<ItemStack> aMap) { - ArrayList<ItemStack> aTemp = OreDictionary.getOres(aOreName); - if (!aTemp.isEmpty()) { - for (ItemStack stack : aTemp) { - aMap.put(stack); - } - } + } - private static void addBasicSlurryRecipes() {} - - private static void addAdvancedSlurryRecipes() {} - - private static void addBasicOrganiseFertRecipes() {} - - private static void addAdvancedOrganiseFertRecipes() {} - - private static void addMiscRecipes() {} + @Override public String errorMessage() { - // TODO Auto-generated method stub - return "Failed to generate recipes for AgroChem."; + return "Failed to generate recipes for OilChem."; } @Override public boolean generateRecipes() { - // Organise OreDict - processAllOreDict(); - - // Slurry Production - addBasicSlurryRecipes(); - addAdvancedSlurryRecipes(); - - // Organic Fert. Production - addBasicOrganiseFertRecipes(); - addAdvancedOrganiseFertRecipes(); - - addMiscRecipes(); return true; } } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java index f2b5d0683c..bbdf322817 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -9,6 +9,7 @@ import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; +import gtPlusPlus.api.helpers.MaterialHelper; import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; @@ -25,7 +26,7 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; public class RocketFuels extends ItemPackage { - + public static HashSet<String> mValidRocketFuelNames = new HashSet<String>(); public static HashMap<Integer, Fluid> mValidRocketFuels = new HashMap<Integer, Fluid>(); @@ -40,6 +41,7 @@ public class RocketFuels extends ItemPackage { public static Fluid Nitrous_Oxide; public static Fluid Hydrated_Ammonium_Nitrate_Slurry; public static Fluid Liquid_Oxygen; + public static Fluid Liquid_Hydrogen; public static Fluid Formaldehyde; @@ -51,16 +53,16 @@ public class RocketFuels extends ItemPackage { public static Item Ammonium_Nitrate_Dust; public static Item Formaldehyde_Catalyst; - + public static void createKerosene(){ - - - + + + FluidStack fuelA = FluidUtils.getFluidStack("diesel", 300); FluidStack fuelB = FluidUtils.getFluidStack("fuel", 300); - - - + + + if (fuelA != null){ //GT_Values.RA.addDistilleryRecipe(23, fuelA, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(Kerosene, 100), 200, 64, false); @@ -134,7 +136,11 @@ public class RocketFuels extends ItemPackage { private static void createLOX() { GT_Values.RA.addVacuumFreezerRecipe(ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), ItemUtils.getItemStackOfAmountFromOreDict("cellLiquidOxygen", 1), 20*16); CORE.RA.addAdvancedFreezerRecipe(new ItemStack[] {}, new FluidStack[] {FluidUtils.getFluidStack("oxygen", 3000)}, new FluidStack[] {FluidUtils.getFluidStack(Liquid_Oxygen, 3000)}, new ItemStack[] {}, new int[] {}, 20*16, 240, 0); + } + private static void createLOH() { + GT_Values.RA.addVacuumFreezerRecipe(ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), ItemUtils.getItemStackOfAmountFromOreDict("cellLiquidhydrogen", 1), 20*16); + CORE.RA.addAdvancedFreezerRecipe(new ItemStack[] {}, new FluidStack[] {FluidUtils.getFluidStack("hydrogen", 300)}, new FluidStack[] {FluidUtils.getFluidStack(Liquid_Hydrogen, 300)}, new ItemStack[] {}, new int[] {}, 20*4, 540, 0); } private static void createHydratedAmmoniumNitrateSlurry() { @@ -213,7 +219,7 @@ public class RocketFuels extends ItemPackage { 0, 0, 256)); //Fuel Value - + mRocketFuels.put(1, new Recipe_GT( true, new ItemStack[] {}, @@ -225,7 +231,7 @@ public class RocketFuels extends ItemPackage { 0, 0, 512)); //Fuel Value - + mRocketFuels.put(2, new Recipe_GT( true, new ItemStack[] {}, @@ -237,7 +243,7 @@ public class RocketFuels extends ItemPackage { 0, 0, 768)); //Fuel Value - + mRocketFuels.put(3, new Recipe_GT( true, new ItemStack[] {}, @@ -249,8 +255,8 @@ public class RocketFuels extends ItemPackage { 0, 0, 1024)); //Fuel Value - - + + //Add in default Diesel for the Buggy mValidRocketFuels.put(-1, Diesel); @@ -287,7 +293,7 @@ public class RocketFuels extends ItemPackage { GT_Values.RA.addCentrifugeRecipe( CI.getNumberedCircuit(23), - ItemUtils.getItemStackOfAmountFromOreDict("cellRP1Fuel", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellRP1", 1), FluidUtils.getFluidStack(Liquid_Oxygen, 4000), FluidUtils.getFluidStack(RP1_Plus_Liquid_Oxygen, 200), CI.emptyCells(1), @@ -348,7 +354,7 @@ public class RocketFuels extends ItemPackage { 20*48, 480); } - + GT_Values.RA.addCentrifugeRecipe( CI.getNumberedCircuit(23), @@ -429,6 +435,7 @@ public class RocketFuels extends ItemPackage { if (!CORE.GTNH) { createLOX(); } + createLOH(); createHydratedAmmoniumNitrateSlurry(); @@ -439,18 +446,18 @@ public class RocketFuels extends ItemPackage { createRocketFuels(); addRocketFuelsToMap(); - + return true; } @Override public boolean onLoadComplete(FMLLoadCompleteEvent event) { - + if (MathUtils.randInt(1, 2) > 0) { return false; } - + Materials aMaterial_Chloramine = MaterialUtils.getMaterial("Chloramine"); Materials aMaterial_Dimethylamine = MaterialUtils.getMaterial("Dimethylamine"); @@ -458,33 +465,35 @@ public class RocketFuels extends ItemPackage { Materials aMaterial_NitrogenDioxide = MaterialUtils.getMaterial("NitrogenDioxide"); Materials aMaterial_DinitrogenTetroxide = MaterialUtils.getMaterial("DinitrogenTetroxide"); Materials aMaterial_Dimethylhydrazine = MaterialUtils.getMaterial("Dimethylhydrazine"); - + Materials aMaterial_Oxygen = Materials.Oxygen; Materials aMaterial_Water = Materials.Water; Materials aMaterial_HypochlorousAcid = MaterialUtils.getMaterial("HypochlorousAcid"); Materials aMaterial_Ammonia = MaterialUtils.getMaterial("Ammonia"); Materials aMaterial_Methanol = MaterialUtils.getMaterial("Methanol"); - + if (aMaterial_Chloramine == null || aMaterial_Dimethylamine == null || aMaterial_DilutedHydrochloricAcid == null || aMaterial_Dimethylhydrazine == null || aMaterial_NitrogenDioxide == null || aMaterial_DinitrogenTetroxide == null || aMaterial_HypochlorousAcid == null || aMaterial_Ammonia == null || aMaterial_Methanol == null) { return false; } - - ItemStack aCellEmpty = CI.emptyCells(1); - ItemStack aCellWater = aMaterial_Water.getCells(1); - ItemStack aCellOxygen = aMaterial_Oxygen.getCells(1); - ItemStack aCellChloramine = aMaterial_Chloramine.getCells(1); - ItemStack aCellDimethylamine = aMaterial_Dimethylamine.getCells(1); - ItemStack aCellDilutedHydrochloricAcid = aMaterial_DilutedHydrochloricAcid.getCells(1); - ItemStack aCellNitrogenDioxide = aMaterial_NitrogenDioxide.getCells(1); - ItemStack aCellDinitrogenTetroxide = aMaterial_DinitrogenTetroxide.getCells(1); - ItemStack aCellDimethylhydrazine = aMaterial_Dimethylhydrazine.getCells(1); - - - + + MaterialHelper.getCells(aMaterial_Water, 1); + ItemStack aCellEmpty = CI.emptyCells(1); + ItemStack aCellWater = MaterialHelper.getCells(aMaterial_Water, 1); + ItemStack aCellOxygen = MaterialHelper.getCells(aMaterial_Oxygen, 1); + ItemStack aCellChloramine = MaterialHelper.getCells(aMaterial_Chloramine, 1); + ItemStack aCellDimethylamine = MaterialHelper.getCells(aMaterial_Dimethylamine, 1); + ItemStack aCellDilutedHydrochloricAcid = MaterialHelper.getCells(aMaterial_DilutedHydrochloricAcid, 1); + ItemStack aCellNitrogenDioxide = MaterialHelper.getCells(aMaterial_NitrogenDioxide, 1); + ItemStack aCellDinitrogenTetroxide = MaterialHelper.getCells(aMaterial_DinitrogenTetroxide, 1); + ItemStack aCellDimethylhydrazine = MaterialHelper.getCells(aMaterial_Dimethylhydrazine, 1); + + + + GT_Recipe aChemReactor_1 = new Recipe_GT( @@ -510,10 +519,10 @@ public class RocketFuels extends ItemPackage { 0, //Dura 0, //Eu 0); //Special - - - - + + + + GT_Recipe aChemReactor_Basic_1 = new Recipe_GT( true, //Optimise new ItemStack[] {}, //I @@ -561,18 +570,18 @@ public class RocketFuels extends ItemPackage { 0, //Dura 0, //Eu 0); //Special - - - - - - - - - - - - + + + + + + + + + + + + GT_Recipe aChemReactor_Adv_1 = new Recipe_GT( true, //Optimise @@ -598,26 +607,26 @@ public class RocketFuels extends ItemPackage { 0, //Eu 0); //Special - - + + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); - - - - - - /* GT_Values.RA.addChemicalRecipe( Materials.Chloramine.getCells(2), GT_Utility.getIntegratedCircuit(1), Materials.Dimethylamine.getGas(5000), Materials.Dimethylhydrazine.getFluid(6000), Materials.DilutedHydrochloricAcid.getCells(1), Materials.Empty.getCells(1), 960, 480); + + + + + + /* GT_Values.RA.addChemicalRecipe( Materials.Chloramine.getCells(2), GT_Utility.getIntegratedCircuit(1), Materials.Dimethylamine.getGas(5000), Materials.Dimethylhydrazine.getFluid(6000), Materials.DilutedHydrochloricAcid.getCells(1), Materials.Empty.getCells(1), 960, 480); GT_Values.RA.addChemicalRecipe( Materials.Dimethylamine.getCells(5), GT_Utility.getIntegratedCircuit(1), Materials.Chloramine.getFluid(2000), Materials.Dimethylhydrazine.getFluid(6000), Materials.DilutedHydrochloricAcid.getCells(1), Materials.Empty.getCells(4), 960, 480); GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Chloramine.getCells(2), Materials.Empty.getCells(4), Materials.Dimethylamine.getGas(5000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), GT_Values.NI, 960, 480); GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Dimethylamine.getCells(5), Materials.Empty.getCells(1), Materials.Chloramine.getFluid(2000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), GT_Values.NI, 960, 480); GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Dimethylamine.getCells(5), Materials.Chloramine.getCells(2), Materials.Chloramine.getFluid(2000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), Materials.DilutedHydrochloricAcid.getCells(1), 960, 480); GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(24)}, new FluidStack[]{Materials.HypochlorousAcid.getFluid(3000), Materials.Ammonia.getGas(8000), Materials.Methanol.getFluid(12000)}, new FluidStack[]{Materials.Dimethylhydrazine.getFluid(12000), Materials.DilutedHydrochloricAcid.getFluid(2000), Materials.Water.getFluid(9000)}, null, 1040, 480); - + GT_Values.RA.addChemicalRecipe(GT_Utility.getIntegratedCircuit(2), GT_Values.NI, Materials.NitrogenDioxide.getGas(1000), Materials.DinitrogenTetroxide.getGas(1000), GT_Values.NI, 640); GT_Values.RA.addChemicalRecipe(Materials.NitrogenDioxide.getCells(1), GT_Utility.getIntegratedCircuit(2), GT_Values.NF, Materials.DinitrogenTetroxide.getGas(1000), Materials.Empty.getCells(1), 640); GT_Values.RA.addChemicalRecipe(Materials.NitrogenDioxide.getCells(1), GT_Utility.getIntegratedCircuit(12), GT_Values.NF, GT_Values.NF, Materials.DinitrogenTetroxide.getCells(1), 640); @@ -629,25 +638,25 @@ public class RocketFuels extends ItemPackage { GT_Values.RA.addMixerRecipe(Materials.Dimethylhydrazine.getCells(2), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Oxygen.getGas(1000), new FluidStack(ItemList.sRocketFuel, 3000), Materials.Empty.getCells(2), 60, 16); GT_Values.RA.addMixerRecipe(Materials.Oxygen.getCells(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Dimethylhydrazine.getFluid(2000), new FluidStack(ItemList.sRocketFuel, 3000), Materials.Empty.getCells(1), 60, 16); - - */ - - - - - - - - - + + */ + + + + + + + + + //Get Rocket Fuel - + //Find recipes using default values - + //Remove - + //Rebake map - + return true; }; @@ -662,18 +671,28 @@ public class RocketFuels extends ItemPackage { @Override public void fluids() { - + //Register default fluids Diesel = MaterialUtils.getMaterial("Fuel", "Diesel").getFluid(1).getFluid(); - Oil_Heavy = MaterialUtils.getMaterial("OilHeavy", "Oil").getFluid(1).getFluid(); - + // 5.08 Compat + if (!FluidUtils.doesFluidExist("liquid_heavy_oil")){ + Oil_Heavy = FluidUtils.generateFluidNoPrefix("liquid_heavy_oil", "Heavy Oil", 200, new short[]{10, 10, 10, 100}); + } + else { + Oil_Heavy = MaterialUtils.getMaterial("OilHeavy", "Oil").getFluid(1).getFluid(); + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellOilHeavy", 1) == null){ + new BaseItemComponent("OilHeavy", "Heavy Oil", new short[] {10, 10, 10}); + } + } + + //Create Kerosene Kerosene = FluidUtils.generateFluidNonMolten("Kerosene", "Kerosene", 500, new short[]{150, 40, 150, 100}, null, null); CoalTar.Coal_Oil = Kerosene; - + //RP! Focket Fuel - RP1 = FluidUtils.generateFluidNonMolten("RP1Fuel", "RP-1 Rocket Fuel", 500, new short[]{210, 50, 50, 100}, null, null); + RP1 = FluidUtils.generateFluidNonMolten("RP1Fuel", "RP-1", 500, new short[]{210, 50, 50, 100}, null, null); //Create Nitrogen Tetroxide Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("NitrogenTetroxide", "Nitrogen Tetroxide", -11, new short[]{170, 170, 0, 100}, null, null); @@ -697,7 +716,7 @@ public class RocketFuels extends ItemPackage { new BaseItemComponent("NitrousOxide", "Nitrous Oxide", new short[] {10, 10, 175}); } } - + //Unsymmetrical_Dimethylhydrazine if (FluidUtils.getFluidStack("1,1dimethylhydrazine", 1) == null){ Unsymmetrical_Dimethylhydrazine = FluidUtils.generateFluidNonMolten("UnsymmetricalDimethylhydrazine", "Unsymmetrical Dimethylhydrazine", -57, new short[]{70, 210, 20, 100}, null, null); @@ -727,16 +746,31 @@ public class RocketFuels extends ItemPackage { new BaseItemComponent("LiquidOxygen", "Liquid Oxygen", new short[] {10, 10, 175}); } } - + + //Create Liquid_Hydrogen + if (FluidUtils.getFluidStack("LiquidHydrogen", 1) == null && FluidUtils.getFluidStack("liquidhydrogen", 1) == null){ + Liquid_Hydrogen = FluidUtils.generateFluidNonMolten("LiquidHydrogen", "Liquid Hydrogen", -240, new short[]{75, 75, 220, 100}, null, null); + } + else { + if (FluidUtils.getFluidStack("LiquidHydrogen", 1) != null ) { + Liquid_Hydrogen = FluidUtils.getFluidStack("LiquidHydrogen", 1).getFluid(); + } + else { + Liquid_Hydrogen = FluidUtils.getFluidStack("liquidhydrogen", 1).getFluid(); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellLiquidHydrogen", 1) == null){ + new BaseItemComponent("LiquidHydrogen", "Liquid Hydrogen", new short[] {10, 10, 175}); + } + } Formaldehyde = FluidUtils.generateFluidNonMolten("Formaldehyde", "Formaldehyde", -92, new short[]{150, 75, 150, 100}, null, null); - + Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("RocketFuelMixA", "H8N4C2O4 Rocket Fuel", -185, new short[]{50, 220, 50, 100}, null, null); - RP1_Plus_Liquid_Oxygen = FluidUtils.generateFluidNonMolten("RocketFuelMixB", "Rp-1 Fuel Mixture", -250, new short[]{250, 50, 50, 100}, null, null); + RP1_Plus_Liquid_Oxygen = FluidUtils.generateFluidNonMolten("RocketFuelMixB", "Rp-1 Rocket Fuel", -250, new short[]{250, 50, 50, 100}, null, null); Monomethylhydrazine_Plus_Nitric_Acid = FluidUtils.generateFluidNonMolten("RocketFuelMixC", "CN3H7O3 Rocket Fuel", -300, new short[]{125, 75, 180, 100}, null, null); Dense_Hydrazine_Mix = FluidUtils.generateFluidNonMolten("RocketFuelMixD", "Dense Hydrazine Fuel Mixture", -250, new short[]{175, 80, 120, 100}, null, null); - + } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java b/src/Java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java index 1e833a7b00..10eaaf0da9 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java @@ -149,7 +149,7 @@ public class StandardBaseParticles extends BaseItemParticle { @Override public void registerIcons(IIconRegister reg) { for (int i = 0; i < this.icons.length; i++) { - this.icons[i] = reg.registerIcon(CORE.MODID + ":" + "particle/"+i); + this.icons[i] = reg.registerIcon(CORE.MODID + ":" + "particle/new/"+i); } } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java b/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java new file mode 100644 index 0000000000..8a003ec7aa --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java @@ -0,0 +1,162 @@ +package gtPlusPlus.core.item.chemistry.general; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +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.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemGenericChemBase extends Item { + + final protected IIcon base[]; + + final private int aMetaSize = 6; + + /* + * 0 - Red Metal Catalyst //FeCu + * 1 - Yellow Metal Catalyst //WNi + * 2 - Blue Metal Catalyst //CoTi + * 3 - Orange Metal Catalyst //Vanadium Pd + * 4 - Purple Metal Catalyst //IrIdium Ruthenium + * 5 - Brown Metal Catalyst //NiAl + * + */ + + public ItemGenericChemBase() { + this.setHasSubtypes(true); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + base = new IIcon[aMetaSize]; + this.setUnlocalizedName("BasicGenericChemItem"); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean shouldRotateAroundWhenRendering() { + return super.shouldRotateAroundWhenRendering(); + } + + @Override + public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + super.onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + return super.getItemStackDisplayName(aStack); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + try { + + } + catch (Throwable t) { + t.printStackTrace(); + } + super.addInformation(aStack, p_77624_2_, aList, p_77624_4_); + } + + @Override + public EnumRarity getRarity(ItemStack p_77613_1_) { + return EnumRarity.common; + } + + @Override + public boolean requiresMultipleRenderPasses() { + return false; + } + + @Override + public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { + for (int i=0;i<aMetaSize;i++) { + aList.add(ItemUtils.simpleMetaStack(aItem, i, 1)); + } + } + + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return stack.getItemDamage(); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } + + @Override + public void registerIcons(final IIconRegister u) { + for (int i=0;i<this.aMetaSize;i++) { + String aPath = CORE.MODID + ":" + "science/general/MetaItem1/"+i; + this.base[i] = u.registerIcon(aPath); + } + } + + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + return this.base[damage]; + } + + @Override + public IIcon getIconFromDamage(int damage) { + return this.base[damage]; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return this.base[stack.getItemDamage()]; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return this.base[stack.getItemDamage()]; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + +} diff --git a/src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java b/src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java index 1c28f99ff8..3f8e31d8d2 100644 --- a/src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java +++ b/src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java @@ -26,7 +26,9 @@ public class ItemDummyResearch extends ItemGenericToken { RESEARCH_4_BASIC_PHYSICS("Basic Physics", "Fundamental laws of motion"), RESEARCH_5_ADV_PHYSICS("Advanced Physics", "Advanced knowledge!"), RESEARCH_6_BASIC_METALLURGY("Basic Metallurgy", "Information about material smelting"), - RESEARCH_7_ADV_METALLURGY("Advanced Metallurgy", "Advanced Material Sciences!"); + RESEARCH_7_ADV_METALLURGY("Advanced Metallurgy", "Advanced Material Sciences!"), + RESEARCH_8_TURBINE_AUTOMATION("Turbine Automation", "You really don't want to share this with anyone!"), + RESEARCH_9_CLOAKING("Cloaking Technologies", "Sneaking around like a mouse"); diff --git a/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java b/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java index 5ef72b6f17..b74b7972be 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java @@ -71,6 +71,9 @@ public class ItemControlCore extends Item { @Override public String getItemStackDisplayName(final ItemStack tItem) { + if (tItem == null) { + return "Control Core"; + } String aReturnValue = super.getItemStackDisplayName(tItem); if (tItem != null) { try { diff --git a/src/Java/gtPlusPlus/core/item/general/ItemGenericToken.java b/src/Java/gtPlusPlus/core/item/general/ItemGenericToken.java index c076bf5c95..21d2c6e120 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemGenericToken.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemGenericToken.java @@ -148,8 +148,19 @@ public class ItemGenericToken extends CoreItem { } @Override - public int getItemStackLimit(ItemStack stack) { - return mMaxStackSizes.get(stack.getItemDamage()); + public int getItemStackLimit(ItemStack aStack) { + if (aStack == null) { + return getItemStackLimit(); + } + else { + Integer aSize = mMaxStackSizes.get(aStack.getItemDamage()); + if (aSize != null) { + return aSize; + } + else { + return getItemStackLimit(); + } + } } @Override diff --git a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java index c8acdc2152..82bb29b5bf 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java @@ -2,23 +2,10 @@ package gtPlusPlus.core.item.general; import java.util.List; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - import baubles.api.BaubleType; import baubles.api.IBauble; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; @@ -31,6 +18,16 @@ import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItemManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; @Optional.InterfaceList(value = {@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles")}) public class ItemHealingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble{ @@ -232,7 +229,7 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI @Override //TODO public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase arg1) { - if (!arg1.worldObj.isRemote){ + if (arg1 != null && arg1.worldObj != null && !arg1.worldObj.isRemote){ //Try Charge First diff --git a/src/Java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java b/src/Java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java index 7134df4a44..fa008bf1a3 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java @@ -2,10 +2,15 @@ package gtPlusPlus.core.item.general; import java.util.List; +import baubles.api.BaubleType; +import baubles.api.IBauble; import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.client.Minecraft; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.events.CustomMovementHandler; +import gtPlusPlus.core.handler.events.SneakManager; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -14,14 +19,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import baubles.api.BaubleType; -import baubles.api.IBauble; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.handler.events.CustomMovementHandler; -import gtPlusPlus.core.handler.events.SneakManager; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; - @Optional.InterfaceList(value = {@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles")}) public class ItemSlowBuildingRing extends Item implements IBauble{ @@ -42,23 +39,11 @@ public class ItemSlowBuildingRing extends Item implements IBauble{ if (worldObj.isRemote) { return; } - if (player instanceof EntityPlayer){ - for (final ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { - if (is == itemStack) { - continue; - } - if (is != null) { - - - } - } - } super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); } @Override public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return (EnumChatFormatting.YELLOW+"Slow Building Ring"+EnumChatFormatting.GRAY); } @@ -68,6 +53,7 @@ public class ItemSlowBuildingRing extends Item implements IBauble{ return false; } + @SuppressWarnings("unchecked") @Override public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { list.add(""); @@ -95,13 +81,32 @@ public class ItemSlowBuildingRing extends Item implements IBauble{ @Override //TODO public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) { - doEffect(arg1); + try { + EntityPlayer aPlayer; + if (arg1 instanceof EntityPlayer) { + aPlayer = (EntityPlayer) arg1; + SneakManager s = SneakManager.get(aPlayer); + s.putRingOn(); + } + } + catch (Throwable t) { + t.printStackTrace(); + } } @Override //TODO public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) { - SneakManager.setSprintingStateON(); - SneakManager.setCrouchingStateOFF(); + try { + EntityPlayer aPlayer; + if (arg1 instanceof EntityPlayer) { + aPlayer = (EntityPlayer) arg1; + SneakManager s = SneakManager.get(aPlayer); + s.takeRingOff(); + } + } + catch (Throwable t) { + t.printStackTrace(); + } } @Override //TODO @@ -110,20 +115,26 @@ public class ItemSlowBuildingRing extends Item implements IBauble{ } private static void doEffect(final EntityLivingBase arg1){ - if (arg1.worldObj.isRemote){ - if (!arg1.isSneaking()){ - arg1.setSneaking(true); - Minecraft.getMinecraft().thePlayer.setSneaking(true); - SneakManager.setSprintingStateOFF(); - SneakManager.setCrouchingStateON(); - } - else if (arg1.isSneaking()){ - arg1.setSprinting(false); - Minecraft.getMinecraft().thePlayer.setSprinting(true); - SneakManager.setSprintingStateOFF(); - SneakManager.setCrouchingStateON(); + try { + // Get World + World aWorld = arg1.worldObj; + if (aWorld != null && !aWorld.isRemote) { + EntityPlayer aPlayer; + if (arg1 instanceof EntityPlayer) { + aPlayer = (EntityPlayer) arg1; + SneakManager s = SneakManager.get(aPlayer); + if (!aPlayer.isSneaking()){ + aPlayer.setSneaking(true); + } + if (aPlayer.isSprinting()) { + aPlayer.setSprinting(false); + } + } } } + catch (Throwable t) { + t.printStackTrace(); + } } } diff --git a/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java b/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java index aa6fdabacc..9994c7d362 100644 --- a/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java +++ b/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java @@ -1,5 +1,7 @@ package gtPlusPlus.core.item.materials; +import static gtPlusPlus.core.util.minecraft.ItemUtils.getSimpleStack; + import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; @@ -10,6 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.handler.Recipes.DecayableRecipe; import gtPlusPlus.core.item.base.BaseItemTickable; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.EntityUtils; @@ -25,6 +28,7 @@ public class DustDecayable extends BaseItemTickable { this.turnsIntoItem = turnsInto; this.radLevel = radLevel; GT_OreDictUnificator.registerOre(unlocal, ItemUtils.getSimpleStack(this)); + new DecayableRecipe(maxTicks, getSimpleStack(this), getSimpleStack(turnsInto)); } @Override diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java b/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java index d0f3005d00..0170df0dc7 100644 --- a/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java +++ b/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java @@ -7,6 +7,7 @@ import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; @@ -62,19 +63,22 @@ public class DebugScanner extends CoreItem { PlayerUtils.messagePlayer(player, "Invisible? "+entity.isInvisible()); PlayerUtils.messagePlayer(player, "Age: "+entity.ticksExisted); - if (entity instanceof EntityLiving) { - EntityLiving g = (EntityLiving) entity; + if (entity instanceof EntityLivingBase) { + EntityLivingBase g = (EntityLivingBase) entity; PlayerUtils.messagePlayer(player, "Health: "+g.getHealth()+"/"+g.getMaxHealth()); PlayerUtils.messagePlayer(player, "On ground? "+g.onGround); - PlayerUtils.messagePlayer(player, "Can Loot? "+g.canPickUpLoot()); - PlayerUtils.messagePlayer(player, "Child? "+g.isChild()); - if (entity instanceof EntityPlayer) { - EntityPlayer y = (EntityPlayer) entity; - PlayerUtils.messagePlayer(player, "Experience: "+y.experience); - PlayerUtils.messagePlayer(player, "Name: "+y.getCommandSenderName()); - } + PlayerUtils.messagePlayer(player, "Child? "+g.isChild()); + } + if (entity instanceof EntityLiving) { + EntityLiving g = (EntityLiving) entity; + PlayerUtils.messagePlayer(player, "Can Loot? "+g.canPickUpLoot()); } + if (entity instanceof EntityPlayer) { + EntityPlayer y = (EntityPlayer) entity; + PlayerUtils.messagePlayer(player, "Experience: "+y.experience); + PlayerUtils.messagePlayer(player, "Name: "+y.getCommandSenderName()); + } } return true; diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java b/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java index 0c31b999cd..a48573888e 100644 --- a/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java +++ b/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java @@ -1127,7 +1127,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri else if ((aTileEntity instanceof IFluidTank || aTileEntity instanceof IFluidHandler)) { if (aTileEntity instanceof IFluidTank) { Logger.INFO("Tile Was instanceof IFluidTank."); - FluidStack f = ((IFluidTank) aTileEntity).getFluid(); + FluidStack f = ((IFluidTank) aTileEntity).getFluid(); if (aSetFluid == null) { aSetFluid = f; aSetFluid.amount = f.amount; diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 38be7d8593..2a267dc16d 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -5,12 +5,16 @@ import java.util.concurrent.ConcurrentHashMap; import com.mojang.authlib.GameProfile; +import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.core.util.sys.GeoUtils; import gtPlusPlus.core.util.sys.NetworkUtils; +import gtPlusPlus.preloader.CORE_Preloader; 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; @@ -51,7 +55,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.7.03.01"; + public static final String VERSION = "1.7.03.45"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); @@ -75,7 +79,7 @@ public class CORE { public static int turbineCutoffBase = 75000; //GT++ Fake Player Profile - public static GameProfile gameProfile = new GameProfile(UUID.nameUUIDFromBytes("gtplusplus.core".getBytes()), "[GT++]"); + public static final GameProfile gameProfile = new GameProfile(UUID.nameUUIDFromBytes("gtplusplus.core".getBytes()), "[GT++]"); public static final WeakHashMap<World, EntityPlayerMP> fakePlayerCache = new WeakHashMap<World, EntityPlayerMP>(); //Tooltips; public static final String GT_Tooltip = "Added by: " + EnumChatFormatting.DARK_GREEN+"Alkalus "+EnumChatFormatting.GRAY+"- "+EnumChatFormatting.RED+"[GT++]"; @@ -87,6 +91,7 @@ public class CORE { //Because I want to be lazy. Beyond Reality Classic Var. public static boolean BRC = false; + public static final String SEPERATOR = "/"; /** @@ -209,6 +214,7 @@ public class CORE { public static boolean enableCustomCircuits = true; public static boolean enableOldGTcircuits = false; public static boolean disableZombieReinforcement = false; + public static int enableWatchdogBGM = CORE_Preloader.enableWatchdogBGM; //GT Fixes public static boolean enableNitroFix = false; @@ -284,7 +290,20 @@ public class CORE { } public static final void crash() { - System.exit(0); + Logger.INFO("=========================================================="); + Logger.INFO("[GT++ CRASH]"); + Logger.INFO("=========================================================="); + Logger.INFO("Oooops..."); + Logger.INFO("This should only happy in a development environment or when something really bad happens."); + Logger.INFO("=========================================================="); + Logger.INFO("Called from: "+ReflectionUtils.getMethodName(0)); + Logger.INFO(ReflectionUtils.getMethodName(1)); + Logger.INFO(ReflectionUtils.getMethodName(2)); + Logger.INFO(ReflectionUtils.getMethodName(3)); + Logger.INFO(ReflectionUtils.getMethodName(4)); + Logger.INFO(ReflectionUtils.getMethodName(5)); + Logger.INFO(ReflectionUtils.getMethodName(6)); + FMLCommonHandler.instance().exitJava(0, true); } public static final void gc() { diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java index 5a2b75337b..d96875b811 100644 --- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -55,6 +55,7 @@ public class LoadedMods { public static boolean Witchery = false; public static boolean Waila = false; public static boolean CropsPlusPlus = false; //Barts Crop Mod + public static boolean Reliquary = false; @@ -102,6 +103,11 @@ public class LoadedMods { Logger.INFO("Components enabled for: Crops++"); totalMods++; } + if (Loader.isModLoaded("xreliquary")) { + Reliquary = true; + Logger.INFO("Components enabled for: Reliquary"); + totalMods++; + } if (Loader.isModLoaded("TConstruct")){ TiCon = true; Logger.INFO("Components enabled for: Tinkers Construct"); diff --git a/src/Java/gtPlusPlus/core/lib/VanillaColours.java b/src/Java/gtPlusPlus/core/lib/VanillaColours.java new file mode 100644 index 0000000000..9a7a82cb1f --- /dev/null +++ b/src/Java/gtPlusPlus/core/lib/VanillaColours.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.lib; + +import gtPlusPlus.core.util.Utils; + +public enum VanillaColours { + + BONE_MEAL(249, 255, 254), INK_BLACK(29, 29, 33), COCOA_BEANS(131, 84, 50), LAPIS_LAZULI(60, 68, 170), + DYE_WHITE(249, 255, 254), DYE_BLACK(29, 29, 33), DYE_RED(176, 46, 38), DYE_GREEN(94, 124, 22), + DYE_CYAN(22, 156, 156), DYE_PINK(243, 139, 170), DYE_LIME(128, 199, 31), DYE_YELLOW(254, 216, 61), + DYE_ORANGE(249, 128, 29), DYE_BROWN(131, 84, 50), DYE_LIGHT_BLUE(58, 179, 218), DYE_LIGHT_PURPLE(199, 78, 189), + DYE_LIGHT_GRAY(157, 157, 151), DYE_DARK_BLUE(60, 68, 170), DYE_DARK_PURPLE(137, 50, 184), DYE_DARK_GRAY(71, 79, 82); + + private final int r, g, b; + + private VanillaColours(int aR, int aG, int aB) { + r = aR; + g = aG; + b = aB; + } + + public short[] getAsShort() { + return new short[] { (short) r, (short) g, (short) b }; + } + + public int getAsInt() { + return Utils.rgbtoHexValue(r, g, b); + } +} diff --git a/src/Java/gtPlusPlus/core/material/ELEMENT.java b/src/Java/gtPlusPlus/core/material/ELEMENT.java index 99586b37fe..ba2579aa97 100644 --- a/src/Java/gtPlusPlus/core/material/ELEMENT.java +++ b/src/Java/gtPlusPlus/core/material/ELEMENT.java @@ -217,9 +217,32 @@ public final class ELEMENT { //Runescape materials - public static final Material BLACK_METAL = new Material("Black Metal", MaterialState.SOLID, TextureSet.SET_METALLIC, new short[] {5, 5, 5}, 2350, 4650, 24, 17, false, "҈", 0, new MaterialStack[]{new MaterialStack(getInstance().LEAD, 15), new MaterialStack(getInstance().TUNGSTEN, 25), new MaterialStack(getInstance().CARBON, 60)});//Not a GT Inherited Material + public static final Material BLACK_METAL = new Material("Black Metal", MaterialState.SOLID, TextureSet.SET_METALLIC, new short[] {5, 5, 5}, 2350, 4650, 24, 17, false, "҈", 0, new MaterialStack[]{new MaterialStack(getInstance().LEAD, 15), new MaterialStack(getInstance().MANGANESE, 25), new MaterialStack(getInstance().CARBON, 60)});//Not a GT Inherited Material public static final Material WHITE_METAL = new Material("White Metal", MaterialState.SOLID, TextureSet.SET_METALLIC, new short[] {255, 255, 255}, 4560, 7580, 35, 41, false, "҉", 0, new MaterialStack[]{new MaterialStack(getInstance().COPPER, 5), new MaterialStack(getInstance().ANTIMONY, 10), new MaterialStack(getInstance().PLATINUM, 10), new MaterialStack(getInstance().TIN, 75)});//Not a GT Inherited Material - public static final Material GRANITE = new Material("Ancient Granite", MaterialState.SOLID, TextureSet.SET_SAND, new short[] {107, 107, 107}, 500, 2000, 16, 12, false, "«»", 0, false);//Not a GT Inherited Material + + public static final Material GRANITE = new Material( + "Ancient Granite", + MaterialState.SOLID, + TextureSet.SET_SAND, + new short[] {107, 107, 107}, + 500, + 2000, + 16, + 12, + false, + "«»", + 0, + false, + new MaterialStack[]{ + new MaterialStack(getInstance().OXYGEN, 30), + new MaterialStack(getInstance().IRON, 20), + new MaterialStack(getInstance().SILICON, 20), + new MaterialStack(getInstance().ALUMINIUM, 10), + new MaterialStack(getInstance().POTASSIUM, 10), + new MaterialStack(getInstance().CALCIUM, 5), + new MaterialStack(getInstance().SODIUM, 5) + });//Not a GT Inherited Material + public static final Material RUNITE = new Material("Runite", MaterialState.SOLID, TextureSet.SET_FINE, new short[] {60, 200, 190}, 6750, 11550, 73, 87, true, "§", 0);//Not a GT Inherited Material public static final Material DRAGON_METAL = new Material("Dragonblood", MaterialState.SOLID, TextureSet.SET_SHINY, new short[] {220, 40, 20, 2}, 10160, 17850, 96, 105, true, "۞", 0);//Not a GT Inherited Material diff --git a/src/Java/gtPlusPlus/core/material/MISC_MATERIALS.java b/src/Java/gtPlusPlus/core/material/MISC_MATERIALS.java index c7032ab7c7..8dad69f70a 100644 --- a/src/Java/gtPlusPlus/core/material/MISC_MATERIALS.java +++ b/src/Java/gtPlusPlus/core/material/MISC_MATERIALS.java @@ -1,22 +1,25 @@ package gtPlusPlus.core.material; +import gregtech.api.enums.Materials; import gregtech.api.enums.TextureSet; -import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.client.CustomTextureSet.TextureSets; import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; public final class MISC_MATERIALS { - + /* * Some of these materials purely exist as data objects, items will most likely be assigned seperately. * Most are just compositions which will have dusts assigned to them. */ - + public static void run() { MaterialUtils.generateSpecialDustAndAssignToAMaterial(STRONTIUM_OXIDE, false); MaterialUtils.generateSpecialDustAndAssignToAMaterial(STRONTIUM_HYDROXIDE, false); + WATER.registerComponentForMaterial(FluidUtils.getWater(1000)); } - + public static final Material STRONTIUM_OXIDE = new Material( "Strontium Oxide", MaterialState.SOLID, @@ -33,8 +36,255 @@ public final class MISC_MATERIALS { new MaterialStack[]{ new MaterialStack(ELEMENT.getInstance().STRONTIUM, 1), new MaterialStack(ELEMENT.getInstance().OXYGEN, 1) - }); - + }); + + public static final Material SELENIUM_DIOXIDE = new Material( + "Selenium Dioxide", + MaterialState.PURE_LIQUID, //State + null, //Material Colour + -1, //Melting Point in C + -1, //Boiling Point in C + -1, //Protons + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().SELENIUM, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2) + }); + + public static final Material SELENIOUS_ACID = new Material( + "Selenious Acid", + MaterialState.PURE_LIQUID, //State + null, //Material Colour + -1, //Melting Point in C + -1, //Boiling Point in C + -1, //Protons + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(SELENIUM_DIOXIDE, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 8), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 4) + }); + + public static final Material HYDROGEN_CYANIDE = new Material( + "Hydrogen Cyanide", + MaterialState.PURE_LIQUID, //State + null, //Material Colour + 4, //Melting Point in C + 26, //Boiling Point in C + -1, //Protons + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().CARBON, 1), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1) + }); + + public static final Material CARBON_MONOXIDE = new Material( + "Carbon Monoxide", + MaterialState.PURE_LIQUID, //State + null, //Material Colour + -1, //Melting Point in C + -1, //Boiling Point in C + -1, //Protons + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().CARBON, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1) + }); + + public static final Material CARBON_DIOXIDE = new Material( + "Carbon Dioxide", + MaterialState.PURE_LIQUID, //State + null, //Material Colour + -1, //Melting Point in C + -1, //Boiling Point in C + -1, //Protons + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().CARBON, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2) + }); + + + /* + * Rare Earth Materials + */ + + public static final Material RARE_EARTH_LOW = new Material( + "Rare Earth (I)", //Material Name + MaterialState.ORE, //State + TextureSets.GEM_A.get(), //Texture Set + null, //Material Colour + 1200, + 2500, + -1, + -1, + -1, //Radiation + new MaterialStack[]{ + new MaterialStack(ORES.GREENOCKITE, 1), + new MaterialStack(ORES.LANTHANITE_CE, 1), + new MaterialStack(ORES.AGARDITE_CD, 1), + new MaterialStack(ORES.XENOTIME, 1), + new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.NetherQuartz), 1), + new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.Galena), 1), + new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.Chalcopyrite), 1), + new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.Cobaltite), 1), + new MaterialStack(ELEMENT.STANDALONE.GRANITE, 1) + }); + + public static final Material RARE_EARTH_MID = new Material( + "Rare Earth (II)", //Material Name + MaterialState.ORE, //State + TextureSets.ENRICHED.get(), //Texture Set + null, //Material Colour + 3500, + 5000, + -1, + -1, + -1, //Radiation + new MaterialStack[]{ + new MaterialStack(ORES.LANTHANITE_ND, 1), + new MaterialStack(ORES.AGARDITE_ND, 1), + new MaterialStack(ORES.YTTRIAITE, 1), + new MaterialStack(ORES.CROCROITE, 1), + new MaterialStack(ORES.NICHROMITE, 1), + new MaterialStack(ORES.ZIRCON, 1), + new MaterialStack(ELEMENT.STANDALONE.GRANITE, 1), + new MaterialStack(ELEMENT.STANDALONE.BLACK_METAL, 1), + new MaterialStack(ELEMENT.STANDALONE.RUNITE, 1) + }); + + public static final Material RARE_EARTH_HIGH = new Material( + "Rare Earth (III)", //Material Name + MaterialState.ORE, //State + TextureSets.REFINED.get(), //Texture Set + null, //Material Colour + 5200, + 7500, + -1, + -1, + -1, //Radiation + new MaterialStack[]{ + new MaterialStack(ORES.GADOLINITE_Y, 1), + new MaterialStack(ORES.LEPERSONNITE, 1), + new MaterialStack(ORES.FLORENCITE, 1), + new MaterialStack(ORES.FLUORCAPHITE, 1), + new MaterialStack(ORES.LAUTARITE, 1), + new MaterialStack(ORES.DEMICHELEITE_BR, 1), + new MaterialStack(ORES.ALBURNITE, 1), + new MaterialStack(ORES.KASHINITE, 1), + new MaterialStack(ORES.AGARDITE_LA, 1), + }); + + public static final Material WATER = new Material( + "Water", + MaterialState.PURE_LIQUID, + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1) + }); + + //OH + public static final Material HYDROXIDE = new Material( + "Hydroxide", //Material Name + MaterialState.PURE_LIQUID, //State + null, //Material Colour + -1, //Melting Point in C + -1, //Boiling Point in C + -1, //Protons + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1) + }); + + //NH3 + public static final Material AMMONIA = new Material( + "Ammonia", //Material Name + MaterialState.PURE_LIQUID, //State + null, //Material Colour + -77, //Melting Point in C + -33, //Boiling Point in C + -1, //Protons + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 3) + }); + + //NH4 + public static final Material AMMONIUM = new Material( + "Ammonium", //Material Name + MaterialState.PURE_LIQUID, //State + null, //Material Colour + -1, //Melting Point in C + -1, //Boiling Point in C + -1, //Protons + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 4) + }); + + + public static final Material HYDROGEN_CHLORIDE = new Material( + "Hydrogen Chloride", + MaterialState.PURE_LIQUID, + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1), + }); + + + public static final Material SODIUM_CHLORIDE = new Material( + "Sodium Chloride", + MaterialState.PURE_LIQUID, + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().SODIUM, 1), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1), + }); + + + public static final Material SODIUM_HYDROXIDE = new Material( + "Sodium Hydroxide", + MaterialState.PURE_LIQUID, + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().SODIUM, 1), + new MaterialStack(HYDROXIDE, 1), + }); + + public static final Material SALT_WATER = new Material( + "Salt Water", + MaterialState.PURE_LIQUID, + new MaterialStack[]{ + new MaterialStack(WATER, 3), + new MaterialStack(SODIUM_CHLORIDE, 1), + }); + + public static final Material BRINE = new Material( + "Brine", + MaterialState.PURE_LIQUID, + new MaterialStack[]{ + new MaterialStack(SALT_WATER, 1), + new MaterialStack(SODIUM_CHLORIDE, 2), + }); + public static final Material STRONTIUM_HYDROXIDE = new Material( "Strontium Hydroxide", MaterialState.SOLID, @@ -50,40 +300,9 @@ public final class MISC_MATERIALS { false, new MaterialStack[]{ new MaterialStack(ELEMENT.getInstance().STRONTIUM, 1), - new MaterialStack(FLUORIDES.HYDROXIDE, 2) - }); - - public static final Material SELENIUM_DIOXIDE = new Material( - "Selenium Dioxide", - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().SELENIUM, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 2) - }); - - public static final Material SELENIOUS_ACID = new Material( - "Selenious Acid", - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(SELENIUM_DIOXIDE, 1), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 8), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 4) - }); - - - + new MaterialStack(MISC_MATERIALS.HYDROXIDE, 2) + }); + + + } diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 6b6be32107..b5922dde53 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -85,8 +85,17 @@ public class Material { public static AutoMap<Materials> invalidMaterials = new AutoMap<Materials>(); + + + public Material(final String materialName, final MaterialState defaultState, final MaterialStack... inputs){ + this(materialName, defaultState, null, inputs); + } + + public Material(final String materialName, final MaterialState defaultState, final short[] rgba, final MaterialStack... inputs){ + this(materialName, defaultState, null, 0, rgba, -1, -1, -1, -1, false, "", 0, false, false, inputs); + } - public Material(String materialName, MaterialState defaultState, short[] rgba, int radiationLevel, MaterialStack[] materialStacks) { + public Material(final String materialName, final MaterialState defaultState, final short[] rgba, int radiationLevel, MaterialStack... materialStacks) { this(materialName, defaultState, null, 0, rgba, -1, -1, -1, -1, false, "", radiationLevel, false, materialStacks); } @@ -94,8 +103,8 @@ public class Material { this(materialName, defaultState, null, 0, rgba, j, k, l, m, false, "", radiationLevel, false, materialStacks); } - public Material(String materialName, MaterialState defaultState, final TextureSet set, short[] rgba, int j, int k, int l, int m, int radiationLevel, MaterialStack[] materialStacks){ - this(materialName, defaultState, set, 0, rgba, j, k, l, m, false, "", radiationLevel, false, materialStacks); + public Material(String materialName, MaterialState defaultState, final TextureSet set, short[] rgba, int meltingPoint, int boilingPoint, int protons, int neutrons, int radiationLevel, MaterialStack[] materialStacks){ + this(materialName, defaultState, set, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, false, "", radiationLevel, false, materialStacks); } public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final MaterialStack... inputs){ @@ -228,7 +237,7 @@ public class Material { int hashSize = MathUtils.howManyPlaces(aValueForGen); String a = String.valueOf(aValueForGen); - String b = null; + String b = ""; if (hashSize < 9) { int aSecondHash = this.materialState.hashCode(); @@ -370,9 +379,6 @@ public class Material { aDataSet.put(m.getStackMaterial().vRadiationLevel); } byte aAverage = MathUtils.getByteAverage(aDataSet); - if (aAverage > Byte.MAX_VALUE || aAverage < Byte.MIN_VALUE) { - aAverage = 0; - } if (aAverage > 0) { Logger.MATERIALS(this.getLocalizedName()+" is radioactive due to trace elements. Level: "+aAverage+"."); this.isRadioactive = true; @@ -463,32 +469,31 @@ public class Material { } if (generateFluid){ - final Materials isValid = Materials.get(this.getLocalizedName()); - if (FluidUtils.getFluidStack(localizedName, 1) != null){ - this.vMoltenFluid = FluidUtils.getFluidStack(localizedName, 1).getFluid(); - } - else if (isValid == null || isValid == Materials._NULL){ - queueFluidGeneration(); + final Materials isValid = Materials.get(this.getLocalizedName()); + FluidStack aTest = FluidUtils.getWildcardFluidStack(localizedName, 1); + if (aTest != null){ + this.vMoltenFluid = aTest.getFluid(); } else { - if (isValid.mFluid != null){ - this.vMoltenFluid = isValid.mFluid; - } - else if (isValid.mGas != null){ - this.vMoltenFluid = isValid.mGas; - } - else { + if (isValid == null || isValid == Materials._NULL){ queueFluidGeneration(); } + else { + FluidStack aTest2 = FluidUtils.getWildcardFluidStack(localizedName, 1); + if (aTest2 != null){ + this.vMoltenFluid = aTest2.getFluid(); + } + else { + queueFluidGeneration(); + } + } } - this.vPlasma = this.generatePlasma(); } else { this.vMoltenFluid = null; this.vPlasma = null; } - String ratio = ""; if (this.vSmallestRatio != null) { for (int hu=0;hu<this.vSmallestRatio.length;hu++){ @@ -523,11 +528,6 @@ public class Material { } } - public Material(String string, MaterialState solid, TextureSet setShiny, int i, short[] s, int j, int k, int l, - int m, boolean b, String string2, int n) { - // TODO Auto-generated constructor stub - } - public final TextureSet getTextureSet() { synchronized(this) { return textureSet; @@ -860,10 +860,9 @@ public class Material { ItemStack a1 = getOre(1); Item a2 = a1.getItem(); Block a3 = Block.getBlockFromItem(a2); - - //Logger.DEBUG_MATERIALS("[Invalid Ore] Is a1 valid? "+(a1 != null)); - //Logger.DEBUG_MATERIALS("[Invalid Ore] Is a2 valid? "+(a2 != null)); - //Logger.DEBUG_MATERIALS("[Invalid Ore] Is a3 valid? "+(a3 != null)); + if (a3 != null) { + return a3; + } Block x = Block.getBlockFromItem(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ore"+Utils.sanitizeString(this.unlocalizedName), stacksize).getItem()); if (x != null){ @@ -1095,96 +1094,41 @@ public class Material { if (this.materialState == MaterialState.ORE){ return null; } + + Fluid aGTBaseFluid = null; - final Materials isValid = Materials.get(this.getLocalizedName()); - //Logger.MATERIALS("Is "+this.getLocalizedName()+" a Gregtech material? "+(isValid != null && isValid != Materials._NULL)+" | Found "+isValid.mDefaultLocalName); - if (isValid != Materials._NULL){ - for (Materials m : invalidMaterials.values()){ - if (isValid == m){ - Logger.MATERIALS("Trying to generate a fluid for blacklisted material: "+m.mDefaultLocalName); - FluidStack a1 = m.getFluid(1); - FluidStack a2 = m.getGas(1); - FluidStack a3 = m.getMolten(1); - FluidStack a4 = m.getSolid(1); - FluidStack a5 = m.getPlasma(1); - if (a1 != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. Fluid."); - return a1.getFluid(); - } - if (a2 != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. Gas."); - return a2.getFluid(); - } - if (a3 != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. Molten."); - return a3.getFluid(); - } - if (a4 != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. Solid."); - return a4.getFluid(); - } - if (a5 != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. Plasma."); - return a5.getFluid(); - } - Logger.MATERIALS("Using null."); - return null; - } - } - } - - if (this.materialState == MaterialState.SOLID){ - if (isValid.mFluid != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. mFluid."); - return isValid.mFluid; - } - else if (isValid.mStandardMoltenFluid != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. mStandardMoltenFluid."); - return isValid.mStandardMoltenFluid; - } - } - else if (this.materialState == MaterialState.GAS){ - if (isValid.mGas != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. mGas."); - return isValid.mGas; - } - } - else if (this.materialState == MaterialState.LIQUID || this.materialState == MaterialState.PURE_LIQUID){ - if (isValid.mFluid != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. mFluid."); - return isValid.mFluid; - } - else if (isValid.mGas != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. mGas."); - return isValid.mGas; - } - else if (isValid.mStandardMoltenFluid != null){ - Logger.MATERIALS("Using a pre-defined Fluid from GT. mStandardMoltenFluid."); - return isValid.mStandardMoltenFluid; - } - } + // Clean up Internal Fluid Generation + final Materials n1 = MaterialUtils.getMaterial(this.getLocalizedName(), Utils.sanitizeString(this.getLocalizedName())); + final Materials n2 = MaterialUtils.getMaterial(this.getUnlocalizedName(), Utils.sanitizeString(this.getUnlocalizedName())); - FluidStack aTest1 = FluidUtils.getFluidStack("molten."+Utils.sanitizeString(this.getLocalizedName()), 1); - FluidStack aTest2 = FluidUtils.getFluidStack("fluid."+Utils.sanitizeString(this.getLocalizedName()), 1); - FluidStack aTest3 = FluidUtils.getFluidStack(Utils.sanitizeString(this.getLocalizedName()), 1); + FluidStack f1 = FluidUtils.getWildcardFluidStack(n1, 1); + FluidStack f2 = FluidUtils.getWildcardFluidStack(n2, 1); + FluidStack f3 = FluidUtils.getWildcardFluidStack(Utils.sanitizeString(this.getUnlocalizedName(), new char[] {'-', '_'}), 1); + FluidStack f4 = FluidUtils.getWildcardFluidStack(Utils.sanitizeString(this.getLocalizedName(), new char[] {'-', '_'}), 1); - if (aTest1 != null) { - Logger.MATERIALS("Found FluidRegistry entry for "+"molten."+Utils.sanitizeString(this.getLocalizedName())); - return aTest1.getFluid(); + if (f1 != null) { + aGTBaseFluid = f1.getFluid(); + } + else if (f2 != null) { + aGTBaseFluid = f2.getFluid(); } - if (aTest2 != null) { - Logger.MATERIALS("Found FluidRegistry entry for "+"fluid."+Utils.sanitizeString(this.getLocalizedName())); - return aTest2.getFluid(); + else if (f3 != null) { + aGTBaseFluid = f3.getFluid(); } - if (aTest3 != null) { - Logger.MATERIALS("Found FluidRegistry entry for "+Utils.sanitizeString(this.getLocalizedName())); - return aTest3.getFluid(); + else if (f4 != null) { + aGTBaseFluid = f4.getFluid(); } + ItemStack aFullCell = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.getUnlocalizedName(), 1); + ItemStack aFullCell2 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.getLocalizedName(), 1); + ItemStack aFullCell3 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+Utils.sanitizeString(this.getUnlocalizedName(), new char[] {'-', '_'}), 1); + ItemStack aFullCell4 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+Utils.sanitizeString(this.getLocalizedName(), new char[] {'-', '_'}), 1); + Logger.MATERIALS("Generating our own fluid."); - //Generate a Cell if we need to - if (aFullCell == null){ + //Generate a Cell if we need to, but first validate all four searches are invalid + + if (!ItemUtils.checkForInvalidItems(new ItemStack[] {aFullCell, aFullCell2, aFullCell3, aFullCell4})){ if (this.vGenerateCells){ Item g = new BaseItemCell(this); aFullCell = ItemUtils.getSimpleStack(g); @@ -1194,7 +1138,29 @@ public class Material { Logger.MATERIALS("Did not generate a cell for "+this.getUnlocalizedName()); } } + else { + // One cell we searched for was valid, let's register it. + if (aFullCell != null) { + this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell); + } + else if (aFullCell2 != null) { + this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell2); + } + else if (aFullCell3 != null) { + this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell3); + } + else if (aFullCell4 != null) { + this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell4); + } + } + // We found a GT fluid, let's use it. + // Good chance we registered the cell from this material too. + if (aGTBaseFluid != null) { + return aGTBaseFluid; + } + + // This fluid does not exist at all, time to generate it. if (this.materialState == MaterialState.SOLID){ return FluidUtils.addGTFluid( this.getUnlocalizedName(), @@ -1334,7 +1300,17 @@ public class Material { } + public boolean registerComponentForMaterial(FluidStack aStack) { + return registerComponentForMaterial(this, aStack); + } + private static boolean registerComponentForMaterial(Material componentMaterial, FluidStack aStack) { + if (componentMaterial != null && aStack != null && componentMaterial.vMoltenFluid == null) { + componentMaterial.vMoltenFluid = aStack.getFluid(); + return true; + } + return false; + } public boolean registerComponentForMaterial(ComponentTypes aPrefix, ItemStack aStack) { return registerComponentForMaterial(this, aPrefix.getGtOrePrefix(), aStack); diff --git a/src/Java/gtPlusPlus/core/material/MaterialGenerator.java b/src/Java/gtPlusPlus/core/material/MaterialGenerator.java index 44c02bc70d..20fdfd3c8c 100644 --- a/src/Java/gtPlusPlus/core/material/MaterialGenerator.java +++ b/src/Java/gtPlusPlus/core/material/MaterialGenerator.java @@ -2,13 +2,6 @@ package gtPlusPlus.core.material; import java.util.Set; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.Recipe_GT; - import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -24,7 +17,11 @@ 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.nugget.BaseItemNugget; -import gtPlusPlus.core.item.base.ore.*; +import gtPlusPlus.core.item.base.ore.BaseItemCentrifugedCrushedOre; +import gtPlusPlus.core.item.base.ore.BaseItemCrushedOre; +import gtPlusPlus.core.item.base.ore.BaseItemImpureDust; +import gtPlusPlus.core.item.base.ore.BaseItemPurifiedCrushedOre; +import gtPlusPlus.core.item.base.ore.BaseItemPurifiedDust; import gtPlusPlus.core.item.base.plates.BaseItemPlate; import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; import gtPlusPlus.core.item.base.rings.BaseItemRing; @@ -36,7 +33,21 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.loaders.*; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_AlloySmelter; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Assembler; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_BlastSmelter; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_DustGeneration; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Extruder; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_FluidCanning; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Fluids; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_MaterialProcessing; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Ore; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Plates; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_ShapedCrafting; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public class MaterialGenerator { @@ -48,21 +59,36 @@ public class MaterialGenerator { @SuppressWarnings("unused") private static volatile Block tempBlock; - public static void addFluidExtractionRecipe(ItemStack a, Object b, FluidStack c, int a1, int a2, int a3) { - GT_Recipe r = new Recipe_GT( - true, - new ItemStack[] {a, b != null ? (ItemStack) b : null}, - new ItemStack[] {}, - null, - new int[] {}, - new FluidStack[] {}, - new FluidStack[] {c}, - a2, a3, a1); - new RecipeGen_FluidCanning(r, true); + + public static boolean addFluidExtractionRecipe(ItemStack aEmpty, ItemStack aRemains, FluidStack aFluid) { + return addFluidExtractionRecipe(aEmpty, aRemains, aFluid, null, null); } - public static void addFluidCannerRecipe(ItemStack aFullContainer, ItemStack aEmpty, FluidStack rFluidIn, FluidStack rFluidOut) { - GT_Recipe r = new Recipe_GT( + /** + * Called Reflectively from CORE.RA.addFluidExtractionRecipe + * @param aSpecial + * @return + */ + public static boolean addFluidExtractionRecipe(ItemStack aEmpty, ItemStack aRemains, FluidStack aFluid, Integer aDuration, Integer aEU) { + RecipeGen_FluidCanning g = new RecipeGen_FluidCanning(true, aEmpty, aRemains, aFluid, aDuration, aEU); + if (g != null && g.valid()) { + //Logger.INFO("[FIND] Adding Extraction recipe for "+ItemUtils.getItemName(aEmpty)+", "+ItemUtils.getItemName(aRemains)+", "+ItemUtils.getFluidName(aFluid)); + return true; + } + Logger.INFO("[ERROR] FAILED adding Extraction recipe for "+ItemUtils.getItemName(aEmpty)+", "+ItemUtils.getItemName(aRemains)+", "+ItemUtils.getFluidName(aFluid)); + return false; + } + + + public static boolean addFluidCannerRecipe(ItemStack aEmpty, ItemStack aFullContainer, FluidStack aFluidIn, FluidStack rFluidOut) { + return addFluidCannerRecipe(aEmpty, aFullContainer, aFluidIn, rFluidOut, null, null); + } + /** + * Called Reflectively from CORE.RA.addFluidCannerRecipe + * @return + */ + public static boolean addFluidCannerRecipe(ItemStack aEmpty, ItemStack aFullContainer, FluidStack aFluidIn, FluidStack rFluidOut, Integer aTime, Integer aEu) { + /*GT_Recipe r = new Recipe_GT( true, new ItemStack[] {aEmpty}, new ItemStack[] {aFullContainer}, @@ -70,12 +96,13 @@ public class MaterialGenerator { new int[] {}, new FluidStack[] {rFluidIn}, new FluidStack[] {rFluidOut}, - 0, 0, 0); - new RecipeGen_FluidCanning(r, false); - } - - public static void generateFluidExtractorRecipe(GT_Recipe recipe, boolean extracting) { - new RecipeGen_FluidCanning(recipe, extracting); + 0, 0, 0);*/ + //new RecipeGen_FluidCanning(r, false); + RecipeGen_FluidCanning g = new RecipeGen_FluidCanning(false, aEmpty, aFullContainer, aFluidIn, null, null, 0); + if (g != null && g.valid()) { + return true; + } + return false; } public static void generate(final Material matInfo){ diff --git a/src/Java/gtPlusPlus/core/material/ORES.java b/src/Java/gtPlusPlus/core/material/ORES.java index 0e1691a557..c2556b60f1 100644 --- a/src/Java/gtPlusPlus/core/material/ORES.java +++ b/src/Java/gtPlusPlus/core/material/ORES.java @@ -90,9 +90,10 @@ public final class ORES { -1, -1, //Radiation new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().LEAD, 1), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 4) + new MaterialStack(ELEMENT.getInstance().LEAD, 2), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), + new MaterialStack(ELEMENT.getInstance().CAESIUM, 1), }); public static final Material NICHROMITE = new Material( @@ -126,7 +127,10 @@ public final class ORES { -1, //Radiation new MaterialStack[]{ new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), //Y not YT/YB - new MaterialStack(ELEMENT.getInstance().OXYGEN, 3) + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), + new MaterialStack(ELEMENT.getInstance().IRON, 4), + new MaterialStack(ELEMENT.getInstance().TIN, 1), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 2) }); //Samarskite_Y @@ -260,6 +264,7 @@ public final class ORES { -1, //Radiation new MaterialStack[]{ new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), + new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 1), new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 1), new MaterialStack(ELEMENT.getInstance().OXYGEN, 4) }); @@ -794,6 +799,21 @@ public final class ORES { new MaterialStack(ELEMENT.getInstance().SULFUR, 16), new MaterialStack(ELEMENT.getInstance().OXYGEN, 15) }); + + public static final Material GREENOCKITE = new Material( + "Greenockite", //Material Name + MaterialState.ORE, //State + TextureSets.GEM_A.get(), //Texture Set + new short[]{110, 193, 25, 0}, //Material Colour + -1, + -1, + -1, + -1, + -1, //Radiation + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().CADMIUM, 2), + new MaterialStack(ELEMENT.getInstance().SULFUR, 2), + }); public static final Material DEEP_EARTH_REACTOR_FUEL_DEPOSIT = new Material( diff --git a/src/Java/gtPlusPlus/core/material/nuclear/FLUORIDES.java b/src/Java/gtPlusPlus/core/material/nuclear/FLUORIDES.java index b7a5f6074d..bfa08d3c29 100644 --- a/src/Java/gtPlusPlus/core/material/nuclear/FLUORIDES.java +++ b/src/Java/gtPlusPlus/core/material/nuclear/FLUORIDES.java @@ -3,6 +3,7 @@ package gtPlusPlus.core.material.nuclear; import gregtech.api.enums.Materials; import gregtech.api.enums.TextureSet; import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MISC_MATERIALS; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.material.state.MaterialState; @@ -166,54 +167,6 @@ public class FLUORIDES { //LFTR sub components - //OH - public static final Material HYDROXIDE = new Material( - "Hydroxide", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1) - }); - - //NH3 - public static final Material AMMONIA = new Material( - "Ammonia", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -77, //Melting Point in C - -33, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 3) - }); - - //NH4 - public static final Material AMMONIUM = new Material( - "Ammonium", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 4) - }); - //(NH4)HF2 public static final Material AMMONIUM_BIFLUORIDE = new Material( "Ammonium Bifluoride", //Material Name @@ -226,7 +179,7 @@ public class FLUORIDES { false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ - new MaterialStack(FLUORIDES.AMMONIUM, 1), + new MaterialStack(MISC_MATERIALS.AMMONIUM, 1), new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) }); @@ -244,7 +197,7 @@ public class FLUORIDES { //Material Stacks with Percentage of required elements. new MaterialStack[]{ new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 1), - new MaterialStack(FLUORIDES.HYDROXIDE, 2) + new MaterialStack(MISC_MATERIALS.HYDROXIDE, 2) }); // (NH4)2Be(OH)2 / (NH4)2BeF4 @@ -259,7 +212,7 @@ public class FLUORIDES { false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ - new MaterialStack(FLUORIDES.AMMONIUM, 2), + new MaterialStack(MISC_MATERIALS.AMMONIUM, 2), new MaterialStack(FLUORIDES.BERYLLIUM_HYDROXIDE, 1) }); diff --git a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java index 71befe0a37..2372762e0d 100644 --- a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java +++ b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java @@ -1,9 +1,5 @@ package gtPlusPlus.core.proxy; -import java.net.URL; -import java.util.HashSet; -import java.util.Scanner; - import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.Optional; @@ -17,6 +13,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.australia.entity.model.ModelBoar; import gtPlusPlus.australia.entity.model.ModelDingo; import gtPlusPlus.australia.entity.model.ModelOctopus; @@ -29,6 +26,7 @@ import gtPlusPlus.australia.entity.type.EntityBoar; import gtPlusPlus.australia.entity.type.EntityDingo; import gtPlusPlus.australia.entity.type.EntityOctopus; import gtPlusPlus.core.client.model.ModelGiantChicken; +import gtPlusPlus.core.client.renderer.CustomItemBlockRenderer; import gtPlusPlus.core.client.renderer.CustomOreBlockRenderer; import gtPlusPlus.core.client.renderer.RenderBatKing; import gtPlusPlus.core.client.renderer.RenderDecayChest; @@ -61,11 +59,13 @@ import gtPlusPlus.core.util.minecraft.particles.EntityParticleFXMysterious; import gtPlusPlus.xmod.gregtech.common.render.GTPP_CapeRenderer; import gtPlusPlus.xmod.gregtech.common.render.GTPP_Render_MachineBlock; import net.minecraft.client.Minecraft; -import net.minecraft.client.model.ModelBat; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.entity.RenderFireball; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxy extends CommonProxy implements Runnable{ @@ -113,6 +113,7 @@ public class ClientProxy extends CommonProxy implements Runnable{ * Custom Block Renderers */ new CustomOreBlockRenderer(); + new CustomItemBlockRenderer(); new GTPP_Render_MachineBlock(); super.init(e); @@ -164,6 +165,20 @@ public class ClientProxy extends CommonProxy implements Runnable{ RenderingRegistry.registerEntityRenderingHandler(EntityBoar.class, new RenderBoar(new ModelBoar(), new ModelBoar(0.5F), 0.7F)); RenderingRegistry.registerEntityRenderingHandler(EntityDingo.class, new RenderDingo(new ModelDingo(), new ModelDingo(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityOctopus.class, new RenderOctopus(new ModelOctopus(), 0.7F)); + + + + + + + + /** + * Items + */ + for (Pair<Item, IItemRenderer> sItemRenderMappings : mItemRenderMappings) { + MinecraftForgeClient.registerItemRenderer(sItemRenderMappings.getKey(), sItemRenderMappings.getValue()); + } + } @Override diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index b6d41443ef..14858b15aa 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -2,9 +2,9 @@ package gtPlusPlus.core.recipe; import static gtPlusPlus.core.lib.CORE.GTNH; +import java.util.ArrayList; + import cpw.mods.fml.common.Loader; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -27,8 +27,6 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.MISC_MATERIALS; -import gtPlusPlus.core.material.MaterialStack; -import gtPlusPlus.core.material.NONMATERIAL; import gtPlusPlus.core.material.ORES; import gtPlusPlus.core.material.Particle; import gtPlusPlus.core.material.nuclear.FLUORIDES; @@ -46,6 +44,7 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; public class RECIPES_GREGTECH { @@ -92,24 +91,25 @@ public class RECIPES_GREGTECH { latheRecipes(); vacuumFreezerRecipes(); fluidheaterRecipes(); - - + + /** * Special Recipe handlers */ RECIPES_SeleniumProcessing.init(); - - - - - + RECIPES_RareEarthProcessing.init(); + + + + + addFuels(); } private static void fluidheaterRecipes() { GT_Values.RA.addFluidHeaterRecipe(CI.getNumberedCircuit(20), FluidUtils.getWater(1000), FluidUtils.getHotWater(1000), 30, 30); - + } private static void vacuumFreezerRecipes() { @@ -274,6 +274,35 @@ public class RECIPES_GREGTECH { 20 * 60 * 1 * (GTNH ? 2 : 1), (int) GT_Values.V[5]); + // Turbine Automation Port + CORE.RA.addAssemblylineRecipe( + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_8_TURBINE_AUTOMATION, 1), + 20 * 60 * 60 * 24, + new ItemStack[] { + CI.getTieredMachineHull(8, 4), + CI.getConveyor(8, GTNH ? 24 : 12), + CI.getElectricMotor(7, GTNH ? 32 : 16), + CI.getElectricPiston(7, GTNH ? 16 : 4), + CI.getEnergyCore(6, GTNH ? 8 : 2), + CI.getPlate(8, GTNH ? 24 : 12), + CI.getTieredComponent(OrePrefixes.screw, 8, GTNH ? 48 : 24), + CI.getTieredComponent(OrePrefixes.bolt, 7, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.rod, 6, GTNH ? 12 : 6), + CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 20 : 10), + CI.getTieredComponent(OrePrefixes.rotor, 6, GTNH ? 16 : 8), + }, + new FluidStack[] { + CI.getTieredFluid(8, 144 * 32), + CI.getAlternativeTieredFluid(7, 144 * 16), + CI.getTertiaryTieredFluid(7, 144 * 16), + ALLOY.BABBIT_ALLOY.getFluid(128 * 144), + ALLOY.ZERON_100.getFluid(144 * 64) + + }, + GregtechItemList.Hatch_Input_TurbineHousing.get(4), + 20 * 60 * 60 * (GTNH ? 2 : 1), + (int) GT_Values.V[8]); + /* * Contianment casings @@ -358,88 +387,116 @@ public class RECIPES_GREGTECH { } - //Nano Healer - CORE.RA.addAssemblylineRecipe( - ItemUtils.simpleMetaStack(Items.golden_apple, 1, 1), - 20 * 60 * 10, - new ItemStack[] { - ItemUtils.getSimpleStack(aGemCasings[2], GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.plate, 8, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 16 : 4), - CI.getTieredComponent(OrePrefixes.cableGt02, 7, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 6 : 3), - CI.getTieredComponent(OrePrefixes.screw, 7, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.bolt, 5, GTNH ? 24 : 12), - CI.getTieredComponent(OrePrefixes.frameGt, 4, GTNH ? 12 : 6), - aCoilWire[3] - }, - new FluidStack[] { - CI.getTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), - CI.getTertiaryTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), - CI.getAlternativeTieredFluid(6, 144 * 18 * (GTNH ? 16 : 8)), - CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), - - }, - ItemUtils.getItemStackFromFQRN("miscutils:personalHealingDevice", 1), - 20 * 60 * 30 * (GTNH ? 2 : 1), - (int) GT_Values.V[7]); - - - - //Charge Pack LuV-UV - - ItemStack[] aChargeResearch = new ItemStack[] { - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1), - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_1, 1), - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_2, 1), - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_3, 1), - }; - - ItemStack[] aChargeOutputs = new ItemStack[] { - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_1, 1), - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_2, 1), - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_3, 1), - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_4, 1), - }; + if (LoadedMods.Baubles) { + //Nano Healer + CORE.RA.addAssemblylineRecipe( + ItemUtils.simpleMetaStack(Items.golden_apple, 1, 1), + 20 * 60 * 10, + new ItemStack[] { + ItemUtils.getSimpleStack(aGemCasings[2], GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.plate, 8, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.cableGt02, 7, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 6 : 3), + CI.getTieredComponent(OrePrefixes.screw, 7, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.bolt, 5, GTNH ? 24 : 12), + CI.getTieredComponent(OrePrefixes.frameGt, 4, GTNH ? 12 : 6), + aCoilWire[3] + }, + new FluidStack[] { + CI.getTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(6, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), - ItemStack[] aBufferCoreInputs = new ItemStack[] { - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", GTNH ? 8 : 4), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", GTNH ? 8 : 4), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", GTNH ? 8 : 4), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", GTNH ? 8 : 4), - }; + }, + ItemUtils.getItemStackFromFQRN("miscutils:personalHealingDevice", 1), + 20 * 60 * 30 * (GTNH ? 2 : 1), + (int) GT_Values.V[7]); + + + + //Charge Pack LuV-UV + + ItemStack[] aChargeResearch = new ItemStack[] { + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_1, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_2, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_3, 1), + }; + + ItemStack[] aChargeOutputs = new ItemStack[] { + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_1, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_2, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_3, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_4, 1), + }; + + ItemStack[] aBufferCoreInputs = new ItemStack[] { + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", GTNH ? 8 : 4), + }; + + int aCurrSlot = 0; + for (int h = 6; h < 10; h++) { + CORE.RA.addAssemblylineRecipe( + aChargeResearch[aCurrSlot], + 20 * 60 * 10 * (aCurrSlot + 1), + new ItemStack[] { + ItemUtils.getSimpleStack( + aGemBatteries[aCurrSlot], GTNH ? 4 : 2), + aBufferCoreInputs[aCurrSlot], + aCoilWire[aCurrSlot], + CI.getTieredComponent(OrePrefixes.plate, h, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.plate, h-1, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, h, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.circuit, h-1, GTNH ? 32 : 8), + CI.getTieredComponent(OrePrefixes.cableGt12, h-1, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.screw, h, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.bolt, h-2, GTNH ? 32 : 16), + CI.getElectricMotor(h, GTNH ? 8 : 4), + CI.getFieldGenerator(h-1, 2), + CI.getRobotArm(h-2, GTNH ? 4 : 2), + }, + new FluidStack[] { + CI.getTieredFluid(h, 144 * 18 * (GTNH ? 8 : 4)), + CI.getTertiaryTieredFluid(h-1, 144 * 18 * (GTNH ? 8 : 4)), + CI.getAlternativeTieredFluid(h-1, 144 * 18 * (GTNH ? 8 : 4)), + CI.getAlternativeTieredFluid(h-2, 144 * 18 * (GTNH ? 8 : 4)), + }, + aChargeOutputs[aCurrSlot], + 20 * 60 * 30 * (GTNH ? 2 : 1) * (aCurrSlot+1), + (int) GT_Values.V[h]); + aCurrSlot++; + } - int aCurrSlot = 0; - for (int h = 6; h < 10; h++) { + //Cloaking device CORE.RA.addAssemblylineRecipe( - aChargeResearch[aCurrSlot], - 20 * 60 * 10 * (aCurrSlot + 1), + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_9_CLOAKING, 1), + 20 * 60 * 10, new ItemStack[] { - ItemUtils.getSimpleStack( - aGemBatteries[aCurrSlot], GTNH ? 4 : 2), - aBufferCoreInputs[aCurrSlot], - aCoilWire[aCurrSlot], - CI.getTieredComponent(OrePrefixes.plate, h, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.plate, h-1, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.circuit, h, GTNH ? 16 : 4), - CI.getTieredComponent(OrePrefixes.circuit, h-1, GTNH ? 32 : 8), - CI.getTieredComponent(OrePrefixes.cableGt12, h-1, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.screw, h, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.bolt, h-2, GTNH ? 32 : 16), - CI.getElectricMotor(h, GTNH ? 8 : 4), - CI.getFieldGenerator(h-1, 2), - CI.getRobotArm(h-2, GTNH ? 4 : 2), + ItemUtils.getSimpleStack(aGemCasings[3], GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.plate, 8, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.cableGt04, 8, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.gearGt, 7, GTNH ? 6 : 3), + CI.getTieredComponent(OrePrefixes.screw, 8, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.bolt, 7, GTNH ? 24 : 12), + CI.getTieredComponent(OrePrefixes.frameGt, 5, GTNH ? 12 : 6), + aCoilWire[3] }, new FluidStack[] { - CI.getTieredFluid(h, 144 * 18 * (GTNH ? 8 : 4)), - CI.getTertiaryTieredFluid(h-1, 144 * 18 * (GTNH ? 8 : 4)), - CI.getAlternativeTieredFluid(h-1, 144 * 18 * (GTNH ? 8 : 4)), - CI.getAlternativeTieredFluid(h-2, 144 * 18 * (GTNH ? 8 : 4)), + CI.getTieredFluid(8, 144 * 18 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(8, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(8, 144 * 18 * (GTNH ? 16 : 8)), + }, - aChargeOutputs[aCurrSlot], - 20 * 60 * 30 * (GTNH ? 2 : 1) * (aCurrSlot+1), - (int) GT_Values.V[h]); - aCurrSlot++; + ItemUtils.getItemStackFromFQRN("miscutils:personalCloakingDevice", 1), + 20 * 60 * 30 * (GTNH ? 2 : 1), + (int) GT_Values.V[8]); } @@ -722,16 +779,36 @@ public class RECIPES_GREGTECH { 480*4); + //Wood's Glass Laser Lens + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(5), + ItemList.Shape_Mold_Ball.get(0), + ELEMENT.getInstance().BARIUM.getDust(1), + ELEMENT.getInstance().SODIUM.getDust(1), + ELEMENT.getInstance().SILICON.getDust(2), + ELEMENT.getInstance().NICKEL.getDust(1), + ItemUtils.getItemStackOfAmountFromOreDict("dustGlass", 5) + }, + FluidUtils.getUUM(1000), + null, + new ItemStack[] { + GregtechItemList.Laser_Lens_WoodsGlass.get(1) + }, + new int[] {10000}, + 20 * 300, + (int) GT_Values.V[3]); + } private static void fluidcannerRecipes() { // Sulfuric Acid - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), + CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), FluidUtils.getFluidStack("sulfuricacid", 250), null); - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), + CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("sulfuricacid", 250)); @@ -741,31 +818,49 @@ public class RECIPES_GREGTECH { // Try use Internal GT Fluid first if (Utils.getGregtechVersionAsInt() >= 50929) { // Hydrofluoric Acid - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), + CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250), null); - addedGtExtraction = GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + addedGtExtraction = CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250)); } //Add a Fill recipe for GT++ Acid - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), + CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), FluidUtils.getFluidStack("hydrofluoricacid", 125), null); //Add an empty recipe, but only if we didn't for the standard GT HF. Prevents Fluid transformation exploits. - if (!addedGtExtraction) - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), - ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 125)); + if (!addedGtExtraction) { + CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 125)); + } + //Gelid Cryotheum + CORE.RA.addFluidExtractionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustCryotheum", 1), FluidUtils.getFluidStack("cryotheum", 250), 200, 240); + + //Ender Fluid + CORE.RA.addFluidExtractionRecipe(ItemUtils.getSimpleStack(Items.ender_pearl), FluidUtils.getFluidStack("ender", 250), 100, 30); + + //Blazing Pyrotheum + CORE.RA.addFluidExtractionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), FluidUtils.getFluidStack("pyrotheum", 250), 200, 240); + } private static void cokeOvenRecipes() { Logger.INFO("Loading Recipes for Industrial Coking Oven."); - - // Wood to Charcoal - AddGregtechRecipe.addCokeAndPyrolyseRecipes(GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 20L), 20, - GT_ModHandler.getSteam(1000), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 24L), - FluidUtils.getFluidStack("fluid.coalgas", 1440), 60, 30); + // Wood to Charcoal + //Try use all woods found + ArrayList<ItemStack> aLogData = OreDictionary.getOres("logWood"); + if (aLogData.isEmpty()) { + AddGregtechRecipe.addCokeAndPyrolyseRecipes(GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 20L), 20, + GT_ModHandler.getSteam(1000), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 24L), + FluidUtils.getFluidStack("fluid.coalgas", 1440), 60, 30); } + else { + for (ItemStack stack : aLogData) { + AddGregtechRecipe.addCokeAndPyrolyseRecipes(ItemUtils.getSimpleStack(stack, 20), 20, + GT_ModHandler.getSteam(1000), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 24L), + FluidUtils.getFluidStack("fluid.coalgas", 1440), 60, 30); + } + } // Coal to Coke AddGregtechRecipe.addCokeAndPyrolyseRecipes(GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 16L), 22, @@ -1334,41 +1429,50 @@ public class RECIPES_GREGTECH { CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] {ItemUtils.getSimpleStack(Items.nether_star), ItemUtils.getItemStackOfAmountFromOreDict("plateTungstenSteel", 8), ItemUtils.getItemStackOfAmountFromOreDict("stickBlackSteel", 8)}, null, ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard, 32), 30*20, 500); + ItemStack aFluidReg1 = Utils.getValueOfItemList("FluidRegulator_LV", ItemList.Pump_LV).get(1); + ItemStack aFluidReg2 = Utils.getValueOfItemList("FluidRegulator_MV", ItemList.Pump_MV).get(1); + ItemStack aFluidReg3 = Utils.getValueOfItemList("FluidRegulator_HV", ItemList.Pump_HV).get(1); + ItemStack aFluidReg4 = Utils.getValueOfItemList("FluidRegulator_EV", ItemList.Pump_EV).get(1); CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - CI.electricPump_LV, + aFluidReg1, CI.electricMotor_LV, - ItemUtils.getItemStackOfAmountFromOreDict("circuitBasic", 2), + CI.getTieredComponent(OrePrefixes.bolt, 1, GTNH ? 8 : 4), ItemUtils.getItemStackOfAmountFromOreDict("ringBrass", 1), ItemUtils.getItemStackOfAmountFromOreDict("stickBrass", 1), ItemUtils.getItemStackOfAmountFromOreDict("plateSteel", 2) }, null, ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1), 10*20, 30); CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - CI.electricPump_MV, + aFluidReg2, CI.electricMotor_MV, - ItemUtils.getItemStackOfAmountFromOreDict("circuitAdvanced", 2), + CI.getTieredComponent(OrePrefixes.bolt, 2, GTNH ? 8 : 4), ItemUtils.getItemStackOfAmountFromOreDict("ringInvar", 1), ItemUtils.getItemStackOfAmountFromOreDict("stickInvar", 1), ItemUtils.getItemStackOfAmountFromOreDict("plateAluminium", 2) }, null, ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1), 10*20*2, 120); CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - CI.electricPump_HV, + aFluidReg3, CI.electricMotor_HV, - ItemUtils.getItemStackOfAmountFromOreDict("circuitData", 2), + CI.getTieredComponent(OrePrefixes.bolt, 3, GTNH ? 8 : 4), ItemUtils.getItemStackOfAmountFromOreDict("ringChrome", 1), ItemUtils.getItemStackOfAmountFromOreDict("stickChrome", 1), ItemUtils.getItemStackOfAmountFromOreDict("plateStainlessSteel", 2) }, null, ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1), 10*20*3, 480); CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - CI.electricPump_EV, + aFluidReg4, CI.electricMotor_EV, - ItemUtils.getItemStackOfAmountFromOreDict("circuitElite", 2), + CI.getTieredComponent(OrePrefixes.bolt, 4, GTNH ? 8 : 4), ItemUtils.getItemStackOfAmountFromOreDict("ringTitanium", 1), ItemUtils.getItemStackOfAmountFromOreDict("stickTitanium", 1), ItemUtils.getItemStackOfAmountFromOreDict("plateTungstenSteel", 2) }, null, ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1), 10*20*4, 1960); + GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1000, 1), 30, 30); + GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1001, 1), 120, 120); + GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1002, 1), 480, 480); + GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1003, 1), 1820, 1820); + @@ -1417,11 +1521,11 @@ public class RECIPES_GREGTECH { ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_4), ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_5) }; - + for (int i = 1; i < 6; i++) { - + int aAS = i-1; - + CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { aPackPlates[aAS], @@ -1430,27 +1534,74 @@ public class RECIPES_GREGTECH { aPackCircuit[aAS], aPackBatteries[aAS], CI.getSensor(i, GTNH ? 4 : 2), - }, + }, CI.getTieredFluid(i, (144 * (GTNH ? 4 : 2))), aPackOutput[aAS], 30 * 20 * i, (int) GT_Values.V[i]); } - + if (!GTNH) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.WroughtIron, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 2L), GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Bronze, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 2L), GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Brass, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 2L), GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), 75, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Invar, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 2L), GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), 75, 32); - - } else { - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.WroughtIron, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 4L), GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bronze, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 4L), GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Brass, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 4L), GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), 75, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Invar, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 4L), GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), 75, 32); - } + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.WroughtIron, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 2L), GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Bronze, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 2L), GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Brass, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 2L), GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), 75, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Invar, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 2L), GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), 75, 32); + + } else { + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.WroughtIron, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 4L), GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bronze, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 4L), GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Brass, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 4L), GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), 75, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Invar, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 4L), GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), 75, 32); + } + } + + + if (LoadedMods.Baubles) { + + + + // Turbine Housing Research Page + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + ItemUtils.getGregtechCircuit(17), + ItemUtils.getItemStackOfAmountFromOreDict("plateRefinedTrinium", GTNH ? 64 : 32), + CI.getSensor(6, GTNH ? 6 : 3), + CI.getBolt(7, GTNH ? 64 : 32), + ItemUtils.getItemStackOfAmountFromOreDict("wireFinePlatinum", GTNH ? 64 : 32), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), GTNH ? 12 : 6) + }, + CI.getAlternativeTieredFluid(7, 144 * 32), + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_8_TURBINE_AUTOMATION, 1), + 20 * 60 * 5, + (int) GT_Values.V[6]); + + // Cloaking Device Research Page + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + ItemUtils.getGregtechCircuit(17), + ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR, 4), + CI.getFieldGenerator(6, GTNH ? 16 : 8), + ItemUtils.getItemStackOfAmountFromOreDict("wireFinePalladium", GTNH ? 32 : 16), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), GTNH ? 12 : 6) + }, + CI.getAlternativeTieredFluid(7, 144 * 32), + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_9_CLOAKING, 1), + 20 * 60 * 10, + (int) GT_Values.V[7]); + + + // Supreme Pizza Gloves + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + ItemUtils.getGregtechCircuit(19), + ItemUtils.getSimpleStack(ModItems.itemRope, GTNH ? 32 : 16), + ItemUtils.getItemStackOfAmountFromOreDict("gearGtSmallWroughtIron", GTNH ? 8 : 4), + ItemUtils.getItemStackOfAmountFromOreDict("wireFineCopper", GTNH ? 32 : 16), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(1), GTNH ? 2 : 1) + }, + FluidUtils.getFluidStack("molten.rubber", 2000), + ItemUtils.getSimpleStack(ModItems.itemPersonalFireProofDevice), + 20 * 60 * 5, + 30); } @@ -1517,8 +1668,10 @@ public class RECIPES_GREGTECH { new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("nuggetBronze", 1), ItemUtils.getItemStackOfAmountFromOreDict("nuggetElectrum", 1), + ItemUtils.getItemStackOfAmountFromOreDict("nuggetTantalum", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTungstate", 1), ItemUtils.getSimpleStack(Blocks.obsidian) }, - new int[] { 750, 250, 1850 }, 0); + new int[] { 750, 250, 250, 250, 1850 }, 0); /* * HotFuel.addNewHotFuel( FluidUtils.getFluidStack("ic2hotcoolant", @@ -1547,19 +1700,19 @@ public class RECIPES_GREGTECH { private static void fluidExtractorRecipes() { //FLiBe fuel - GT_Values.RA.addFluidExtractionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustLi2BeF4", 1), null, - FluidUtils.getFluidStack("li2bef4", 144), 10000, 100, 500); + CORE.RA.addFluidExtractionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustLi2BeF4", 1), + FluidUtils.getFluidStack("li2bef4", 144), 100, 500); //LFTR Fuel 1 - GT_Values.RA.addFluidExtractionRecipe(NUCLIDE.LiFBeF2ZrF4U235.getDust(1), null, - NUCLIDE.LiFBeF2ZrF4U235.getFluid(144), 10000, 250, 1000); - GT_Values.RA.addFluidExtractionRecipe(NUCLIDE.LiFBeF2ZrF4UF4.getDust(1), null, - NUCLIDE.LiFBeF2ZrF4UF4.getFluid(144), 10000, 150, 2000); - GT_Values.RA.addFluidExtractionRecipe(NUCLIDE.LiFBeF2ThF4UF4.getDust(1), null, - NUCLIDE.LiFBeF2ThF4UF4.getFluid(144), 10000, 200, 1500); + CORE.RA.addFluidExtractionRecipe(NUCLIDE.LiFBeF2ZrF4U235.getDust(1), + NUCLIDE.LiFBeF2ZrF4U235.getFluid(144), 250, 1000); + CORE.RA.addFluidExtractionRecipe(NUCLIDE.LiFBeF2ZrF4UF4.getDust(1), + NUCLIDE.LiFBeF2ZrF4UF4.getFluid(144), 150, 2000); + CORE.RA.addFluidExtractionRecipe(NUCLIDE.LiFBeF2ThF4UF4.getDust(1), + NUCLIDE.LiFBeF2ThF4UF4.getFluid(144), 200, 1500); //ZIRCONIUM_TETRAFLUORIDE - GT_Values.RA.addFluidExtractionRecipe(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getDust(1), null, - FluidUtils.getFluidStack(ModItems.fluidZrF4, 144), 10000, 200, 512+256); + CORE.RA.addFluidExtractionRecipe(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getDust(1), + FluidUtils.getFluidStack(ModItems.fluidZrF4, 144), 200, 512+256); @@ -1600,6 +1753,27 @@ public class RECIPES_GREGTECH { } private static void centrifugeRecipes() { + + //Try use all woods found, fix/add methane extraction. + ArrayList<ItemStack> aLogData = OreDictionary.getOres("logWood"); + ArrayList<ItemStack> aRubberLogs = OreDictionary.getOres("logRubber"); + if (!aLogData.isEmpty() && !aRubberLogs.isEmpty()) { + Logger.INFO("Fixing Methane output of centrifuged logs."); + //First Check to see if it's a rubber log + for (ItemStack stack : aLogData) { + if (aRubberLogs.contains(stack)) { + if (GT_Values.RA.addCentrifugeRecipe(GT_Utility.copyAmount(1L, stack), null, null, Materials.Methane.getGas(60L), ItemList.IC2_Resin.get(1L, new Object[0]), GT_ModHandler.getIC2Item("plantBall", 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Carbon, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L), null, null, new int[] { 5000, 3750, 2500, 2500 }, 200, 20)) { + Logger.INFO("Added rubber plant based methane extraction for "+ItemUtils.getItemName(stack)); + } + } + else { + if (GT_Values.RA.addCentrifugeRecipe(GT_Utility.copyAmount(1L, stack), null, null, Materials.Methane.getGas(60L), GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_Values.NI, null, 200, 20)) { + Logger.INFO("Added methane extraction for "+ItemUtils.getItemName(stack)); + } + } + } + } + GT_Values.RA.addCentrifugeRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustThorium", 8), GT_Values.NI, GT_Values.NF, GT_Values.NF, ELEMENT.getInstance().THORIUM232.getDust(2), ItemUtils.getItemStackOfAmountFromOreDict("dustSmallThorium", 20), @@ -1850,7 +2024,6 @@ public class RECIPES_GREGTECH { Materials.Titanium.mBlastFurnaceTemp); } - } private static void autoclaveRecipes() { @@ -1895,25 +2068,6 @@ public class RECIPES_GREGTECH { } - public static boolean addPulverisationRecipe(final ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, - final ItemStack aOutput3) { - aOutput1 = GT_OreDictUnificator.get(true, aOutput1); - aOutput2 = GT_OreDictUnificator.get(true, aOutput2); - if ((GT_Utility.isStackInvalid(aInput)) || (GT_Utility.isStackInvalid(aOutput1))) { - return false; - } - if (GT_Utility.getContainerItem(aInput, false) == null) { - - if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) { - GT_Utility.addSimpleIC2MachineRecipe(aInput, GT_ModHandler.getMaceratorRecipeList(), null, - new Object[] { aOutput1 }); - } - GT_Values.RA.addPulveriserRecipe(aInput, new ItemStack[] { aOutput1, aOutput2, aOutput3 }, - new int[] { 10000, 10000, 10000 }, 400, 2); - } - return true; - } - private static void cyclotronRecipes() { // Polonium @@ -2241,24 +2395,6 @@ public class RECIPES_GREGTECH { private static void sifterRecipes() { - // Rare Earth Processing - GT_Values.RA.addSifterRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustRareEarth", 1), - new ItemStack[] { - ELEMENT.getInstance().YTTRIUM.getSmallDust(1), - ELEMENT.getInstance().NEODYMIUM.getSmallDust(1), - ELEMENT.getInstance().LANTHANUM.getSmallDust(1), - ELEMENT.getInstance().CERIUM.getSmallDust(1), - ELEMENT.getInstance().CADMIUM.getSmallDust(1), - ELEMENT.getInstance().CAESIUM.getSmallDust(1), - ORES.SAMARSKITE_YB.getSmallDust(1), - ORES.FLORENCITE.getSmallDust(1), - ORES.FLUORCAPHITE.getSmallDust(1), - //ELEMENT.getInstance().YTTERBIUM.getTinyDust(1), - //ELEMENT.getInstance().SAMARIUM.getTinyDust(1), - //ELEMENT.getInstance().GADOLINIUM.getTinyDust(1) - }, - new int[] { 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000 }, 20 * 30, 500); - // Zirconium GT_Values.RA.addSifterRecipe(ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedIlmenite", 1), new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1), diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 6ed5c71bcc..5048c5f2a5 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -1,11 +1,14 @@ package gtPlusPlus.core.recipe; +import static gtPlusPlus.core.lib.CORE.GTNH; import static gtPlusPlus.core.recipe.common.CI.bitsd; import static gtPlusPlus.core.util.minecraft.ItemUtils.getSimpleStack; import static gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits.generatePipeRecipes; import static gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits.generateWireRecipes; -import gregtech.api.enums.*; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; @@ -14,15 +17,14 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; -import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -55,7 +57,6 @@ public class RECIPES_General { OUTPUT_Blueprint = ItemUtils.getSimpleStack(ModItems.itemBlueprintBase); run(); addCompressedObsidian(); - addHandPumpRecipes(); migratedRecipes(); } } @@ -118,12 +119,6 @@ public class RECIPES_General { Logger.INFO("Added a recipe for Rainforest oak Saplings."); } - - // Try fix this ore - if (ModBlocks.blockOreFluorite != null){ - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(ModBlocks.blockOreFluorite)}, FLUORIDES.FLUORITE.getOre(1)); - } - //Iron bars final ItemStack ironBars; if (CORE.GTNH) { @@ -162,13 +157,13 @@ public class RECIPES_General { //Shaped Crafting for ULV Material Dusts - + //Potin if (RecipeUtils.addShapelessGregtechRecipe(new Object[] {"dustLead", "dustBronze", "dustTin", "dustLead", "dustBronze"}, ALLOY.POTIN.getDust(5))){ Logger.INFO("Added shapeless recipe for Potin Dust."); } - + //Tumbaga if (RecipeUtils.addShapelessGregtechRecipe(new Object[] { "dustGold", "dustGold", "dustCopper"}, ItemUtils.getSimpleStack(ModItems.dustTumbagaMix))){ @@ -179,7 +174,7 @@ public class RECIPES_General { ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), "dustGold" - }, + }, ALLOY.TUMBAGA.getDust(10))){ Logger.INFO("Added shapeless recipe for Tumbaga Dust."); } @@ -291,6 +286,19 @@ public class RECIPES_General { 20 * 30, // Dur 16); // Eu + // Pest Killer + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedCircuit(16), + CI.getTieredMachineCasing(1), + CI.getElectricPump(2, 1), + CI.getPlate(2, GTNH ? 4 : 2), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(0), GTNH ? 2 : 1), + }, + FluidUtils.getHotWater(500), // Fluid + ItemUtils.getSimpleStack(ModBlocks.blockPestKiller), // Output + 20 * 60, // Dur + 16); // Eu @@ -335,42 +343,6 @@ public class RECIPES_General { return true; } - private static void addHandPumpRecipes() { - if (RecipeUtils.recipeBuilder( - CI.electricPump_LV, "circuitBasic", null, - "ringBrass", CI.electricMotor_LV, "circuitBasic", - "plateSteel", "plateSteel", "rodBrass", - ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1))) - Logger.INFO("Added recipe for Hand Pump I - true"); - if (RecipeUtils.recipeBuilder( - CI.electricPump_MV, "circuitAdvanced", null, - "ringMagnalium", CI.electricMotor_MV, "circuitAdvanced", - "plateAluminium", "plateAluminium", "rodMagnalium", - ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1))) - Logger.INFO("Added recipe for Hand Pump II - true"); - if (RecipeUtils.recipeBuilder( - CI.electricPump_HV, "circuitData", null, - "ringChrome", CI.electricMotor_HV, "circuitData", - "plateStainlessSteel", "plateStainlessSteel", "rodChrome", - ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1))) - Logger.INFO("Added recipe for Hand Pump III - true"); - if (RecipeUtils.recipeBuilder( - CI.electricPump_EV, "circuitElite", null, - "ringTitanium", CI.electricMotor_EV, "circuitElite", - "plateTungstenSteel", "plateTungstenSteel", "rodTitanium", - ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1))) - Logger.INFO("Added recipe for Hand Pump IV - true"); - - - - GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1000, 1), 30, 30); - GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1001, 1), 120, 120); - GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1002, 1), 480, 480); - GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1003, 1), 1820, 1820); - - - } - private static void migratedRecipes() { RecipeUtils.generateMortarRecipe(ItemUtils.getSimpleStack(ModItems.itemPlateRawMeat), ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 1)); @@ -423,12 +395,11 @@ public class RECIPES_General { generatePipeRecipes(e.mDefaultLocalName, e.getMass(), tVoltageMultiplier); } - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[4], "rotorGtStainlessSteel", CI.component_Plate[4], - CI.getTieredCircuitOreDictName(3), CI.machineHull_HV, CI.getTieredCircuitOreDictName(3), - CI.component_Plate[4], CI.electricPump_HV, CI.component_Plate[4], - GregtechItemList.Hatch_Air_Intake.get(1L, new Object[0])); + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[4], "rotorGtStainlessSteel", CI.component_Plate[4], + CI.getTieredCircuitOreDictName(3), CI.machineHull_HV, CI.getTieredCircuitOreDictName(3), + CI.component_Plate[4], CI.electricPump_HV, CI.component_Plate[4], + GregtechItemList.Hatch_Air_Intake.get(1L, new Object[0])); RecipeUtils.addShapedGregtechRecipe(CI.component_Plate[6], ALLOY.MARAGING250.getGear(1), CI.component_Plate[6], CI.getTieredCircuitOreDictName(4), GregtechItemList.Casing_AdvancedVacuum.get(1), @@ -446,7 +417,7 @@ public class RECIPES_General { CI.component_Plate[8], GregtechItemList.Hatch_Input_Naquadah.get(1L, new Object[0])); - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (PollutionUtils.isPollutionEnabled()) { GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LV.get(1L, new Object[0]), bitsd, new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LV.get(1), Character.valueOf('P'), GregtechItemList.Pollution_Cleaner_LV.get(1) }); diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 6979bb4f39..578ef8f89c 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -2,6 +2,7 @@ package gtPlusPlus.core.recipe; import static gtPlusPlus.core.lib.CORE.GTNH; +import cpw.mods.fml.common.Loader; import gregtech.api.enums.*; import gregtech.api.util.GT_ModHandler; import gtPlusPlus.api.objects.Logger; @@ -15,8 +16,13 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.*; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.everglades.dimension.Dimension_Everglades; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.covers.CoverManager; +import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem; +import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -207,7 +213,7 @@ public class RECIPES_Machines { } private static void run(){ - + //Determines Casing Recipe Output if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !GTNH){ Casing_Amount=2; @@ -215,7 +221,7 @@ public class RECIPES_Machines { else { Casing_Amount=1; } - + initModItems(); controlCores(); energyCores(); @@ -223,7 +229,9 @@ public class RECIPES_Machines { largeArcFurnace(); industrialVacuumFurnace(); fakeMachineCasingCovers(); + ztonesCoverRecipes(); superBuses(); + roundRobinators(); } private static void initModItems(){ @@ -289,7 +297,7 @@ public class RECIPES_Machines { private static void runModRecipes(){ if (LoadedMods.Gregtech){ - + //Computer Cube CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -357,7 +365,7 @@ public class RECIPES_Machines { ItemUtils.getSimpleStack(ModBlocks.blockCustomJukebox), 20 * 30, 30); - + //Poo Collector CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -443,7 +451,7 @@ public class RECIPES_Machines { //Add recycle recipes for the Iron Plated Bricks //GT_ModHandler.addPulverisationRecipe(RECIPE_IronPlatedBricks, ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustIron", 6), ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustClay", 2), true); - RECIPES_GREGTECH.addPulverisationRecipe( + CORE.RA.addPulverisationRecipe( RECIPE_IronPlatedBricks, ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustIron", 6), ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustClay", 2), @@ -708,7 +716,7 @@ public class RECIPES_Machines { //Semi-Fluid Generators ItemStack mSemiFluidgen = ItemUtils.getItemStackFromFQRN("IC2:blockGenerator:7", 1); mSemiFluidgen.setItemDamage(7); - //ItemUtils.simpleMetaStack("IC2:blockGenerator:7", 7, 1); + //ItemUtils.simpleMetaStack("IC2:blockGenerator:7", 7, 1); ItemStack[] aSemifluids = new ItemStack[] {mSemiFluidgen, GregtechItemList.Generator_SemiFluid_LV.get(1), GregtechItemList.Generator_SemiFluid_MV.get(1), GregtechItemList.Generator_SemiFluid_HV.get(1)}; for (int o=1;o<4;o++) { CORE.RA.addSixSlotAssemblingRecipe( @@ -829,7 +837,7 @@ public class RECIPES_Machines { "plankWood", "frameGtTumbaga", "plankWood", "plankWood", "plankWood", "plankWood", RECIPE_TreeFarmFrame); - } + } if (CORE.ConfigSwitches.enableMachine_Tesseracts){ //Tesseracts @@ -852,8 +860,8 @@ public class RECIPES_Machines { if (CORE.ConfigSwitches.enableMachine_SimpleWasher){ ItemStack plateWrought = ItemUtils.getItemStackOfAmountFromOreDict("plateWroughtIron", 1); ItemStack washerPipe; - - + + if (CORE.ConfigSwitches.enableCustom_Pipes){ washerPipe = ItemUtils.getItemStackOfAmountFromOreDict("pipeLargeClay", 1); RecipeUtils.addShapedGregtechRecipe( @@ -869,7 +877,7 @@ public class RECIPES_Machines { plateWrought, washerPipe, plateWrought, plateWrought, CI.machineCasing_ULV, plateWrought, GregtechItemList.SimpleDustWasher_ULV.get(1)); - + int aSimpleWasherTier = 2; int aSlot = 0; ItemStack[][] aInputsForSimpleWashers = new ItemStack[4][6]; @@ -880,7 +888,7 @@ public class RECIPES_Machines { CI.getTieredComponent(OrePrefixes.plate, 1, GTNH ? 8 : 4), CI.getTieredComponent(OrePrefixes.rod, 2, GTNH ? 4 : 2), CI.getTieredComponent(OrePrefixes.circuit, 2, GTNH ? 3 : 1), - + }; aInputsForSimpleWashers[1] = new ItemStack[] { CI.getTieredMachineHull(4), @@ -888,7 +896,7 @@ public class RECIPES_Machines { CI.getTieredComponent(OrePrefixes.plate, 3, GTNH ? 12 : 6), CI.getTieredComponent(OrePrefixes.rod, 4, GTNH ? 6 : 3), CI.getTieredComponent(OrePrefixes.circuit, 4, GTNH ? 4 : 2), - + }; aInputsForSimpleWashers[2] = new ItemStack[] { CI.getTieredMachineHull(6), @@ -896,7 +904,7 @@ public class RECIPES_Machines { CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 16 : 8), CI.getTieredComponent(OrePrefixes.rod, 6, GTNH ? 8 : 4), CI.getTieredComponent(OrePrefixes.circuit, 6, GTNH ? 6 : 3), - + }; aInputsForSimpleWashers[3] = new ItemStack[] { CI.getTieredMachineHull(8), @@ -904,37 +912,37 @@ public class RECIPES_Machines { CI.getTieredComponent(OrePrefixes.plate, 7, GTNH ? 32 : 16), CI.getTieredComponent(OrePrefixes.rod, 8, GTNH ? 10 : 5), CI.getTieredComponent(OrePrefixes.circuit, 8, GTNH ? 8 : 4), - + }; - - - - - - + + + + + + ItemStack[] aSimpleWashers = new ItemStack[] {GregtechItemList.SimpleDustWasher_MV.get(1), GregtechItemList.SimpleDustWasher_EV.get(1), GregtechItemList.SimpleDustWasher_LuV.get(1), GregtechItemList.SimpleDustWasher_UV.get(1)}; for (int i=0;i<4;i++) { - + CORE.RA.addSixSlotAssemblingRecipe( aInputsForSimpleWashers[aSlot], CI.getTieredFluid(aSimpleWasherTier, 144 * aSimpleWasherTier), aSimpleWashers[aSlot], 20 * 15 * aSimpleWasherTier, (int) GT_Values.V[aSimpleWasherTier]); - + aSimpleWasherTier += 2; aSlot++; } - - - - - - + + + + + + } - if (CORE.ConfigSwitches.enableMachine_Pollution && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - + if (CORE.ConfigSwitches.enableMachine_Pollution && PollutionUtils.isPollutionEnabled()){ + RecipeUtils.addShapedGregtechRecipe( "plateCarbon", "plateCarbon", "plateCarbon", "dustCarbon", "dustCarbon", "dustCarbon", @@ -1056,7 +1064,20 @@ public class RECIPES_Machines { RECIPE_ThermalBoilerCasing); //Lava Filter Recipe - GT_Values.RA.addAssemblerRecipe(ItemUtils.getItemStackWithMeta(LoadedMods.IndustrialCraft2, "IC2:itemPartCarbonMesh", "RawCarbonMesh", 0, 16), CI.getNumberedCircuit(18), ItemUtils.getSimpleStack(ModItems.itemLavaFilter), 80*20, 16); + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + CI.getNumberedCircuit(18), + ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", GTNH ? 64 : 32), + ItemUtils.getItemStackOfAmountFromOreDict("wireFineSteel", GTNH ? 64 : 32), + ItemUtils.getItemStackOfAmountFromOreDict("ringTumbaga", GTNH ? 32 : 16), + ItemUtils.getItemStackOfAmountFromOreDict("foilCopper", GTNH ? 8 : 4), + ItemUtils.getItemStackWithMeta(LoadedMods.IndustrialCraft2, "IC2:itemPartCarbonMesh", "RawCarbonMesh", 0, 64), + + }, + CI.getTieredFluid(3, 144), + ItemUtils.getSimpleStack(ModItems.itemLavaFilter, GTNH ? 8 : 16), + 1600, + 240 + ); } if (CORE.ConfigSwitches.enableMultiblock_LiquidFluorideThoriumReactor){ @@ -1164,7 +1185,7 @@ public class RECIPES_Machines { RECIPE_CyclotronController = GregtechItemList.COMET_Cyclotron.get(1); RECIPE_CyclotronOuterCasing = GregtechItemList.Casing_Cyclotron_External.get(Casing_Amount); RECIPE_CyclotronInnerCoil = GregtechItemList.Casing_Cyclotron_Coil.get(1); - + //Outer Casing CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1179,8 +1200,8 @@ public class RECIPES_Machines { RECIPE_CyclotronOuterCasing, 30 * 20 * 2, MaterialUtils.getVoltageForTier(4)); - - + + //Inner Coil CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1995,7 +2016,7 @@ public class RECIPES_Machines { } } - + private static void largeArcFurnace() { int aCostMultiplier = GTNH ? 2 : 1; CORE.RA.addSixSlotAssemblingRecipe( @@ -2025,10 +2046,10 @@ public class RECIPES_Machines { 60 * 20 * 8, MaterialUtils.getVoltageForTier(6)); } - + private static void industrialVacuumFurnace() { int aCostMultiplier = GTNH ? 2 : 1; - + CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { CI.getTieredMachineHull(-1, 1 * aCostMultiplier), @@ -2041,9 +2062,9 @@ public class RECIPES_Machines { GregtechItemList.Casing_Vacuum_Furnace.get(Casing_Amount), 20 * 10 * 6, MaterialUtils.getVoltageForTier(6)); - + ; - + CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { GregtechItemList.Casing_Vacuum_Furnace.get(Casing_Amount), @@ -2058,113 +2079,290 @@ public class RECIPES_Machines { 60 * 20 * 12, MaterialUtils.getVoltageForTier(7)); } - + private static void fakeMachineCasingCovers() { - GregtechItemList[] mMachineCasingCovers = new GregtechItemList[] { - GregtechItemList.FakeMachineCasingPlate_ULV, - GregtechItemList.FakeMachineCasingPlate_LV, - GregtechItemList.FakeMachineCasingPlate_MV, - GregtechItemList.FakeMachineCasingPlate_HV, - GregtechItemList.FakeMachineCasingPlate_EV, - GregtechItemList.FakeMachineCasingPlate_IV, - GregtechItemList.FakeMachineCasingPlate_LuV, - GregtechItemList.FakeMachineCasingPlate_ZPM, - GregtechItemList.FakeMachineCasingPlate_UV, - GregtechItemList.FakeMachineCasingPlate_MAX, - }; - for (int i = 0;i<10;i++) { - GT_Values.RA.addCutterRecipe( - CI.getTieredMachineCasing(i), - mMachineCasingCovers[i].get(5), - null, - 20 * 5 * i, - (int) GT_Values.V[i]); - } + GregtechItemList[] mMachineCasingCovers = new GregtechItemList[] { + GregtechItemList.FakeMachineCasingPlate_ULV, + GregtechItemList.FakeMachineCasingPlate_LV, + GregtechItemList.FakeMachineCasingPlate_MV, + GregtechItemList.FakeMachineCasingPlate_HV, + GregtechItemList.FakeMachineCasingPlate_EV, + GregtechItemList.FakeMachineCasingPlate_IV, + GregtechItemList.FakeMachineCasingPlate_LuV, + GregtechItemList.FakeMachineCasingPlate_ZPM, + GregtechItemList.FakeMachineCasingPlate_UV, + GregtechItemList.FakeMachineCasingPlate_MAX, + }; + int aMaxTier = GT_Values.VOLTAGE_NAMES.length; + if (!GTNH) { + aMaxTier = 10; + } + ItemStack aTier[] = new ItemStack[aMaxTier]; + for (int i=0;i<aMaxTier;i++) { + aTier[i] = ItemUtils.simpleMetaStack(CoverManager.Cover_Gt_Machine_Casing, i, 7); + } + // Deprecate old recipes + for (int i=0;i<10;i++) { + RecipeUtils.addShapelessGregtechRecipe(new ItemStack[] {mMachineCasingCovers[i].get(1)}, ItemUtils.getSimpleStack(aTier[i], 1)); + } + // Add recipes for new ones + for (int i = 0;i<aMaxTier;i++) { + GT_Values.RA.addCutterRecipe( + CI.getTieredMachineCasing(i), + aTier[i], + null, + 20 * 5 * i, + (int) GT_Values.V[i]); + } } - + + private static void ztonesCoverRecipes() { + + if (!Loader.isModLoaded("Ztones")) { + return; + } + Class ModBlocksClass = ReflectionUtils.getClass("com.riciJak.Ztones.init.ModBlocks"); + Block agon = (Block) ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "agonBlock")); + Block korp = (Block) ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "korpBlock")); + Block jelt = (Block) ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "jeltBlock")); + Block bitt = (Block) ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "bittBlock")); + Block iszm = (Block) ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "iszmBlock")); + + // "agon", "iszm", "korp", "jelt", "bitt" + + ItemStack[] aBlocks = new ItemStack[] { + ItemUtils.getSimpleStack(agon), + ItemUtils.getSimpleStack(iszm), + ItemUtils.getSimpleStack(korp), + ItemUtils.getSimpleStack(jelt), + ItemUtils.getSimpleStack(bitt) + }; + MetaCustomCoverItem[] aCovers = new MetaCustomCoverItem[] { + CoverManager.Cover_Agon, + CoverManager.Cover_Iszm, + CoverManager.Cover_Korp, + CoverManager.Cover_Jelt, + CoverManager.Cover_Bitt + }; + + ItemStack aInputs[][] = new ItemStack[5][16]; + ItemStack aOutputs[][] = new ItemStack[5][16]; + for (int a=0;a<5;a++) { + for (int i=0;i<16;i++) { + aInputs[a][i] = ItemUtils.simpleMetaStack(aBlocks[a].getItem(), i, 1); + aOutputs[a][i] = ItemUtils.simpleMetaStack(aCovers[a], i, 9); + } + } + for (int a=0;a<5;a++) { + for (int i = 0;i<16;i++) { + ItemStack aInput = aInputs[a][i]; + ItemStack aOutput = aOutputs[a][i]; + if (GT_Values.RA.addCutterRecipe( + aInput, + aOutput, + null, + 20 * 5, + 16)) { + Logger.INFO("Added Cutting recipe for "+aInput.getDisplayName()); + } + + if (CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedCircuit((i/4)+4), + aOutput + }, + FluidUtils.getWildcardFluidStack("glue", 250), + aInput, + 20 * 10, + 16)) { + Logger.INFO("Added Assembly recipe for "+aInput.getDisplayName()); + } + } + } + } + private static void superBuses() { - GregtechItemList[] mSuperBusesInput = new GregtechItemList[] { - GregtechItemList.Hatch_SuperBus_Input_ULV, - GregtechItemList.Hatch_SuperBus_Input_LV, - GregtechItemList.Hatch_SuperBus_Input_MV, - GregtechItemList.Hatch_SuperBus_Input_HV, - GregtechItemList.Hatch_SuperBus_Input_EV, - GregtechItemList.Hatch_SuperBus_Input_IV, - GregtechItemList.Hatch_SuperBus_Input_LuV, - GregtechItemList.Hatch_SuperBus_Input_ZPM, - GregtechItemList.Hatch_SuperBus_Input_UV, - GregtechItemList.Hatch_SuperBus_Input_MAX, - }; - - GregtechItemList[] mSuperBusesOutput = new GregtechItemList[] { - GregtechItemList.Hatch_SuperBus_Output_ULV, - GregtechItemList.Hatch_SuperBus_Output_LV, - GregtechItemList.Hatch_SuperBus_Output_MV, - GregtechItemList.Hatch_SuperBus_Output_HV, - GregtechItemList.Hatch_SuperBus_Output_EV, - GregtechItemList.Hatch_SuperBus_Output_IV, - GregtechItemList.Hatch_SuperBus_Output_LuV, - GregtechItemList.Hatch_SuperBus_Output_ZPM, - GregtechItemList.Hatch_SuperBus_Output_UV, - GregtechItemList.Hatch_SuperBus_Output_MAX, - }; - - ItemStack[] mInputHatch = new ItemStack[] { - ItemList.Hatch_Input_Bus_EV.get(1), - ItemList.Hatch_Input_Bus_IV.get(1), - ItemList.Hatch_Input_Bus_LuV.get(1), - ItemList.Hatch_Input_Bus_ZPM.get(1), - ItemList.Hatch_Input_Bus_UV.get(1), - ItemList.Hatch_Input_Bus_MAX.get(1), - GregtechItemList.Hatch_SuperBus_Input_ULV.get(1), - GregtechItemList.Hatch_SuperBus_Input_LV.get(1), - GregtechItemList.Hatch_SuperBus_Input_MV.get(1), - GregtechItemList.Hatch_SuperBus_Input_HV.get(1), - }; - - ItemStack[] mOutputHatch = new ItemStack[] { - ItemList.Hatch_Output_Bus_EV.get(1), - ItemList.Hatch_Output_Bus_IV.get(1), - ItemList.Hatch_Output_Bus_LuV.get(1), - ItemList.Hatch_Output_Bus_ZPM.get(1), - ItemList.Hatch_Output_Bus_UV.get(1), - ItemList.Hatch_Output_Bus_MAX.get(1), - GregtechItemList.Hatch_SuperBus_Output_ULV.get(1), - GregtechItemList.Hatch_SuperBus_Output_LV.get(1), - GregtechItemList.Hatch_SuperBus_Output_MV.get(1), - GregtechItemList.Hatch_SuperBus_Output_HV.get(1), - }; - - //Input Buses - for (int i = 0; i < 10; i++) { - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - CI.getNumberedCircuit(16), - mInputHatch[i], - CI.getElectricMotor(i, GTNH ? 8 : 2), - CI.getConveyor(i, GTNH ? 10 : 5), - CI.getGear(i, GTNH ? 6 : 3), - CI.getTieredComponent(OrePrefixes.circuit, i, GTNH ? 4 : 2) - }, - CI.getAlternativeTieredFluid(i, 144 * 8), - mSuperBusesInput[i].get(1), 20 * 30 * 2 * i, - (int) GT_Values.V[i]); - } - //Output Buses - for (int i = 0; i < 10; i++) { - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - CI.getNumberedCircuit(18), - mOutputHatch[i], - CI.getElectricPiston(i, GTNH ? 8 : 2), - CI.getConveyor(i, GTNH ? 10 : 5), - CI.getGear(i, GTNH ? 6 : 3), - CI.getTieredComponent(OrePrefixes.circuit, i, GTNH ? 4 : 2) - }, - CI.getTertiaryTieredFluid(i, 144 * 8), - mSuperBusesOutput[i].get(1), 20 * 30 * 2 * i, - (int) GT_Values.V[i]); - } - + GregtechItemList[] mSuperBusesInput = new GregtechItemList[] { + GregtechItemList.Hatch_SuperBus_Input_ULV, + GregtechItemList.Hatch_SuperBus_Input_LV, + GregtechItemList.Hatch_SuperBus_Input_MV, + GregtechItemList.Hatch_SuperBus_Input_HV, + GregtechItemList.Hatch_SuperBus_Input_EV, + GregtechItemList.Hatch_SuperBus_Input_IV, + GregtechItemList.Hatch_SuperBus_Input_LuV, + GregtechItemList.Hatch_SuperBus_Input_ZPM, + GregtechItemList.Hatch_SuperBus_Input_UV, + GregtechItemList.Hatch_SuperBus_Input_MAX, + }; + + GregtechItemList[] mSuperBusesOutput = new GregtechItemList[] { + GregtechItemList.Hatch_SuperBus_Output_ULV, + GregtechItemList.Hatch_SuperBus_Output_LV, + GregtechItemList.Hatch_SuperBus_Output_MV, + GregtechItemList.Hatch_SuperBus_Output_HV, + GregtechItemList.Hatch_SuperBus_Output_EV, + GregtechItemList.Hatch_SuperBus_Output_IV, + GregtechItemList.Hatch_SuperBus_Output_LuV, + GregtechItemList.Hatch_SuperBus_Output_ZPM, + GregtechItemList.Hatch_SuperBus_Output_UV, + GregtechItemList.Hatch_SuperBus_Output_MAX, + }; + + ItemStack[] mInputHatch = new ItemStack[] { + ItemList.Hatch_Input_Bus_EV.get(1), + ItemList.Hatch_Input_Bus_IV.get(1), + ItemList.Hatch_Input_Bus_LuV.get(1), + ItemList.Hatch_Input_Bus_ZPM.get(1), + ItemList.Hatch_Input_Bus_UV.get(1), + ItemList.Hatch_Input_Bus_MAX.get(1), + GregtechItemList.Hatch_SuperBus_Input_LV.get(1), + GregtechItemList.Hatch_SuperBus_Input_MV.get(1), + GregtechItemList.Hatch_SuperBus_Input_HV.get(1), + GregtechItemList.Hatch_SuperBus_Input_EV.get(1), + }; + + ItemStack[] mOutputHatch = new ItemStack[] { + ItemList.Hatch_Output_Bus_EV.get(1), + ItemList.Hatch_Output_Bus_IV.get(1), + ItemList.Hatch_Output_Bus_LuV.get(1), + ItemList.Hatch_Output_Bus_ZPM.get(1), + ItemList.Hatch_Output_Bus_UV.get(1), + ItemList.Hatch_Output_Bus_MAX.get(1), + GregtechItemList.Hatch_SuperBus_Output_LV.get(1), + GregtechItemList.Hatch_SuperBus_Output_MV.get(1), + GregtechItemList.Hatch_SuperBus_Output_HV.get(1), + GregtechItemList.Hatch_SuperBus_Output_EV.get(1), + }; + + // Special Case recipes for ULV buses + { + + int i = 0; + ItemStack[] aInputs1 = new ItemStack[] { + CI.getNumberedCircuit(17), + mInputHatch[i], + CI.getElectricMotor(i, GTNH ? 8 : 2), + CI.getConveyor(i, GTNH ? 10 : 5), + CI.getBolt(i, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, i, GTNH ? 4 : 2) + }; + Logger.INFO("[FIND] "+ItemUtils.getArrayStackNames(aInputs1)); + ItemStack[] aOutputs1 = new ItemStack[] { + CI.getNumberedCircuit(18), + mOutputHatch[i], + CI.getElectricPiston(i, GTNH ? 8 : 2), + CI.getConveyor(i, GTNH ? 10 : 5), + CI.getGear(i, GTNH ? 6 : 3), + CI.getTieredComponent(OrePrefixes.circuit, i, GTNH ? 4 : 2) + }; + Logger.INFO("[FIND] "+ItemUtils.getArrayStackNames(aOutputs1)); + + FluidStack a1 = CI.getAlternativeTieredFluid(i, 144 * 8); + FluidStack a2 = CI.getTertiaryTieredFluid(i, 144 * 8); + + + Logger.INFO("[FIND] Input Bus Fluid: "+ItemUtils.getFluidName(a1)); + Logger.INFO("[FIND] Output Bus Fluid: "+ItemUtils.getFluidName(a2)); + + + CORE.RA.addSixSlotAssemblingRecipe(aInputs1, + a1, + mSuperBusesInput[i].get(1), + 20 * 30 * 2 * i, + (int) GT_Values.V[i]); + + CORE.RA.addSixSlotAssemblingRecipe(aOutputs1, + a2, + mSuperBusesOutput[i].get(1), + 20 * 30 * 2 * i, + (int) GT_Values.V[i]); + + + } + + //Input Buses + for (int i = 1; i < 10; i++) { + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + CI.getNumberedCircuit(17), + mInputHatch[i], + CI.getElectricMotor(i, GTNH ? 8 : 2), + CI.getConveyor(i, GTNH ? 10 : 5), + CI.getBolt(i, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, i, GTNH ? 4 : 2) + }, + CI.getAlternativeTieredFluid(i, 144 * 8), + mSuperBusesInput[i].get(1), 20 * 30 * 2 * i, + (int) GT_Values.V[i]); + } + //Output Buses + for (int i = 1; i < 10; i++) { + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + CI.getNumberedCircuit(18), + mOutputHatch[i], + CI.getElectricPiston(i, GTNH ? 8 : 2), + CI.getConveyor(i, GTNH ? 10 : 5), + CI.getGear(i, GTNH ? 6 : 3), + CI.getTieredComponent(OrePrefixes.circuit, i, GTNH ? 4 : 2) + }, + CI.getTertiaryTieredFluid(i, 144 * 8), + mSuperBusesOutput[i].get(1), 20 * 30 * 2 * i, + (int) GT_Values.V[i]); + } + } - + + private static void roundRobinators() { + + RecipeUtils.addShapedGregtechRecipe( + ItemUtils.getSimpleStack(Blocks.hopper), "circuitPrimitive", ItemUtils.getSimpleStack(Blocks.hopper), + CI.craftingToolWrench, CI.machineCasing_ULV, CI.craftingToolScrewdriver, + ItemUtils.getSimpleStack(Blocks.hopper), "circuitPrimitive", ItemUtils.getSimpleStack(Blocks.hopper), + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 0, 1)); + + ItemStack[] aRobinators = new ItemStack[] { + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 0, 1), + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 1, 1), + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 2, 1), + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 3, 1), + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 4, 1), + }; + + int aCostMultiplier = GTNH ? 2 : 1; + + for (int i = 0; i < 5; i++) { + if (i == 0) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedCircuit(17), + CI.getTieredMachineCasing(0), + ItemUtils.getSimpleStack(Blocks.hopper, 4), + CI.getTieredComponent(OrePrefixes.circuit, 0, 2) + }, + GT_Values.NF, //Input Fluid + aRobinators[i], + 45 * 10 * 1, + 8); + continue; + } + int aTier = i+1; + ItemStack[] aInputs = new ItemStack[] { + aRobinators[i-1], + CI.getTieredMachineHull(aTier, 1 * aCostMultiplier), + CI.getConveyor(aTier, 2 * aCostMultiplier), + CI.getElectricMotor(aTier, 2 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.plate, aTier, 4 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.circuit, i, 2 * aCostMultiplier), + }; + + CORE.RA.addSixSlotAssemblingRecipe( + aInputs, + GT_Values.NF, //Input Fluid + aRobinators[i], + 45 * 10 * 1 * (i+1), + MaterialUtils.getVoltageForTier(i)); + + } + } + } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java new file mode 100644 index 0000000000..d3c0b4c093 --- /dev/null +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java @@ -0,0 +1,226 @@ +package gtPlusPlus.core.recipe; + +import static gtPlusPlus.core.material.MISC_MATERIALS.BRINE; +import static gtPlusPlus.core.material.MISC_MATERIALS.HYDROGEN_CHLORIDE; +import static gtPlusPlus.core.material.MISC_MATERIALS.RARE_EARTH_HIGH; +import static gtPlusPlus.core.material.MISC_MATERIALS.RARE_EARTH_LOW; +import static gtPlusPlus.core.material.MISC_MATERIALS.RARE_EARTH_MID; +import static gtPlusPlus.core.material.MISC_MATERIALS.SALT_WATER; +import static gtPlusPlus.core.material.MISC_MATERIALS.SODIUM_CHLORIDE; +import static gtPlusPlus.core.material.MISC_MATERIALS.SODIUM_HYDROXIDE; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.material.ORES; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class RECIPES_RareEarthProcessing { + + private static ItemStack mDustSodiumHydroxide; + private static ItemStack mDustSalt; + private static FluidStack mSaltWater; + private static FluidStack mBrine; + private static FluidStack mHydrogenChloride; + + public static void init() { + + // Salt Check and Assignment + mDustSalt = ItemUtils.getItemStackOfAmountFromOreDict("dustSalt", 1); + if (mDustSalt == null) { + MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_CHLORIDE, false); + mDustSalt = SODIUM_CHLORIDE.getDust(1); + } + else { + SODIUM_CHLORIDE.registerComponentForMaterial(OrePrefixes.dust, mDustSalt); + } + + // Salt water Check and Assignment + mSaltWater = FluidUtils.getFluidStack("saltwater", 1000); + if (mSaltWater == null) { + Fluid f = SALT_WATER.generateFluid(); + SALT_WATER.registerComponentForMaterial(FluidUtils.getFluidStack(f, 1000)); + mSaltWater = SALT_WATER.getFluid(1000); + } + else { + SALT_WATER.registerComponentForMaterial(FluidUtils.getFluidStack(mSaltWater, 1000)); + } + + // Brine Check and assignment + mBrine = FluidUtils.getFluidStack("brine", 1000); + if (mBrine == null) { + Fluid f = BRINE.generateFluid(); + BRINE.registerComponentForMaterial(FluidUtils.getFluidStack(f, 1000)); + mBrine = BRINE.getFluid(1000); + } + else { + BRINE.registerComponentForMaterial(FluidUtils.getFluidStack(mBrine, 1000)); + } + + // Check Sodium Hydroxide Exists, generate if not. + mDustSodiumHydroxide = ItemUtils.getItemStackOfAmountFromOreDict("dustSodiumHydroxide", 1); + if (mDustSodiumHydroxide == null) { + mDustSodiumHydroxide = ItemUtils.getItemStackOfAmountFromOreDict("dustSodiumHydroxide_GT5U", 1); + if (mDustSodiumHydroxide == null) { + MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_HYDROXIDE, false); + mDustSodiumHydroxide = SODIUM_HYDROXIDE.getDust(1); + } + else { + SODIUM_HYDROXIDE.registerComponentForMaterial(OrePrefixes.dust, mDustSodiumHydroxide); + } + } + else { + SODIUM_HYDROXIDE.registerComponentForMaterial(OrePrefixes.dust, mDustSodiumHydroxide); + } + + // Hydrogen Chloride Check and assignment + mHydrogenChloride = FluidUtils.getFluidStack("hydrogenchloride", 1000); + if (mHydrogenChloride == null) { + HYDROGEN_CHLORIDE.generateFluid(); + mHydrogenChloride = BRINE.getFluid(1000); + } + else { + HYDROGEN_CHLORIDE.registerComponentForMaterial(FluidUtils.getFluidStack(mHydrogenChloride, 1000)); + } + + + // Add Process for creating Brine + CORE.RA.addBrewingRecipe( + ItemUtils.getSimpleStack(mDustSalt, 16), + MISC_MATERIALS.SALT_WATER.getFluid(2000), + FluidUtils.getFluidStack(mBrine, 4000), + 20 * 20, + 120, + false); + + // Chloralkali process + GT_Values.RA.addElectrolyzerRecipe( + CI.getNumberedCircuit(16), + CI.emptyCells(4), + FluidUtils.getFluidStack(mBrine, 4000), + null, // Out + ItemUtils.getItemStackOfAmountFromOreDict("cellChlorine", 2), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 2), + ItemUtils.getSimpleStack(mDustSodiumHydroxide, 2), + null, + null, + null, + new int[] {10000, 10000, 10000}, + 20 * 30, + (int) GT_Values.V[2]); + + // Generate Special Laser Recipe + CORE.RA.addUvLaserRecipe( + ELEMENT.getInstance().CHLORINE.getCell(2), + ELEMENT.getInstance().HYDROGEN.getCell(2), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenChloride", 4), + 20 * 30, + 480); + + + // Set Material Tiers correctly + ORES.GREENOCKITE.vTier = 1; + RARE_EARTH_LOW.vTier = 1; + RARE_EARTH_MID.vTier = 3; + RARE_EARTH_HIGH.vTier = 5; + + // Set Material Voltages correctly + ORES.GREENOCKITE.vVoltageMultiplier = 30; + RARE_EARTH_LOW.vVoltageMultiplier = 30; + RARE_EARTH_MID.vVoltageMultiplier = 480; + RARE_EARTH_HIGH.vVoltageMultiplier = 7680; + + // Set Material Tooltips to be shorter + RARE_EARTH_LOW.vChemicalFormula = "??????"; + RARE_EARTH_MID.vChemicalFormula = "??????"; + RARE_EARTH_HIGH.vChemicalFormula = "??????"; + + // Set Material Tooltips to be shorter + RARE_EARTH_LOW.vChemicalSymbol = "??"; + RARE_EARTH_MID.vChemicalSymbol = "??"; + RARE_EARTH_HIGH.vChemicalSymbol = "??"; + + // Generate Ore Materials + MaterialGenerator.generateOreMaterial(RARE_EARTH_LOW); + MaterialGenerator.generateOreMaterial(RARE_EARTH_MID); + MaterialGenerator.generateOreMaterial(RARE_EARTH_HIGH); + + ItemStack aRareEarth = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.RareEarth, 1L); + + Fluid aSulfuric = FluidUtils.getFluidStack("sulfuricacid", 1).getFluid(); + Fluid aHydrocholric = FluidUtils.getFluidStack("hydrogenchloride", 1).getFluid(); + Fluid aNitric = FluidUtils.getFluidStack("hydrofluoricacid", 1).getFluid(); + + + + // LV Rare Earth + GT_Values.RA.addChemicalBathRecipe( + ItemUtils.getSimpleStack(aRareEarth, 3), + FluidUtils.getFluidStack(aSulfuric, 1000), + RARE_EARTH_LOW.getCrushed(1), + RARE_EARTH_LOW.getCrushed(1), + RARE_EARTH_LOW.getCrushed(1), + new int[] {10000, 10000, 9000}, + 20 * 30, + (int) GT_Values.V[1]); + + // HV Rare Earth + GT_Values.RA.addChemicalBathRecipe( + ItemUtils.getSimpleStack(aRareEarth, 6), + FluidUtils.getFluidStack(aHydrocholric, 3000), + RARE_EARTH_MID.getCrushed(2), + RARE_EARTH_MID.getCrushed(2), + RARE_EARTH_MID.getCrushed(2), + new int[] {10000, 9000, 8000}, + 20 * 60, + (int) GT_Values.V[3]); + + // IV Rare Earth + GT_Values.RA.addChemicalBathRecipe( + ItemUtils.getSimpleStack(aRareEarth, 9), + FluidUtils.getFluidStack(aNitric, 6000), + RARE_EARTH_HIGH.getCrushed(3), + RARE_EARTH_HIGH.getCrushed(3), + RARE_EARTH_HIGH.getCrushed(3), + new int[] {9000, 8000, 7000}, + 20 * 90, + (int) GT_Values.V[5]); + + + } + + + public static void processCopperRecipes() { + + // Rare Earth Processing + /*GT_Values.RA.addSifterRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustRareEarth", 1), + new ItemStack[] { + ELEMENT.getInstance().YTTRIUM.getSmallDust(1), + ELEMENT.getInstance().NEODYMIUM.getSmallDust(1), + ELEMENT.getInstance().LANTHANUM.getSmallDust(1), + ELEMENT.getInstance().CERIUM.getSmallDust(1), + ELEMENT.getInstance().CADMIUM.getSmallDust(1), + ELEMENT.getInstance().CAESIUM.getSmallDust(1), + ORES.SAMARSKITE_YB.getSmallDust(1), + ORES.FLORENCITE.getSmallDust(1), + ORES.FLUORCAPHITE.getSmallDust(1), + //ELEMENT.getInstance().YTTERBIUM.getTinyDust(1), + //ELEMENT.getInstance().SAMARIUM.getTinyDust(1), + //ELEMENT.getInstance().GADOLINIUM.getTinyDust(1) + }, + new int[] { 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000 }, 20 * 30, 500);*/ + + } + +} diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java index 471a3cc33e..902806e026 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java @@ -17,7 +17,7 @@ public class RECIPES_SeleniumProcessing { public static void init() { //We need this - MaterialUtils.generateSpecialDustAndAssignToAMaterial(MISC_MATERIALS.SELENIUM_DIOXIDE); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(MISC_MATERIALS.SELENIUM_DIOXIDE, false); // Makes Selenium Dioxide processCopperRecipes(); @@ -86,15 +86,15 @@ public class RECIPES_SeleniumProcessing { public static void processCopperRecipes() { - //Copper + //Copper CORE.RA.addDehydratorRecipe( new ItemStack[]{ - ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Copper, 1), // Item Input + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Copper, 1), // Item Input }, FluidUtils.getHotWater(1000), // Fluid MISC_MATERIALS.SELENIUM_DIOXIDE.getFluid(20), // Fluid new ItemStack[] { - ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Copper, 1), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Copper, 1), MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), @@ -116,18 +116,17 @@ public class RECIPES_SeleniumProcessing { 1000 }, 40 * 20, // Time in ticks - 1024); // EU - + 1024); // EU //Tetra CORE.RA.addDehydratorRecipe( new ItemStack[]{ - ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Tetrahedrite, 1), // Item Input + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Tetrahedrite, 1), // Item Input }, FluidUtils.getHotWater(1000), // Fluid MISC_MATERIALS.SELENIUM_DIOXIDE.getFluid(10), // Fluid new ItemStack[] { - ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Tetrahedrite, 1), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Tetrahedrite, 1), MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), @@ -150,15 +149,16 @@ public class RECIPES_SeleniumProcessing { }, 40 * 20, // Time in ticks 1024); // EU + //Chalco CORE.RA.addDehydratorRecipe( new ItemStack[]{ - ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Chalcopyrite, 1), // Item Input + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Chalcopyrite, 1), // Item Input }, FluidUtils.getHotWater(1000), // Fluid MISC_MATERIALS.SELENIUM_DIOXIDE.getFluid(10), // Fluid new ItemStack[] { - ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Chalcopyrite, 1), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Chalcopyrite, 1), MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), @@ -181,15 +181,16 @@ public class RECIPES_SeleniumProcessing { }, 40 * 20, // Time in ticks 1024); // EU + //Malachite CORE.RA.addDehydratorRecipe( new ItemStack[]{ - ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Malachite, 1), // Item Input + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Malachite, 1), // Item Input }, FluidUtils.getHotWater(1000), // Fluid MISC_MATERIALS.SELENIUM_DIOXIDE.getFluid(10), // Fluid new ItemStack[] { - ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Malachite, 1), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Malachite, 1), MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java index 10cefdf0c4..2cc6d7b41a 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java @@ -154,16 +154,7 @@ public class RECIPES_Tools { CobbleStone, sandHammer, CobbleStone, CobbleStone, CobbleStone, CobbleStone, RECIPE_Sand); - - if (LoadedMods.Baubles){ - //Cloaking Device - RecipeUtils.recipeBuilder( - plateDoubleNiChrome, plateIridiumAlloy, plateDoubleNiChrome, - plateIridiumAlloy, batteryUltimate, plateIridiumAlloy, - plateDoubleNiChrome, plateIridiumAlloy, plateDoubleNiChrome, - personalCloakingDevice); - - } + //Sand to Sandstone RecipeUtils.recipeBuilder( Sand, Sand, Sand, diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index a9f336d19c..be1089a72a 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -6,6 +6,7 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; @@ -447,7 +448,10 @@ public class CI { } public static final ItemStack getTieredMachineCasing(int tier){ - if (tier == 0){ + if (tier == 0){ + if (machineCasing_ULV == null) { + machineCasing_ULV = ItemList.Casing_ULV.get(1); + } return machineCasing_ULV; } else if (tier == 1){ @@ -544,7 +548,7 @@ public class CI { private static final Material[] aMaterial_Main = new Material[] { ALLOY.POTIN, - ALLOY.ZIRCONIUM_CARBIDE, + ALLOY.TUMBAGA, ALLOY.EGLIN_STEEL, ALLOY.INCONEL_792, ALLOY.TUNGSTEN_TITANIUM_CARBIDE, @@ -558,7 +562,7 @@ public class CI { }; private static final Material[] aMaterial_Secondary = new Material[] { - ALLOY.TUMBAGA, + ALLOY.STEEL, ALLOY.SILICON_CARBIDE, ALLOY.TUNGSTEN_CARBIDE, ALLOY.INCONEL_690, @@ -573,7 +577,7 @@ public class CI { }; private static final Material[] aMaterial_Tertiary = new Material[] { - ALLOY.STEEL, + ELEMENT.getInstance().LEAD, ELEMENT.getInstance().ALUMINIUM, ALLOY.STAINLESS_STEEL, ELEMENT.getInstance().TUNGSTEN, @@ -631,12 +635,22 @@ public class CI { } public static FluidStack getTieredFluid(int aTier, int aAmount, int aType) { - ItemStack aCell = getTieredComponent(OrePrefixes.liquid, aTier, 1); + // Weird Legacy handling + /*ItemStack aCell = getTieredComponent(OrePrefixes.liquid, aTier, 1); FluidStack a = GT_Utility.getFluidForFilledItem(aCell, true); if (a == null) { a = aMaster[aType][aTier].getFluid(aAmount); - } - a.amount = aAmount; + }*/ + + // Modern Handling + FluidStack a = aMaster[aType][aTier].getFluid(aAmount); + if (a == null) { + ItemStack aCell = getTieredComponent(OrePrefixes.liquid, aTier, 1); + if (aCell != null) { + a = GT_Utility.getFluidForFilledItem(aCell, true); + a.amount = aAmount; + } + } return a; } @@ -1226,4 +1240,8 @@ public class CI { } + public static ItemStack getNumberedBioCircuit(int i) { + return ItemUtils.simpleMetaStack(AgriculturalChem.mBioCircuit, i, 0); + } + } diff --git a/src/Java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java b/src/Java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java new file mode 100644 index 0000000000..6cd13dc209 --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java @@ -0,0 +1,45 @@ +package gtPlusPlus.core.slots; + +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class SlotChemicalPlantInput extends Slot { + + public SlotChemicalPlantInput(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + return isItemValidForChemicalPlantSlot(itemstack); + } + + public static boolean isItemValidForChemicalPlantSlot(ItemStack aStack) { + boolean validItem = Gregtech_Recipe_Map.sFluidChemicalReactorRecipes.containsInput(aStack); + if (!validItem) { + for (Recipe_GT f : Gregtech_Recipe_Map.sFluidChemicalReactorRecipes.mRecipeList) { + if (f.mFluidInputs.length > 0) { + for (FluidStack g : f.mFluidInputs) { + if (g != null) { + if (FluidContainerRegistry.containsFluid(aStack, g)) { + return true; + } + } + } + } + } + } + return validItem; + } + + @Override + public int getSlotStackLimit() { + return 64; + } + +} diff --git a/src/Java/gtPlusPlus/core/slots/SlotGeneric.java b/src/Java/gtPlusPlus/core/slots/SlotGeneric.java index d4c389d9cc..533539d914 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotGeneric.java +++ b/src/Java/gtPlusPlus/core/slots/SlotGeneric.java @@ -6,9 +6,8 @@ import net.minecraft.item.ItemStack; public class SlotGeneric extends Slot { - public SlotGeneric(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - + public SlotGeneric(final IInventory inventory, final int aSlotID, final int x, final int y) { + super(inventory, aSlotID, x, y); } @Override diff --git a/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java b/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java index c41a385c4b..48b050d678 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java +++ b/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java @@ -10,12 +10,13 @@ import gtPlusPlus.core.recipe.common.CI; public class SlotIntegratedCircuit extends Slot { public static Item mCircuitItem; + public static Item mCircuitItem2; private final short mCircuitLock; public SlotIntegratedCircuit(final IInventory inventory, final int slot, final int x, final int y) { this(Short.MAX_VALUE+1, inventory, slot, x, y); } - + public SlotIntegratedCircuit(int mTypeLock, final IInventory inventory, final int slot, final int x, final int y) { super(inventory, slot, x, y); if (mTypeLock > Short.MAX_VALUE || mTypeLock < Short.MIN_VALUE) { @@ -28,18 +29,29 @@ public class SlotIntegratedCircuit extends Slot { @Override public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(mCircuitLock, itemstack); + } + + public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { + return isItemValidForSlot(-1, itemstack); + } + + public static synchronized boolean isItemValidForSlot(int aLockedCircuitNumber, final ItemStack itemstack) { boolean isValid = false; if (mCircuitItem == null) { mCircuitItem = CI.getNumberedCircuit(0).getItem(); } - if (mCircuitItem != null) { + if (mCircuitItem2 == null) { + mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null) { if (itemstack != null) { - if (itemstack.getItem() == mCircuitItem) { - if (mCircuitLock == -1) { + if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2) { + if (aLockedCircuitNumber == -1) { isValid = true; } else { - if (itemstack.getItemDamage() == mCircuitLock) { + if (itemstack.getItemDamage() == aLockedCircuitNumber) { isValid = true; } } @@ -49,6 +61,33 @@ public class SlotIntegratedCircuit extends Slot { return isValid; } + /** + * Returns the circuit type. -1 is invalid, 0 is standard, 1 is GT++ bio. + * @param itemstack - the Circuit Stack. + * @return + */ + public static synchronized int isRegularProgrammableCircuit(final ItemStack itemstack) { + if (mCircuitItem == null) { + mCircuitItem = CI.getNumberedCircuit(0).getItem(); + } + if (mCircuitItem2 == null) { + mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null) { + if (itemstack != null) { + if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2) { + if (itemstack.getItem() == mCircuitItem) { + return 0; + } + else if (itemstack.getItem() == mCircuitItem2) { + return 1; + } + } + } + } + return -1; + } + @Override public int getSlotStackLimit() { return 64; diff --git a/src/Java/gtPlusPlus/core/slots/SlotNoInputLogging.java b/src/Java/gtPlusPlus/core/slots/SlotNoInputLogging.java new file mode 100644 index 0000000000..762714ac94 --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotNoInputLogging.java @@ -0,0 +1,36 @@ +package gtPlusPlus.core.slots; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +public class SlotNoInputLogging extends SlotNoInput { + + private final int aSlotIndex; + + public SlotNoInputLogging(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); + aSlotIndex = index; + Logger.INFO("Slot "+index+" is doing logging"); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (ItemUtils.checkForInvalidItems(itemstack)) { + Logger.INFO("Tried Inserting "+ItemUtils.getItemName(itemstack)+" into slot "+aSlotIndex); + Block b = Block.getBlockFromItem(itemstack.getItem()); + Logger.INFO(""+itemstack.getUnlocalizedName()); + if (b != null) { + Logger.INFO(""+b.getLocalizedName()); + Logger.INFO(""+b.getUnlocalizedName()); + } + } + else { + Logger.INFO("Bad Itemstack"); + } + return false; + } + +} diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index c3670ef959..e7b7c46e7b 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -1,14 +1,26 @@ package gtPlusPlus.core.tileentities; import cpw.mods.fml.common.registry.GameRegistry; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.general.BlockSuperLight.TileEntitySuperLight; import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.tileentities.general.*; -import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler; -import gtPlusPlus.core.tileentities.machines.*; +import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; +import gtPlusPlus.core.tileentities.general.TileEntityFirepit; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; +import gtPlusPlus.core.tileentities.general.TileEntityInfiniteFluid; +import gtPlusPlus.core.tileentities.general.TileEntityPlayerDoorBase; +import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; +import gtPlusPlus.core.tileentities.machines.TileEntityAdvPooCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; +import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; +import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; +import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; import gtPlusPlus.plugin.villagers.tile.TileEntityGenericSpawner; public class ModTileEntities { @@ -32,6 +44,8 @@ public class ModTileEntities { GameRegistry.registerTileEntity(TileEntityDecayablesChest.class, "TileDecayablesChest"); GameRegistry.registerTileEntity(TileEntitySuperJukebox.class, "TileEntitySuperJukebox"); GameRegistry.registerTileEntity(TileEntitySuperLight.class, "TileEntitySuperLight"); + GameRegistry.registerTileEntity(TileEntityPestKiller.class, "TileEntityPestKiller"); + GameRegistry.registerTileEntity(TileEntityRoundRobinator.class, "TileEntityRoundRobinator"); //Mod TEs diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java index 4f9a8d3748..65ae9218fe 100644 --- a/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java +++ b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java @@ -1315,6 +1315,24 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT } return false; } + + + /** + * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d + */ + public boolean inputEnergyFrom(byte arg0, boolean arg1) { + // TODO Auto-generated method stub + return false; + } + + + /** + * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d + */ + public boolean outputsEnergyTo(byte arg0, boolean arg1) { + // TODO Auto-generated method stub + return false; + } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java index 0cda40c616..23ad2a3233 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java @@ -11,6 +11,7 @@ import net.minecraft.tileentity.TileEntity; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.inventories.InventoryCircuitProgrammer; import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.slots.SlotIntegratedCircuit; import gtPlusPlus.core.util.minecraft.PlayerUtils; public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInventory { @@ -76,16 +77,21 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv boolean doAdd = false; ItemStack g = this.getStackInSlot(e); int aSize = 0; - ItemStack aInputStack = null; - if (g != null) { + ItemStack aInputStack = null; + int aTypeInSlot = SlotIntegratedCircuit.isRegularProgrammableCircuit(g); + if (aTypeInSlot >= 0 && g != null) { + // No Existing Output if (!hasOutput) { aSize = g.stackSize; doAdd = true; } + // Existing Output else { ItemStack f = this.getStackInSlot(25); - if (f != null) { - if (f.getItemDamage() == e) { + int aTypeInCheckedSlot = SlotIntegratedCircuit.isRegularProgrammableCircuit(f); + // Check that the Circuit in the Output slot is not null and the same type as the circuit input. + if (aTypeInCheckedSlot >= 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { + if (g.getItem() == f.getItem() && f.getItemDamage() == e) { aSize = f.stackSize + g.stackSize; if (aSize > 64) { aInputStack = g.copy(); @@ -93,16 +99,23 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv } doAdd = true; } - } - else { - doAdd = true; - aSize = g.stackSize; } } - if (doAdd) { - ItemStack aOutput = CI.getNumberedCircuit(e); - aOutput.stackSize = aSize; + if (doAdd) { + // Check Circuit Type + ItemStack aOutput; + if (aTypeInSlot == 0) { + aOutput = CI.getNumberedCircuit(e); + } + else if (aTypeInSlot == 1) { + aOutput = CI.getNumberedBioCircuit(e); + } + else { + aOutput = null; + } + if (aOutput != null) { + aOutput.stackSize = aSize; this.setInventorySlotContents(e, aInputStack); this.setInventorySlotContents(25, aOutput); return true; diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java new file mode 100644 index 0000000000..3ebe5be40d --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java @@ -0,0 +1,506 @@ +package gtPlusPlus.core.tileentities.machines; + +import java.util.ArrayList; +import java.util.List; + +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; +import gtPlusPlus.core.inventories.InventoryPestKiller; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +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; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.oredict.OreDictionary; + +public class TileEntityPestKiller extends TileEntity implements ISidedInventory, IFluidHandler { + + private final int mBaseTickRate = 20 * 30; + private final InventoryPestKiller mInventory; + private final FluidTank mTank; + private int mChunkX; + private int mChunkZ; + private boolean mSet = false; + + private int mTickCounter = 0; + private int mUpdateTick = 0; + private boolean mNeedsUpdate = false; + private String mCustomName; + + private static final AutoMap<Class<?>> mEntityMap = new AutoMap<Class<?>>(); + + static { + mEntityMap.put(EntityBat.class); + if (LoadedMods.Forestry) { + mEntityMap.put(ReflectionUtils.getClass("forestry.lepidopterology.entities.EntityButterfly")); + } + } + + public TileEntityPestKiller() { + this.mInventory = new InventoryPestKiller(); + mTank = new BTF_FluidTank(2000); + } + + public InventoryPestKiller getInventory() { + return this.mInventory; + } + + public FluidTank getTank() { + return mTank; + } + + private final void setup() { + World w = this.worldObj; + if (w != null) { + Chunk c = w.getChunkFromBlockCoords(this.xCoord, this.zCoord); + if (c != null) { + mChunkX = c.xPosition; + mChunkZ = c.zPosition; + mSet = true; + } + } + } + + @SuppressWarnings("rawtypes") + public boolean tryKillPests() { + int min = 0; + int max = 0; + switch (getTier()) { + case 1: + min = -2; + max = 3; + break; + case 2: + min = -4; + max = 5; + break; + default: + // code block + } + int aChunkCount = 0; + AutoMap<Entity> entities = new AutoMap<Entity>(); + if (min != 0 && max != 0) { + for (int x = min; x < max; x++) { + for (int z = min; z < max; z++) { + Chunk c = getChunkFromOffsetIfLoaded(x, z); + if (c != null) { + if (c.hasEntities) { + aChunkCount++; + List[] lists = c.entityLists; + for (List o : lists) { + for (Object e : o) { + if (e instanceof Entity) { + for (Class<?> C : mEntityMap) { + if (e.getClass().equals(C) || C.isAssignableFrom(e.getClass())) { + entities.put((Entity) e); + } + } + } + } + } + } + } + } + } + } else { + Chunk c = getChunkFromOffsetIfLoaded(0, 0); + if (c != null) { + if (c.hasEntities) { + List[] lists = c.entityLists; + for (List o : lists) { + for (Object e : o) { + if (e instanceof Entity) { + for (Class<?> C : mEntityMap) { + if (e.getClass().equals(C) || C.isAssignableFrom(e.getClass())) { + entities.put((Entity) e); + } + } + } + } + } + } + } + } + boolean killed = false; + if (!entities.isEmpty()) { + for (Entity e : entities) { + if (e != null) { + if (e.isEntityAlive()) { + if (this.mTank.getFluidAmount() >= 1 || getTier() == 0) { + if (getTier() > 0) { + int aChanceToUse = MathUtils.randInt(1, (100 * getTier())); + if (aChanceToUse == 1) { + this.mTank.drain(1, true); + } + } + e.performHurtAnimation(); + EntityUtils.doDamage(e, DamageSource.generic, Short.MAX_VALUE); + e.setDead(); + killed = true; + } + } + } + } + } + updateTileEntity(); + return killed; + } + + public Chunk getChunkFromOffsetIfLoaded(int x, int y) { + Chunk c = this.worldObj.getChunkFromChunkCoords(mChunkX + x, mChunkZ + y); + if (c.isChunkLoaded) { + return c; + } + return null; + } + + public int getTier() { + if (this.mTank != null) { + FluidStack f = mTank.getFluid(); + if (f != null) { + if (f.isFluidEqual(FluidUtils.getWildcardFluidStack("formaldehyde", 1))) { + return 1; + } else if (f.isFluidEqual(MISC_MATERIALS.HYDROGEN_CYANIDE.getFluid(1))) { + return 2; + } + } + } + return 0; + } + + @Override + public void updateEntity() { + if (worldObj.isRemote) { + return; + } + if (!mSet) { + setup(); + } + this.mTickCounter++; + if (this.mTank != null) { + if (this.hasFluidSpace()) { + handleInventory(); + } + } + if (this.mTickCounter % this.mBaseTickRate == 0) { + tryKillPests(); + } + updateTick(); + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + mTank.writeToNBT(nbt); + super.writeToNBT(nbt); + // Utils.LOG_MACHINE_INFO("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.mInventory.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + mTank.readFromNBT(nbt); + super.readFromNBT(nbt); + // Utils.LOG_MACHINE_INFO("Trying to read NBT data from TE."); + this.mInventory.readFromNBT(nbt.getCompoundTag("ContentsChest")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { + accessibleSides[r] = r; + } + return accessibleSides; + + } + + @Override + public boolean canInsertItem(final int aSlot, final ItemStack aStack, final int p_102007_3_) { + if (this.getInventory().getInventory()[0] == null) { + return true; + } else if (GT_Utility.areStacksEqual(aStack, this.getInventory().getInventory()[0])) { + if (this.getInventory().getInventory()[0].stackSize < 64) { + int diff = 64 - this.getInventory().getInventory()[0].stackSize; + if (aStack.stackSize <= diff) { + return true; + } + } + } + return false; + } + + @Override + public boolean canExtractItem(final int aSlot, final ItemStack aStack, final int p_102008_3_) { + if (this.getInventory().getInventory()[1] == null) { + return false; + } else { + return true; + } + } + + public String getCustomName() { + return this.mCustomName; + } + + public void setCustomName(final String customName) { + this.mCustomName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.mCustomName : "container.pestkiller"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.mCustomName != null) && !this.mCustomName.equals(""); + } + + @Override + public final int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + updateTileEntity(); + return this.mTank.fill(resource, doFill); + } + + @Override + public final FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + updateTileEntity(); + return this.mTank.drain(resource.amount, doDrain); + } + + @Override + public final FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + FluidStack fluid = this.mTank.getFluid(); + // return this.tank.drain(maxDrain, doDrain); + if (fluid == null) { + return null; + } + + int drained = maxDrain; + if (fluid.amount < drained) { + drained = fluid.amount; + } + + FluidStack stack = new FluidStack(fluid, drained); + if (doDrain) { + fluid.amount -= drained; + if (fluid.amount <= 0) { + fluid = null; + } + + if (this != null) { + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, this.getWorldObj(), this.xCoord, + this.yCoord, this.zCoord, this.mTank, 0)); + } + } + updateTileEntity(); + return stack; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return mTank.getFluid() == null || mTank.getFluid().getFluid().equals(fluid); + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public final FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] { this.mTank.getInfo() }; + } + + @Override + public final Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public final void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound tag = pkt.func_148857_g(); + readFromNBT(tag); + } + + + public boolean hasFluidSpace() { + if (this.mTank.getFluidAmount() <= 1000) { + return true; + } + return false; + } + + public boolean drainCell() { + boolean didFill = false; + ItemStack aInput = this.getStackInSlot(0); + if (aInput == null) { + return false; + } + aInput = aInput.copy(); + if (aInput != null && (this.getStackInSlot(1) == null || this.getStackInSlot(1).stackSize < 64)) { + ArrayList<ItemStack> t1Cells = OreDictionary.getOres("cellFormaldehyde"); + ArrayList<ItemStack> t2Cells = OreDictionary.getOres("cellHydrogenCyanide"); + didFill = addFluid(t1Cells, aInput, FluidUtils.getWildcardFluidStack("formaldehyde", 1000)); + if (!didFill) { + didFill = addFluid(t2Cells, aInput, MISC_MATERIALS.HYDROGEN_CYANIDE.getFluid(1000)); + } + } + + return didFill; + } + + public boolean handleInventory() { + if (this.getInventory() != null && drainCell()) { + this.decrStackSize(0, 1); + if (this.getStackInSlot(1) == null) { + this.setInventorySlotContents(1, CI.emptyCells(1)); + } else { + this.getStackInSlot(1).stackSize++; + } + this.updateTileEntity(); + return true; + } else { + return false; + } + } + + public boolean addFluid(ArrayList<ItemStack> inputs, ItemStack aInput, FluidStack aFluidForInput) { + for (ItemStack a : inputs) { + if (GT_Utility.areStacksEqual(a, aInput)) { + if (mTank.getFluid() == null || mTank.getFluid() + .isFluidEqual(aFluidForInput)) { + boolean didFill = fill(ForgeDirection.UNKNOWN, aFluidForInput, true) > 0; + return didFill; + } + } else { + continue; + } + } + return false; + } + + public void updateTileEntity() { + this.getInventory().markDirty(); + this.markDirty(); + this.mNeedsUpdate = true; + } + + private final void updateTick() { + if (mNeedsUpdate) { + if (mUpdateTick == 0) { + mUpdateTick = 4; // every 4 ticks it will send an update + } else { + --mUpdateTick; + if (mUpdateTick == 0) { + markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + mNeedsUpdate = false; + } + } + } + } + + + +} diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java new file mode 100644 index 0000000000..a220997c84 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java @@ -0,0 +1,739 @@ +package gtPlusPlus.core.tileentities.machines; + +import java.util.List; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.inventories.Inventory_RoundRobinator; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockChest; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.IHopper; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Facing; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class TileEntityRoundRobinator extends TileEntity implements ISidedInventory, IHopper { + + private int tickCount = 0; + private final Inventory_RoundRobinator inventoryContents; + private String customName; + public int locationX; + public int locationY; + public int locationZ; + private int aData = 1111; + private int aTier = 1; + private int aTickRate = 100; + + public TileEntityRoundRobinator() { + this.inventoryContents = new Inventory_RoundRobinator(); + this.setTileLocation(); + } + + public boolean setTileLocation() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + this.locationX = this.xCoord; + this.locationY = this.yCoord; + this.locationZ = this.zCoord; + this.aTier = this.getWorldObj().getBlockMetadata(locationX, locationY, locationZ) + 1; + return true; + } + } + return false; + } + + //Rename to hasCircuitToConfigure + public final boolean hasInventoryContents() { + for (ItemStack i : this.aHopperInventory) { + if (i == null) { + continue; + } + else { + return true; + } + } + return false; + } + + public Inventory_RoundRobinator getInventory() { + return this.inventoryContents; + } + + public int getTier() { + return this.aTier; + } + + public int getTickRate() { + return this.aTickRate; + } + + @Override + public void updateEntity() { + try{ + // TODO + if (this.worldObj != null && !this.worldObj.isRemote){ + setTileLocation(); + aTickRate = (60-(aTier*10)); + if (this.getTier() == 1) { + // 20 s + aTickRate = 400; + } + else if (this.getTier() == 2) { + // 5 + aTickRate = 100; + } + else if (this.getTier() == 3) { + // 1 + aTickRate = 20; + } + else if (this.getTier() == 4) { + // 1/5 + aTickRate = 10; + } + else if (this.getTier() == 5) { + // 1/20 + aTickRate = 1; + } + else { + aTickRate = 999999; + } + + if (tickCount % getTickRate() == 0) { + if (hasInventoryContents()) { + Logger.WARNING("Trying to move items. "+aTickRate); + this.tryProcessItems(); + } + } + this.tickCount++; + } + } + catch (final Throwable t){ + t.printStackTrace(); + } + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + nbt.setInteger("aCurrentMode", aData); + this.writeToNBT2(nbt); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + aData = nbt.getInteger("aCurrentMode"); + this.readFromNBT2(nbt); + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + //this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + //this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int aSide) { + return new int[] {0, 1, 2, 3, 4}; + } + + @Override + public boolean canInsertItem(final int aSlot, final ItemStack aStack, final int aSide) { + return aSide < 2; + } + + @Override + public boolean canExtractItem(final int aSlot, final ItemStack aStack, final int aSide) { + return false; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.roundrobinator"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + @Override + public Packet getDescriptionPacket() { + final NBTTagCompound tag = new NBTTagCompound(); + this.writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { + final NBTTagCompound tag = pkt.func_148857_g(); + this.readFromNBT(tag); + } + + + public boolean onRightClick(byte side, EntityPlayer player, int x, int y, int z) { + if (player != null && player.getHeldItem() == null) { + if (!player.isSneaking() && !KeyboardUtils.isShiftKeyDown()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI16, player.getEntityWorld(), x, y, z); + } + else { + String InventoryContents = ItemUtils.getArrayStackNames(this.aHopperInventory); + PlayerUtils.messagePlayer(player, "Contents: "+InventoryContents+" | "+getDataString()); + } + return true; + } + else { + return false; + } + } + + public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { + try { + if (side < 2) { + // Top/Bottom + } + else { + if (toggleSide(side)) { + PlayerUtils.messagePlayer(player, "Enabling side "+side+"."); + } + else { + PlayerUtils.messagePlayer(player, "Disabling side "+side+"."); + } + PlayerUtils.messagePlayer(player, "Mode String: "+aData+""); + } + return true; + } + catch (Throwable t) { + t.printStackTrace(); + return false; + } + } + + public int getDataString() { + return aData; + } + + public boolean[] getActiveSides() { + this.markDirty(); + String s = String.valueOf(aData); + if (s == null || s.length() != 4) { + s = "1111"; + } + boolean[] aActiveSides = new boolean[4]; + for (int i=0;i<4;i++) { + char ch = s.charAt(i); + if (ch == '1') { + aActiveSides[i] = true; + } + else { + aActiveSides[i] = false; + } + } + return aActiveSides; + } + + /** + * Toggle active state of side + * @param aSide - Forge Direction / Side + * @return - True if the side is now Active, false if now disabled. + */ + public boolean toggleSide(int aSide) { + setSideActive(!getSideActive(aSide), aSide); + return getSideActive(aSide); + } + + + public void setSideActive(boolean aActive, int aSide) { + try { + if (aSide < 2) { + } + else { + if (aData < 1111) { + aData = 1111; + } + else if (aData > 2222) { + aData = 2222; + } + String s = String.valueOf(aData); + StringBuilder aDataString = new StringBuilder(s); + int aIndex = aSide - 2; + if (aActive) { + aDataString.setCharAt(aIndex, '1'); + } + else { + aDataString.setCharAt(aIndex, '2'); + } + aData = Integer.valueOf(aDataString.toString()); + this.markDirty(); + } + } + catch (Throwable t) { + t.printStackTrace(); + } + } + + public boolean getSideActive(int aSide) { + this.markDirty(); + try { + if (aSide < 2) { + return false; + } + else { + if (aData < 1111) { + aData = 1111; + } + else if (aData > 2222) { + aData = 2222; + } + String s = String.valueOf(aData); + int aIndex = aSide - 2; + char ch = s.charAt(aIndex); + if (ch == '1') { + return true; + } + else { + return false; + } + + } + } + catch (Throwable t) { + t.printStackTrace(); + return false; + } + } + + @Override + public double getXPos() { + return this.locationX; + } + + @Override + public double getYPos() { + return this.locationY; + } + + @Override + public double getZPos() { + return this.locationZ; + } + + + + + + + + + // TODO + + + + /* + * Hopper Code + */ + + + private ItemStack[] aHopperInventory = new ItemStack[5]; + + public int getSizeInventory() { + return this.aHopperInventory.length; + } + + public ItemStack getStackInSlot(int aSlot) { + return this.aHopperInventory[aSlot]; + } + + /** + * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a + * new stack. + */ + public ItemStack decrStackSize(int aSlot, int aMinimumSizeOfExistingStack) + { + if (this.aHopperInventory[aSlot] != null) + { + ItemStack itemstack; + + if (this.aHopperInventory[aSlot].stackSize <= aMinimumSizeOfExistingStack) + { + itemstack = this.aHopperInventory[aSlot]; + this.aHopperInventory[aSlot] = null; + return itemstack; + } + else + { + itemstack = this.aHopperInventory[aSlot].splitStack(aMinimumSizeOfExistingStack); + + if (this.aHopperInventory[aSlot].stackSize == 0) + { + this.aHopperInventory[aSlot] = null; + } + + return itemstack; + } + } + else + { + return null; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + public ItemStack getStackInSlotOnClosing(int aSlot) + { + if (this.aHopperInventory[aSlot] != null) + { + ItemStack itemstack = this.aHopperInventory[aSlot]; + this.aHopperInventory[aSlot] = null; + return itemstack; + } + else + { + return null; + } + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). + */ + public void setInventorySlotContents(int aSlot, ItemStack aStack) + { + this.aHopperInventory[aSlot] = aStack; + + if (aStack != null && aStack.stackSize > this.getInventoryStackLimit()) + { + aStack.stackSize = this.getInventoryStackLimit(); + } + } + + public boolean tryProcessItems() { + if (this.worldObj != null && !this.worldObj.isRemote) { + boolean didSomething = false; + if (!this.isEmpty()) { + Logger.WARNING("Has Items, Trying to push to all active directions."); + didSomething = this.tryPushItemsIntoNeighbours(); + } + if (didSomething) { + this.markDirty(); + return true; + } + } + return false; + } + + /** + * Is Empty + * @return + */ + private boolean isEmpty() { + ItemStack[] aitemstack = this.aHopperInventory; + int i = aitemstack.length; + + for (int j = 0; j < i; ++j) { + ItemStack itemstack = aitemstack[j]; + + if (itemstack != null) { + return false; + } + } + + return true; + } + + private boolean tryPushItemsIntoNeighbours() { + + boolean aDidPush = false; + + for (int u = 2; u < 6; u++) { + if (!this.getSideActive(u)) { + Logger.WARNING("Not pushing on side "+u); + continue; + } + + Logger.WARNING("Pushing on side "+u); + IInventory iinventory = this.getInventoryFromFacing(u); + + if (iinventory == null) { + Logger.WARNING("No inventory found."); + continue; + } + else { + + int i = Facing.oppositeSide[u]; + Logger.WARNING("Using Opposite direction: "+i); + + if (this.isInventoryFull(iinventory, i)) { + Logger.WARNING("Target is full, skipping."); + continue; + } + else { + Logger.WARNING("Target has space, let's move a single item."); + for (int j = 0; j < this.getSizeInventory(); ++j) { + if (this.getStackInSlot(j) != null) { + ItemStack itemstack = this.getStackInSlot(j).copy(); + ItemStack itemstack1 = setStackInNeighbour(iinventory, this.decrStackSize(j, 1), i); + if (itemstack1 == null || itemstack1.stackSize == 0) { + iinventory.markDirty(); + aDidPush = true; + continue; + } + this.setInventorySlotContents(j, itemstack); + } + } + } + } + } + + return aDidPush; + } + + private boolean isInventoryFull(IInventory aInv, int aSide) { + if (aInv instanceof ISidedInventory && aSide > -1) { + ISidedInventory isidedinventory = (ISidedInventory)aInv; + int[] aint = isidedinventory.getAccessibleSlotsFromSide(aSide); + + for (int l = 0; l < aint.length; ++l) + { + ItemStack itemstack1 = isidedinventory.getStackInSlot(aint[l]); + + if (itemstack1 == null || itemstack1.stackSize != itemstack1.getMaxStackSize()) + { + return false; + } + } + } + else { + int j = aInv.getSizeInventory(); + + for (int k = 0; k < j; ++k) + { + ItemStack itemstack = aInv.getStackInSlot(k); + + if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize()) + { + return false; + } + } + } + return true; + } + + public static ItemStack setStackInNeighbour(IInventory aNeighbour, ItemStack aStack, int aSide) { + if (aNeighbour instanceof ISidedInventory && aSide > -1) + { + ISidedInventory isidedinventory = (ISidedInventory)aNeighbour; + int[] aint = isidedinventory.getAccessibleSlotsFromSide(aSide); + + for (int l = 0; l < aint.length && aStack != null && aStack.stackSize > 0; ++l) + { + aStack = tryMoveStack(aNeighbour, aStack, aint[l], aSide); + } + } + else + { + int j = aNeighbour.getSizeInventory(); + + for (int k = 0; k < j && aStack != null && aStack.stackSize > 0; ++k) + { + aStack = tryMoveStack(aNeighbour, aStack, k, aSide); + } + } + + if (aStack != null && aStack.stackSize == 0) + { + aStack = null; + } + + return aStack; + } + + private static boolean canInsertItemIntoNeighbour(IInventory aNeighbour, ItemStack aStack, int aSlot, int aSide) { + return !aNeighbour.isItemValidForSlot(aSlot, aStack) ? false : !(aNeighbour instanceof ISidedInventory) || ((ISidedInventory)aNeighbour).canInsertItem(aSlot, aStack, aSide); + } + + private static ItemStack tryMoveStack(IInventory aNeighbour, ItemStack aStack, int aSlot, int aSide) { + ItemStack itemstack1 = aNeighbour.getStackInSlot(aSlot); + if (canInsertItemIntoNeighbour(aNeighbour, aStack, aSlot, aSide)) { + boolean aDidSomething = false; + if (itemstack1 == null) { + //Forge: BUGFIX: Again, make things respect max stack sizes. + int max = Math.min(aStack.getMaxStackSize(), aNeighbour.getInventoryStackLimit()); + if (max >= aStack.stackSize) { + aNeighbour.setInventorySlotContents(aSlot, aStack); + aStack = null; + } + else { + aNeighbour.setInventorySlotContents(aSlot, aStack.splitStack(max)); + } + aDidSomething = true; + } + else if (areItemStacksEqual(itemstack1, aStack)) { + //Forge: BUGFIX: Again, make things respect max stack sizes. + int max = Math.min(aStack.getMaxStackSize(), aNeighbour.getInventoryStackLimit()); + if (max > itemstack1.stackSize) { + int l = Math.min(aStack.stackSize, max - itemstack1.stackSize); + aStack.stackSize -= l; + itemstack1.stackSize += l; + aDidSomething = l > 0; + } + } + if (aDidSomething){ + aNeighbour.markDirty(); + } + } + return aStack; + } + + private IInventory getInventoryFromFacing(int aSide) + { + int i = aSide; + return tryFindInvetoryAtXYZ(this.getWorldObj(), (double)(this.xCoord + Facing.offsetsXForSide[i]), (double)(this.yCoord + Facing.offsetsYForSide[i]), (double)(this.zCoord + Facing.offsetsZForSide[i])); + } + + public static IInventory tryFindInvetoryAtXYZ(World aWorld, double aX, double aY, double aZ) + { + IInventory iinventory = null; + int sX = MathHelper.floor_double(aX); + int sY = MathHelper.floor_double(aY); + int sZ = MathHelper.floor_double(aZ); + TileEntity tileentity = aWorld.getTileEntity(sX, sY, sZ); + + if (tileentity != null && tileentity instanceof IInventory) + { + iinventory = (IInventory)tileentity; + + if (iinventory instanceof TileEntityChest) + { + Block block = aWorld.getBlock(sX, sY, sZ); + + if (block instanceof BlockChest) + { + iinventory = ((BlockChest)block).func_149951_m(aWorld, sX, sY, sZ); + } + } + } + + if (iinventory == null) + { + List list = aWorld.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1.0D, aY + 1.0D, aZ + 1.0D), IEntitySelector.selectInventories); + + if (list != null && list.size() > 0) + { + iinventory = (IInventory)list.get(aWorld.rand.nextInt(list.size())); + } + } + + return iinventory; + } + + private static boolean areItemStacksEqual(ItemStack aStack, ItemStack aStack2) { + return aStack.getItem() != aStack2.getItem() ? false : (aStack.getItemDamage() != aStack2.getItemDamage() ? false : (aStack.stackSize > aStack.getMaxStackSize() ? false : ItemStack.areItemStackTagsEqual(aStack, aStack2))); + } + + public void readFromNBT2(NBTTagCompound p_145839_1_) { + super.readFromNBT(p_145839_1_); + NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10); + this.aHopperInventory = new ItemStack[this.getSizeInventory()]; + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + byte b0 = nbttagcompound1.getByte("Slot"); + if (b0 >= 0 && b0 < this.aHopperInventory.length) { + this.aHopperInventory[b0] = ItemStack.loadItemStackFromNBT( + nbttagcompound1 + ); + } + } + } + + public void writeToNBT2(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + NBTTagList nbttaglist = new NBTTagList(); + for (int i = 0; i < this.aHopperInventory.length; ++i) { + if (this.aHopperInventory[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte) i); + this.aHopperInventory[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + aNBT.setTag("Items", nbttaglist); + } + + + + + + + +} diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index bb1d9064e8..c73f9ee7a4 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -2,13 +2,23 @@ package gtPlusPlus.core.util; import java.awt.Color; import java.awt.Graphics; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; -import java.util.*; +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 javax.xml.bind.DatatypeConverter; @@ -17,30 +27,15 @@ import org.apache.commons.lang3.EnumUtils; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.item.Item.ToolMaterial; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; -import net.minecraft.world.World; - import gregtech.GT_Mod; 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.TC_Aspects; import gregtech.api.enums.TC_Aspects.TC_AspectStack; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; - import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -59,6 +54,18 @@ import gtPlusPlus.plugin.villagers.tile.TileEntityGenericSpawner; import ic2.core.Ic2Items; import ic2.core.init.InternalName; import ic2.core.item.resources.ItemCell; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -73,6 +80,10 @@ public class Utils { public static final boolean isServer() { return FMLCommonHandler.instance().getEffectiveSide().isServer(); } + + public static final boolean isClient() { + return FMLCommonHandler.instance().getEffectiveSide().isClient(); + } static class ShortTimerTask extends TimerTask { @Override @@ -367,9 +378,6 @@ public class Utils { } final 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)); Logger.WARNING("Made " + temp + " - Hopefully it's not a mess."); Logger.WARNING("It will decode into " + Integer.decode(temp) + "."); diff --git a/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java b/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java index cca58467ef..3e96220995 100644 --- a/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java @@ -1,10 +1,15 @@ package gtPlusPlus.core.util.data; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; -import net.minecraft.item.ItemStack; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import net.minecraft.item.ItemStack; public class ArrayUtils { @@ -75,5 +80,13 @@ public class ArrayUtils { } } + public static String toString(Object[] aArray, String string) { + return org.apache.commons.lang3.ArrayUtils.toString(aArray, string); + } + + public static String toString(Object[] aArray) { + return org.apache.commons.lang3.ArrayUtils.toString(aArray); + } + } diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index bda722b47e..2f4db2efcc 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -13,6 +13,8 @@ import gtPlusPlus.core.util.Utils; public class MathUtils { + final static Random rand = CORE.RANDOM; + /** * Returns a psuedo-random number between min and max, inclusive. * The difference between min and max can be at most @@ -23,9 +25,6 @@ public class MathUtils { * @return Integer between min and max, inclusive. * @see java.util.Random#nextInt(int) */ - - final static Random rand = CORE.RANDOM; - public static int randInt(final int min, final int max) { // nextInt is normally exclusive of the top value, // so add 1 to make it inclusive @@ -692,6 +691,39 @@ public class MathUtils { public static int balance(int aInput, int aMin, int aMax) { return Math.max(Math.min(aInput, aMax), aMin); } + + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - A Number which will be between the bounds, or a boundary value. + */ + public static Number balance(Number aInput, Number aMin, Number aMax) { + return max(min(aInput, aMax), aMin); + } + + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - An Integer which will be between the bounds, or a boundary value. + */ + public static int balanceInt(Number aInput, Number aMin, Number aMax) { + return MathUtils.safeCast_LongToInt((long) balance(max(min(aInput, aMax), aMin), Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - A Long which will be between the bounds, or a boundary value. + */ + public static long balanceLong(Number aInput, Number aMin, Number aMax) { + return (long) balance(max(min(aInput, aMax), aMin), Long.MIN_VALUE, Long.MAX_VALUE); + } public static int getValueWithinRange(int i, int aMin, int aMax) { int aAmount = Math.max(Math.min(i, aMax), aMin); @@ -703,5 +735,37 @@ public class MathUtils { int aRemainder = (int) (aLong - (aIntMaxInLong * Integer.MAX_VALUE)); return new Pair<Integer, Integer>(aIntMaxInLong, aRemainder); } + + + + + /** + * Returns the smaller of two {@code Number}s. That is, + * the result the argument closer to the value of + * {@link Long#MIN_VALUE}. If the arguments have the same + * value, the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static Number min(Number a, Number b) { + return (a.longValue() <= b.longValue()) ? a : b; + } + + /** + * Returns the greater of two {@code Number}s. That is, the + * result is the argument closer to the value of + * {@link Long#MAX_VALUE}. If the arguments have the same value, + * the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static Number max(Number a, Number b) { + return (a.longValue() >= b.longValue()) ? a : b; + } + } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ClientUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ClientUtils.java new file mode 100644 index 0000000000..806f83d830 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/minecraft/ClientUtils.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.util.minecraft; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; + +public class ClientUtils { + + static { + if (FMLCommonHandler.instance().getSide() == Side.SERVER) { + Logger.ERROR("Something tried to access the ClientUtils class from the Server Side."); + Logger.ERROR("Soft crashing to prevent data corruption."); + CORE.crash(); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java index 09263bb639..d7b6bc0a30 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java @@ -6,15 +6,17 @@ import net.minecraft.item.ItemStack; import gregtech.api.enums.Dyes; import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.FluidGT6; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.item.base.cell.BaseItemPlasmaCell; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import net.minecraftforge.fluids.*; @@ -147,7 +149,7 @@ public class FluidUtils { public static Fluid addGtFluid(final String aName, final String aLocalized, final GT_Materials aMaterial, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount, final boolean aGenerateCell) { - Fluid g = addGTFluid(aName, "fluid.autogenerated", aLocalized, aMaterial.mRGBa, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, aGenerateCell); + Fluid g = addGTFluid(aName, "fluid.autogenerated", aLocalized, aMaterial != null ? aMaterial.mRGBa : new short[]{255, 255, 255, 0}, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, aGenerateCell); if (g != null) { if (aMaterial != null) { switch (aState) { @@ -203,7 +205,7 @@ public class FluidUtils { ItemStack temp = null; //Generate a Cell if we need to if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellPlasma"+aMaterial.getUnlocalizedName(), 1) == null){ - final Item temp2 = new BaseItemPlasmaCell(aMaterial); + new BaseItemPlasmaCell(aMaterial); temp = aMaterial.getPlasmaCell(1); } else { @@ -308,7 +310,7 @@ public class FluidUtils { rFluid.setTemperature((int) (aTemperatureK)); } if ((aFullContainer != null) && (aEmptyContainer != null) && !FluidContainerRegistry.registerFluidContainer(new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) { - MaterialGenerator.addFluidCannerRecipe(aFullContainer, container(aFullContainer, false), null, new FluidStack(rFluid, aFluidAmount)); + CORE.RA.addFluidCannerRecipe(CI.emptyCells(1), aFullContainer, new FluidStack(rFluid, aFluidAmount)); } else { //Utils.LOG_INFO("Failed creating recipes to fill/empty cells of "+aName+"."); @@ -460,21 +462,17 @@ public class FluidUtils { aGenerateCell); if (dustStack != null){ - MaterialGenerator.addFluidExtractionRecipe( - dustStack, //Input - null, //Input 2 + CORE.RA.addFluidExtractionRecipe( + dustStack, //Input 2 FluidUtils.getFluidStack(gtFluid, amountPerItem), //Fluid Output - 0, //Chance 1*20, //Duration 16 //Eu Tick ); } if (dustStack2 != null){ - MaterialGenerator.addFluidExtractionRecipe( - dustStack2, //Input - null, //Input 2 + CORE.RA.addFluidExtractionRecipe( + dustStack2, //Input 2 FluidUtils.getFluidStack(gtFluid, amountPerItem), //Fluid Output - 0, //Chance 1*20, //Duration 16 //Eu Tick ); @@ -564,12 +562,12 @@ public class FluidUtils { } public static FluidStack getWildcardFluidStack(String aFluidName, int amount) { - FluidStack aFStack1 = (FluidUtils.getFluidStack("molten"+"."+aFluidName.toLowerCase(), 1)); - FluidStack aFStack2 = (FluidUtils.getFluidStack("fluid"+"."+aFluidName.toLowerCase(), 1)); - FluidStack aFStack3 = (FluidUtils.getFluidStack(aFluidName.toLowerCase(), 1)); - FluidStack aFStack4 = (FluidUtils.getFluidStack(aFluidName, 1)); - FluidStack aFStack5 = (FluidUtils.getFluidStack("liquid_"+aFluidName.toLowerCase(), 1)); - FluidStack aFStack6 = (FluidUtils.getFluidStack("liquid"+"."+aFluidName.toLowerCase(), 1)); + FluidStack aFStack1 = (FluidUtils.getFluidStack("molten"+"."+aFluidName.toLowerCase(), amount)); + FluidStack aFStack2 = (FluidUtils.getFluidStack("fluid"+"."+aFluidName.toLowerCase(), amount)); + FluidStack aFStack3 = (FluidUtils.getFluidStack(aFluidName.toLowerCase(), amount)); + FluidStack aFStack4 = (FluidUtils.getFluidStack(aFluidName, amount)); + FluidStack aFStack5 = (FluidUtils.getFluidStack("liquid_"+aFluidName.toLowerCase(), amount)); + FluidStack aFStack6 = (FluidUtils.getFluidStack("liquid"+"."+aFluidName.toLowerCase(), amount)); if (aFStack1 != null) { return aFStack1; } @@ -590,6 +588,28 @@ public class FluidUtils { } return null; } + + public static FluidStack getWildcardFluidStack(Materials aMaterial, int amount) { + FluidStack aFStack1 = aMaterial.getFluid(amount); + FluidStack aFStack2 = aMaterial.getGas(amount); + FluidStack aFStack3 = aMaterial.getMolten(amount); + FluidStack aFStack4 = aMaterial.getSolid(amount); + if (aFStack1 != null) { + return aFStack1; + } + else if (aFStack2 != null) { + return aFStack2; + } + else if (aFStack3 != null) { + return aFStack3; + } + else if (aFStack4 != null) { + return aFStack4; + } + else { + return null; + } + } } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java index c529f60ba1..d69dd5d66e 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java @@ -306,7 +306,14 @@ public class HazmatUtils { //Logger.INFO("[Hazmat] Item was mapped for TTs"); Collections.sort(aTempTooltipData); //Logger.INFO("[Hazmat] Sorted TTs"); - return aTempTooltipData.toArray(); + + String[] mBuiltOutput = new String[aTempTooltipData.size()]; + int aIndex = 0; + for (String i : aTempTooltipData) { + mBuiltOutput[aIndex++] = i; + } + + return mBuiltOutput; } } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index adeaf8c8ad..cb490203df 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -7,6 +7,7 @@ import java.util.Map; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -30,6 +31,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; @@ -41,10 +43,11 @@ import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; @@ -57,13 +60,13 @@ public class ItemUtils { public static ItemStack getSimpleStack(final Block x) { return simpleMetaStack(Item.getItemFromBlock(x), 0, 1); } - + public static ItemStack getSimpleStack(final Block x, int i) { if (i == 0) { return getSimpleStack(x, i, 1); } - + return getSimpleStack(x, 0, i); } @@ -205,29 +208,28 @@ public class ItemUtils { } } - @SuppressWarnings("unused") - public static ItemStack simpleMetaStack(final Item item, final int meta, final int size) { - try { - if (item == null) { - return null; - } - Item em = item; - final Item em1 = item; - Logger.WARNING("Found: " + em1.getUnlocalizedName() + ":" + meta); - if (em1 != null) { - if (null == em) { - em = em1; - } - if (em != null) { - final ItemStack metaStack = new ItemStack(em, size, meta); - return metaStack; - } - } - return null; - } catch (final NullPointerException e) { - // Utils.LOG_ERROR(item.getUnlocalizedName()+" not found. [NULL]"); + public static ItemStack simpleMetaStack(ItemStack simpleStack, int meta, int size) { + return simpleMetaStack(simpleStack.getItem(), meta, size); + } + + public static ItemStack simpleMetaStack(final Item item, int meta, int size) { + if (item == null) { return null; } + if (meta < 0 || meta > Short.MAX_VALUE) { + meta = 0; + } + if (size < 0 || size > 64) { + size = 1; + } + //Logger.INFO("Found Metastack: " + item.getUnlocalizedName() + ":" + meta); + //Logger.INFO(""+ReflectionUtils.getMethodName(0)); + //Logger.INFO(""+ReflectionUtils.getMethodName(1)); + //Logger.INFO(""+ReflectionUtils.getMethodName(2)); + //Logger.INFO(""+ReflectionUtils.getMethodName(3)); + //Logger.INFO(""+ReflectionUtils.getMethodName(4)); + final ItemStack metaStack = new ItemStack(item, size, meta); + return metaStack; } public static ItemStack simpleMetaStack(final Block block, final int meta, final int size) { @@ -302,9 +304,9 @@ public class ItemUtils { else { mTemp = Utils.sanitizeString(mTemp); } - - - + + + if (oredictName.contains("rod")) { String s = "stick"+oredictName.substring(3); oredictName = s; @@ -371,7 +373,7 @@ public class ItemUtils { return returnValue.copy(); } } - + Logger.RECIPE(oredictName + " was not valid."); return null; } catch (final Throwable t) { @@ -402,7 +404,7 @@ public class ItemUtils { new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, mChemForm, Colour, "Dust"), new BaseItemDustUnique("itemDustSmall" + unlocalizedName, materialName, mChemForm, Colour, "Small"), new BaseItemDustUnique("itemDustTiny" + unlocalizedName, materialName, mChemForm, Colour, "Tiny") }; - + //Generate Shaped/Shapeless Recipes final ItemStack normalDust = ItemUtils.getSimpleStack(output[0]); @@ -456,7 +458,7 @@ public class ItemUtils { Logger.WARNING("4 Small dust from 1 Dust Recipe: "+materialName+" - Failed"); } } - + return output; } @@ -486,7 +488,7 @@ public class ItemUtils { public static Item[] generateSpecialUseDusts(final Material material, final boolean onlyLargeDust) { return generateSpecialUseDusts(material, onlyLargeDust, false); } - + public static Item[] generateSpecialUseDusts(final Material material, final boolean onlyLargeDust, final boolean disableExtraRecipes) { final String materialName = material.getLocalizedName(); final String unlocalizedName = Utils.sanitizeString(materialName); @@ -693,20 +695,22 @@ public class ItemUtils { public static String[] getArrayStackNamesAsArray(final ItemStack[] aStack) { final String[] itemNames = aStack == null ? new String[] {} : new String[aStack.length]; - Logger.INFO(""+aStack.length); - + if (aStack != null){ + Logger.INFO(""+aStack.length); + } + if (aStack == null || aStack.length < 1) { return itemNames; } - + int arpos = 0; for (final ItemStack alph : aStack) { if (alph == null) { continue; } try { - itemNames[arpos] = alph.getDisplayName(); - arpos++; + itemNames[arpos] = alph.getDisplayName(); + arpos++; } catch (Throwable t) { t.printStackTrace(); @@ -998,15 +1002,15 @@ public class ItemUtils { return true; } - - + + public static IInventory organiseInventory(IInventory aInputInventory) { ItemStack[] p = new ItemStack[aInputInventory.getSizeInventory()]; for (int o = 0; o < aInputInventory.getSizeInventory(); o++) { p[o] = aInputInventory.getStackInSlot(o); } //ItemStack[] g = organiseInventory(p); - + IInventory aTemp = aInputInventory; for (int i = 0; i < p.length; ++i) { for (int j = i + 1; j < p.length; ++j) { @@ -1016,22 +1020,22 @@ public class ItemUtils { } } } - + /* for (int o = 0; o < aInputInventory.getSizeInventory(); o++) { aTemp.setInventorySlotContents(o, g[o]); }*/ return aTemp; } - - + + public static ItemStack[] organiseInventory(ItemStack[] aInputs) { //Update Slots int aInvSize = aInputs.length; ItemStack[] newArray = new ItemStack[aInvSize]; - - + + //Try merge stacks for (int i = 0; i < aInvSize; i++) { for (int i2 = 0; i2 < aInvSize; i2++) { @@ -1045,29 +1049,29 @@ public class ItemUtils { } //Try Merge else { - + if (GT_Utility.areStacksEqual(t1[0], t1[1])) { - while ((t1[0].stackSize < 64 && t1[1].stackSize > 0)) { - t1[0].stackSize++; - t1[1].stackSize--; - if (t1[1].stackSize <= 0) { - t1[1] = null; - break; - } - if (t1[0].stackSize == 64) { - break; - } - } - newArray[i] = t1[1]; - newArray[i2] = t1[0]; + while ((t1[0].stackSize < 64 && t1[1].stackSize > 0)) { + t1[0].stackSize++; + t1[1].stackSize--; + if (t1[1].stackSize <= 0) { + t1[1] = null; + break; + } + if (t1[0].stackSize == 64) { + break; + } + } + newArray[i] = t1[1]; + newArray[i2] = t1[0]; } } } } } - + ItemStack[] newArray2 = new ItemStack[aInvSize]; - + //Move nulls to end int count2 = 0; for (int i = 0; i < aInvSize; i++) @@ -1075,10 +1079,18 @@ public class ItemUtils { newArray2[count2++] = newArray[i]; while (count2 < aInvSize) newArray2[count2++] = null; - + return newArray2; + + } + public static String getFluidName(FluidStack aFluid) { + return aFluid != null ? aFluid.getFluid().getLocalizedName(aFluid) : "NULL"; + } + + public static String getFluidName(Fluid aFluid) { + return aFluid != null ? aFluid.getLocalizedName() : "NULL"; } public static String getItemName(ItemStack aStack) { @@ -1089,7 +1101,7 @@ public class ItemUtils { try { aDisplay = ("" + StatCollector .translateToLocal(aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) - .trim(); + .trim(); if (aStack.hasTagCompound()) { if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); @@ -1117,7 +1129,7 @@ public class ItemUtils { String aDisplay = null; try { aDisplay = (aStack.getUnlocalizedName()).trim(); - + } catch (Throwable t) { aDisplay = aStack.getItem().getUnlocalizedName(); } @@ -1126,7 +1138,7 @@ public class ItemUtils { } return aDisplay; } - + public static boolean isItemGregtechTool(ItemStack aStack) { if (aStack == null) { return false; @@ -1139,49 +1151,49 @@ public class ItemUtils { } return false; } - + public static boolean isToolWrench(ItemStack aWrench) { if (isItemGregtechTool(aWrench) && (aWrench.getItemDamage() == 16 || aWrench.getItemDamage() == 120 || aWrench.getItemDamage() == 122 || aWrench.getItemDamage() == 124 || aWrench.getItemDamage() == 7734)) { return true; } return false; } - + public static boolean isToolMallet(ItemStack aMallet) { if (isItemGregtechTool(aMallet) && (aMallet.getItemDamage() == 14)) { return true; } return false; } - + public static boolean isToolScrewdriver(ItemStack aScrewdriver) { if (isItemGregtechTool(aScrewdriver) && (aScrewdriver.getItemDamage() == 22 || aScrewdriver.getItemDamage() == 150)) { return true; } return false; } - + public static boolean isToolCrowbar(ItemStack aCrowbar) { if (isItemGregtechTool(aCrowbar) && (aCrowbar.getItemDamage() == 20)) { return true; } return false; } - + public static boolean isToolWirecutters(ItemStack aWirecutters) { if (isItemGregtechTool(aWirecutters) && (aWirecutters.getItemDamage() == 26)) { return true; } return false; } - + public static boolean isToolHammer(ItemStack aHammer) { if (isItemGregtechTool(aHammer) && (aHammer.getItemDamage() == 12 || aHammer.getItemDamage() == 7734)) { return true; } return false; } - + public static boolean isToolSolderingIron(ItemStack aSoldering) { if (isItemGregtechTool(aSoldering) && (aSoldering.getItemDamage() == 160)) { return true; @@ -1210,14 +1222,38 @@ public class ItemUtils { public static ItemStack getEnchantedBook(Enchantment aEnch, int aLevel) { return enchantItem(new ItemStack(Items.enchanted_book), aEnch, aLevel); } - + public static ItemStack enchantItem(ItemStack aStack, Enchantment aEnch, int aLevel) { Items.enchanted_book.addEnchantment(aStack, new EnchantmentData(aEnch, aLevel)); return aStack; } public static boolean doesOreDictHaveEntryFor(String string) { - return OreDictionary.doesOreNameExist(string); + return OreDictUtils.containsValidEntries(string); + } + + public static void hideItemFromNEI(ItemStack aItemToHide) { + codechicken.nei.api.API.hideItem(aItemToHide); + } + + public static ItemStack getNullStack() { + return GT_Values.NI; + } + + + public static ItemStack depleteStack(ItemStack aStack) { + return depleteStack(aStack, 1); + } + + public static ItemStack depleteStack(ItemStack aStack, int aAmount) { + final int cap = aStack.stackSize; + if (cap > 1 && cap > aAmount) { + aStack.stackSize = (MathUtils.balance((aStack.stackSize - 1), 0, 64)); + if (aStack.stackSize > 0) { + return aStack; + } + } + return getNullStack(); } } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java new file mode 100644 index 0000000000..ea161e4adb --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java @@ -0,0 +1,56 @@ +package gtPlusPlus.core.util.minecraft; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class LangUtils { + + + public static boolean rewriteEntryForLanguageRegistry(String aKey, String aNewValue){ + return rewriteEntryForLanguageRegistry("en_US", aKey, aNewValue); + } + + @SuppressWarnings("unchecked") + public static boolean rewriteEntryForLanguageRegistry(String aLang, String aKey, String aNewValue){ + LanguageRegistry aInstance = LanguageRegistry.instance(); + Field aModLanguageData = ReflectionUtils.getField(LanguageRegistry.class, "modLanguageData"); + if (aModLanguageData != null){ + Map<String,Properties> aProps = new HashMap<String, Properties>(); + Object aInstanceProps; + try { + aInstanceProps = aModLanguageData.get(aInstance); + if (aInstanceProps != null){ + aProps = (Map<String, Properties>) aInstanceProps; + Properties aLangProps = aProps.get(aLang); + if (aLangProps != null){ + if (aLangProps.containsKey(aKey)) { + aLangProps.remove(aKey); + aLangProps.put(aKey, aNewValue); + } + else { + aLangProps.put(aKey, aNewValue); + } + aProps.remove(aLang); + aProps.put(aLang, aLangProps); + ReflectionUtils.setField(aInstance, aModLanguageData, aProps); + } + } + } + catch (IllegalArgumentException | IllegalAccessException e) { + + } + } + return false; + } + + public static String trans(String aNr, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aNr, aEnglish, false); + } + +} diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index 364430b07d..9c623bb9be 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -25,6 +25,7 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.data.EnumUtils; import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -207,9 +208,9 @@ public class MaterialUtils { return true; } - public static int getTierOfMaterial(final int aMeltingPoint){ + public static int getTierOfMaterial(final double aMeltingPoint){ - return aMeltingPoint < 1000 ? 0 : (Math.round(aMeltingPoint/1000)); + return aMeltingPoint < 1000 ? 0 : (MathUtils.roundToClosestInt(aMeltingPoint/1000f)); /*if ((aMeltingPoint >= 0) && (aMeltingPoint <= 1000)){ diff --git a/src/Java/gtPlusPlus/core/util/minecraft/OreDictUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/OreDictUtils.java new file mode 100644 index 0000000000..324d39b863 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/minecraft/OreDictUtils.java @@ -0,0 +1,25 @@ +package gtPlusPlus.core.util.minecraft; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class OreDictUtils { + + public static boolean containsValidEntries(String aOreName) { + boolean a = OreDictionary.doesOreNameExist(aOreName); + List<ItemStack> b = OreDictionary.getOres(aOreName, false); + + if (!a) { + return false; + } + else { + if (b == null || b.isEmpty()) { + return false; + } + } + return true; + } + +} diff --git a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java index aeeb4ae5be..2ae2a9f1de 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java @@ -1,16 +1,30 @@ package gtPlusPlus.core.util.minecraft.gregtech; +import static gtPlusPlus.core.lib.CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK; + import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import org.apache.commons.lang3.ArrayUtils; + import gregtech.GT_Mod; +import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; import gregtech.common.GT_Proxy; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.base.cell.BaseItemCell; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.ItemStack; import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.fluids.FluidStack; public class PollutionUtils { @@ -22,13 +36,19 @@ public class PollutionUtils { private static Method mGetPollution; private static Method mGetPollution2; + public static AutoMap<FluidStack> mPollutionFluidStacks = new AutoMap<FluidStack>(); + static { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { + if (MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { mIsPollutionEnabled = mPollution(); } else { mIsPollutionEnabled = false; } } + + public static boolean isPollutionEnabled() { + return mIsPollutionEnabled; + } public static boolean mPollution() { try { @@ -119,8 +139,57 @@ public class PollutionUtils { return addPollution(aChunk, -pollutionValue); } + public static boolean nullifyPollution(IGregTechTileEntity te) { + if (te == null) { + return false; + } + return nullifyPollution((IHasWorldObjectAndCoords) te); + } + + public static boolean nullifyPollution(IHasWorldObjectAndCoords aTileOfSomeSort) { + if (aTileOfSomeSort == null) { + return false; + } + IHasWorldObjectAndCoords j = (IHasWorldObjectAndCoords) aTileOfSomeSort; + Chunk c = j.getWorld().getChunkFromBlockCoords(j.getXCoord(), j.getZCoord()); + return nullifyPollution(c); + } + + public static boolean nullifyPollution(Chunk aChunk) { + try { + if (aChunk == null) { + return false; + } + long getCurrentPollution = getPollution(aChunk); + if (getCurrentPollution <= 0) { + return false; + } + else { + if (mAddPollution2 != null) { + mAddPollution2.invoke(null, aChunk, -getCurrentPollution); + return true; + } + else { + Class<?> GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); + if (GT_Pollution != null) { + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "addPollution", Chunk.class, int.class); + if (addPollution != null) { + mAddPollution2 = addPollution; + mAddPollution2.invoke(null, aChunk, 0); + return true; + } + } + } + } + + } catch (SecurityException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + } + return false; + } + public static int getPollution(IGregTechTileEntity te) { - if (mIsPollutionEnabled) + if (MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) try { if (te == null) { return 0; @@ -143,7 +212,7 @@ public class PollutionUtils { } public static int getPollution(Chunk te) { - if (mIsPollutionEnabled) + if (MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) try { if (te == null) { return 0; @@ -164,5 +233,73 @@ public class PollutionUtils { } return 0; } + + public static boolean setPollutionFluids() { + if (mPollutionFluidStacks.isEmpty()) { + FluidStack CD, CM, SD; + CD = FluidUtils.getFluidStack("carbondioxide", 1000); + CM = FluidUtils.getFluidStack("carbonmonoxide", 1000); + SD = FluidUtils.getFluidStack("sulfurdioxide", 1000); + if (PollutionUtils.mPollutionFluidStacks.size() == 0) { + if (CD != null) { + Logger.INFO("[PollutionCompat] Found carbon dioxide fluid, registering it."); + PollutionUtils.mPollutionFluidStacks.put(CD); + MISC_MATERIALS.CARBON_DIOXIDE.registerComponentForMaterial(CD); + ItemStack cellCD = ItemUtils.getItemStackOfAmountFromOreDict("cellCarbonDioxide", 1); + if (ItemUtils.checkForInvalidItems(cellCD)) { + Logger.INFO("[PollutionCompat] Found carbon dioxide cell, registering component."); + MISC_MATERIALS.CARBON_DIOXIDE.registerComponentForMaterial(OrePrefixes.cell, cellCD); + } + else { + Logger.INFO("[PollutionCompat] Did not find carbon dioxide cell, registering new component."); + new BaseItemCell(MISC_MATERIALS.CARBON_DIOXIDE); + } + } + else { + MaterialGenerator.generate(MISC_MATERIALS.CARBON_DIOXIDE, false, false); + } + + if (CM != null) { + Logger.INFO("[PollutionCompat] Found carbon monoxide fluid, registering it."); + PollutionUtils.mPollutionFluidStacks.put(CM); + MISC_MATERIALS.CARBON_MONOXIDE.registerComponentForMaterial(CM); + ItemStack cellCD = ItemUtils.getItemStackOfAmountFromOreDict("cellCarbonMonoxide", 1); + if (ItemUtils.checkForInvalidItems(cellCD)) { + Logger.INFO("[PollutionCompat] Found carbon monoxide cell, registering component."); + MISC_MATERIALS.CARBON_MONOXIDE.registerComponentForMaterial(OrePrefixes.cell, cellCD); + } + else { + Logger.INFO("[PollutionCompat] Did not find carbon monoxide cell, registering new component."); + new BaseItemCell(MISC_MATERIALS.CARBON_MONOXIDE); + } + } + else { + MaterialGenerator.generate(MISC_MATERIALS.CARBON_MONOXIDE, false, false); + } + + if (SD != null) { + Logger.INFO("[PollutionCompat] Found sulfur dioxide fluid, registering it."); + PollutionUtils.mPollutionFluidStacks.put(SD); + } + } + if (PollutionUtils.mPollutionFluidStacks.size() > 0) { + return true; + } + return false; + } + else { + if (mPollutionFluidStacks.size() != 3) { + Logger.INFO("Unable to detect all 3 pollution fluids. Found: "); + Logger.INFO(ArrayUtils.toString(mPollutionFluidStacks)); + return false; + } + else { + return true; + } + } + + + + } } diff --git a/src/Java/gtPlusPlus/core/util/reflect/OreDictUtils.java b/src/Java/gtPlusPlus/core/util/reflect/OreDictUtils.java deleted file mode 100644 index 6d34733545..0000000000 --- a/src/Java/gtPlusPlus/core/util/reflect/OreDictUtils.java +++ /dev/null @@ -1,7 +0,0 @@ -package gtPlusPlus.core.util.reflect; - -public class OreDictUtils { - - - -} diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 2371753fe6..135f98dd17 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -25,10 +25,25 @@ import gtPlusPlus.core.util.data.StringUtils; public class ReflectionUtils { - public static Map<String, Class> mCachedClasses = new LinkedHashMap<String, Class>(); + public static Map<String, Class<?>> mCachedClasses = new LinkedHashMap<String, Class<?>>(); public static Map<String, CachedMethod> mCachedMethods = new LinkedHashMap<String, CachedMethod>(); public static Map<String, CachedField> mCachedFields = new LinkedHashMap<String, CachedField>(); + public static Map<String, CachedConstructor> mCachedConstructors = new LinkedHashMap<String, CachedConstructor>(); + private static class CachedConstructor { + + private final Constructor<?> METHOD; + + public CachedConstructor(Constructor<?> aCons) { + METHOD = aCons; + } + + public Constructor<?> get() { + return METHOD; + } + + } + private static class CachedMethod { private final boolean STATIC; @@ -69,11 +84,11 @@ public class ReflectionUtils { } - private static boolean cacheClass(Class aClass) { + private static boolean cacheClass(Class<?> aClass) { if (aClass == null) { return false; } - Class y = mCachedClasses.get(aClass.getCanonicalName()); + Class<?> y = mCachedClasses.get(aClass.getCanonicalName()); if (y == null) { mCachedClasses.put(aClass.getCanonicalName(), aClass); return true; @@ -81,7 +96,7 @@ public class ReflectionUtils { return false; } - private static boolean cacheMethod(Class aClass, Method aMethod) { + private static boolean cacheMethod(Class<?> aClass, Method aMethod) { if (aMethod == null) { return false; } @@ -94,7 +109,7 @@ public class ReflectionUtils { return false; } - private static boolean cacheField(Class aClass, Field aField) { + private static boolean cacheField(Class<?> aClass, Field aField) { if (aField == null) { return false; } @@ -107,17 +122,60 @@ public class ReflectionUtils { return false; } + private static boolean cacheConstructor(Class<?> aClass, Constructor<?> aConstructor) { + if (aConstructor == null) { + return false; + } + CachedConstructor y = mCachedConstructors.get(aClass.getName()+"."+ArrayUtils.toString(aConstructor.getParameterTypes())); + if (y == null) { + mCachedConstructors.put(aClass.getName()+"."+ArrayUtils.toString(aConstructor.getParameterTypes()), new CachedConstructor(aConstructor)); + return true; + } + return false; + } + + + /** + * Returns a cached {@link Constructor} object. + * @param aClass - Class containing the Constructor. + * @param aTypes - Varags Class Types for objects constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Constructor<?> getConstructor(Class<?> aClass, Class<?>... aTypes) { + if (aClass == null || aTypes == null) { + return null; + } + + String aMethodKey = ArrayUtils.toString(aTypes); + //Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); + CachedConstructor y = mCachedConstructors.get(aClass.getName() + "." + aMethodKey); + if (y == null) { + Constructor<?> u = getConstructor_Internal(aClass, aTypes); + if (u != null) { + Logger.REFLECTION("Caching Constructor: "+aClass.getName() + "." + aMethodKey); + cacheConstructor(aClass, u); + return u; + } else { + return null; + } + } else { + return y.get(); + } + } + + + /** * Returns a cached {@link Class} object. * @param aClassCanonicalName - The canonical name of the underlying class. * @return - Valid, {@link Class} object, or {@link null}. */ - public static Class getClass(String aClassCanonicalName) { + public static Class<?> getClass(String aClassCanonicalName) { if (aClassCanonicalName == null || aClassCanonicalName.length() <= 0) { return null; } - Class y = mCachedClasses.get(aClassCanonicalName); + Class<?> y = mCachedClasses.get(aClassCanonicalName); if (y == null) { y = getClass_Internal(aClassCanonicalName); if (y != null) { @@ -149,7 +207,7 @@ public class ReflectionUtils { * @param aTypes - Varags Class Types for {@link Method}'s constructor. * @return - Valid, non-final, {@link Method} object, or {@link null}. */ - public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { + public static Method getMethod(Class<?> aClass, String aMethodName, Class<?>... aTypes) { if (aClass == null || aMethodName == null || aMethodName.length() <= 0) { return null; } @@ -169,6 +227,17 @@ public class ReflectionUtils { return y.get(); } } + + public static boolean isStaticMethod(Class<?> aClass, String aMethodName, Class<?>... aTypes) { + return isStaticMethod(ReflectionUtils.getMethod(aClass, aMethodName, aTypes)); + } + + public static boolean isStaticMethod(Method aMethod) { + if (aMethod != null && Modifier.isStatic(aMethod.getModifiers())) { + return true; + } + return false; + } @@ -178,7 +247,7 @@ public class ReflectionUtils { * @param aFieldName - Field name in {@link String} form. * @return - Valid, non-final, {@link Field} object, or {@link null}. */ - public static Field getField(final Class aClass, final String aFieldName) { + public static Field getField(final Class<?> aClass, final String aFieldName) { if (aClass == null || aFieldName == null || aFieldName.length() <= 0) { return null; } @@ -293,7 +362,7 @@ public class ReflectionUtils { return loaded > 0; } - + public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { Class<?> clazz = object.getClass(); @@ -313,8 +382,8 @@ public class ReflectionUtils { } } return false; - - + + } public static boolean setField(final Object object, final Field field, final Object fieldValue) { @@ -381,7 +450,6 @@ public class ReflectionUtils { public static boolean invoke(Object objectInstance, String methodName, Class[] parameters, Object[] values){ if (objectInstance == null || methodName == null || parameters == null || values == null){ - //Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: "+objectInstance.getClass().getName()); return false; } Class<?> mLocalClass = (objectInstance instanceof Class ? (Class<?>) objectInstance : objectInstance.getClass()); @@ -389,6 +457,28 @@ public class ReflectionUtils { try { Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); if (mInvokingMethod != null){ + return invoke(objectInstance, mInvokingMethod, values); + } + } + catch (NoSuchMethodException | SecurityException | IllegalArgumentException e) { + Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName()); + } + + Logger.REFLECTION("Invoke failed or did something wrong."); + return false; + } + + public static boolean invoke(Object objectInstance, Method method, Object[] values){ + if (method == null || values == null || (!ReflectionUtils.isStaticMethod(method) && objectInstance == null)){ + //Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: "+objectInstance.getClass().getName()); + return false; + } + String methodName = method.getName(); + String classname = objectInstance != null ? objectInstance.getClass().getCanonicalName() : method.getDeclaringClass().getCanonicalName(); + Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+classname+"."); + try { + Method mInvokingMethod = method; + if (mInvokingMethod != null){ Logger.REFLECTION(methodName+" was not null."); if ((boolean) mInvokingMethod.invoke(objectInstance, values)){ Logger.REFLECTION("Successfully invoked "+methodName+"."); @@ -398,14 +488,10 @@ public class ReflectionUtils { Logger.REFLECTION("Invocation failed for "+methodName+"."); } } - else { - Logger.REFLECTION(methodName+" is null."); - } } - catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName()); - } - + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+classname); + } Logger.REFLECTION("Invoke failed or did something wrong."); return false; } @@ -484,11 +570,11 @@ public class ReflectionUtils { * Internal Magic that probably should not get exposed. */ - - - - - + + + + + @@ -662,7 +748,7 @@ public class ReflectionUtils { return m; } - private static Method getMethod_Internal(Class aClass, String aMethodName, Class... aTypes) { + private static Method getMethod_Internal(Class<?> aClass, String aMethodName, Class<?>... aTypes) { Method m = null; try { Logger.REFLECTION("Method: Internal Lookup: "+aMethodName); @@ -688,6 +774,55 @@ public class ReflectionUtils { } return m; } + + private static Constructor<?> getConstructor_Internal(Class<?> aClass, Class<?>... aTypes) { + Constructor<?> c = null; + try { + Logger.REFLECTION("Constructor: Internal Lookup: "+aClass.getName()); + c = aClass.getDeclaredConstructor(aTypes); + if (c != null) { + c.setAccessible(true); + int modifiers = c.getModifiers(); + Field modifierField = c.getClass().getDeclaredField("modifiers"); + modifiers = modifiers & ~Modifier.FINAL; + modifierField.setAccessible(true); + modifierField.setInt(c, modifiers); + } + } + catch (Throwable t) { + Logger.REFLECTION("Constructor: Internal Lookup Failed: "+aClass.getName()); + try { + c = getConstructorRecursively(aClass, aTypes); + } catch (Exception e) { + Logger.REFLECTION("Unable to find method '"+aClass.getName()+"'"); + e.printStackTrace(); + dumpClassInfo(aClass); + } + } + return c; + } + + private static Constructor<?> getConstructorRecursively(Class<?> aClass, Class<?>... aTypes) throws Exception { + try { + Logger.REFLECTION("Constructor: Recursion Lookup: "+aClass.getName()); + Constructor<?> c = aClass.getConstructor(aTypes); + if (c != null) { + c.setAccessible(true); + int modifiers = c.getModifiers(); + Field modifierField = c.getClass().getDeclaredField("modifiers"); + modifiers = modifiers & ~Modifier.FINAL; + modifierField.setAccessible(true); + modifierField.setInt(c, modifiers); + } + return c; + } catch (final NoSuchMethodException | IllegalArgumentException | IllegalAccessException e) { + final Class<?> superClass = aClass.getSuperclass(); + if (superClass == null || superClass == Object.class) { + throw e; + } + return getConstructor_Internal(superClass, aTypes); + } + } private static Method getMethodRecursively(final Class<?> clazz, final String aMethodName) throws NoSuchMethodException { try { @@ -704,7 +839,7 @@ public class ReflectionUtils { } } - private static void dumpClassInfo(Class aClass) { + private static void dumpClassInfo(Class<?> aClass) { Logger.INFO("We ran into an error processing reflection in "+aClass.getName()+", dumping all data for debugging."); // Get the methods Method[] methods = aClass.getDeclaredMethods(); @@ -720,7 +855,7 @@ public class ReflectionUtils { System.out.println(f.getName()); } Logger.INFO("Dumping all Constructors."); - for (Constructor c : consts) { + for (Constructor<?> c : consts) { System.out.println(c.getName()+" | "+c.getParameterCount()+" | "+StringUtils.getDataStringFromArray(c.getParameterTypes())); } } @@ -767,15 +902,52 @@ public class ReflectionUtils { } private static Class<?> getClass_Internal(String string) { + Class<?> aClass = null; if (ReflectionUtils.doesClassExist(string)) { try { - return Class.forName(string); + aClass = Class.forName(string); } catch (ClassNotFoundException e) { - return getNonPublicClass(string); + aClass = getNonPublicClass(string); } } - return null; + + if (aClass == null) { + String aClassName = ""; + Logger.REFLECTION("Splitting "+string+" to try look for hidden classes."); + String[] aData = string.split("\\."); + Logger.REFLECTION("Obtained "+aData.length+" pieces."); + for (int i=0;i<(aData.length-1);i++) { + aClassName += (i > 0) ? "."+aData[i] : ""+aData[i]; + Logger.REFLECTION("Building: "+aClassName); + } + Logger.REFLECTION("Trying to search '"+aClassName+"' for inner classes."); + Class<?> clazz = ReflectionUtils.getClass(aClassName); + + Class[] y = clazz.getDeclaredClasses(); + if (y == null || y.length <= 0) { + Logger.REFLECTION("No hidden inner classes found."); + return null; + } + else { + boolean found = false; + for (Class<?> h : y) { + Logger.REFLECTION("Found hidden inner class: "+h.getCanonicalName()); + if (h.getSimpleName().toLowerCase().equals(aData[aData.length-1].toLowerCase())) { + Logger.REFLECTION("Found correct class. ["+aData[aData.length-1]+"] Caching at correct location: "+string); + Logger.REFLECTION("Found at location: "+h.getCanonicalName()); + ReflectionUtils.mCachedClasses.put(string, h); + aClass = h; + found = true; + break; + } + } + if (!found) { + return null; + } + } + } + return aClass; } /** @@ -800,4 +972,30 @@ public class ReflectionUtils { } + public static boolean doesFieldExist(String clazz, String string) { + return doesFieldExist(ReflectionUtils.getClass(clazz), string); + } + + public static boolean doesFieldExist(Class<?> clazz, String string) { + if (clazz != null) { + if (ReflectionUtils.getField(clazz, string) != null) { + return true; + } + } + return false; + } + + public static Object getFieldValue(Field field) { + return getFieldValue(field, null); + } + + public static Object getFieldValue(Field field, Object instance) { + try { + return field.get(instance); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + return null; + } + + } |