diff options
author | Raven Szewczyk <git@eigenraven.me> | 2024-05-24 19:50:35 +0100 |
---|---|---|
committer | Raven Szewczyk <git@eigenraven.me> | 2024-05-24 19:50:35 +0100 |
commit | 6d1b2216464d4dad449ac6fcfec476832224a55e (patch) | |
tree | 526a0c15f7056313c80e6c0386e025e9b3f61781 /src/main/java/gtPlusPlus/core | |
parent | b5d35f40afa606ed1b07061dad82e0521a59c186 (diff) | |
download | GT5-Unofficial-6d1b2216464d4dad449ac6fcfec476832224a55e.tar.gz GT5-Unofficial-6d1b2216464d4dad449ac6fcfec476832224a55e.tar.bz2 GT5-Unofficial-6d1b2216464d4dad449ac6fcfec476832224a55e.zip |
Merge addon sources
Diffstat (limited to 'src/main/java/gtPlusPlus/core')
274 files changed, 57183 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/core/block/ModBlocks.java b/src/main/java/gtPlusPlus/core/block/ModBlocks.java new file mode 100644 index 0000000000..634a073b02 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/ModBlocks.java @@ -0,0 +1,104 @@ +package gtPlusPlus.core.block; + +import net.minecraft.block.Block; +import net.minecraftforge.fluids.Fluid; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.general.BlockCompressedObsidian; +import gtPlusPlus.core.block.general.FluidTankInfinite; +import gtPlusPlus.core.block.general.HellFire; +import gtPlusPlus.core.block.general.LightGlass; +import gtPlusPlus.core.block.general.MiningExplosives; +import gtPlusPlus.core.block.general.antigrief.BlockWitherProof; +import gtPlusPlus.core.block.machine.CircuitProgrammer; +import gtPlusPlus.core.block.machine.DecayablesChest; +import gtPlusPlus.core.block.machine.FishTrap; +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_SuperJukebox; +import gtPlusPlus.core.block.machine.VolumetricFlaskSetter; +import gtPlusPlus.core.fluids.FluidRegistryHandler; + +public final class ModBlocks { + + public static Block blockCircuitProgrammer; + public static Block blockVolumetricFlaskSetter; + + public static Block blockFishTrap; + public static Block blockDecayablesChest; + + public static Block blockCasingsMisc; + public static Block blockCasings2Misc; + public static Block blockCasings3Misc; + public static Block blockCasings4Misc; + public static Block blockCasings5Misc; + public static Block blockCasings6Misc; + public static Block blockCasingsTieredGTPP; + public static Block blockSpecialMultiCasings; + public static Block blockSpecialMultiCasings2; + public static Block blockCustomMachineCasings; + public static Block blockCustomPipeGearCasings; + + public static Block MatterFabricatorEffectBlock; + + public static Fluid fluidSludge = new Fluid("fluid.sludge"); + public static Block blockFluidSludge; + + public static Block blockMiningExplosive; + + public static Block blockHellfire; + public static Block blockInfiniteFLuidTank; + public static Block blockProjectTable; + public static Block blockWitherGuard; + public static Block blockCompressedObsidian; + + public static Block blockPlayerDoorWooden; + public static Block blockPlayerDoorIron; + public static Block blockPlayerDoorCustom_Glass; + public static Block blockPlayerDoorCustom_Ice; + public static Block blockPlayerDoorCustom_Cactus; + + public static Block blockCustomJukebox; + + public static Block blockPooCollector; + + public static Block blockPestKiller; + + public static void init() { + Logger.INFO("Initializing Blocks."); + + registerBlocks(); + } + + public static void registerBlocks() { + + Logger.INFO("Registering Blocks."); + MatterFabricatorEffectBlock = new LightGlass(false); + + // Fluids + FluidRegistryHandler.registerFluids(); + + // Workbench + blockFishTrap = new FishTrap(); + blockInfiniteFLuidTank = new FluidTankInfinite(); + blockMiningExplosive = new MiningExplosives(); + blockHellfire = new HellFire(); + blockProjectTable = new Machine_ProjectTable(); + blockWitherGuard = new BlockWitherProof(); + blockCompressedObsidian = new BlockCompressedObsidian(); + + blockCircuitProgrammer = new CircuitProgrammer(); + + blockDecayablesChest = new DecayablesChest(); + + blockCustomJukebox = new Machine_SuperJukebox(); + + blockPooCollector = new Machine_PooCollector(); + + blockPestKiller = new Machine_PestKiller(); + + blockVolumetricFlaskSetter = new VolumetricFlaskSetter(); + + } +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BasicBlock.java b/src/main/java/gtPlusPlus/core/block/base/BasicBlock.java new file mode 100644 index 0000000000..d39c194dfd --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BasicBlock.java @@ -0,0 +1,70 @@ +package gtPlusPlus.core.block.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; + +public class BasicBlock extends BlockContainer { + + public BasicBlock(BlockTypes type, final String unlocalizedName, final Material material, final int harvestLevel) { + super(material); + this.setBlockName(Utils.sanitizeString(unlocalizedName)); + + if (type != BlockTypes.ORE && !unlocalizedName.toLowerCase() + .contains("ore")) { + this.setBlockTextureName(GTPlusPlus.ID + ":" + unlocalizedName); + } + + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHardness(1.0f * harvestLevel); + this.setHarvestLevel("pickaxe", harvestLevel); + this.setStepSound(soundTypeMetal); + } + + public static enum BlockTypes { + + STANDARD("blockBlock", "pickaxe", soundTypeMetal), + FRAME("blockFrameGt", "wrench", soundTypeMetal), + ORE("blockStone", "pickaxe", soundTypeStone); + + private final String TEXTURE_NAME; + private final String HARVEST_TOOL; + private final SoundType soundOfBlock; + + BlockTypes(final String textureName, final String harvestTool, final SoundType blockSound) { + this.TEXTURE_NAME = textureName; + this.HARVEST_TOOL = harvestTool; + this.soundOfBlock = blockSound; + } + + public String getTexture() { + return this.TEXTURE_NAME; + } + + public String getHarvestTool() { + return this.HARVEST_TOOL; + } + + } + + @Override + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { + return null; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java b/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java new file mode 100644 index 0000000000..c39565ea41 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java @@ -0,0 +1,322 @@ +package gtPlusPlus.core.block.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +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 net.minecraftforge.common.util.ForgeDirection; + +import appeng.core.CreativeTab; +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; + +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? + */ + public final boolean hasMeta() { + return getMetaCount() > 0; + } + + /** + * The amount of meta this block has. + */ + 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(); + + /** + * 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}(). + */ + @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. + */ + protected abstract String getTileEntityName(); + + /** + * The String used for texture pathing. + * + * @return Sanitized {@link String}, containing no spaces or illegal characters. + */ + private 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. + */ + public CubicObject<String>[] getCustomTextureDirectoryObject() { + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public final IIcon getIcon(final int ordinalSide, final int aMeta) { + return mSidedTextureArray.get(aMeta) + .get(ForgeDirection.getOrientation(ordinalSide)) + .getIcon(); + } + + @Override + public IIcon getIcon(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + return super.getIcon(aWorld, aX, aY, aZ, ordinalSide); + } + + @SideOnly(Side.CLIENT) + private 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<>(); + mSidedTexturePathArray = new AutoMap<>(); + + // 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 = GTPlusPlus.ID + ":"; + // Default Path Name, this will make us look in the subdirectory 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<>( + 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<>(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) {} + + @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) { + return aWorld.getBlockMetadata(aX, aY, aZ); + } + + @Override + public Item getItemDropped(int meta, Random rand, int p_149650_3_) { + return ItemUtils.getSimpleStack(this, 1) + .getItem(); + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList<ItemStack> drops = new ArrayList<>(); + drops.add(ItemUtils.simpleMetaStack(this, metadata, 1)); + return drops; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseFluid.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseFluid.java new file mode 100644 index 0000000000..6772b71262 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseFluid.java @@ -0,0 +1,102 @@ +package gtPlusPlus.core.block.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.Random; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Mods; +import gtPlusPlus.core.client.renderer.particle.EntityDropParticleFX; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.util.Utils; + +public class BlockBaseFluid extends BlockFluidClassic { + + private final String name; + private final IIcon[] textureArray = new IIcon[6]; + + protected float particleRed = 1.0F; + protected float particleGreen = 1.0F; + protected float particleBlue = 1.0F; + + public BlockBaseFluid(String materialName, Fluid fluid, Material material) { + super(fluid, material); + this.setLightOpacity(2); + this.name = Utils.sanitizeString(materialName); + this.setBlockName("fluid" + this.name); + this.setCreativeTab(AddToCreativeTab.tabBlock); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "fluid" + this.name); + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType arg0, IBlockAccess arg1, int arg2, int arg3, int arg4) { + return false; + } + + public boolean preInit() { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int meta) { + return ordinalSide <= 1 ? this.textureArray[0] : this.textureArray[1]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister icon) { + this.textureArray[0] = icon.registerIcon(GTPlusPlus.ID + ":" + "fluid/" + "Fluid_" + this.name + "_Still"); + this.textureArray[1] = icon.registerIcon(GTPlusPlus.ID + ":" + "fluid/" + "Fluid_" + this.name + "_Flow"); + } + + @Override + @Optional.Method(modid = Mods.Names.C_O_F_H_CORE) + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World arg0, int arg1, int arg2, int arg3, Random arg4) { + super.randomDisplayTick(arg0, arg1, arg2, arg3, arg4); + double arg5 = arg1 + arg4.nextFloat(); + double arg7 = arg2 - 1.05D; + double arg9 = arg3 + arg4.nextFloat(); + if (super.density < 0) { + arg7 = arg2 + 2.1D; + } + + if (arg4.nextInt(20) == 0 + && arg0.isSideSolid( + arg1, + arg2 + super.densityDir, + arg3, + super.densityDir == -1 ? ForgeDirection.UP : ForgeDirection.DOWN) + && !arg0.getBlock(arg1, arg2 + 2 * super.densityDir, arg3) + .getMaterial() + .blocksMovement()) { + EntityDropParticleFX arg11 = new EntityDropParticleFX( + arg0, + arg5, + arg7, + arg9, + this.particleRed, + this.particleGreen, + this.particleBlue, + super.densityDir); + FMLClientHandler.instance() + .getClient().effectRenderer.addEffect(arg11); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java new file mode 100644 index 0000000000..b07c6d1529 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -0,0 +1,245 @@ +package gtPlusPlus.core.block.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GregTech; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.base.itemblock.ItemBlockGtBlock; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BlockBaseModular extends BasicBlock { + + protected Material blockMaterial; + + protected int blockColour; + public BlockTypes thisBlock; + protected String thisBlockMaterial; + protected String thisBlockMaterialTranslatedName; + protected final String thisBlockType; + + private static final HashMap<String, Block> sBlockCache = new HashMap<>(); + + public static Block getMaterialBlock(Material aMaterial, BlockTypes aType) { + return sBlockCache.get(aMaterial.getUnlocalizedName() + "." + aType.name()); + } + + public BlockBaseModular(final Material material, final BlockTypes blockType) { + this(material, blockType, material.getRgbAsHex()); + } + + public BlockBaseModular(final Material material, final BlockTypes blockType, final int colour) { + this( + material.getUnlocalizedName(), + material.getLocalizedName(), + net.minecraft.block.material.Material.iron, + blockType, + colour, + Math.min(Math.max(material.vTier, 1), 6)); + blockMaterial = material; + registerComponent(); + sBlockCache.put(material.getUnlocalizedName() + "." + blockType.name(), this); + thisBlockMaterialTranslatedName = material.getTranslatedName(); + GT_LanguageManager.addStringLocalization("gtplusplus." + getUnlocalizedName() + ".name", getProperName()); + } + + protected BlockBaseModular(final String unlocalizedName, final String blockMaterialString, + final net.minecraft.block.material.Material vanillaMaterial, final BlockTypes blockType, final int colour, + final int miningLevel) { + super(blockType, unlocalizedName, vanillaMaterial, miningLevel); + this.setHarvestLevel(blockType.getHarvestTool(), miningLevel); + this.setBlockTextureName(GTPlusPlus.ID + ":" + blockType.getTexture()); + this.blockColour = colour; + this.thisBlock = blockType; + this.thisBlockMaterial = blockMaterialString; + this.thisBlockType = blockType.name() + .toUpperCase(); + this.setBlockName(this.getUnlocalizedProperName()); + int fx = getBlockTypeMeta(); + GameRegistry.registerBlock( + this, + ItemBlockGtBlock.class, + Utils.sanitizeString(blockType.getTexture() + unlocalizedName)); + if (fx == 0) { + GT_OreDictUnificator + .registerOre("block" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); + } else if (fx == 1) { + GT_OreDictUnificator + .registerOre("frameGt" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); + } else if (fx == 2) { + GT_OreDictUnificator + .registerOre("frameGt" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); + } + } + + public static String unifyMaterialName(String rawMaterName) { + return rawMaterName.replace(" ", "") + .replace("-", "") + .replace("_", ""); + } + + public void registerComponent() { + Logger.MATERIALS("Attempting to register " + this.getUnlocalizedName() + "."); + if (this.blockMaterial == null) { + Logger.MATERIALS("Tried to register " + this.getUnlocalizedName() + " but the material was null."); + return; + } + String aName = blockMaterial.getUnlocalizedName(); + // Register Component + Map<String, ItemStack> aMap = Material.mComponentMap.get(aName); + if (aMap == null) { + aMap = new HashMap<>(); + } + int fx = getBlockTypeMeta(); + String aKey = (fx == 0 ? OrePrefixes.block.name() + : (fx == 1 ? OrePrefixes.frameGt.name() : OrePrefixes.ore.name())); + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, ItemUtils.getSimpleStack(this)); + Logger.MATERIALS("Registering a material component. Item: [" + aName + "] Map: [" + aKey + "]"); + Material.mComponentMap.put(aName, aMap); + } else { + // Bad + Logger.MATERIALS("Tried to double register a material component."); + } + } + + public int getBlockTypeMeta() { + if (this.thisBlockType.equals( + BlockTypes.STANDARD.name() + .toUpperCase())) { + return 0; + } else if (this.thisBlockType.equals( + BlockTypes.FRAME.name() + .toUpperCase())) { + return 1; + } else + if (this.thisBlockType.equals( + BlockTypes.ORE.name() + .toUpperCase())) { + return 2; + } + return 0; + } + + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + if (this.thisBlock == BlockTypes.FRAME) { + return 1; + } + return 0; + } + + public String getProperName() { + String tempIngot = null; + if (this.thisBlock == BlockTypes.STANDARD) { + tempIngot = "Block of %material"; + } else if (this.thisBlock == BlockTypes.FRAME) { + tempIngot = "%material Frame Box"; + } else if (this.thisBlock == BlockTypes.ORE) { + tempIngot = "%material Ore [Old]"; + } + return tempIngot; + } + + public String getUnlocalizedProperName() { + return getProperName().replace("%s", "%temp") + .replace("%material", this.thisBlockMaterial) + .replace("%temp", "%s"); + } + + @Override + public String getLocalizedName() { + return GT_LanguageManager.getTranslation("gtplusplus." + getUnlocalizedName() + ".name") + .replace("%s", "%temp") + .replace("%material", this.thisBlockMaterialTranslatedName) + .replace("%temp", "%s"); + } + + @Override + public String getUnlocalizedName() { + return "block." + blockMaterial.getUnlocalizedName() + + "." + + this.thisBlock.name() + .toLowerCase(); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + public Material getMaterialEx() { + return this.blockMaterial; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + if (!CORE.ConfigSwitches.useGregtechTextures || this.blockMaterial == null + || this.thisBlock == BlockTypes.ORE) { + this.blockIcon = iIcon.registerIcon(GTPlusPlus.ID + ":" + this.thisBlock.getTexture()); + } + String metType = "9j4852jyo3rjmh3owlhw9oe"; + if (this.blockMaterial != null) { + TextureSet u = this.blockMaterial.getTextureSet(); + if (u != null) { + metType = u.mSetName; + } + } + metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); + int tier = blockMaterial != null ? this.blockMaterial.vTier : 0; + String aType = (this.thisBlock == BlockTypes.FRAME) ? "frameGt" : (tier <= 4 ? "block1" : "block5"); + this.blockIcon = iIcon.registerIcon(GregTech.ID + ":" + "materialicons/" + metType + "/" + aType); + } + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + + @Override + public int getRenderColor(final int aMeta) { + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + + @Override + public int getBlockColor() { + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java new file mode 100644 index 0000000000..1813090810 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -0,0 +1,217 @@ +package gtPlusPlus.core.block.base; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.GT_Mod; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.interfaces.ITexturedBlock; +import gtPlusPlus.core.client.renderer.CustomOreBlockRenderer; +import gtPlusPlus.core.item.base.itemblock.ItemBlockOre; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPP_RenderedTexture; + +public class BlockBaseOre extends BasicBlock implements ITexturedBlock { + + private final Material blockMaterial; + protected static boolean shouldFortune = false; + protected static boolean shouldSilkTouch = false; + + public BlockBaseOre(final Material material, final BlockTypes blockType) { + super( + blockType, + Utils.sanitizeString(material.getUnlocalizedName()), + net.minecraft.block.material.Material.rock, + Math.min(Math.max(material.vTier, 1), 6)); + int aMaterialTierForMining = Math.min(Math.max(material.vTier, 1), 6); + this.blockMaterial = material; + this.setHardness(1.0f * aMaterialTierForMining); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHarvestLevel("pickaxe", aMaterialTierForMining); + this.setStepSound(soundTypeStone); + this.setBlockName("Ore" + Utils.sanitizeString(Utils.sanitizeString(material.getUnlocalizedName()))); + this.setBlockTextureName("stone"); + try { + GameRegistry.registerBlock( + this, + ItemBlockOre.class, + Utils.sanitizeString("ore" + Utils.sanitizeString(this.blockMaterial.getLocalizedName()))); + GT_OreDictUnificator.registerOre( + "ore" + Utils.sanitizeString(this.blockMaterial.getLocalizedName()), + ItemUtils.getSimpleStack(this)); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { + return false; + } + + public Material getMaterialEx() { + return this.blockMaterial; + } + + @Override + public int getRenderType() { + try { + if (CustomOreBlockRenderer.INSTANCE != null) { + return CustomOreBlockRenderer.INSTANCE.mRenderID; + } + return super.getRenderType(); + } catch (NullPointerException n) { + return 0; + } + } + + @Override + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int ordinalSide) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + return Blocks.stone.getIcon(0, 0); + } + + /** + * GT Texture Handler + */ + + // .08 compat + public static IIconContainer[] hiddenTextureArray; + + @Override + public ITexture[] getTexture(ForgeDirection side) { + return getTexture(null, side); + } + + @Override + public ITexture[] getTexture(Block block, ForgeDirection side) { + if (this.blockMaterial != null) { + GTPP_RenderedTexture aIconSet = new GTPP_RenderedTexture( + blockMaterial.getTextureSet().mTextures[OrePrefixes.ore.mTextureIndex], + this.blockMaterial.getRGBA()); + return new ITexture[] { new GTPP_CopiedBlockTexture(Blocks.stone, 0, 0), aIconSet }; + } + + if (hiddenTextureArray == null) { + try { + Field o = ReflectionUtils.getField(Textures.BlockIcons.class, "STONES"); + if (o != null) { + hiddenTextureArray = (IIconContainer[]) o.get(Textures.BlockIcons.class); + } + if (hiddenTextureArray == null) { + hiddenTextureArray = new IIconContainer[6]; + } + } catch (IllegalArgumentException | IllegalAccessException e) { + hiddenTextureArray = new IIconContainer[6]; + } + } + return new ITexture[] { new GTPP_RenderedTexture(hiddenTextureArray[0], new short[] { 240, 240, 240, 0 }) }; + } + + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) {} + + @Override + public void harvestBlock(World worldIn, EntityPlayer player, int x, int y, int z, int meta) { + if (EnchantmentHelper.getSilkTouchModifier(player)) { + shouldSilkTouch = true; + super.harvestBlock(worldIn, player, x, y, z, meta); + + if (shouldSilkTouch) { + shouldSilkTouch = false; + } + return; + } + + if (!(player instanceof FakePlayer)) { + shouldFortune = true; + } + super.harvestBlock(worldIn, player, x, y, z, meta); + if (shouldFortune) { + shouldFortune = false; + } + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList<ItemStack> drops = new ArrayList<>(); + if (shouldSilkTouch) { + drops.add(ItemUtils.simpleMetaStack(this, metadata, 1)); + } else { + switch (GT_Mod.gregtechproxy.oreDropSystem) { + case Item -> { + drops.add( + ItemUtils.getItemStackOfAmountFromOreDictNoBroken( + "oreRaw" + this.blockMaterial.getLocalizedName(), + 1)); + } + case FortuneItem -> { + // if shouldFortune and isNatural then get fortune drops + // if not shouldFortune or not isNatural then get normal drops + // if not shouldFortune and isNatural then get normal drops + // if shouldFortune and not isNatural then get normal drops + if (shouldFortune && fortune > 0) { + int aMinAmount = 1; + // Max applicable fortune + if (fortune > 3) fortune = 3; + long amount = (long) new Random().nextInt(fortune) + aMinAmount; + for (int i = 0; i < amount; i++) { + drops.add( + ItemUtils.getItemStackOfAmountFromOreDictNoBroken( + "oreRaw" + this.blockMaterial.getLocalizedName(), + 1)); + } + } else { + drops.add( + ItemUtils.getItemStackOfAmountFromOreDictNoBroken( + "oreRaw" + this.blockMaterial.getLocalizedName(), + 1)); + } + } + case UnifiedBlock -> { + // Unified ore + drops.add(ItemUtils.simpleMetaStack(this, metadata, 1)); + } + case PerDimBlock -> { + // Per Dimension ore + drops.add(ItemUtils.simpleMetaStack(this, metadata, 1)); + } + case Block -> { + // Regular ore + drops.add(ItemUtils.simpleMetaStack(this, metadata, 1)); + } + } + } + return drops; + } + +} diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java b/src/main/java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java new file mode 100644 index 0000000000..0c353cfbdd --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java @@ -0,0 +1,100 @@ +package gtPlusPlus.core.block.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.BlockObsidian; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; + +public class BlockCompressedObsidian extends BlockObsidian { + + private final IIcon textureArray[] = new IIcon[11]; + + public BlockCompressedObsidian() { + this.setBlockName("blockCompressedObsidian"); + this.setHardness(50.0F); + this.setResistance(2000.0F); + this.setStepSound(soundTypePiston); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockCompressedObsidian"); + } + + @Override + public MapColor getMapColor(final int meta) { + if (meta < 5) { + return MapColor.obsidianColor; + } + if (meta > 5) { + return MapColor.goldColor; + } else { + return MapColor.sandColor; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iicon) { + this.textureArray[0] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "obsidian1"); + this.textureArray[1] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "obsidian2"); + this.textureArray[2] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "obsidian3"); + this.textureArray[3] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "obsidian4"); + this.textureArray[4] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "obsidian5"); + this.textureArray[5] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "obsidian_invert"); + this.textureArray[6] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "glowstone1"); + this.textureArray[7] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "glowstone2"); + this.textureArray[8] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "glowstone3"); + this.textureArray[9] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "glowstone4"); + this.textureArray[10] = iicon.registerIcon(GTPlusPlus.ID + ":" + "compressed/" + "glowstone5"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return this.textureArray[meta]; + } + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { + for (int i = 0; i < 11; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public Item getItemDropped(final int meta, final Random rand, final int fortune) { + return Item.getItemFromBlock(this); + } + + @Override + public ArrayList<ItemStack> getDrops(final World world, final int x, final int y, final int z, final int metadata, + final int fortune) { + int m = metadata; + if (m == 5) { + m = 1; + } + return super.getDrops(world, x, y, z, m, fortune); + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java b/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java new file mode 100644 index 0000000000..dc6c92f065 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java @@ -0,0 +1,197 @@ +package gtPlusPlus.core.block.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +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.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.block.ModBlocks; + +public class BlockSuperLight extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + public BlockSuperLight() { + super(Material.circuits); + this.setBlockName("blockSuperLight"); + this.setCreativeTab(CreativeTabs.tabRedstone); + GameRegistry.registerBlock(this, "blockSuperLight"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "SwirlBigBlue"); + } + + /** + * Returns a new instance of a block's tile entity class. Called on placing the block. + */ + @Override + public TileEntity createNewTileEntity(World aWorld, int p_149915_2_) { + return new TileEntitySuperLight(); + } + + public static class TileEntitySuperLight extends TileEntity { + + private long mCreated; + + private long mLastUpdateTick = 0; + + private int[][][][] aLitBlocks = new int[50][10][50][1]; + + private boolean mPowered = false; + + public TileEntitySuperLight() { + mCreated = System.currentTimeMillis(); + Logger.INFO("Created Super-Lamp"); + } + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + mCreated = aNBT.getLong("mCreated"); + mPowered = aNBT.getBoolean("mPowered"); + NBTTagCompound aLightingData = aNBT.getCompoundTag("lighting"); + for (int x = 0; x < 50; x++) { + for (int y = 0; y < 10; y++) { + for (int z = 0; z < 50; z++) { + int aData = aLightingData.getInteger("[" + x + "][" + y + "][" + z + "]"); + aLitBlocks[x][y][z][0] = aData; + } + } + } + } + + @Override + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + aNBT.setLong("mCreated", mCreated); + aNBT.setBoolean("mPowered", mPowered); + NBTTagCompound aLightingData = new NBTTagCompound(); + for (int x = 0; x < 50; x++) { + for (int y = 0; y < 10; y++) { + for (int z = 0; z < 50; z++) { + int aFlag = aLitBlocks[x][y][z][0]; + aLightingData.setInteger("[" + x + "][" + y + "][" + z + "]", aFlag); + } + } + } + aNBT.setTag("lighting", aLightingData); + } + + @Override + public void updateEntity() { + super.updateEntity(); + + if (this.worldObj.isRemote) { + return; + } + + try { + if (mLastUpdateTick == 0 || (System.currentTimeMillis() - mLastUpdateTick) >= 30000) { + boolean powered = (this.worldObj + .isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)); + boolean aLastState = mPowered; + // Logger.INFO("Powered: "+powered); + mPowered = powered; + if (mPowered != aLastState) { + updateLighting(powered); + } + } + } catch (Throwable ignored) {} + } + + @Override + public void markDirty() { + super.markDirty(); + } + + @Override + public boolean canUpdate() { + return super.canUpdate(); + } + + public void updateLighting(boolean enable) { + + mLastUpdateTick = System.currentTimeMillis(); + + aLitBlocks = new int[50][10][50][1]; + int aLitCounter = 0; + AutoMap<BlockPos> aBlocksToUpdate = new AutoMap<>(); + Logger.INFO("Trying to relight area."); + + BlockPos aStartIterationPoint = new BlockPos( + this.xCoord - 24, + this.yCoord - 4, + this.zCoord - 24, + this.worldObj); + for (int x = 0; x < 50; x++) { + for (int y = 0; y < 10; y++) { + for (int z = 0; z < 50; z++) { + int xOff = aStartIterationPoint.xPos + x; + int yOff = aStartIterationPoint.yPos + y; + int zOff = aStartIterationPoint.zPos + z; + Block aBlockGet = this.worldObj.getBlock(xOff, yOff, zOff); + if (aBlockGet != null) { + if (aBlockGet instanceof BlockAir) { + + int aLight = aBlockGet.getLightValue(); + + // Don't Need to relight anything. + if ((enable && aLight > 0) || (!enable && aLight == 0)) { + continue; + } + // Turning Lights on + else if (enable && aLight == 0) { + aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj)); + this.worldObj + .setBlock(xOff, yOff, zOff, ModBlocks.MatterFabricatorEffectBlock, 0, 3); + aLitCounter++; + } + // Turning Lights off + else if (!enable && aLight > 0) { + aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj)); + if (aBlockGet instanceof LightGlass) { + Logger.INFO("Dimmed air."); + this.worldObj.setBlock(xOff, yOff, zOff, Blocks.air, 0, 3); + } + } + aLitBlocks[x][y][z][0] = enable ? 15 : 0; + } else { + aLitBlocks[x][y][z][0] = -1; + } + } else { + aLitBlocks[x][y][z][0] = -1; + } + } + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java b/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java new file mode 100644 index 0000000000..41a581394b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java @@ -0,0 +1,141 @@ +package gtPlusPlus.core.block.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.ItemFluidContainer; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.tileentities.general.TileEntityInfiniteFluid; +import gtPlusPlus.core.util.minecraft.PlayerUtils; + +public class FluidTankInfinite extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + public FluidTankInfinite() { + super(Material.iron); + this.setBlockName("blockInfiniteFluidTank"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockInfiniteFluidTank"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return ordinalSide == 1 ? this.textureTop + : (ordinalSide == 0 ? this.textureBottom + : ((ordinalSide != 2) && (ordinalSide != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureTop = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureBottom = p_149651_1_ + .registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureFront = p_149651_1_ + .registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + } + + /** + * 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 { + TileEntityInfiniteFluid tank = (TileEntityInfiniteFluid) world.getTileEntity(x, y, z); + if (tank != null) { + Item handItem; + try { + handItem = player.getHeldItem() + .getItem(); + } catch (Throwable t) { + handItem = null; + } + if (handItem != null + && (handItem instanceof IFluidContainerItem || handItem instanceof ItemFluidContainer + || FluidContainerRegistry.isFilledContainer(player.getHeldItem()))) { + if (tank.tank.getFluid() == null) { + try { + if (!FluidContainerRegistry.isFilledContainer(player.getHeldItem())) { + ItemStack handItemStack = player.getHeldItem(); + IFluidContainerItem container = (IFluidContainerItem) handItem; + FluidStack containerFluid = container.getFluid(handItemStack); + container.drain(handItemStack, container.getFluid(handItemStack).amount, true); + tank.tank.setFluid(containerFluid); + } else { + ItemStack handItemStack = player.getHeldItem(); + FluidContainerRegistry.drainFluidContainer(handItemStack); + FluidStack containerFluid = FluidContainerRegistry.getFluidForFilledItem(handItemStack); + ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(handItemStack); + player.setItemInUse(emptyContainer, 0); + + tank.tank.setFluid(containerFluid); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + if (tank.tank.getFluid() != null) { + PlayerUtils.messagePlayer( + player, + "This tank contains " + tank.tank.getFluidAmount() + + "L of " + + tank.tank.getFluid() + .getLocalizedName()); + } + } + } + return true; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityInfiniteFluid(); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/HellFire.java b/src/main/java/gtPlusPlus/core/block/general/HellFire.java new file mode 100644 index 0000000000..4e8d94328d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/HellFire.java @@ -0,0 +1,535 @@ +package gtPlusPlus.core.block.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.UP; +import static net.minecraftforge.common.util.ForgeDirection.WEST; + +import java.util.IdentityHashMap; +import java.util.Map.Entry; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFire; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.objects.XSTR; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.math.MathUtils; + +public class HellFire extends BlockFire { + + private final int[] field_149849_a = new int[Short.MAX_VALUE]; + + private final int[] field_149848_b = new int[Short.MAX_VALUE]; + + @SideOnly(Side.CLIENT) + private IIcon[] IIconArray; + + public HellFire() { + this.setTickRandomly(true); + this.setLightLevel(1F); + this.setLightOpacity(0); + // this.setBlockTextureName(GTPlusPlus.ID + "hellfire/blockHellFire"); + this.setBlockName("blockHellFire"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + GameRegistry.registerBlock(this, "blockHellFire"); + this.enableBrutalFire(); + } + + private void enableBrutalFire() { + for (final Object o : Block.blockRegistry.getKeys()) { + + try { + + final String name = (String) o; + final Block b = Block.getBlockFromName(name); + if (b != Blocks.air) { + final int spread = Blocks.fire.getEncouragement(b); + final int flamm = Blocks.fire.getFlammability(b); + if (flamm > 0 && spread > 0) { + this.setFireInfo(b, spread * 4, flamm * 4); + } + } + + } catch (Throwable t) { + t.printStackTrace(); + } + } + + // Special Case madness + this.setFireInfo(Blocks.brown_mushroom_block, 20, 100); + this.setFireInfo(Blocks.red_mushroom_block, 20, 100); + this.setFireInfo(Blocks.grass, 20, 100); + this.setFireInfo(Blocks.mycelium, 20, 100); + } + + /** + * How many world ticks before ticking + */ + @Override + public int tickRate(final World world) { + return 5; + } + + /** + * Ticks the block if it's been scheduled + */ + @Override + public void updateTick(final World world, final int x, final int y, final int z, Random random) { + + random = new XSTR(); + + if (world.getGameRules() + .getGameRuleBooleanValue("doFireTick")) { + final boolean flag = world.getBlock(x, y - 1, z) + .isFireSource(world, x, y - 1, z, UP); + + if (!this.canPlaceBlockAt(world, x, y, z)) { + world.setBlockToAir(x, y, z); + } + + if (!flag && world.isRaining() + && (world.canLightningStrikeAt(x, y, z) || world.canLightningStrikeAt(x - 1, y, z) + || world.canLightningStrikeAt(x + 1, y, z) + || world.canLightningStrikeAt(x, y, z - 1) + || world.canLightningStrikeAt(x, y, z + 1))) { + + if (MathUtils.randInt(0, 100) >= 90) { + world.setBlockToAir(x, y, z); + } + } else { + final int blockMeta = world.getBlockMetadata(x, y, z); + + if (blockMeta < 15) { + world.setBlockMetadataWithNotify(x, y, z, blockMeta + (random.nextInt(3) / 2), 4); + } + + world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world) + random.nextInt(10)); + + if (!flag && !this.canNeighborBurn(world, x, y, z)) { + if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) || (blockMeta > 3)) { + world.setBlockToAir(x, y, z); + } + } else if (!flag && !this.canCatchFire(world, x, y - 1, z, UP) + && (blockMeta == 15) + && (random.nextInt(4) == 0)) { + world.setBlockToAir(x, y, z); + } else { + final boolean flag1 = world.isBlockHighHumidity(x, y, z); + byte b0 = 0; + + if (flag1) { + b0 = -50; + } + + this.tryCatchFire(world, x + 1, y, z, 300 + b0, random, blockMeta, WEST); + this.tryCatchFire(world, x - 1, y, z, 300 + b0, random, blockMeta, EAST); + this.tryCatchFire(world, x, y - 1, z, 250 + b0, random, blockMeta, UP); + this.tryCatchFire(world, x, y + 1, z, 250 + b0, random, blockMeta, DOWN); + this.tryCatchFire(world, x, y, z - 1, 300 + b0, random, blockMeta, SOUTH); + this.tryCatchFire(world, x, y, z + 1, 300 + b0, random, blockMeta, NORTH); + + for (int i1 = x - 1; i1 <= (x + 1); ++i1) { + for (int j1 = z - 1; j1 <= (z + 1); ++j1) { + for (int k1 = y - 1; k1 <= (y + 4); ++k1) { + if ((i1 != x) || (k1 != y) || (j1 != z)) { + int l1 = 100; + + if (k1 > (y + 1)) { + l1 += (k1 - (y + 1)) * 100; + } + + final int neighbourFireChance = this + .getChanceOfNeighborsEncouragingFire(world, i1, k1, j1); + + if (neighbourFireChance > 0) { + int j2 = (neighbourFireChance + 40 + + (world.difficultySetting.getDifficultyId() * 14)) / (blockMeta + 30); + + if (flag1) { + j2 /= 2; + } + + if ((j2 > 0) && (random.nextInt(l1) <= j2) + && (!world.isRaining() || !world.canLightningStrikeAt(i1, k1, j1)) + && !world.canLightningStrikeAt(i1 - 1, k1, z) + && !world.canLightningStrikeAt(i1 + 1, k1, j1) + && !world.canLightningStrikeAt(i1, k1, j1 - 1) + && !world.canLightningStrikeAt(i1, k1, j1 + 1)) { + int k2 = blockMeta + (random.nextInt(5) / 4); + + if (k2 > 15) { + k2 = 15; + } + + world.setBlock(i1, k1, j1, this, k2, 3); + } + } + } + } + } + } + } + } + } + } + + private void tryCatchFire(final World world, final int p_149841_2_, final int p_149841_3_, final int p_149841_4_, + final int p_149841_5_, final Random p_149841_6_, final int p_149841_7_, final ForgeDirection face) { + final int j1 = world.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) + .getFlammability(world, p_149841_2_, p_149841_3_, p_149841_4_, face); + + if (p_149841_6_.nextInt(p_149841_5_) < j1) { + final boolean flag = world.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) == Blocks.tnt; + + if ((p_149841_6_.nextInt(p_149841_7_ + 10) < 5) + && !world.canLightningStrikeAt(p_149841_2_, p_149841_3_, p_149841_4_)) { + int k1 = p_149841_7_ + (p_149841_6_.nextInt(5) / 4); + + if (k1 > 15) { + k1 = 15; + } + + world.setBlock(p_149841_2_, p_149841_3_, p_149841_4_, this, k1, 3); + } else { + world.setBlockToAir(p_149841_2_, p_149841_3_, p_149841_4_); + } + + if (flag) { + Blocks.tnt.onBlockDestroyedByPlayer(world, p_149841_2_, p_149841_3_, p_149841_4_, 1); + } + } + } + + /** + * Returns true if at least one block next to this one can burn. + */ + private boolean canNeighborBurn(final World world, final int x, final int y, final int z) { + return this.canCatchFire(world, x + 1, y, z, WEST) || this.canCatchFire(world, x - 1, y, z, EAST) + || this.canCatchFire(world, x, y - 1, z, UP) + || this.canCatchFire(world, x, y + 1, z, DOWN) + || this.canCatchFire(world, x, y, z - 1, SOUTH) + || this.canCatchFire(world, x, y, z + 1, NORTH); + } + + /** + * Gets the highest chance of a neighbor block encouraging this block to catch fire + */ + private int getChanceOfNeighborsEncouragingFire(final World world, final int x, final int y, final int z) { + final byte b0 = 0; + + if (!world.isAirBlock(x, y, z)) { + return 0; + } else { + int l = b0; + l = this.getChanceToEncourageFire(world, x + 1, y, z, l, WEST); + l = this.getChanceToEncourageFire(world, x - 1, y, z, l, EAST); + l = this.getChanceToEncourageFire(world, x, y - 1, z, l, UP); + l = this.getChanceToEncourageFire(world, x, y + 1, z, l, DOWN); + l = this.getChanceToEncourageFire(world, x, y, z - 1, l, SOUTH); + l = this.getChanceToEncourageFire(world, x, y, z + 1, l, NORTH); + return l; + } + } + + /** + * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z + */ + @Override + public boolean canPlaceBlockAt(final World worldObj, final int x, final int y, final int z) { + return World.doesBlockHaveSolidTopSurface(worldObj, x, y - 1, z) || this.canNeighborBurn(worldObj, x, y, z); + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are + * their own) Args: x, y, z, neighbor Block + */ + @Override + public void onNeighborBlockChange(final World worldObj, final int x, final int y, final int z, + final Block blockObj) { + if (!World.doesBlockHaveSolidTopSurface(worldObj, x, y - 1, z) && !this.canNeighborBurn(worldObj, x, y, z)) { + worldObj.setBlockToAir(x, y, z); + } + } + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + if ((world.provider.dimensionId > 0) || !Blocks.portal.func_150000_e(world, x, y, z)) { + if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) && !this.canNeighborBurn(world, x, y, z)) { + world.setBlockToAir(x, y, z); + } else { + world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world) + world.rand.nextInt(10)); + } + } + } + + // Burn + @Override + public void onEntityWalking(final World world, final int i, final int j, final int k, final Entity entity) { + entity.setFire(10); + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { + return false; + } + + // Burn + @Override + public void onEntityCollidedWithBlock(final World world, final int i, final int j, final int k, + final Entity entity) { + entity.setFire(10); + } + + /** + * A randomly called display update to be able to add particles or other items for display + */ + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World world, final int x, final int y, final int z, Random randomObj) { + + randomObj = new XSTR(); + + if (randomObj.nextInt(24) == 0) { + world.playSound( + x + 0.5F, + y + 0.5F, + z + 0.5F, + "fire.fire", + 1.0F + randomObj.nextFloat(), + (randomObj.nextFloat() * 0.7F) + 0.3F, + false); + } + + int l; + float f; + float f1; + float f2; + + if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) + && !Blocks.fire.canCatchFire(world, x, y - 1, z, UP)) { + if (Blocks.fire.canCatchFire(world, x - 1, y, z, EAST)) { + for (l = 0; l < 2; ++l) { + f = x + (randomObj.nextFloat() * 0.1F); + f1 = y + randomObj.nextFloat(); + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x + 1, y, z, WEST)) { + for (l = 0; l < 2; ++l) { + f = (x + 1) - (randomObj.nextFloat() * 0.1F); + f1 = y + randomObj.nextFloat(); + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x, y, z - 1, SOUTH)) { + for (l = 0; l < 2; ++l) { + f = x + randomObj.nextFloat(); + f1 = y + randomObj.nextFloat(); + f2 = z + (randomObj.nextFloat() * 0.1F); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x, y, z + 1, NORTH)) { + for (l = 0; l < 2; ++l) { + f = x + randomObj.nextFloat(); + f1 = y + randomObj.nextFloat(); + f2 = (z + 1) - (randomObj.nextFloat() * 0.1F); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x, y + 1, z, DOWN)) { + for (l = 0; l < 2; ++l) { + f = x + randomObj.nextFloat(); + f1 = (y + 1) - (randomObj.nextFloat() * 0.1F); + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + } else { + for (l = 0; l < 5; ++l) { + f = x + randomObj.nextFloat(); + f1 = y + (randomObj.nextFloat() * 0.5F) + 0.5F; + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister IIconRegister) { + this.IIconArray = new IIcon[] { + IIconRegister.registerIcon(GTPlusPlus.ID + ":" + "hellfire/" + "blockHellFire" + "_layer_0"), + IIconRegister.registerIcon(GTPlusPlus.ID + ":" + "hellfire/" + "blockHellFire" + "_layer_1") }; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getFireIcon(final int p_149840_1_) { + return this.IIconArray[p_149840_1_]; + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return this.IIconArray[0]; + } + + @Override + public MapColor getMapColor(final int p_149728_1_) { + return MapColor.snowColor; + } + + /* + * ================================= Forge Start ====================================== + */ + private static class FireInfo { + + private int encouragement = 0; + private int flammibility = 0; + } + + private final IdentityHashMap<Block, FireInfo> blockInfo = Maps.newIdentityHashMap(); + + @Override + public void setFireInfo(final Block block, final int encouragement, final int flammibility) { + try { + if (block == Blocks.air) { + throw new IllegalArgumentException("Tried to set air on fire... This is bad."); + } + final int id = Block.getIdFromBlock(block); + if (id >= 4096 || id >= field_149849_a.length || id >= field_149848_b.length) { + return; + } + this.field_149849_a[id] = encouragement; + this.field_149848_b[id] = flammibility; + + final FireInfo info = this.getInfo(block, true); + info.encouragement = encouragement; + info.flammibility = flammibility; + } catch (Throwable t) {} + } + + private FireInfo getInfo(final Block block, final boolean garentee) { + FireInfo ret = this.blockInfo.get(block); + if ((ret == null) && garentee) { + ret = new FireInfo(); + this.blockInfo.put(block, ret); + } + return ret; + } + + @Override + public void rebuildFireInfo() { + for (int x = 0; x < 4096; x++) { + // If we care.. we could detect changes in here and make sure we + // keep them, however + // it's my thinking that anyone who hacks into the private variables + // should DIAF and we don't care about them. + this.field_149849_a[x] = 0; + this.field_149848_b[x] = 0; + } + + for (final Entry<Block, FireInfo> e : this.blockInfo.entrySet()) { + final int id = Block.getIdFromBlock(e.getKey()); + if ((id >= 0) && (id < 4096)) { + this.field_149849_a[id] = e.getValue().encouragement; + this.field_149848_b[id] = e.getValue().flammibility; + } + } + } + + @Override + public int getFlammability(final Block block) { + final int id = Block.getIdFromBlock(block); + return (id >= 0) && (id < 4096) ? this.field_149848_b[id] : 0; + } + + @Override + public int getEncouragement(final Block block) { + final int id = Block.getIdFromBlock(block); + return (id >= 0) && (id < 4096) ? this.field_149849_a[id] : 0; + } + + /** + * Side sensitive version that calls the block function. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param face The side the fire is coming from + * @return True if the face can catch fire. + */ + @Override + public boolean canCatchFire(final IBlockAccess world, final int x, final int y, final int z, + final ForgeDirection face) { + return world.getBlock(x, y, z) + .isFlammable(world, x, y, z, face); + } + + /** + * Side sensitive version that calls the block function. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param oldChance The previous maximum chance. + * @param face The side the fire is coming from + * @return The chance of the block catching fire, or oldChance if it is higher + */ + @Override + public int getChanceToEncourageFire(final IBlockAccess world, final int x, final int y, final int z, + final int oldChance, final ForgeDirection face) { + final int newChance = world.getBlock(x, y, z) + .getFireSpreadSpeed(world, x, y, z, face); + return (newChance > oldChance ? newChance : oldChance); + } + /* + * ================================= Forge Start ====================================== + */ +} diff --git a/src/main/java/gtPlusPlus/core/block/general/LightGlass.java b/src/main/java/gtPlusPlus/core/block/general/LightGlass.java new file mode 100644 index 0000000000..b6facce45f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/LightGlass.java @@ -0,0 +1,137 @@ +package gtPlusPlus.core.block.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import codechicken.nei.api.API; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; + +/* + * public class LightGlass extends BlockBreakable { + */ +public class LightGlass extends BlockAir { + + private int state = 0; + private final int a = 255; + private int r = 255; + private int g = 0; + private int b = 0; + private int hex; + + public LightGlass(final boolean bool) { + super(); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setBlockName("blockMFEffect"); + this.setLightLevel(12F); + setHardness(0.1F); + setBlockTextureName(GTPlusPlus.ID + ":" + "blockMFEffect"); + setStepSound(Block.soundTypeGlass); + GameRegistry.registerBlock(this, "blockMFEffect"); + + API.hideItem(new ItemStack(this)); + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(final Random rand) { + return 0; + } + + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 0; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() { + return false; + } + + /** + * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops. + */ + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + this.blockIcon = iIcon.registerIcon(GTPlusPlus.ID + ":" + "blockMFEffect"); + } + + @Override + // http://stackoverflow.com/questions/31784658/how-can-i-loop-through-all-rgb-combinations-in-rainbow-order-in-java + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + if (this.state == 0) { + this.g++; + if (this.g == 255) { + this.state = 1; + } + } + if (this.state == 1) { + this.r--; + if (this.r == 0) { + this.state = 2; + } + } + if (this.state == 2) { + this.b++; + if (this.b == 255) { + this.state = 3; + } + } + if (this.state == 3) { + this.g--; + if (this.g == 0) { + this.state = 4; + } + } + if (this.state == 4) { + this.r++; + if (this.r == 255) { + this.state = 5; + } + } + if (this.state == 5) { + this.b--; + if (this.b == 0) { + this.state = 0; + } + } + this.hex = (this.a << 24) + (this.r << 16) + (this.g << 8) + (this.b); + return this.hex; + } + + /** + * A randomly called display update to be able to add particles or other items for display + */ + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World world, final int posX, final int posY, final int posZ, + final Random random) { + // Utils.spawnFX(world, posX, posY, posZ, "smoke", "cloud"); + + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java b/src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java new file mode 100644 index 0000000000..7579907e9d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java @@ -0,0 +1,193 @@ +package gtPlusPlus.core.block.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockTNT; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; + +public class MiningExplosives extends BlockTNT { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + public MiningExplosives() { + this.setBlockName("blockMiningExplosives"); + GameRegistry.registerBlock(this, "blockMiningExplosives"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return ordinalSide == 0 ? this.textureBottom : (ordinalSide == 1 ? this.textureTop : this.blockIcon); + } + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + + if (world.isBlockIndirectlyGettingPowered(x, y, z)) { + this.onBlockDestroyedByPlayer(world, x, y, z, 1); + world.setBlockToAir(x, y, z); + } + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are + * their own) Args: x, y, z, neighbor Block + */ + @Override + public void onNeighborBlockChange(final World world, final int x, final int y, final int z, + final Block neighbourblock) { + if (world.isBlockIndirectlyGettingPowered(x, y, z)) { + this.onBlockDestroyedByPlayer(world, x, y, z, 1); + world.setBlockToAir(x, y, z); + } + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(final Random random) { + return 1; + } + + /** + * Called upon the block being destroyed by an explosion + */ + @Override + public void onBlockDestroyedByExplosion(final World world, final int x, final int y, final int z, + final Explosion bang) { + if (!world.isRemote) { + final EntityPrimedMiningExplosive EntityPrimedMiningExplosive = new EntityPrimedMiningExplosive( + world, + x + 0.5F, + y + 0.5F, + z + 0.5F, + bang.getExplosivePlacedBy()); + EntityPrimedMiningExplosive.fuse = world.rand.nextInt(EntityPrimedMiningExplosive.fuse / 4) + + (EntityPrimedMiningExplosive.fuse / 8); + world.spawnEntityInWorld(EntityPrimedMiningExplosive); + } + } + + /** + * Called right before the block is destroyed by a player. Args: world, x, y, z, metaData + */ + @Override + public void onBlockDestroyedByPlayer(final World world, final int x, final int y, final int z, final int meta) { + this.func_150114_a(world, x, y, z, meta, (EntityLivingBase) null); + } + + // TODO Spawns Primed TNT? + @Override + public void func_150114_a(final World world, final int p_150114_2_, final int p_150114_3_, final int p_150114_4_, + final int p_150114_5_, final EntityLivingBase entityLiving) { + if (!world.isRemote) { + if ((p_150114_5_ & 1) == 1) { + final EntityPrimedMiningExplosive EntityPrimedMiningExplosive = new EntityPrimedMiningExplosive( + world, + p_150114_2_ + 0.5F, + p_150114_3_ + 0.5F, + p_150114_4_ + 0.5F, + entityLiving); + world.spawnEntityInWorld(EntityPrimedMiningExplosive); + world.playSoundAtEntity(EntityPrimedMiningExplosive, "game.tnt.primed", 1.0F, 1.0F); + } + } + } + + /** + * 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 clickingPlayer, final int p_149727_6_, final float p_149727_7_, final float p_149727_8_, + final float p_149727_9_) { + if ((clickingPlayer.getCurrentEquippedItem() != null) && (clickingPlayer.getCurrentEquippedItem() + .getItem() == Items.flint_and_steel)) { + this.func_150114_a(world, x, y, z, 1, clickingPlayer); + world.setBlockToAir(x, y, z); + clickingPlayer.getCurrentEquippedItem() + .damageItem(1, clickingPlayer); + return true; + } else { + return super.onBlockActivated( + world, + x, + y, + z, + clickingPlayer, + p_149727_6_, + p_149727_7_, + p_149727_8_, + p_149727_9_); + } + } + + /** + * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity + */ + @Override + public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, + final Entity entityTriggering) { + if ((entityTriggering instanceof final EntityArrow entityarrow) && !world.isRemote) { + + if (entityarrow.isBurning()) { + this.func_150114_a( + world, + x, + y, + z, + 1, + entityarrow.shootingEntity instanceof EntityLivingBase + ? (EntityLivingBase) entityarrow.shootingEntity + : null); + world.setBlockToAir(x, y, z); + } + } + } + + /** + * Return whether this block can drop from an explosion. + */ + @Override + public boolean canDropFromExplosion(final Explosion bang) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iconRegister) { + this.blockIcon = iconRegister.registerIcon(GTPlusPlus.ID + ":" + "chrono/" + "MetalSheet2"); + this.textureTop = iconRegister.registerIcon(GTPlusPlus.ID + ":" + "chrono/" + "MetalFunnel"); + this.textureBottom = iconRegister.registerIcon(GTPlusPlus.ID + ":" + "chrono/" + "MetalPanel"); + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java b/src/main/java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java new file mode 100644 index 0000000000..7e64f19bf3 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java @@ -0,0 +1,161 @@ +package gtPlusPlus.core.block.general.antigrief; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; + +public class BlockWitherProof extends Block { + + public BlockWitherProof() { + super(Material.redstoneLight); + this.setBlockName(Utils.sanitizeString("blockBlackGate")); + this.setBlockTextureName(GTPlusPlus.ID + ":" + "blockFrameGt"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(-1F); + this.setResistance(5000.0F); + this.setHarvestLevel("pickaxe", 3); + this.setStepSound(soundTypeMetal); + GameRegistry.registerBlock(this, Utils.sanitizeString("blockBlackGate")); + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + this.blockIcon = iIcon.registerIcon(GTPlusPlus.ID + ":" + "blockFrameGt"); + } + + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion) { + // prevent from being destroyed by wither and nukes. + } + + @Override + public void onBlockDestroyedByExplosion(final World p_149723_1_, final int p_149723_2_, final int p_149723_3_, + final int p_149723_4_, final Explosion p_149723_5_) {} + + @Override + public boolean canDropFromExplosion(final Explosion p_149659_1_) { + return false; + } + + @Override + public boolean canEntityDestroy(final IBlockAccess world, final int x, final int y, final int z, + final Entity entity) { + if ((entity == null) || !entity.isEntityAlive()) { + return false; + } + if ((entity instanceof EntityWither) || (entity instanceof EntityDragon) + || (entity instanceof IBossDisplayData)) { + return false; + } else { + return super.canEntityDestroy(world, x, y, z, entity); + } + } + + // Colour Handling + private static final int mWitherColour = Utils.rgbtoHexValue(32, 32, 32); + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + return mWitherColour; + } + + @Override + public int getRenderColor(final int aMeta) { + return mWitherColour; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { + return false; + } + + @Override + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, + int p_149749_6_) { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + @Override + public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World p_149737_2_, int p_149737_3_, + int p_149737_4_, int p_149737_5_) { + if (aPlayer != null && aPlayer instanceof EntityPlayerMP) { + return 1f; + } + return -1f; + } + + @Override + public float getExplosionResistance(Entity p_149638_1_) { + return Float.MAX_VALUE; + } + + @Override + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, + EntityPlayer p_149699_5_) { + super.onBlockClicked(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_, p_149699_5_); + } + + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + if ((entity == null) || !entity.isEntityAlive()) { + return; + } + if ((entity instanceof EntityWither) || (entity instanceof EntityDragon) + || (entity instanceof IBossDisplayData)) { + return; + } else { + super.onEntityCollidedWithBlock(world, x, y, z, entity); + } + } + + @Override + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, + int p_149636_5_, int p_149636_6_) { + super.harvestBlock(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + } + + @Override + public boolean canHarvestBlock(EntityPlayer player, int meta) { + if (player != null && player instanceof EntityPlayerMP) { + return true; + } + return super.canHarvestBlock(player, meta); + } + + @Override + public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, + double explosionY, double explosionZ) { + return Float.MAX_VALUE; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java b/src/main/java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java new file mode 100644 index 0000000000..200f85d31d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java @@ -0,0 +1,68 @@ +package gtPlusPlus.core.block.general.fluids; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; + +public class BlockFluidSludge extends BlockFluidClassic { + + @SideOnly(Side.CLIENT) + protected IIcon stillIcon; + + @SideOnly(Side.CLIENT) + protected IIcon flowingIcon; + + public BlockFluidSludge(final Fluid fluid, final Material material) { + super(fluid, material); + this.setCreativeTab(AddToCreativeTab.tabMisc); + } + + @Override + public IIcon getIcon(final int ordinalSide, final int meta) { + return ((ordinalSide == 0) || (ordinalSide == 1)) ? this.stillIcon : this.flowingIcon; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(final IIconRegister register) { + this.stillIcon = register.registerIcon(GTPlusPlus.ID + ":fluids/fluid.jackdaniels"); + this.flowingIcon = register.registerIcon(GTPlusPlus.ID + ":fluids/fluid.jackdaniels"); + } + + @Override + public boolean canDisplace(final IBlockAccess world, final int x, final int y, final int z) { + if (world.getBlock(x, y, z) + .getMaterial() + .isLiquid()) { + return false; + } + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(final World world, final int x, final int y, final int z) { + if (world.getBlock(x, y, z) + .getMaterial() + .isLiquid()) { + return false; + } + return super.displaceIfPossible(world, x, y, z); + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java b/src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java new file mode 100644 index 0000000000..f6cd34aec1 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java @@ -0,0 +1,153 @@ +package gtPlusPlus.core.block.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.block.material.Material; +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.world.IBlockAccess; +import net.minecraft.world.World; + +import gregtech.common.items.GT_MetaGenerated_Tool_01; +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.tileentities.general.TileEntityCircuitProgrammer; +import gtPlusPlus.core.util.minecraft.PlayerUtils; + +public class CircuitProgrammer extends BasicTileBlockWithTooltip { + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 4; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + public CircuitProgrammer() { + 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()); + final Item mHandItem = mHandStack.getItem(); + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) + && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { + final TileEntityCircuitProgrammer tile = (TileEntityCircuitProgrammer) 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 TileEntityCircuitProgrammer)) { + player.openGui(GTplusplus.instance, GuiHandler.GUI8, world, x, y, z); + return true; + } + } else { + return true; + } + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityCircuitProgrammer(); + } + + @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 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()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { + 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[] { GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_METAL_PANEL_G", + GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B", + GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I" }; + CubicObject<String>[] aTextureData = new CubicObject[] { new CubicObject<>(aTexData) }; + return aTextureData; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java b/src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java new file mode 100644 index 0000000000..c333e7a5ca --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java @@ -0,0 +1,186 @@ +package gtPlusPlus.core.block.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +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; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.client.renderer.RenderDecayChest; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; +import gtPlusPlus.core.util.minecraft.InventoryUtils; + +public class DecayablesChest 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 = 5; + + public final int field_149956_a = 0; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + public DecayablesChest() { + super(Material.iron); + this.setBlockName("blockDecayablesChest"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHardness(5f); + this.setResistance(1f); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockDecayablesChest"); + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } + + /** + * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two + * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. + */ + @Override + public boolean isOpaqueCube() { + return false; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() { + return false; + } + + /** + * The type of render function that is called for this block + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderType() { + try { + if (RenderDecayChest.INSTANCE != null) { + return RenderDecayChest.INSTANCE.mRenderID; + } + return super.getRenderType(); + } catch (NullPointerException n) { + return 0; + } + } + + /** + * Updates the blocks bounds based on its current state. Args: world, x, y, z + */ + @Override + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, + int p_149719_4_) { + if (p_149719_1_.getBlock(p_149719_2_, p_149719_3_, p_149719_4_ - 1) == this) { + this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F); + } else if (p_149719_1_.getBlock(p_149719_2_, p_149719_3_, p_149719_4_ + 1) == this) { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F); + } else if (p_149719_1_.getBlock(p_149719_2_ - 1, p_149719_3_, p_149719_4_) == this) { + this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } else if (p_149719_1_.getBlock(p_149719_2_ + 1, p_149719_3_, p_149719_4_) == this) { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F); + } else { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return ordinalSide == 1 ? this.textureTop : (ordinalSide == 0 ? this.textureBottom : this.textureFront); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "DecayablesChest_top"); + this.textureTop = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "DecayablesChest_top"); + this.textureBottom = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "DecayablesChest_side"); + this.textureFront = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "DecayablesChest_bottom"); + } + + /** + * 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 TileEntityDecayablesChest)) { + player.openGui(GTplusplus.instance, GuiHandler.GUI13, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityDecayablesChest(); + } + + @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()) { + ((TileEntityDecayablesChest) 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; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/FishTrap.java b/src/main/java/gtPlusPlus/core/block/machine/FishTrap.java new file mode 100644 index 0000000000..0ec1ac629a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/FishTrap.java @@ -0,0 +1,136 @@ +package gtPlusPlus.core.block.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +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; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; +import gtPlusPlus.core.util.minecraft.InventoryUtils; + +public class FishTrap 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 = 0; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + public FishTrap() { + super(Material.iron); + this.setBlockName("blockFishTrap"); + this.setHardness(5f); + this.setResistance(1f); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockFishTrap"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return ordinalSide == 1 ? this.textureTop + : (ordinalSide == 0 ? this.textureBottom + : ((ordinalSide != 2) && (ordinalSide != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "fishtrap"); + this.textureTop = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "fishtrap"); + this.textureBottom = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "fishtrap"); + this.textureFront = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "fishtrap"); + } + + /** + * 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 TileEntityFishTrap)) { + player.openGui(GTplusplus.instance, 5, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityFishTrap(); + } + + @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()) { + ((TileEntityFishTrap) 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; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java new file mode 100644 index 0000000000..bf98a22500 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java @@ -0,0 +1,137 @@ +package gtPlusPlus.core.block.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +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; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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.tileentities.machines.TileEntityPestKiller; +import gtPlusPlus.core.util.minecraft.InventoryUtils; + +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; + } + + 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"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return ordinalSide == 1 ? this.textureTop : (ordinalSide == 0 ? this.textureBottom : this.textureFront); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_ + .registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); + this.textureTop = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "MACHINE_PESTKILLER_TOP"); + this.textureBottom = p_149651_1_.registerIcon("planks_acacia"); + this.textureFront = p_149651_1_ + .registerIcon(GTPlusPlus.ID + ":" + "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; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java new file mode 100644 index 0000000000..4f1b679fcf --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java @@ -0,0 +1,177 @@ +package gtPlusPlus.core.block.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; +import java.util.Random; + +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.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.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.tileentities.machines.TileEntityAdvPooCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityBaseFluidCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; + +public class Machine_PooCollector extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureTop2; + + @SideOnly(Side.CLIENT) + private IIcon textureSide; + + @SideOnly(Side.CLIENT) + private IIcon textureSide2; + + public Machine_PooCollector() { + super(Material.iron); + this.setHardness(5f); + this.setResistance(1f); + this.setBlockName("blockPooCollector"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockPooCollector"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int aMeta) { + if (aMeta <= 7) { + blockIcon = textureSide; + return ordinalSide <= 1 ? this.textureTop : this.textureSide; + } else { + blockIcon = textureSide2; + return ordinalSide <= 1 ? this.textureTop2 : this.textureSide2; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.textureTop = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "sewer_top"); + this.textureTop2 = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "sewer_adv_top"); + this.textureSide = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "sewer_sides"); + this.textureSide2 = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "sewer_adv_sides"); + } + + /** + * 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 { + TileEntityBaseFluidCollector tank = (TileEntityBaseFluidCollector) world.getTileEntity(x, y, z); + if (tank != null) { + Item handItem; + try { + handItem = player.getHeldItem() + .getItem(); + } catch (Throwable t) { + handItem = null; + } + + // Fluid container code + /* + * if (handItem != null && (handItem instanceof IFluidContainerItem || handItem instanceof + * ItemFluidContainer || FluidContainerRegistry.isFilledContainer(player.getHeldItem()))) { if + * (tank.tank.getFluid() == null) { try { if + * (!FluidContainerRegistry.isFilledContainer(player.getHeldItem())) { ItemStack handItemStack = + * player.getHeldItem(); IFluidContainerItem container = (IFluidContainerItem) handItem; FluidStack + * containerFluid = container.getFluid(handItemStack); container.drain(handItemStack, + * container.getFluid(handItemStack).amount, true); tank.tank.setFluid(containerFluid); } else { + * ItemStack handItemStack = player.getHeldItem(); + * FluidContainerRegistry.drainFluidContainer(handItemStack); FluidStack containerFluid = + * FluidContainerRegistry.getFluidForFilledItem(handItemStack); ItemStack emptyContainer = + * FluidContainerRegistry.drainFluidContainer(handItemStack); player.setItemInUse(emptyContainer, 0); + * tank.tank.setFluid(containerFluid); } } catch (Throwable t) { t.printStackTrace(); } } } + */ + + if (!tank.mInventory.isEmpty()) { + PlayerUtils.messagePlayer(player, "Inventory contains:"); + PlayerUtils.messagePlayer(player, ItemUtils.getArrayStackNames(tank.mInventory.getRealInventory())); + } else { + PlayerUtils.messagePlayer(player, "No solids collected yet."); + } + if (tank.tank.getFluid() != null) { + PlayerUtils.messagePlayer( + player, + "Tank contains " + tank.tank.getFluidAmount() + + "L of " + + tank.tank.getFluid() + .getLocalizedName()); + } + } + } + return true; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public boolean isOpaqueCube() { + return super.isOpaqueCube(); + } + + @Override + public TileEntity createNewTileEntity(final World world, final int aMeta) { + return aMeta <= 7 ? new TileEntityPooCollector() : new TileEntityAdvPooCollector(); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public int getBlockColor() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public Item getItemDropped(final int meta, final Random rand, final int fortune) { + return Item.getItemFromBlock(this); + } + + @Override + public int getRenderColor(int aMeta) { + return super.getRenderColor(aMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + aList.add(new ItemStack(aItem, 1, 0)); + aList.add(new ItemStack(aItem, 1, 8)); + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java new file mode 100644 index 0000000000..4f0d0d7d60 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java @@ -0,0 +1,160 @@ +package gtPlusPlus.core.block.machine; + +import static gregtech.api.enums.Mods.BuildCraftCore; +import static gregtech.api.enums.Mods.EnderIO; +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +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; + +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Mods; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import ic2.core.item.tool.ItemToolWrench; + +@Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = Mods.Names.ENDER_I_O) +public class Machine_ProjectTable 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 = 3; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + public Machine_ProjectTable() { + super(Material.iron); + this.setBlockName("blockProjectBench"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockProjectBench"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int ordinalSide, final int meta) { + return ordinalSide == 1 ? this.textureTop + : (ordinalSide == 0 ? this.textureBottom + : ((ordinalSide != 2) && (ordinalSide != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "machine_top"); + this.textureTop = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "cover_crafting"); + this.textureBottom = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "machine_top"); + this.textureFront = p_149651_1_.registerIcon(GTPlusPlus.ID + ":" + "TileEntities/" + "machine_top"); + } + + /** + * 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) { + + ItemStack heldItem = null; + if (world.isRemote) { + heldItem = PlayerUtils.getItemStackInPlayersHand(); + } + + boolean holdingWrench = false; + + if (heldItem != null) { + holdingWrench = isWrench(heldItem); + } + + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof TileEntityProjectTable) { + if (!holdingWrench) { + player.openGui(GTplusplus.instance, 0, world, x, y, z); + return true; + } + Logger.INFO("Holding a Wrench, doing wrench things instead."); + } + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityProjectTable(); + } + + public static boolean isWrench(final ItemStack item) { + if (item.getItem() instanceof ItemToolWrench) { + return true; + } + if (BuildCraftCore.isModLoaded()) { + return checkBuildcraftWrench(item); + } + if (EnderIO.isModLoaded()) { + return checkEnderIOWrench(item); + } + return false; + } + + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { + Class<?> wrenchClass; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; + } + } + return false; + } + + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { + Class<?> wrenchClass; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; + } + } + return false; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java new file mode 100644 index 0000000000..470fa98a9b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java @@ -0,0 +1,558 @@ +package gtPlusPlus.core.block.machine; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockJukebox; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemRecord; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.inventories.Inventory_SuperJukebox; +import gtPlusPlus.core.util.math.MathUtils; + +public class Machine_SuperJukebox extends BlockJukebox { + + @SideOnly(Side.CLIENT) + private IIcon mIcon; + + public Machine_SuperJukebox() { + this.setBlockName("blockSuperJukebox"); + this.setCreativeTab(CreativeTabs.tabRedstone); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypePiston); + setBlockTextureName("jukebox"); + GameRegistry.registerBlock(this, "blockSuperJukebox"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int aMeta) { + return ordinalSide == 1 ? this.mIcon : this.blockIcon; + } + + /** + * 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 TileEntitySuperJukebox)) { + player.openGui(GTplusplus.instance, GuiHandler.GUI14, world, x, y, z); + return true; + } + return false; + + /* + * if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { return false; } else { this.func_149925_e(aWorld, aX, aY, + * aZ); return true; } + */ + } + + /** + * Set the record in the {@link SuperJukebox} {@link TileEntity}. + */ + @Override + public final void func_149926_b(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) { + setRecordInJukeBox(aWorld, aX, aY, aZ, aStackToSet); + } + + public void setRecordInJukeBox(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) { + if (!aWorld.isRemote) { + TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ); + if (tileentityjukebox != null && aStackToSet.getItem() instanceof ItemRecord) { + tileentityjukebox.setCurrentRecord(aStackToSet.copy()); + // aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 1, 2); + } + } + } + + /** + * Function to handle playing of records. + */ + @Override + public final void func_149925_e(World aWorld, int aX, int aY, int aZ) { + playJukeboxRecord(aWorld, aX, aY, aZ); + } + + public void playJukeboxRecord(World aWorld, int aX, int aY, int aZ) { + if (!aWorld.isRemote) { + TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ); + + if (tileentityjukebox != null) { + ItemStack itemstack = tileentityjukebox.func_145856_a(); + + if (itemstack != null) { + + aWorld.playAuxSFX(1005, aX, aY, aZ, Item.getIdFromItem(itemstack.getItem())); + /* + * float f = 0.7F; double d0 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + * double d1 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D; double d2 + * = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; ItemStack itemstack1 = + * itemstack.copy(); EntityItem entityitem = new EntityItem(aWorld, (double) aX + d0, (double) aY + + * d1, (double) aZ + d2, itemstack1); entityitem.delayBeforeCanPickup = 10; + * aWorld.spawnEntityInWorld(entityitem); + */ + } + } + } + } + + @Override + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, + int p_149749_6_) { + this.func_149925_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_); + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + /** + * Drops the block items with a specified chance of dropping the specified items + */ + @Override + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, + int p_149690_5_, float p_149690_6_, int p_149690_7_) { + if (!p_149690_1_.isRemote) { + super.dropBlockAsItemWithChance( + p_149690_1_, + p_149690_2_, + p_149690_3_, + p_149690_4_, + p_149690_5_, + p_149690_6_, + 0); + } + } + + /** + * Returns a new instance of a block's tile entity class. Called on placing the block. + */ + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileEntitySuperJukebox(); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.mIcon = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + } + + public static class TileEntitySuperJukebox extends TileEntityJukebox implements ISidedInventory { + + /** The number of players currently using this chest */ + public int numPlayersUsing; + + private ItemStack mCurrentlyPlayingStack; + private final Inventory_SuperJukebox inventoryContents; + private String customName; + + /* + * Important Data + */ + + public int a_TEST_INT_VAR_1; + public int a_TEST_INT_VAR_2; + public int a_TEST_INT_VAR_3; + public int a_TEST_INT_VAR_4; + + public boolean mIsPlaying = false; + public boolean mIsLooping = false; + public boolean a_TEST_BOOL_VAR_3; + public boolean a_TEST_BOOL_VAR_4; + + public TileEntitySuperJukebox() { + this.inventoryContents = new Inventory_SuperJukebox(); + } + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + + if (aNBT.hasKey("RecordItem", 10)) { + this.func_145857_a(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("RecordItem"))); + } else if (aNBT.getInteger("Record") > 0) { + this.func_145857_a(new ItemStack(Item.getItemById(aNBT.getInteger("Record")), 1, 0)); + } + + this.inventoryContents.readFromNBT(aNBT.getCompoundTag("ContentsChest")); + if (aNBT.hasKey("CustomName", 8)) { + this.setCustomName(aNBT.getString("CustomName")); + } + + mIsPlaying = aNBT.getBoolean("mIsPlaying"); + mIsLooping = aNBT.getBoolean("mIsLooping"); + } + + @Override + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + + if (this.getCurrentRecord() != null) { + aNBT.setTag( + "RecordItem", + this.func_145856_a() + .writeToNBT(new NBTTagCompound())); + aNBT.setInteger( + "Record", + Item.getIdFromItem( + this.func_145856_a() + .getItem())); + } + + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + aNBT.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + aNBT.setString("CustomName", this.getCustomName()); + } + + aNBT.setBoolean("mIsPlaying", mIsPlaying); + aNBT.setBoolean("mIsLooping", mIsLooping); + } + + /** + * Called to get the internal stack + */ + @Override + public ItemStack func_145856_a() { + return this.mCurrentlyPlayingStack; + } + + /** + * Called to get the internal stack, wraps vanilla function {@link func_145856_a}. + */ + public ItemStack getCurrentRecord() { + return func_145856_a(); + } + + /** + * Called to set the internal stack + */ + @Override + public void func_145857_a(ItemStack p_145857_1_) { + this.mCurrentlyPlayingStack = p_145857_1_; + this.markDirty(); + } + + /** + * Called to set the internal stack, wraps vanilla function {@link func_145857_a}. + */ + public void setCurrentRecord(ItemStack aStack) { + func_145857_a(aStack); + this.markDirty(); + } + + public Inventory_SuperJukebox getInventory() { + return this.inventoryContents; + } + + public boolean playRecord(ItemStack aRecord) { + + return false; + } + + public boolean stopRecord() { + return openDiscDrive(); + } + + public void setLoopState(boolean isShufflingForever) {} + + // Play button pressed + public boolean jukeboxLogicUpdate() { + + if (this.worldObj.isRemote) { + return true; + } + + Logger.INFO("a"); + if (this.mIsPlaying || this.mIsLooping) { + return selectRecordToPlayFromInventoryAndSetViaVanillaHandler(); + } else { + return stopRecord(); + } + } + + // Determine which record to play + public boolean selectRecordToPlayFromInventoryAndSetViaVanillaHandler() { + AutoMap<ItemStack> mValidRecords = new AutoMap<>(); + for (ItemStack g : this.getInventory() + .getInventory()) { + if (g != null) { + if (g.getItem() instanceof ItemRecord) { + mValidRecords.put(g); + } + } + } + + Logger.INFO("b1"); + // Select First Record + ItemStack aRecordToPlay; + if (mValidRecords.size() == 0) { + Logger.INFO("bX"); + return false; + } else { + aRecordToPlay = mValidRecords.get(!mIsLooping ? 0 : MathUtils.randInt(0, (mValidRecords.size() - 1))); + } + Logger.INFO("b2 - " + aRecordToPlay.getDisplayName()); + + int aSlotCounter = 0; + for (ItemStack g : this.getInventory() + .getInventory()) { + if (g != null && aSlotCounter <= 17) { + Logger.INFO("b3 - " + g.getDisplayName()); + if (GT_Utility.areStacksEqual(g, aRecordToPlay, true)) { + IInventory aThisInv = this.getInventory(); + if (aThisInv.getStackInSlot(20) != null) { + openDiscDrive(); + } + + GT_Utility.moveStackFromSlotAToSlotB( + aThisInv, + aThisInv, + aSlotCounter, + 20, + (byte) 1, + (byte) 1, + (byte) 1, + (byte) 1); + setCurrentRecord(aThisInv.getStackInSlot(20)); + + World aWorld = this.worldObj; + int aX = this.xCoord; + int aY = this.yCoord; + int aZ = this.zCoord; + if (!aWorld.isRemote) { + aRecordToPlay = this.func_145856_a(); + if (aRecordToPlay != null) { + aWorld.playAuxSFX(1005, aX, aY, aZ, Item.getIdFromItem(aRecordToPlay.getItem())); + this.markDirty(); + return true; + } + } + + Logger.INFO("b++"); + this.markDirty(); + return false; + } + } + aSlotCounter++; + } + + Logger.INFO("b4"); + this.markDirty(); + return false; + } + + public boolean genericMethodThree(Object a1, Object a2, Object a3, Object a4) { + return false; + } + + public void vanillaStopJukebox() { + World aWorld = this.worldObj; + int aX = this.xCoord; + int aY = this.yCoord; + int aZ = this.zCoord; + if (!aWorld.isRemote) { + TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ); + if (tileentityjukebox != null) { + ItemStack aRecordToPlay = tileentityjukebox.func_145856_a(); + if (aRecordToPlay != null) { + aWorld.playAuxSFX(1005, aX, aY, aZ, 0); + aWorld.playRecord((String) null, aX, aY, aZ); + tileentityjukebox.func_145857_a((ItemStack) null); + this.markDirty(); + } + } + } + } + + public boolean openDiscDrive() { + int aSlotCounter = 17; + + ItemStack g; + + for (int i = 17; i >= 0; i--) { + g = this.getInventory() + .getInventory()[i]; + if (g == null && aSlotCounter >= 0) { + IInventory aThisInv = this.getInventory(); + GT_Utility + .moveStackFromSlotAToSlotB(aThisInv, aThisInv, 20, i, (byte) 1, (byte) 1, (byte) 1, (byte) 1); + vanillaStopJukebox(); + Logger.INFO("b++"); + this.markDirty(); + return true; + } + } + + /* + * for (ItemStack g : this.getInventory().getInventory()) { if (g == null && aSlotCounter >= 0) { IInventory + * aThisInv = this.getInventory(); GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, 20, + * aSlotCounter, (byte) 1, (byte) 1, (byte) 1, (byte) 1); vanillaStopJukebox(); Logger.INFO("b++"); return + * true; } aSlotCounter--; } + */ + this.markDirty(); + return false; + } + + 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 int getSizeInventory() { + return this.getInventory() + .getSizeInventory() - 3; + } + + @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 1; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory() + .isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + if (this.numPlayersUsing < 0) { + this.numPlayersUsing = 0; + } + if (!this.worldObj.isRemote) { + this.numPlayersUsing++; + } + this.worldObj + .addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + 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() { + if (!this.worldObj.isRemote) { + this.numPlayersUsing--; + } + this.worldObj + .addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + 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) { + if (slot >= 18) { + return false; + } + return this.getInventory() + .isItemValidForSlot(slot, itemstack); + } + + private static final int[] SIDED_SLOTS = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17 }; + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return SIDED_SLOTS; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + if (p_102007_1_ >= 18) { + return false; + } + return this.getInventory() + .isItemValidForSlot(p_102007_1_, p_102007_2_); + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + if (p_102008_1_ >= 18) { + return false; + } + return this.getInventory() + .isItemValidForSlot(p_102008_1_, p_102008_2_); + } + + 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.SuperJukebox"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java new file mode 100644 index 0000000000..1bca4a5c5f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java @@ -0,0 +1,157 @@ +package gtPlusPlus.core.block.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.block.material.Material; +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.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gregtech.common.items.GT_MetaGenerated_Tool_01; +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.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import gtPlusPlus.core.util.minecraft.PlayerUtils; + +public class VolumetricFlaskSetter extends BasicTileBlockWithTooltip { + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 8; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @Override + public Class<? extends ItemBlock> getItemBlockClass() { + return ItemBlockBasicTile.class; + } + + public VolumetricFlaskSetter() { + 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()); + final Item mHandItem = mHandStack.getItem(); + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) + && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { + final TileEntityVolumetricFlaskSetter tile = (TileEntityVolumetricFlaskSetter) 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 TileEntityVolumetricFlaskSetter aTile)) { + player.openGui(GTplusplus.instance, GuiHandler.GUI18, world, x, y, z); + // new Packet_VolumetricFlaskGui2(aTile, aTile.getCustomValue()); + return true; + } + } else { + return true; + } + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityVolumetricFlaskSetter(); + } + + @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 onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, + final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityVolumetricFlaskSetter) 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; + } + + @Override + public int getMetaCount() { + return 0; + } + + @Override + public String getUnlocalBlockName() { + return "blockVolumetricFlaskSetter"; + } + + @Override + protected float initBlockHardness() { + return 5f; + } + + @Override + protected float initBlockResistance() { + return 1f; + } + + @Override + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; + } + + @Override + protected String getTileEntityName() { + return "Volumetric Flask Configurator"; + } + + @Override + public CubicObject<String>[] getCustomTextureDirectoryObject() { + String[] aTexData = new String[] { GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_METAL_PANEL_A", + GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_TECH_PANEL_C", + GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + GTPlusPlus.ID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H" }; + CubicObject<String>[] aTextureData = new CubicObject[] { new CubicObject<>(aTexData) }; + return aTextureData; + } +} diff --git a/src/main/java/gtPlusPlus/core/client/CustomTextureSet.java b/src/main/java/gtPlusPlus/core/client/CustomTextureSet.java new file mode 100644 index 0000000000..ce4d9a0320 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/CustomTextureSet.java @@ -0,0 +1,30 @@ +package gtPlusPlus.core.client; + +import gregtech.api.enums.TextureSet; + +public class CustomTextureSet extends TextureSet { + + public static enum TextureSets { + + REFINED(), + GEM_A(), + ENRICHED(), + NUCLEAR; + + private final CustomTextureSet A; + + private TextureSets() { + A = new CustomTextureSet( + this.name() + .toUpperCase()); + } + + public CustomTextureSet get() { + return A; + } + } + + public CustomTextureSet(String aSetName) { + super(aSetName); + } +} diff --git a/src/main/java/gtPlusPlus/core/client/model/ModelDecayChest.java b/src/main/java/gtPlusPlus/core/client/model/ModelDecayChest.java new file mode 100644 index 0000000000..ef0943684c --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/model/ModelDecayChest.java @@ -0,0 +1,45 @@ +package gtPlusPlus.core.client.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelDecayChest extends ModelBase { + + /** The chest lid in the chest's model. */ + public ModelRenderer chestLid = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64); + /** The model of the bottom of the chest. */ + public ModelRenderer chestBelow; + /** The chest's knob in the chest model. */ + public ModelRenderer chestKnob; + + public ModelDecayChest() { + this.chestLid.addBox(0.0F, -5.0F, -14.0F, 14, 5, 14, 0.0F); + this.chestLid.rotationPointX = 1.0F; + this.chestLid.rotationPointY = 7.0F; + this.chestLid.rotationPointZ = 15.0F; + this.chestKnob = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64); + this.chestKnob.addBox(-1.0F, -2.0F, -15.0F, 2, 4, 1, 0.0F); + this.chestKnob.rotationPointX = 8.0F; + this.chestKnob.rotationPointY = 7.0F; + this.chestKnob.rotationPointZ = 15.0F; + this.chestBelow = (new ModelRenderer(this, 0, 19)).setTextureSize(64, 64); + this.chestBelow.addBox(0.0F, 0.0F, 0.0F, 14, 10, 14, 0.0F); + this.chestBelow.rotationPointX = 1.0F; + this.chestBelow.rotationPointY = 6.0F; + this.chestBelow.rotationPointZ = 1.0F; + } + + /** + * This method renders out all parts of the chest model. + */ + public void renderAll() { + this.chestKnob.rotateAngleX = this.chestLid.rotateAngleX; + this.chestLid.render(0.0625F); + this.chestKnob.render(0.0625F); + this.chestBelow.render(0.0625F); + } +} diff --git a/src/main/java/gtPlusPlus/core/client/model/ModelSickBlaze.java b/src/main/java/gtPlusPlus/core/client/model/ModelSickBlaze.java new file mode 100644 index 0000000000..3b5922444d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/model/ModelSickBlaze.java @@ -0,0 +1,87 @@ +package gtPlusPlus.core.client.model; + +import net.minecraft.client.model.ModelBlaze; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelSickBlaze extends ModelBlaze { + + /** The sticks that fly around the Blaze. */ + private ModelRenderer[] blazeSticks = new ModelRenderer[24]; + + private ModelRenderer blazeHead; + + public ModelSickBlaze() { + for (int i = 0; i < this.blazeSticks.length; ++i) { + this.blazeSticks[i] = new ModelRenderer(this, 0, 16); + this.blazeSticks[i].addBox(0.0F, 0.0F, 0.0F, 2, 8, 2); + } + + this.blazeHead = new ModelRenderer(this, 0, 0); + this.blazeHead.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8); + } + + @Override + public int func_78104_a() { + return 8; + } + + /** + * Sets the models various rotation angles then renders the model. + */ + @Override + 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_) { + this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); + this.blazeHead.render(p_78088_7_); + + for (ModelRenderer blazeStick : this.blazeSticks) { + blazeStick.render(p_78088_7_); + } + } + + /** + * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms + * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how + * "far" arms and legs can swing at most. + */ + @Override + public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, + float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { + float f6 = p_78087_3_ * (float) Math.PI * -0.1F; + int i; + + for (i = 0; i < 4; ++i) { + this.blazeSticks[i].rotationPointY = -2.0F + MathHelper.cos((i * 2 + p_78087_3_) * 0.25F); + this.blazeSticks[i].rotationPointX = MathHelper.cos(f6) * 9.0F; + this.blazeSticks[i].rotationPointZ = MathHelper.sin(f6) * 9.0F; + ++f6; + } + + f6 = ((float) Math.PI / 4F) + p_78087_3_ * (float) Math.PI * 0.03F; + + for (i = 4; i < 8; ++i) { + this.blazeSticks[i].rotationPointY = 2.0F + MathHelper.cos((i * 2 + p_78087_3_) * 0.25F); + this.blazeSticks[i].rotationPointX = MathHelper.cos(f6) * 7.0F; + this.blazeSticks[i].rotationPointZ = MathHelper.sin(f6) * 7.0F; + ++f6; + } + + f6 = 0.47123894F + p_78087_3_ * (float) Math.PI * -0.05F; + + for (i = 8; i < 12; ++i) { + this.blazeSticks[i].rotationPointY = 11.0F + MathHelper.cos((i * 1.5F + p_78087_3_) * 0.5F); + this.blazeSticks[i].rotationPointX = MathHelper.cos(f6) * 5.0F; + this.blazeSticks[i].rotationPointZ = MathHelper.sin(f6) * 5.0F; + ++f6; + } + + this.blazeHead.rotateAngleY = p_78087_4_ / (180F / (float) Math.PI); + this.blazeHead.rotateAngleX = p_78087_5_ / (180F / (float) Math.PI); + } +} diff --git a/src/main/java/gtPlusPlus/core/client/model/ModelStaballoyConstruct.java b/src/main/java/gtPlusPlus/core/client/model/ModelStaballoyConstruct.java new file mode 100644 index 0000000000..457bc7a377 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/model/ModelStaballoyConstruct.java @@ -0,0 +1,117 @@ +package gtPlusPlus.core.client.model; + +import net.minecraft.client.model.ModelIronGolem; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelStaballoyConstruct extends ModelIronGolem { + + public ModelStaballoyConstruct() { + this(0.0F); + } + + public ModelStaballoyConstruct(float p_i1161_1_) { + this(p_i1161_1_, -7.0F); + } + + public ModelStaballoyConstruct(float p_i1162_1_, float p_i1162_2_) { + short short1 = 128; + short short2 = 128; + this.ironGolemHead = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.ironGolemHead.setRotationPoint(0.0F, 0.0F + p_i1162_2_, -2.0F); + this.ironGolemHead.setTextureOffset(0, 0) + .addBox(-4.0F, -12.0F, -5.5F, 8, 10, 8, p_i1162_1_); + this.ironGolemHead.setTextureOffset(24, 0) + .addBox(-1.0F, -5.0F, -7.5F, 2, 4, 2, p_i1162_1_); + this.ironGolemBody = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.ironGolemBody.setRotationPoint(0.0F, 0.0F + p_i1162_2_, 0.0F); + this.ironGolemBody.setTextureOffset(0, 40) + .addBox(-9.0F, -2.0F, -6.0F, 18, 12, 11, p_i1162_1_); + this.ironGolemBody.setTextureOffset(0, 70) + .addBox(-4.5F, 10.0F, -3.0F, 9, 5, 6, p_i1162_1_ + 0.5F); + this.ironGolemRightArm = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.ironGolemRightArm.setRotationPoint(0.0F, -7.0F, 0.0F); + this.ironGolemRightArm.setTextureOffset(60, 21) + .addBox(-13.0F, -2.5F, -3.0F, 4, 30, 6, p_i1162_1_); + this.ironGolemLeftArm = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.ironGolemLeftArm.setRotationPoint(0.0F, -7.0F, 0.0F); + this.ironGolemLeftArm.setTextureOffset(60, 58) + .addBox(9.0F, -2.5F, -3.0F, 4, 30, 6, p_i1162_1_); + this.ironGolemLeftLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(short1, short2); + this.ironGolemLeftLeg.setRotationPoint(-4.0F, 18.0F + p_i1162_2_, 0.0F); + this.ironGolemLeftLeg.setTextureOffset(37, 0) + .addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, p_i1162_1_); + this.ironGolemRightLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(short1, short2); + this.ironGolemRightLeg.mirror = true; + this.ironGolemRightLeg.setTextureOffset(60, 0) + .setRotationPoint(5.0F, 18.0F + p_i1162_2_, 0.0F); + this.ironGolemRightLeg.addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, p_i1162_1_); + } + + /** + * Sets the models various rotation angles then renders the model. + */ + @Override + 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_) { + this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); + this.ironGolemHead.render(p_78088_7_); + this.ironGolemBody.render(p_78088_7_); + this.ironGolemLeftLeg.render(p_78088_7_); + this.ironGolemRightLeg.render(p_78088_7_); + this.ironGolemRightArm.render(p_78088_7_); + this.ironGolemLeftArm.render(p_78088_7_); + } + + /** + * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms + * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how + * "far" arms and legs can swing at most. + */ + @Override + public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, + float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { + this.ironGolemHead.rotateAngleY = p_78087_4_ / (180F / (float) Math.PI); + this.ironGolemHead.rotateAngleX = p_78087_5_ / (180F / (float) Math.PI); + this.ironGolemLeftLeg.rotateAngleX = -1.5F * this.func_78172_a(p_78087_1_, 13.0F) * p_78087_2_; + this.ironGolemRightLeg.rotateAngleX = 1.5F * this.func_78172_a(p_78087_1_, 13.0F) * p_78087_2_; + this.ironGolemLeftLeg.rotateAngleY = 0.0F; + this.ironGolemRightLeg.rotateAngleY = 0.0F; + } + + /** + * Used for easily adding entity-dependent animations. The second and third float params here are the same second + * and third as in the setRotationAngles method. + */ + @Override + public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_) { + EntityIronGolem entityirongolem = (EntityIronGolem) p_78086_1_; + int i = entityirongolem.getAttackTimer(); + + if (i > 0) { + this.ironGolemRightArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a(i - p_78086_4_, 10.0F); + this.ironGolemLeftArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a(i - p_78086_4_, 10.0F); + } else { + int j = entityirongolem.getHoldRoseTick(); + + if (j > 0) { + this.ironGolemRightArm.rotateAngleX = -0.8F + 0.025F * this.func_78172_a(j, 70.0F); + this.ironGolemLeftArm.rotateAngleX = 0.0F; + } else { + this.ironGolemRightArm.rotateAngleX = (-0.2F + 1.5F * this.func_78172_a(p_78086_2_, 13.0F)) + * p_78086_3_; + this.ironGolemLeftArm.rotateAngleX = (-0.2F - 1.5F * this.func_78172_a(p_78086_2_, 13.0F)) * p_78086_3_; + } + } + } + + private float func_78172_a(float p_78172_1_, float p_78172_2_) { + return (Math.abs(p_78172_1_ % p_78172_2_ - p_78172_2_ * 0.5F) - p_78172_2_ * 0.25F) / (p_78172_2_ * 0.25F); + } +} diff --git a/src/main/java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java b/src/main/java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java new file mode 100644 index 0000000000..f83844f3e3 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java @@ -0,0 +1,84 @@ +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/main/java/gtPlusPlus/core/client/renderer/CustomOreBlockRenderer.java b/src/main/java/gtPlusPlus/core/client/renderer/CustomOreBlockRenderer.java new file mode 100644 index 0000000000..689f075703 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/renderer/CustomOreBlockRenderer.java @@ -0,0 +1,2469 @@ +package gtPlusPlus.core.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.api.interfaces.ITexture; +import gtPlusPlus.api.interfaces.ITexturedBlock; +import gtPlusPlus.api.objects.Logger; + +public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { + + public static CustomOreBlockRenderer INSTANCE; + public final int mRenderID; + + public CustomOreBlockRenderer() { + INSTANCE = this; + this.mRenderID = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + Logger.INFO("Registered Custom Ore Block Renderer."); + } + + public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + RenderBlocks aRenderer) { + Block tTileEntity = aBlock; + if ((tTileEntity instanceof ITexturedBlock)) { + return renderStandardBlock( + aWorld, + aX, + aY, + aZ, + aBlock, + aRenderer, + new ITexture[][] { ((ITexturedBlock) tTileEntity).getTexture(ForgeDirection.DOWN), + ((ITexturedBlock) tTileEntity).getTexture(ForgeDirection.UP), + ((ITexturedBlock) tTileEntity).getTexture(ForgeDirection.NORTH), + ((ITexturedBlock) tTileEntity).getTexture(ForgeDirection.SOUTH), + ((ITexturedBlock) tTileEntity).getTexture(ForgeDirection.WEST), + ((ITexturedBlock) tTileEntity).getTexture(ForgeDirection.EAST) }); + } + return false; + } + + public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + RenderBlocks aRenderer, ITexture[][] aTextures) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + int l = aBlock.colorMultiplier(aWorld, aX, aY, aZ); + float RED = (float) (l >> 16 & 255) / 255.0F; + float GREEN = (float) (l >> 8 & 255) / 255.0F; + float BLUE = (float) (l & 255) / 255.0F; + + if (Minecraft.isAmbientOcclusionEnabled() && aBlock.getLightValue() == 0) { + if (RenderBlocks.getInstance().partialRenderBounds) { + return INSTANCE.renderStandardBlockWithAmbientOcclusionPartial( + aWorld, + aRenderer, + aTextures, + aBlock, + aX, + aY, + aZ, + RED, + GREEN, + BLUE); + } else { + return INSTANCE.renderStandardBlockWithAmbientOcclusion( + aWorld, + aRenderer, + aTextures, + aBlock, + aX, + aY, + aZ, + RED, + GREEN, + BLUE); + } + } else { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[0], true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[1], true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[2], true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[3], true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[4], true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[5], true); + } + return true; + } + + public static void renderFaceYNeg(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, + ITexture[][] aIcon) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[0], true); + } + + public static void renderFaceYPos(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, + ITexture[][] aIcon) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[1], true); + } + + public static void renderFaceZNeg(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, + ITexture[][] aIcon) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[2], true); + } + + public static void renderFaceZPos(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, + ITexture[][] aIcon) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[3], true); + } + + public static void renderFaceXNeg(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, + ITexture[][] aIcon) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[4], true); + } + + public static void renderFaceXPos(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, + ITexture[][] aIcon) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[5], true); + } + + public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0))) { + return; + } + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); + } + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderYNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public static void renderPositiveYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY + 1, aZ, 1))) { + return; + } + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); + } + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderYPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public static void renderNegativeZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2))) { + return; + } + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); + } + aRenderer.flipTexture = (!aFullBlock); + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public static void renderPositiveZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ + 1, 3))) { + return; + } + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); + } + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderZPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public static void renderNegativeXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX - 1, aY, aZ, 4))) { + return; + } + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); + } + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderXNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public static void renderPositiveXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5))) { + return; + } + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); + } + aRenderer.flipTexture = (!aFullBlock); + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + @Override + public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + ((ITexturedBlock) aBlock).getTexture(ForgeDirection.DOWN), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + ((ITexturedBlock) aBlock).getTexture(ForgeDirection.UP), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + ((ITexturedBlock) aBlock).getTexture(ForgeDirection.NORTH), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + ((ITexturedBlock) aBlock).getTexture(ForgeDirection.SOUTH), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + ((ITexturedBlock) aBlock).getTexture(ForgeDirection.WEST), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + ((ITexturedBlock) aBlock).getTexture(ForgeDirection.EAST), + true); + Tessellator.instance.draw(); + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + @Override + public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, + RenderBlocks aRenderer) { + blockAccess = aWorld; + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } + + @Override + public boolean shouldRender3DInInventory(int aModel) { + return true; + } + + @Override + public int getRenderId() { + return this.mRenderID; + } + + public void setRenderBounds(double p_147782_1_, double p_147782_3_, double p_147782_5_, double p_147782_7_, + double p_147782_9_, double p_147782_11_) { + if (!this.lockBlockBounds) { + this.renderMinX = p_147782_1_; + this.renderMaxX = p_147782_7_; + this.renderMinY = p_147782_3_; + this.renderMaxY = p_147782_9_; + this.renderMinZ = p_147782_5_; + this.renderMaxZ = p_147782_11_; + this.partialRenderBounds = this.minecraftRB.gameSettings.ambientOcclusion >= 2 + && (this.renderMinX > 0.0D || this.renderMaxX < 1.0D + || this.renderMinY > 0.0D + || this.renderMaxY < 1.0D + || this.renderMinZ > 0.0D + || this.renderMaxZ < 1.0D); + } + } + + /** + * Like setRenderBounds, but automatically pulling the bounds from the given Block. + */ + public void setRenderBoundsFromBlock(Block block) { + if (!this.lockBlockBounds) { + this.renderMinX = block.getBlockBoundsMinX(); + this.renderMaxX = block.getBlockBoundsMaxX(); + this.renderMinY = block.getBlockBoundsMinY(); + this.renderMaxY = block.getBlockBoundsMaxY(); + this.renderMinZ = block.getBlockBoundsMinZ(); + this.renderMaxZ = block.getBlockBoundsMaxZ(); + this.partialRenderBounds = this.minecraftRB.gameSettings.ambientOcclusion >= 2 + && (this.renderMinX > 0.0D || this.renderMaxX < 1.0D + || this.renderMinY > 0.0D + || this.renderMaxY < 1.0D + || this.renderMinZ > 0.0D + || this.renderMaxZ < 1.0D); + } + } + + /** + * Vanilla Variables + */ + + /** The minimum X value for rendering (default 0.0). */ + public double renderMinX; + /** The maximum X value for rendering (default 1.0). */ + public double renderMaxX; + /** The minimum Y value for rendering (default 0.0). */ + public double renderMinY; + /** The maximum Y value for rendering (default 1.0). */ + public double renderMaxY; + /** The minimum Z value for rendering (default 0.0). */ + public double renderMinZ; + /** The maximum Z value for rendering (default 1.0). */ + public double renderMaxZ; + + public boolean lockBlockBounds; + public boolean partialRenderBounds; + public final Minecraft minecraftRB = RenderBlocks.getInstance().minecraftRB; + public int uvRotateEast; + public int uvRotateWest; + public int uvRotateSouth; + public int uvRotateNorth; + public int uvRotateTop; + public int uvRotateBottom; + /** Whether ambient occlusion is enabled or not */ + public boolean enableAO; + /** Used as a scratch variable for ambient occlusion on the north/bottom/east corner. */ + public float aoLightValueScratchXYZNNN; + /** Used as a scratch variable for ambient occlusion between the bottom face and the north face. */ + public float aoLightValueScratchXYNN; + /** Used as a scratch variable for ambient occlusion on the north/bottom/west corner. */ + public float aoLightValueScratchXYZNNP; + /** Used as a scratch variable for ambient occlusion between the bottom face and the east face. */ + public float aoLightValueScratchYZNN; + /** Used as a scratch variable for ambient occlusion between the bottom face and the west face. */ + public float aoLightValueScratchYZNP; + /** Used as a scratch variable for ambient occlusion on the south/bottom/east corner. */ + public float aoLightValueScratchXYZPNN; + /** Used as a scratch variable for ambient occlusion between the bottom face and the south face. */ + public float aoLightValueScratchXYPN; + /** Used as a scratch variable for ambient occlusion on the south/bottom/west corner. */ + public float aoLightValueScratchXYZPNP; + /** Used as a scratch variable for ambient occlusion on the north/top/east corner. */ + public float aoLightValueScratchXYZNPN; + /** Used as a scratch variable for ambient occlusion between the top face and the north face. */ + public float aoLightValueScratchXYNP; + /** Used as a scratch variable for ambient occlusion on the north/top/west corner. */ + public float aoLightValueScratchXYZNPP; + /** Used as a scratch variable for ambient occlusion between the top face and the east face. */ + public float aoLightValueScratchYZPN; + /** Used as a scratch variable for ambient occlusion on the south/top/east corner. */ + public float aoLightValueScratchXYZPPN; + /** Used as a scratch variable for ambient occlusion between the top face and the south face. */ + public float aoLightValueScratchXYPP; + /** Used as a scratch variable for ambient occlusion between the top face and the west face. */ + public float aoLightValueScratchYZPP; + /** Used as a scratch variable for ambient occlusion on the south/top/west corner. */ + public float aoLightValueScratchXYZPPP; + /** Used as a scratch variable for ambient occlusion between the north face and the east face. */ + public float aoLightValueScratchXZNN; + /** Used as a scratch variable for ambient occlusion between the south face and the east face. */ + public float aoLightValueScratchXZPN; + /** Used as a scratch variable for ambient occlusion between the north face and the west face. */ + public float aoLightValueScratchXZNP; + /** Used as a scratch variable for ambient occlusion between the south face and the west face. */ + public float aoLightValueScratchXZPP; + /** Ambient occlusion brightness XYZNNN */ + public int aoBrightnessXYZNNN; + /** Ambient occlusion brightness XYNN */ + public int aoBrightnessXYNN; + /** Ambient occlusion brightness XYZNNP */ + public int aoBrightnessXYZNNP; + /** Ambient occlusion brightness YZNN */ + public int aoBrightnessYZNN; + /** Ambient occlusion brightness YZNP */ + public int aoBrightnessYZNP; + /** Ambient occlusion brightness XYZPNN */ + public int aoBrightnessXYZPNN; + /** Ambient occlusion brightness XYPN */ + public int aoBrightnessXYPN; + /** Ambient occlusion brightness XYZPNP */ + public int aoBrightnessXYZPNP; + /** Ambient occlusion brightness XYZNPN */ + public int aoBrightnessXYZNPN; + /** Ambient occlusion brightness XYNP */ + public int aoBrightnessXYNP; + /** Ambient occlusion brightness XYZNPP */ + public int aoBrightnessXYZNPP; + /** Ambient occlusion brightness YZPN */ + public int aoBrightnessYZPN; + /** Ambient occlusion brightness XYZPPN */ + public int aoBrightnessXYZPPN; + /** Ambient occlusion brightness XYPP */ + public int aoBrightnessXYPP; + /** Ambient occlusion brightness YZPP */ + public int aoBrightnessYZPP; + /** Ambient occlusion brightness XYZPPP */ + public int aoBrightnessXYZPPP; + /** Ambient occlusion brightness XZNN */ + public int aoBrightnessXZNN; + /** Ambient occlusion brightness XZPN */ + public int aoBrightnessXZPN; + /** Ambient occlusion brightness XZNP */ + public int aoBrightnessXZNP; + /** Ambient occlusion brightness XZPP */ + public int aoBrightnessXZPP; + /** Brightness top left */ + public int brightnessTopLeft; + /** Brightness bottom left */ + public int brightnessBottomLeft; + /** Brightness bottom right */ + public int brightnessBottomRight; + /** Brightness top right */ + public int brightnessTopRight; + /** Red color value for the top left corner */ + public float colorRedTopLeft; + /** Red color value for the bottom left corner */ + public float colorRedBottomLeft; + /** Red color value for the bottom right corner */ + public float colorRedBottomRight; + /** Red color value for the top right corner */ + public float colorRedTopRight; + /** Green color value for the top left corner */ + public float colorGreenTopLeft; + /** Green color value for the bottom left corner */ + public float colorGreenBottomLeft; + /** Green color value for the bottom right corner */ + public float colorGreenBottomRight; + /** Green color value for the top right corner */ + public float colorGreenTopRight; + /** Blue color value for the top left corner */ + public float colorBlueTopLeft; + /** Blue color value for the bottom left corner */ + public float colorBlueBottomLeft; + /** Blue color value for the bottom right corner */ + public float colorBlueBottomRight; + /** Blue color value for the top right corner */ + public float colorBlueTopRight; + /** If set to >=0, all block faces will be rendered using this texture index */ + public IIcon overrideBlockTexture; + + /** + * Clear override block texture + */ + public void clearOverrideBlockTexture() { + this.overrideBlockTexture = null; + } + + public boolean hasOverrideBlockTexture() { + return this.overrideBlockTexture != null; + } + + public IIcon getBlockIcon(Block block, IBlockAccess access, int x, int y, int z, int side) { + return this.getIconSafe(block.getIcon(access, x, y, z, side)); + } + + public IIcon getBlockIconFromSideAndMetadata(Block block, int side, int meta) { + return this.getIconSafe(block.getIcon(side, meta)); + } + + public IIcon getBlockIconFromSide(Block block, int side) { + return this.getIconSafe(block.getBlockTextureFromSide(side)); + } + + public IIcon getBlockIcon(Block block) { + return this.getIconSafe(block.getBlockTextureFromSide(1)); + } + + public IIcon getIconSafe(IIcon iicon) { + if (iicon == null) { + iicon = ((TextureMap) Minecraft.getMinecraft() + .getTextureManager() + .getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + } + + return (IIcon) iicon; + } + + IBlockAccess blockAccess = RenderBlocks.getInstance().blockAccess; + + public boolean renderStandardBlockWithAmbientOcclusion(IBlockAccess aWorld, RenderBlocks aRenderer, + ITexture[][] aTextures, Block block, int xPos, int yPos, int zPos, float R, float G, float B) { + this.enableAO = true; + boolean flag = false; + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + boolean flag1 = true; + int l = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(983055); + + if (this.getBlockIcon(block) + .getIconName() + .equals("grass_top")) { + flag1 = false; + } else if (this.hasOverrideBlockTexture()) { + flag1 = false; + } + + boolean flag2; + boolean flag3; + boolean flag4; + boolean flag5; + int i1; + float f7; + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos - 1, zPos, 0)) { + if (this.renderMinY <= 0.0D) { + --yPos; + } + + this.aoBrightnessXYNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + this.aoLightValueScratchXYNN = blockAccess.getBlock(xPos - 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = blockAccess.getBlock(xPos, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = blockAccess.getBlock(xPos, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPN = blockAccess.getBlock(xPos + 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + flag2 = blockAccess.getBlock(xPos + 1, yPos - 1, zPos) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos - 1, zPos) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos - 1, zPos + 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos - 1) + .getCanBlockGrass(); + + if (!flag5 && !flag3) { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXYNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXYNN; + } else { + this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos - 1, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos - 1); + } + + if (!flag4 && !flag3) { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXYNN; + this.aoBrightnessXYZNNP = this.aoBrightnessXYNN; + } else { + this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos - 1, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos + 1); + } + + if (!flag5 && !flag2) { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXYPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXYPN; + } else { + this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos + 1, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos - 1); + } + + if (!flag4 && !flag2) { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXYPN; + this.aoBrightnessXYZPNP = this.aoBrightnessXYPN; + } else { + this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos + 1, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos + 1); + } + + if (this.renderMinY <= 0.0D) { + ++yPos; + } + + i1 = l; + + if (this.renderMinY <= 0.0D || !blockAccess.getBlock(xPos, yPos - 1, zPos) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + } + + f7 = blockAccess.getBlock(xPos, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXYNN + this.aoLightValueScratchYZNP + f7) + / 4.0F; + f6 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXYPN) + / 4.0F; + f5 = (f7 + this.aoLightValueScratchYZNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNN) + / 4.0F; + f4 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNN + f7 + this.aoLightValueScratchYZNN) + / 4.0F; + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXYNN, this.aoBrightnessYZNP, i1); + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXYPN, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYPN, this.aoBrightnessXYZPNN, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNN, this.aoBrightnessYZNN, i1); + + if (flag1) { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R + * 0.5F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G + * 0.5F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B + * 0.5F; + } else { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.5F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.5F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.5F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + CustomOreBlockRenderer.renderFaceYNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos + 1, zPos, 1)) { + if (this.renderMaxY >= 1.0D) { + ++yPos; + } + + this.aoBrightnessXYNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessXYPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + this.aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessYZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoLightValueScratchXYNP = blockAccess.getBlock(xPos - 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = blockAccess.getBlock(xPos + 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = blockAccess.getBlock(xPos, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = blockAccess.getBlock(xPos, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + flag2 = blockAccess.getBlock(xPos + 1, yPos + 1, zPos) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos + 1, zPos) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos + 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos + 1, zPos - 1) + .getCanBlockGrass(); + + if (!flag5 && !flag3) { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXYNP; + this.aoBrightnessXYZNPN = this.aoBrightnessXYNP; + } else { + this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos - 1, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos - 1); + } + + if (!flag5 && !flag2) { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXYPP; + this.aoBrightnessXYZPPN = this.aoBrightnessXYPP; + } else { + this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos + 1, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos - 1); + } + + if (!flag4 && !flag3) { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXYNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXYNP; + } else { + this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos - 1, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos + 1); + } + + if (!flag4 && !flag2) { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXYPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXYPP; + } else { + this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos + 1, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos + 1); + } + + if (this.renderMaxY >= 1.0D) { + --yPos; + } + + i1 = l; + + if (this.renderMaxY >= 1.0D || !blockAccess.getBlock(xPos, yPos + 1, zPos) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + } + + f7 = blockAccess.getBlock(xPos, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + f6 = (this.aoLightValueScratchXYZNPP + this.aoLightValueScratchXYNP + this.aoLightValueScratchYZPP + f7) + / 4.0F; + f3 = (this.aoLightValueScratchYZPP + f7 + this.aoLightValueScratchXYZPPP + this.aoLightValueScratchXYPP) + / 4.0F; + f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPN) + / 4.0F; + f5 = (this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) + / 4.0F; + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNPP, this.aoBrightnessXYNP, this.aoBrightnessYZPP, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXYZPPP, this.aoBrightnessXYPP, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXYPP, this.aoBrightnessXYZPPN, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNP, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B; + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + CustomOreBlockRenderer.renderFaceYPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + flag = true; + } + + IIcon iicon; + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos - 1, 2)) { + if (this.renderMinZ <= 0.0D) { + --zPos; + } + + this.aoLightValueScratchXZNN = blockAccess.getBlock(xPos - 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = blockAccess.getBlock(xPos, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = blockAccess.getBlock(xPos, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = blockAccess.getBlock(xPos + 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXZNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + this.aoBrightnessXZPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + flag2 = blockAccess.getBlock(xPos + 1, yPos, zPos - 1) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos, zPos - 1) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos - 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos - 1) + .getCanBlockGrass(); + + if (!flag3 && !flag5) { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos - 1, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos - 1, zPos); + } + + if (!flag3 && !flag4) { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos - 1, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos + 1, zPos); + } + + if (!flag2 && !flag5) { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos + 1, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos - 1, zPos); + } + + if (!flag2 && !flag4) { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos + 1, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos + 1, zPos); + } + + if (this.renderMinZ <= 0.0D) { + ++zPos; + } + + i1 = l; + + if (this.renderMinZ <= 0.0D || !blockAccess.getBlock(xPos, yPos, zPos - 1) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + } + + f7 = blockAccess.getBlock(xPos, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXZNN + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) + / 4.0F; + f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXZPN + this.aoLightValueScratchXYZPPN) + / 4.0F; + f5 = (this.aoLightValueScratchYZNN + f7 + this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXZPN) + / 4.0F; + f6 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXZNN + this.aoLightValueScratchYZNN + f7) + / 4.0F; + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYZPNN, this.aoBrightnessXZPN, i1); + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXZNN, this.aoBrightnessYZNN, i1); + + if (flag1) { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R + * 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G + * 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B + * 0.8F; + } else { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 2); + CustomOreBlockRenderer.renderFaceZNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass && iicon.getIconName() + .equals("grass_side") && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceZNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos + 1, 3)) { + if (this.renderMaxZ >= 1.0D) { + ++zPos; + } + + this.aoLightValueScratchXZNP = blockAccess.getBlock(xPos - 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = blockAccess.getBlock(xPos + 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = blockAccess.getBlock(xPos, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = blockAccess.getBlock(xPos, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXZNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessXZPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + this.aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessYZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + flag2 = blockAccess.getBlock(xPos + 1, yPos, zPos + 1) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos, zPos + 1) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos + 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos + 1) + .getCanBlockGrass(); + + if (!flag3 && !flag5) { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos - 1, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos - 1, zPos); + } + + if (!flag3 && !flag4) { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos - 1, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos + 1, zPos); + } + + if (!flag2 && !flag5) { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos + 1, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos - 1, zPos); + } + + if (!flag2 && !flag4) { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos + 1, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos + 1, zPos); + } + + if (this.renderMaxZ >= 1.0D) { + --zPos; + } + + i1 = l; + + if (this.renderMaxZ >= 1.0D || !blockAccess.getBlock(xPos, yPos, zPos + 1) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + } + + f7 = blockAccess.getBlock(xPos, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXZNP + this.aoLightValueScratchXYZNPP + f7 + this.aoLightValueScratchYZPP) + / 4.0F; + f6 = (f7 + this.aoLightValueScratchYZPP + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYZPPP) + / 4.0F; + f5 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXZPP) + / 4.0F; + f4 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXZNP + this.aoLightValueScratchYZNP + f7) + / 4.0F; + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYZNPP, this.aoBrightnessYZPP, i1); + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXZPP, this.aoBrightnessXYZPPP, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, this.aoBrightnessYZNP, i1); + + if (flag1) { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R + * 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G + * 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B + * 0.8F; + } else { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 3); + CustomOreBlockRenderer.renderFaceZPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass && iicon.getIconName() + .equals("grass_side") && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceZPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos - 1, yPos, zPos, 4)) { + if (this.renderMinX <= 0.0D) { + --xPos; + } + + this.aoLightValueScratchXYNN = blockAccess.getBlock(xPos, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNN = blockAccess.getBlock(xPos, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNP = blockAccess.getBlock(xPos, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYNP = blockAccess.getBlock(xPos, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessXZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessXZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoBrightnessXYNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + flag2 = blockAccess.getBlock(xPos - 1, yPos + 1, zPos) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos - 1, zPos) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos - 1, yPos, zPos - 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos - 1, yPos, zPos + 1) + .getCanBlockGrass(); + + if (!flag4 && !flag3) { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos, yPos - 1, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos - 1); + } + + if (!flag5 && !flag3) { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos, yPos - 1, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos + 1); + } + + if (!flag4 && !flag2) { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos, yPos + 1, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos - 1); + } + + if (!flag5 && !flag2) { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos, yPos + 1, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos + 1); + } + + if (this.renderMinX <= 0.0D) { + ++xPos; + } + + i1 = l; + + if (this.renderMinX <= 0.0D || !blockAccess.getBlock(xPos - 1, yPos, zPos) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + } + + f7 = blockAccess.getBlock(xPos - 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + f6 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNP + f7 + this.aoLightValueScratchXZNP) + / 4.0F; + f3 = (f7 + this.aoLightValueScratchXZNP + this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPP) + / 4.0F; + f4 = (this.aoLightValueScratchXZNN + f7 + this.aoLightValueScratchXYZNPN + this.aoLightValueScratchXYNP) + / 4.0F; + f5 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXYNN + this.aoLightValueScratchXZNN + f7) + / 4.0F; + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYNP, this.aoBrightnessXYZNPP, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessXYNP, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXYNN, this.aoBrightnessXZNN, i1); + + if (flag1) { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R + * 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G + * 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B + * 0.6F; + } else { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 4); + CustomOreBlockRenderer.renderFaceXNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass && iicon.getIconName() + .equals("grass_side") && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceXNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos + 1, yPos, zPos, 5)) { + if (this.renderMaxX >= 1.0D) { + ++xPos; + } + + this.aoLightValueScratchXYPN = blockAccess.getBlock(xPos, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = blockAccess.getBlock(xPos, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = blockAccess.getBlock(xPos, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = blockAccess.getBlock(xPos, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessXZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessXZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoBrightnessXYPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + flag2 = blockAccess.getBlock(xPos + 1, yPos + 1, zPos) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos + 1, yPos - 1, zPos) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos + 1, yPos, zPos + 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos + 1, yPos, zPos - 1) + .getCanBlockGrass(); + + if (!flag3 && !flag5) { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos, yPos - 1, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos - 1); + } + + if (!flag3 && !flag4) { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos, yPos - 1, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos + 1); + } + + if (!flag2 && !flag5) { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos, yPos + 1, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos - 1); + } + + if (!flag2 && !flag4) { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos, yPos + 1, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos + 1); + } + + if (this.renderMaxX >= 1.0D) { + --xPos; + } + + i1 = l; + + if (this.renderMaxX >= 1.0D || !blockAccess.getBlock(xPos + 1, yPos, zPos) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + } + + f7 = blockAccess.getBlock(xPos + 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNP + f7 + this.aoLightValueScratchXZPP) + / 4.0F; + f4 = (this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXZPN + f7) + / 4.0F; + f5 = (this.aoLightValueScratchXZPN + f7 + this.aoLightValueScratchXYZPPN + this.aoLightValueScratchXYPP) + / 4.0F; + f6 = (f7 + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPP) + / 4.0F; + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYPN, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZPP, this.aoBrightnessXYPP, this.aoBrightnessXYZPPP, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, this.aoBrightnessXYPP, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZPNN, this.aoBrightnessXYPN, this.aoBrightnessXZPN, i1); + + if (flag1) { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R + * 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G + * 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B + * 0.6F; + } else { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 5); + CustomOreBlockRenderer.renderFaceXPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass && iicon.getIconName() + .equals("grass_side") && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceXPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + this.enableAO = false; + return flag; + } + + /** + * Renders non-full-cube block with ambient occusion. Args: block, x, y, z, red, green, blue (lighting) + */ + public boolean renderStandardBlockWithAmbientOcclusionPartial(IBlockAccess aWorld, RenderBlocks aRenderer, + ITexture[][] aTextures, Block block, int xPos, int yPos, int zPos, float R, float G, float B) { + this.enableAO = true; + boolean flag = false; + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + boolean flag1 = true; + int l = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(983055); + + if (this.getBlockIcon(block) + .getIconName() + .equals("grass_top")) { + flag1 = false; + } else if (this.hasOverrideBlockTexture()) { + flag1 = false; + } + + boolean flag2; + boolean flag3; + boolean flag4; + boolean flag5; + int i1; + float f7; + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos - 1, zPos, 0)) { + if (this.renderMinY <= 0.0D) { + --yPos; + } + + this.aoBrightnessXYNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + this.aoLightValueScratchXYNN = blockAccess.getBlock(xPos - 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = blockAccess.getBlock(xPos, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = blockAccess.getBlock(xPos, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPN = blockAccess.getBlock(xPos + 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + flag2 = blockAccess.getBlock(xPos + 1, yPos - 1, zPos) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos - 1, zPos) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos - 1, zPos + 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos - 1) + .getCanBlockGrass(); + + if (!flag5 && !flag3) { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXYNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXYNN; + } else { + this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos - 1, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos - 1); + } + + if (!flag4 && !flag3) { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXYNN; + this.aoBrightnessXYZNNP = this.aoBrightnessXYNN; + } else { + this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos - 1, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos + 1); + } + + if (!flag5 && !flag2) { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXYPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXYPN; + } else { + this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos + 1, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos - 1); + } + + if (!flag4 && !flag2) { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXYPN; + this.aoBrightnessXYZPNP = this.aoBrightnessXYPN; + } else { + this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos + 1, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos + 1); + } + + if (this.renderMinY <= 0.0D) { + ++yPos; + } + + i1 = l; + + if (this.renderMinY <= 0.0D || !blockAccess.getBlock(xPos, yPos - 1, zPos) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + } + + f7 = blockAccess.getBlock(xPos, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXYNN + this.aoLightValueScratchYZNP + f7) + / 4.0F; + f6 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXYPN) + / 4.0F; + f5 = (f7 + this.aoLightValueScratchYZNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNN) + / 4.0F; + f4 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNN + f7 + this.aoLightValueScratchYZNN) + / 4.0F; + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXYNN, this.aoBrightnessYZNP, i1); + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXYPN, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYPN, this.aoBrightnessXYZPNN, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNN, this.aoBrightnessYZNN, i1); + + if (flag1) { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R + * 0.5F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G + * 0.5F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B + * 0.5F; + } else { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.5F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.5F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.5F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + CustomOreBlockRenderer.renderFaceYNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos + 1, zPos, 1)) { + if (this.renderMaxY >= 1.0D) { + ++yPos; + } + + this.aoBrightnessXYNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessXYPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + this.aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessYZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoLightValueScratchXYNP = blockAccess.getBlock(xPos - 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = blockAccess.getBlock(xPos + 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = blockAccess.getBlock(xPos, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = blockAccess.getBlock(xPos, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + flag2 = blockAccess.getBlock(xPos + 1, yPos + 1, zPos) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos + 1, zPos) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos + 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos + 1, zPos - 1) + .getCanBlockGrass(); + + if (!flag5 && !flag3) { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXYNP; + this.aoBrightnessXYZNPN = this.aoBrightnessXYNP; + } else { + this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos - 1, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos - 1); + } + + if (!flag5 && !flag2) { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXYPP; + this.aoBrightnessXYZPPN = this.aoBrightnessXYPP; + } else { + this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos + 1, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos - 1); + } + + if (!flag4 && !flag3) { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXYNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXYNP; + } else { + this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos - 1, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos + 1); + } + + if (!flag4 && !flag2) { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXYPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXYPP; + } else { + this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos + 1, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos + 1); + } + + if (this.renderMaxY >= 1.0D) { + --yPos; + } + + i1 = l; + + if (this.renderMaxY >= 1.0D || !blockAccess.getBlock(xPos, yPos + 1, zPos) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + } + + f7 = blockAccess.getBlock(xPos, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + f6 = (this.aoLightValueScratchXYZNPP + this.aoLightValueScratchXYNP + this.aoLightValueScratchYZPP + f7) + / 4.0F; + f3 = (this.aoLightValueScratchYZPP + f7 + this.aoLightValueScratchXYZPPP + this.aoLightValueScratchXYPP) + / 4.0F; + f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPN) + / 4.0F; + f5 = (this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) + / 4.0F; + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNPP, this.aoBrightnessXYNP, this.aoBrightnessYZPP, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXYZPPP, this.aoBrightnessXYPP, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXYPP, this.aoBrightnessXYZPPN, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNP, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B; + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + CustomOreBlockRenderer.renderFaceYPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + flag = true; + } + + float f8; + float f9; + float f10; + float f11; + int j1; + int k1; + int l1; + int i2; + IIcon iicon; + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos - 1, 2)) { + if (this.renderMinZ <= 0.0D) { + --zPos; + } + + this.aoLightValueScratchXZNN = blockAccess.getBlock(xPos - 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = blockAccess.getBlock(xPos, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = blockAccess.getBlock(xPos, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = blockAccess.getBlock(xPos + 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXZNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + this.aoBrightnessXZPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + flag2 = blockAccess.getBlock(xPos + 1, yPos, zPos - 1) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos, zPos - 1) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos - 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos - 1) + .getCanBlockGrass(); + + if (!flag3 && !flag5) { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos - 1, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos - 1, zPos); + } + + if (!flag3 && !flag4) { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos - 1, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos + 1, zPos); + } + + if (!flag2 && !flag5) { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos + 1, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos - 1, zPos); + } + + if (!flag2 && !flag4) { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos + 1, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos + 1, zPos); + } + + if (this.renderMinZ <= 0.0D) { + ++zPos; + } + + i1 = l; + + if (this.renderMinZ <= 0.0D || !blockAccess.getBlock(xPos, yPos, zPos - 1) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + } + + f7 = blockAccess.getBlock(xPos, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXZNN + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) + / 4.0F; + f9 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXZPN + this.aoLightValueScratchXYZPPN) + / 4.0F; + f10 = (this.aoLightValueScratchYZNN + f7 + this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXZPN) + / 4.0F; + f11 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXZNN + this.aoLightValueScratchYZNN + f7) + / 4.0F; + f3 = (float) ((double) f8 * this.renderMaxY * (1.0D - this.renderMinX) + + (double) f9 * this.renderMaxY * this.renderMinX + + (double) f10 * (1.0D - this.renderMaxY) * this.renderMinX + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); + f4 = (float) ((double) f8 * this.renderMaxY * (1.0D - this.renderMaxX) + + (double) f9 * this.renderMaxY * this.renderMaxX + + (double) f10 * (1.0D - this.renderMaxY) * this.renderMaxX + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); + f5 = (float) ((double) f8 * this.renderMinY * (1.0D - this.renderMaxX) + + (double) f9 * this.renderMinY * this.renderMaxX + + (double) f10 * (1.0D - this.renderMinY) * this.renderMaxX + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); + f6 = (float) ((double) f8 * this.renderMinY * (1.0D - this.renderMinX) + + (double) f9 * this.renderMinY * this.renderMinX + + (double) f10 * (1.0D - this.renderMinY) * this.renderMinX + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); + j1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + k1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, i1); + l1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYZPNN, this.aoBrightnessXZPN, i1); + i2 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXZNN, this.aoBrightnessYZNN, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + k1, + l1, + i2, + this.renderMaxY * (1.0D - this.renderMinX), + this.renderMaxY * this.renderMinX, + (1.0D - this.renderMaxY) * this.renderMinX, + (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + k1, + l1, + i2, + this.renderMaxY * (1.0D - this.renderMaxX), + this.renderMaxY * this.renderMaxX, + (1.0D - this.renderMaxY) * this.renderMaxX, + (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); + this.brightnessBottomRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + k1, + l1, + i2, + this.renderMinY * (1.0D - this.renderMaxX), + this.renderMinY * this.renderMaxX, + (1.0D - this.renderMinY) * this.renderMaxX, + (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); + this.brightnessTopRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + k1, + l1, + i2, + this.renderMinY * (1.0D - this.renderMinX), + this.renderMinY * this.renderMinX, + (1.0D - this.renderMinY) * this.renderMinX, + (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); + + if (flag1) { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R + * 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G + * 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B + * 0.8F; + } else { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 2); + CustomOreBlockRenderer.renderFaceZNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass && iicon.getIconName() + .equals("grass_side") && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceZNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos + 1, 3)) { + if (this.renderMaxZ >= 1.0D) { + ++zPos; + } + + this.aoLightValueScratchXZNP = blockAccess.getBlock(xPos - 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = blockAccess.getBlock(xPos + 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = blockAccess.getBlock(xPos, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = blockAccess.getBlock(xPos, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXZNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessXZPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + this.aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessYZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + flag2 = blockAccess.getBlock(xPos + 1, yPos, zPos + 1) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos, zPos + 1) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos + 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos + 1) + .getCanBlockGrass(); + + if (!flag3 && !flag5) { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos - 1, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos - 1, zPos); + } + + if (!flag3 && !flag4) { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos - 1, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos + 1, zPos); + } + + if (!flag2 && !flag5) { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos + 1, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos - 1, zPos); + } + + if (!flag2 && !flag4) { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos + 1, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos + 1, zPos); + } + + if (this.renderMaxZ >= 1.0D) { + --zPos; + } + + i1 = l; + + if (this.renderMaxZ >= 1.0D || !blockAccess.getBlock(xPos, yPos, zPos + 1) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + } + + f7 = blockAccess.getBlock(xPos, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXZNP + this.aoLightValueScratchXYZNPP + f7 + this.aoLightValueScratchYZPP) + / 4.0F; + f9 = (f7 + this.aoLightValueScratchYZPP + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYZPPP) + / 4.0F; + f10 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXZPP) + / 4.0F; + f11 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXZNP + this.aoLightValueScratchYZNP + f7) + / 4.0F; + f3 = (float) ((double) f8 * this.renderMaxY * (1.0D - this.renderMinX) + + (double) f9 * this.renderMaxY * this.renderMinX + + (double) f10 * (1.0D - this.renderMaxY) * this.renderMinX + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); + f4 = (float) ((double) f8 * this.renderMinY * (1.0D - this.renderMinX) + + (double) f9 * this.renderMinY * this.renderMinX + + (double) f10 * (1.0D - this.renderMinY) * this.renderMinX + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); + f5 = (float) ((double) f8 * this.renderMinY * (1.0D - this.renderMaxX) + + (double) f9 * this.renderMinY * this.renderMaxX + + (double) f10 * (1.0D - this.renderMinY) * this.renderMaxX + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); + f6 = (float) ((double) f8 * this.renderMaxY * (1.0D - this.renderMaxX) + + (double) f9 * this.renderMaxY * this.renderMaxX + + (double) f10 * (1.0D - this.renderMaxY) * this.renderMaxX + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); + j1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYZNPP, this.aoBrightnessYZPP, i1); + k1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXZPP, this.aoBrightnessXYZPPP, i1); + l1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + i2 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, this.aoBrightnessYZNP, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + this.renderMaxY * (1.0D - this.renderMinX), + (1.0D - this.renderMaxY) * (1.0D - this.renderMinX), + (1.0D - this.renderMaxY) * this.renderMinX, + this.renderMaxY * this.renderMinX); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + this.renderMinY * (1.0D - this.renderMinX), + (1.0D - this.renderMinY) * (1.0D - this.renderMinX), + (1.0D - this.renderMinY) * this.renderMinX, + this.renderMinY * this.renderMinX); + this.brightnessBottomRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + this.renderMinY * (1.0D - this.renderMaxX), + (1.0D - this.renderMinY) * (1.0D - this.renderMaxX), + (1.0D - this.renderMinY) * this.renderMaxX, + this.renderMinY * this.renderMaxX); + this.brightnessTopRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + this.renderMaxY * (1.0D - this.renderMaxX), + (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX), + (1.0D - this.renderMaxY) * this.renderMaxX, + this.renderMaxY * this.renderMaxX); + + if (flag1) { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R + * 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G + * 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B + * 0.8F; + } else { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 3); + CustomOreBlockRenderer.renderFaceZPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass && iicon.getIconName() + .equals("grass_side") && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceZPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos - 1, yPos, zPos, 4)) { + if (this.renderMinX <= 0.0D) { + --xPos; + } + + this.aoLightValueScratchXYNN = blockAccess.getBlock(xPos, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNN = blockAccess.getBlock(xPos, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNP = blockAccess.getBlock(xPos, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYNP = blockAccess.getBlock(xPos, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessXZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessXZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoBrightnessXYNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + flag2 = blockAccess.getBlock(xPos - 1, yPos + 1, zPos) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos - 1, zPos) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos - 1, yPos, zPos - 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos - 1, yPos, zPos + 1) + .getCanBlockGrass(); + + if (!flag4 && !flag3) { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos, yPos - 1, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos - 1); + } + + if (!flag5 && !flag3) { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos, yPos - 1, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos + 1); + } + + if (!flag4 && !flag2) { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos, yPos + 1, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos - 1); + } + + if (!flag5 && !flag2) { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos, yPos + 1, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos + 1); + } + + if (this.renderMinX <= 0.0D) { + ++xPos; + } + + i1 = l; + + if (this.renderMinX <= 0.0D || !blockAccess.getBlock(xPos - 1, yPos, zPos) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + } + + f7 = blockAccess.getBlock(xPos - 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNP + f7 + this.aoLightValueScratchXZNP) + / 4.0F; + f9 = (f7 + this.aoLightValueScratchXZNP + this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPP) + / 4.0F; + f10 = (this.aoLightValueScratchXZNN + f7 + this.aoLightValueScratchXYZNPN + this.aoLightValueScratchXYNP) + / 4.0F; + f11 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXYNN + this.aoLightValueScratchXZNN + f7) + / 4.0F; + f3 = (float) ((double) f9 * this.renderMaxY * this.renderMaxZ + + (double) f10 * this.renderMaxY * (1.0D - this.renderMaxZ) + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ) + + (double) f8 * (1.0D - this.renderMaxY) * this.renderMaxZ); + f4 = (float) ((double) f9 * this.renderMaxY * this.renderMinZ + + (double) f10 * this.renderMaxY * (1.0D - this.renderMinZ) + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ) + + (double) f8 * (1.0D - this.renderMaxY) * this.renderMinZ); + f5 = (float) ((double) f9 * this.renderMinY * this.renderMinZ + + (double) f10 * this.renderMinY * (1.0D - this.renderMinZ) + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinZ) + + (double) f8 * (1.0D - this.renderMinY) * this.renderMinZ); + f6 = (float) ((double) f9 * this.renderMinY * this.renderMaxZ + + (double) f10 * this.renderMinY * (1.0D - this.renderMaxZ) + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ) + + (double) f8 * (1.0D - this.renderMinY) * this.renderMaxZ); + j1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, i1); + k1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYNP, this.aoBrightnessXYZNPP, i1); + l1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessXYNP, i1); + i2 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXYNN, this.aoBrightnessXZNN, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .mixAoBrightness( + k1, + l1, + i2, + j1, + this.renderMaxY * this.renderMaxZ, + this.renderMaxY * (1.0D - this.renderMaxZ), + (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ), + (1.0D - this.renderMaxY) * this.renderMaxZ); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .mixAoBrightness( + k1, + l1, + i2, + j1, + this.renderMaxY * this.renderMinZ, + this.renderMaxY * (1.0D - this.renderMinZ), + (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ), + (1.0D - this.renderMaxY) * this.renderMinZ); + this.brightnessBottomRight = RenderBlocks.getInstance() + .mixAoBrightness( + k1, + l1, + i2, + j1, + this.renderMinY * this.renderMinZ, + this.renderMinY * (1.0D - this.renderMinZ), + (1.0D - this.renderMinY) * (1.0D - this.renderMinZ), + (1.0D - this.renderMinY) * this.renderMinZ); + this.brightnessTopRight = RenderBlocks.getInstance() + .mixAoBrightness( + k1, + l1, + i2, + j1, + this.renderMinY * this.renderMaxZ, + this.renderMinY * (1.0D - this.renderMaxZ), + (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ), + (1.0D - this.renderMinY) * this.renderMaxZ); + + if (flag1) { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R + * 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G + * 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B + * 0.6F; + } else { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 4); + CustomOreBlockRenderer.renderFaceXNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass && iicon.getIconName() + .equals("grass_side") && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceXNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos + 1, yPos, zPos, 5)) { + if (this.renderMaxX >= 1.0D) { + ++xPos; + } + + this.aoLightValueScratchXYPN = blockAccess.getBlock(xPos, yPos - 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = blockAccess.getBlock(xPos, yPos, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = blockAccess.getBlock(xPos, yPos, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = blockAccess.getBlock(xPos, yPos + 1, zPos) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessXZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessXZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoBrightnessXYPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + flag2 = blockAccess.getBlock(xPos + 1, yPos + 1, zPos) + .getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos + 1, yPos - 1, zPos) + .getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos + 1, yPos, zPos + 1) + .getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos + 1, yPos, zPos - 1) + .getCanBlockGrass(); + + if (!flag3 && !flag5) { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos, yPos - 1, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos - 1); + } + + if (!flag3 && !flag4) { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos, yPos - 1, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos + 1); + } + + if (!flag2 && !flag5) { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos, yPos + 1, zPos - 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos - 1); + } + + if (!flag2 && !flag4) { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos, yPos + 1, zPos + 1) + .getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos + 1); + } + + if (this.renderMaxX >= 1.0D) { + --xPos; + } + + i1 = l; + + if (this.renderMaxX >= 1.0D || !blockAccess.getBlock(xPos + 1, yPos, zPos) + .isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + } + + f7 = blockAccess.getBlock(xPos + 1, yPos, zPos) + .getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNP + f7 + this.aoLightValueScratchXZPP) + / 4.0F; + f9 = (this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXZPN + f7) + / 4.0F; + f10 = (this.aoLightValueScratchXZPN + f7 + this.aoLightValueScratchXYZPPN + this.aoLightValueScratchXYPP) + / 4.0F; + f11 = (f7 + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPP) + / 4.0F; + f3 = (float) ((double) f8 * (1.0D - this.renderMinY) * this.renderMaxZ + + (double) f9 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ) + + (double) f10 * this.renderMinY * (1.0D - this.renderMaxZ) + + (double) f11 * this.renderMinY * this.renderMaxZ); + f4 = (float) ((double) f8 * (1.0D - this.renderMinY) * this.renderMinZ + + (double) f9 * (1.0D - this.renderMinY) * (1.0D - this.renderMinZ) + + (double) f10 * this.renderMinY * (1.0D - this.renderMinZ) + + (double) f11 * this.renderMinY * this.renderMinZ); + f5 = (float) ((double) f8 * (1.0D - this.renderMaxY) * this.renderMinZ + + (double) f9 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ) + + (double) f10 * this.renderMaxY * (1.0D - this.renderMinZ) + + (double) f11 * this.renderMaxY * this.renderMinZ); + f6 = (float) ((double) f8 * (1.0D - this.renderMaxY) * this.renderMaxZ + + (double) f9 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ) + + (double) f10 * this.renderMaxY * (1.0D - this.renderMaxZ) + + (double) f11 * this.renderMaxY * this.renderMaxZ); + j1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYPN, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + k1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZPP, this.aoBrightnessXYPP, this.aoBrightnessXYZPPP, i1); + l1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, this.aoBrightnessXYPP, i1); + i2 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZPNN, this.aoBrightnessXYPN, this.aoBrightnessXZPN, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + (1.0D - this.renderMinY) * this.renderMaxZ, + (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ), + this.renderMinY * (1.0D - this.renderMaxZ), + this.renderMinY * this.renderMaxZ); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + (1.0D - this.renderMinY) * this.renderMinZ, + (1.0D - this.renderMinY) * (1.0D - this.renderMinZ), + this.renderMinY * (1.0D - this.renderMinZ), + this.renderMinY * this.renderMinZ); + this.brightnessBottomRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + (1.0D - this.renderMaxY) * this.renderMinZ, + (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ), + this.renderMaxY * (1.0D - this.renderMinZ), + this.renderMaxY * this.renderMinZ); + this.brightnessTopRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + (1.0D - this.renderMaxY) * this.renderMaxZ, + (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ), + this.renderMaxY * (1.0D - this.renderMaxZ), + this.renderMaxY * this.renderMaxZ); + + if (flag1) { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R + * 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G + * 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B + * 0.6F; + } else { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 5); + CustomOreBlockRenderer.renderFaceXPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass && iicon.getIconName() + .equals("grass_side") && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceXPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + this.enableAO = false; + return flag; + } +} diff --git a/src/main/java/gtPlusPlus/core/client/renderer/RenderDecayChest.java b/src/main/java/gtPlusPlus/core/client/renderer/RenderDecayChest.java new file mode 100644 index 0000000000..c691bac144 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/renderer/RenderDecayChest.java @@ -0,0 +1,92 @@ +package gtPlusPlus.core.client.renderer; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.client.model.ModelDecayChest; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; + +@SideOnly(Side.CLIENT) +public class RenderDecayChest extends TileEntitySpecialRenderer { + + private static final ResourceLocation mChestTexture = new ResourceLocation( + GTPlusPlus.ID, + "textures/blocks/TileEntities/DecayablesChest_full.png"); + private ModelDecayChest mChestModel = new ModelDecayChest(); + + public static RenderDecayChest INSTANCE; + public final int mRenderID; + + public RenderDecayChest() { + INSTANCE = this; + this.mRenderID = RenderingRegistry.getNextAvailableRenderId(); + Logger.INFO("Registered Lead Lined Chest Renderer."); + } + + public void renderTileEntityAt(TileEntityDecayablesChest p_147500_1_, double p_147500_2_, double p_147500_4_, + double p_147500_6_, float p_147500_8_) { + + int i = 0; + + if (true) { + this.bindTexture(mChestTexture); + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslatef((float) p_147500_2_, (float) p_147500_4_ + 1.0F, (float) p_147500_6_ + 1.0F); + GL11.glScalef(1.0F, -1.0F, -1.0F); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + short short1 = 0; + + if (i == 2) { + short1 = 180; + } + + if (i == 3) { + short1 = 0; + } + + if (i == 4) { + short1 = 90; + } + + if (i == 5) { + short1 = -90; + } + + GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + float f1 = p_147500_1_.prevLidAngle + (p_147500_1_.lidAngle - p_147500_1_.prevLidAngle) * p_147500_8_; + + f1 = 1.0F - f1; + f1 = 1.0F - f1 * f1 * f1; + mChestModel.chestLid.rotateAngleX = -(f1 * CORE.PI / 2.0F); + mChestModel.renderAll(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + } + + @Override + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, + float p_147500_8_) { + this.renderTileEntityAt( + (TileEntityDecayablesChest) p_147500_1_, + p_147500_2_, + p_147500_4_, + p_147500_6_, + p_147500_8_); + } +} diff --git a/src/main/java/gtPlusPlus/core/client/renderer/RenderMiningExplosivesPrimed.java b/src/main/java/gtPlusPlus/core/client/renderer/RenderMiningExplosivesPrimed.java new file mode 100644 index 0000000000..259352367d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/renderer/RenderMiningExplosivesPrimed.java @@ -0,0 +1,111 @@ +package gtPlusPlus.core.client.renderer; + +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.entity.RenderTNTPrimed; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; + +@SideOnly(Side.CLIENT) +public class RenderMiningExplosivesPrimed extends RenderTNTPrimed { + + private final RenderBlocks blockRenderer = new RenderBlocks(); + + public RenderMiningExplosivesPrimed() { + this.shadowSize = 0.5F; + Logger.WARNING("Rendering Mining Explosion. 1"); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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(final EntityPrimedMiningExplosive entity, final double p_76986_2_, final double p_76986_4_, + final double p_76986_6_, final float p_76986_8_, final float p_76986_9_) { + Logger.WARNING("Rendering Mining Explosion. 2"); + GL11.glPushMatrix(); + GL11.glTranslatef((float) p_76986_2_, (float) p_76986_4_, (float) p_76986_6_); + float f2; + + if (((entity.fuse - p_76986_9_) + 1.0F) < 10.0F) { + f2 = 1.0F - (((entity.fuse - p_76986_9_) + 1.0F) / 10.0F); + + if (f2 < 0.0F) { + f2 = 0.0F; + } + + if (f2 > 1.0F) { + f2 = 1.0F; + } + + f2 *= f2; + f2 *= f2; + final float f3 = 1.0F + (f2 * 0.3F); + GL11.glScalef(f3, f3, f3); + } + + f2 = (1.0F - (((entity.fuse - p_76986_9_) + 1.0F) / 100.0F)) * 0.8F; + this.bindEntityTexture(entity); + this.blockRenderer.renderBlockAsItem(ModBlocks.blockMiningExplosive, 0, entity.getBrightness(p_76986_9_)); + + if (((entity.fuse / 5) % 2) == 0) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f2); + this.blockRenderer.renderBlockAsItem(ModBlocks.blockMiningExplosive, 0, 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glPopMatrix(); + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(final EntityPrimedMiningExplosive p_110775_1_) { + return TextureMap.locationBlocksTexture; + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + @Override + protected ResourceLocation getEntityTexture(final Entity p_110775_1_) { + Logger.WARNING("Rendering Mining Explosion. 4"); + return this.getEntityTexture((EntityPrimedMiningExplosive) p_110775_1_); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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. + */ + @Override + public void doRender(final Entity p_76986_1_, final double p_76986_2_, final double p_76986_4_, + final double p_76986_6_, final float p_76986_8_, final float p_76986_9_) { + Logger.WARNING("Rendering Mining Explosion. 3"); + this.doRender( + (EntityPrimedMiningExplosive) p_76986_1_, + p_76986_2_, + p_76986_4_, + p_76986_6_, + p_76986_8_, + p_76986_9_); + } +} diff --git a/src/main/java/gtPlusPlus/core/client/renderer/RenderSickBlaze.java b/src/main/java/gtPlusPlus/core/client/renderer/RenderSickBlaze.java new file mode 100644 index 0000000000..c1d3927416 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/renderer/RenderSickBlaze.java @@ -0,0 +1,96 @@ +package gtPlusPlus.core.client.renderer; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +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.util.ResourceLocation; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.client.model.ModelSickBlaze; +import gtPlusPlus.core.entity.monster.EntitySickBlaze; + +@SideOnly(Side.CLIENT) +public class RenderSickBlaze extends RenderLiving { + + private static final ResourceLocation blazeTextures = new ResourceLocation( + GTPlusPlus.ID + ":" + "textures/entity/sickBlaze.png"); + private int field_77068_a; + + public RenderSickBlaze() { + super(new ModelSickBlaze(), 0.5F); + this.field_77068_a = ((ModelSickBlaze) this.mainModel).func_78104_a(); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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(EntitySickBlaze 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 = ((ModelSickBlaze) this.mainModel).func_78104_a(); + + if (i != this.field_77068_a) { + this.field_77068_a = i; + this.mainModel = new ModelSickBlaze(); + } + + super.doRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(EntitySickBlaze p_110775_1_) { + return blazeTextures; + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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. + */ + @Override + 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((EntitySickBlaze) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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. + */ + @Override + 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((EntitySickBlaze) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return this.getEntityTexture((EntitySickBlaze) p_110775_1_); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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. + */ + @Override + 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((EntitySickBlaze) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } +} diff --git a/src/main/java/gtPlusPlus/core/client/renderer/RenderStaballoyConstruct.java b/src/main/java/gtPlusPlus/core/client/renderer/RenderStaballoyConstruct.java new file mode 100644 index 0000000000..f2ebe84d4d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/renderer/RenderStaballoyConstruct.java @@ -0,0 +1,163 @@ +package gtPlusPlus.core.client.renderer; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.client.model.ModelStaballoyConstruct; +import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; + +@SideOnly(Side.CLIENT) +public class RenderStaballoyConstruct extends RenderLiving { + + private static final ResourceLocation staballoyGolemTextures = new ResourceLocation( + GTPlusPlus.ID + ":" + "textures/entity/golemStaballoy.png"); + /** Staballoy Golem's Model. */ + private final ModelStaballoyConstruct staballoyGolemModel; + + public RenderStaballoyConstruct() { + super(new ModelStaballoyConstruct(), 0.8F); + this.staballoyGolemModel = (ModelStaballoyConstruct) this.mainModel; + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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(EntityStaballoyConstruct p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, + float p_76986_8_, float p_76986_9_) { + super.doRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(EntityStaballoyConstruct p_110775_1_) { + return staballoyGolemTextures; + } + + protected void rotateCorpse(EntityStaballoyConstruct p_77043_1_, float p_77043_2_, float p_77043_3_, + float p_77043_4_) { + super.rotateCorpse(p_77043_1_, p_77043_2_, p_77043_3_, p_77043_4_); + + if (p_77043_1_.limbSwingAmount >= 0.01D) { + float f3 = 13.0F; + float f4 = p_77043_1_.limbSwing - p_77043_1_.limbSwingAmount * (1.0F - p_77043_4_) + 6.0F; + float f5 = (Math.abs(f4 % f3 - f3 * 0.5F) - f3 * 0.25F) / (f3 * 0.25F); + GL11.glRotatef(6.5F * f5, 0.0F, 0.0F, 1.0F); + } + } + + protected void renderEquippedItems(EntityStaballoyConstruct p_77029_1_, float p_77029_2_) { + super.renderEquippedItems(p_77029_1_, p_77029_2_); + + if (p_77029_1_.getHoldRoseTick() != 0) { + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPushMatrix(); + GL11.glRotatef( + 5.0F + 180.0F * this.staballoyGolemModel.ironGolemRightArm.rotateAngleX / (float) Math.PI, + 1.0F, + 0.0F, + 0.0F); + GL11.glTranslatef(-0.6875F, 1.25F, -0.9375F); + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + float f1 = 0.8F; + GL11.glScalef(f1, -f1, f1); + int i = p_77029_1_.getBrightnessForRender(p_77029_2_); + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.bindTexture(TextureMap.locationBlocksTexture); + this.field_147909_c.renderBlockAsItem(Blocks.red_flower, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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. + */ + @Override + 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( + (EntityStaballoyConstruct) p_76986_1_, + p_76986_2_, + p_76986_4_, + p_76986_6_, + p_76986_8_, + p_76986_9_); + } + + @Override + protected void renderEquippedItems(EntityLivingBase p_77029_1_, float p_77029_2_) { + this.renderEquippedItems((EntityStaballoyConstruct) p_77029_1_, p_77029_2_); + } + + @Override + protected void rotateCorpse(EntityLivingBase p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { + this.rotateCorpse((EntityStaballoyConstruct) p_77043_1_, p_77043_2_, p_77043_3_, p_77043_4_); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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. + */ + @Override + 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( + (EntityStaballoyConstruct) p_76986_1_, + p_76986_2_, + p_76986_4_, + p_76986_6_, + p_76986_8_, + p_76986_9_); + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return this.getEntityTexture((EntityStaballoyConstruct) p_110775_1_); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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. + */ + @Override + 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( + (EntityStaballoyConstruct) p_76986_1_, + p_76986_2_, + p_76986_4_, + p_76986_6_, + p_76986_8_, + p_76986_9_); + } +} diff --git a/src/main/java/gtPlusPlus/core/client/renderer/RenderToxinball.java b/src/main/java/gtPlusPlus/core/client/renderer/RenderToxinball.java new file mode 100644 index 0000000000..2c0ed7f562 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/renderer/RenderToxinball.java @@ -0,0 +1,89 @@ +package gtPlusPlus.core.client.renderer; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.entity.projectile.EntityToxinball; + +@SideOnly(Side.CLIENT) +public class RenderToxinball extends Render { + + private float mSize; + + public RenderToxinball(float scale) { + this.mSize = scale; + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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(EntityToxinball entity, double p_76986_2_, double p_76986_4_, double p_76986_6_, + float p_76986_8_, float p_76986_9_) { + GL11.glPushMatrix(); + this.bindEntityTexture(entity); + GL11.glTranslatef((float) p_76986_2_, (float) p_76986_4_, (float) p_76986_6_); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f2 = this.mSize; + GL11.glScalef(f2 / 1.0F, f2 / 1.0F, f2 / 1.0F); + IIcon iicon = Items.slime_ball.getIconFromDamage(0); + Tessellator tessellator = Tessellator.instance; + float f3 = iicon.getMinU(); + float f4 = iicon.getMaxU(); + float f5 = iicon.getMinV(); + float f6 = iicon.getMaxV(); + float f7 = 1.0F; + float f8 = 0.5F; + float f9 = 0.25F; + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV(0.0F - f8, 0.0F - f9, 0.0D, f3, f6); + tessellator.addVertexWithUV(f7 - f8, 0.0F - f9, 0.0D, f4, f6); + tessellator.addVertexWithUV(f7 - f8, 1.0F - f9, 0.0D, f4, f5); + tessellator.addVertexWithUV(0.0F - f8, 1.0F - f9, 0.0D, f3, f5); + tessellator.draw(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(EntityToxinball entity) { + return TextureMap.locationItemsTexture; + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + @Override + protected ResourceLocation getEntityTexture(Entity entity) { + return this.getEntityTexture((EntityToxinball) entity); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render<T extends Entity) and this method has signature public void 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. + */ + @Override + public void doRender(Entity entity, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, + float p_76986_9_) { + this.doRender((EntityToxinball) entity, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } +} diff --git a/src/main/java/gtPlusPlus/core/client/renderer/particle/EntityDropParticleFX.java b/src/main/java/gtPlusPlus/core/client/renderer/particle/EntityDropParticleFX.java new file mode 100644 index 0000000000..58b135f3fb --- /dev/null +++ b/src/main/java/gtPlusPlus/core/client/renderer/particle/EntityDropParticleFX.java @@ -0,0 +1,105 @@ +package gtPlusPlus.core.client.renderer.particle; + +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.material.Material; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.world.World; + +import cofh.lib.util.helpers.MathHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class EntityDropParticleFX extends EntityFX { + + private int bobTimer; + + public EntityDropParticleFX(World world, double x, double y, double z, float particleRed, float particleGreen, + float particleBlue) { + + this(world, x, y, z, particleRed, particleGreen, particleBlue, -1); + } + + public EntityDropParticleFX(World world, double x, double y, double z, float particleRed, float particleGreen, + float particleBlue, int gravityMod) { + + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.motionX = this.motionY = this.motionZ = 0.0D; + + this.particleRed = particleRed; + this.particleGreen = particleGreen; + this.particleBlue = particleBlue; + + this.setParticleTextureIndex(113); + this.setSize(0.01F, 0.01F); + this.particleGravity = -0.06F * gravityMod; + this.bobTimer = 40; + this.particleMaxAge = (int) (48.0D / (Math.random() * 0.8D + 0.2D)); + this.motionX = this.motionY = this.motionZ = 0.0D; + } + + @Override + public void onUpdate() { + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + this.motionY -= this.particleGravity; + + if (this.bobTimer-- > 0) { + this.motionX *= 0.02D; + this.motionY *= 0.02D; + this.motionZ *= 0.02D; + this.setParticleTextureIndex(113); + } else { + this.setParticleTextureIndex(112); + } + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.particleMaxAge-- <= 0) { + this.setDead(); + } + if (this.onGround) { + this.setParticleTextureIndex(114); + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + if (this.particleGravity > 0) { + Material material = this.worldObj + .getBlock(MathHelper.floor(this.posX), MathHelper.floor(this.posY), MathHelper.floor(this.posZ)) + .getMaterial(); + + if (material.isLiquid() || material.isSolid()) { + double d0 = MathHelper.floor(this.posY) + 1 + - BlockLiquid.getLiquidHeightPercent( + this.worldObj.getBlockMetadata( + MathHelper.floor(this.posX), + MathHelper.floor(this.posY), + MathHelper.floor(this.posZ))); + if (this.posY < d0) { + this.setDead(); + } + } + } else { + Material material = this.worldObj + .getBlock(MathHelper.ceil(this.posX), MathHelper.ceil(this.posY), MathHelper.ceil(this.posZ)) + .getMaterial(); + + if (material.isLiquid() || material.isSolid()) { + double d0 = MathHelper.ceil(this.posY) + 1 + - BlockLiquid.getLiquidHeightPercent( + this.worldObj.getBlockMetadata( + MathHelper.ceil(this.posX), + MathHelper.ceil(this.posY), + MathHelper.ceil(this.posZ))); + if (this.posY > d0) { + this.setDead(); + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java b/src/main/java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java new file mode 100644 index 0000000000..1794951248 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java @@ -0,0 +1,279 @@ +package gtPlusPlus.core.commands; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.CORE_Preloader; +import gtPlusPlus.preloader.asm.AsmConfig; + +public class CommandEnableDebugWhileRunning implements ICommand { + + private final List<String> aliases; + + public CommandEnableDebugWhileRunning() { + this.aliases = new ArrayList<>(); + this.aliases.add("gtplusplus"); + } + + @Override + public int compareTo(final Object o) { + if (o instanceof Comparable<?>) { + @SuppressWarnings("unchecked") + Comparable<ICommand> a = (Comparable<ICommand>) o; + if (a.equals(this)) { + return 0; + } else { + return -1; + } + } + return -1; + } + + @Override + public String getCommandName() { + return "gtpp"; + } + + // Use '/gtpp' 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 "/gtpp ?"; + } + + @Override + public List<String> getCommandAliases() { + return this.aliases; + } + + @Override + public void processCommand(final ICommandSender S, final String[] argString) { + int aMaxArgumentsAllowed = 2; + + if ((argString == null || argString.length == 0 || argString.length > aMaxArgumentsAllowed) + || argString[0].toLowerCase() + .equals("?")) { + Logger.INFO("Listing commands and their uses."); + final EntityPlayer P = CommandUtils.getPlayer(S); + AsmConfig.disableAllLogging = !AsmConfig.disableAllLogging; + PlayerUtils.messagePlayer(P, "The following are valid args for the '/gtpp' command:"); + PlayerUtils.messagePlayer(P, "? - This help command."); + PlayerUtils.messagePlayer(P, "logging - Toggles ALL GT++ logging for current session."); + PlayerUtils.messagePlayer(P, "hand - Lists information about held item."); + PlayerUtils.messagePlayer(P, "fuid xxx - Tries to find the fluid in the FluidRegistry."); + PlayerUtils.messagePlayer( + P, + "debug - Toggles GT++ Debug Mode. Only use when advised, may break everything. (OP)"); + } else if (argString[0].toLowerCase() + .equals("debug")) { + Logger.INFO("Toggling Debug Mode."); + final EntityPlayer P = CommandUtils.getPlayer(S); + if (PlayerUtils.isPlayerOP(P)) { + CORE_Preloader.DEBUG_MODE = !CORE_Preloader.DEBUG_MODE; + PlayerUtils.messagePlayer(P, "Toggled GT++ Debug Mode - Enabled: " + CORE_Preloader.DEBUG_MODE); + } + } else if (argString[0].toLowerCase() + .equals("logging")) { + Logger.INFO("Toggling Logging."); + final EntityPlayer P = CommandUtils.getPlayer(S); + AsmConfig.disableAllLogging = !AsmConfig.disableAllLogging; + PlayerUtils.messagePlayer(P, "Toggled GT++ Logging - Enabled: " + (!AsmConfig.disableAllLogging)); + } + /* + * else if (argString[0].toLowerCase().equals("test")) { ItemStack mSemiFluidgen = + * ItemUtils.simpleMetaStack("IC2:blockGenerator", 7, 1); final EntityPlayer P = CommandUtils.getPlayer(S); + * if(mSemiFluidgen != null) { PlayerUtils.messagePlayer(P, ItemUtils.getItemName(mSemiFluidgen)); } } + */ + + else if (argString[0].toLowerCase() + .equals("inv")) { + final EntityPlayer P = CommandUtils.getPlayer(S); + if (P != null && !P.worldObj.isRemote) { + ItemStack[] aInv = P.inventory.mainInventory; + for (ItemStack aItem : aInv) { + if (aItem != null) { + String aModID = GameRegistry.findUniqueIdentifierFor(aItem.getItem()).modId; + String aRegistryName = GameRegistry.findUniqueIdentifierFor(aItem.getItem()).name; + Logger.INFO( + aModID + ":" + + aRegistryName + + ":" + + aItem.getItemDamage() + + " | " + + aItem.getDisplayName()); + } + } + PlayerUtils.messagePlayer(P, "Dumped Inventory."); + } + } else if (argString[0].toLowerCase() + .equals("hand")) { + final EntityPlayer P = CommandUtils.getPlayer(S); + if (P != null) { + ItemStack aHeldItem = PlayerUtils.getItemStackInPlayersHand(P); + if (aHeldItem != null) { + String aItemDisplayName = ItemUtils.getItemName(aHeldItem); + String aItemUnlocalName = ItemUtils.getUnlocalizedItemName(aHeldItem); + String aNbtString = tryIterateNBTData(aHeldItem); + AutoMap<String> aOreDictNames = new AutoMap<>(); + + int[] aOreIDs = OreDictionary.getOreIDs(aHeldItem); + for (int id : aOreIDs) { + String aOreNameFromID = OreDictionary.getOreName(id); + if (aOreNameFromID != null && aOreNameFromID.length() > 0 + && !aOreNameFromID.equals("Unknown")) { + aOreDictNames.add(aOreNameFromID); + } + } + + String aOreDictData = ""; + if (!aOreDictNames.isEmpty()) { + for (String tag : aOreDictNames) { + aOreDictData += (tag + ", "); + } + if (aOreDictData.endsWith(", ")) { + aOreDictData = aOreDictData.substring(0, aOreDictData.length() - 2); + } + } + + AutoMap<String> aFluidContainerData = new AutoMap<>(); + FluidStack aHeldItemFluid = FluidContainerRegistry.getFluidForFilledItem(aHeldItem); + if (aHeldItemFluid != null) { + aFluidContainerData + .put("FluidStack Unlocal Name: " + aHeldItemFluid.getUnlocalizedName()); + aFluidContainerData.put("FluidStack Local Name: " + aHeldItemFluid.getLocalizedName()); + aFluidContainerData.put( + "Fluid Unlocal Name: " + aHeldItemFluid.getFluid() + .getUnlocalizedName()); + aFluidContainerData.put("Fluid Local Name: " + aHeldItemFluid.getLocalizedName()); + aFluidContainerData.put( + "Fluid Name: " + aHeldItemFluid.getFluid() + .getName()); + } + + PlayerUtils.messagePlayer(P, "[" + aItemUnlocalName + "]" + "[" + aItemDisplayName + "] "); + if (aFluidContainerData.size() > 0) { + for (String s : aFluidContainerData) { + PlayerUtils.messagePlayer(P, "" + s); + } + } + if (!aOreDictNames.isEmpty()) { + PlayerUtils.messagePlayer(P, "" + aOreDictData); + } + if (aNbtString.length() > 0) { + PlayerUtils.messagePlayer(P, "" + aNbtString); + } + } else { + PlayerUtils.messagePlayer(P, "No item held."); + } + } + } else if (argString[0].toLowerCase() + .equals("fluid")) { + if (argString.length > 1 && argString[1] != null && argString[1].length() > 0) { + final EntityPlayer P = CommandUtils.getPlayer(S); + FluidStack aFluid = FluidUtils.getWildcardFluidStack(argString[1], 1); + if (P != null && aFluid != null) { + PlayerUtils + .messagePlayer(P, "Found fluid stack: " + FluidRegistry.getFluidName(aFluid)); + } else if (P != null && aFluid == null) { + PlayerUtils.messagePlayer(P, "Could not find any fluids."); + } + } + } else if (argString[0].toLowerCase() + .equals("item")) { + if (argString.length > 1 && argString[1] != null && argString[1].length() > 0) { + final EntityPlayer P = CommandUtils.getPlayer(S); + ItemStack aTest = ItemUtils.getItemStackFromFQRN(argString[1], 1); + if (P != null && aTest != null) { + PlayerUtils.messagePlayer(P, "Found fluid stack: " + ItemUtils.getItemName(aTest)); + } else if (P != null && aTest == null) { + PlayerUtils.messagePlayer(P, "Could not find valid item."); + } + } + } else { + final EntityPlayer P = CommandUtils.getPlayer(S); + PlayerUtils.messagePlayer(P, "Invalid command, use '?' as an argument for help.'"); + } + } + + @Override + public boolean canCommandSenderUseCommand(final ICommandSender var1) { + if (var1 == null || CommandUtils.getPlayer(var1) == null) { + return false; + } + return true; + } + + @Override + public List<?> addTabCompletionOptions(final ICommandSender var1, final String[] var2) { + ArrayList<String> aTabCompletes = new ArrayList<>(); + aTabCompletes.add("?"); + aTabCompletes.add("logging"); + aTabCompletes.add("debug"); + aTabCompletes.add("hand"); + aTabCompletes.add("fluid"); + return aTabCompletes; + } + + @Override + public boolean isUsernameIndex(final String[] var1, final int var2) { + // TODO Auto-generated method stub + return false; + } + + public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost) { + return true; + } + + public static String tryIterateNBTData(ItemStack aStack) { + try { + AutoMap<String> aItemDataTags = new AutoMap<>(); + NBTTagCompound aNBT = NBTUtils.getNBT(aStack); + if (aNBT != null) { + if (!aNBT.hasNoTags()) { + Map<?, ?> mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); + if (mInternalMap != null) { + for (Map.Entry<?, ?> e : mInternalMap.entrySet()) { + aItemDataTags.add( + e.getKey() + .toString() + ":" + + e.getValue()); + } + int a = 0; + String data = ""; + for (String tag : aItemDataTags) { + data += (tag + ", "); + } + if (data.endsWith(", ")) { + data = data.substring(0, data.length() - 2); + } + return data; + } else { + Logger.INFO("Data map reflected from NBTTagCompound was not valid."); + return "Bad NBT"; + } + } + } + } catch (Throwable t) {} + return ""; + } +} diff --git a/src/main/java/gtPlusPlus/core/commands/CommandMath.java b/src/main/java/gtPlusPlus/core/commands/CommandMath.java new file mode 100644 index 0000000000..6065044c29 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/commands/CommandMath.java @@ -0,0 +1,92 @@ +package gtPlusPlus.core.commands; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.MiningUtils; + +public class CommandMath implements ICommand { + + private final List<String> aliases; + + protected String fullEntityName; + protected Entity conjuredEntity; + + public CommandMath() { + this.aliases = new ArrayList<>(); + } + + @Override + public int compareTo(final Object o) { + return 0; + } + + @Override + public String getCommandName() { + return "alkalus"; + } + + @Override + public String getCommandUsage(final ICommandSender var1) { + return "/alkalus [Dev Command]"; + } + + @Override + public List<String> getCommandAliases() { + return this.aliases; + } + + @Override + public void processCommand(final ICommandSender S, final String[] argString) { + Logger.INFO("Debug Command"); + final World W = S.getEntityWorld(); + final EntityPlayer P = CommandUtils.getPlayer(S); + if (P.getDisplayName() + .equalsIgnoreCase("draknyte1")) { + Logger.INFO("[Bedrock Miner] OreType Scan"); + MiningUtils.iterateAllOreTypes(); + } + } + + @Override + public boolean canCommandSenderUseCommand(final ICommandSender var1) { + final EntityPlayer P = CommandUtils.getPlayer(var1); + if (P == null) { + return false; + } + if (P.getDisplayName() + .toLowerCase() + .equals("draknyte1") + || P.getCommandSenderName() + .toLowerCase() + .equals("draknyte1") + || CORE.DEVENV) { + return true; + } + return false; + } + + @Override + public List<?> addTabCompletionOptions(final ICommandSender var1, final String[] var2) { + return null; + } + + @Override + public boolean isUsernameIndex(final String[] var1, final int var2) { + // TODO Auto-generated method stub + return false; + } + + public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost) { + + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/commands/CommandUtils.java b/src/main/java/gtPlusPlus/core/commands/CommandUtils.java new file mode 100644 index 0000000000..931ac5239f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/commands/CommandUtils.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.commands; + +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; + +public class CommandUtils { + + public static EntityPlayer getPlayer(final ICommandSender icommandsender) { + EntityPlayer player; + + if (icommandsender instanceof EntityPlayer) { + player = (EntityPlayer) icommandsender; + return player; + } else { + return null; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/common/CommonProxy.java b/src/main/java/gtPlusPlus/core/common/CommonProxy.java new file mode 100644 index 0000000000..d52b3aa112 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/common/CommonProxy.java @@ -0,0 +1,210 @@ +package gtPlusPlus.core.common; + +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.client.IItemRenderer; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.entity.InternalEntityRegistry; +import gtPlusPlus.core.handler.BookHandler; +import gtPlusPlus.core.handler.BurnableFuelHandler; +import gtPlusPlus.core.handler.COMPAT_HANDLER; +import gtPlusPlus.core.handler.COMPAT_IntermodStaging; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.handler.events.EnderDragonDeathHandler; +import gtPlusPlus.core.handler.events.EntityDeathHandler; +import gtPlusPlus.core.handler.events.GeneralTooltipEventHandler; +import gtPlusPlus.core.handler.events.PlayerSleepEventHandler; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.tileentities.ModTileEntities; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.CORE_Preloader; +import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; +import gtPlusPlus.xmod.gregtech.recipes.GregtechRecipeAdder; +import gtPlusPlus.xmod.ic2.CustomInternalName; + +public class CommonProxy { + + public CommonProxy() { + // Should Register Gregtech Materials I've Made + Utils.registerEvent(this); + } + + public void preInit(final FMLPreInitializationEvent e) { + Logger.INFO("Doing some house cleaning."); + CORE.RA = new GregtechRecipeAdder(); + Logger.INFO("Created Gregtech recipe handler."); + if (!CORE_Preloader.DEBUG_MODE) { + Logger.WARNING("Development mode not enabled."); + } else if (CORE_Preloader.DEBUG_MODE) { + Logger.INFO("Development mode enabled."); + } else { + Logger.WARNING("Development mode not set."); + } + + AddToCreativeTab.initialiseTabs(); + CustomInternalName.init(); + + ModItems.init(); + ModBlocks.init(); + CI.preInit(); + COMPAT_IntermodStaging.preInit(e); + BookHandler.run(); + // Registration of entities and renderers + Logger.INFO("[Proxy] Calling Entity registration."); + registerEntities(); + Logger.INFO("[Proxy] Calling Tile Entity registration."); + registerTileEntities(); + + Logger.INFO("[Proxy] Calling Render registration."); + registerRenderThings(); + } + + public void init(final FMLInitializationEvent e) { + CI.init(); + + Utils.registerEvent(new GeneralTooltipEventHandler()); + // Handles Tooltips for items giving custom multiblock behaviour + Utils.registerEvent(new SpecialBehaviourTooltipHandler()); + // Handles Sleep Benefits + PlayerSleepEventHandler.init(); + // Handles Magic Feather + Utils.registerEvent(ModItems.itemMagicFeather); + + Utils.registerEvent(new EnderDragonDeathHandler()); + Utils.registerEvent(new EntityDeathHandler()); + + // Compat Handling + COMPAT_HANDLER.registerMyModsOreDictEntries(); + COMPAT_HANDLER.intermodOreDictionarySupport(); + COMPAT_IntermodStaging.init(e); + } + + public void postInit(final FMLPostInitializationEvent e) { + + // Make Burnables burnable + if (!CORE.burnables.isEmpty()) { + BurnableFuelHandler fuelHandler = new BurnableFuelHandler(); + GameRegistry.registerFuelHandler(fuelHandler); + Logger.INFO( + "[Fuel Handler] Registering " + fuelHandler.getClass() + .getName()); + } + + // Compat Handling + Logger.INFO("Removing recipes from other mods."); + COMPAT_HANDLER.RemoveRecipesFromOtherMods(); + Logger.INFO("Initialising Handler, Then Adding Recipes"); + COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); + 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, to prevent recipes being generated post initialisation. + Logger.INFO("Loading Gregtech API recipes."); + COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); + } + + public void serverStarting(final FMLServerStartingEvent e) { + COMPAT_HANDLER.InitialiseLateHandlerThenAddRecipes(); + } + + public void onLoadComplete(FMLLoadCompleteEvent event) { + COMPAT_IntermodStaging.onLoadComplete(event); + COMPAT_HANDLER.onLoadComplete(event); + } + + public void registerNetworkStuff() { + GuiHandler.init(); + } + + public void registerEntities() { + InternalEntityRegistry.registerEntities(); + } + + public void registerTileEntities() { + ModTileEntities.init(); + } + + public void registerRenderThings() {} + + public int addArmor(final String armor) { + return 0; + } + + public void registerCustomMobDrops() { + + // Blazes + if (ItemUtils.doesOreDictHaveEntryFor("dustPyrotheum")) { + EntityUtils.registerDropsForMob( + EntityBlaze.class, + ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), + 1, + 10); + EntityUtils.registerDropsForMob( + EntityBlaze.class, + ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), + 1, + 10); + } + + // GalaxySpace Support + if (ReflectionUtils.doesClassExist("galaxyspace.core.entity.mob.EntityEvolvedColdBlaze")) { + Class<?> aColdBlaze = ReflectionUtils.getClass("galaxyspace.core.entity.mob.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<>(); + + public World getClientWorld() { + return null; + } + + /** + * Returns a side-appropriate EntityPlayer for use during message handling + */ + public EntityPlayer getPlayerEntity(MessageContext ctx) { + return ctx.getServerHandler().playerEntity; + } +} diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java new file mode 100644 index 0000000000..e90596c876 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java @@ -0,0 +1,58 @@ +package gtPlusPlus.core.common.compat; + +import static gregtech.api.enums.Mods.Baubles; +import static gregtech.client.GT_TooltipHandler.Tier.EV; +import static gregtech.client.GT_TooltipHandler.Tier.HV; +import static gregtech.client.GT_TooltipHandler.Tier.IV; +import static gregtech.client.GT_TooltipHandler.Tier.LV; +import static gregtech.client.GT_TooltipHandler.Tier.LuV; +import static gregtech.client.GT_TooltipHandler.Tier.MV; +import static gregtech.client.GT_TooltipHandler.Tier.UHV; +import static gregtech.client.GT_TooltipHandler.Tier.UV; +import static gregtech.client.GT_TooltipHandler.Tier.ZPM; +import static gregtech.client.GT_TooltipHandler.registerTieredTooltip; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; +import gtPlusPlus.core.item.bauble.FireProtectionBauble; +import gtPlusPlus.core.item.general.ItemCloakingDevice; +import gtPlusPlus.core.item.general.ItemHealingDevice; + +public class COMPAT_Baubles { + + public static void run() { + if (Baubles.isModLoaded()) { + baublesLoaded(); + } + } + + public static void baublesLoaded() { + Logger.INFO("Baubles Found - Loading Wearables."); + ModItems.itemPersonalCloakingDevice = new ItemCloakingDevice(0); + ModItems.itemPersonalHealingDevice = new ItemHealingDevice(); + ModItems.itemSupremePizzaGloves = new FireProtectionBauble(); + + ModItems.itemChargePack_Low_1 = new BatteryPackBaseBauble(1); + registerTieredTooltip(new ItemStack(ModItems.itemChargePack_Low_1, 1, OreDictionary.WILDCARD_VALUE), LV); + ModItems.itemChargePack_Low_2 = new BatteryPackBaseBauble(2); + registerTieredTooltip(new ItemStack(ModItems.itemChargePack_Low_2, 1, OreDictionary.WILDCARD_VALUE), MV); + ModItems.itemChargePack_Low_3 = new BatteryPackBaseBauble(3); + registerTieredTooltip(new ItemStack(ModItems.itemChargePack_Low_3, 1, OreDictionary.WILDCARD_VALUE), HV); + ModItems.itemChargePack_Low_4 = new BatteryPackBaseBauble(4); + registerTieredTooltip(new ItemStack(ModItems.itemChargePack_Low_4, 1, OreDictionary.WILDCARD_VALUE), EV); + ModItems.itemChargePack_Low_5 = new BatteryPackBaseBauble(5); + registerTieredTooltip(new ItemStack(ModItems.itemChargePack_Low_5, 1, OreDictionary.WILDCARD_VALUE), IV); + ModItems.itemChargePack_High_1 = new BatteryPackBaseBauble(6); + registerTieredTooltip(new ItemStack(ModItems.itemChargePack_High_1, 1, OreDictionary.WILDCARD_VALUE), LuV); + ModItems.itemChargePack_High_2 = new BatteryPackBaseBauble(7); + registerTieredTooltip(new ItemStack(ModItems.itemChargePack_High_2, 1, OreDictionary.WILDCARD_VALUE), ZPM); + ModItems.itemChargePack_High_3 = new BatteryPackBaseBauble(8); + registerTieredTooltip(new ItemStack(ModItems.itemChargePack_High_3, 1, OreDictionary.WILDCARD_VALUE), UV); + ModItems.itemChargePack_High_4 = new BatteryPackBaseBauble(9); + registerTieredTooltip(new ItemStack(ModItems.itemChargePack_High_4, 1, OreDictionary.WILDCARD_VALUE), UHV); + } +} diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java new file mode 100644 index 0000000000..f61c70ab5b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.common.compat; + +import net.minecraft.item.ItemStack; + +import gtPlusPlus.core.recipe.RECIPES_Tools; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class COMPAT_ExtraUtils { + + public static void OreDict() { + RECIPES_Tools.RECIPE_DivisionSigil = new ItemStack(ItemUtils.getItemFromFQRN("ExtraUtilities:divisionSigil")); + run(); + } + + private static void run() { + ItemUtils.getItemForOreDict("ExtraUtilities:bedrockiumIngot", "ingotBedrockium", "Bedrockium Ingot", 0); + } +} diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_HarvestCraft.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_HarvestCraft.java new file mode 100644 index 0000000000..9a9557e418 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_HarvestCraft.java @@ -0,0 +1,14 @@ +package gtPlusPlus.core.common.compat; + +import gtPlusPlus.xmod.pamsharvest.fishtrap.FishTrapHandler; + +public class COMPAT_HarvestCraft { + + public static void OreDict() { + run(); + } + + private static void run() { + FishTrapHandler.pamsHarvestCraftCompat(); + } +} diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_IC2.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_IC2.java new file mode 100644 index 0000000000..c442251a0e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_IC2.java @@ -0,0 +1,58 @@ +package gtPlusPlus.core.common.compat; + +import static gtPlusPlus.core.handler.COMPAT_HANDLER.RemoveRecipeQueue; + +import net.minecraft.item.ItemStack; + +import gtPlusPlus.core.lib.CORE.ConfigSwitches; +import gtPlusPlus.core.recipe.ShapedRecipeObject; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class COMPAT_IC2 { + + private static ItemStack itemCropnalyzer = ItemUtils.simpleMetaStack("IC2:itemCropnalyzer", 0, 1); + private static ItemStack itemSolarHelmet = ItemUtils.simpleMetaStack("IC2:itemSolarHelmet", 0, 1); + + public static ShapedRecipeObject Cropnalyzer = new ShapedRecipeObject( + "ore:cableGt02Copper", + "ore:cableGt02Copper", + null, + "minecraft:redstone", + "ore:blockGlass", + "minecraft:redstone", + "minecraft:redstone", + "ore:circuitBasic", + "minecraft:redstone", + itemCropnalyzer); + public static ShapedRecipeObject SolarHelmet = new ShapedRecipeObject( + "ore:plateIron", + "ore:plateIron", + "ore:plateIron", + "ore:plateIron", + "gregtech:gt.metaitem.01:32750", + "ore:plateIron", + "ore:craftingWireCopper", + "ore:craftingWireCopper", + "ore:craftingWireCopper", + itemSolarHelmet); + + public static void OreDict() { + run(); + } + + private static void run() { + + if (ConfigSwitches.disableIC2Recipes) { + + // Remove these. + RemoveRecipeQueue.add("IC2:itemCable"); + RemoveRecipeQueue.add("IC2:itemCable:1"); + RemoveRecipeQueue.add("IC2:itemCable:2"); + RemoveRecipeQueue.add("IC2:itemCable:3"); + RemoveRecipeQueue.add("IC2:itemCable:5"); + RemoveRecipeQueue.add("IC2:itemCable:6"); + RemoveRecipeQueue.add("IC2:itemCable:10"); + RemoveRecipeQueue.add("IC2:itemCable:13"); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java new file mode 100644 index 0000000000..d9c9fec08e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java @@ -0,0 +1,47 @@ +package gtPlusPlus.core.common.compat; + +import static gregtech.api.enums.Mods.ForbiddenMagic; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.lib.CORE.ConfigSwitches; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class COMPAT_Thaumcraft { + + public static void OreDict() { + + if (ConfigSwitches.enableThaumcraftShardUnification) { + run(); + } + } + + private static void run() { + + for (int i = 0; i <= 6; i++) { + ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "shardAny", "TC Shard " + i, i); + GT_OreDictUnificator + .registerOre("shardAny", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:" + i, 1)); + ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "gemInfusedAnything", "TC Shard " + i, i); + GT_OreDictUnificator + .registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:" + i, 1)); + } + + if (ForbiddenMagic.isModLoaded()) { + for (int i = 0; i <= 6; i++) { + ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "shardAny", "FM Shard " + i, i); + GT_OreDictUnificator + .registerOre("shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:" + i, 1)); + ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "gemInfusedAnything", "FM Shard " + i, i); + GT_OreDictUnificator.registerOre( + "gemInfusedAnything", + ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:" + i, 1)); + } + ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "shardAny", "FM Gluttony Shard", 0); + GT_OreDictUnificator + .registerOre("shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); + ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "gemInfusedAnything", "FM Gluttony Shard", 0); + GT_OreDictUnificator + .registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Witchery.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Witchery.java new file mode 100644 index 0000000000..f6fdd87eec --- /dev/null +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Witchery.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.common.compat; + +import static gregtech.api.enums.Mods.Witchery; + +import net.minecraft.item.ItemStack; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class COMPAT_Witchery { + + public static void OreDict() { + run(); + } + + private static void run() { + // Koboldite + ItemStack aKobolditeDust = ItemUtils + .getItemStackWithMeta(Witchery.isModLoaded(), "witchery:ingredient", "Koboldite Dust", 148, 1); + ItemStack aKobolditeNugget = ItemUtils + .getItemStackWithMeta(Witchery.isModLoaded(), "witchery:ingredient", "Koboldite Nugget", 149, 1); + ItemStack aKobolditeIngot = ItemUtils + .getItemStackWithMeta(Witchery.isModLoaded(), "witchery:ingredient", "Koboldite Ingot", 150, 1); + if (aKobolditeDust != null) GT_OreDictUnificator.registerOre("dust" + "Koboldite", aKobolditeDust); + if (aKobolditeNugget != null) GT_OreDictUnificator.registerOre("nugget" + "Koboldite", aKobolditeNugget); + if (aKobolditeIngot != null) GT_OreDictUnificator.registerOre("ingot" + "Koboldite", aKobolditeIngot); + } +} diff --git a/src/main/java/gtPlusPlus/core/config/ConfigHandler.java b/src/main/java/gtPlusPlus/core/config/ConfigHandler.java new file mode 100644 index 0000000000..162d5b0f12 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/config/ConfigHandler.java @@ -0,0 +1,670 @@ +package gtPlusPlus.core.config; + +import static gregtech.api.enums.Mods.GregTech; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.MACHINE_INFO; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.baseMaxPollutionPerSecondRocketFuelGenerator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.baseMinPollutionPerSecondRocketFuelGenerator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.basePollutionPerSecondBoiler; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.basePollutionPerSecondGeothermalGenerator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.basePollutionPerSecondSemiFluidGenerator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.boilerSteamPerSecond; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.disableIC2Recipes; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.dumpItemAndBlockData; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableAnimatedTextures; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableCustomCapes; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableCustom_Cables; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableCustom_Pipes; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMachine_Dehydrators; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMachine_FluidTanks; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMachine_GeothermalEngines; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMachine_Pollution; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMachine_RocketEngines; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMachine_SimpleWasher; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMachine_SteamConverter; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMachine_Tesseracts; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_AlloyBlastSmelter; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_Cyclotron; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialCentrifuge; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialCokeOven; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialCuttingMachine; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialElectrolyzer; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialExtrudingMachine; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialFishingPort; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialMacerationStack; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialMultiMachine; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialPlatePress; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialSifter; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialThermalCentrifuge; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialWashPlant; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialWireMill; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_LargeAutoCrafter; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_LiquidFluorideThoriumReactor; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_MatterFabricator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_MultiTank; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_NuclearFuelRefinery; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_NuclearSaltProcessingPlant; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_PowerSubstation; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_ThermalBoiler; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableThaumcraftShardUnification; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableWatchdogBGM; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.hideUniversalCells; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiABS; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDT; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDistillery; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiAdvEBF; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiAdvImplosion; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiAlgaePond; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiAutoCrafter; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiCyclotron; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiFrothFlotationCell; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialAlloySmelter; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialArcFurnace; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCentrifuge; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialChisel; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCokeOven; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCuttingMachine; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialDehydrator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialElectrolyzer; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialExtruder; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialFishingPond; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialForgeHammer; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMacerator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMixer; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeBending; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeForming; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialRockBreaker; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialSifter; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialThermalCentrifuge; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialVacuumFreezer; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeWasher; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWireMill; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiIsaMill; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiLargeSemiFluidGenerator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiMassFabricator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiMolecularTransformer; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiPackager; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiRefinery; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiThermalBoiler; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionPerSecondMultiTreeFarm; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionReleasedByTierBoiler; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionReleasedByTierGeothermalGenerator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.pollutionReleasedByTierSemiFluidGenerator; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.showHiddenNEIItems; +import static gtPlusPlus.core.lib.CORE.EVERGLADESBIOME_ID; +import static gtPlusPlus.core.lib.CORE.EVERGLADES_ID; +import static gtPlusPlus.core.lib.CORE.turbineCutoffBase; + +import java.io.File; + +import net.minecraftforge.common.config.Configuration; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class ConfigHandler { + + public static void handleConfigFile(final FMLPreInitializationEvent event) { + final Configuration config = new Configuration( + new File(event.getModConfigurationDirectory(), "GTplusplus/GTplusplus.cfg")); + config.load(); + + // Debug + /* + * DEBUG = config.getBoolean("debugMode", "debug", false, + * "Enables all sorts of debug logging. (Don't use unless told to, breaks other things.)"); + */ + MACHINE_INFO = config.getBoolean( + "enableMachineInfoLogging", + "debug", + false, + "Makes many machines display lots of debug logging."); + showHiddenNEIItems = config + .getBoolean("showHiddenNEIItems", "debug", false, "Makes all items hidden from NEI display."); + dumpItemAndBlockData = config.getBoolean( + "dumpItemAndBlockData", + "debug", + false, + "Dumps all GT++ and Toxic Everglade Data to en_US.lang in the config folder. This config option can be used by foreign players to generate blank .lang files, which they can populate with their language of choice."); + + // Machines + enableThaumcraftShardUnification = config.getBoolean( + "enableThaumcraftShardUnification", + "machines", + false, + "Allows the use of TC shards across many recipes by oreDicting them into a common group."); + disableIC2Recipes = config.getBoolean( + "disableIC2Recipes", + "machines", + false, + "Alkaluscraft Related - Removes IC2 Cables Except glass fibre. Few other Misc Tweaks."); + boilerSteamPerSecond = config.getInt( + "boilerSteamPerSecond", + "machines", + 750, + 0, + 10000, + "Sets the steam per second value in LV,MV,HV boilers (respectively 1x,2x,3x this number for the tiers)"); + + // GT-Fixes + turbineCutoffBase = config.getInt( + "turbineCutoffBase", + GregTech.ID, + 75000, + 0, + Integer.MAX_VALUE, + "Rotors below this durability will be removed, prevents NEI clutter. Minimum Durability is N * x, where N is the new value set and x is the turbine size, where 1 is Tiny and 4 is Huge. Set to 0 to disable."); + + // Pipes & Cables + enableCustom_Pipes = config.getBoolean("enableCustom_Pipes", GregTech.ID, true, "Adds Custom GT Fluid Pipes."); + enableCustom_Cables = config.getBoolean("enableCustom_Cables", GregTech.ID, true, "Adds Custom GT Cables."); + + enableMachine_Dehydrators = config + .getBoolean("enableMachineDehydrators", GregTech.ID, true, "These dehydrate stuff."); + enableMachine_SteamConverter = config + .getBoolean("enableMachineSteamConverter", GregTech.ID, true, "Converts IC2 steam -> Railcraft steam."); + enableMachine_FluidTanks = config + .getBoolean("enableMachineFluidTanks", GregTech.ID, true, "Portable fluid tanks."); + enableMachine_RocketEngines = config.getBoolean( + "enableMachineRocketEngines", + GregTech.ID, + true, + "Diesel egines with different internals, they consume less fuel overall."); + enableMachine_GeothermalEngines = config.getBoolean( + "enableMachineGeothermalEngines", + GregTech.ID, + true, + "These may be overpowered, Consult a local geologist."); + enableMachine_Tesseracts = config + .getBoolean("enableMachineTesseracts", GregTech.ID, true, "Tesseracts for wireless item/fluid movement."); + enableMachine_SimpleWasher = config.getBoolean( + "enableMachineSimpleWasher", + GregTech.ID, + true, + "Very basic automated cauldron for dust washing."); + enableMachine_Pollution = config + .getBoolean("enableMachinePollution", GregTech.ID, true, "Pollution Detector & Scrubbers."); + + // Multi machines + enableMultiblock_AlloyBlastSmelter = config.getBoolean( + "enableMultiblockAlloyBlastSmelter", + GregTech.ID, + true, + "Required to smelt most high tier materials from GT++. Also smelts everything else to molten metal."); + enableMultiblock_IndustrialCentrifuge = config + .getBoolean("enableMultiblockIndustrialCentrifuge", GregTech.ID, true, "Spin, Spin, Spiiiin."); + enableMultiblock_IndustrialCokeOven = config.getBoolean( + "enableMultiblockIndustrialCokeOven", + GregTech.ID, + true, + "Pyro Oven Alternative, older, more realistic, better."); + enableMultiblock_IndustrialElectrolyzer = config.getBoolean( + "enableMultiblockIndustrialElectrolyzer", + GregTech.ID, + true, + "Electrolyzes things with extra bling factor."); + enableMultiblock_IndustrialMacerationStack = config.getBoolean( + "enableMultiblockIndustrialMacerationStack", + GregTech.ID, + true, + "A hyper efficient maceration tower, nets more bonus outputs."); + enableMultiblock_IndustrialPlatePress = config.getBoolean( + "enableMultiblockIndustrialPlatePress", + GregTech.ID, + true, + "Industrial bendering machine thingo."); + enableMultiblock_IndustrialWireMill = config.getBoolean( + "enableMultiblockIndustrialWireMill", + GregTech.ID, + true, + "Produces fine wire and exotic cables."); + enableMultiblock_MatterFabricator = config + .getBoolean("enableMultiblockMatterFabricator", GregTech.ID, true, "?FAB?RIC?ATE MA?TT?ER."); + enableMultiblock_MultiTank = config.getBoolean( + "enableMultiblockMultiTank", + GregTech.ID, + true, + "Tall tanks, each layer adds extra fluid storage."); + enableMultiblock_PowerSubstation = config + .getBoolean("enableMultiblockPowerSubstation", GregTech.ID, true, "For managing large power grids."); + enableMultiblock_LiquidFluorideThoriumReactor = config.getBoolean( + "enableMultiblockLiquidFluorideThoriumReactor", + GregTech.ID, + true, + "For supplying large power grids."); + enableMultiblock_NuclearFuelRefinery = config.getBoolean( + "enableMultiblock_NuclearFuelRefinery", + GregTech.ID, + true, + "Refines molten chemicals into nuclear fuels."); + enableMultiblock_NuclearSaltProcessingPlant = config.getBoolean( + "enableMultiblockNuclearSaltProcessingPlant", + GregTech.ID, + true, + "Reprocesses depleted nuclear salts into useful chemicals."); + enableMultiblock_IndustrialSifter = config + .getBoolean("enableMultiblock_IndustrialSifter", GregTech.ID, true, "Large scale sifting."); + enableMultiblock_LargeAutoCrafter = config.getBoolean( + "enableMultiblock_LargeAutoCrafter", + GregTech.ID, + true, + "Can Assemble, Disassemble and Craft Project data from Data Sticks."); + enableMultiblock_IndustrialThermalCentrifuge = config.getBoolean( + "enableMultiblock_IndustrialThermalCentrifuge", + GregTech.ID, + true, + "Your warm spin for the ore thing."); + enableMultiblock_IndustrialWashPlant = config.getBoolean( + "enableMultiblock_IndustrialWashPlant", + GregTech.ID, + true, + "Used to wash the dirt, riiiiight offff.."); + enableMultiblock_ThermalBoiler = config.getBoolean( + "enableMachineThermalBoiler", + GregTech.ID, + true, + "Thermal Boiler from GT4. Can Filter Lava for resources."); + enableMultiblock_IndustrialCuttingMachine = config.getBoolean( + "enableMultiblock_IndustrialCuttingMachine", + GregTech.ID, + true, + "Very fast and efficient Cutting Machine."); + enableMultiblock_IndustrialFishingPort = config + .getBoolean("enableMultiblock_IndustrialFishingPort", GregTech.ID, true, "Fish the seas, except on land."); + enableMultiblock_IndustrialExtrudingMachine = config.getBoolean( + "enableMultiblock_IndustrialExtrudingMachine", + GregTech.ID, + true, + "Very fast and efficient Extruding Machine."); + enableMultiblock_IndustrialMultiMachine = config.getBoolean( + "enableMultiblock_IndustrialMultiMachine", + GregTech.ID, + true, + "Can run recipes for 9 different types of machines."); + enableMultiblock_Cyclotron = config + .getBoolean("enableMultiblock_Cyclotron", GregTech.ID, true, "COMET - Scientific Cyclotron."); + + // Features + enableCustomCapes = config.getBoolean("enableSupporterCape", "features", true, "Enables Custom GT++ Cape."); + + 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."); + hideUniversalCells = config + .getBoolean("hideUniversalCells", "features", true, "Hides every filled IC2 Universal Cell from NEI."); + + // Biomes + EVERGLADES_ID = config.getInt("darkworld_ID", "worldgen", 227, 1, 254, "The ID of the Dark Dimension."); + EVERGLADESBIOME_ID = config + .getInt("darkbiome_ID", "worldgen", 238, 1, 254, "The biome within the Dark Dimension."); + + // Pollution + pollutionPerSecondMultiPackager = config + .get( + "pollution", + "pollutionPerSecondMultiPackager", + pollutionPerSecondMultiPackager, + "pollution rate in gibbl/s for the Amazon warehousing depot") + .getInt(pollutionPerSecondMultiPackager); + pollutionPerSecondMultiIndustrialAlloySmelter = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialAlloySmelter", + pollutionPerSecondMultiIndustrialAlloySmelter, + "pollution rate in gibbl/s for the Alloy blast smelter") + .getInt(pollutionPerSecondMultiIndustrialAlloySmelter); + pollutionPerSecondMultiIndustrialArcFurnace = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialArcFurnace", + pollutionPerSecondMultiIndustrialArcFurnace, + "pollution rate in gibbl/s for the High current arc furnace") + .getInt(pollutionPerSecondMultiIndustrialArcFurnace); + pollutionPerSecondMultiIndustrialCentrifuge = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialCentrifuge", + pollutionPerSecondMultiIndustrialCentrifuge, + "pollution rate in gibbl/s for the Industrial centrifuge") + .getInt(pollutionPerSecondMultiIndustrialCentrifuge); + pollutionPerSecondMultiIndustrialCokeOven = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialCokeOven", + pollutionPerSecondMultiIndustrialCokeOven, + "pollution rate in gibbl/s for the Industrial coke oven") + .getInt(pollutionPerSecondMultiIndustrialCokeOven); + pollutionPerSecondMultiIndustrialCuttingMachine = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialCuttingMachine", + pollutionPerSecondMultiIndustrialCuttingMachine, + "pollution rate in gibbl/s for the Cutting factory") + .getInt(pollutionPerSecondMultiIndustrialCuttingMachine); + pollutionPerSecondMultiIndustrialDehydrator = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialDehydrator", + pollutionPerSecondMultiIndustrialDehydrator, + "pollution rate in gibbl/s for the Utupu-Tanuri") + .getInt(pollutionPerSecondMultiIndustrialDehydrator); + pollutionPerSecondMultiIndustrialElectrolyzer = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialElectrolyzer", + pollutionPerSecondMultiIndustrialElectrolyzer, + "pollution rate in gibbl/s for the Industrial electrolyzer") + .getInt(pollutionPerSecondMultiIndustrialElectrolyzer); + pollutionPerSecondMultiIndustrialExtruder = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialExtruder", + pollutionPerSecondMultiIndustrialExtruder, + "pollution rate in gibbl/s for the Industrial extrusion machine") + .getInt(pollutionPerSecondMultiIndustrialExtruder); + pollutionPerSecondMultiIndustrialMacerator = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialMacerator", + pollutionPerSecondMultiIndustrialMacerator, + "pollution rate in gibbl/s for the Maceration stack") + .getInt(pollutionPerSecondMultiIndustrialMacerator); + pollutionPerSecondMultiIndustrialMixer = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialMixer", + pollutionPerSecondMultiIndustrialMixer, + "pollution rate in gibbl/s for the Industrial mixing machine") + .getInt(pollutionPerSecondMultiIndustrialMixer); + pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal", + pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal, + "pollution rate in gibbl/s for the Large processing factory in metal mode") + .getInt(pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal); + pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid", + pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid, + "pollution rate in gibbl/s for the Large processing factory in fluid mode") + .getInt(pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid); + pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc", + pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc, + "pollution rate in gibbl/s for the Large processing factory in misc mode") + .getInt(pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc); + pollutionPerSecondMultiIndustrialPlatePress_ModeForming = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialPlatePress_ModeForming", + pollutionPerSecondMultiIndustrialPlatePress_ModeForming, + "pollution rate in gibbl/s for the Industrial material press in forming mode") + .getInt(pollutionPerSecondMultiIndustrialPlatePress_ModeForming); + pollutionPerSecondMultiIndustrialPlatePress_ModeBending = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialPlatePress_ModeBending", + pollutionPerSecondMultiIndustrialPlatePress_ModeBending, + "pollution rate in gibbl/s for the Industrial material press in bending mode") + .getInt(pollutionPerSecondMultiIndustrialPlatePress_ModeBending); + pollutionPerSecondMultiIndustrialForgeHammer = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialForgeHammer", + pollutionPerSecondMultiIndustrialForgeHammer, + "pollution rate in gibbl/s for the Industrial Forge Hammer") + .getInt(pollutionPerSecondMultiIndustrialForgeHammer); + pollutionPerSecondMultiIndustrialSifter = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialSifter", + pollutionPerSecondMultiIndustrialSifter, + "pollution rate in gibbl/s for the Large Sifter") + .getInt(pollutionPerSecondMultiIndustrialSifter); + pollutionPerSecondMultiIndustrialThermalCentrifuge = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialThermalCentrifuge", + pollutionPerSecondMultiIndustrialThermalCentrifuge, + "pollution rate in gibbl/s for the Large thermal refinery") + .getInt(pollutionPerSecondMultiIndustrialThermalCentrifuge); + pollutionPerSecondMultiIndustrialVacuumFreezer = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialVacuumFreezer", + pollutionPerSecondMultiIndustrialVacuumFreezer, + "pollution rate in gibbl/s for the Cryogenic freezer") + .getInt(pollutionPerSecondMultiIndustrialVacuumFreezer); + pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath", + pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath, + "pollution rate in gibbl/s for the Ore washing plant in chemical bath mode") + .getInt(pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath); + pollutionPerSecondMultiIndustrialWashPlant_ModeWasher = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialWashPlant_ModeWasher", + pollutionPerSecondMultiIndustrialWashPlant_ModeWasher, + "pollution rate in gibbl/s for the Ore washing plant in ore washer mode") + .getInt(pollutionPerSecondMultiIndustrialWashPlant_ModeWasher); + pollutionPerSecondMultiIndustrialWireMill = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialWireMill", + pollutionPerSecondMultiIndustrialWireMill, + "pollution rate in gibbl/s for the Wire factory") + .getInt(pollutionPerSecondMultiIndustrialWireMill); + pollutionPerSecondMultiIsaMill = config + .get( + "pollution", + "pollutionPerSecondMultiIsaMill", + pollutionPerSecondMultiIsaMill, + "pollution rate in gibbl/s for the IsaMill grinding machine") + .getInt(pollutionPerSecondMultiIsaMill); + pollutionPerSecondMultiAdvDistillationTower_ModeDistillery = config + .get( + "pollution", + "pollutionPerSecondMultiAdvDistillationTower_ModeDistillery", + pollutionPerSecondMultiAdvDistillationTower_ModeDistillery, + "pollution rate in gibbl/s for the Dangote distillus in distillery mode") + .getInt(pollutionPerSecondMultiAdvDistillationTower_ModeDistillery); + pollutionPerSecondMultiAdvDistillationTower_ModeDT = config + .get( + "pollution", + "pollutionPerSecondMultiAdvDistillationTower_ModeDT", + pollutionPerSecondMultiAdvDistillationTower_ModeDT, + "pollution rate in gibbl/s for the Dangote distillus in distillation tower mode") + .getInt(pollutionPerSecondMultiAdvDistillationTower_ModeDT); + pollutionPerSecondMultiAdvEBF = config + .get( + "pollution", + "pollutionPerSecondMultiAdvEBF", + pollutionPerSecondMultiAdvEBF, + "pollution rate in gibbl/s for the Volcanus") + .getInt(pollutionPerSecondMultiAdvEBF); + pollutionPerSecondMultiAdvImplosion = config + .get( + "pollution", + "pollutionPerSecondMultiAdvImplosion", + pollutionPerSecondMultiAdvImplosion, + "pollution rate in gibbl/s for the Density^2") + .getInt(pollutionPerSecondMultiAdvImplosion); + pollutionPerSecondMultiABS = config + .get( + "pollution", + "pollutionPerSecondMultiABS", + pollutionPerSecondMultiABS, + "pollution rate in gibbl/s for the Alloy blast furnace") + .getInt(pollutionPerSecondMultiABS); + pollutionPerSecondMultiCyclotron = config + .get( + "pollution", + "pollutionPerSecondMultiCyclotron", + pollutionPerSecondMultiCyclotron, + "pollution rate in gibbl/s for the Cyclotron") + .getInt(pollutionPerSecondMultiCyclotron); + pollutionPerSecondMultiIndustrialFishingPond = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialFishingPond", + pollutionPerSecondMultiIndustrialFishingPond, + "pollution rate in gibbl/s for the Zuhai - fishing port") + .getInt(pollutionPerSecondMultiIndustrialFishingPond); + // pollutionPerSecondMultiLargeRocketEngine; + pollutionPerSecondMultiLargeSemiFluidGenerator = config + .get( + "pollution", + "pollutionPerSecondMultiLargeSemiFluidGenerator", + pollutionPerSecondMultiLargeSemiFluidGenerator, + "pollution rate in gibbl/s for the Large semifluid burner") + .getInt(pollutionPerSecondMultiLargeSemiFluidGenerator); + pollutionPerSecondMultiMassFabricator = config + .get( + "pollution", + "pollutionPerSecondMultiMassFabricator", + pollutionPerSecondMultiMassFabricator, + "pollution rate in gibbl/s for the Matter fabrication CPU") + .getInt(pollutionPerSecondMultiMassFabricator); + pollutionPerSecondMultiRefinery = config + .get( + "pollution", + "pollutionPerSecondMultiRefinery", + pollutionPerSecondMultiRefinery, + "pollution rate in gibbl/s for the Reactor fuel processing plant") + .getInt(pollutionPerSecondMultiRefinery); + // pollutionPerSecondMultiGeneratorArray; + pollutionPerSecondMultiIndustrialRockBreaker = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialRockBreaker", + pollutionPerSecondMultiIndustrialRockBreaker, + "pollution rate in gibbl/s for the Industrial Rock Breaker") + .getInt(pollutionPerSecondMultiIndustrialRockBreaker); + pollutionPerSecondMultiIndustrialChisel = config + .get( + "pollution", + "pollutionPerSecondMultiIndustrialChisel", + pollutionPerSecondMultiIndustrialChisel, + "pollution rate in gibbl/s for the Industrial Chisel") + .getInt(pollutionPerSecondMultiIndustrialChisel); + pollutionPerSecondMultiTreeFarm = config + .get( + "pollution", + "pollutionPerSecondMultiTreeFarm", + pollutionPerSecondMultiTreeFarm, + "pollution rate in gibbl/s for the Tree growth simulator") + .getInt(pollutionPerSecondMultiTreeFarm); + pollutionPerSecondMultiFrothFlotationCell = config + .get( + "pollution", + "pollutionPerSecondMultiFrothFlotationCell", + pollutionPerSecondMultiFrothFlotationCell, + "pollution rate in gibbl/s for the Flotation cell regulator") + .getInt(pollutionPerSecondMultiFrothFlotationCell); + pollutionPerSecondMultiAutoCrafter = config + .get( + "pollution", + "pollutionPerSecondMultiAutoCrafter", + pollutionPerSecondMultiAutoCrafter, + "pollution rate in gibbl/s for the Large-Scale auto assembler v1.01") + .getInt(pollutionPerSecondMultiAutoCrafter); + pollutionPerSecondMultiMolecularTransformer = config + .get( + "pollution", + "pollutionPerSecondMultiMolecularTransformer", + pollutionPerSecondMultiMolecularTransformer, + "pollution rate in gibbl/s for the Multiblock Molecular Transformer") + .getInt(pollutionPerSecondMultiMolecularTransformer); + pollutionPerSecondMultiThermalBoiler = config + .get( + "pollution", + "pollutionPerSecondMultiThermalBoiler", + pollutionPerSecondMultiThermalBoiler, + "pollution rate in gibbl/s for the Thermal boiler") + .getInt(pollutionPerSecondMultiThermalBoiler); + pollutionPerSecondMultiAlgaePond = config + .get( + "pollution", + "pollutionPerSecondMultiAlgaePond", + pollutionPerSecondMultiAlgaePond, + "pollution rate in gibbl/s for the Algae farm") + .getInt(pollutionPerSecondMultiAlgaePond); + basePollutionPerSecondSemiFluidGenerator = config + .get( + "pollution", + "basePollutionPerSecondSemiFluidGenerator", + basePollutionPerSecondSemiFluidGenerator, + "base pollution rate in gibbl/s for the single block semi fluid generators") + .getInt(basePollutionPerSecondSemiFluidGenerator); + pollutionReleasedByTierSemiFluidGenerator = config.get( + "pollution", + "pollutionReleasedByTierSemiFluidGenerator", + pollutionReleasedByTierSemiFluidGenerator, + "coefficient applied to the base rate of the single block semi fluid generators based on its tier (first is tier 0 aka ULV)") + .getDoubleList(); + basePollutionPerSecondBoiler = config + .get( + "pollution", + "basePollutionPerSecondBoiler", + basePollutionPerSecondBoiler, + "base pollution rate in gibbl/s for the single block boilers") + .getInt(basePollutionPerSecondBoiler); + pollutionReleasedByTierBoiler = config.get( + "pollution", + "pollutionReleasedByTierBoiler", + pollutionReleasedByTierBoiler, + "coefficient applied to the base rate of the single block semi fluid generators based on its tier (first is tier 0 aka ULV)") + .getDoubleList(); + baseMinPollutionPerSecondRocketFuelGenerator = config + .get( + "pollution", + "baseMinPollutionPerSecondRocketFuelGenerator", + baseMinPollutionPerSecondRocketFuelGenerator, + "minimum base pollution rate in gibbl/s for the single block rocket engines") + .getInt(baseMinPollutionPerSecondRocketFuelGenerator); + baseMaxPollutionPerSecondRocketFuelGenerator = config + .get( + "pollution", + "baseMaxPollutionPerSecondRocketFuelGenerator", + baseMaxPollutionPerSecondRocketFuelGenerator, + "maximum base pollution rate in gibbl/s for the single block rocket engines") + .getInt(baseMaxPollutionPerSecondRocketFuelGenerator); + pollutionReleasedByTierRocketFuelGenerator = config.get( + "pollution", + "pollutionReleasedByTierRocketFuelGenerator", + pollutionReleasedByTierRocketFuelGenerator, + "coefficient applied to the base rate of the single block rocket engines based on its tier (first is tier 0 aka ULV)") + .getDoubleList(); + basePollutionPerSecondGeothermalGenerator = config + .get( + "pollution", + "basePollutionPerSecondGeothermalGenerator", + basePollutionPerSecondGeothermalGenerator, + "base pollution rate in gibbl/s for the geothermal engines") + .getInt(basePollutionPerSecondGeothermalGenerator); + pollutionReleasedByTierGeothermalGenerator = config.get( + "pollution", + "pollutionReleasedByTierGeothermalGenerator", + pollutionReleasedByTierGeothermalGenerator, + "coefficient applied to the base rate of the single block geothermal engines based on its tier (first is tier 0 aka ULV)") + .getDoubleList(); + + // Visual + enableAnimatedTextures = config + .getBoolean("enableAnimatedTextures", "visual", true, "Enables Animated GT++ Textures, Requires Restart"); + config.save(); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_CircuitProgrammer.java b/src/main/java/gtPlusPlus/core/container/Container_CircuitProgrammer.java new file mode 100644 index 0000000000..f1e84f439f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/container/Container_CircuitProgrammer.java @@ -0,0 +1,176 @@ +package gtPlusPlus.core.container; + +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 gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.InventoryCircuitProgrammer; +import gtPlusPlus.core.slots.SlotIntegratedCircuit; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; + +public class Container_CircuitProgrammer extends Container { + + protected TileEntityCircuitProgrammer tile_entity; + public final InventoryCircuitProgrammer inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static final int SLOT_OUTPUT = 25; + + public static int StorageSlotNumber = 26; // 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_CircuitProgrammer(final InventoryPlayer inventory, final TileEntityCircuitProgrammer te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + Logger.INFO("1"); + + int o = 0; + + // Storage Side + /* + * for (var6 = 0; var6 < 3; var6++) { for (var7 = 0; var7 < 5; var7++) { this.addSlotToContainer(new + * SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18))); o++; } } + */ + + int xStart = 8; + int yStart = 5; + + try { + // 0 + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart, yStart)); + // 1-10 + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 18, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 36, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 54, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 72, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 90, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 108, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 18, yStart + 18)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 36, yStart + 18)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 54, yStart + 18)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 72, yStart + 18)); + // 11-20 + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 90, yStart + 18)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 108, yStart + 18)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 18, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 36, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 54, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 72, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 90, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 108, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 18, yStart + 54)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 36, yStart + 54)); + // 21-24 + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 54, yStart + 54)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 72, yStart + 54)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 90, yStart + 54)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 108, yStart + 54)); + Logger.INFO("2"); + + // Add Output + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_OUTPUT, xStart + (8 * 18), yStart + 54)); + o++; + Logger.INFO("3"); + + // 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)); + } + + Logger.INFO("4"); + } catch (Throwable t) {} + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + 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.blockCircuitProgrammer) { + 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_); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_DecayablesChest.java b/src/main/java/gtPlusPlus/core/container/Container_DecayablesChest.java new file mode 100644 index 0000000000..d8bab9395a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/container/Container_DecayablesChest.java @@ -0,0 +1,133 @@ +package gtPlusPlus.core.container; + +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 gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.Inventory_DecayablesChest; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; + +public class Container_DecayablesChest extends Container { + + protected TileEntityDecayablesChest tile_entity; + public final Inventory_DecayablesChest inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static int StorageSlotNumber = 15; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots + + private final int[] slotStorage = new int[15]; + + public Container_DecayablesChest(final InventoryPlayer inventory, final TileEntityDecayablesChest 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; + + // Storage Side + for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.slotStorage[o] = o; + this.addSlotToContainer(new Slot(this.inventoryChest, o++, 44 + (var7 * 18), 15 + (var6 * 18))); + } + } + + // 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)); + } + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @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.blockDecayablesChest) { + 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_); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_FishTrap.java b/src/main/java/gtPlusPlus/core/container/Container_FishTrap.java new file mode 100644 index 0000000000..881311897f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/container/Container_FishTrap.java @@ -0,0 +1,134 @@ +package gtPlusPlus.core.container; + +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 gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.InventoryFishTrap; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; + +public class Container_FishTrap extends Container { + + protected TileEntityFishTrap tile_entity; + public final InventoryFishTrap inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static int StorageSlotNumber = 15; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots + + private final int[] slotStorage = new int[15]; + + public Container_FishTrap(final InventoryPlayer inventory, final TileEntityFishTrap 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; + + // Storage Side + for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.slotStorage[o] = o; + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, 44 + (var7 * 18), 15 + (var6 * 18))); + } + } + + // 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)); + } + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @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.blockFishTrap) { + 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_); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_PestKiller.java b/src/main/java/gtPlusPlus/core/container/Container_PestKiller.java new file mode 100644 index 0000000000..d6afa0d68f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/container/Container_PestKiller.java @@ -0,0 +1,147 @@ +package gtPlusPlus.core.container; + +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; + +import gregtech.api.gui.GT_Slot_Render; +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; + +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_); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_ProjectTable.java b/src/main/java/gtPlusPlus/core/container/Container_ProjectTable.java new file mode 100644 index 0000000000..1702be19ab --- /dev/null +++ b/src/main/java/gtPlusPlus/core/container/Container_ProjectTable.java @@ -0,0 +1,196 @@ +package gtPlusPlus.core.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCraftResult; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.world.World; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.projecttable.InventoryProjectMain; +import gtPlusPlus.core.inventories.projecttable.InventoryProjectOutput; +import gtPlusPlus.core.slots.SlotCraftingNoCollect; +import gtPlusPlus.core.slots.SlotDataStick; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; + +public class Container_ProjectTable extends Container { + + /** The crafting matrix inventory (3x3). */ + public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); + + public IInventory craftResult = new InventoryCraftResult(); + + protected TileEntityProjectTable tile_entity; + public final InventoryProjectMain inventoryGrid; + public final InventoryProjectOutput inventoryOutputs; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + private final int[] slotOutputs = new int[2]; + private final int[] slotGrid = new int[9]; + + public Container_ProjectTable(final InventoryPlayer inventory, final TileEntityProjectTable tile) { + this.tile_entity = tile; + this.inventoryGrid = tile.inventoryGrid; + this.inventoryOutputs = tile.inventoryOutputs; + this.tile_entity.setContainer(this); + + int var6; + int var7; + this.worldObj = tile.getWorldObj(); + this.posX = tile.xCoord; + this.posY = tile.yCoord; + this.posZ = tile.zCoord; + + int nextFreeSlot = 0; + + // Output slots + this.addSlotToContainer(new SlotDataStick(this.inventoryOutputs, 0, 26 + (18 * 6), 8)); + this.addSlotToContainer(new SlotNoInput(this.inventoryOutputs, 1, 26 + (18 * 6), 44)); + + this.addSlotToContainer( + new SlotCraftingNoCollect(inventory.player, this.craftMatrix, this.craftResult, 0, 26 + (18 * 4), 25)); + + int o = 0; + // Storage Side + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 3; ++var7) { + this.addSlotToContainer( + new Slot(this.craftMatrix, nextFreeSlot, 8 + 18 + (var7 * 18), 8 + (var6 * 18))); + this.slotGrid[o] = nextFreeSlot; + nextFreeSlot++; + o++; + } + } + + // 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)); + } + + this.onCraftMatrixChanged(this.craftMatrix); + } + + /** + * Callback for when the crafting matrix is changed. + */ + @Override + public void onCraftMatrixChanged(IInventory p_75130_1_) { + this.craftResult.setInventorySlotContents( + 0, + CraftingManager.getInstance() + .findMatchingRecipe(this.craftMatrix, this.worldObj)); + } + + /** + * Called when the container is closed. + */ + @Override + public void onContainerClosed(EntityPlayer p_75134_1_) { + super.onContainerClosed(p_75134_1_); + if (!this.worldObj.isRemote) { + for (int i = 0; i < 9; ++i) { + ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); + if (itemstack != null) { + p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); + } + } + } + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + + if (aSlotIndex == 0) { + Logger.INFO("Player Clicked on the Data Stick slot"); + // TODO + } + if (aSlotIndex == 1) { + Logger.INFO("Player Clicked on the output slot"); + // TODO + } + + for (final int x : this.slotGrid) { + if (aSlotIndex == x) { + Logger.INFO("Player Clicked slot " + aSlotIndex + " in the crafting Grid"); + } + } + } + // Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid"); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockProjectTable) { + 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) { + + return null; + + /* + * 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(ItemStack p_94530_1_, Slot p_94530_2_) { + return p_94530_2_.inventory != this.craftResult && super.func_94530_a(p_94530_1_, p_94530_2_); + } + + public ItemStack getOutputContent() { + ItemStack output = this.craftResult.getStackInSlot(0); + if (output != null) { + return output; + } + return null; + } + + public ItemStack[] getInputComponents() { + ItemStack inputs[] = new ItemStack[9]; + for (int r = 0; r < this.craftMatrix.getSizeInventory(); r++) { + ItemStack temp = this.craftMatrix.getStackInSlot(r); + inputs[r] = temp; + } + return inputs; + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_SuperJukebox.java b/src/main/java/gtPlusPlus/core/container/Container_SuperJukebox.java new file mode 100644 index 0000000000..ab7525c897 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/container/Container_SuperJukebox.java @@ -0,0 +1,232 @@ +package gtPlusPlus.core.container; + +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; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox; +import gtPlusPlus.core.inventories.Inventory_SuperJukebox; +import gtPlusPlus.core.slots.SlotJukebox; +import gtPlusPlus.core.slots.SlotNoInput; + +public class Container_SuperJukebox extends Container { + + protected TileEntitySuperJukebox tile_entity; + public final Inventory_SuperJukebox inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static final int SLOT_HOLO_PLAY = 18; + public static final int SLOT_HOLO_LOOP = 19; + public static final int SLOT_OUTPUT = 20; + + public static int StorageSlotNumber = 26; // 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_SuperJukebox(final InventoryPlayer inventory, final TileEntitySuperJukebox te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + Logger.INFO("1"); + + int o = 0; + + // Storage Side + /* + * for (var6 = 0; var6 < 3; var6++) { for (var7 = 0; var7 < 5; var7++) { this.addSlotToContainer(new + * SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18))); o++; } } + */ + + int xStart = 9; + int yStart = 20; + + try { + + // Row One + for (int c = 0; c < 9; c++) { + if (c >= 3 && c < 6) { + continue; + } + this.addSlotToContainer(new SlotJukebox(this.inventoryChest, o++, xStart + (18 * c), yStart)); + } + + // Row Two + for (int c = 0; c < 9; c++) { + if (c >= 3 && c < 6) { + continue; + } + this.addSlotToContainer(new SlotJukebox(this.inventoryChest, o++, xStart + (18 * c), yStart + 18)); + } + + // Row Two + for (int c = 0; c < 9; c++) { + if (c >= 3 && c < 6) { + continue; + } + this.addSlotToContainer(new SlotJukebox(this.inventoryChest, o++, xStart + (18 * c), yStart + 36)); + } + + // Controls + int c = 4; + + // Two Control Buttons + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_HOLO_PLAY, xStart + (18 * c), 12)); + this.addSlotToContainer( + new SlotNoInput(this.inventoryChest, SLOT_HOLO_LOOP, xStart + (18 * c), 12 + (1 * 18))); + + // Active playing slot for visual + this.addSlotToContainer( + new SlotJukebox(this.inventoryChest, SLOT_OUTPUT, xStart + (18 * c), 18 + (2 * 18), true)); + + // 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)); + } + + Logger.INFO("3"); + + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @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.blockCustomJukebox) { + 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_); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (tile_entity == null || tile_entity.getWorldObj().isRemote) return null; + switch (aSlotIndex) { + case SLOT_HOLO_PLAY -> { + if (tile_entity == null) return null; + tile_entity.mIsPlaying = !tile_entity.mIsPlaying; + Logger.INFO("Jukebox | Playing: " + tile_entity.mIsPlaying); + tile_entity.jukeboxLogicUpdate(); + return null; + } + case SLOT_HOLO_LOOP -> { + if (tile_entity == null) return null; + tile_entity.mIsLooping = !tile_entity.mIsLooping; + Logger.INFO("Jukebox | Looping: " + tile_entity.mIsLooping); + return null; + } + case 20 -> { + return null; + } + default -> { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + } + } + + public boolean isPlaying; + public boolean isLooping; + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (tile_entity == null || tile_entity.getWorldObj().isRemote) return; + + isPlaying = tile_entity.mIsPlaying; + isLooping = tile_entity.mIsLooping; + + for (Object crafter : this.crafters) { + ICrafting var1 = (ICrafting) crafter; + var1.sendProgressBarUpdate(this, 102, isPlaying ? 1 : 0); + var1.sendProgressBarUpdate(this, 103, isLooping ? 1 : 0); + } + } + + @Override + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 102 -> isPlaying = (par2 != 0); + case 103 -> isLooping = (par2 != 0); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java new file mode 100644 index 0000000000..0315967263 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java @@ -0,0 +1,170 @@ +package gtPlusPlus.core.container; + +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; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.Inventory_VolumetricFlaskSetter; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.slots.SlotVolumetricFlask; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import gtPlusPlus.core.util.Utils; + +public class Container_VolumetricFlaskSetter extends Container { + + public TileEntityVolumetricFlaskSetter mTileEntity; + public final Inventory_VolumetricFlaskSetter inventoryChest; + + public int mCustomValue; + private int oCustomValue; + private int mTimer; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static final int SLOT_OUTPUT = 8; + + public static int StorageSlotNumber = 8; // 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_VolumetricFlaskSetter(final InventoryPlayer inventory, final TileEntityVolumetricFlaskSetter te) { + this.mTileEntity = te; + this.inventoryChest = te.getInventory(); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + // mCustomValue = te.getCustomValue(); + + int o = 0; + + // Storage Side + /* + * for (var6 = 0; var6 < 3; var6++) { for (var7 = 0; var7 < 5; var7++) { this.addSlotToContainer(new + * SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18))); o++; } } + */ + + int xStart = 26; + int yStart = 12; + + try { + // 0 + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart + 18)); + + // Add Output + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, 8 + (8 * 18), 59)); + o++; + + // 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)); + } + detectAndSendChanges(); + } catch (Throwable t) {} + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockVolumetricFlaskSetter) { + 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; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if ((Utils.isClient()) || (this.mTileEntity == null)) { + return; + } + + mCustomValue = mTileEntity.getCustomValue(); + mTimer++; + + for (Object crafter : this.crafters) { + ICrafting var1 = (ICrafting) crafter; + if (mTimer % 20 == 10 || oCustomValue != mCustomValue) { + var1.sendProgressBarUpdate(this, 0, mCustomValue); + } + } + + oCustomValue = mCustomValue; + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 0 -> mCustomValue = (short) par2; + } + } + + public void log(String aString) { + Logger.INFO("[Flask-Container] " + aString); + } +} diff --git a/src/main/java/gtPlusPlus/core/creative/AddToCreativeTab.java b/src/main/java/gtPlusPlus/core/creative/AddToCreativeTab.java new file mode 100644 index 0000000000..fa0d3844b2 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/creative/AddToCreativeTab.java @@ -0,0 +1,25 @@ +package gtPlusPlus.core.creative; + +import net.minecraft.creativetab.CreativeTabs; + +import gregtech.api.util.GT_CreativeTab; + +public class AddToCreativeTab { + + public static CreativeTabs tabBlock; + public static CreativeTabs tabMisc; + public static CreativeTabs tabTools; + public static CreativeTabs tabMachines; + public static CreativeTabs tabOther; + public static CreativeTabs tabBOP; + + public static void initialiseTabs() { + // GT_CreativeTab + tabBlock = new GT_CreativeTab("GTPP_BLOCKS", "GT++ Blocks"); + tabMisc = new GT_CreativeTab("GTPP_MISC", "GT++ Misc"); + tabTools = new GT_CreativeTab("GTPP_TOOLS", "GT++ Tools"); + tabMachines = new GT_CreativeTab("GTPP_MACHINES", "GT++ Machines"); + tabOther = new GT_CreativeTab("GTPP_OTHER", "GT++ Other"); + tabBOP = new GT_CreativeTab("GTPP_OTHER_2", "GT++ Other II"); + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/EntityPrimedMiningExplosive.java b/src/main/java/gtPlusPlus/core/entity/EntityPrimedMiningExplosive.java new file mode 100644 index 0000000000..99a86c447a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/entity/EntityPrimedMiningExplosive.java @@ -0,0 +1,405 @@ +package gtPlusPlus.core.entity; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.world.explosions.ExplosionHandler; + +public class EntityPrimedMiningExplosive extends EntityTNTPrimed { + + /** How long the fuse is */ + private EntityLivingBase tntPlacedBy; + + public EntityPrimedMiningExplosive(final World world) { + super(world); + this.fuse = 160; + this.preventEntitySpawning = true; + this.setSize(0.98F, 0.98F); + this.yOffset = this.height / 2.0F; + } + + public EntityPrimedMiningExplosive(final World world, final double x, final double y, final double z, + final EntityLivingBase placingEntity) { + this(world); + this.setPosition(x, y, z); + final float f = (float) (Math.random() * Math.PI * 2.0D); + this.motionX = -((float) Math.sin(f)) * 0.02F; + this.motionY = 0.20000000298023224D; + this.motionZ = -((float) Math.cos(f)) * 0.02F; + this.fuse = 160; + this.prevPosX = x; + this.prevPosY = y; + this.prevPosZ = z; + this.tntPlacedBy = placingEntity; + } + + @Override + protected void entityInit() {} + + /** + * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to + * prevent them from trampling crops + */ + @Override + protected boolean canTriggerWalking() { + return false; + } + + /** + * Returns true if other Entities should be prevented from moving through this Entity. + */ + @Override + public boolean canBeCollidedWith() { + return !this.isDead; + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.03999999910593033D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.onGround) { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + this.motionY *= -0.5D; + } + + if (this.fuse-- <= 0) { + this.setDead(); + + if (!this.worldObj.isRemote) { + this.explode(); + } + } else { + + int t = MathUtils.randInt(0, 15); + + if (t <= 2) { + int e = MathUtils.randInt(0, 3); + if (e <= 1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else if (e == 2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + } else if (t <= 4) { + int e = MathUtils.randInt(0, 5); + if (e <= 1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else if (e == 2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + } else if (t <= 6) { + int e = MathUtils.randInt(0, 4); + if (e <= 1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else if (e == 2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + } else if (t <= 8) { + int e = MathUtils.randInt(0, 1); + if (e <= 1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else if (e == 2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + } else if (t <= 10) { + int e = MathUtils.randInt(0, 6); + if (e <= 1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else if (e >= 2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + } + } + } + + private void explode() { + final float f = 100.0F; + + ExplosionHandler explode = new ExplosionHandler(); + explode.createExplosion(this.worldObj, this, this.posX, this.posY, this.posZ, f, false, true); + + /* + * this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true); + * this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, + * this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true); + * this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, + * this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true); + * this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, + * this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true); + * this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, + * this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true); + */ + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + protected void writeEntityToNBT(final NBTTagCompound tag) { + tag.setByte("Fuse", (byte) this.fuse); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + protected void readEntityFromNBT(final NBTTagCompound tag) { + this.fuse = tag.getByte("Fuse"); + } + + /** + * returns null or the entityliving it was placed or ignited by + */ + @Override + public EntityLivingBase getTntPlacedBy() { + return this.tntPlacedBy; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java b/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java new file mode 100644 index 0000000000..a971541bc2 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java @@ -0,0 +1,64 @@ +package gtPlusPlus.core.entity; + +import cpw.mods.fml.common.registry.EntityRegistry; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.entity.monster.EntitySickBlaze; +import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; +import gtPlusPlus.core.entity.projectile.EntityLightningAttack; +import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; +import gtPlusPlus.core.item.general.spawn.ItemCustomSpawnEgg; +import gtPlusPlus.core.util.Utils; + +public class InternalEntityRegistry { + + static int mEntityID = 0; + + public static void registerEntities() { + Logger.INFO("Registering GT++ Entities."); + + EntityRegistry.registerModEntity( + EntityPrimedMiningExplosive.class, + "MiningCharge", + mEntityID++, + GTplusplus.instance, + 64, + 20, + true); + + EntityRegistry + .registerModEntity(EntityToxinballSmall.class, "toxinBall", mEntityID++, GTplusplus.instance, 64, 20, true); + + EntityRegistry.registerModEntity( + EntityStaballoyConstruct.class, + "constructStaballoy", + mEntityID++, + GTplusplus.instance, + 64, + 20, + true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg( + 0, + "constructStaballoy", + Utils.rgbtoHexValue(20, 200, 20), + Utils.rgbtoHexValue(20, 20, 20)); + + EntityRegistry + .registerModEntity(EntitySickBlaze.class, "sickBlaze", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg( + 1, + "sickBlaze", + Utils.rgbtoHexValue(40, 180, 40), + Utils.rgbtoHexValue(75, 75, 75)); + + EntityRegistry.registerModEntity( + EntityLightningAttack.class, + "EntityLightningAttack", + mEntityID++, + GTplusplus.instance, + 64, + 20, + true); + + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java b/src/main/java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java new file mode 100644 index 0000000000..38940d3ad6 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java @@ -0,0 +1,224 @@ +package gtPlusPlus.core.entity.monster; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; + +public class EntitySickBlaze extends EntityMob { + + /** Random offset used in floating behaviour */ + private float heightOffset = 0.5F; + /** ticks until heightOffset is randomized */ + private int heightOffsetUpdateTime; + + private int field_70846_g; + private final int mDataWatcherID = 30; + + public EntitySickBlaze(World p_i1731_1_) { + super(p_i1731_1_); + this.isImmuneToFire = true; + this.experienceValue = 10; + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth) + .setBaseValue(20.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed) + .setBaseValue(1.5D); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage) + .setBaseValue(6.0D); + } + + @Override + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(mDataWatcherID, 0); + } + + /** + * Returns the sound this mob makes while it's alive. + */ + @Override + protected String getLivingSound() { + return "mob.blaze.breathe"; + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + @Override + protected String getHurtSound() { + return "mob.blaze.hit"; + } + + /** + * Returns the sound this mob makes on death. + */ + @Override + protected String getDeathSound() { + return "mob.blaze.death"; + } + + @Override + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float p_70070_1_) { + return 15728880; + } + + /** + * Gets how bright this entity is. + */ + @Override + public float getBrightness(float p_70013_1_) { + return p_70013_1_; + } + + /** + * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons + * use this to react to sunlight and start to burn. + */ + @Override + public void onLivingUpdate() { + if (!this.worldObj.isRemote) { + if (this.isWet()) { + this.attackEntityFrom(DamageSource.drown, 1.0F); + } + + --this.heightOffsetUpdateTime; + + if (this.heightOffsetUpdateTime <= 0) { + this.heightOffsetUpdateTime = 100; + this.heightOffset = 0.5F + (float) this.rand.nextGaussian() * 3.0F; + } + + if (this.getEntityToAttack() != null && this.getEntityToAttack().posY + this.getEntityToAttack() + .getEyeHeight() > this.posY + this.getEyeHeight() + this.heightOffset) { + this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D; + } + } + + if (!this.onGround && this.motionY < 0.0D) { + this.motionY *= 0.6D; + } + + for (int i = 0; i < 2; ++i) { + this.worldObj.spawnParticle( + "crit", + this.posX + (this.rand.nextDouble() - 0.5D) * this.width, + this.posY + this.rand.nextDouble() * this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * this.width, + 0.0D, + 0.0D, + 0.0D); + } + + super.onLivingUpdate(); + } + + /** + * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define their attack. + */ + @Override + protected void attackEntity(Entity entity, float p_70785_2_) { + if (this.attackTime <= 0 && p_70785_2_ < 2.0F + && entity.boundingBox.maxY > this.boundingBox.minY + && entity.boundingBox.minY < this.boundingBox.maxY) { + this.attackTime = 20; + this.attackEntityAsMob(entity); + } else if (p_70785_2_ < 30.0F) { + double d0 = entity.posX - this.posX; + double d1 = entity.boundingBox.minY + entity.height / 2.0F - (this.posY + this.height / 2.0F); + double d2 = entity.posZ - this.posZ; + + if (this.attackTime == 0) { + ++this.field_70846_g; + + if (this.field_70846_g == 1) { + this.attackTime = 60; + } else if (this.field_70846_g <= 4) { + this.attackTime = 6; + } else { + this.attackTime = 100; + this.field_70846_g = 0; + } + + if (this.field_70846_g > 1) { + float f1 = MathHelper.sqrt_float(p_70785_2_) * 0.5F; + this.worldObj.playAuxSFXAtEntity(null, 1009, (int) this.posX, (int) this.posY, (int) this.posZ, 0); + + for (int i = 0; i < 1; ++i) { + EntityToxinballSmall entitysmalltoxinball = new EntityToxinballSmall( + this.worldObj, + this, + d0 + this.rand.nextGaussian() * f1, + d1, + d2 + this.rand.nextGaussian() * f1); + entitysmalltoxinball.posY = this.posY + this.height / 2.0F + 0.5D; + this.worldObj.spawnEntityInWorld(entitysmalltoxinball); + } + } + } + + this.rotationYaw = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; + this.hasAttacked = true; + } + } + + /** + * Called when the mob is falling. Calculates and applies fall damage. + */ + @Override + protected void fall(float p_70069_1_) {} + + @Override + protected Item getDropItem() { + return Items.slime_ball; + } + + /** + * Returns true if the entity is on fire. Used by render to add the fire effect on rendering. + */ + @Override + public boolean isBurning() { + return false; + } + + /** + * 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. + */ + @Override + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { + if (p_70628_1_) { + int j = this.rand.nextInt(2 + p_70628_2_); + + for (int k = 0; k < j; ++k) { + this.dropItem(getDropItem(), 1); + } + } + } + + /** + * Checks to make sure the light is not too bright where the mob is spawning + */ + @Override + protected boolean isValidLightLevel() { + return true; + } + + @Override + public int getMaxSpawnedInChunk() { + return 8; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java b/src/main/java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java new file mode 100644 index 0000000000..c58f5ba9df --- /dev/null +++ b/src/main/java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java @@ -0,0 +1,652 @@ +package gtPlusPlus.core.entity.monster; + +import java.lang.reflect.Field; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIAttackOnCollide; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; +import net.minecraft.entity.ai.EntityAIMoveTowardsTarget; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.village.Village; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.core.world.explosions.ExplosionHandler; + +public class EntityStaballoyConstruct extends EntityIronGolem { + + /* + * Determines whether or not the entity is in a fluid at all. + */ + private boolean inFluid = false; + private boolean mReflectFirstUpdate = true; + private boolean isReadyToExplode = false; + private int fuse = 60; + private int attackTimer; + + public EntityStaballoyConstruct(World world) { + super(world); + this.experienceValue = 250; + this.setSize(1.4F, 2.9F); + this.getNavigator() + .setAvoidsWater(true); + this.getNavigator() + .setBreakDoors(true); + this.getNavigator() + .setCanSwim(false); + this.getNavigator() + .setAvoidSun(false); + this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); + this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); + // this.tasks.addTask(3, new EntityAIMoveThroughVillage(this, 0.6D, true)); + this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D)); + this.tasks.addTask(4, new EntityAIWander(this, 0.6D)); + this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(6, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask( + 2, + new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector)); + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(NBTTagCompound p_70014_1_) { + super.writeEntityToNBT(p_70014_1_); + p_70014_1_.setBoolean("inFluid", this.inFluid); + p_70014_1_.setBoolean("isReadyToExplode", this.isReadyToExplode); + p_70014_1_.setInteger("fuse", this.fuse); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(NBTTagCompound p_70037_1_) { + super.readEntityFromNBT(p_70037_1_); + this.inFluid = p_70037_1_.getBoolean("inFluid"); + this.isReadyToExplode = p_70037_1_.getBoolean("isReadyToExplode"); + this.fuse = p_70037_1_.getInteger("fuse"); + } + + @Override + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(17, Byte.valueOf((byte) 0)); + } + + /** + * Returns true if the newer Entity AI code should be run + */ + @Override + public boolean isAIEnabled() { + return true; + } + + /** + * main AI tick function, replaces updateEntityActionState + */ + @Override + protected void updateAITick() { + super.updateAITick(); + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth) + .setBaseValue(500.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed) + .setBaseValue(0.5D); + } + + /** + * Decrements the entity's air supply when underwater + */ + @Override + protected int decreaseAirSupply(int p_70682_1_) { + return 0; + } + + @Override + protected void collideWithEntity(Entity p_82167_1_) { + if (p_82167_1_ instanceof IMob && this.getRNG() + .nextInt(20) == 0) { + this.setAttackTarget((EntityLivingBase) p_82167_1_); + } + + super.collideWithEntity(p_82167_1_); + } + + /** + * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons + * use this to react to sunlight and start to burn. + */ + @Override + public void onLivingUpdate() { + super.onLivingUpdate(); + + if (this.attackTimer > 0) { + --this.attackTimer; + } + + if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D + && this.rand.nextInt(5) == 0) { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - this.yOffset); + int k = MathHelper.floor_double(this.posZ); + Block block = this.worldObj.getBlock(i, j, k); + + if (block.getMaterial() != Material.air) { + this.worldObj.spawnParticle( + "blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(i, j, k), + this.posX + (this.rand.nextFloat() - 0.5D) * this.width, + this.boundingBox.minY + 0.1D, + this.posZ + (this.rand.nextFloat() - 0.5D) * this.width, + 4.0D * (this.rand.nextFloat() - 0.5D), + 0.5D, + (this.rand.nextFloat() - 0.5D) * 4.0D); + } + } + } + + /** + * Returns true if this entity can attack entities of the specified class. + */ + @Override + public boolean canAttackClass(Class clazz) { + return clazz.equals(this.getClass()) ? false : true; + } + + @Override + public boolean attackEntityAsMob(Entity p_70652_1_) { + this.attackTimer = 10; + this.worldObj.setEntityState(this, (byte) 4); + boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), 7 + this.rand.nextInt(15)); + + if (flag) { + p_70652_1_.motionY += 0.4000000059604645D; + } + + this.playSound("mob.irongolem.throw", 1.0F, 1.0F); + return flag; + } + + @Override + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte p_70103_1_) { + if (p_70103_1_ == 4) { + this.attackTimer = 10; + this.playSound("mob.irongolem.throw", 1.0F, 1.0F); + } else { + super.handleHealthUpdate(p_70103_1_); + } + } + + @Override + public Village getVillage() { + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public int getAttackTimer() { + return this.attackTimer; + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + @Override + protected String getHurtSound() { + return "mob.irongolem.hit"; + } + + /** + * Returns the sound this mob makes on death. + */ + @Override + protected String getDeathSound() { + return "mob.irongolem.death"; + } + + @Override + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { + this.playSound("mob.irongolem.walk", 1.0F, 1.0F); + } + + /** + * 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. + */ + @Override + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { + int lootingChance = p_70628_2_ + 1; + int j = this.rand.nextInt(3); + int k; + + for (k = 0; k < j; ++k) { + this.entityDropItem(ItemUtils.getItemStackOfAmountFromOreDict("blockStaballoy", 1), 0f); + } + + k = 3 + this.rand.nextInt(3); + + for (int l = 0; l < k; ++l) { + this.entityDropItem(ItemUtils.getItemStackOfAmountFromOreDict("ingotStaballoy", lootingChance), 0f); + if (MathUtils.randInt(0, 2) == 0) { + this.entityDropItem(ItemUtils.getItemStackOfAmountFromOreDict("plateStaballoy", lootingChance), 0f); + } + } + } + + @Override + public boolean isPlayerCreated() { + return false; + } + + @Override + public void setPlayerCreated(boolean p_70849_1_) {} + + /** + * Called when the mob's health reaches 0. + */ + @Override + public void onDeath(DamageSource p_70645_1_) { + super.onDeath(p_70645_1_); + } + + @Override + protected String getLivingSound() { // TODO + return super.getLivingSound(); + } + + @Override + public int getTalkInterval() { + return 0; + } + + @Override + protected boolean canDespawn() { + return true; + } + + @Override + public void onEntityUpdate() { + // Set Fire Immunity + if (!this.isImmuneToFire) { + this.isImmuneToFire = true; + } + + if (!this.worldObj.isRemote) { + final float hp = getHealth(); + final float modifier = MathUtils.randInt(5, 10) / 100F; + final float amountToExplode = (hp * modifier); + + if (hp <= amountToExplode && !isReadyToExplode) { + if (this.ticksExisted >= 50) { + // Logger.INFO("Construct has low hp, trying to enable explosions. HP: "+this.getHealth()+", Max: + // "+this.getMaxHealth()+", Mod: "+modifier); + // Logger.INFO("Construct required HP to be <= "+amountToExplode); + float r = MathUtils.randFloat(0, 10); + if (r <= 0.1) { + this.isReadyToExplode = true; + // Logger.INFO("Construct can now explode."); + } + } + } + // Handle Exploding + else if (hp <= amountToExplode && isReadyToExplode) { + // Logger.INFO("Trying to explode. ["+this.fuse+"]"); + if (this.fuse-- <= 0) { + // Logger.INFO("Fuse has run out."); + this.setDead(); + if (!this.worldObj.isRemote) { + this.explode(); + } + } else { + // Logger.INFO("Ticking fuse and spawning particles."); + + int maxFuse = 60; + int fuseUsed = maxFuse - this.fuse; + float var2 = (float) (fuseUsed * 0.1); + + this.setSize(1.4F + (var2 / 2), 2.9F + (var2 / 2)); + + float r = MathUtils.randFloat(0, 1); + int r2 = MathUtils.randInt(5, 15); + for (int o = 0; o < r2; o++) { + if (r <= 0.3) { + this.worldObj.spawnParticle( + "smoke", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.6) { + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + } + if (r <= 0.3) { + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.7) { + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + } + if (r <= 0.2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.5) { + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.7) { + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + } + } + } + } else { + + } + + // Get a private field from a super class if it exists. + if (mFirstUpdateField == null) { + mFirstUpdateField = ReflectionUtils.getField(this.getClass(), "firstUpdate"); + } + if (mFirstUpdateField != null && mReflectFirstUpdate == true) { + try { + this.mReflectFirstUpdate = (boolean) mFirstUpdateField.get(this); + } catch (IllegalArgumentException | IllegalAccessException e) {} + } + } + super.onEntityUpdate(); + } + + private static Field mFirstUpdateField; + + @Override + public int getMaxSpawnedInChunk() { + return 1; + } + + @Override + public boolean canBreatheUnderwater() { + return true; + } + + @Override + public void knockBack(Entity p_70653_1_, float p_70653_2_, double p_70653_3_, double p_70653_5_) {} + + @Override + protected void setOnFireFromLava() { + extinguish(); + } + + @Override + public void setFire(int p_70015_1_) { + extinguish(); + } + + @Override + protected void dealFireDamage(int p_70081_1_) {} + + @Override + public boolean isInWater() { + if (super.isInWater()) { + return true; + } else { + this.moveForward *= 0.98F; + return false; + } + } + + @Override + public boolean handleWaterMovement() { + this.moveForward *= 0.74F; + return handleFluidMovement(Material.water); + } + + @Override + public boolean handleLavaMovement() { + this.moveForward *= 0.74F; + return handleFluidMovement(Material.lava); + } + + /** + * Returns if this entity is in water and will end up adding the waters velocity to the entity + */ + public boolean handleFluidMovement(Material fluid) { + + if (this.worldObj.handleMaterialAcceleration( + this.boundingBox.expand(0.0D, -0.4000000059604645D, 0.0D) + .contract(0.001D, 0.001D, 0.001D), + fluid, + this)) { + if (!this.inFluid && !this.mReflectFirstUpdate) { + float f = MathHelper.sqrt_double( + this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + + this.motionZ * this.motionZ * 0.20000000298023224D) + * 0.2F; + + if (f > 1.0F) { + f = 1.0F; + } + + this.playSound(this.getSplashSound(), f, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); + float f1 = MathHelper.floor_double(this.boundingBox.minY); + int i; + float f2; + float f3; + + for (i = 0; i < 1.0F + this.width * 20.0F; ++i) { + f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + this.worldObj.spawnParticle( + "bubble", + this.posX + f2, + f1 + 1.0F, + this.posZ + f3, + this.motionX, + this.motionY - this.rand.nextFloat() * 0.2F, + this.motionZ); + } + + for (i = 0; i < 1.0F + this.width * 20.0F; ++i) { + f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + this.worldObj.spawnParticle( + "splash", + this.posX + f2, + f1 + 1.0F, + this.posZ + f3, + this.motionX, + this.motionY, + this.motionZ); + } + } + this.fallDistance = 0.0F; + this.inFluid = true; + } else { + this.inFluid = false; + } + return this.inFluid; + } + + @Override + public void onChunkLoad() { + // TODO Auto-generated method stub + super.onChunkLoad(); + } + + @Override + public void onStruckByLightning(EntityLightningBolt p_70077_1_) { + this.isReadyToExplode = true; + this.fuse = 20; + } + + private void explode() { + /* + * float f = 12.0F; this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true); + */ + + if (!this.worldObj.isRemote) { + final float f = 6.5F; + ExplosionHandler explode = new ExplosionHandler(); + explode.createExplosion(this.worldObj, this, this.posX, this.posY, this.posZ, f, true, true); + + float r = MathUtils.randFloat(0, 1); + int r2 = MathUtils.randInt(20, 40); + for (int o = 0; o < r2; o++) { + if (r <= 0.3) { + this.worldObj.spawnParticle( + "smoke", + this.posX + MathUtils.randDouble(-4, 4), + this.posY + MathUtils.randDouble(0, 3), + this.posZ + MathUtils.randDouble(-4, 4), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.6) { + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(-4, 4), + this.posY + MathUtils.randDouble(-4, 4), + this.posZ + MathUtils.randDouble(-4, 4), + 0.0D, + 0.0D, + 0.0D); + } + if (r <= 0.3) { + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(-4, 4), + this.posY + MathUtils.randDouble(-4, 4), + this.posZ + MathUtils.randDouble(-4, 4), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.7) { + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-4, 4), + this.posY + MathUtils.randDouble(-4, 4), + this.posZ + MathUtils.randDouble(-4, 4), + 0.0D, + 0.0D, + 0.0D); + } + if (r <= 0.2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(-4, 4), + this.posY + MathUtils.randDouble(-4, 4), + this.posZ + MathUtils.randDouble(-4, 4), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.5) { + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(-4, 4), + this.posY + MathUtils.randDouble(-4, 4), + this.posZ + MathUtils.randDouble(-4, 4), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.7) { + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(-4, 4), + this.posY + MathUtils.randDouble(-4, 4), + this.posZ + MathUtils.randDouble(-4, 4), + 0.0D, + 0.0D, + 0.0D); + } + } + } + } + + @Override + public boolean canAttackWithItem() { + return true; + } + + @Override + public boolean canRenderOnFire() { + return false; + } + + @Override + public boolean isPushedByWater() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/projectile/EntityLightningAttack.java b/src/main/java/gtPlusPlus/core/entity/projectile/EntityLightningAttack.java new file mode 100644 index 0000000000..e1a4063f49 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/entity/projectile/EntityLightningAttack.java @@ -0,0 +1,79 @@ +package gtPlusPlus.core.entity.projectile; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.projectile.EntityWitherSkull; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class EntityLightningAttack extends EntityWitherSkull { + + public EntityLightningAttack(World p_i1794_1_, EntityLivingBase p_i1794_2_, double p_i1794_3_, double p_i1794_5_, + double p_i1794_7_) { + super(p_i1794_1_, p_i1794_2_, p_i1794_3_, p_i1794_5_, p_i1794_7_); + this.setSize(0.3125F, 0.3125F); + } + + @SideOnly(Side.CLIENT) + public EntityLightningAttack(World p_i1795_1_, double p_i1795_2_, double p_i1795_4_, double p_i1795_6_, + double p_i1795_8_, double p_i1795_10_, double p_i1795_12_) { + super(p_i1795_1_, p_i1795_2_, p_i1795_4_, p_i1795_6_, p_i1795_8_, p_i1795_10_, p_i1795_12_); + this.setSize(0.3125F, 0.3125F); + } + + /** + * Called when this EntityFireball hits a block or entity. + */ + @Override + protected void onImpact(MovingObjectPosition p_70227_1_) { + + if (!this.worldObj.isRemote) { + if (p_70227_1_.entityHit != null) { + if (this.shootingEntity != null) { + if (p_70227_1_.entityHit.attackEntityFrom(DamageSource.causeMobDamage(this.shootingEntity), 8.0F) + && !p_70227_1_.entityHit.isEntityAlive()) { + this.shootingEntity.heal(0.5F); + } + } else { + p_70227_1_.entityHit.attackEntityFrom(DamageSource.lava, 10.0F); + } + + if (p_70227_1_.entityHit instanceof EntityLivingBase) { + byte b0 = 0; + + if (this.worldObj.difficultySetting == EnumDifficulty.NORMAL) { + b0 = 10; + } else if (this.worldObj.difficultySetting == EnumDifficulty.HARD) { + b0 = 40; + } + + if (b0 > 0) { + ((EntityLivingBase) p_70227_1_.entityHit) + .addPotionEffect(new PotionEffect(Potion.poison.id, 20 * b0, 1)); + ((EntityLivingBase) p_70227_1_.entityHit) + .addPotionEffect(new PotionEffect(Potion.confusion.id, 20 * b0, 1)); + ((EntityLivingBase) p_70227_1_.entityHit) + .addPotionEffect(new PotionEffect(Potion.weakness.id, 20 * b0, 1)); + } + } + } + + this.worldObj.newExplosion( + this, + this.posX, + this.posY, + this.posZ, + 1.0F, + false, + this.worldObj.getGameRules() + .getGameRuleBooleanValue("mobGriefing")); + this.setDead(); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinball.java b/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinball.java new file mode 100644 index 0000000000..a3b2f6f28b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinball.java @@ -0,0 +1,334 @@ +package gtPlusPlus.core.entity.projectile; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.projectile.EntityFireball; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public abstract class EntityToxinball extends EntityFireball { + + protected int entityX = -1; + protected int entityY = -1; + protected int entityZ = -1; + private Block block; + private boolean inGround; + private int ticksAlive; + private int ticksInAir; + + public EntityToxinball(World world) { + super(world); + this.setSize(1.0F, 1.0F); + } + + @Override + protected void entityInit() {} + + /** + * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge + * length * 64 * renderDistanceWeight Args: distance + */ + @Override + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double p_70112_1_) { + double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return p_70112_1_ < d1 * d1; + } + + public EntityToxinball(World world, double x, double y, double z, double f1, double f2, double f3) { + super(world); + this.setSize(1.0F, 1.0F); + this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch); + this.setPosition(x, y, z); + double d6 = MathHelper.sqrt_double(f1 * f1 + f2 * f2 + f3 * f3); + this.accelerationX = f1 / d6 * 0.1D; + this.accelerationY = f2 / d6 * 0.1D; + this.accelerationZ = f3 / d6 * 0.1D; + } + + public EntityToxinball(World world, EntityLivingBase entity, double x, double y, double z) { + super(world); + this.shootingEntity = entity; + this.setSize(1.0F, 1.0F); + this.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch); + this.setPosition(this.entityX, this.entityY, this.entityZ); + this.yOffset = 0.0F; + this.motionX = this.motionY = this.motionZ = 0.0D; + x += this.rand.nextGaussian() * 0.4D; + y += this.rand.nextGaussian() * 0.4D; + z += this.rand.nextGaussian() * 0.4D; + double d3 = MathHelper.sqrt_double(x * x + y * y + z * z); + this.accelerationX = x / d3 * 0.1D; + this.accelerationY = y / d3 * 0.1D; + this.accelerationZ = z / d3 * 0.1D; + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() { + if (!this.worldObj.isRemote && (this.shootingEntity != null && this.shootingEntity.isDead + || !this.worldObj.blockExists(this.entityX, this.entityY, this.entityZ))) { + this.setDead(); + } else { + super.onUpdate(); + this.setFire(1); + + if (this.inGround) { + if (this.worldObj.getBlock(this.entityX, this.entityY, this.entityZ) == this.block) { + ++this.ticksAlive; + + if (this.ticksAlive == 600) { + this.setDead(); + } + + return; + } + + this.inGround = false; + this.motionX *= this.rand.nextFloat() * 0.2F; + this.motionY *= this.rand.nextFloat() * 0.2F; + this.motionZ *= this.rand.nextFloat() * 0.2F; + this.ticksAlive = 0; + this.ticksInAir = 0; + } else { + ++this.ticksInAir; + } + + Vec3 vec3 = Vec3.createVectorHelper(this.entityX, this.entityY, this.entityZ); + Vec3 vec31 = Vec3.createVectorHelper( + this.entityX + this.motionX, + this.entityY + this.motionY, + this.entityZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31); + vec3 = Vec3.createVectorHelper(this.entityX, this.entityY, this.entityZ); + vec31 = Vec3.createVectorHelper( + this.entityX + this.motionX, + this.entityY + this.motionY, + this.entityZ + this.motionZ); + + if (movingobjectposition != null) { + vec31 = Vec3.createVectorHelper( + movingobjectposition.hitVec.xCoord, + movingobjectposition.hitVec.yCoord, + movingobjectposition.hitVec.zCoord); + } + + Entity entity = null; + List<?> list = this.worldObj.getEntitiesWithinAABBExcludingEntity( + this, + this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ) + .expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + + for (Object o : list) { + Entity entity1 = (Entity) o; + + if (entity1.canBeCollidedWith() + && (!entity1.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25)) { + float f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null) { + this.onImpact(movingobjectposition); + } + + this.entityX += this.motionX; + this.entityY += this.motionY; + this.entityZ += this.motionZ; + float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float) (Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F; + + for (this.rotationPitch = (float) (Math.atan2(f1, this.motionY) * 180.0D / Math.PI) + - 90.0F; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float f2 = this.getMotionFactor(); + + if (this.isInWater()) { + for (int j = 0; j < 4; ++j) { + float f3 = 0.25F; + this.worldObj.spawnParticle( + "bubble", + this.entityX - this.motionX * f3, + this.entityY - this.motionY * f3, + this.entityZ - this.motionZ * f3, + this.motionX, + this.motionY, + this.motionZ); + } + + f2 = 0.8F; + } + + this.motionX += this.accelerationX; + this.motionY += this.accelerationY; + this.motionZ += this.accelerationZ; + this.motionX *= f2; + this.motionY *= f2; + this.motionZ *= f2; + this.worldObj.spawnParticle("smoke", this.entityX, this.entityY + 0.5D, this.entityZ, 0.0D, 0.0D, 0.0D); + this.setPosition(this.entityX, this.entityY, this.entityZ); + } + } + + /** + * Return the motion factor for this projectile. The factor is multiplied by the original motion. + */ + @Override + protected float getMotionFactor() { + return 0.95F; + } + + /** + * Called when this EntityFireball hits a block or entity. + */ + @Override + protected abstract void onImpact(MovingObjectPosition p_70227_1_); + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(NBTTagCompound aTag) { + aTag.setShort("xTile", (short) this.entityX); + aTag.setShort("yTile", (short) this.entityY); + aTag.setShort("zTile", (short) this.entityZ); + aTag.setByte("inTile", (byte) Block.getIdFromBlock(this.block)); + aTag.setByte("inGround", (byte) (this.inGround ? 1 : 0)); + aTag.setTag("direction", this.newDoubleNBTList(new double[] { this.motionX, this.motionY, this.motionZ })); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(NBTTagCompound aTag) { + this.entityX = aTag.getShort("xTile"); + this.entityY = aTag.getShort("yTile"); + this.entityZ = aTag.getShort("zTile"); + this.block = Block.getBlockById(aTag.getByte("inTile") & 255); + this.inGround = aTag.getByte("inGround") == 1; + + if (aTag.hasKey("direction", 9)) { + NBTTagList nbttaglist = aTag.getTagList("direction", 6); + this.motionX = nbttaglist.func_150309_d(0); + this.motionY = nbttaglist.func_150309_d(1); + this.motionZ = nbttaglist.func_150309_d(2); + } else { + this.setDead(); + } + } + + /** + * Returns true if other Entities should be prevented from moving through this Entity. + */ + @Override + public boolean canBeCollidedWith() { + return true; + } + + @Override + public float getCollisionBorderSize() { + return 1.0F; + } + + /** + * Called when the entity is attacked. + */ + @Override + public boolean attackEntityFrom(DamageSource damage, float p_70097_2_) { + if (this.isEntityInvulnerable()) { + return false; + } else { + this.setBeenAttacked(); + + if (damage.getEntity() != null) { + Vec3 vec3 = damage.getEntity() + .getLookVec(); + + if (vec3 != null) { + this.motionX = vec3.xCoord; + this.motionY = vec3.yCoord; + this.motionZ = vec3.zCoord; + this.accelerationX = this.motionX * 0.1D; + this.accelerationY = this.motionY * 0.1D; + this.accelerationZ = this.motionZ * 0.1D; + } + + if (damage.getEntity() instanceof EntityLivingBase) { + this.shootingEntity = (EntityLivingBase) damage.getEntity(); + } + + return true; + } else { + return false; + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public float getShadowSize() { + return 0.0F; + } + + /** + * Gets how bright this entity is. + */ + @Override + public float getBrightness(float p_70013_1_) { + return 1.0F; + } + + @Override + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float p_70070_1_) { + return 15728880; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinballSmall.java b/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinballSmall.java new file mode 100644 index 0000000000..44b2e8f694 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinballSmall.java @@ -0,0 +1,65 @@ +package gtPlusPlus.core.entity.projectile; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class EntityToxinballSmall extends EntityToxinball { + + public EntityToxinballSmall(World world, EntityLivingBase entity, double x, double y, double z) { + super(world, entity, x, y, z); + this.setSize(0.3125F, 0.3125F); + } + + /** + * Called when this EntityFireball hits a block or entity. + */ + @Override + protected void onImpact(MovingObjectPosition MoP) { + if (!this.worldObj.isRemote) { + if (MoP.entityHit != null) { + if (!MoP.entityHit.isImmuneToFire() && MoP.entityHit + .attackEntityFrom(DamageSource.causeFireballDamage(this, this.shootingEntity), 5.0F)) { + MoP.entityHit.setFire(5); + } + } else { + int i = MoP.blockX; + int j = MoP.blockY; + int k = MoP.blockZ; + + switch (MoP.sideHit) { + case 0 -> --j; + case 1 -> ++j; + case 2 -> --k; + case 3 -> ++k; + case 4 -> --i; + case 5 -> ++i; + } + + if (this.worldObj.isAirBlock(i, j, k)) { + this.worldObj.setBlock(i, j, k, Blocks.fire); + } + } + + this.setDead(); + } + } + + /** + * Returns true if other Entities should be prevented from moving through this Entity. + */ + @Override + public boolean canBeCollidedWith() { + return false; + } + + /** + * Called when the entity is attacked. + */ + @Override + public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/fluids/FluidRegistryHandler.java b/src/main/java/gtPlusPlus/core/fluids/FluidRegistryHandler.java new file mode 100644 index 0000000000..b08889b42b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/fluids/FluidRegistryHandler.java @@ -0,0 +1,52 @@ +package gtPlusPlus.core.fluids; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gtPlusPlus.core.block.ModBlocks.blockFluidSludge; +import static gtPlusPlus.core.block.ModBlocks.fluidSludge; + +import net.minecraft.block.material.Material; +import net.minecraftforge.fluids.FluidRegistry; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.block.general.fluids.BlockFluidSludge; + +public class FluidRegistryHandler { + + // Fluids + /** + * + * Luminosity .setLuminosity(luminosity) How much light does the fluid emit. Default: 0, Lava uses 15 Density + * .setDensity(density) How dense is the fluid, the only effect is whether or not a fluid replaces another fluid + * when they flow into each other. Default: 1000, the density of water at 4 degrees Celsius in kg/m³ Temperature + * .setTemperature(temp) How hot, or cold is the fluid. Has currently no effect. Default: 295, the "normal" room + * temperature in degrees Kelvin, this is approximately 72°F or 22°C. Viscosity .setViscosity(viscosity) How thick + * the fluid is. Determines how fast it flows. Default: 1000 for water, lava uses 6000 Is Gaseous + * .setGaseous(boolean) Indicates if the fluid is gaseous. Used for rendering. Default: false + * + */ + public static void registerFluids() { + run(); + } + + private static void run() { + fluidSludge(); + } + + private static void fluidSludge() { + // testFluid + fluidSludge.setLuminosity(8); + fluidSludge.setDensity(8196); + fluidSludge.setTemperature(295); + fluidSludge.setViscosity(3000); + fluidSludge.setGaseous(false); + fluidSludge.setUnlocalizedName("fluid.sludge"); + FluidRegistry.registerFluid(fluidSludge); + blockFluidSludge = new BlockFluidSludge(fluidSludge, Material.cactus).setBlockName("fluidBlockSludge"); + GameRegistry.registerBlock( + blockFluidSludge, + GTPlusPlus.ID + "_" + + blockFluidSludge.getUnlocalizedName() + .substring(5)); + fluidSludge.setUnlocalizedName(blockFluidSludge.getUnlocalizedName()); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/GUI_Base_Tile_Entity.java b/src/main/java/gtPlusPlus/core/gui/GUI_Base_Tile_Entity.java new file mode 100644 index 0000000000..379827a1db --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/GUI_Base_Tile_Entity.java @@ -0,0 +1,14 @@ +package gtPlusPlus.core.gui; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Container; + +public abstract class GUI_Base_Tile_Entity extends GuiContainer { + + public final Container mContainer; + + public GUI_Base_Tile_Entity(Container aContainer) { + super(aContainer); + mContainer = aContainer; + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/beta/Gui_ID_Registry.java b/src/main/java/gtPlusPlus/core/gui/beta/Gui_ID_Registry.java new file mode 100644 index 0000000000..7da3d1a35c --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/beta/Gui_ID_Registry.java @@ -0,0 +1,47 @@ +package gtPlusPlus.core.gui.beta; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import gtPlusPlus.core.interfaces.IGuiManagerMiscUtils; + +public class Gui_ID_Registry { + + private static final Map<Class<? extends IGuiManagerMiscUtils>, MU_GuiId> classMap = new HashMap<>(); + private static final Map<Integer, MU_GuiId> idMap = new HashMap<>(); + private static int nextId = 0; + + static {} + + private static void registerGuiHandlers(final Gui_Types MU_GuiType, + final List<Class<? extends IGuiManagerMiscUtils>> guiHandlerClasses) { + for (final Class<? extends IGuiManagerMiscUtils> tileGuiHandlerClass : guiHandlerClasses) { + final MU_GuiId guiId = new MU_GuiId(nextId++, MU_GuiType, tileGuiHandlerClass); + classMap.put(tileGuiHandlerClass, guiId); + idMap.put(Integer.valueOf(guiId.getId()), guiId); + } + } + + public static MU_GuiId getGuiIdForGuiHandler(final IGuiManagerMiscUtils guiHandler) { + final Class<? extends IGuiManagerMiscUtils> guiHandlerClass = guiHandler.getClass(); + MU_GuiId guiId = classMap.get(guiHandlerClass); + if (guiId == null) { + for (final Map.Entry<Class<? extends IGuiManagerMiscUtils>, MU_GuiId> classGuiIdEntry : classMap + .entrySet()) { + if (((Class<?>) classGuiIdEntry.getKey()).isAssignableFrom(guiHandlerClass)) { + guiId = classGuiIdEntry.getValue(); + break; + } + } + } + if (guiId == null) { + throw new IllegalStateException("No gui ID for gui handler: " + guiHandler); + } + return guiId; + } + + public static MU_GuiId getGuiId(final int id) { + return idMap.get(Integer.valueOf(id)); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/beta/Gui_Types.java b/src/main/java/gtPlusPlus/core/gui/beta/Gui_Types.java new file mode 100644 index 0000000000..f0bf946b23 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/beta/Gui_Types.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.gui.beta; + +public enum Gui_Types { + + Item, + Tile, + Entity; + + private Gui_Types() {} +} diff --git a/src/main/java/gtPlusPlus/core/gui/beta/MU_GuiId.java b/src/main/java/gtPlusPlus/core/gui/beta/MU_GuiId.java new file mode 100644 index 0000000000..8b15f5b937 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/beta/MU_GuiId.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.gui.beta; + +import gtPlusPlus.core.interfaces.IGuiManagerMiscUtils; + +public class MU_GuiId { + + private final int id; + private final Gui_Types MU_GuiType; + private final Class<? extends IGuiManagerMiscUtils> guiHandlerClass; + + MU_GuiId(final int id, final Gui_Types MU_GuiType, final Class<? extends IGuiManagerMiscUtils> guiHandlerClass) { + this.id = id; + this.MU_GuiType = MU_GuiType; + this.guiHandlerClass = guiHandlerClass; + } + + public Gui_Types getGuiType() { + return this.MU_GuiType; + } + + public Class<? extends IGuiManagerMiscUtils> getGuiHandlerClass() { + return this.guiHandlerClass; + } + + public int getId() { + return this.id; + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_CircuitProgrammer.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_CircuitProgrammer.java new file mode 100644 index 0000000000..71d3b36470 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_CircuitProgrammer.java @@ -0,0 +1,46 @@ +package gtPlusPlus.core.gui.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.container.Container_CircuitProgrammer; +import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; + +@SideOnly(Side.CLIENT) +public class GUI_CircuitProgrammer extends GuiContainer { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation( + GTPlusPlus.ID, + "textures/gui/CircuitProgrammer.png"); + + public GUI_CircuitProgrammer(final InventoryPlayer player_inventory, final TileEntityCircuitProgrammer te) { + super(new Container_CircuitProgrammer(player_inventory, te)); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + super.drawGuiContainerForegroundLayer(i, j); + } + + @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(); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_DecayablesChest.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_DecayablesChest.java new file mode 100644 index 0000000000..60e0f0e67e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_DecayablesChest.java @@ -0,0 +1,54 @@ +package gtPlusPlus.core.gui.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.container.Container_DecayablesChest; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; + +@SideOnly(Side.CLIENT) +public class GUI_DecayablesChest extends GuiContainer { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation( + GTPlusPlus.ID, + "textures/gui/FishTrap.png"); + + public GUI_DecayablesChest(final InventoryPlayer player_inventory, final TileEntityDecayablesChest te) { + super(new Container_DecayablesChest(player_inventory, te)); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + + } + + @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() { + // You have to add this line for the Gui to function properly! + super.initGui(); + + // The parameters of GuiButton are(id, x, y, width, height, text); + // this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); + // this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); + // NOTE: the id always has to be different or else it might get called twice or never! + + // Add any other buttons here too! + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_FishTrap.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_FishTrap.java new file mode 100644 index 0000000000..d57ef408d0 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_FishTrap.java @@ -0,0 +1,52 @@ +package gtPlusPlus.core.gui.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.container.Container_FishTrap; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; + +@SideOnly(Side.CLIENT) +public class GUI_FishTrap extends GuiContainer { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation( + GTPlusPlus.ID, + "textures/gui/FishTrap.png"); + + public GUI_FishTrap(final InventoryPlayer player_inventory, final TileEntityFishTrap te) { + super(new Container_FishTrap(player_inventory, te)); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) {} + + @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() { + // You have to add this line for the Gui to function properly! + super.initGui(); + + // The parameters of GuiButton are(id, x, y, width, height, text); + // this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); + // this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); + // NOTE: the id always has to be different or else it might get called twice or never! + + // Add any other buttons here too! + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java new file mode 100644 index 0000000000..bed8707fc4 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java @@ -0,0 +1,175 @@ +package gtPlusPlus.core.gui.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.awt.Color; + +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; + +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.material.MISC_MATERIALS; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +import gtPlusPlus.core.util.math.MathUtils; + +@SideOnly(Side.CLIENT) +public class GUI_PestKiller extends GuiContainer { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation( + GTPlusPlus.ID, + "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); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_ProjectTable.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_ProjectTable.java new file mode 100644 index 0000000000..3707855641 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_ProjectTable.java @@ -0,0 +1,58 @@ +package gtPlusPlus.core.gui.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; + +@SideOnly(Side.CLIENT) +public class GUI_ProjectTable extends GuiContainer { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation( + GTPlusPlus.ID, + "textures/gui/ProjectTable.png"); + + public GUI_ProjectTable(final InventoryPlayer player_inventory, final TileEntityProjectTable tile) { + super(new Container_ProjectTable(player_inventory, tile)); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + + } + + @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() { + // You have to add this line for the Gui to function properly! + super.initGui(); + + // The parameters of GuiButton are(id, x, y, width, height, text); + // this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); + // this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); + // NOTE: the id always has to be different or else it might get called twice or never! + + // Add any other buttons here too! + } + + @Override + protected void actionPerformed(final GuiButton B) {} +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_SuperJukebox.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_SuperJukebox.java new file mode 100644 index 0000000000..9afa2b4ce1 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_SuperJukebox.java @@ -0,0 +1,88 @@ +package gtPlusPlus.core.gui.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox; +import gtPlusPlus.core.container.Container_SuperJukebox; +import gtPlusPlus.core.gui.GUI_Base_Tile_Entity; + +@SideOnly(Side.CLIENT) +public class GUI_SuperJukebox extends GUI_Base_Tile_Entity { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation( + GTPlusPlus.ID, + "textures/gui/SuperJukebox.png"); + private final Container_SuperJukebox mThisContainer; + + public GUI_SuperJukebox(final InventoryPlayer player_inventory, final TileEntitySuperJukebox te) { + super(new Container_SuperJukebox(player_inventory, te)); + mThisContainer = (Container_SuperJukebox) this.mContainer; + } + + // This method is called when the Gui is first called! + @Override + public void initGui() { + super.initGui(); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + super.drawGuiContainerForegroundLayer(par1, par2); + + boolean a = mThisContainer.isPlaying; + boolean b = mThisContainer.isLooping; + + if (a && b) { + this.fontRendererObj.drawString("[X] [X]", 72, 74, 4210752); + } else if (a && !b) { + this.fontRendererObj.drawString("[X] [ ]", 72, 74, 4210752); + } else if (!a && b) { + this.fontRendererObj.drawString("[ ] [X]", 72, 74, 4210752); + } else { + this.fontRendererObj.drawString("[ ] [ ]", 72, 74, 4210752); + } + + this.drawTooltip(par1, par2); + } + + private void drawTooltip(final int x2, final int y2) { + final int xStart = (this.width - this.xSize) / 2; + final int yStart = (this.height - this.ySize) / 2; + final int x3 = x2 - xStart; + final int y3 = y2 - yStart + 5; + final List<String> list = new ArrayList<>(); + + if (y3 >= 17 && y3 <= 33) { + if (x3 >= 80 && x3 <= 96) { + list.add("Play"); + } + } + if (y3 >= 35 && y3 <= 53) { + if (x3 >= 80 && x3 <= 96) { + list.add("Loop"); + } + } + if (!list.isEmpty()) { + this.drawHoveringText(list, x3, y3, this.fontRendererObj); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + 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); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java new file mode 100644 index 0000000000..6595b510c0 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java @@ -0,0 +1,228 @@ +package gtPlusPlus.core.gui.machine; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.container.Container_VolumetricFlaskSetter; +import gtPlusPlus.core.gui.widget.GuiValueField; +import gtPlusPlus.core.handler.PacketHandler; +import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; + +@SideOnly(Side.CLIENT) +public class GUI_VolumetricFlaskSetter extends GuiContainer { + + private static final ResourceLocation mGuiTextures = new ResourceLocation( + GTPlusPlus.ID, + "textures/gui/VolumetricFlaskSetter.png"); + private Container_VolumetricFlaskSetter mContainer; + private boolean mIsOpen = false; + private GuiValueField mText; + private TileEntityVolumetricFlaskSetter mTile; + + public GUI_VolumetricFlaskSetter(Container_VolumetricFlaskSetter aContainer) { + super(aContainer); + mContainer = aContainer; + mTile = mContainer.mTileEntity; + } + + @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(mGuiTextures); + 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); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + super.drawGuiContainerForegroundLayer(i, j); + this.mText.drawTextBox(); + this.fontRendererObj.drawString(I18n.format("container.VolumetricFlaskSetter", new Object[0]), 4, 3, 4210752); + int aYVal = 49; + this.fontRendererObj.drawString(I18n.format("0 = 16l", new Object[0]), 8, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("4 = 576l", new Object[0]), 64, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("1 = 36l", new Object[0]), 8, aYVal += 8, 4210752); + this.fontRendererObj.drawString(I18n.format("5 = 720l", new Object[0]), 64, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("2 = 144l", new Object[0]), 8, aYVal += 8, 4210752); + this.fontRendererObj.drawString(I18n.format("6 = 864l", new Object[0]), 64, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("3 = 432l", new Object[0]), 8, aYVal += 8, 4210752); + this.fontRendererObj.drawString(I18n.format("-> = Custom", new Object[0]), 59, aYVal, 4210752); + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + this.drawDefaultBackground(); + super.drawScreen(par1, par2, par3); + } + + protected String getText() { + return this.mText.getText(); + } + + @Override + public void initGui() { + super.initGui(); + // Keyboard.enableRepeatEvents(true); + mIsOpen = true; + this.mText = new GuiValueField( + this.fontRendererObj, + 26, + 31, + this.width / 2 - 62, + this.height / 2 - 52, + 106, + 14, + this); + mText.setMaxStringLength(5); + mText.setEnableBackgroundDrawing(true); + mText.setText("0"); + mText.setFocused(true); + } + + public boolean isNumber(char c) { + boolean isNum = ((c >= 48 && c <= 57) || c == 45); + if (isNum) { + log("Found Digit: " + c + " | char value"); + } else { + switch (c) { + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' -> { + log("Found Digit: " + c + " | char switch"); + return true; + } + } + } + return isNum; + } + + public boolean isNumber(int c) { + switch (c) { + case Keyboard.KEY_0, Keyboard.KEY_1, Keyboard.KEY_2, Keyboard.KEY_3, Keyboard.KEY_4, Keyboard.KEY_5, Keyboard.KEY_6, Keyboard.KEY_7, Keyboard.KEY_8, Keyboard.KEY_9, Keyboard.KEY_NUMPAD0, Keyboard.KEY_NUMPAD1, Keyboard.KEY_NUMPAD2, Keyboard.KEY_NUMPAD3, Keyboard.KEY_NUMPAD4, Keyboard.KEY_NUMPAD5, Keyboard.KEY_NUMPAD6, Keyboard.KEY_NUMPAD7, Keyboard.KEY_NUMPAD8, Keyboard.KEY_NUMPAD9 -> { + log("Found Digit: " + Keyboard.getKeyName(c) + " | LWJGL Keybinding"); + return true; + } + } + return false; + } + + @Override + protected void keyTyped(char par1, int par2) { + if (mIsOpen) { + log("Pressed " + par1 + " | " + par2); + if (mText.isFocused()) { + log("Text box has focus."); + if (par2 == Keyboard.KEY_RETURN) { + log("Pressed Enter, unfocusing."); + mText.setFocused(false); + } else if (par2 == Keyboard.KEY_BACK) { + log("Pressed Backspace."); + String aCurrentText = getText(); + if (aCurrentText.length() > 0) { + this.mText.setText(aCurrentText.substring(0, aCurrentText.length() - 1)); + if (getText().length() <= 0) { + setText(0); + } + sendUpdateToServer(); + } + } else { + if (isNumber(par2) || isNumber(par1)) { + log("Pressed number."); + if (this.mText.getText() + .equals("0")) { + this.mText.textboxKeyTyped(par1, par2); + sendUpdateToServer(); + } else { + this.mText.textboxKeyTyped(par1, par2); + sendUpdateToServer(); + } + } else { + log("Pressed unused key."); + super.keyTyped(par1, par2); + } + } + } else { + log("Text box not focused."); + super.keyTyped(par1, par2); + } + } else { + log("Gui is not open?"); + } + } + + @Override + protected void mouseClicked(int x, int y, int btn) { + if (mIsOpen) { + log("Clicked."); + this.mText.mouseClicked(x, y, btn); + if (!mText.didClickInTextField(x, y)) { + log("Did not click in text box, passing to super."); + super.mouseClicked(x, y, btn); + } + } else { + log("Gui is not open?"); + } + } + + @Override + public void onGuiClosed() { + mIsOpen = false; + mText.setEnabled(false); + mText.setVisible(false); + super.onGuiClosed(); + // Keyboard.enableRepeatEvents(false); + } + + public int parse(String aValue) { + try { + return Integer.parseInt(getText()); + } catch (NumberFormatException e) { + return 0; + } + } + + public void sendUpdateToServer() { + if (getText().length() > 0) { + PacketHandler.sendToServer(new Packet_VolumetricFlaskGui(mTile, parse(getText()))); + } + } + + public void setText(int aValue) { + this.mText.setText("" + aValue); + } + + @Override + public void updateScreen() { + super.updateScreen(); + // Update Textbox to 0 if Empty + if (getText().length() <= 0) { + this.mText.setText("0"); + sendUpdateToServer(); + } + this.mText.updateCursorCounter(); + + // Check TextBox Value is correct + if (getText().length() > 0) { + int aCustomValue = parse(getText()); + int aTileValue = ((Container_VolumetricFlaskSetter) mContainer).mCustomValue; + if (mContainer != null) { + if (aTileValue != aCustomValue) { + setText(aTileValue); + } + } + } + } + + public void log(String aString) { + Logger.INFO("[Flask-GUI] " + aString); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java b/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java new file mode 100644 index 0000000000..698aa1951a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java @@ -0,0 +1,104 @@ +package gtPlusPlus.core.gui.widget; + +import java.lang.reflect.Field; + +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiTextField; + +import gtPlusPlus.core.gui.machine.GUI_VolumetricFlaskSetter; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.CORE_Preloader; + +public class GuiValueField extends GuiTextField { + + private final FontRenderer mFontRenderer; + private final int mScreenLocationX; + private final int mScreenLocationY; + private final GUI_VolumetricFlaskSetter mGUI; + + public GuiValueField(FontRenderer aFontRenderer, int aX, int aY, int aScreenLocationX, int aScreenLocationY, + int aWidth, int aHeight, GUI_VolumetricFlaskSetter aGUI) { + super(aFontRenderer, aX, aY, aWidth, aHeight); + mFontRenderer = aFontRenderer; + mScreenLocationX = aScreenLocationX; + mScreenLocationY = aScreenLocationY; + mGUI = aGUI; + } + + @Override + public boolean isFocused() { + return super.isFocused(); + } + + public boolean isBackgroundDrawingEnabled() { + Field enableBackgroundDrawing = ReflectionUtils.getField( + GuiTextField.class, + !CORE_Preloader.DEV_ENVIRONMENT ? "field_146215_m" : "enableBackgroundDrawing"); + if (enableBackgroundDrawing != null) { + return ReflectionUtils.getFieldValue(enableBackgroundDrawing, this); + } + return true; + } + + public int getLineScrollOffset() { + Field lineScrollOffset = ReflectionUtils + .getField(GuiTextField.class, !CORE_Preloader.DEV_ENVIRONMENT ? "field_146225_q" : "lineScrollOffset"); + if (lineScrollOffset != null) { + return (int) ReflectionUtils.getFieldValue(lineScrollOffset, this); + } + return 0; + } + + public boolean didClickInTextField(int aX, int aY) { + mGUI.log("Clicked at X:" + aX + ", Y:" + aY); + boolean aDidClick = aX >= this.mScreenLocationX && aX < this.mScreenLocationX + this.width + && aY >= this.mScreenLocationY + && aY < this.mScreenLocationY + this.height; + mGUI.log("Did click in textbox? " + aDidClick); + mGUI.log("Expected Region: X:" + mScreenLocationX + "-" + (this.mScreenLocationX + this.width)); + mGUI.log("Expected Region: Y:" + mScreenLocationY + "-" + (this.mScreenLocationY + this.height)); + return aDidClick; + } + + /** + * Args: x, y, buttonClicked + */ + @Override + public void mouseClicked(int aX, int aY, int aButton) { + boolean aDidClick = didClickInTextField(aX, aY); + + mGUI.log("Did click inside text box? " + aDidClick); + mGUI.log("Focus 1: " + this.isFocused()); + this.setFocused(aDidClick); + mGUI.log("Focus 2: " + this.isFocused()); + if (isFocused()) { + int l = aX - this.mScreenLocationX; + if (isBackgroundDrawingEnabled()) { + l -= 4; + } + if (aButton == 0) { + mGUI.log("Left clicked in text box."); + String s = this.mFontRenderer.trimStringToWidth( + this.getText() + .substring(getLineScrollOffset()), + this.getWidth()); + this.setCursorPosition( + this.mFontRenderer.trimStringToWidth(s, l) + .length() + getLineScrollOffset()); + } else if (aButton == 1) { + mGUI.log("Right clicked in text box."); + mGUI.setText(0); + mGUI.sendUpdateToServer(); + String s = this.mFontRenderer.trimStringToWidth( + this.getText() + .substring(getLineScrollOffset()), + this.getWidth()); + this.setCursorPosition( + this.mFontRenderer.trimStringToWidth(s, l) + .length() + getLineScrollOffset()); + } + } else { + mGUI.log("Clicked, but no focus."); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/AchievementHandler.java b/src/main/java/gtPlusPlus/core/handler/AchievementHandler.java new file mode 100644 index 0000000000..41513163a0 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/AchievementHandler.java @@ -0,0 +1,491 @@ +package gtPlusPlus.core.handler; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GregTech; + +import java.util.concurrent.ConcurrentHashMap; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; +import net.minecraftforge.common.AchievementPage; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemSmeltedEvent; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Log; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.ModItems; +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.common.items.MetaGeneratedGregtechTools; + +public class AchievementHandler { + + public ConcurrentHashMap<String, Achievement> achievementList = new ConcurrentHashMap<>(); + + public int adjX = 5; + public int adjY = 9; + + private static final String aBaseAchievementName = "gtpp.start"; + + public AchievementHandler() { + + Logger.INFO("Initializing GT++ achievements"); + GT_Log.out.println("Initializing GT++ achievements"); + + // register first + this.registerAchievement( + aBaseAchievementName, + 0, + 0, + MetaGeneratedGregtechTools.INSTANCE.getToolWithStats( + MetaGeneratedGregtechTools.ANGLE_GRINDER, + 1, + Materials.Osmium, + Materials.Osmium, + null), + "", + true); + + this.registerAchievement( + "hatch.dynamo.buffered", + 2, + -2, + GregtechItemList.Hatch_Buffer_Dynamo_IV.get(1), + aBaseAchievementName, + false); + // First multi anyone really needs + this.registerAchievement( + "multi.abs", + -4, + -2, + GregtechItemList.Industrial_AlloyBlastSmelter.get(1), + aBaseAchievementName, + true); + + // Material Advancement + this.registerAchievement("dust.potin", 0, 2, ALLOY.POTIN.getDust(1), aBaseAchievementName, false); + this.registerAchievement("dust.eglin", 0, 4, ALLOY.EGLIN_STEEL.getDust(1), "dust.potin", false); + this.registerAchievement("dust.staballoy", 0, 6, ALLOY.STABALLOY.getDust(1), "dust.eglin", false); + this.registerAchievement("dust.quantum", 0, 8, ALLOY.QUANTUM.getDust(1), "dust.staballoy", true); + this.registerAchievement("dust.hypogen", 0, 10, ELEMENT.STANDALONE.HYPOGEN.getDust(1), "dust.quantum", true); + + // Blocks + this.registerAchievement( + "block.fishtrap", + -2, + 2, + ItemUtils.getSimpleStack(ModBlocks.blockFishTrap), + "dust.potin", + false); + this.registerAchievement( + "block.withercage", + -2, + 4, + ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard), + "dust.eglin", + false); + + // Machines (-10/-8/-6) + this.registerAchievement("rtg", -16, -10, GregtechItemList.RTG.get(1), aBaseAchievementName, false); + this.registerAchievement( + "dehydrate", + -15, + -10, + GregtechItemList.GT_Dehydrator_HV.get(1), + aBaseAchievementName, + false); + 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); + 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); + + // Multis (-4/-2/0) + this.registerAchievement("multi.pss", -16, -7, GregtechItemList.PowerSubStation.get(1), "multi.abs", false); + this.registerAchievement("multi.cyclo", -15, -7, GregtechItemList.COMET_Cyclotron.get(1), "multi.abs", false); + this.registerAchievement( + "multi.sifter", + -14, + -7, + GregtechItemList.Industrial_Sifter.get(1), + "dust.eglin", + false); + this.registerAchievement( + "multi.cokeoven", + -13, + -7, + GregtechItemList.Industrial_CokeOven.get(1), + "multi.abs", + false); + this.registerAchievement( + "multi.boiler.thermal", + -12, + -7, + GregtechItemList.GT4_Thermal_Boiler.get(1), + "multi.abs", + false); + this.registerAchievement( + "multi.zhuhai", + -11, + -7, + GregtechItemList.Industrial_FishingPond.get(1), + aBaseAchievementName, + false); + + // Casings + this.registerAchievement( + "casing.abs", + 2, + -10, + GregtechItemList.Casing_Coil_BlastSmelter.get(1), + aBaseAchievementName, + false); + this.registerAchievement( + "casing.cyclotron.coil", + 3, + -10, + GregtechItemList.Casing_Cyclotron_Coil.get(1), + aBaseAchievementName, + false); + this.registerAchievement( + "casing.multiuse", + 4, + -10, + GregtechItemList.Casing_Multi_Use.get(1), + aBaseAchievementName, + false); + this.registerAchievement( + "casing.containment", + 5, + -10, + GregtechItemList.Casing_Containment.get(1), + aBaseAchievementName, + false); + + // Radioactive + this.registerAchievement( + "decay.neptunium238", + 11, + 8, + ItemUtils.getSimpleStack(ModItems.dustNeptunium238), + "multi.cyclo", + false); + this.registerAchievement( + "decay.radium226", + 12, + 8, + ItemUtils.getSimpleStack(ModItems.dustRadium226), + "multi.cyclo", + false); + this.registerAchievement( + "decay.molybdenum99", + 13, + 8, + ItemUtils.getSimpleStack(ModItems.dustMolybdenum99), + "multi.cyclo", + false); + + AchievementPage.registerAchievementPage( + new AchievementPage( + "GT++", + this.achievementList.values() + .toArray(new Achievement[0]))); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance() + .bus() + .register(this); + } + + public Achievement registerAchievement(String textId, int x, int y, ItemStack icon, String requirement, + boolean special) { + Achievement achievement = new Achievement( + textId, + textId, + this.adjX + x, + this.adjY + y, + icon, + this.getAchievement(requirement)); + if (special) { + achievement.setSpecial(); + } + + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + + this.achievementList.put(textId, achievement); + return achievement; + } + + public void issueAchievement(EntityPlayer entityplayer, String textId) { + if (entityplayer != null) { + entityplayer.triggerAchievement(this.achievementList.get(textId)); + } + } + + public Achievement getAchievement(String textId) { + return this.achievementList.get(textId); + } + + /** + * A generic handler that will give an achievement for an item. Useful to only write this once, then call it from + * all handlers. + * + * @param aStack - The Itemstack to check for achievements. + * @param aPlayer - The player to unlock for. + */ + private void handleAchivement(ItemStack aStack, EntityPlayer aPlayer) { + + if (aPlayer != null && aStack != null) { + /* + * Copy this to all events because I am lazy - Alk 2019 + */ + + // Safe name + String aUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + + boolean isValid = false; + // Check if valid name // mod + String aModID = ItemUtils.getModId(aStack); + + if (aModID == null || aModID.isEmpty()) { + return; + } + + if (ItemUtils.getModId(aStack) + .equals(GTPlusPlus.ID) + || ItemUtils.getModId(aStack) + .equalsIgnoreCase(GregTech.ID)) { + isValid = true; + } + if (!isValid) { + return; + } + + // Should unlock base achievement from *ANY* GT++ item. (Too lazy to special case GT machineBlocks though) + if (ItemUtils.getModId(aStack) + .equals(GTPlusPlus.ID)) { + this.issueAchievement(aPlayer, aBaseAchievementName); + } + + if (aUnlocalName.contains("item.")) { + aUnlocalName = aUnlocalName.substring(5); + } else if (aUnlocalName.contains("tile.")) { + aUnlocalName = aUnlocalName.substring(5); + } + + /* + * Misc Blocks + */ + if (aUnlocalName.equals("blockFishTrap")) { + this.issueAchievement(aPlayer, "block.fishtrap"); + } + if (aUnlocalName.equals("blockBlackGate")) { + this.issueAchievement(aPlayer, "block.withercage"); + } + + /* + * Decayables + */ + if (aUnlocalName.equals("dustNeptunium238")) { + this.issueAchievement(aPlayer, "decay.neptunium238"); + } else if (aUnlocalName.equals("dustRadium226")) { + this.issueAchievement(aPlayer, "decay.radium226"); + } else if (aUnlocalName.equals("dustMolybdenum99")) { + this.issueAchievement(aPlayer, "decay.molybdenum99"); + } else if (aUnlocalName.equals("dustTechnetium99M")) { + this.issueAchievement(aPlayer, "decay.technetium99m"); + } else if (aUnlocalName.equals("dustTechnetium99")) { + this.issueAchievement(aPlayer, "decay.technetium99"); + } + + /* + * Random Materials worthy of Achievements + */ + else if (aUnlocalName.equals("itemDustPotin")) { + this.issueAchievement(aPlayer, "dust.potin"); + } else if (aUnlocalName.equals("itemDustEglinSteel")) { + this.issueAchievement(aPlayer, "dust.eglin"); + } else if (aUnlocalName.equals("itemDustStaballoy")) { + this.issueAchievement(aPlayer, "dust.staballoy"); + } else if (aUnlocalName.equals("itemDustQuantum")) { + this.issueAchievement(aPlayer, "dust.quantum"); + } else if (aUnlocalName.equals("itemDustHypogen")) { + this.issueAchievement(aPlayer, "dust.hypogen"); + } + + /* + * Machines + */ + else if (aUnlocalName.startsWith("gt.blockmachines.")) { + + // Readability + String aStartsWith = "gt.blockmachines."; + + /* + * Single Blocks + */ + + // RTG + if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.rtg")) { + this.issueAchievement(aPlayer, "rtg"); + } + // Dehydrator + else if (aUnlocalName.startsWith(aStartsWith + "machine.dehydrator.tier.")) { + this.issueAchievement(aPlayer, "dehydrate"); + } + // SemiFluids + else if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.semifluid.tier.")) { + this.issueAchievement(aPlayer, "semifluid"); + } + // Simple Washer + else if (aUnlocalName.startsWith(aStartsWith + "simplewasher.01.tier.")) { + this.issueAchievement(aPlayer, "earlywasher"); + } + // Advanced Boilers + else if (aUnlocalName.startsWith(aStartsWith + "electricboiler.")) { + this.issueAchievement(aPlayer, "advancedsteam"); + } + // Scrubers + else if (aUnlocalName.startsWith(aStartsWith + "pollutioncleaner.01.tier.")) { + this.issueAchievement(aPlayer, "pollutionremoval"); + } + // High-amp xformers + else if (aUnlocalName.startsWith(aStartsWith + "transformer.ha.tier.")) { + this.issueAchievement(aPlayer, "hiampxform"); + } + // Buffered Dynamos + else if (aUnlocalName.startsWith(aStartsWith + "hatch.dynamo.buffer.tier.")) { + this.issueAchievement(aPlayer, "hatch.dynamo.buffered"); + } + // Control Core Hatch + else if (aUnlocalName.startsWith(aStartsWith + "hatch.control.adv")) { + this.issueAchievement(aPlayer, "hatch.control"); + } + + /* + * Multis + */ + + // ABS + else if (aUnlocalName.equals(aStartsWith + "industrialsalloyamelter.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.abs"); + } + // PSS + else if (aUnlocalName.equals(aStartsWith + "substation.01.input.single")) { + this.issueAchievement(aPlayer, "multi.pss"); + } + // Cyclotron + else if (aUnlocalName.startsWith(aStartsWith + "cyclotron.tier.single")) { + this.issueAchievement(aPlayer, "multi.cyclo"); + } + // Sifter + else if (aUnlocalName.equals(aStartsWith + "industrialsifter.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.sifter"); + } + // Coke Oven + else if (aUnlocalName.equals(aStartsWith + "industrialcokeoven.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.cokeoven"); + } + // Thermal Boiler + else if (aUnlocalName.equals(aStartsWith + "gtplusplus.thermal.boiler")) { + this.issueAchievement(aPlayer, "multi.boiler.thermal"); + } + // Zhuhai + else if (aUnlocalName.equals(aStartsWith + "industrial.fishpond.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.zhuhai"); + } + + } + + /* + * Casings + */ + else if (aUnlocalName.equals("gtplusplus.blockcasings.14")) { + this.issueAchievement(aPlayer, "casing.abs"); + } else if (aUnlocalName.equals("gtplusplus.blockcasings.2.9")) { + this.issueAchievement(aPlayer, "casing.cyclotron.coil"); + } else if (aUnlocalName.equals("gtplusplus.blockcasings.3.2")) { + this.issueAchievement(aPlayer, "casing.multiuse"); + } else if (aUnlocalName.equals("gtplusplus.blockcasings.3.15")) { + this.issueAchievement(aPlayer, "casing.containment"); + } + } + } + + /* + * Handle achievements for all vanilla types of obtianment. + */ + + @SubscribeEvent + public void onCrafting(ItemCraftedEvent event) { + EntityPlayer player = event.player; + ItemStack stack = event.crafting; + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } + + @SubscribeEvent + public void onSmelting(ItemSmeltedEvent event) { + EntityPlayer player = event.player; + ItemStack stack = event.smelting; + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } + + @SubscribeEvent + public void onItemPickup(EntityItemPickupEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack stack = event.item.getEntityItem(); + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/BookHandler.java b/src/main/java/gtPlusPlus/core/handler/BookHandler.java new file mode 100644 index 0000000000..5725c1c710 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/BookHandler.java @@ -0,0 +1,486 @@ +package gtPlusPlus.core.handler; + +import static gtPlusPlus.core.util.Utils.addBookPagesLocalization; +import static gtPlusPlus.core.util.Utils.addBookTitleLocalization; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; + +public class BookHandler { + + public static int mBookKeeperCount = 0; + + public static Map<Integer, BookTemplate> mBookMap = new HashMap<>(); + + public static BookTemplate book_ThermalBoiler; + public static BookTemplate book_MultiPowerStation; + public static BookTemplate book_ModularBauble; + public static BookTemplate book_MultiMachineManual; + public static BookTemplate book_NuclearManual; + public static BookTemplate book_MultiChemicalPlant; + + public static void run() { + + Logger.INFO("Writing books."); + + // Thermal Boiler + book_ThermalBoiler = writeBookTemplate( + "Manual_Thermal_Boiler", + "Thermal Boiler Manual", + "GregoriusT", + new String[] { + "This Book explains how to set up and run your Thermal Boiler. We are not responsible for any Damage done by this Book itself nor its content.", + "First you need to craft the following things for a Thermal Boiler to Function: The Main Boiler Block, 20 Thermal Containment Casings, two Input Hatches, two Output Hatches, a bunch of different Tools and a Maintenance Hatch.", + "To begin the building, lay out the first 3x3 layer of Machine Casings on the ground (with a Hatch in the Middle), then place the Boiler Block facing outward in the middle of one of the 3m wide Sides.", + "Now grab 3 other Hatches and place them on the remaining three 3m wide Sides also facing outwards. And now the four corners of the Machine need also a Machine Casing. There should only be a Hole left in the middle of the Cube.", + "So, now place a 3x3 of Machine Casings on top, at the 3rd Layer with the last Hatch in the middle facing outwards as well.", + "When accessing the Boiler Block, it should now stop telling you, that the structure is incomplete (bottom Line of that Screen). Now go with a bunch of different Tools (Metal Hammer, Rubber Hammer, Screwdriver, Wrench, Soldering Iron and Crowbar)", + "to the Maintenance Hatch and access it. After that you grab the 6 Tools and rightclick the Slot with each of them in your Hand in the Maintenance GUI. Note that you need Soldering Tin/Lead in your Inventory to use the Soldering Iron.", + "The Main Block should now tell you that you need to use the Rubber Hammer on it to (re)activate the Machine. The Rubber Hammer can enable and disable Machines. The Machine disables itself after something important broke.", + "If you want to use Lava with this Device, then you should add a Lava Filter to extract additional Resources from the Lava. If the Filter breaks, the Machine won't explode like a Turbine would. If you use molten Salt, then you won't need a Filter.", + "You will get Obsidian when processing Lava, however if a Filter is used, you will get sometimes an Ingot instead of a Block of Obsidian. When using molten Salt, you will get the Salt back.", + "So, now for the Maintenance. After a few Hours of running nonstop, your Boiler will get small Problems, which don't prevent it from running, these Problems just decrease Efficiency. Every Problem listed on the Screen does -10% Efficiency.", + "To fix these Problems, just go to the Maintenance Hatch and click with the problem corresponding Tool on the Slot to repair. If all six possible runtime Problems happen, the Machine will auto-shutdown no matter what. No Explosion, it's just stopping.", + "The Thermal Boiler will produce 800 Liters of Steam per tick for about 5 or 6 Liters of Water per tick at reaching 100% Efficiency. In case of Lava it consumes 1666 Liters every Second.", + "A Thermal Boiler is worth about 33 small Thermal Generators, and as the Boilers get much less Efficient, when not having enough Fuel, you should consider making a large Nether Pump for Lava, or a good Nuclear Reactor for molten Salt.", + "Input and Output Slots are fully optional, you can place multiple ones of them or even none on the Machine. A Machine without Input couldn't process any Recipes, while a Machine without Output just voids all outputted Items and Liquids.", + "It might be useful to use the Screwdriver on the Output Hatches to determine what is outputted where." }); + + // Test Novel + book_MultiPowerStation = writeBookTemplate( + "Manual_Multi_PowerStation", + "Power Storage & You [Version 0.64]", + "Alkalus", + new String[] { + // Page 1 + """ + So, when it comes to power storage you really have three separate options: + \s + Battery Buffers, + Energy Buffers, + The Power Sub-Station + """, + // Page 2 + """ + Battery Buffer + \s + Is rather portable. Allowing you to throw set one up and insert batteries where ever you may need. + They output 1A for each battery stored inside, up to a maximum of 16A.""", + // Page 3 + """ + Energy Buffer + \s + Is a more optimal choice for storage in your base. Once placed down, they cannot be moved without losing all stored power. + Energy Buffers can output 4A from the output side, however accept 16A as input.""", + // Page 4 + """ + The Power Sub-Station\s + Is used for storing Insane amounts of power later game. + Consumes 2% of the average voltage of all energy type hatches every tick. + """, + // Page 5 + """ + Allows Insertion/Removal of power from the rear face of the controller, swap with a screwdriver. + Variable Height Structure, between 4-16Y. Inserted Redox Cells dictate max energy tier of structure. + """, + // Page 6 + """ + Redox Cells cannot be placed into the Top or Bottom layer and only take up 3xhx3 internally. + Different Tier cells CANNOT be mixed together. + """, + // Page 7 + """ + All Hatches Must be HV at a Minimum, this minimum tier is in place to stop people abusing ULV/LV hatches to lower the avg/t. + Currently the GUI will NOT display anything at all until the structure forms, this is a known bug. + """, + // Page 8 + """ + Valid Hatches: + Energy Hatch, + Dynamo Hatch, + Charging Bus, + Discharging Bus, + Dynamo Buffer, + Multi-Amp Dynamo Hatch. + + + Structure MUST contain at least one energy input and one energy output hatch.""" }); + + // Test Novel + book_ModularBauble = writeBookTemplate( + "Manual_Modular_Bauble", + "How to: Modular Baubles", + "Alkalus", + new String[] { + """ + Concept: This idea came from wanting flexibility.\s + First step, Build a Modularity table to begin customisation of your Bauble.\s + After this has been constructed, you can now combine the upgrades listed within this book to improve the baubles level/100.""", + """ + Defence: + Can be upgraded by combining metal plates with the bauble.\s + | +1 | Aluminium\s + | +2 | Stainless Steel\s + | +3 | Tungsten\s + | +4 | Tungsten Steel\s + | +5 | Naquadah\s + """, "There was once a sad and lonely oak tree. \n", "There was once a sad and lonely oak tree. \n", + "There was once a sad and lonely oak tree. \n" }); + + // Test Novel + // 20/21/22 + book_MultiMachineManual = writeBookTemplate( + "Manual_Multi_Machine", + "Multi-Machine Manual", + "Alkalus", + new String[] { + "This Multiblock, depending upon the mode used, can function as a variety of different machines. The idea behind this, was that most of these machines are rather niche compared to any others, as such, not used often.", + "To build, you need to construct a hollow 3x3x3 structure made from Multi-Use casings, With a minimum of 6. Any Casing position can be substituted out with an Input Hatch/Bus, an Output Hatch/Bus, Muffler, Maint. Hatch or Energy Injector Hatch.", + "The Mode can be set by using a Screwdriver on the controller block. Each mode allows the use of Numbered Circuits, to allow a different machine 'type' for each input bus.", + "[Metal Work] Mode Metal - Allows the multiblock to function as a Compressor, a Lathe or an Electro-Magnet. To allow a hatch to run in Compressor mode, insert a No. 20 circuit. For Lathe, use No. 21 and for Electro-Magnet use No. 22.", + "[Fluid Work] Mode Fluid - Allows the multiblock to function as a Fermenter, a Fluid Extractor or an Extractor. To allow a hatch to run in Fermenter mode, insert a No. 20 circuit. For Fluid Extractor, use No. 21 and for Extractor use No. 22.", + "[Misc. Work] Mode Misc - Allows the multiblock to function as a Laser Engraver, an Autoclave or a Fluid Solidifier. To allow a hatch to run in Laser Engraver mode, insert a No. 20 circuit. For Autoclave, use No. 21 and for Solidifier use No. 22.", }); + + book_NuclearManual = writeBookTemplate( + "Manual_NuclearStuff_1", + "Nuclear Chemistry [FFPP]", + "Alkalus", + new String[] { + // Page 1 + """ + Fission Fuel Processing Plant + Size: 3x9x3 [LxHxW] + Controller: Center, Bottom + 4x Input Hatch + 2x Output Hatch + 1x Output Bus + 1x ZPM+ Muffler + 1x Maintenance Hatch + 1x Energy Hatch + """, + // Page 2 + """ + [1] 7x Hastelloy-X or I/O + [2] 5x Incoloy-DS Fluid Containment + [3] 4x Zeron-100 Shielding + [4] 17x Hastelloy-N Sealant Case + Multiblock Construction + Convention is [LxHxW] + + """, + // Page 3 + """ + Layer 1/2: + [1][1][1] + [1][1][1] + [1][1][1] + + Layer 3/5/6 + [ ][4][ ] + [4][2][4] + [ ][4][ ] + + """, + // Page 4 + """ + Layer 4 + [ ][3][ ] + [3][2][3] + [ ][3][ ] + + Layer 7/8/9 + [ ][ ][ ] + [ ][3][ ] + [ ][ ][ ] + """, + // Page 5 + """ + Fission Fuel + Processing Plant---------------------- + This structure is used to produce the Molten Salts required to run a Liquid Fluorine Thorium Reactor [LFTR].""" }); + + book_MultiChemicalPlant = writeBookTemplate( + "book_Multi_ChemicalPlant", + "Chemical Plant Manual", + "Alkalus", + new String[] { + + // Intro + "This book will explain how the Chemical Plant is constructed, which blocks are valid to upgrade it and also how the upgrades work.", + + // Info + """ + Solid Casings = Plant tier + Machine Casings = Hatch tier + Higher tier coils More Speed + T1 50% , T2 100% , T3 150%, etc + """, """ + Higher tier pipe casings boost parallel + and reduce catalyst consumption. + +2 parallel per tier, 20% extra chance of + not damaging catalyst per tier.""", """ + Awakened Draconium Coil (or above) with + Tungstensteel Pipe Casing + does not damage catalyst at all.""", + + // Machine Casings + """ + Valid Solid Machine Casings: + 1 - Strong Bronze + 2 - Solid Steel + 3 - Sturdy Aluminium + 4 - Clean Stainless Steel + 5 - Stable Titanium + 6 - Robust Tungstensteel + 7 - Vigorous Laurenium + 8 - Rugged Botmium""", + + // Machine Casings + "Valid Tiered Machine Casings:" + "\n" + + "\n" + + "1 - " + + GT_Values.VN[0] + + "\n" + + "2 - " + + GT_Values.VN[1] + + "\n" + + "3 - " + + GT_Values.VN[2] + + "\n" + + "4 - " + + GT_Values.VN[3] + + "\n" + + "5 - " + + GT_Values.VN[4] + + "\n" + + "6 - " + + GT_Values.VN[5] + + "\n" + + "7 - " + + GT_Values.VN[6] + + "\n" + + "8 - " + + GT_Values.VN[7] + + "\n" + + "9 - " + + GT_Values.VN[8] + + "\n" + + "10 - " + + GT_Values.VN[9], + + // Pipe Casings + """ + Valid Pipe Casings: + + 1 - Bronze + 2 - Steel + 3 - Titanium + 4 - Tungstensteel""", + + // Coils + """ + Valid Coils: + + 1 - Cupronickel + 2 - Kanthal + 3 - Nichrome + 4 - TPV-Alloy + 5 - HSS-G + 6 - HSS-S + 7 - Naquadah + 8 - Naquadah Alloy + 9 - Trinium + 10 - Fluxed Electrum""", """ + 11 - Awakened Draconium + 12 - Infinity + 13 - Hypogen + 14 - Eternal""", + + // Requirements + """ + Multiblock Requirements: + + 27x Coils + 18x Pipe Casings + 57x Tiered Machine Casings + 70+ Solid Casings + 1x Catalyst Housing (Catalysts cannot go inside an Input Bus)""", + + // Construction Guide + """ + Construction Guide Pt1: + + Controller is placed on a middle casing in the bottom layer + Hatches can only be placed on the bottom layer edges""", """ + Construction Guide Pt2: + + 7x7x7 Hollow frame of solid casings + 5x1x5 layer of solid casings (fills in top layer) + 5x1x5 layer of machine casings (fills in bottom layer)""", """ + Construction Guide Pt3: + In the central 3x5x3: + 3x1x3 layer of Coils, surrounded by ring of Machine Casings + 3x1x3 layer of Pipe Casings + 3x1x3 layer of Coils + 3x1x3 layer of Pipe Casings + 3x1x3 layer of Coils, surrounded by ring of Machine Casings""", + + // Construction Guide Info + """ + Information: + + A = Air + X = Solid Casing + M = Machine Casing + P = Pipe Casing + C = Coil Casing""", """ + Layer 1: + + XXXXXXX + XMMMMMX + XMMMMMX + XMMMMMX + XMMMMMX + XMMMMMX + XXXXXXX""", """ + Layer 2: + + XAAAAAX + AMMMMMA + AMCCCMA + AMCCCMA + AMCCCMA + AMMMMMA + XAAAAAX""", """ + Layer 3: + + XAAAAAX + AAAAAAA + AAPPPAA + AAPPPAA + AAPPPAA + AAAAAAA + XAAAAAX""", """ + Layer 4: + + XAAAAAX + AAAAAAA + AACCCAA + AACCCAA + AACCCAA + AAAAAAA + XAAAAAX""", """ + Layer 5: + + XAAAAAX + AAAAAAA + AAPPPAA + AAPPPAA + AAPPPAA + AAAAAAA + XAAAAAX""", """ + Layer 6: + + XAAAAAX + AMMMMMA + AMCCCMA + AMCCCMA + AMCCCMA + AMMMMMA + XAAAAAX""", """ + Layer 7: + + XXXXXXX + XXXXXXX + XXXXXXX + XXXXXXX + XXXXXXX + XXXXXXX + XXXXXXX""", }); + } + + public static ItemStack ItemBookWritten_ThermalBoiler; + public static ItemStack ItemBookWritten_NuclearManual; + public static ItemStack ItemBookWritten_ModularBaubles; + public static ItemStack ItemBookWritten_MultiPowerStorage; + public static ItemStack ItemBookWritten_MultiMachineManual; + public static ItemStack ItemBookWritten_MultiChemicalPlant; + + public static void runLater() { + ItemBookWritten_ThermalBoiler = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 0, 1); + ItemBookWritten_MultiPowerStorage = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 1, 1); + ItemBookWritten_ModularBaubles = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 2, 1); + ItemBookWritten_MultiMachineManual = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 3, 1); + ItemBookWritten_NuclearManual = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 4, 1); + ItemBookWritten_MultiChemicalPlant = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 5, 1); + + // Multiblock Manuals + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(Items.writable_book), + ItemUtils.getSimpleStack(Items.lava_bucket) }, + ItemBookWritten_ThermalBoiler); + GT_ModHandler.addCraftingRecipe( + ItemBookWritten_MultiMachineManual, + GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "Xw", 'X', ItemUtils.getSimpleStack(Items.writable_book) }); + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(Items.writable_book), + ItemUtils.getItemStackOfAmountFromOreDict("wireGt01Tin", 1) }, + ItemBookWritten_MultiPowerStorage); + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(Items.writable_book), + ItemUtils.getItemStackOfAmountFromOreDict("dustUranium", 1) }, + ItemBookWritten_NuclearManual); + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(Items.writable_book), + ItemUtils.getItemStackOfAmountFromOreDict("wireGt01Copper", 1) }, + ItemBookWritten_MultiChemicalPlant); + + for (int i = 0; i < mBookKeeperCount; i++) { + ItemStack bookstack = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, i, 1); + GT_OreDictUnificator.registerOre("bookWritten", bookstack); + GT_OreDictUnificator.registerOre("craftingBook", bookstack); + } + } + + private static BookTemplate writeBookTemplate(String aMapping, String aTitle, String aAuthor, String[] aPages) { + mBookKeeperCount++; + for (int i = 0; i < aPages.length; i++) { + aPages[i] = aPages[i].replaceAll("\n", "<BR>"); + } + addBookTitleLocalization(aTitle); + addBookPagesLocalization(aTitle, aPages); + BookTemplate mTemp = new BookTemplate(mBookKeeperCount, aMapping, aTitle, aAuthor, aPages); + mBookMap.put(mBookKeeperCount - 1, mTemp); + return mTemp; + } + + public static class BookTemplate { + + public final int mMeta; + public final String mMapping; + public final String mTitle; + public final String mAuthor; + public final String[] mPages; + + BookTemplate(int aMeta, String aMapping, String aTitle, String aAuthor, String[] aPages) { + this.mMeta = aMeta; + this.mMapping = aMapping; + this.mTitle = aTitle; + this.mAuthor = aAuthor; + this.mPages = aPages; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/BurnableFuelHandler.java b/src/main/java/gtPlusPlus/core/handler/BurnableFuelHandler.java new file mode 100644 index 0000000000..8e3377b5f9 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/BurnableFuelHandler.java @@ -0,0 +1,35 @@ +package gtPlusPlus.core.handler; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.IFuelHandler; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BurnableFuelHandler implements IFuelHandler { + + @Override + public int getBurnTime(ItemStack aStack) { + // Iterate over my burnables. + for (Pair<Integer, ItemStack> temp : CORE.burnables) { + int aStackID = Item.getIdFromItem(aStack.getItem()); + int burnID = Item.getIdFromItem( + temp.getValue() + .getItem()); + if (aStackID == burnID) { + int burn = temp.getKey(); + ItemStack fuel = temp.getValue(); + ItemStack testItem = ItemUtils.getSimpleStack(fuel, aStack.stackSize); + + if (aStack.isItemEqual(testItem)) { + return burn; + } + } + } + + // If it's not my fuel, return 0. + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java new file mode 100644 index 0000000000..cf276d90a1 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -0,0 +1,299 @@ +package gtPlusPlus.core.handler; + +import static gregtech.api.enums.Mods.ExtraUtilities; +import static gregtech.api.enums.Mods.PamsHarvestCraft; +import static gregtech.api.enums.Mods.Thaumcraft; +import static gregtech.api.enums.Mods.Witchery; + +import java.util.LinkedList; +import java.util.Queue; +import java.util.Set; + +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_OreDictUnificator; +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.COMPAT_ExtraUtils; +import gtPlusPlus.core.common.compat.COMPAT_HarvestCraft; +import gtPlusPlus.core.common.compat.COMPAT_IC2; +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.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +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.loaders.RecipeGen_FluidCanning; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_ChemicalSkips; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_GTNH; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_GlueLine; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_Nuclear; +import gtPlusPlus.xmod.gregtech.registration.gregtech.Gregtech4Content; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechAdvancedBoilers; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechAlgaeContent; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechAmazonWarehouse; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechBufferDynamos; +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.GregtechGeothermalThermalGenerator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechHiAmpTransformer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialAlloySmelter; +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.GregtechIndustrialChisel; +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.GregtechIndustrialElementDuplicator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialExtruder; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialFishPond; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialFluidHeater; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialForgeHammer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialFuelRefinery; +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.GregtechIndustrialPlatePress; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialRockBreaker; +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.GregtechIsaMill; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechLFTR; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechLargeTurbinesAndHeatExchanger; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechMolecularTransformer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechNuclearSaltProcessingPlant; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechPollutionDevices; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechPowerSubStation; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechQuantumForceTransformer; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRTG; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRocketFuelGenerator; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSemiFluidgenerators; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSimpleWasher; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSolarTower; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSteamMultis; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSuperChests; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechThaumcraftDevices; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechThreadedBuffers; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechTieredFluidTanks; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechTreeFarmerTE; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechWirelessChargers; + +public class COMPAT_HANDLER { + + public static Queue<Object> RemoveRecipeQueue = new LinkedList<>(); + public static Queue<ShapedRecipeObject> AddRecipeQueue = new LinkedList<>(); + public static Boolean areInitItemsLoaded = false; + + public static void registerMyModsOreDictEntries() { + + Logger.INFO("Registering Materials with OreDict."); + // In-house + + for (int i = 1; i <= 10; i++) { + GT_OreDictUnificator.registerOre( + "bufferCore_" + GT_Values.VN[i - 1], + new ItemStack(ItemUtils.getItemFromFQRN("miscutils:item.itemBufferCore" + i))); + } + } + + public static void registerGregtechMachines() { + // Free IDs + /* + * --- 859 to 868 --- 911 to 940 + */ + + new RECIPES_LaserEngraver(); + GregtechEnergyBuffer.run(); + GregtechLFTR.run(); + GregtechNuclearSaltProcessingPlant.run(); + GregtechIndustrialCentrifuge.run(); + GregtechIndustrialCokeOven.run(); + GregtechIndustrialPlatePress.run(); + GregtechRocketFuelGenerator.run(); + GregtechIndustrialElectrolyzer.run(); + GregtechIndustrialMacerator.run(); + GregtechIndustrialWiremill.run(); + GregtechIndustrialMassFabricator.run(); + GregtechIndustrialBlastSmelter.run(); + GregtechQuantumForceTransformer.run(); + GregtechPowerSubStation.run(); + GregtechDehydrator.run(); + GregtechAdvancedBoilers.run(); + GregtechPollutionDevices.run(); + GregtechTieredFluidTanks.run(); + GregtechGeothermalThermalGenerator.run(); + Gregtech4Content.run(); + GregtechIndustrialFuelRefinery.run(); + GregtechTreeFarmerTE.run(); + GregtechIndustrialTreeFarm.run(); + GregtechIndustrialSifter.run(); + GregtechSimpleWasher.run(); + GregtechRTG.run(); + GregtechCyclotron.run(); + GregtechHiAmpTransformer.run(); + GregtechIndustrialThermalCentrifuge.run(); + GregtechIndustrialWashPlant.run(); + GregtechSemiFluidgenerators.run(); + GregtechWirelessChargers.run(); + GregtechIndustrialCuttingFactory.run(); + GregtechSuperChests.run(); + GregtechIndustrialFishPond.run(); + GregtechIndustrialExtruder.run(); + GregtechIndustrialMultiMachine.run(); + GregtechBufferDynamos.run(); + GregtechAmazonWarehouse.run(); + GregtechFactoryGradeReplacementMultis.run(); + GregtechThaumcraftDevices.run(); + GregtechThreadedBuffers.run(); + GregtechIndustrialMixer.run(); + GregtechCustomHatches.run(); + GregtechIndustrialArcFurnace.run(); + GregtechSolarTower.run(); + GregtechLargeTurbinesAndHeatExchanger.run(); + GregtechAlgaeContent.run(); + GregtechIndustrialAlloySmelter.run(); + GregtechIsaMill.run(); + GregtechSteamMultis.run(); + GregtechIndustrialForgeHammer.run(); + GregtechMolecularTransformer.run(); + GregtechIndustrialElementDuplicator.run(); + GregtechIndustrialRockBreaker.run(); + GregtechIndustrialChisel.run(); + GregtechIndustrialFluidHeater.run(); + } + + // InterMod + public static void intermodOreDictionarySupport() { + if (Thaumcraft.isModLoaded()) { + COMPAT_Thaumcraft.OreDict(); + } + if (ExtraUtilities.isModLoaded()) { + COMPAT_ExtraUtils.OreDict(); + } + if (PamsHarvestCraft.isModLoaded()) { + COMPAT_HarvestCraft.OreDict(); + } + COMPAT_IC2.OreDict(); + if (Witchery.isModLoaded()) { + COMPAT_Witchery.OreDict(); + } + } + + public static void RemoveRecipesFromOtherMods() { + // Removal of Recipes + for (final Object item : RemoveRecipeQueue) { + RecipeUtils.removeCraftingRecipe(item); + } + } + + public static void InitialiseHandlerThenAddRecipes() { + RegistrationHandler.run(); + } + + public static void InitialiseLateHandlerThenAddRecipes() { + LateRegistrationHandler.run(); + } + + public static void startLoadingGregAPIBasedRecipes() { + // Add hand-made recipes + RECIPES_GREGTECH.run(); + RecipeLoader_GTNH.generate(); + RecipeLoader_Nuclear.generate(); + RecipeLoader_GlueLine.generate(); + RecipeLoader_ChemicalSkips.generate(); + // Add autogenerated Recipes from Item Components + for (Set<RunnableWithInfo<Material>> m : MaterialGenerator.mRecipeMapsToGenerate) { + for (RunnableWithInfo<Material> r : m) { + try { + r.run(); + Logger.INFO( + "[FIND] " + r.getInfoData() + .getLocalizedName() + " recipes generated."); + } catch (Throwable t) { + t.printStackTrace(); + Logger.INFO( + "[ERROR] " + r.getInfoData() + .getLocalizedName() + " recipes failed to generated."); + } + } + } + RecipeGen_Recycling.executeGenerators(); + runQueuedMisc(); + + // Do Fluid Canning Last, because they're not executed on demand, but rather queued. + RecipeGen_FluidCanning.init(); + } + + public static void onLoadComplete(FMLLoadCompleteEvent event) { + runQueuedOnLoadComplete(event); + } + + public static final AutoMap<RunnableWithInfo<String>> mRecipesToGenerate = new AutoMap<>(); + public static final AutoMap<RunnableWithInfo<String>> mGtRecipesToGenerate = new AutoMap<>(); + + public static final AutoMap<RunnableWithInfo<String>> mObjectsToRunInPostInit = new AutoMap<>(); + public static final AutoMap<ItemPackage> mObjectsToRunInOnLoadComplete = new AutoMap<>(); + + public static void runQueuedRecipes() { + // Add autogenerated Recipes from Item Components + for (RunnableWithInfo<String> m : mRecipesToGenerate) { + try { + m.run(); + } catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] " + m.getInfoData() + " recipe failed to generated."); + } + } + for (RunnableWithInfo<String> m : mGtRecipesToGenerate) { + try { + m.run(); + } catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] " + m.getInfoData() + " recipe failed to generated."); + } + } + } + + public static void runQueuedMisc() { + for (RunnableWithInfo<String> m : mObjectsToRunInPostInit) { + try { + m.run(); + } catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] " + m.getInfoData()); + } + } + } + + /** + * Generally used to register GT recipe map changes after they've been populated. + */ + public static void runQueuedOnLoadComplete(FMLLoadCompleteEvent event) { + for (ItemPackage m : mObjectsToRunInOnLoadComplete) { + try { + m.onLoadComplete(event); + } catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] " + m.getInfoData()); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/main/java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java new file mode 100644 index 0000000000..af09762c08 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -0,0 +1,50 @@ +package gtPlusPlus.core.handler; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gtPlusPlus.recipes.RecipeRemovals; +import gtPlusPlus.xmod.bartcrops.HANDLER_CropsPlusPlus; +import gtPlusPlus.xmod.bop.HANDLER_BiomesOPlenty; +import gtPlusPlus.xmod.forestry.HANDLER_FR; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; +import gtPlusPlus.xmod.ic2.HANDLER_IC2; +import gtPlusPlus.xmod.railcraft.HANDLER_Railcraft; +import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; +import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers; + +public class COMPAT_IntermodStaging { + + public static void preInit(FMLPreInitializationEvent preinit) { + HANDLER_GT.preInit(); + HANDLER_TF.preInit(); + HANDLER_FR.preInit(); + HANDLER_IC2.preInit(); + HANDLER_BiomesOPlenty.preInit(); + HANDLER_CropsPlusPlus.preInit(preinit); + HANDLER_Railcraft.preInit(); + } + + public static void init(FMLInitializationEvent init) { + HANDLER_GT.init(); + HANDLER_TF.init(); + } + + public static void postInit(FMLPostInitializationEvent postinit) { + HANDLER_GT.postInit(); + HANDLER_TF.postInit(); + HANDLER_FR.postInit(); + HANDLER_IC2.postInit(); + HANDLER_BiomesOPlenty.postInit(); + HANDLER_Tinkers.postInit(); + HANDLER_CropsPlusPlus.postInit(postinit); + HANDLER_Railcraft.postInit(); + RecipeRemovals.postInit(); + } + + public static void onLoadComplete(FMLLoadCompleteEvent event) { + HANDLER_GT.onLoadComplete(event); + RecipeRemovals.onLoadComplete(); + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/GuiHandler.java b/src/main/java/gtPlusPlus/core/handler/GuiHandler.java new file mode 100644 index 0000000000..d5d0859472 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/GuiHandler.java @@ -0,0 +1,159 @@ +package gtPlusPlus.core.handler; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox; +import gtPlusPlus.core.container.Container_CircuitProgrammer; +import gtPlusPlus.core.container.Container_DecayablesChest; +import gtPlusPlus.core.container.Container_FishTrap; +import gtPlusPlus.core.container.Container_PestKiller; +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.container.Container_SuperJukebox; +import gtPlusPlus.core.container.Container_VolumetricFlaskSetter; +import gtPlusPlus.core.gui.beta.Gui_ID_Registry; +import gtPlusPlus.core.gui.beta.MU_GuiId; +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_PestKiller; +import gtPlusPlus.core.gui.machine.GUI_ProjectTable; +import gtPlusPlus.core.gui.machine.GUI_SuperJukebox; +import gtPlusPlus.core.gui.machine.GUI_VolumetricFlaskSetter; +import gtPlusPlus.core.interfaces.IGuiManager; +import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; + +public class GuiHandler implements IGuiHandler { + + public static final int GUI1 = 0; // Project Table + public static final int GUI2 = 1; // None + public static final int GUI3 = 2; // None + public static final int GUI4 = 3; // Workbench + public static final int GUI5 = 4; // Workbench Adv + public static final int GUI6 = 5; // Fish trap + public static final int GUI7 = 6; // None + public static final int GUI8 = 7; // Circuit Programmer + public static final int GUI9 = 8; // None + public static final int GUI10 = 9; // None + public static final int GUI11 = 10; // None + public static final int GUI12 = 11; // None + 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; // None + public static final int GUI17 = 16; // None + public static final int GUI18 = 17; // Volumetric Flask Setter + + public static void init() { + Logger.INFO("Registering GUIs."); + NetworkRegistry.INSTANCE.registerGuiHandler(GTplusplus.instance, new GuiHandler()); + } + + @Override // ContainerModTileEntity + public Object getServerGuiElement(final int ID, final EntityPlayer player, final World world, final int x, + final int y, final int z) { + final TileEntity te = world.getTileEntity(x, y, z); + + if (te != null) { + if (ID == GUI1) { + return new Container_ProjectTable(player.inventory, (TileEntityProjectTable) te); + } else if (ID == GUI2) {} + } + + if (te != null) { + if (ID == GUI5) { + Logger.INFO("sad"); + // return new Container_WorkbenchAdvanced(player.inventory, (TileEntityWorkbenchAdvanced) te); + } else if (ID == GUI6) { + return new Container_FishTrap(player.inventory, (TileEntityFishTrap) te); + } else if (ID == GUI8) { + return new Container_CircuitProgrammer(player.inventory, (TileEntityCircuitProgrammer) te); + } else if (ID == GUI13) { + return new Container_DecayablesChest(player.inventory, (TileEntityDecayablesChest) te); + } 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 == GUI18) { + return new Container_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te); + } + } + + return null; + } + + @Override // GuiModTileEntity + public Object getClientGuiElement(final int ID, final EntityPlayer player, final World world, final int x, + final int y, final int z) { + Logger.WARNING( + "getClientGuiElement Called by: " + player + + ", in world: " + + player.dimension + + " at x:" + + x + + ", y:" + + y + + ", z:" + + z + + "."); + final TileEntity te = world.getTileEntity(x, y, z); + if (te != null) { + if (ID == GUI1) { + return new GUI_ProjectTable(player.inventory, (TileEntityProjectTable) te); + } + } + + if (te != null) { + if (ID == GUI6) { + return new GUI_FishTrap(player.inventory, (TileEntityFishTrap) te); + } else if (ID == GUI8) { + return new GUI_CircuitProgrammer(player.inventory, (TileEntityCircuitProgrammer) te); + } else if (ID == GUI13) { + 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 == GUI18) { + return new GUI_VolumetricFlaskSetter( + new Container_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te)); + } + } + + return null; + } + + // New Methods + public static void openGui(final EntityPlayer entityplayer, final IGuiManager guiHandler) { + openGui(entityplayer, guiHandler, (short) 0); + } + + public static void openGui(final EntityPlayer entityplayer, final IGuiManager guiHandler, final short data) { + final int guiData = encodeGuiData(guiHandler, data); + final ChunkCoordinates coordinates = guiHandler.getCoordinates(); + entityplayer.openGui( + GTplusplus.instance, + guiData, + entityplayer.worldObj, + coordinates.posX, + coordinates.posY, + coordinates.posZ); + } + + private static int encodeGuiData(final IGuiManager guiHandler, final short data) { + final MU_GuiId guiId = Gui_ID_Registry.getGuiIdForGuiHandler(guiHandler); + return (data << 16) | guiId.getId(); + } + +} diff --git a/src/main/java/gtPlusPlus/core/handler/PacketHandler.java b/src/main/java/gtPlusPlus/core/handler/PacketHandler.java new file mode 100644 index 0000000000..af6a376f1a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/PacketHandler.java @@ -0,0 +1,94 @@ +package gtPlusPlus.core.handler; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; + +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import cpw.mods.fml.relauncher.Side; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.network.handler.AbstractClientMessageHandler; +import gtPlusPlus.core.network.packet.AbstractPacket; +import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui; +import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui2; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class PacketHandler { + + private static byte packetId = 0; + + private static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(GTPlusPlus.ID); + + public static final void init() { + registerMessage(Packet_VolumetricFlaskGui.class, Packet_VolumetricFlaskGui.class); + registerMessage(Packet_VolumetricFlaskGui2.class, Packet_VolumetricFlaskGui2.class); + } + + /** + * Registers a message and message handler + */ + private static void registerMessage(Class handlerClass, Class messageClass) { + Side side = AbstractClientMessageHandler.class.isAssignableFrom(handlerClass) ? Side.CLIENT : Side.SERVER; + registerMessage(handlerClass, messageClass, side); + } + + private static void registerMessage(Class handlerClass, Class messageClass, Side side) { + INSTANCE.registerMessage(handlerClass, messageClass, packetId++, side); + if (AbstractPacket.class.isInstance(messageClass.getClass())) { + AbstractPacket aPacket = ReflectionUtils.createNewInstanceFromConstructor( + ReflectionUtils.getConstructor(messageClass, new Class[] {}), + new Object[] {}); + if (aPacket != null) { + Logger.INFO("Registered Packet: " + aPacket.getPacketName()); + } + } + } + + /** + * Send this message to the specified player. See {@link SimpleNetworkWrapper#sendTo(IMessage, EntityPlayerMP)} + */ + public static final void sendTo(IMessage message, EntityPlayerMP player) { + INSTANCE.sendTo(message, player); + } + + /** + * Send this message to everyone within a certain range of a point. See + * {@link SimpleNetworkWrapper#sendToDimension(IMessage, NetworkRegistry.TargetPoint)} + */ + public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { + INSTANCE.sendToAllAround(message, point); + } + + /** + * Sends a message to everyone within a certain range of the coordinates in the same dimension. + */ + public static final void sendToAllAround(IMessage message, int dimension, double x, double y, double z, + double range) { + sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); + } + + /** + * Sends a message to everyone within a certain range of the player provided. + */ + public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { + sendToAllAround(message, player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, range); + } + + /** + * Send this message to everyone within the supplied dimension. See + * {@link SimpleNetworkWrapper#sendToDimension(IMessage, int)} + */ + public static final void sendToDimension(IMessage message, int dimensionId) { + INSTANCE.sendToDimension(message, dimensionId); + } + + /** + * Send this message to the server. See {@link SimpleNetworkWrapper#sendToServer(IMessage)} + */ + public static final void sendToServer(IMessage message) { + INSTANCE.sendToServer(message); + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java b/src/main/java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java new file mode 100644 index 0000000000..e50a76d5d5 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java @@ -0,0 +1,38 @@ +package gtPlusPlus.core.handler.Recipes; + +import net.minecraft.item.ItemStack; + +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class DecayableRecipe { + + public static final AutoMap<DecayableRecipe> mRecipes = new AutoMap<>(); + + 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 i) { + 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/main/java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java b/src/main/java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java new file mode 100644 index 0000000000..9eb3a1826e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java @@ -0,0 +1,27 @@ +package gtPlusPlus.core.handler.Recipes; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.COMPAT_HANDLER; +import gtPlusPlus.core.recipe.ShapedRecipeObject; + +public class LateRegistrationHandler { + + public static int recipesSuccess = 0; + public static int recipesFailed = 0; + + public static void run() { + init(); + } + + private static void init() { + for (final ShapedRecipeObject item : COMPAT_HANDLER.AddRecipeQueue) { + item.buildRecipe(); + } + try { + Thread.sleep(10); + } catch (final InterruptedException e) { + Logger.INFO(e.toString()); + } + Logger.INFO("Late Recipes Loaded: " + recipesSuccess + " Failed: " + recipesFailed); + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java b/src/main/java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java new file mode 100644 index 0000000000..abf7300f7a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java @@ -0,0 +1,25 @@ +package gtPlusPlus.core.handler.Recipes; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.COMPAT_HANDLER; +import gtPlusPlus.core.recipe.RECIPES_General; +import gtPlusPlus.core.recipe.RECIPES_Machines; +import gtPlusPlus.core.recipe.RECIPE_Batteries; + +public class RegistrationHandler { + + public static int recipesSuccess = 0; + public static int recipesFailed = 0; + + public static void run() { + init(); + } + + private static void init() { + RECIPES_General.loadRecipes(); + RECIPES_Machines.loadRecipes(); + RECIPE_Batteries.loadRecipes(); + Logger.INFO("Loaded: " + recipesSuccess + " Failed: " + recipesFailed); + COMPAT_HANDLER.areInitItemsLoaded = true; + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/events/CustomMovementHandler.java b/src/main/java/gtPlusPlus/core/handler/events/CustomMovementHandler.java new file mode 100644 index 0000000000..390efe0b35 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/events/CustomMovementHandler.java @@ -0,0 +1,144 @@ +package gtPlusPlus.core.handler.events; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.MovementInputFromOptions; + +/* + * Replacement for MovementInputFromOptions - Built from the source of ToggleSneak 3.0.3 + */ + +public class CustomMovementHandler { + + public boolean isDisabled; + public boolean canDoubleTap; + + public boolean sprint = false; + public boolean sprintHeldAndReleased = false; + public boolean sprintDoubleTapped = false; + + private long lastPressed; + private long lastSprintPressed; + private boolean handledSneakPress; + private boolean handledSprintPress; + private boolean wasRiding; + + /* + * MovementInputFromOptions.updatePlayerMoveState() + */ + public void update(final Minecraft mc, final MovementInputFromOptions options, final EntityPlayerSP thisPlayer) { + options.moveStrafe = 0.0F; + options.moveForward = 0.0F; + + final GameSettings settings = mc.gameSettings; + + if (settings.keyBindForward.getIsKeyPressed()) { + ++options.moveForward; + } + + if (settings.keyBindBack.getIsKeyPressed()) { + --options.moveForward; + } + + if (settings.keyBindLeft.getIsKeyPressed()) { + ++options.moveStrafe; + } + + if (settings.keyBindRight.getIsKeyPressed()) { + --options.moveStrafe; + } + + options.jump = settings.keyBindJump.getIsKeyPressed(); + + // + // Sneak Toggle - Essentially the same as old ToggleSneak + // + + // Check to see if Enabled - Added 6/17/14 to provide option to disable Sneak Toggle + final boolean isSneaking = SneakManager.get(thisPlayer) + .Sneaking(); + if (isSneaking) { + // Key Pressed + if (settings.keyBindSneak.getIsKeyPressed() && !this.handledSneakPress) { + // Descend if we are flying, note if we were riding (so we can unsneak once dismounted) + if (thisPlayer.isRiding() || thisPlayer.capabilities.isFlying) { + options.sneak = true; + this.wasRiding = thisPlayer.isRiding(); + } else { + options.sneak = !options.sneak; + } + + this.lastPressed = System.currentTimeMillis(); + this.handledSneakPress = true; + } + + // Key Released + if (!settings.keyBindSneak.getIsKeyPressed() && this.handledSneakPress) { + // If we are flying or riding, stop sneaking after descent/dismount. + if (thisPlayer.capabilities.isFlying || this.wasRiding) { + options.sneak = false; + this.wasRiding = false; + } + // If the key was held down for more than 300ms, stop sneaking upon release. + else if ((System.currentTimeMillis() - this.lastPressed) > 300L) { + options.sneak = false; + } + + this.handledSneakPress = false; + } + } else { + options.sneak = settings.keyBindSneak.getIsKeyPressed(); + } + + if (options.sneak || SneakManager.get(thisPlayer) + .Sneaking()) { + options.moveStrafe = (float) (options.moveStrafe * 0.3D); + options.moveForward = (float) (options.moveForward * 0.3D); + } + + // + // Sprint Toggle - Updated 6/18/2014 + // + + // Establish conditions where we don't want to start a sprint - sneaking, riding, flying, hungry + 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.get(thisPlayer) + .Sprinting(); + this.canDoubleTap = SneakManager.get(thisPlayer).optionDoubleTap; + + // Key Pressed + if ((canSprint || this.isDisabled) && settings.keyBindSprint.getIsKeyPressed() && !this.handledSprintPress) { + if (!this.isDisabled) { + this.sprint = !this.sprint; + this.lastSprintPressed = System.currentTimeMillis(); + this.handledSprintPress = true; + this.sprintHeldAndReleased = false; + } + } + + // Key Released + if ((canSprint || this.isDisabled) && !settings.keyBindSprint.getIsKeyPressed() && this.handledSprintPress) { + // Was key held for longer than 300ms? If so, mark it so we can resume vanilla behavior + if ((System.currentTimeMillis() - this.lastSprintPressed) > 300L) { + this.sprintHeldAndReleased = true; + } + this.handledSprintPress = false; + } + } + + public void UpdateSprint(final boolean newValue, final boolean doubleTapped, SneakManager aSneak) { + if (!aSneak.Sprinting()) { + this.sprint = false; + this.sprintDoubleTapped = doubleTapped; + } else { + this.sprint = newValue; + this.sprintDoubleTapped = doubleTapped; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java b/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java new file mode 100644 index 0000000000..07b027faa1 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java @@ -0,0 +1,61 @@ +package gtPlusPlus.core.handler.events; + +import net.minecraft.entity.boss.EntityDragon; +import net.minecraftforge.event.entity.living.LivingDropsEvent; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class EnderDragonDeathHandler { + + private static final String mDragonClassName = "chylex.hee.entity.boss.EntityBossDragon"; + private static final boolean mHEE; + private static final Class mHardcoreDragonClass; + + private static final String mChaosDragonClassName = "com.brandon3055.draconicevolution.common.entity.EntityCustomDragon"; + private static final boolean mDE; + private static final Class mChaoseDragonClass; + + static { + mHEE = ReflectionUtils.doesClassExist(mDragonClassName); + mHardcoreDragonClass = (mHEE ? ReflectionUtils.getClass(mDragonClassName) : null); + mDE = ReflectionUtils.doesClassExist(mChaosDragonClassName); + mChaoseDragonClass = (mDE ? ReflectionUtils.getClass(mChaosDragonClassName) : null); + } + + @SubscribeEvent + public void onEntityDrop(LivingDropsEvent event) { + + int aCountTotal = 0; + + if (mHEE && mHardcoreDragonClass != null && mHardcoreDragonClass.isInstance(event.entityLiving)) { + for (int y = 0; y < MathUtils.randInt(100, 250); y++) { + int aAmount = MathUtils.randInt(5, 25); + event.entityLiving + .entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); + aCountTotal = +aAmount; + } + } else if (mDE && mChaoseDragonClass != null && mChaoseDragonClass.isInstance(event.entityLiving)) { + for (int y = 0; y < MathUtils.randInt(100, 200); y++) { + int aAmount = MathUtils.randInt(1, 5); + event.entityLiving + .entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getIngot(aAmount), MathUtils.randFloat(0, 1)); + aCountTotal = +aAmount; + } + } else if (event.entityLiving instanceof EntityDragon) { + for (int y = 0; y < MathUtils.randInt(25, 50); y++) { + int aAmount = MathUtils.randInt(1, 10); + event.entityLiving + .entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); + aCountTotal = +aAmount; + } + } + if (aCountTotal > 0) { + PlayerUtils + .messageAllPlayers(aCountTotal + " Shards of Dragons Blood have crystalized into a metallic form."); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java b/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java new file mode 100644 index 0000000000..20d64f2b36 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java @@ -0,0 +1,126 @@ +package gtPlusPlus.core.handler.events; + +import java.util.HashMap; +import java.util.HashSet; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.living.LivingDropsEvent; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; + +public class EntityDeathHandler { + + private static final HashMap<Class, AutoMap<Triplet<ItemStack, Integer, Integer>>> mMobDropMap = new HashMap<>(); + private static final HashSet<Class> mInternalClassKeyCache = new HashSet<>(); + + /** + * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. + * + * @param aMobClass - The Base Class you want to drop this item. + * @param aStack - The ItemStack, stack size is not respected. + * @param aMaxAmount - The maximum size of the ItemStack which drops. + * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) + */ + public static void registerDropsForMob(Class aMobClass, ItemStack aStack, int aMaxAmount, int aChance) { + Triplet<ItemStack, Integer, Integer> aData = new Triplet<>(aStack, aMaxAmount, aChance); + AutoMap<Triplet<ItemStack, Integer, Integer>> aDataMap = mMobDropMap.get(aMobClass); + if (aDataMap == null) { + aDataMap = new AutoMap<>(); + } + aDataMap.put(aData); + mMobDropMap.put(aMobClass, aDataMap); + + Logger.INFO( + "[Loot] Registered " + aStack + .getDisplayName() + " (1-" + aMaxAmount + ") as a valid drop for " + aMobClass.getCanonicalName()); + + mInternalClassKeyCache.add(aMobClass); + } + + private static ItemStack processItemDropTriplet(Triplet<ItemStack, Integer, Integer> aData) { + ItemStack aLoot = aData.getValue_1(); + int aMaxDrop = aData.getValue_2(); + int aChanceOutOf10000 = aData.getValue_3(); + if (MathUtils.randInt(0, 10000) <= aChanceOutOf10000) { + aLoot = ItemUtils.getSimpleStack(aLoot, MathUtils.randInt(1, aMaxDrop)); + if (ItemUtils.checkForInvalidItems(aLoot)) { + return aLoot; + } + } + return null; + } + + private static boolean processDropsForMob(EntityLivingBase entityLiving) { + AutoMap<Triplet<ItemStack, Integer, Integer>> aMobData = mMobDropMap.get(entityLiving.getClass()); + boolean aDidDrop = false; + if (aMobData != null) { + if (!aMobData.isEmpty()) { + ItemStack aPossibleDrop; + for (Triplet<ItemStack, Integer, Integer> g : aMobData) { + aPossibleDrop = processItemDropTriplet(g); + if (aPossibleDrop != null) { + if (entityLiving.entityDropItem(aPossibleDrop, MathUtils.randFloat(0, 1)) != null) { + aDidDrop = true; + } + } + } + } + } + return aDidDrop; + } + + private static void dropMeatFromPlayer(EntityPlayer aPlayer) { + + // always drop some meat. + int aBigMeatStackSize1 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem( + ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize1), + MathUtils.randInt(0, 1)); + + // additional chances for more meat. + if (MathUtils.randInt(0, 10) < 7) { + int aBigMeatStackSize2 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem( + ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize2), + MathUtils.randInt(0, 1)); + } + if (MathUtils.randInt(0, 10) < 4) { + int aBigMeatStackSize3 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem( + ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize3), + MathUtils.randInt(0, 1)); + } + if (MathUtils.randInt(0, 10) < 2) { + int aBigMeatStackSize4 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem( + ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize4), + MathUtils.randInt(0, 1)); + } + } + + @SubscribeEvent + public void onEntityDrop(LivingDropsEvent event) { + if (event == null || event.entityLiving == null) { + return; + } + if (PlayerUtils.isRealPlayer(event.entityLiving)) { + EntityPlayer aPlayer = (EntityPlayer) event.entityLiving; + dropMeatFromPlayer(aPlayer); + } else { + for (Class<?> c : mInternalClassKeyCache) { + if (c.isInstance(event.entityLiving)) { + processDropsForMob(event.entityLiving); + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java b/src/main/java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java new file mode 100644 index 0000000000..650fd70efd --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java @@ -0,0 +1,20 @@ +package gtPlusPlus.core.handler.events; + +import net.minecraft.item.Item; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +import advsolar.common.AdvancedSolarPanel; +import cpw.mods.fml.common.Optional; +import gregtech.api.enums.Mods; + +public class GeneralTooltipEventHandler { + + @Optional.Method(modid = Mods.Names.ADVANCED_SOLAR_PANEL) + @SuppressWarnings("unused") + public static void molecularTransformer(ItemTooltipEvent event) { + if (event.itemStack.getItem() == Item.getItemFromBlock(AdvancedSolarPanel.blockMolecularTransformer)) { + event.toolTip.add("" + EnumChatFormatting.RED + "Disabled, Use the multiblock"); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java b/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java new file mode 100644 index 0000000000..0ca315cc72 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java @@ -0,0 +1,109 @@ +package gtPlusPlus.core.handler.events; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; +import net.minecraftforge.event.entity.player.PlayerWakeUpEvent; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.potion.GtPotionEffect; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.CORE_Preloader; + +public class PlayerSleepEventHandler { + + private static Field sEffectDuration = ReflectionUtils + .getField(PotionEffect.class, !CORE_Preloader.DEV_ENVIRONMENT ? "field_76460_b" : "duration"); + private static ArrayList<Potion> sPositiveEffects = new ArrayList<>(); + private static ArrayList<Potion> sNegativeEffects = new ArrayList<>(); + + public static void init() { + Utils.registerEvent(new PlayerSleepEventHandler()); + sPositiveEffects.add(Potion.moveSpeed); + sPositiveEffects.add(Potion.waterBreathing); + sPositiveEffects.add(Potion.resistance); + sPositiveEffects.add(Potion.regeneration); + sPositiveEffects.add(Potion.damageBoost); + sPositiveEffects.add(Potion.digSpeed); + sPositiveEffects.add(Potion.fireResistance); + sPositiveEffects.add(Potion.field_76434_w); // Health Boost + sPositiveEffects.add(Potion.field_76444_x); // Absorption + sNegativeEffects.add(Potion.blindness); + sNegativeEffects.add(Potion.confusion); + sNegativeEffects.add(Potion.digSlowdown); + sNegativeEffects.add(Potion.harm); + sNegativeEffects.add(Potion.hunger); + sNegativeEffects.add(Potion.moveSlowdown); + sNegativeEffects.add(Potion.poison); + sNegativeEffects.add(Potion.weakness); + sNegativeEffects.add(Potion.wither); + } + + @SubscribeEvent + public void sleep(PlayerSleepInBedEvent event) {} + + @SubscribeEvent + public void wake(PlayerWakeUpEvent event) { + EntityPlayer aPlayer = event.entityPlayer; + if (aPlayer != null && !aPlayer.worldObj.isRemote) { + if (event.entityPlayer.getEntityWorld() + .getWorldTime() % 24000 != 0) { + return; + } + boolean aRemovedBad = false; + try { + Collection<PotionEffect> aActive = aPlayer.getActivePotionEffects(); + for (PotionEffect aEffect : aActive) { + for (Potion aBadPotion : sNegativeEffects) { + if (aEffect.getPotionID() == aBadPotion.getId()) { + ReflectionUtils.setField(aEffect, sEffectDuration, 1); + aRemovedBad = true; + Logger.INFO("Set duration of " + aEffect.getEffectName() + " to 1 tick"); + } + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + if (aRemovedBad) { + messagePlayer(aPlayer, "sleep.event.downsides"); + } else { + // Try Heal + float aCurrentHP = aPlayer.getHealth(); + float aMaxHP = aPlayer.getMaxHealth(); + if (aCurrentHP < aMaxHP) { + float aDamage = aMaxHP - aCurrentHP; + float aToHeal = MathUtils.randFloat(1, aDamage); + if (aToHeal > 0) { + aPlayer.heal(aToHeal); + messagePlayer(aPlayer, (aToHeal >= aDamage / 2 ? "sleep.event.good" : "sleep.event.okay")); + } + } + // Already healed, try give a buff + else { + int aRandomBuff = MathUtils.randInt(0, sPositiveEffects.size() - 1); + Potion aPotionToApply = sPositiveEffects.get(aRandomBuff); + if (aPotionToApply != null) { + aPlayer.addPotionEffect( + new GtPotionEffect(aPotionToApply.id, MathUtils.randInt(60, 180), MathUtils.randInt(0, 2))); + messagePlayer(aPlayer, "sleep.event.wellrested"); + } + } + } + } + } + + private static void messagePlayer(EntityPlayer aPlayer, String aChatKey) { + PlayerUtils.messagePlayer(aPlayer, new ChatComponentTranslation(aChatKey, new Object[0])); + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/events/SneakManager.java b/src/main/java/gtPlusPlus/core/handler/events/SneakManager.java new file mode 100644 index 0000000000..7af831c675 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/events/SneakManager.java @@ -0,0 +1,131 @@ +package gtPlusPlus.core.handler.events; + +import java.util.concurrent.ConcurrentHashMap; + +import net.minecraft.entity.player.EntityPlayer; + +import gtPlusPlus.api.objects.Logger; + +public class SneakManager { + + // We make this a singleton for clientside data storage. + + public static ConcurrentHashMap<String, SneakManager> mPlayerCache = new ConcurrentHashMap<>(); + + 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 boolean Sneaking() { + return Crouching.getState(); + } + + public boolean Sprinting() { + return Sprinting.getState(); + } + + public State getSneakingState() { + return Crouching; + } + + public State getSprintingDisabledState() { + return Sprinting; + } + + public void toggleSneaking() { + toggleState(Crouching); + } + + public void toggleSprinting() { + toggleState(Sprinting); + } + + private State toggleState(final State state) { + Logger.INFO("State Toggle"); + if (state == State.ON) { + return State.OFF; + } + return State.ON; + } + + private State setCrouchingStateON() { + return Crouching = State.ON; + } + + private State setCrouchingStateOFF() { + return Crouching = State.OFF; + } + + private State setSprintingStateON() { + return Sprinting = State.ON; + } + + 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); + + private final boolean STATE; + + private State(final boolean State) { + this.STATE = State; + } + + public boolean getState() { + return this.STATE; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java b/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java new file mode 100644 index 0000000000..6933c0f82d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java @@ -0,0 +1,161 @@ +package gtPlusPlus.core.handler.workbench; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraft.world.World; + +public class Workbench_CraftingHandler { + + private static final Workbench_CraftingHandler instance = new Workbench_CraftingHandler(); + private final List<IRecipe> recipes = new ArrayList<>(); + + public static final Workbench_CraftingHandler getInstance() { + return instance; + } + + public Workbench_CraftingHandler() { + + // just a example recipe so you know how to add them + this.addRecipe( + new ItemStack(Blocks.iron_block), + new Object[] { "###", "###", "###", Character.valueOf('#'), Items.iron_ingot }); + + // another example Recipe, but shapeless + this.addShapelessRecipe(new ItemStack(Items.cake), new Object[] { Items.stick }); + } + + void addRecipe(final ItemStack par1ItemStack, final Object par2ArrayOfObj[]) { + String s = ""; + int i = 0; + int j = 0; + int k = 0; + + if (par2ArrayOfObj[i] instanceof String[]) { + final String as[] = (String[]) par2ArrayOfObj[i++]; + + for (final String s2 : as) { + k++; + j = s2.length(); + s = (new StringBuilder()).append(s) + .append(s2) + .toString(); + } + } else { + while (par2ArrayOfObj[i] instanceof String) { + final String s1 = (String) par2ArrayOfObj[i++]; + k++; + j = s1.length(); + s = (new StringBuilder()).append(s) + .append(s1) + .toString(); + } + } + + final HashMap<Character, ItemStack> hashmap = new HashMap<>(); + + for (; i < par2ArrayOfObj.length; i += 2) { + final Character character = (Character) par2ArrayOfObj[i]; + ItemStack itemstack = null; + + if (par2ArrayOfObj[i + 1] instanceof Item) { + itemstack = new ItemStack((Item) par2ArrayOfObj[i + 1]); + } else if (par2ArrayOfObj[i + 1] instanceof Block) { + itemstack = new ItemStack((Block) par2ArrayOfObj[i + 1], 1, -1); + } else if (par2ArrayOfObj[i + 1] instanceof ItemStack) { + itemstack = (ItemStack) par2ArrayOfObj[i + 1]; + } + + hashmap.put(character, itemstack); + } + + final ItemStack aitemstack[] = new ItemStack[j * k]; + + for (int i1 = 0; i1 < (j * k); i1++) { + final char c = s.charAt(i1); + + if (hashmap.containsKey(Character.valueOf(c))) { + aitemstack[i1] = hashmap.get(Character.valueOf(c)) + .copy(); + } else { + aitemstack[i1] = null; + } + } + + this.recipes.add(new ShapedRecipes(j, k, aitemstack, par1ItemStack)); + } + + public void addShapelessRecipe(final ItemStack par1ItemStack, final Object par2ArrayOfObj[]) { + final ArrayList<ItemStack> arraylist = new ArrayList<>(); + final Object aobj[] = par2ArrayOfObj; + final int i = aobj.length; + + for (final Object obj : aobj) { + if (obj instanceof ItemStack) { + arraylist.add(((ItemStack) obj).copy()); + continue; + } + + if (obj instanceof Item) { + arraylist.add(new ItemStack((Item) obj)); + continue; + } + + if (obj instanceof Block) { + arraylist.add(new ItemStack((Block) obj)); + } else { + throw new RuntimeException("Invalid shapeless recipe!"); + } + } + + this.recipes.add(new ShapelessRecipes(par1ItemStack, arraylist)); + } + + public ItemStack findMatchingRecipe(final InventoryCrafting par1InventoryCrafting, final World par2World) { + int i = 0; + for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); j++) { + final ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j); + + if (itemstack2 == null) { + continue; + } + + if (i == 0) {} + + if (i == 1) {} + + i++; + } + + // TODO - Update from itemIDs + /* + * if (i == 2 && itemstack.itemID == itemstack1.itemID && itemstack.stackSize == 1 && itemstack1.stackSize == 1 + * && Item.itemsList[itemstack.itemID].isDamageable()) { Item item = Item.itemsList[itemstack.itemID]; int l = + * item.getMaxDamage() - itemstack.getItemDamageForDisplay(); int i1 = item.getMaxDamage() - + * itemstack1.getItemDamageForDisplay(); int j1 = l + i1 + (item.getMaxDamage() * 10) / 100; int k1 = + * item.getMaxDamage() - j1; if (k1 < 0) { k1 = 0; } return new ItemStack(itemstack.itemID, 1, k1); } + */ + + for (final IRecipe irecipe : this.recipes) { + if (irecipe.matches(par1InventoryCrafting, par2World)) { + return irecipe.getCraftingResult(par1InventoryCrafting); + } + } + + return null; + } + + public List<IRecipe> getRecipeList() { + return this.recipes; + } +} diff --git a/src/main/java/gtPlusPlus/core/interfaces/IGuiManager.java b/src/main/java/gtPlusPlus/core/interfaces/IGuiManager.java new file mode 100644 index 0000000000..599ed6b59b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/interfaces/IGuiManager.java @@ -0,0 +1,16 @@ +package gtPlusPlus.core.interfaces; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +public abstract interface IGuiManager extends IGuiManagerMiscUtils { + + public abstract ChunkCoordinates getCoordinates(); + + public abstract World getWorld(); + + public abstract Object getGui(EntityPlayer paramEntityPlayer, int paramInt); + + public abstract Object getContainer(EntityPlayer paramEntityPlayer, int paramInt); +} diff --git a/src/main/java/gtPlusPlus/core/interfaces/IGuiManagerMiscUtils.java b/src/main/java/gtPlusPlus/core/interfaces/IGuiManagerMiscUtils.java new file mode 100644 index 0000000000..f7f1194b9a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/interfaces/IGuiManagerMiscUtils.java @@ -0,0 +1,4 @@ +package gtPlusPlus.core.interfaces; + +public abstract interface IGuiManagerMiscUtils { +} diff --git a/src/main/java/gtPlusPlus/core/interfaces/IItemBlueprint.java b/src/main/java/gtPlusPlus/core/interfaces/IItemBlueprint.java new file mode 100644 index 0000000000..b0fa752f3f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/interfaces/IItemBlueprint.java @@ -0,0 +1,52 @@ +package gtPlusPlus.core.interfaces; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +public interface IItemBlueprint { + + /** + * The inventory size for the blueprint~ + */ + public int INV_SIZE = 9; + + /** + * Meta Compatible function to allow meta items to be blueprints + * + * @param stack yourMetaItem + * @return true if it is a Blueprint + */ + public boolean isBlueprint(ItemStack stack); + + /** + * Sets the blueprint for this itemstack. + * + * @param stack yourMetaItem + * @return true if blueprint is set successfully + */ + public boolean setBlueprint(ItemStack stack, IInventory craftingTable, ItemStack output); + + /** + * Sets the name of the recipe/blueprint + * + * @param String Blueprint Name + * @return N/A + */ + public void setBlueprintName(ItemStack stack, String name); + + /** + * Does this itemstack hold a blueprint? + * + * @param stack yourMetaItem + * @return true if is holding a Blueprint + */ + public boolean hasBlueprint(ItemStack stack); + + /** + * Gets the recipe held by the item + * + * @param stack yourMetaItem + * @return the blueprints contents + */ + public ItemStack[] getBlueprint(ItemStack stack); +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java b/src/main/java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java new file mode 100644 index 0000000000..180df60e81 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java @@ -0,0 +1,156 @@ +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; + +import gtPlusPlus.core.slots.SlotIntegratedCircuit; + +public class InventoryCircuitProgrammer implements IInventory { + + private final String name = "Circuit Programmer"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 26; + + /** 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 SlotIntegratedCircuit.isItemValidForSlot(itemstack); + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryFishTrap.java b/src/main/java/gtPlusPlus/core/inventories/InventoryFishTrap.java new file mode 100644 index 0000000000..e4797d67bc --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryFishTrap.java @@ -0,0 +1,157 @@ +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 InventoryFishTrap implements IInventory { + + private final String name = "Fishtrap"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 15; + + /** 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; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryPestKiller.java b/src/main/java/gtPlusPlus/core/inventories/InventoryPestKiller.java new file mode 100644 index 0000000000..b508de1d6d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryPestKiller.java @@ -0,0 +1,157 @@ +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; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/Inventory_DecayablesChest.java b/src/main/java/gtPlusPlus/core/inventories/Inventory_DecayablesChest.java new file mode 100644 index 0000000000..83b3631fe9 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/Inventory_DecayablesChest.java @@ -0,0 +1,157 @@ +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_DecayablesChest implements IInventory { + + private final String name = "DecayablesChest"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 15; + + /** 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; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/Inventory_EggBox.java b/src/main/java/gtPlusPlus/core/inventories/Inventory_EggBox.java new file mode 100644 index 0000000000..04a95a4f9a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/Inventory_EggBox.java @@ -0,0 +1,157 @@ +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_EggBox implements IInventory { + + private final String name = "EggBox"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 15; + + /** 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; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/Inventory_SuperJukebox.java b/src/main/java/gtPlusPlus/core/inventories/Inventory_SuperJukebox.java new file mode 100644 index 0000000000..bd44e89776 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/Inventory_SuperJukebox.java @@ -0,0 +1,154 @@ +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_SuperJukebox implements IInventory { + + private final String name = "Sir Mixalot"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 21; + + /** 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 1; + } + + /** + * 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; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java new file mode 100644 index 0000000000..25a03aa212 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java @@ -0,0 +1,156 @@ +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; + +import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; + +public class Inventory_VolumetricFlaskSetter implements IInventory { + + private final String name = "Volumetric Flask Setter"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 9; + + /** 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 16; + } + + /** + * 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 VolumetricFlaskHelper.isVolumetricFlask(itemstack); + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectMain.java b/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectMain.java new file mode 100644 index 0000000000..40e848dc3c --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectMain.java @@ -0,0 +1,173 @@ +package gtPlusPlus.core.inventories.projecttable; + +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 InventoryProjectMain implements IInventory { + + private final String name = "Inventory Grid"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 9; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryProjectMain() {} + + 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)) { + 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) { + 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) { + // Utils.LOG_INFO("getStackInSlot["+slot+"]"); + try { + if (slot >= this.inventory.length) { + // Utils.LOG_INFO("Returning invalid slot item."); + return null; + } + return this.inventory[slot]; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + @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) { + if (slot >= this.inventory.length) { + return; + } + 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; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectOutput.java b/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectOutput.java new file mode 100644 index 0000000000..77bcbd1e35 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectOutput.java @@ -0,0 +1,160 @@ +package gtPlusPlus.core.inventories.projecttable; + +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 InventoryProjectOutput implements IInventory { + + private final String name = "Inventory Output"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 2; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryProjectOutput() {} + + 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)) { + 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) { + 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; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeMain.java b/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeMain.java new file mode 100644 index 0000000000..24dd053e31 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeMain.java @@ -0,0 +1,173 @@ +package gtPlusPlus.core.inventories.tradetable; + +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 InventoryTradeMain implements IInventory { + + private final String name = "Inventory Grid"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 9; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryTradeMain() {} + + 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)) { + 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) { + 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) { + // Utils.LOG_INFO("getStackInSlot["+slot+"]"); + try { + if (slot >= this.inventory.length) { + // Utils.LOG_INFO("Returning invalid slot item."); + return null; + } + return this.inventory[slot]; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + @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) { + if (slot >= this.inventory.length) { + return; + } + 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; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeOutput.java b/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeOutput.java new file mode 100644 index 0000000000..edfbe7602e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeOutput.java @@ -0,0 +1,160 @@ +package gtPlusPlus.core.inventories.tradetable; + +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 InventoryTradeOutput implements IInventory { + + private final String name = "Inventory Output"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 2; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryTradeOutput() {} + + 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)) { + 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) { + 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; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/ModItems.java b/src/main/java/gtPlusPlus/core/item/ModItems.java new file mode 100644 index 0000000000..0fabf375a2 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/ModItems.java @@ -0,0 +1,988 @@ +package gtPlusPlus.core.item; + +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GregTech; +import static gregtech.api.enums.Mods.Thaumcraft; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; +import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; + +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; +import gtPlusPlus.core.block.base.BlockBaseModular; +import gtPlusPlus.core.common.compat.COMPAT_Baubles; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.BaseItemComponent.ComponentTypes; +import gtPlusPlus.core.item.base.BaseItemDamageable; +import gtPlusPlus.core.item.base.BaseItemTCShard; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.item.base.dusts.BaseItemDust; +import gtPlusPlus.core.item.base.foil.BaseItemFoil; +import gtPlusPlus.core.item.base.gears.BaseItemSmallGear; +import gtPlusPlus.core.item.base.ingots.BaseItemIngot; +import gtPlusPlus.core.item.base.ingots.BaseItemIngot_OLD; +import gtPlusPlus.core.item.base.plates.BaseItemPlate; +import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; +import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.item.chemistry.CoalTar; +import gtPlusPlus.core.item.chemistry.GenericChem; +import gtPlusPlus.core.item.chemistry.IonParticles; +import gtPlusPlus.core.item.chemistry.MilledOreProcessing; +import gtPlusPlus.core.item.chemistry.NuclearChem; +import gtPlusPlus.core.item.chemistry.RocketFuels; +import gtPlusPlus.core.item.chemistry.StandardBaseParticles; +import gtPlusPlus.core.item.crafting.ItemDummyResearch; +import gtPlusPlus.core.item.food.BaseItemMetaFood; +import gtPlusPlus.core.item.general.BufferCore; +import gtPlusPlus.core.item.general.ItemAirFilter; +import gtPlusPlus.core.item.general.ItemBasicScrubberTurbine; +import gtPlusPlus.core.item.general.ItemBlueprint; +import gtPlusPlus.core.item.general.ItemEmpty; +import gtPlusPlus.core.item.general.ItemGenericToken; +import gtPlusPlus.core.item.general.ItemHalfCompleteCasings; +import gtPlusPlus.core.item.general.ItemLavaFilter; +import gtPlusPlus.core.item.general.ItemMagicFeather; +import gtPlusPlus.core.item.general.books.ItemBaseBook; +import gtPlusPlus.core.item.general.chassis.ItemBoilerChassis; +import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoil; +import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoilWire; +import gtPlusPlus.core.item.general.spawn.ItemCustomSpawnEgg; +import gtPlusPlus.core.item.init.ItemsFoods; +import gtPlusPlus.core.item.materials.DustDecayable; +import gtPlusPlus.core.item.tool.misc.GregtechPump; +import gtPlusPlus.core.item.wearable.WearableLoader; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.material.NONMATERIAL; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.material.nuclear.NUCLIDE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.everglades.GTplusplus_Everglades; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; + +public final class ModItems { + + public static Item ZZZ_Empty; + public static Item AAA_Broken; + + public static Item itemAlkalusDisk; + public static ItemCustomSpawnEgg itemCustomSpawnEgg; + + public static Item itemIngotBatteryAlloy; + + public static Item itemBedLocator_Base; + public static Item itemBaseItemWithCharge; + + public static Item itemPersonalCloakingDevice; + public static Item itemPersonalHealingDevice; + public static Item itemSupremePizzaGloves; + + public static ItemBlueprint itemBlueprintBase; + + public static Item dustLithiumCarbonate; + public static Item dustLithiumHydroxide; + public static Item dustLithiumPeroxide; + + public static Item dustQuicklime; + public static Item dustCalciumHydroxide; + public static Item dustCalciumCarbonate; + public static Item dustLi2CO3CaOH2; + public static Item dustLi2BeF4; + + public static Item dustTumbagaMix; + + public static Item dustAer; + public static Item dustIgnis; + public static Item dustTerra; + public static Item dustAqua; + + public static Item cellHydrogenChlorideMix; + + public static Item shardAer; + public static Item shardIgnis; + public static Item shardTerra; + public static Item shardAqua; + + // Zirconium + public static Item itemZirconiumChlorideCinterPellet; + public static Item dustZrCl4; + public static Item dustCookedZrCl4; + + public static Item dustCalciumSulfate; + + public static Item dustFertUN18; + public static Item dustFertUN32; + public static Fluid fluidNuclearWaste; + + // Possibly missing base items that GT may be missing. + + public static Item itemSmallWroughtIronGear; + public static Item itemPlateRawMeat; + public static Item itemPlateClay; + public static Item itemPlateLithium; + public static Item itemPlateEuropium; + public static Item itemPlateVanadium; + public static Item itemDoublePlateClay; + public static Item itemDoublePlateEuropium; + public static Item itemFoilUranium235; + public static Item itemDustIndium; + public static BlockBaseModular blockRawMeat; + + public static Item itemBoilerChassis; + public static Item itemDehydratorCoilWire; + public static Item itemDehydratorCoil; + + public static Item itemLavaFilter; + 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; + public static Item itemBasicTurbine; + + public static Item itemHalfCompleteCasings; + + public static Item itemCustomBook; + + // Unstable Elements & Related Content + public static Item dustNeptunium238; + public static Item dustDecayedRadium226; + public static Item dustRadium226; + public static Item dustProtactinium233; + + public static GregtechPump toolGregtechPump; + + public static ItemGenericToken itemGenericToken; + + public static ItemStack itemHotTitaniumIngot; + + public static Fluid fluidZrF4; + public static Fluid fluidFertBasic; + public static Fluid fluidFertUN32; + public static Fluid fluidFertUN18; + + public static DustDecayable dustMolybdenum99; + public static DustDecayable dustTechnetium99; + public static DustDecayable dustTechnetium99M; + + public static IonParticles itemIonParticleBase; + public static StandardBaseParticles itemStandarParticleBase; + + public static BatteryPackBaseBauble itemChargePack_Low_1; + public static BatteryPackBaseBauble itemChargePack_Low_2; + public static BatteryPackBaseBauble itemChargePack_Low_3; + public static BatteryPackBaseBauble itemChargePack_Low_4; + public static BatteryPackBaseBauble itemChargePack_Low_5; + public static BatteryPackBaseBauble itemChargePack_High_1; + public static BatteryPackBaseBauble itemChargePack_High_2; + public static BatteryPackBaseBauble itemChargePack_High_3; + public static BatteryPackBaseBauble itemChargePack_High_4; + + public static ItemDummyResearch itemDummyResearch; + + public static BaseItemMetaFood itemMetaFood; + + public static ItemMagicFeather itemMagicFeather; + + static { + Logger.INFO("Items!"); + // Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is + // called upon. + AAA_Broken = new BaseItemIngot_OLD( + "AAA_Broken", + "Errors - Tell Alkalus", + Utils.rgbtoHexValue(128, 128, 128), + 0); + ZZZ_Empty = new ItemEmpty(); + } + + public static void init() { + + itemMagicFeather = new ItemMagicFeather(); + + itemAlkalusDisk = new BaseItemDamageable( + "itemAlkalusDisk", + AddToCreativeTab.tabMisc, + 1, + 0, + "Unknown Use", + EnumRarity.rare, + EnumChatFormatting.AQUA, + false, + null); + + itemGenericToken = new ItemGenericToken(); + itemDummyResearch = new ItemDummyResearch(); + itemCustomSpawnEgg = new ItemCustomSpawnEgg(); + + // Register meta item, because we need them for everything. + MetaGeneratedGregtechItems.INSTANCE.generateMetaItems(); + + // Register Hydrogen Blobs first, so we can replace old helium blobs. + // Register Old Helium Blob, this will be replaced when held by a player. + + // Load Wearable Items + WearableLoader.run(); + + itemBlueprintBase = new ItemBlueprint("itemBlueprint"); + + itemHalfCompleteCasings = new ItemHalfCompleteCasings( + "itemHalfCompleteCasings", + AddToCreativeTab.tabMisc, + 32, + 0, + "This isn't quite finished yet.", + EnumRarity.common, + EnumChatFormatting.GRAY, + false, + Utils.rgbtoHexValue(255, 255, 255)).setTextureName(GregTech.ID + ":" + "gt.metaitem.01/" + "761"); + + // Start meta Item Generation + ItemsFoods.load(); + + try { + + registerCustomMaterialComponents(); + + // Elements generate first so they can be used in compounds. + // Missing Elements + MaterialGenerator.generate(ELEMENT.getInstance().SELENIUM); // LFTR byproduct + MaterialGenerator.generate(ELEMENT.getInstance().BROMINE); + MaterialGenerator.generate(ELEMENT.getInstance().KRYPTON); // LFTR byproduct + MaterialGenerator.generate(ELEMENT.getInstance().STRONTIUM); + MaterialGenerator.generate(ELEMENT.getInstance().ZIRCONIUM); + MaterialGenerator.generate(ELEMENT.getInstance().RUTHENIUM); + MaterialGenerator.generate(ELEMENT.getInstance().IODINE); // LFTR byproduct + MaterialGenerator.generate(ELEMENT.getInstance().HAFNIUM); + MaterialGenerator.generate(ELEMENT.getInstance().DYSPROSIUM); + MaterialGenerator.generate(ELEMENT.getInstance().ERBIUM); + MaterialGenerator.generate(ELEMENT.getInstance().PRASEODYMIUM); + MaterialGenerator.generate(ELEMENT.getInstance().TELLURIUM); // LFTR byproduct + MaterialGenerator.generate(ELEMENT.getInstance().RHODIUM); + MaterialGenerator.generate(ELEMENT.getInstance().RHENIUM); + MaterialGenerator.generate(ELEMENT.getInstance().THALLIUM); + MaterialGenerator.generate(ELEMENT.getInstance().GERMANIUM); + + // RADIOACTIVE ELEMENTS + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().POLONIUM, false); + // MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().RADON, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().RADIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PROMETHIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PROTACTINIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().CURIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().CALIFORNIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().NEPTUNIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().FERMIUM, false); + + // Nuclear Isotopes + + // Lithium-7 is used as a part of the molten lithium fluoride in molten salt reactors: liquid-fluoride + // nuclear reactors. + // The large neutron-absorption cross-section of lithium-6 (about 940 barns[5]) as compared with the very + // small + // neutron cross-section of lithium-7 (about 45 millibarns) makes high separation of lithium-7 from natural + // lithium a + // strong requirement for the possible use in lithium fluoride reactors. + MaterialGenerator.generate(ELEMENT.getInstance().LITHIUM7, false); + // Thorium-232 is the most stable isotope of Thorium, purified for nuclear fuel use in this case. + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().THORIUM232); + // Production of 233U (through the neutron irradiation of 232Th) invariably produces small amounts of 232U + // as an impurity + // because of parasitic (n,2n) reactions on uranium-233 itself, or on protactinium-233, or on thorium-232: + MaterialGenerator.generate(ELEMENT.getInstance().URANIUM232); + // Uranium-233 is a fissile isotope of uranium that is bred from thorium-232 as part of the thorium fuel + // cycle. + MaterialGenerator.generate(ELEMENT.getInstance().URANIUM233); + // Plutonium-238 is a very powerful alpha emitter. This makes the plutonium-238 isotope suitable for usage + // in radioisotope thermoelectric generators (RTGs) + // and radioisotope heater units - one gram of plutonium-238 generates approximately 0.5 W of thermal power. + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PLUTONIUM238, false); + + // Custom Materials that will have standalone refinery processes + MaterialGenerator.generate(ELEMENT.STANDALONE.ADVANCED_NITINOL, false); + MaterialGenerator.generate(ELEMENT.STANDALONE.ASTRAL_TITANIUM); + MaterialGenerator.generate(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); + MaterialGenerator.generate(ELEMENT.STANDALONE.HYPOGEN); + MaterialGenerator.generate(ELEMENT.STANDALONE.CHRONOMATIC_GLASS); + + // Custom Materials that are from Runescape + MaterialGenerator.generate(ELEMENT.STANDALONE.BLACK_METAL); + MaterialGenerator.generate(ELEMENT.STANDALONE.WHITE_METAL); + MaterialGenerator.generateOreMaterialWithAllExcessComponents(ELEMENT.STANDALONE.GRANITE); + MaterialGenerator.generateOreMaterialWithAllExcessComponents(ELEMENT.STANDALONE.RUNITE); + MaterialGenerator.generate(ELEMENT.STANDALONE.DRAGON_METAL, false); + + MISC_MATERIALS.run(); + + MaterialGenerator.generate(ALLOY.SILICON_CARBIDE); + MaterialGenerator.generate(ALLOY.ZIRCONIUM_CARBIDE); + MaterialGenerator.generate(ALLOY.TANTALUM_CARBIDE); + MaterialGenerator.generate(ALLOY.NIOBIUM_CARBIDE); + MaterialGenerator.generate(ALLOY.TUNGSTEN_TITANIUM_CARBIDE); + + // LFTR Fuel components + MaterialGenerator.generateNuclearDusts(FLUORIDES.AMMONIUM_BIFLUORIDE); // LFTR fuel component + MaterialGenerator.generateNuclearDusts(FLUORIDES.BERYLLIUM_HYDROXIDE); // LFTR fuel component + // MaterialGenerator.generateNuclearDusts(FLUORIDES.AMMONIUM_TETRAFLUOROBERYLLATE); // LFTR fuel component + + // Generate Fluorides + MaterialGenerator.generateNuclearDusts(FLUORIDES.BERYLLIUM_FLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.LITHIUM_FLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.THORIUM_TETRAFLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.THORIUM_HEXAFLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.URANIUM_TETRAFLUORIDE, false); + MaterialGenerator.generateNuclearDusts(FLUORIDES.URANIUM_HEXAFLUORIDE, false); + MaterialGenerator.generateNuclearDusts(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE); + // LFTR Fluoride outputs + MaterialGenerator.generateNuclearDusts(FLUORIDES.NEPTUNIUM_HEXAFLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.TECHNETIUM_HEXAFLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.SELENIUM_HEXAFLUORIDE); + + // Generate Reactor Fuel Salts + MaterialGenerator.generateNuclearDusts(NUCLIDE.LiFBeF2ZrF4U235); + MaterialGenerator.generateNuclearDusts(NUCLIDE.LiFBeF2ZrF4UF4); + MaterialGenerator.generateNuclearDusts(NUCLIDE.LiFBeF2ThF4UF4); + // MaterialGenerator.generateNuclearMaterial(NUCLIDE.Li2BeF4, false); + + // Generate some Alloys + + // Misc Alloys + MaterialGenerator.generate(ALLOY.ENERGYCRYSTAL); + MaterialGenerator.generate(ALLOY.BLOODSTEEL); + + MaterialGenerator.generate(ALLOY.ZERON_100); + // Tumbaga was the name given by Spaniards to a non-specific alloy of gold and copper + MaterialGenerator.generate(ALLOY.TUMBAGA); + // Potin is traditionally an alloy of bronze, tin and lead, with varying quantities of each possible + MaterialGenerator.generate(ALLOY.POTIN); + + // Staballoy & Tantalloy + MaterialGenerator.generate(ALLOY.STABALLOY); + MaterialGenerator.generate(ALLOY.TANTALLOY_60); + MaterialGenerator.generate(ALLOY.TANTALLOY_61); + + // Inconel + MaterialGenerator.generate(ALLOY.INCONEL_625); + MaterialGenerator.generate(ALLOY.INCONEL_690); + MaterialGenerator.generate(ALLOY.INCONEL_792); + + // Steels + MaterialGenerator.generateDusts(ALLOY.EGLIN_STEEL_BASE); + MaterialGenerator.generate(ALLOY.EGLIN_STEEL); + MaterialGenerator.generate(ALLOY.MARAGING250); + MaterialGenerator.generate(ALLOY.MARAGING300); + MaterialGenerator.generate(ALLOY.MARAGING350); + MaterialGenerator.generate(ALLOY.AQUATIC_STEEL); + + MaterialGenerator.generate(ALLOY.NITINOL_60, true); + + // Composite Alloys + MaterialGenerator.generate(ALLOY.STELLITE); + MaterialGenerator.generate(ALLOY.TALONITE); + + // Hastelloy + MaterialGenerator.generate(ALLOY.HASTELLOY_W); + MaterialGenerator.generate(ALLOY.HASTELLOY_X); + MaterialGenerator.generate(ALLOY.HASTELLOY_C276); + MaterialGenerator.generate(ALLOY.HASTELLOY_N); + + // Incoloy + MaterialGenerator.generate(ALLOY.INCOLOY_020); + MaterialGenerator.generate(ALLOY.INCOLOY_DS); + MaterialGenerator.generate(ALLOY.INCOLOY_MA956); + + // Leagrisium + MaterialGenerator.generate(ALLOY.LEAGRISIUM); + + // Super Conductor + MaterialGenerator.generate(ALLOY.HG1223, false, false); + + // Generate Fictional Materials + MaterialGenerator.generate(ALLOY.TRINIUM_TITANIUM); + MaterialGenerator.generate(ALLOY.TRINIUM_NAQUADAH, false); + MaterialGenerator.generate(ALLOY.TRINIUM_NAQUADAH_CARBON); + MaterialGenerator.generate(ALLOY.TRINIUM_REINFORCED_STEEL); + + // Top Tier Alloys + MaterialGenerator.generate(ALLOY.HELICOPTER); + MaterialGenerator.generate(ALLOY.LAFIUM); + MaterialGenerator.generate(ALLOY.CINOBITE); + MaterialGenerator.generate(ALLOY.PIKYONIUM); + MaterialGenerator.generate(ALLOY.ABYSSAL); + MaterialGenerator.generate(ALLOY.LAURENIUM); + + // abs recipe in RECIPES_GREGTECH.java + MaterialGenerator.generate(ALLOY.BOTMIUM, true, false); + + MaterialGenerator.generate(ALLOY.HS188A); + + MaterialGenerator.generate(ALLOY.TITANSTEEL); + MaterialGenerator.generate(ALLOY.ARCANITE); + MaterialGenerator.generate(ALLOY.OCTIRON); + + MaterialGenerator.generate(ALLOY.BABBIT_ALLOY, false); + MaterialGenerator.generate(ALLOY.BLACK_TITANIUM, false); + MaterialGenerator.generate(ALLOY.INDALLOY_140, false, false); + + // High Level Bioplastic + MaterialGenerator.generate(ELEMENT.STANDALONE.RHUGNOR, false, false); + + // Must be the final Alloy to Generate + MaterialGenerator.generate(ALLOY.QUANTUM); + + // Ores + MaterialGenerator.generateOreMaterial(FLUORIDES.FLUORITE); + MaterialGenerator.generateOreMaterial(ALLOY.KOBOLDITE); + GTplusplus_Everglades.GenerateOreMaterials(); + + // formula override + ALLOY.TUNGSTEN_TITANIUM_CARBIDE.vChemicalFormula = StringUtils.subscript("(CW)7Ti3"); + ALLOY.TITANSTEEL.vChemicalFormula = StringUtils.subscript("((CW)7Ti3)3???"); + + // Werkstoff bridge + ELEMENT.getInstance().ZIRCONIUM.setWerkstoffID((short) 3); + ELEMENT.getInstance().THORIUM232.setWerkstoffID((short) 30); + ELEMENT.getInstance().RUTHENIUM.setWerkstoffID((short) 64); + ELEMENT.getInstance().HAFNIUM.setWerkstoffID((short) 11000); + ELEMENT.getInstance().IODINE.setWerkstoffID((short) 11012); + + } catch (final Throwable r) { + Logger.INFO("Failed to Generated a Material. " + r.getMessage()); + r.printStackTrace(); + } + + // Generates four elemental shards when TC is not installed. + if (!Thaumcraft.isModLoaded()) { + shardAer = new BaseItemTCShard("Aer", Utils.rgbtoHexValue(225, 225, 5)); + shardIgnis = new BaseItemTCShard("Ignis", Utils.rgbtoHexValue(255, 5, 5)); + shardTerra = new BaseItemTCShard("Terra", Utils.rgbtoHexValue(5, 255, 5)); + shardAqua = new BaseItemTCShard("Aqua", Utils.rgbtoHexValue(5, 5, 255)); + } else { + shardAer = ItemUtils + .getItemStackWithMeta(Thaumcraft.isModLoaded(), "Thaumcraft:ItemShard", "Air Shard", 0, 1) + .getItem(); + shardIgnis = ItemUtils + .getItemStackWithMeta(Thaumcraft.isModLoaded(), "Thaumcraft:ItemShard", "Fire Shard", 1, 1) + .getItem(); + shardAqua = ItemUtils + .getItemStackWithMeta(Thaumcraft.isModLoaded(), "Thaumcraft:ItemShard", "Warer Shard", 2, 1) + .getItem(); + shardTerra = ItemUtils + .getItemStackWithMeta(Thaumcraft.isModLoaded(), "Thaumcraft:ItemShard", "Earth Shard", 3, 1) + .getItem(); + } + // Generates a set of four special dusts to be used in my recipes. + dustAer = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().AER, true)[0]; + dustIgnis = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().IGNIS, true)[0]; + dustTerra = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().TERRA, true)[0]; + dustAqua = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().AQUA, true)[0]; + + ItemUtils.generateSpecialUseDusts(MISC_MATERIALS.WOODS_GLASS, false); + cellHydrogenChlorideMix = MISC_MATERIALS.HYDROGEN_CHLORIDE_MIX.getCell(1) + .getItem(); + + // Nuclear Fuel Dusts + dustLithiumCarbonate = ItemUtils.generateSpecialUseDusts( + "LithiumCarbonate", + "Lithium Carbonate", + "Li2CO3", + Utils.rgbtoHexValue(240, 240, 240))[0]; // https://en.wikipedia.org/wiki/Lithium_carbonate + dustLithiumPeroxide = ItemUtils.generateSpecialUseDusts( + "LithiumPeroxide", + "Lithium Peroxide", + "Li2O2", + Utils.rgbtoHexValue(250, 250, 250))[0]; // https://en.wikipedia.org/wiki/Lithium_peroxide + dustLithiumHydroxide = ItemUtils.generateSpecialUseDusts( + "LithiumHydroxide", + "Lithium Hydroxide", + "LiOH", + Utils.rgbtoHexValue(250, 250, 250))[0]; // https://en.wikipedia.org/wiki/Lithium_hydroxide + + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDict("dustQuicklime", 1))) { + dustQuicklime = ItemUtils + .generateSpecialUseDusts("Quicklime", "Quicklime", "CaO", Utils.rgbtoHexValue(255, 255, 175))[0]; // https://en.wikipedia.org/wiki/Calcium_oxide + } + dustCalciumHydroxide = ItemUtils.generateSpecialUseDusts( + "CalciumHydroxide", + "Hydrated Lime", + "Ca(OH)2", + Utils.rgbtoHexValue(255, 255, 255))[0]; // https://en.wikipedia.org/wiki/Calcium_hydroxide + dustCalciumCarbonate = ItemUtils.generateSpecialUseDusts( + "CalciumCarbonate", + "Calcium Carbonate", + "CaCO3", + Utils.rgbtoHexValue(255, 255, 255))[0]; // https://en.wikipedia.org/wiki/Calcium_carbonate + if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGypsum", 1) == null) + || (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustCalciumSulfate", 1) == null)) { + dustCalciumSulfate = ItemUtils.generateSpecialUseDusts( + "Gypsum", + "Calcium Sulfate (Gypsum)", + "CaSO4", + Utils.rgbtoHexValue(255, 255, 255))[0]; // https://en.wikipedia.org/wiki/Calcium_sulfate + GT_OreDictUnificator.registerOre("dustCalciumSulfate", ItemUtils.getSimpleStack(dustCalciumSulfate)); + } else { + GT_OreDictUnificator + .registerOre("dustCalciumSulfate", ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGypsum", 1)); + } + dustLi2CO3CaOH2 = ItemUtils.generateSpecialUseDusts( + "Li2CO3CaOH2", + "Li2CO3 + Ca(OH)2 Compound", + "Li2CO3CaOH2", + Utils.rgbtoHexValue(255, 255, 255))[0]; // https://en.wikipedia.org/wiki/Calcium_carbonate + MaterialUtils.generateSpecialDustAndAssignToAMaterial(FLUORIDES.SODIUM_FLUORIDE, false); + // FLiBe Fuel Compounds + dustLi2BeF4 = ItemUtils.generateSpecialUseDusts( + "Li2BeF4", + "Lithium Tetrafluoroberyllate Fuel Compound", + "Li2BeF4", + Utils.rgbtoHexValue(255, 255, 255))[0]; // https://en.wikipedia.org/wiki/FLiBe + Material.registerComponentForMaterial(NUCLIDE.Li2BeF4, OrePrefixes.dust, ItemUtils.getSimpleStack(dustLi2BeF4)); + // fluidFLiBeSalt = ("Li2BeF4", "Li2BeF4", 7430, new short[]{255, 255, 255, 100}, 0); + // fluidFLiBeSalt = FluidUtils.addGTFluidNoPrefix("Li2BeF4", "Lithium Tetrafluoroberyllate", new short[]{255, + // 255, 255, 100}, 0, 743, null, CI.emptyCells(1), 1000, true); + // fluidFLiBeSaltBurnt = FluidUtils.addGTFluidNoPrefix("Li2BeF2UF4", "Li2BeF2UF4", new short[]{50, 255, 50, + // 100}, 0, 743, null, CI.emptyCells(1), 1000, true); + + // LFTR Core Fluid Processing + // fluidLftrCore1 = FluidUtils.addGTFluidNoPrefix("LiBeF2UF4FP", "LiBeF2UF4FP", new short[]{110, 255, 110, 100}, + // 0, 800, null, CI.emptyCells(1), 1000, true); + // fluidLftrCore2 = FluidUtils.addGTFluidNoPrefix("UF6F2FP", "UF6F2FP", new short[]{150, 255, 150, 100}, 0, 800, + // null, CI.emptyCells(1), 1000, true); + // fluidLftrCore3 = FluidUtils.addGTFluidNoPrefix("LiFBeF2", "LiFBeF2", new short[]{100, 255, 50, 100}, 0, 800, + // null, CI.emptyCells(1), 1000, true); + // fluidLftrCore4 = FluidUtils.addGTFluidNoPrefix("LiFBeF2UF4", "LiFBeF2UF4", new short[]{50, 255, 100, 100}, 0, + // 800, null, CI.emptyCells(1), 1000, true); + // LFTR Blanket Fluid Processing + fluidNuclearWaste = FluidUtils.addGTFluidNoPrefix( + "nuclear.waste", + "Nuclear Waste", + new short[] { 10, 250, 10, 100 }, + 0, + 1000, + null, + CI.emptyCells(1), + 1000, + true); + + // LFTR Control Circuit + itemCircuitLFTR = new CoreItem( + "itemCircuitLFTR", + "" + EnumChatFormatting.GREEN + "Control Circuit", + AddToCreativeTab.tabMisc, + 1, + 0, + new String[] { "Keeps Multiblocks Stable" }, + EnumRarity.epic, + EnumChatFormatting.DARK_GREEN, + false, + null); + + if (CORE.ConfigSwitches.enableMachine_Pollution) { + itemBasicTurbine = new ItemBasicScrubberTurbine(); + } + + // Zirconium + // Cinter Pellet. + itemZirconiumChlorideCinterPellet = new CoreItem( + "itemZirconiumPellet", + "Zirconium Pellet [" + StringUtils.subscript("ZrCl4") + "]", + tabMisc).setTextureName(GTPlusPlus.ID + ":itemShard"); + GT_OreDictUnificator.registerOre("pelletZirconium", new ItemStack(itemZirconiumChlorideCinterPellet)); + // Zirconium Chloride + dustZrCl4 = ItemUtils.generateSpecialUseDusts("ZrCl4", "ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; // http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf + dustCookedZrCl4 = ItemUtils + .generateSpecialUseDusts("CookedZrCl4", "Cooked ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; // http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf + + // Zirconium Tetrafluoride + /* + * GT_OreDictUnificator.registerOre("cellZrF4", + * ItemUtils.getItemStackOfAmountFromOreDict("cellZirconiumTetrafluoride", 1)); + * GT_OreDictUnificator.registerOre("dustZrF4", + * ItemUtils.getItemStackOfAmountFromOreDict("dustZirconiumTetrafluoride", 1)); + */ + fluidZrF4 = FluidUtils.generateFluidNoPrefix( + "ZirconiumTetrafluoride", + "Zirconium Tetrafluoride", + 500, + new short[] { 170, 170, 140, 100 }); // https://en.wikipedia.org/wiki/Zirconium_tetrafluoride + FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.setFluid(fluidZrF4); + + // Coolant Salt + // NaBF4 - NaF - 621C + // dustNaBF4NaF = ItemUtils.generateSpecialUseDusts("NaBF4NaF", "NaBF4NaF", Utils.rgbtoHexValue(45, 45, 90))[0]; + // //https://en.wikipedia.org/wiki/Zirconium_tetrafluoride + + // Load Tree Farmer + if (CORE.ConfigSwitches.enableMultiblock_TreeFarmer) { // https://en.wikipedia.org/wiki/UAN + dustFertUN18 = ItemUtils + .generateSpecialUseDusts("UN18Fertiliser", "UN-18 Fertiliser", Utils.rgbtoHexValue(60, 155, 60))[0]; + dustFertUN32 = ItemUtils + .generateSpecialUseDusts("UN32Fertiliser", "UN-32 Fertiliser", Utils.rgbtoHexValue(55, 190, 55))[0]; + + ItemStack temp1 = ItemUtils.getCorrectStacktype("IC2:itemFertilizer", 1); + ItemStack temp2 = null; + + if (Forestry.isModLoaded()) { + temp2 = ItemUtils.getCorrectStacktype("Forestry:fertilizerCompound", 1); + } + if (temp1 != null) { + fluidFertBasic = FluidUtils.generateFluidNonMolten( + "Fertiliser", + "Fertiliser", + 32, + new short[] { 45, 170, 45, 100 }, + temp1, + null, + true); + GT_Values.RA.stdBuilder() + .itemInputs(temp2) + .fluidOutputs(new FluidStack(fluidFertBasic, 36)) + .duration(5 * TICKS) + .eut(16) + .addTo(fluidExtractionRecipes); + } + fluidFertUN32 = FluidUtils.generateFluidNonMolten( + "UN32Fertiliser", + "UN-32 Fertiliser", + 24, + new short[] { 55, 190, 55, 100 }, + null, + null, + true); + fluidFertUN18 = FluidUtils.generateFluidNonMolten( + "UN18Fertiliser", + "UN-18 Fertiliser", + 22, + new short[] { 60, 155, 60, 100 }, + null, + null, + true); + + /* + * GT_Values.RA.addMixerRecipe( arg0, //Item In arg1, arg2, arg3, arg4, //Fluid in arg5, //Fluid Out arg6, + * //Item out arg7, //Eu arg8); //Time + */ + + } + + // Juice + FluidUtils.generateFluidNonMolten( + "RaisinJuice", + "Raisin Juice", + 2, + new short[] { 51, 0, 51, 100 }, + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foodRaisins", 1), + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("fruitRaisins", 1), + 50, + true); + + // Test items + toolGregtechPump = new GregtechPump(); + toolGregtechPump.registerPumpType(0, "Simple Hand Pump", 0, 0); + toolGregtechPump.registerPumpType(1, "Advanced Hand Pump", 32000, 1); + toolGregtechPump.registerPumpType(2, "Super Hand Pump", 128000, 2); + toolGregtechPump.registerPumpType(3, "Ultimate Hand Pump", 512000, 3); + + // Xp Fluids - Dev + if (!FluidRegistry.isFluidRegistered("mobessence")) { + FluidUtils.generateFluidNoPrefix("mobessence", "Mob Essence", 0, new short[] { 125, 175, 125, 100 }); + } + + dustNeptunium238 = new DustDecayable( + "dustNeptunium238", + Utils.rgbtoHexValue(175, 240, 75), + 50640, + new String[] { StringUtils.superscript("238Np"), + "Result: Plutonium 238 (" + StringUtils.superscript("238Pu") + ")" }, + ELEMENT.getInstance().PLUTONIUM238.getDust(1) + .getItem(), + 5); + dustDecayedRadium226 = ItemUtils.generateSpecialUseDusts( + "DecayedRadium226", + "Decayed Radium-226", + "Contains Radon (" + StringUtils.superscript("222Rn") + ")", + ELEMENT.getInstance().RADIUM.getRgbAsHex())[0]; + dustRadium226 = new DustDecayable( + "dustRadium226", + ELEMENT.getInstance().RADIUM.getRgbAsHex(), + 90000, + new String[] { StringUtils.superscript("226Ra"), + "Result: Radon (" + StringUtils.superscript("222Rn") + ")" }, + ItemUtils.getSimpleStack(dustDecayedRadium226) + .getItem(), + 5); + dustProtactinium233 = new DustDecayable( + "dustProtactinium233", + ELEMENT.getInstance().PROTACTINIUM.getRgbAsHex(), + 32000, + new String[] { StringUtils.superscript("233Pa"), + "Result: Uranium 233(" + StringUtils.superscript("233U") + ")" }, + ELEMENT.getInstance().URANIUM233.getDust(1) + .getItem(), + 6); + dustMolybdenum99 = new DustDecayable( + "dustMolybdenum99", + ELEMENT.getInstance().MOLYBDENUM.getRgbAsHex(), + 16450, + new String[] { StringUtils.superscript("99Mo"), + "Result: Technicium 99ᵐ (" + StringUtils.superscript("99ᵐTc") + ")" }, + dustTechnetium99M, + 4); + + itemIonParticleBase = new IonParticles(); + itemStandarParticleBase = new StandardBaseParticles(); + + Item a8kFlask = VolumetricFlaskHelper.generateNewFlask("Volumetric_Flask_8k", "Large Volumetric Flask", 8000); + Item a64kFlask = VolumetricFlaskHelper + .generateNewFlask("Volumetric_Flask_32k", "Gigantic Volumetric Flask", 32000); + GregtechItemList.VOLUMETRIC_FLASK_8k.set(a8kFlask); + GregtechItemList.VOLUMETRIC_FLASK_32k.set(a64kFlask); + + itemBoilerChassis = new ItemBoilerChassis(); + itemDehydratorCoilWire = new ItemDehydratorCoilWire(); + itemDehydratorCoil = new ItemDehydratorCoil(); + + itemAirFilter = new ItemAirFilter(); + itemLavaFilter = new ItemLavaFilter(); + + // Chemistry + new CoalTar(); + new RocketFuels(); + + // Nuclear Processing + new NuclearChem(); + + // Farm Animal Fun + new AgriculturalChem(); + + // General Chemistry + new GenericChem(); + + // Milled Ore Processing + new MilledOreProcessing(); + + // IC2 Exp + Logger.INFO("IndustrialCraft2 Found - Loading Resources."); + + // Baubles Mod Test + try { + final Class<?> baublesTest = ReflectionUtils.getClass("baubles.api.IBauble"); + if (baublesTest != null) { + COMPAT_Baubles.run(); + } else { + Logger.INFO("Baubles Not Found - Skipping Resources."); + } + } catch (final Throwable T) { + Logger.INFO("Baubles Not Found - Skipping Resources."); + } + + // Buffer Cores! + Item itemBufferCore; + for (int i = 1; i <= 10; i++) { + itemBufferCore = new BufferCore("itemBufferCore", i).setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerItem(itemBufferCore, itemBufferCore.getUnlocalizedName()); + } + + itemCustomBook = new ItemBaseBook(); + registerCustomTokens(); + } + + public static void registerCustomTokens() { + itemGenericToken.register(0, "BitCoin", 16, "Can be used on the dark web"); + itemGenericToken.register(1, "Hand Pump Trade Token I", 1, "Craft into a Tier I Hand pump"); + itemGenericToken.register(2, "Hand Pump Trade Token II", 1, "Craft into a Tier II Hand pump"); + itemGenericToken.register(3, "Hand Pump Trade Token III", 1, "Craft into a Tier III Hand pump"); + itemGenericToken.register(4, "Hand Pump Trade Token IV", 1, "Craft into a Tier IV Hand pump"); + } + + public static void registerCustomMaterialComponents() { + // Custom GT++ Crafting Components + + /* + * Try to generate dusts for missing rare earth materials if they don't exist + */ + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGadolinium", 1))) { + ItemUtils.generateSpecialUseDusts( + "Gadolinium", + "Gadolinium", + Materials.Gadolinium.mElement.name(), + Utils.rgbtoHexValue(226, 172, 9)); + } + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustYtterbium", 1))) { + ItemUtils.generateSpecialUseDusts( + "Ytterbium", + "Ytterbium", + Materials.Ytterbium.mElement.name(), + Utils.rgbtoHexValue( + Materials.Yttrium.mRGBa[0] - 60, + Materials.Yttrium.mRGBa[1] - 60, + Materials.Yttrium.mRGBa[2] - 60)); + } + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustSamarium", 1))) { + ItemUtils.generateSpecialUseDusts( + "Samarium", + "Samarium", + Materials.Samarium.mElement.name(), + Utils.rgbtoHexValue(161, 168, 114)); + } + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustLanthanum", 1))) { + ItemUtils.generateSpecialUseDusts( + "Lanthanum", + "Lanthanum", + Materials.Lanthanum.mElement.name(), + Utils.rgbtoHexValue(106, 127, 163)); + } + + // Just an unusual plate needed for some black magic. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateClay", 1) == null) { + itemPlateClay = new BaseItemPlate(NONMATERIAL.CLAY); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleClay", 1) == null) { + itemDoublePlateClay = new BaseItemPlateDouble(NONMATERIAL.CLAY); + } + + // Need this for Mutagenic Frames + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilUranium235", 1) == null) { + itemFoilUranium235 = new BaseItemFoil(ELEMENT.getInstance().URANIUM235); + } + + // A small gear needed for wizardry. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("gearGtSmallWroughtIron", 1) == null) { + itemSmallWroughtIronGear = new BaseItemSmallGear(NONMATERIAL.WROUGHT_IRON); + } + // Krypton Processing + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotHotTitanium", 1) == null) { + itemHotTitaniumIngot = ItemUtils + .getSimpleStack(new BaseItemIngot(ELEMENT.getInstance().TITANIUM, ComponentTypes.HOTINGOT)); + } else { + itemHotTitaniumIngot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotHotTitanium", 1); + } + + // Need this for Laurenium + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustIndium", 1) == null) { + itemDustIndium = new BaseItemDust(ELEMENT.getInstance().INDIUM); + } + + // Springs + MaterialUtils + .generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ELEMENT.STANDALONE.WHITE_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.NITINOL_60); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.AQUATIC_STEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.EGLIN_STEEL); + + // Small Springs + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.MARAGING250); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.NICHROME); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.STABALLOY); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.STEEL_BLACK); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.BLACK_TITANIUM); + + // Fine Wire + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.STANDALONE.WHITE_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.getInstance().PALLADIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.getInstance().ZIRCONIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.LEAGRISIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.BABBIT_ALLOY); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.KOBOLDITE); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.HG1223); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.QUANTUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.STANDALONE.HYPOGEN); + MaterialUtils + .generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.STANDALONE.CHRONOMATIC_GLASS); + + // Foil + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.BLACK_TITANIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.BOTMIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.TITANSTEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.NITINOL_60); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.QUANTUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.LAURENIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.HYPOGEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.ASTRAL_TITANIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.RHUGNOR); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.WHITE_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.ADVANCED_NITINOL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.PIKYONIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.CINOBITE); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.LAFIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.TRINIUM_REINFORCED_STEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.CHRONOMATIC_GLASS); + + // Special Sillyness + if (true) { + + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateSodium", 1) == null) { + new BaseItemPlate(ELEMENT.getInstance().SODIUM); + } + + Material meatRaw = NONMATERIAL.MEAT; + // A plate of Meat. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateMeatRaw", 1) == null) { + itemPlateRawMeat = new BaseItemPlate(meatRaw); + ItemUtils.registerFuel(ItemUtils.getSimpleStack(itemPlateRawMeat), 100); + } + // A Block of Meat. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("blockMeatRaw", 1) == null) { + blockRawMeat = new BlockBaseModular(meatRaw, BlockTypes.STANDARD); + ItemUtils.registerFuel(ItemUtils.getSimpleStack(blockRawMeat), 900); + } + } + + // A plate of Vanadium. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateVanadium", 1) == null) { + itemPlateVanadium = new BaseItemPlate(ELEMENT.getInstance().VANADIUM); + } + + // A plate of Lithium. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateLithium", 1) == null) { + itemPlateLithium = new BaseItemPlate(ELEMENT.getInstance().LITHIUM); + } + + // A plate of Europium. + if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateEuropium", 1) == null) + && CORE.ConfigSwitches.enableCustom_Pipes) { + itemPlateEuropium = new BaseItemPlate(ELEMENT.getInstance().EUROPIUM); + } + if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleEuropium", 1) == null) + && CORE.ConfigSwitches.enableCustom_Pipes) { + itemDoublePlateEuropium = new BaseItemPlateDouble(ELEMENT.getInstance().EUROPIUM); + } + + // Tumbaga Mix (For Simple Crafting) + dustTumbagaMix = ItemUtils + .generateSpecialUseDusts("MixTumbaga", "Tumbaga Mix", "Au2Cu", Utils.rgbtoHexValue(255, 150, 80))[0]; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemBurnable.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemBurnable.java new file mode 100644 index 0000000000..8bbc5a3b08 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemBurnable.java @@ -0,0 +1,42 @@ +package gtPlusPlus.core.item.base; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; + +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BaseItemBurnable extends CoreItem { + + protected final int meta; + + public BaseItemBurnable(String unlocalizedName, String displayName, CreativeTabs creativeTab, int stackSize, + int maxDmg, String description, String oredictName, int burnTime, int meta) { + super(unlocalizedName, creativeTab, stackSize, maxDmg, description); + this.itemName = displayName; + this.meta = meta; + if (oredictName != null && !oredictName.equals("")) { + registerOrdictionary(oredictName); + } + registerFuel(burnTime); + } + + public void registerFuel(int burn) { + CORE.burnables.add(new Pair<>(burn, ItemUtils.getSimpleStack(this, 1))); + } + + public final void registerOrdictionary(String name) { + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(this), name); + } + + @Override + public int getDamage(ItemStack stack) { + return this.meta; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemColourable.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemColourable.java new file mode 100644 index 0000000000..d391207a56 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemColourable.java @@ -0,0 +1,100 @@ +package gtPlusPlus.core.item.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_LanguageManager; + +public class BaseItemColourable extends Item { + + private final EnumRarity rarity; + private final EnumChatFormatting descColour; + private final boolean hasEffect; + public final int componentColour; + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return this.componentColour; + } + + // 5 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public BaseItemColourable(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, + final int maxDmg, final String description, final EnumRarity regRarity, final EnumChatFormatting colour, + final boolean Effect, int rgb) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(GTPlusPlus.ID + ":" + unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(stackSize); + this.setMaxDamage(maxDmg); + this.setHasSubtypes(true); + this.rarity = regRarity; + GT_LanguageManager.addStringLocalization("gtplusplus." + this.getUnlocalizedName() + ".tooltip", description); + this.descColour = colour; + this.hasEffect = Effect; + this.componentColour = rgb; + GameRegistry.registerItem(this, unlocalizedName); + } + + // 6 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public BaseItemColourable(final String unlocalizedName, final String displayName, final CreativeTabs creativeTab, + final int stackSize, final int maxDmg, final String description, final EnumRarity regRarity, + final EnumChatFormatting colour, final boolean Effect, int rgb) { + this.setUnlocalizedName(unlocalizedName); + GT_LanguageManager.addStringLocalization("gtplusplus." + this.getUnlocalizedName() + ".name", displayName); + this.setTextureName(GTPlusPlus.ID + ":" + unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(stackSize); + this.setMaxDamage(maxDmg); + this.rarity = regRarity; + GT_LanguageManager.addStringLocalization("gtplusplus." + this.getUnlocalizedName() + ".tooltip", description); + this.descColour = colour; + this.hasEffect = Effect; + this.componentColour = rgb; + GameRegistry.registerItem(this, unlocalizedName); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add( + this.descColour + + GT_LanguageManager.getTranslation("gtplusplus." + this.getUnlocalizedName() + ".tooltip")); + // super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return this.rarity; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack, final int pass) { + return this.hasEffect; + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if (!("gtplusplus." + this.getUnlocalizedName() + ".name") + .equals(GT_LanguageManager.getTranslation("gtplusplus." + this.getUnlocalizedName() + ".name"))) { + return GT_LanguageManager.getTranslation("gtplusplus." + this.getUnlocalizedName() + ".name"); + } else return super.getItemStackDisplayName(tItem); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java new file mode 100644 index 0000000000..6846f8febb --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -0,0 +1,459 @@ +package gtPlusPlus.core.item.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GregTech; + +import java.awt.Color; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; + +public class BaseItemComponent extends Item { + + private static final Class<TextureSet> mTextureSetPreload; + + static { + mTextureSetPreload = TextureSet.class; + } + + public final Material componentMaterial; + public final String materialName; + public final String unlocalName; + public final String translatedMaterialName; + public final ComponentTypes componentType; + public final int componentColour; + public Object extraData; + + protected IIcon base; + protected IIcon overlay; + + public BaseItemComponent(final Material material, final ComponentTypes componentType) { + this.componentMaterial = material; + this.unlocalName = "item" + componentType.COMPONENT_NAME + material.getUnlocalizedName(); + this.materialName = material.getLocalizedName(); + this.translatedMaterialName = material.getTranslatedName(); + this.componentType = componentType; + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(this.unlocalName); + this.setMaxStackSize(64); + // this.setTextureName(this.getCorrectTextures()); + this.componentColour = material.getRgbAsHex(); + GameRegistry.registerItem(this, this.unlocalName); + + // if (componentType != ComponentTypes.DUST) + + GT_OreDictUnificator.registerOre( + componentType.getOreDictName() + material.getUnlocalizedName(), + ItemUtils.getSimpleStack(this)); + if (componentType == ComponentTypes.GEAR) { + GT_OreDictUnificator.registerOre("gear" + material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); + } + registerComponent(); + + GT_LanguageManager.addStringLocalization("gtplusplus.item." + unlocalName + ".name", getFormattedLangName()); + } + + // For Cell Generation + public BaseItemComponent(final String unlocalName, final String localName, final short[] RGBA) { + + // Handles .'s from fluid internal names. + String aFormattedNameForFluids; + if (unlocalName.contains(".")) { + aFormattedNameForFluids = StringUtils.splitAndUppercase(unlocalName, "."); + } else { + aFormattedNameForFluids = unlocalName; + } + Material aTempMaterial = Material.mMaterialCache.get(localName.toLowerCase()); + Logger.INFO("Attempted to get " + localName + " cell material from cache. Valid? " + (aTempMaterial != null)); + this.componentMaterial = aTempMaterial; + this.unlocalName = "itemCell" + aFormattedNameForFluids; + this.materialName = localName; + this.translatedMaterialName = getFluidName( + "fluid." + this.materialName.toLowerCase() + .replace(" ", "")); + this.componentType = ComponentTypes.CELL; + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(aFormattedNameForFluids); + this.setMaxStackSize(64); + this.componentColour = MathUtils.getRgbAsHex(RGBA); + this.extraData = RGBA; + + this.setTextureName(GTPlusPlus.ID + ":" + "item" + ComponentTypes.CELL.COMPONENT_NAME); + GameRegistry.registerItem(this, aFormattedNameForFluids); + GT_OreDictUnificator.registerOre( + ComponentTypes.CELL.getOreDictName() + Utils.sanitizeStringKeepBrackets(localName), + ItemUtils.getSimpleStack(this)); + registerComponent(); + + GT_LanguageManager + .addStringLocalization("gtplusplus.item." + this.unlocalName + ".name", getFormattedLangName()); + } + + private String getFormattedLangName() { + return componentType.getName() + .replace("@", "%material"); + } + + public boolean registerComponent() { + if (this.componentMaterial == null) { + return false; + } + // Register Component + Map<String, ItemStack> aMap = Material.mComponentMap.get(componentMaterial.getUnlocalizedName()); + if (aMap == null) { + aMap = new HashMap<>(); + } + String aKey = componentType.getGtOrePrefix() + .name(); + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, ItemUtils.getSimpleStack(this)); + Logger.MATERIALS( + "Registering a material component. Item: [" + componentMaterial.getUnlocalizedName() + + "] Map: [" + + aKey + + "]"); + Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap); + if (componentType == ComponentTypes.PLATE) { + GregTech_API.registerCover( + componentMaterial.getPlate(1), + new GT_RenderedTexture( + componentMaterial.getTextureSet().mTextures[71], + componentMaterial.getRGBA(), + false), + null); + } else if (componentType == ComponentTypes.PLATEDOUBLE) { + GregTech_API.registerCover( + componentMaterial.getPlateDouble(1), + new GT_RenderedTexture( + componentMaterial.getTextureSet().mTextures[72], + componentMaterial.getRGBA(), + false), + null); + } + return true; + } else { + // Bad + Logger.MATERIALS("Tried to double register a material component. "); + return false; + } + } + + public String getCorrectTextures() { + if (!CORE.ConfigSwitches.useGregtechTextures) { + return GTPlusPlus.ID + ":" + "item" + this.componentType.COMPONENT_NAME; + } + String metType = "9j4852jyo3rjmh3owlhw9oe"; + if (this.componentMaterial != null) { + TextureSet u = this.componentMaterial.getTextureSet(); + if (u != null) { + metType = u.mSetName; + } + } + metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); + return GregTech.ID + ":" + "materialicons/" + metType + "/" + this.componentType.getOreDictName(); + + // return GregTech.ID + ":" + "materialicons/"+metType+"/" + this.componentType.COMPONENT_NAME.toLowerCase(); + } + + /* + * @Override public String getItemStackDisplayName(final ItemStack p_77653_1_) { if (this.componentType == + * ComponentTypes.SMALLGEAR){ return "Small " + this.materialName+" Gear"; } if (this.componentMaterial != null) { + * return (this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME); } return + * this.materialName+" Cell"; } + */ + + public final String getMaterialName() { + return this.materialName; + } + + public String getFluidName(String aKey) { + String trans; + trans = GT_LanguageManager.getTranslation(aKey); + if (!trans.equals(aKey)) return trans; + aKey = "fluid." + aKey; + trans = GT_LanguageManager.getTranslation(aKey); + if (!trans.equals(aKey)) return trans; + return GT_LanguageManager.addStringLocalization( + "gtplusplus.fluid." + this.materialName.toLowerCase() + .replace(" ", ""), + this.materialName); + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return GT_LanguageManager.getTranslation("gtplusplus.item." + unlocalName + ".name") + .replace("%s", "%temp") + .replace("%material", translatedMaterialName) + .replace("%temp", "%s"); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + 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.contains("?")) { + list.add(Utils.sanitizeStringKeepBrackets(this.componentMaterial.vChemicalFormula)); + } else if (this.componentMaterial.vChemicalFormula.contains("?")) { + 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.get()); + } + + if (this.componentType == ComponentTypes.INGOT || this.componentType == ComponentTypes.HOTINGOT) { + if ((this.materialName != null) && (this.materialName != "") + && !this.materialName.equals("") + && this.unlocalName.toLowerCase() + .contains("hot")) { + list.add( + EnumChatFormatting.GRAY + "Warning: " + + EnumChatFormatting.RED + + "Very hot! " + + EnumChatFormatting.GRAY + + " Avoid direct handling.."); + } + } + } else { + String aChemicalFormula = Material.sChemicalFormula.get(materialName.toLowerCase()); + if (aChemicalFormula != null && aChemicalFormula.length() > 0) { + list.add(Utils.sanitizeStringKeepBrackets(aChemicalFormula)); + } + } + + // Hidden Tooltip + if (KeyboardUtils.isCtrlKeyDown()) { + if (this.componentMaterial != null) { + String type = this.componentMaterial.getTextureSet().mSetName; + String output = type.substring(0, 1) + .toUpperCase() + type.substring(1); + list.add(EnumChatFormatting.GRAY + "Material Type: " + output + "."); + list.add( + EnumChatFormatting.GRAY + "Material State: " + + this.componentMaterial.getState() + .name() + + "."); + list.add( + EnumChatFormatting.GRAY + "Radioactivity Level: " + + this.componentMaterial.vRadiationLevel + + "."); + } + } else { + list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); + } + } + } catch (Throwable t) {} + + super.addInformation(stack, aPlayer, list, bool); + } + + @SuppressWarnings("unchecked") + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + if (this.componentMaterial != null) { + if (entityHolding instanceof EntityPlayer) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + EntityUtils.applyRadiationDamageToEntity( + iStack.stackSize, + this.componentMaterial.vRadiationLevel, + world, + entityHolding); + } + } + } + } + + /** + * + * Handle Custom Rendering + * + */ + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return (CORE.ConfigSwitches.useGregtechTextures ? true : false); + } + + @SuppressWarnings("unchecked") + @Override + public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + + if (this.componentType == ComponentTypes.CELL || this.componentType == ComponentTypes.PLASMACELL) { + if (renderPass == 0 && !CORE.ConfigSwitches.useGregtechTextures) { + return Utils.rgbtoHexValue(255, 255, 255); + } + if (renderPass == 1 && CORE.ConfigSwitches.useGregtechTextures) { + return Utils.rgbtoHexValue(255, 255, 255); + } + } + + try { + if (this.componentMaterial == null) { + if (extraData != null) { + if (short.class.isInstance(extraData)) { + short[] abc = (short[]) extraData; + return Utils.rgbtoHexValue(abc[0], abc[1], abc[2]); + } + } + return this.componentColour; + } + + if (this.componentMaterial.getRGBA()[3] <= 1) { + return this.componentColour; + } else { + // Mild Glow Effect + if (this.componentMaterial.getRGBA()[3] == 2) { + // 4 sec cycle, 200 control point. 20ms interval. + int currentFrame = (int) ((System.nanoTime() % 4_000_000_000L) / 20_000_000L); + int value = currentFrame < 50 ? currentFrame + 1 + : currentFrame < 100 ? 50 : currentFrame < 150 ? 149 - currentFrame : 0; + return Utils.rgbtoHexValue( + Math.min(255, Math.max(componentMaterial.getRGBA()[0] + value, 0)), + Math.min(255, Math.max(componentMaterial.getRGBA()[1] + value, 0)), + Math.min(255, Math.max(componentMaterial.getRGBA()[2] + value, 0))); + } + + // Rainbow Hue Cycle + else if (this.componentMaterial.getRGBA()[3] == 3) { + return Color.HSBtoRGB((float) (System.nanoTime() % 8_000_000_000L) / 8_000_000_000f, 1, 1); + } + } + + } catch (Throwable t) { + + } + return this.componentColour; + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (CORE.ConfigSwitches.useGregtechTextures) { + if (pass == 0) { + return this.base; + } + return this.overlay; + } + return this.base; + } + + @Override + public void registerIcons(final IIconRegister i) { + + if (CORE.ConfigSwitches.useGregtechTextures) { + this.base = i.registerIcon(getCorrectTextures()); + this.overlay = i.registerIcon(getCorrectTextures() + "_OVERLAY"); + } else { + this.base = i.registerIcon(getCorrectTextures()); + // this.overlay = i.registerIcon(getCorrectTextures() + "_OVERLAY"); + } + } + + public static enum ComponentTypes { + + DUST("Dust", "@ Dust", "dust", OrePrefixes.dust), + DUSTSMALL("DustSmall", "Small Pile of @ Dust", "dustSmall", OrePrefixes.dustSmall), + DUSTTINY("DustTiny", "Tiny Pile of @ Dust", "dustTiny", OrePrefixes.dustTiny), + INGOT("Ingot", "@ Ingot", "ingot", OrePrefixes.ingot), + HOTINGOT("HotIngot", "Hot @ Ingot", "ingotHot", OrePrefixes.ingotHot), + PLATE("Plate", "@ Plate", "plate", OrePrefixes.plate), + PLATEDOUBLE("PlateDouble", "Double @ Plate", "plateDouble", OrePrefixes.plateDouble), + ROD("Rod", "@ Rod", "stick", OrePrefixes.stick), + RODLONG("RodLong", "Long @ Rod", "stickLong", OrePrefixes.stickLong), + GEAR("Gear", "@ Gear", "gearGt", OrePrefixes.gearGt), + SMALLGEAR("SmallGear", "Small @ Gear", "gearGtSmall", OrePrefixes.gearGtSmall), // TODO + SCREW("Screw", "@ Screw", "screw", OrePrefixes.screw), + BOLT("Bolt", "@ Bolt", "bolt", OrePrefixes.bolt), + ROTOR("Rotor", "@ Rotor", "rotor", OrePrefixes.rotor), + RING("Ring", "@ Ring", "ring", OrePrefixes.ring), + FOIL("Foil", "@ Foil", "foil", OrePrefixes.foil), + PLASMACELL("CellPlasma", "@ Plasma Cell", "cellPlasma", OrePrefixes.cellPlasma), + CELL("Cell", "@ Cell", "cell", OrePrefixes.cell), + NUGGET("Nugget", "@ Nugget", "nugget", OrePrefixes.nugget), + SPRING("Spring", "@ Spring", "spring", OrePrefixes.spring), + SMALLSPRING("SmallSpring", "Small @ Spring", "springSmall", OrePrefixes.springSmall), + FINEWIRE("FineWire", "Fine @ Wire", "wireFine", OrePrefixes.wireFine), + PLATEDENSE("PlateDense", "Dense @ Plate", "plateDense", OrePrefixes.plateDense),; + + private final String COMPONENT_NAME; + private final String DISPLAY_NAME; + private final String OREDICT_NAME; + private final OrePrefixes a_GT_EQUAL; + + private ComponentTypes(final String LocalName, final String DisplayName, final String OreDictName, + final OrePrefixes aPrefix) { + this.COMPONENT_NAME = LocalName; + this.DISPLAY_NAME = DisplayName; + this.OREDICT_NAME = OreDictName; + this.a_GT_EQUAL = aPrefix; + } + + public String getComponent() { + return this.COMPONENT_NAME; + } + + public String getName() { + return this.DISPLAY_NAME; + } + + public String getOreDictName() { + return this.OREDICT_NAME; + } + + public OrePrefixes getGtOrePrefix() { + return this.a_GT_EQUAL; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemDamageable.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemDamageable.java new file mode 100644 index 0000000000..9a4109a1de --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemDamageable.java @@ -0,0 +1,194 @@ +package gtPlusPlus.core.item.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; + +public class BaseItemDamageable extends Item { + + private final EnumRarity rarity; + private final String itemDescription; + protected String itemName; + private final boolean hasEffect; + + public BaseItemDamageable(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, + final int maxDmg, final String description, final EnumRarity regRarity, final EnumChatFormatting colour, + final boolean Effect, final ItemStack OverrideItem) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(GTPlusPlus.ID + ":" + unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(1); + this.setMaxDamage(251); + this.setNoRepair(); + this.rarity = regRarity; + this.itemDescription = description; + this.hasEffect = Effect; + GameRegistry.registerItem(this, unlocalizedName); + } + + public String getItemDescription() { + return this.itemDescription; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + int dmg = (int) getItemDamage(stack); + if (dmg <= 3) { + list.add(EnumChatFormatting.GRAY + this.itemDescription); + } + if (dmg > 3 && dmg <= 25) { + list.add( + EnumChatFormatting.GRAY + + "You have discovered that smashing this against valuable stones has some function.."); + } else if (dmg > 0) { + int maxDamage = 250; + list.add( + EnumChatFormatting.GRAY + "" + + (maxDamage - getItemDamage(stack)) + + "/" + + maxDamage + + " gems remaining."); + } + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + int dmg = (int) getItemDamage(par1ItemStack); + if (dmg > 200) { + return EnumRarity.epic; + } + return this.rarity; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack, final int pass) { + int dmg = (int) getItemDamage(par1ItemStack); + if (dmg > 200) { + return true; + } + return this.hasEffect; + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if ((this.itemName == null) || this.itemName.equals("")) { + return super.getItemStackDisplayName(tItem); + } + return this.itemName; + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Value", 0); + tagMain.setTag("Damage", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getItemDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("Damage"); + if (aNBT != null) { + return aNBT.getLong("Value"); + } + } else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setItemDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("Damage"); + if (aNBT != null) { + aNBT.setLong("Value", aDamage); + return true; + } + } else { + createNBT(aStack); + } + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); + } + double currentDamage = getItemDamage(stack); + double durabilitypercent = currentDamage / 100; + double inverse = (100 - durabilitypercent); + return durabilitypercent; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + int dmg = (int) getItemDamage(stack); + if (dmg <= 20) { + return false; + } else { + return true; + } + } + + public static ItemStack damageItem(ItemStack item) { + if (item != null) { + long currentUse = BaseItemDamageable.getItemDamage(item); + if (currentUse >= 0 && currentUse <= 250) { + BaseItemDamageable.setItemDamage(item, currentUse + 1); + return item; + } else { + return item; + } + } + return null; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) { + Logger.INFO("Does Leave Table? " + stack.getDisplayName()); + return true; + } + + @Override + public boolean getShareTag() { + return true; + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + return true; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + ItemStack stack = itemStack.copy(); + // stack.setItemDamage(stack.getItemDamage() + 1); + damageItem(stack); + stack.stackSize = 1; + return stack; + } + + @Override + public int getDamage(ItemStack stack) { + return (int) getItemDamage(stack); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemTCShard.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemTCShard.java new file mode 100644 index 0000000000..3ecb6960d6 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemTCShard.java @@ -0,0 +1,69 @@ +package gtPlusPlus.core.item.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BaseItemTCShard extends Item { + + public final String unlocalName; + public final String displayName; + public final int itemColour; + + public BaseItemTCShard(final String DisplayName, final int colour) { + this(DisplayName, colour, null); + } + + public BaseItemTCShard(final String DisplayName, final int colour, final String[] Description) { + this.unlocalName = "item" + Utils.sanitizeString(DisplayName); + this.displayName = DisplayName; + this.itemColour = colour; + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(this.unlocalName); + if (Description != null) { + for (int i = 0; i < Description.length; i++) { + GT_LanguageManager + .addStringLocalization("gtplusplus." + getUnlocalizedName() + ".tooltip." + i, Description[i]); + } + } + this.setMaxStackSize(64); + this.setTextureName(GTPlusPlus.ID + ":" + "itemShard"); + GameRegistry.registerItem(this, this.unlocalName); + GT_OreDictUnificator.registerOre("shard" + DisplayName, ItemUtils.getSimpleStack(this)); + GT_OreDictUnificator.registerOre("gemInfused" + DisplayName, ItemUtils.getSimpleStack(this)); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + for (int i = 0;; i++) { + String tooltip = GT_LanguageManager + .getTranslation("gtplusplus." + this.getUnlocalizedName() + ".tooltip" + "." + i); + if (!("gtplusplus." + this.getUnlocalizedName() + ".tooltip" + "." + i).equals(tooltip)) { + list.add(tooltip); + } else break; + } + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return this.itemColour; + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) {} +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemTickable.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemTickable.java new file mode 100644 index 0000000000..8417eba3d1 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemTickable.java @@ -0,0 +1,332 @@ +package gtPlusPlus.core.item.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; + +public class BaseItemTickable extends CoreItem { + + public final String[] descriptionString; + public final int itemColour; + public final int maxTicks; + public final boolean twoRenderPasses; + public final boolean ticksInContainers; + + public IIcon[] mIcon = new IIcon[2]; + + public BaseItemTickable(boolean twoPass, final String unlocalName, final int colour, final int maxTicks) { + this(false, twoPass, unlocalName, colour, maxTicks, new String[] {}); + } + + public BaseItemTickable(boolean containerTick, boolean twoPass, final String unlocalName, final int colour, + final int maxTicks) { + this(containerTick, twoPass, unlocalName, colour, maxTicks, new String[] {}); + } + + public BaseItemTickable(boolean containerTick, boolean twoPass, final String unlocalName, final int colour, + final int maxTicks, final String[] Description) { + super( + unlocalName, + AddToCreativeTab.tabMisc, + 1, + 999999999, + Description, + EnumRarity.epic, + EnumChatFormatting.DARK_RED, + true, + null); + this.itemColour = colour; + this.descriptionString = Description; + this.maxTicks = maxTicks; + this.twoRenderPasses = twoPass; + this.ticksInContainers = containerTick; + this.maxStackSize = 1; + // setGregtechItemList(); + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + if (world == null || iStack == null) { + return; + } + if (world.isRemote) { + return; + } + + boolean active = isTicking(world, iStack); + if (active) { + tickItemTag(world, iStack); + } + } + + /* + * private final boolean setGregtechItemList() { ItemList.Component_LavaFilter.set(this); return + * ItemList.Component_LavaFilter.get(1) != null ? true : false; } + */ + + /** + * + * Handle Custom Rendering + * + */ + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return this.twoRenderPasses; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + if (renderPass == 1 && this.twoRenderPasses) { + return Utils.rgbtoHexValue(255, 255, 255); + } + return this.itemColour; + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (this.twoRenderPasses) { + if (pass == 0) { + return this.mIcon[0]; + } + return this.mIcon[1]; + } + return this.mIcon[0]; + } + + @Override + public void registerIcons(final IIconRegister i) { + + if (this.twoRenderPasses) { + this.mIcon[0] = i.registerIcon(GTPlusPlus.ID + ":" + this.getUnlocalizedName()); + this.mIcon[1] = i.registerIcon(GTPlusPlus.ID + ":" + this.getUnlocalizedName() + "_OVERLAY"); + } else { + this.mIcon[0] = i.registerIcon(GTPlusPlus.ID + ":" + this.getUnlocalizedName()); + // this.overlay = i.registerIcon(getCorrectTextures() + "_OVERLAY"); + } + } + + protected int getMaxTicks(ItemStack aStack) { + return maxTicks; + } + + protected boolean createNBT(World world, ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Tick", 0); + tagNBT.setLong("maxTick", getMaxTicks(rStack)); + tagNBT.setBoolean("isActive", true); + + // Try set world time + if (world != null) { + // tagNBT.setLong("CreationDate", world.getTotalWorldTime()); + } + + tagMain.setTag("TickableItem", tagNBT); + rStack.setTagCompound(tagMain); + Logger.INFO("Created Tickable NBT data."); + return true; + } + + public final long getTicks(World world, final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + return aNBT.getLong("Tick"); + } + } else { + createNBT(world, aStack); + } + return 0L; + } + + public final boolean setTicks(World world, final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + aNBT.setLong("Tick", aDamage); + return true; + } + } else { + createNBT(world, aStack); + } + return false; + } + + public final boolean isTicking(World world, final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + return aNBT.getBoolean("isActive"); + } + } else { + return createNBT(world, aStack); + } + return true; + } + + public final boolean setTicking(World world, final ItemStack aStack, final boolean active) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + aNBT.setBoolean("isActive", active); + return true; + } + } else { + createNBT(world, aStack); + } + return false; + } + + public final boolean getTicksInContainer(World world, final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + return aNBT.getBoolean("ticksInContainer"); + } + } else { + createNBT(world, aStack); + } + return false; + } + + public final boolean setTicksInContainer(World world, final ItemStack aStack, final boolean active) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + aNBT.setBoolean("ticksInContainer", active); + return true; + } + } else { + createNBT(world, aStack); + } + return false; + } + + public final long getDifferenceInWorldTimeToCreationTime(World world, final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + return (world.getTotalWorldTime() - aNBT.getLong("CreationDate")); + } + } else { + createNBT(world, aStack); + } + return 0L; + } + + public final boolean setItemStackCreationTime(final ItemStack aStack, World world) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + aNBT.setLong("CreationDate", world.getTotalWorldTime()); + return true; + } + } else { + createNBT(world, aStack); + } + return false; + } + + public final boolean tickItemTag(World world, ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + if (aNBT.hasKey("TickableItem")) { + aNBT = aNBT.getCompoundTag("TickableItem"); + // Done Ticking + if (getMaxTicks(aStack) - getTicks(world, aStack) <= 0) { + setTicking(world, aStack, false); + return false; + } + if (isTicking(world, aStack)) { + if (aNBT != null) { + aNBT.setLong("Tick", getTicks(world, aStack) + 1); + return true; + } else { + return false; + } + } else { + return false; + } + } + } + return createNBT(world, aStack); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + // createNBT(null, stack); + return 0; + } + double currentDamage = getTicks(null, stack); + double durabilitypercent = currentDamage / getMaxTicks(stack); + return durabilitypercent; + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack stack, EntityPlayer player, @SuppressWarnings("rawtypes") List list, + boolean bool) { + World world = player.getEntityWorld(); + if (this.descriptionString.length > 0) { + list.add(EnumChatFormatting.GRAY + this.descriptionString[0]); + } + long maxTicks = getMaxTicks(stack); + long ticks = 0; + if (stack.hasTagCompound()) { + ticks = getTicks(world, stack); + } + EnumChatFormatting durability = EnumChatFormatting.GRAY; + if (maxTicks - ticks > (maxTicks * 0.8)) { + durability = EnumChatFormatting.GRAY; + } else if (maxTicks - ticks > (maxTicks * 0.6)) { + durability = EnumChatFormatting.GREEN; + } else if (maxTicks - ticks > (maxTicks * 0.4)) { + durability = EnumChatFormatting.YELLOW; + } else if (maxTicks - ticks > (maxTicks * 0.2)) { + durability = EnumChatFormatting.GOLD; + } else if (maxTicks - ticks > 0) { + durability = EnumChatFormatting.RED; + } + list.add(durability + "" + ((maxTicks - ticks) / 20) + EnumChatFormatting.GRAY + " seconds until decay"); + + if (this.descriptionString.length > 1) { + for (int h = 1; h < this.descriptionString.length; h++) { + list.add(EnumChatFormatting.GRAY + this.descriptionString[h]); + } + } + + // super.addInformation(stack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java new file mode 100644 index 0000000000..0e1b0ab0f2 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java @@ -0,0 +1,30 @@ +package gtPlusPlus.core.item.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class BaseItemWithDamageValue extends Item { + + public BaseItemWithDamageValue(final String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(GTPlusPlus.ID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(100); + } + + @Override + public void setDamage(final ItemStack stack, final int damage) { + super.setDamage(stack, damage); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + super.addInformation(stack, aPlayer, list, bool); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BasicSpawnEgg.java b/src/main/java/gtPlusPlus/core/item/base/BasicSpawnEgg.java new file mode 100644 index 0000000000..b564d60424 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/BasicSpawnEgg.java @@ -0,0 +1,238 @@ +package gtPlusPlus.core.item.base; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; + +public class BasicSpawnEgg extends ItemMonsterPlacer { + + @SideOnly(Side.CLIENT) + private IIcon theIcon; + + protected int colorBase = 0x000000; + protected int colorSpots = 0xFFFFFF; + protected String entityMODID = ""; + protected String entityToSpawnName = ""; + protected String entityToSpawnNameFull = ""; + protected EntityLiving entityToSpawn = null; + + public BasicSpawnEgg() { + super(); + } + + public BasicSpawnEgg(final String MODID, final String parEntityToSpawnName, final int parPrimaryColor, + final int parSecondaryColor) { + this.setHasSubtypes(false); + this.maxStackSize = 64; + this.setCreativeTab(AddToCreativeTab.tabOther); + this.setEntityToSpawnName(parEntityToSpawnName); + this.colorBase = parPrimaryColor; + this.colorSpots = parSecondaryColor; + this.entityMODID = MODID; + + // DEBUG + Logger.WARNING("Spawn egg constructor for " + this.entityToSpawnName); + } + + /** + * Callback for item usage. If the item does something special on right clicking, + * + * he will have one of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS + */ + @Override + public boolean onItemUse(final ItemStack par1ItemStack, final EntityPlayer par2EntityPlayer, final World par3World, + int par4, int par5, int par6, final int par7, final float par8, final float par9, final float par10) { + if (par3World.isRemote) { + return true; + } + final Block block = par3World.getBlock(par4, par5, par6); + par4 += Facing.offsetsXForSide[par7]; + par5 += Facing.offsetsYForSide[par7]; + par6 += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if ((par7 == 1) && (block.getRenderType() == 11)) { + d0 = 0.5D; + } + + final Entity entity = this.spawnEntity(par3World, par4 + 0.5D, par5 + d0, par6 + 0.5D); + + if (entity != null) { + if ((entity instanceof EntityLivingBase) && par1ItemStack.hasDisplayName()) { + ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par2EntityPlayer.capabilities.isCreativeMode) { + --par1ItemStack.stackSize; + } + } + + return true; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. + * + * Args: itemStack, world, entityPlayer + */ + @Override + public ItemStack onItemRightClick(final ItemStack par1ItemStack, final World par2World, + final EntityPlayer par3EntityPlayer) { + if (par2World.isRemote) { + return par1ItemStack; + } + final MovingObjectPosition movingobjectposition = this + .getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) { + return par1ItemStack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + + final int i = movingobjectposition.blockX; + final int j = movingobjectposition.blockY; + final int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) { + return par1ItemStack; + } + + if (par2World.getBlock(i, j, k) instanceof BlockLiquid) { + final Entity entity = this.spawnEntity(par2World, i, j, k); + + if (entity != null) { + if ((entity instanceof EntityLivingBase) && par1ItemStack.hasDisplayName()) { + ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par3EntityPlayer.capabilities.isCreativeMode) { + --par1ItemStack.stackSize; + } + } + } + } + + return par1ItemStack; + } + + /** + * Spawns the creature specified by the egg's type in the location specified by + * + * the last three parameters. Parameters: world, entityID, x, y, z. + */ + public Entity spawnEntity(final World parWorld, final double parX, final double parY, final double parZ) { + + if (!parWorld.isRemote) // never spawn entity on client side + { + this.entityToSpawnNameFull = this.entityMODID + "." + this.entityToSpawnName; + if (EntityList.stringToClassMapping.containsKey(this.entityToSpawnNameFull)) { + this.entityToSpawn = (EntityLiving) EntityList.createEntityByName(this.entityToSpawnNameFull, parWorld); + + this.entityToSpawn.setLocationAndAngles( + parX, + parY, + parZ, + MathHelper.wrapAngleTo180_float(parWorld.rand.nextFloat() * 360.0F), + 0.0F); + + parWorld.spawnEntityInWorld(this.entityToSpawn); + this.entityToSpawn.onSpawnWithEgg((IEntityLivingData) null); + this.entityToSpawn.playLivingSound(); + } else { + // DEBUG + Logger.WARNING("Entity not found " + this.entityToSpawnName); + } + } + + return this.entityToSpawn; + } + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(final Item parItem, final CreativeTabs parTab, final List parList) { + parList.add(new ItemStack(parItem, 1, 0)); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(final ItemStack par1ItemStack, final int parColorType) { + return (parColorType == 0) ? this.colorBase : this.colorSpots; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + // Doing this override means that there is no localization for language + // unless you specifically check for localization here and convert + public String getItemStackDisplayName(final ItemStack par1ItemStack) { + return "Spawn " + this.entityToSpawnName; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + this.theIcon = par1IconRegister.registerIcon(this.getIconString() + "_overlay"); + } + + /** + * Gets an icon index based on an item's damage value and the given render pass + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(final int parDamageVal, final int parRenderPass) { + return parRenderPass > 0 ? this.theIcon : super.getIconFromDamageForRenderPass(parDamageVal, parRenderPass); + } + + public void setColors(final int parColorBase, final int parColorSpots) { + this.colorBase = parColorBase; + this.colorSpots = parColorSpots; + } + + public int getColorBase() { + return this.colorBase; + } + + public int getColorSpots() { + return this.colorSpots; + } + + public final void setEntityToSpawnName(final String parEntityToSpawnName) { + this.entityToSpawnName = parEntityToSpawnName; + this.entityToSpawnNameFull = this.entityMODID + "." + this.entityToSpawnName; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/CoreItem.java b/src/main/java/gtPlusPlus/core/item/base/CoreItem.java new file mode 100644 index 0000000000..4745fda281 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/CoreItem.java @@ -0,0 +1,286 @@ +package gtPlusPlus.core.item.base; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +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.EnumChatFormatting; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class CoreItem extends Item { + + private final EnumRarity rarity; + private final EnumChatFormatting descColour; + protected String itemName; + private final boolean hasEffect; + + // Replace Item - What does this item turn into when held. + private final ItemStack turnsInto; + + // 0 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab) { + this(unlocalizedName, creativeTab, 64, 0); // Calls 3 + } + + // 0 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(final String unlocalizedName, final String displayName, final CreativeTabs creativeTab) { + this(unlocalizedName, creativeTab, 64, 0); // Calls 3 + this.itemName = displayName; + } + + // 0.1 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final ItemStack OverrideItem) { + this( + unlocalizedName, + creativeTab, + 64, + 0, + new String[] { + "This item will be replaced by another when held by a player, it is old and should not be used in recipes." }, + EnumRarity.uncommon, + EnumChatFormatting.UNDERLINE, + false, + OverrideItem); // Calls 5 + } + + // 0.1 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(final String unlocalizedName, final String displayName, final CreativeTabs creativeTab, + final ItemStack OverrideItem) { + this( + unlocalizedName, + creativeTab, + 64, + 0, + new String[] { + "This item will be replaced by another when held by a player, it is old and should not be used in recipes." }, + EnumRarity.uncommon, + EnumChatFormatting.UNDERLINE, + false, + OverrideItem); // Calls 5 + this.itemName = displayName; + } + + // 1 + /* + * Name, Tab, Stack - 0 Dmg + */ + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize) { + this(unlocalizedName, creativeTab, stackSize, 0); // Calls 3 + } + + // 2 + /* + * Name, Tab, Stack, Description - 0 Dmg + */ + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, + final String[] description) { + this(unlocalizedName, creativeTab, stackSize, 0, description); // Calls 4 + } + + // 3 + /* + * Name, Tab, Stack, Dmg - Description + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, String string) { + this(unlocalizedName, creativeTab, stackSize, new String[] { string }); + } + + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, + final int maxDmg) { + this(unlocalizedName, creativeTab, stackSize, maxDmg, new String[] {}); // Calls 4 + } + + // 4 //Not Rare + basic tooltip + /* + * Name, Tab, Stack, Dmg, Description + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String string) { + this(unlocalizedName, creativeTab, stackSize, maxDmg, new String[] { string }); + } + + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, + final String[] description) { + this( + unlocalizedName, + creativeTab, + stackSize, + maxDmg, + description, + EnumRarity.common, + EnumChatFormatting.GRAY, + false, + null); // Calls 4.5 + } + + // 4.5 + /* + * Name, Tab, Stack, Dmg, Description, Text Colour - Common + */ + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, + final String[] description, final EnumChatFormatting colour) { + this(unlocalizedName, creativeTab, stackSize, maxDmg, description, EnumRarity.common, colour, false, null); // Calls + // 5 + } + + // 4.75 + /* + * Name, Tab, Stack, Dmg, Description, Rarity - Gray text + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String string, + EnumRarity uncommon) { + this(unlocalizedName, creativeTab, stackSize, maxDmg, new String[] { string }, uncommon); + } + + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, + final String[] description, final EnumRarity rarity) { + this( + unlocalizedName, + creativeTab, + stackSize, + maxDmg, + description, + rarity, + EnumChatFormatting.GRAY, + false, + null); // Calls 5 + } + + // 5 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, + final String[] description, final EnumRarity regRarity, final EnumChatFormatting colour, final boolean Effect, + final ItemStack OverrideItem) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(GTPlusPlus.ID + ":" + unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(stackSize); + this.setMaxDamage(maxDmg); + this.rarity = regRarity; + this.setItemDescription(description); + this.descColour = colour != null ? colour : EnumChatFormatting.RESET; + this.hasEffect = Effect; + this.turnsInto = OverrideItem; + GameRegistry.registerItem(this, unlocalizedName); + } + + // 6 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public CoreItem(final String unlocalizedName, final String displayName, final CreativeTabs creativeTab, + final int stackSize, final int maxDmg, final String[] description, final EnumRarity regRarity, + final EnumChatFormatting colour, final boolean Effect, final ItemStack OverrideItem) { + this.setUnlocalizedName(unlocalizedName); + this.itemName = displayName; + this.setTextureName(GTPlusPlus.ID + ":" + unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(stackSize); + this.setMaxDamage(maxDmg); + this.rarity = regRarity; + this.setItemDescription(description); + this.descColour = colour != null ? colour : EnumChatFormatting.RESET; + this.hasEffect = Effect; + this.turnsInto = OverrideItem; + GameRegistry.registerItem(this, unlocalizedName); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + for (int i = 0;; i++) { + String tooltip = GT_LanguageManager + .getTranslation("gtplusplus." + this.getUnlocalizedName() + ".tooltip" + "." + i); + if (!("gtplusplus." + this.getUnlocalizedName() + ".tooltip" + "." + i).equals(tooltip)) { + list.add(tooltip); + } else break; + } + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return this.rarity; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack, final int pass) { + return this.hasEffect; + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + if (this.turnsInto != null) { + if (entityHolding instanceof EntityPlayer) { + + Logger.INFO("Replacing " + iStack.getDisplayName() + " with " + this.turnsInto.getDisplayName() + "."); + final ItemStack tempTransform = this.turnsInto; + if (iStack.stackSize == 64) { + tempTransform.stackSize = 64; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + for (int l = 0; l < 64; l++) { + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + + } else { + tempTransform.stackSize = 1; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + } + } + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean isRepairable() { + return false; + } + + public ItemStack getStack() { + return ItemUtils.getSimpleStack(this); + } + + public void setItemDescription(String[] description) { + for (int i = 0; i < description.length; i++) { + GT_LanguageManager.addStringLocalization( + "gtplusplus." + this.getUnlocalizedName() + ".tooltip" + "." + i, + description[i]); + } + } + /* + * @Override public String getItemStackDisplayName(final ItemStack tItem) { if ((this.itemName == null) || + * this.itemName.equals("")) { return super.getItemStackDisplayName(tItem); } return this.itemName; } + */ +} diff --git a/src/main/java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java b/src/main/java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java new file mode 100644 index 0000000000..74ff99a7fe --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.bolts; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemBolt extends BaseItemComponent { + + public BaseItemBolt(final Material material) { + super(material, BaseItemComponent.ComponentTypes.BOLT); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/cell/BaseItemCell.java b/src/main/java/gtPlusPlus/core/item/base/cell/BaseItemCell.java new file mode 100644 index 0000000000..1140390375 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/cell/BaseItemCell.java @@ -0,0 +1,73 @@ +package gtPlusPlus.core.item.base.cell; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GregTech; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import ic2.core.Ic2Items; + +public class BaseItemCell extends BaseItemComponent { + + ComponentTypes Cell = ComponentTypes.CELL; + + public BaseItemCell(final Material material) { + super(material, BaseItemComponent.ComponentTypes.CELL); + this.fluidColour = (short[]) material.getRGBA(); + } + + public BaseItemCell(final String unlocalName, final String localName, final short[] RGBa) { + super(unlocalName, localName, RGBa); + this.fluidColour = RGBa; + FluidStack aFluid = FluidUtils.getFluidStack(unlocalName.toLowerCase(), 1000); + if (aFluid != null) { + FluidContainerRegistry.registerFluidContainer(aFluid, ItemUtils.getSimpleStack(this), Ic2Items.cell.copy()); + } + } + + public BaseItemCell(final String unlocalName, final String localName, final short[] RGBa, final Fluid cellFluid) { + super(unlocalName, localName, RGBa); + this.fluidColour = RGBa; + FluidContainerRegistry.registerFluidContainer( + FluidUtils.getFluidStack(cellFluid, 1000), + ItemUtils.getSimpleStack(this), + Ic2Items.cell.copy()); + } + + @Override + public void registerIcons(final IIconRegister i) { + + if (CORE.ConfigSwitches.useGregtechTextures) { + this.base = i.registerIcon(GregTech.ID + ":" + "materialicons/METALLIC/" + "cell"); + this.overlay = i.registerIcon(GregTech.ID + ":" + "materialicons/METALLIC/" + "cell_OVERLAY"); + } else { + this.base = i.registerIcon(GTPlusPlus.ID + ":" + "item" + this.Cell.getComponent()); + this.overlay = i.registerIcon(GTPlusPlus.ID + ":" + "item" + this.Cell.getComponent() + "_Overlay"); + } + // this.overlay = cellMaterial.getFluid(1000).getFluid().get + } + + private final short[] fluidColour; + boolean upwards = true; + + @Override + public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + if (renderPass == 0 && !CORE.ConfigSwitches.useGregtechTextures) { + return Utils.rgbtoHexValue(230, 230, 230); + } + if (renderPass == 1 && CORE.ConfigSwitches.useGregtechTextures) { + return Utils.rgbtoHexValue(230, 230, 230); + } + return this.componentColour; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/cell/BaseItemPlasmaCell.java b/src/main/java/gtPlusPlus/core/item/base/cell/BaseItemPlasmaCell.java new file mode 100644 index 0000000000..151f3f3860 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/cell/BaseItemPlasmaCell.java @@ -0,0 +1,76 @@ +package gtPlusPlus.core.item.base.cell; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; + +public class BaseItemPlasmaCell extends BaseItemComponent { + + private IIcon base; + private IIcon overlay; + ComponentTypes PlasmaCell = ComponentTypes.PLASMACELL; + private int tickCounter = 0; + private final int tickCounterMax = 200; + private final short[] fluidColour; + + public BaseItemPlasmaCell(final Material material) { + super(material, ComponentTypes.PLASMACELL); + this.fluidColour = (short[]) material.getRGBA(); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public void registerIcons(final IIconRegister i) { + this.base = i.registerIcon(GTPlusPlus.ID + ":" + "item" + this.PlasmaCell.getComponent()); + this.overlay = i.registerIcon(GTPlusPlus.ID + ":" + "item" + this.PlasmaCell.getComponent() + "_Overlay"); + // this.overlay = cellMaterial.getFluid(1000).getFluid().get + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + if (renderPass == 0) { + return Utils.rgbtoHexValue(230, 230, 230); + } + return this.componentColour; + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (pass == 0) { + return this.base; + } + return this.overlay; + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + if (this.componentMaterial != null) { + if (!world.isRemote) { + if (this.tickCounter < this.tickCounterMax) { + this.tickCounter++; + } else if (this.tickCounter >= this.tickCounterMax) { + entityHolding.attackEntityFrom(DamageSource.onFire, 2); + this.tickCounter = 0; + } + } + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java new file mode 100644 index 0000000000..fd52fe78c4 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -0,0 +1,135 @@ +package gtPlusPlus.core.item.base.dusts; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemDust extends BaseItemComponent { + + private BaseItemComponent[] mSizedDusts = new BaseItemComponent[2]; + + public BaseItemDust(Material aMat) { + this(aMat, true); + } + + public BaseItemDust(Material aMat, boolean generateSmallDusts) { + super(aMat, ComponentTypes.DUST); + if (generateSmallDusts) { + mSizedDusts[0] = new BaseItemComponent(aMat, ComponentTypes.DUSTSMALL); + mSizedDusts[1] = new BaseItemComponent(aMat, ComponentTypes.DUSTTINY); + } + } + + public BaseItemDust(DustState aState, Material aMat) { + super(aMat, ComponentTypes.DUST); + if (aState.generatesSmallDust()) { + mSizedDusts[0] = new BaseItemComponent(aMat, ComponentTypes.DUSTSMALL); + } + if (aState.generatesTinyDust()) { + mSizedDusts[1] = new BaseItemComponent(aMat, ComponentTypes.DUSTTINY); + } + } + + private BaseItemDust(String unlocalizedName, String materialName, Material matInfo, int colour, String pileSize, + int tier, boolean addRecipes) { + super(matInfo, ComponentTypes.DUST); + } + + public static class DustState { + + static final int NORMAL = (1); + static final int SMALL = (10); + static final int TINY = (100); + final int MIXTURE; + final boolean[] doesThings = new boolean[3]; + + public DustState(boolean genDust, boolean genSmallDust, boolean genDustTiny) { + int aTotal = 0; + if (genDust) { + aTotal += NORMAL; + doesThings[0] = true; + } else { + doesThings[0] = false; + } + if (genSmallDust) { + aTotal += SMALL; + doesThings[1] = true; + } else { + doesThings[1] = false; + } + if (genDustTiny) { + aTotal += TINY; + doesThings[2] = true; + } else { + doesThings[2] = false; + } + MIXTURE = aTotal; + } + + public boolean generatesDust() { + return doesThings[0]; + } + + public boolean generatesSmallDust() { + return doesThings[1]; + } + + public boolean generatesTinyDust() { + return doesThings[2]; + } + + private DustState(int amount) { + + if (amount == 1) { + doesThings[0] = true; + doesThings[1] = false; + doesThings[2] = false; + + } else if (amount == 10) { + doesThings[0] = false; + doesThings[1] = true; + doesThings[2] = false; + } else if (amount == 100) { + doesThings[0] = false; + doesThings[1] = false; + doesThings[2] = true; + + } else if (amount == 11) { + doesThings[0] = true; + doesThings[1] = true; + doesThings[2] = false; + + } else if (amount == 101) { + doesThings[0] = true; + doesThings[1] = false; + doesThings[2] = true; + + } else if (amount == 110) { + doesThings[0] = false; + doesThings[1] = true; + doesThings[2] = true; + + } else if (amount == 111) { + doesThings[0] = true; + doesThings[1] = true; + doesThings[2] = true; + } else { + doesThings[0] = false; + doesThings[1] = false; + doesThings[2] = false; + } + MIXTURE = amount; + } + + public DustState get(int a) { + if (a == 1) { + return new DustState(NORMAL); + } else if (a == 10) { + return new DustState(SMALL); + } else if (a == 100) { + return new DustState(TINY); + } else { + return new DustState(MIXTURE); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java new file mode 100644 index 0000000000..2592fe3cf7 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java @@ -0,0 +1,164 @@ +package gtPlusPlus.core.item.base.dusts; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GregTech; +import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BaseItemDustUnique extends Item { + + protected final int colour; + protected final int sRadiation; + protected final String materialName; + protected final String chemicalNotation; + + public BaseItemDustUnique(final String unlocalizedName, final String materialName, final int colour, + final String pileSize) { + this(unlocalizedName, materialName, "NullFormula", colour, pileSize); + } + + public BaseItemDustUnique(final String unlocalizedName, final String materialName, final String mChemicalFormula, + final int colour, final String pileSize) { + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(64); + this.setTextureName(this.getCorrectTexture(pileSize)); + this.setCreativeTab(tabMisc); + this.colour = colour; + this.materialName = materialName; + if (mChemicalFormula == null || mChemicalFormula.equals("") || mChemicalFormula.equals("NullFormula")) { + this.chemicalNotation = StringUtils.subscript(materialName); + } else { + this.chemicalNotation = StringUtils.subscript(mChemicalFormula); + } + this.sRadiation = ItemUtils.getRadioactivityLevel(materialName); + GameRegistry.registerItem(this, unlocalizedName); + + String type; + if (this.getUnlocalizedName() + .contains("DustTiny")) { + type = "Tiny Pile of %material Dust"; + } else if (this.getUnlocalizedName() + .contains("DustSmall")) { + type = "Small Pile of %material Dust"; + } else { + type = "%material Dust"; + } + GT_LanguageManager.addStringLocalization("gtplusplus." + this.getUnlocalizedName() + ".name", type); + + 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)); + } + registerComponent(); + } + + public boolean registerComponent() { + if (this.materialName == null) { + return false; + } + String aName = materialName; + // Register Component + Map<String, ItemStack> aMap = Material.mComponentMap.get(aName); + if (aMap == null) { + aMap = new HashMap<>(); + } + String aKey = OrePrefixes.dust.name(); + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, ItemUtils.getSimpleStack(this)); + Logger.MATERIALS("Registering a material component. Item: [" + aName + "] Map: [" + aKey + "]"); + Material.mComponentMap.put(aName, aMap); + return true; + } else { + // Bad + Logger.MATERIALS("Tried to double register a material component. "); + return false; + } + } + + @Override + public String getItemStackDisplayName(final ItemStack iStack) { + return GT_LanguageManager.getTranslation("gtplusplus." + getUnlocalizedName() + ".name") + .replace("%material", GT_LanguageManager.getTranslation("gtplusplus.material." + materialName)); + } + + private String getCorrectTexture(final String pileSize) { + if (!CORE.ConfigSwitches.useGregtechTextures) { + if ((pileSize.equals("dust")) || (pileSize.equals("Dust"))) { + this.setTextureName(GTPlusPlus.ID + ":" + "dust"); + } else { + this.setTextureName(GTPlusPlus.ID + ":" + "dust" + pileSize); + } + } + if (pileSize.toLowerCase() + .contains("small")) { + return GregTech.ID + ":" + "materialicons/SHINY/dustSmall"; + } else if (pileSize.toLowerCase() + .contains("tiny")) { + return GregTech.ID + ":" + "materialicons/SHINY/dustTiny"; + } + return GregTech.ID + ":" + "materialicons/SHINY/dust"; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (this.sRadiation > 0) { + list.add(CORE.GT_Tooltip_Radioactive.get()); + } + if (this.chemicalNotation.length() > 0 && !chemicalNotation.equals("") + && !chemicalNotation.equals("NullFormula")) { + list.add(this.chemicalNotation); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return StringUtils.subscript(this.materialName); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + return this.colour; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/foil/BaseItemFoil.java b/src/main/java/gtPlusPlus/core/item/base/foil/BaseItemFoil.java new file mode 100644 index 0000000000..9b55461cfd --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/foil/BaseItemFoil.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.foil; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemFoil extends BaseItemComponent { + + public BaseItemFoil(final Material material) { + super(material, BaseItemComponent.ComponentTypes.FOIL); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemGear.java b/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemGear.java new file mode 100644 index 0000000000..d759c7f116 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemGear.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.gears; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemGear extends BaseItemComponent { + + public BaseItemGear(final Material material) { + super(material, BaseItemComponent.ComponentTypes.GEAR); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemSmallGear.java b/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemSmallGear.java new file mode 100644 index 0000000000..ddfdbd7534 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemSmallGear.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.gears; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemSmallGear extends BaseItemComponent { + + public BaseItemSmallGear(final Material material) { + super(material, BaseItemComponent.ComponentTypes.SMALLGEAR); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java new file mode 100644 index 0000000000..fc2748ec23 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java @@ -0,0 +1,20 @@ +package gtPlusPlus.core.item.base.ingots; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemIngot extends BaseItemComponent { + + protected final String materialName; + protected final String unlocalName; + + public BaseItemIngot(final Material material) { + this(material, ComponentTypes.INGOT); + } + + public BaseItemIngot(final Material material, final ComponentTypes type) { + super(material, type); + this.materialName = material.getLocalizedName(); + this.unlocalName = material.getUnlocalizedName(); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java new file mode 100644 index 0000000000..9d22c0faf8 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java @@ -0,0 +1,111 @@ +package gtPlusPlus.core.item.base.ingots; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GregTech; +import static gregtech.api.recipe.RecipeMaps.vacuumFreezerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +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.item.base.BaseItemComponent; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BaseItemIngotHot extends BaseItemIngot { + + private final ItemStack outputIngot; + private int tickCounter = 0; + private final int tickCounterMax = 200; + private final int mTier; + + private IIcon base; + private IIcon overlay; + + public BaseItemIngotHot(final Material material) { + super(material, ComponentTypes.HOTINGOT); + this.setTextureName(GTPlusPlus.ID + ":" + "itemIngotHot"); + this.outputIngot = material.getIngot(1); + this.mTier = material.vTier; + this.generateRecipe(); + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return super.getItemStackDisplayName(p_77653_1_); + // return ("Hot "+this.materialName+ " Ingot"); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return Utils.rgbtoHexValue(225, 225, 225); + } + + private void generateRecipe() { + Logger.WARNING("Adding Vacuum Freezer recipe for a Hot Ingot of " + this.materialName + "."); + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(this)) + .itemOutputs(this.outputIngot.copy()) + .duration(Math.max(this.componentMaterial.getMass() * 3L, 1L) * TICKS) + .eut(this.componentMaterial.vVoltageMultiplier) + .addTo(vacuumFreezerRecipes); + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + if (this.componentMaterial != null) { + if (entityHolding != null && entityHolding instanceof EntityPlayer) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + EntityUtils.applyHeatDamageToEntity(1, world, entityHolding); + } + } + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + if (CORE.ConfigSwitches.useGregtechTextures) { + return true; + } else { + return false; + } + } + + @Override + public void registerIcons(final IIconRegister i) { + + if (CORE.ConfigSwitches.useGregtechTextures) { + this.base = i.registerIcon(GregTech.ID + ":" + "materialicons/METALLIC/" + "ingotHot"); + this.overlay = i.registerIcon(GregTech.ID + ":" + "materialicons/METALLIC/" + "ingotHot_OVERLAY"); + } else { + this.base = i + .registerIcon(GTPlusPlus.ID + ":" + "item" + BaseItemComponent.ComponentTypes.HOTINGOT.getComponent()); + } + // this.overlay = cellMaterial.getFluid(1000).getFluid().get + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (pass == 0 && CORE.ConfigSwitches.useGregtechTextures) { + return this.base; + } else if (pass == 1 && CORE.ConfigSwitches.useGregtechTextures) { + return this.overlay; + } else { + return this.overlay; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot_OLD.java b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot_OLD.java new file mode 100644 index 0000000000..6335820c9a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot_OLD.java @@ -0,0 +1,106 @@ +package gtPlusPlus.core.item.base.ingots; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.recipe.RecipeMaps.compressorRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BaseItemIngot_OLD extends Item { + + protected int colour; + protected String materialName; + protected String unlocalName; + + public BaseItemIngot_OLD(final String unlocalizedName, final String materialName, final int colour, + final int sRadioactivity) { + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(GTPlusPlus.ID + ":" + "itemIngot"); + this.colour = colour; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + String temp = ""; + if (this.unlocalName.contains("itemIngot")) { + temp = this.unlocalName.replace("itemI", "i"); + } else if (this.unlocalName.contains("itemHotIngot")) { + temp = this.unlocalName.replace("itemHotIngot", "ingotHot"); + } + if ((temp != null) && !temp.equals("")) { + GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this)); + } + // this.generateCompressorRecipe(); + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + + return (this.materialName + " Ingot"); + } + + public final String getMaterialName() { + return this.materialName; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + return this.colour; + } + + private void generateCompressorRecipe() { + if (this.unlocalName.contains("itemIngot")) { + final ItemStack tempStack = ItemUtils.getSimpleStack(this, 9); + ItemStack tempOutput = null; + String temp = this.getUnlocalizedName() + .replace("item.itemIngot", "block"); + 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); + } + temp = temp.replace("itemIngot", "block"); + Logger.WARNING("Generating OreDict Name: " + temp); + if ((temp != null) && !temp.equals("")) { + tempOutput = ItemUtils.getItemStackOfAmountFromOreDict(temp, 1); + if (tempOutput != null) { + GT_Values.RA.stdBuilder() + .itemInputs(tempStack) + .itemOutputs(tempOutput) + .duration(15 * SECONDS) + .eut(2) + .addTo(compressorRecipes); + } + } + } else if (this.unlocalName.contains("itemHotIngot")) { + return; + } + } + + protected final int sRadiation; + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java new file mode 100644 index 0000000000..cf50da52a3 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java @@ -0,0 +1,51 @@ +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 ItemBlockBasicTile extends ItemBlock { + + private final int mID; + + public ItemBlockBasicTile(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) { // 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 == 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"); + } 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 == 8) { // Volumetric Flask Setter + list.add("Easy Flask Configuration"); + list.add("Configure default input slot with a screwdriver"); + } else if (this.mID == 9) { + + } else { + list.add("Bad Tooltip ID - " + mID); + } + super.addInformation(stack, aPlayer, list, bool); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java new file mode 100644 index 0000000000..98c652a1ba --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java @@ -0,0 +1,184 @@ +package gtPlusPlus.core.item.base.itemblock; + +import java.util.HashMap; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; +import gtPlusPlus.core.block.base.BlockBaseModular; +import gtPlusPlus.core.block.base.BlockBaseOre; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; + +public class ItemBlockGtBlock extends ItemBlock { + + public static HashMap<String, String> sNameCache = new HashMap<>(); + + protected final int blockColour; + private int sRadiation; + + private Material mMaterial; + protected BlockTypes thisBlockType; + + private final Block thisBlock; + private boolean isOre = false; + private boolean isModular = false; + + public ItemBlockGtBlock(final Block block) { + super(block); + this.thisBlock = block; + if (block instanceof BlockBaseOre) { + this.isOre = true; + } else if (block instanceof BlockBaseModular) { + this.isModular = true; + } + final BlockBaseModular baseBlock = (BlockBaseModular) block; + if (isModular) { + this.blockColour = baseBlock.getRenderColor(0); + } else if (isOre) { + this.blockColour = block.getBlockColor(); + } else { + this.blockColour = block.getBlockColor(); + } + + if (block instanceof BlockBaseModular g) { + this.mMaterial = g.getMaterialEx(); + this.thisBlockType = g.thisBlock; + } else { + this.mMaterial = null; + this.thisBlockType = BlockTypes.STANDARD; + } + } + + public int getBlockTypeMeta() { + if (this.thisBlockType.equals(BlockTypes.STANDARD)) { + return 0; + } else if (this.thisBlockType.equals(BlockTypes.FRAME)) { + return 1; + } else if (this.thisBlockType.equals(BlockTypes.ORE)) { + return 2; + } + return 0; + } + + public String getUnlocalizedBlockName() { + return "block." + mMaterial.getUnlocalizedName() + + "." + + this.thisBlockType.name() + .toLowerCase(); + } + + public String GetProperName() { + String tempIngot = sNameCache.get(getUnlocalizedBlockName()); + if (tempIngot == null) { + tempIngot = "BAD.UNLOCAL.NAME"; + } + return tempIngot; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return this.thisBlock.getLocalizedName(); + } + + public int getRenderColor(final int aMeta) { + return this.blockColour; + } + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + if (this.mMaterial != null) { + list.add(this.mMaterial.vChemicalFormula); + } else { + + try { + BlockBaseModular g = (BlockBaseModular) thisBlock; + this.mMaterial = g.getMaterialEx(); + } catch (Throwable t) { + + } + + // list.add("Material is Null."); + } + + if (this.isOre) { + if (KeyboardUtils.isCtrlKeyDown()) { + Block b = Block.getBlockFromItem(stack.getItem()); + if (b != null) { + + String aTool = b.getHarvestTool(stack.getItemDamage()); + int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); + + if (this.mMaterial != null) { + list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); + list.add("Contains: "); + if (mMaterial.getComposites() + .isEmpty()) { + list.add("- " + mMaterial.getLocalizedName()); + } else { + for (MaterialStack m : mMaterial.getComposites()) { + list.add( + "- " + m.getStackMaterial() + .getLocalizedName() + " x" + m.getPartsPerOneHundred()); + } + } + } + } + } else { + list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); + } + } else { + Block b = Block.getBlockFromItem(stack.getItem()); + if (b != null) { + String aTool = b.getHarvestTool(stack.getItemDamage()); + int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); + list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); + } + } + + if (this.mMaterial != null) { + if (this.mMaterial.vRadiationLevel > 0) { + list.add(CORE.GT_Tooltip_Radioactive.get()); + } + } + + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + + if (!isModular && !isOre) { + mMaterial = null; + } else { + if (this.mMaterial == null) { + Block b = Block.getBlockFromItem(iStack.getItem()); + if (isOre) { + mMaterial = ((BlockBaseOre) b).getMaterialEx(); + } else { + mMaterial = ((BlockBaseModular) b).getMaterialEx(); + } + if (mMaterial != null) { + this.sRadiation = mMaterial.vRadiationLevel; + } else { + this.sRadiation = 0; + } + } + if (this.sRadiation > 0) { + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java new file mode 100644 index 0000000000..54cfefbac2 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java @@ -0,0 +1,106 @@ +package gtPlusPlus.core.item.base.itemblock; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + +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; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.data.AutoMap; + +public class ItemBlockMeta extends ItemBlockWithMetadata { + + private final Block mBlock; + private HashMap<Integer, AutoMap<String>> aTooltips = new LinkedHashMap<>(); + + public ItemBlockMeta(final Block aBlock) { + super(aBlock, aBlock); + this.mBlock = aBlock; + this.setMaxDamage(0); + this.setHasSubtypes(true); + if (aBlock instanceof ITileTooltip aTooltip) { + // aTooltips.put(aTooltip.getTooltipID(), aTooltip.getTooltipMap()); + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + Block aThis = Block.getBlockFromItem(stack.getItem()); + if (aThis != null) { + if (!aTooltips.isEmpty()) { + AutoMap<String> h = aTooltips.get(stack.getItemDamage()); + if (h != null && !h.isEmpty()) { + for (String s : h) { + list.add(s); + } + } + } + } + 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(2, 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 boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockOre.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockOre.java new file mode 100644 index 0000000000..0cee16b3f6 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockOre.java @@ -0,0 +1,148 @@ +package gtPlusPlus.core.item.base.itemblock; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.block.base.BlockBaseOre; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.everglades.gen.gt.WorldGen_GT_Ore_Layer; + +public class ItemBlockOre extends ItemBlock { + + private final BlockBaseOre mThisOre; + private final Material mThisMaterial; + private final int mThisRadiation; + + public ItemBlockOre(final Block block) { + super(block); + if (block instanceof BlockBaseOre) { + this.mThisOre = (BlockBaseOre) block; + this.mThisMaterial = this.mThisOre.getMaterialEx(); + this.mThisRadiation = this.mThisMaterial.vRadiationLevel; + } else { + this.mThisOre = null; + this.mThisMaterial = null; + this.mThisRadiation = 0; + } + } + + private static Map<String, AutoMap<String>> mMapOreBlockItemToDimName = new LinkedHashMap<>(); + private static boolean mInitOres_Everglades = false; + private AutoMap<String> mDimsForThisOre = new AutoMap<>(); + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + if (!mInitOres_Everglades) { + for (WorldGen_GT_Ore_Layer f : gtPlusPlus.everglades.gen.gt.WorldGen_Ores.validOreveins.values()) { + Material[] m2 = new Material[] { f.mPrimary, f.mSecondary, f.mBetween, f.mSporadic }; + for (Material m1 : m2) { + AutoMap<String> aMap = mMapOreBlockItemToDimName.get( + m1.getUnlocalizedName() + .toLowerCase()); + if (aMap == null) { + aMap = new AutoMap<>(); + } + String aDimName = "Everglades"; + if (!aMap.containsValue(aDimName)) { + aMap.put(aDimName); + } + mMapOreBlockItemToDimName.put( + m1.getUnlocalizedName() + .toLowerCase(), + aMap); + } + } + mInitOres_Everglades = true; + } + + if (this.mThisMaterial != null) { + list.add(this.mThisMaterial.vChemicalFormula); + } + + // Radioactive? + if (this.mThisRadiation > 0) { + list.add(CORE.GT_Tooltip_Radioactive.get()); + } + + if (this.mThisMaterial != null) { + list.add("Ore contains: "); + if (mThisMaterial.getComposites() + .isEmpty()) { + list.add("- " + mThisMaterial.getLocalizedName()); + } else { + for (MaterialStack m : mThisMaterial.getComposites()) { + list.add( + "- " + m.getStackMaterial() + .getLocalizedName() + " x" + m.getPartsPerOneHundred()); + } + } + } + + if (KeyboardUtils.isCtrlKeyDown()) { + + Block b = Block.getBlockFromItem(stack.getItem()); + if (b != null) { + int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); + if (aMiningLevel1 != 0) { + list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); + } + } + + if (mDimsForThisOre.isEmpty()) { + AutoMap<String> A = mMapOreBlockItemToDimName.get( + this.mThisMaterial.getUnlocalizedName() + .toLowerCase()); + if (A != null) { + mDimsForThisOre = A; + } + } + + list.add("Found: "); + if (!mDimsForThisOre.isEmpty()) { + for (String m : mDimsForThisOre) { + list.add("- " + m); + } + } else { + list.add("- Unknown"); + } + + } else { + list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); + } + + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + if (this.mThisMaterial != null) { + if (this.mThisRadiation > 0) { + if (entityHolding instanceof EntityPlayer) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + EntityUtils.applyRadiationDamageToEntity( + iStack.stackSize, + this.mThisMaterial.vRadiationLevel, + world, + entityHolding); + } + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemMisc.java b/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemMisc.java new file mode 100644 index 0000000000..020becc687 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemMisc.java @@ -0,0 +1,154 @@ +package gtPlusPlus.core.item.base.misc; + +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BaseItemMisc extends Item { + + public final String displayName; + public final String unlocalName; + public final MiscTypes miscType; + public final Object componentColour; + + public BaseItemMisc(final String displayName, final short[] RGB, final int maxStackSize, final MiscTypes miscType, + String[] description) { + + // Set-up the Misc Generic Item + this.displayName = displayName; + String unlocalName = Utils.sanitizeString(displayName); + this.unlocalName = "item" + miscType.TYPE + unlocalName; + this.miscType = miscType; + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(this.unlocalName); + this.setMaxStackSize(maxStackSize); + // this.setTextureName(this.getCorrectTextures()); + if (RGB != null) { + this.componentColour = Utils.rgbtoHexValue(RGB[0], RGB[1], RGB[2]); + } else { + this.componentColour = null; + } + if (description != null) { + for (int i = 0; i < description.length; i++) { + GT_LanguageManager + .addStringLocalization("gtplusplus." + this.getUnlocalizedName() + ".tooltip." + i, description[i]); + } + } + GameRegistry.registerItem(this, this.unlocalName); + GT_OreDictUnificator.registerOre(miscType.getOreDictPrefix() + unlocalName, ItemUtils.getSimpleStack(this)); + } + + private String getCorrectTextures() { + return GTPlusPlus.ID + ":" + "item" + this.miscType.TYPE; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return this.miscType == MiscTypes.DROP; + } + + @Override + public int getRenderPasses(int meta) { + return (this.miscType == MiscTypes.DROP) ? 2 : 1; + } + + @SideOnly(Side.CLIENT) + private IIcon secondIcon; + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + if (this.miscType == MiscTypes.DROP && Forestry.isModLoaded()) { + this.itemIcon = par1IconRegister.registerIcon("forestry:honeyDrop.0"); + this.secondIcon = par1IconRegister.registerIcon("forestry:honeyDrop.1"); + } else { + this.itemIcon = par1IconRegister.registerIcon(getCorrectTextures()); + } + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return (pass == 0) ? itemIcon : secondIcon; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, + final boolean bool) { + for (int i = 0;; i++) { + String tooltip = GT_LanguageManager + .getTranslation("gtplusplus." + this.getUnlocalizedName() + ".tooltip" + "." + i); + if (!("gtplusplus." + this.getUnlocalizedName() + ".tooltip" + "." + i).equals(tooltip)) { + list.add(tooltip); + } else break; + } + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + // Returns default colour if a custom one is not set. + if (this.componentColour == null) { + return 16777215; + } else { + return (int) this.componentColour; + } + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + // Nothing Fancy here yet. + } + + public static enum MiscTypes { + + POTION("Potion", " Potion", "potion"), + KEY("Key", " Key", "key"), + BIGKEY("KeyBig", " Big Key", "bosskey"), + BOTTLE("Bottle", " Bottle", "bottle"), + GEM("Gem", " Gemstone", "gem"), + DROP("Droplet", " Droplet", "droplet"), + MUSHROOM("Mushroom", " Mushroom", "mushroom"); + + private final String TYPE; + private final String DISPLAY_NAME_SUFFIX; + private final String OREDICT_PREFIX; + + private MiscTypes(final String LocalName, final String DisplayNameSuffix, final String OreDictPrefix) { + this.TYPE = LocalName; + this.DISPLAY_NAME_SUFFIX = DisplayNameSuffix; + this.OREDICT_PREFIX = OreDictPrefix; + } + + public String getType() { + return this.TYPE; + } + + public String getName() { + return this.DISPLAY_NAME_SUFFIX; + } + + public String getOreDictPrefix() { + return this.OREDICT_PREFIX; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java b/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java new file mode 100644 index 0000000000..b6292c695e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java @@ -0,0 +1,66 @@ +package gtPlusPlus.core.item.base.misc; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.CoreItem; + +public abstract class BaseItemParticle extends CoreItem { + + protected static final Map<Integer, Integer> aColourMap = new LinkedHashMap<>(); + private final int aMaxCount; + + public BaseItemParticle(String aType, int aCount, EnumRarity aRarity) { + super( + "particle" + aType, + aType, + AddToCreativeTab.tabOther, + 64, + 0, + new String[] {}, + aRarity, + EnumChatFormatting.DARK_AQUA, + false, + null); + this.setTextureName(GTPlusPlus.ID + ":" + "science/Atom"); + aMaxCount = aCount; + this.setHasSubtypes(true); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return aColourMap.get(stack.getItemDamage()); + } + + public int getColorFromParentClass(ItemStack stack, int aaa) { + return super.getColorFromItemStack(stack, aaa); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < aMaxCount; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public final String getItemStackDisplayName(final ItemStack tItem) { + String aReturnValue = super.getItemStackDisplayName(tItem); + String[] a2 = getAffixes(); + aReturnValue = (a2[0] + aReturnValue + a2[1]); + return aReturnValue; + } + + public abstract String[] getAffixes(); +} diff --git a/src/main/java/gtPlusPlus/core/item/base/nugget/BaseItemNugget.java b/src/main/java/gtPlusPlus/core/item/base/nugget/BaseItemNugget.java new file mode 100644 index 0000000000..b0537f022f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/nugget/BaseItemNugget.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.nugget; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemNugget extends BaseItemComponent { + + public BaseItemNugget(final Material material) { + super(material, BaseItemComponent.ComponentTypes.NUGGET); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCentrifugedCrushedOre.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCentrifugedCrushedOre.java new file mode 100644 index 0000000000..9a72f62040 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCentrifugedCrushedOre.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.item.base.ore; + +import gtPlusPlus.core.material.Material; + +public class BaseItemCentrifugedCrushedOre extends BaseOreComponent { + + public BaseItemCentrifugedCrushedOre(final Material material) { + super(material, BaseOreComponent.ComponentTypes.CRUSHEDCENTRIFUGED); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCrushedOre.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCrushedOre.java new file mode 100644 index 0000000000..e9588f9f96 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCrushedOre.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.item.base.ore; + +import gtPlusPlus.core.material.Material; + +public class BaseItemCrushedOre extends BaseOreComponent { + + public BaseItemCrushedOre(final Material material) { + super(material, BaseOreComponent.ComponentTypes.CRUSHED); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemImpureDust.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemImpureDust.java new file mode 100644 index 0000000000..f80e392703 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemImpureDust.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.item.base.ore; + +import gtPlusPlus.core.material.Material; + +public class BaseItemImpureDust extends BaseOreComponent { + + public BaseItemImpureDust(final Material material) { + super(material, BaseOreComponent.ComponentTypes.DUSTIMPURE); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemMilledOre.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemMilledOre.java new file mode 100644 index 0000000000..90235a18b3 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemMilledOre.java @@ -0,0 +1,24 @@ +package gtPlusPlus.core.item.base.ore; + +import net.minecraft.item.Item; + +import gregtech.api.enums.Materials; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.minecraft.MaterialUtils; + +public class BaseItemMilledOre extends BaseOreComponent { + + public BaseItemMilledOre(final Material material, int aMaterialEU) { + super(material, BaseOreComponent.ComponentTypes.MILLED); + CORE.RA.addMillingRecipe(material, aMaterialEU); + } + + public static Item generate(Materials aMat, int aMaterialEU) { + return generate(MaterialUtils.generateMaterialFromGtENUM(aMat), aMaterialEU); + } + + public static Item generate(Material aMat, int aMaterialEU) { + return new BaseItemMilledOre(aMat, aMaterialEU); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedCrushedOre.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedCrushedOre.java new file mode 100644 index 0000000000..744b204d43 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedCrushedOre.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.item.base.ore; + +import gtPlusPlus.core.material.Material; + +public class BaseItemPurifiedCrushedOre extends BaseOreComponent { + + public BaseItemPurifiedCrushedOre(final Material material) { + super(material, BaseOreComponent.ComponentTypes.CRUSHEDPURIFIED); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedDust.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedDust.java new file mode 100644 index 0000000000..4b94b98e64 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedDust.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.item.base.ore; + +import gtPlusPlus.core.material.Material; + +public class BaseItemPurifiedDust extends BaseOreComponent { + + public BaseItemPurifiedDust(final Material material) { + super(material, BaseOreComponent.ComponentTypes.DUSTPURE); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemRawOre.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemRawOre.java new file mode 100644 index 0000000000..bca44d0045 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemRawOre.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.item.base.ore; + +import gtPlusPlus.core.material.Material; + +public class BaseItemRawOre extends BaseOreComponent { + + public BaseItemRawOre(final Material material) { + super(material, BaseOreComponent.ComponentTypes.RAWORE); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java new file mode 100644 index 0000000000..2074bb2ede --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java @@ -0,0 +1,272 @@ +package gtPlusPlus.core.item.base.ore; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GregTech; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BaseOreComponent extends Item { + + @SideOnly(Side.CLIENT) + private IIcon base; + + @SideOnly(Side.CLIENT) + private IIcon overlay; + + public final Material componentMaterial; + public final String materialName; + public final String unlocalName; + public final ComponentTypes componentType; + public final int componentColour; + public Object extraData; + + public BaseOreComponent(final Material material, final ComponentTypes componentType) { + this.componentMaterial = material; + this.unlocalName = componentType.COMPONENT_NAME + material.getUnlocalizedName(); + this.materialName = material.getLocalizedName(); + this.componentType = componentType; + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(this.unlocalName); + this.setMaxStackSize(64); + this.componentColour = material.getRgbAsHex(); + GameRegistry.registerItem(this, this.unlocalName); + registerComponent(); + GT_OreDictUnificator + .registerOre(componentType.getComponent() + material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); + } + + public boolean registerComponent() { + Logger.MATERIALS("Attempting to register " + this.getUnlocalizedName() + "."); + if (this.componentMaterial == null) { + Logger.MATERIALS("Tried to register " + this.getUnlocalizedName() + " but the material was null."); + return false; + } + // Register Component + Map<String, ItemStack> aMap = Material.mComponentMap.get(componentMaterial.getUnlocalizedName()); + if (aMap == null) { + aMap = new HashMap<>(); + } + String aKey = "Invalid"; + switch (componentType) { + case CRUSHED -> aKey = OrePrefixes.crushed.name(); + case CRUSHEDCENTRIFUGED -> aKey = OrePrefixes.crushedCentrifuged.name(); + case CRUSHEDPURIFIED -> aKey = OrePrefixes.crushedPurified.name(); + case DUST -> aKey = OrePrefixes.dust.name(); + case DUSTIMPURE -> aKey = OrePrefixes.dustImpure.name(); + case DUSTPURE -> aKey = OrePrefixes.dustPure.name(); + case MILLED -> aKey = OrePrefixes.milled.name(); + case RAWORE -> aKey = OrePrefixes.rawOre.name(); + } + + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, ItemUtils.getSimpleStack(this)); + Logger.MATERIALS( + "Registering a material component. Item: [" + componentMaterial.getUnlocalizedName() + + "] Map: [" + + aKey + + "]"); + Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap); + return true; + } else { + // Bad + Logger.MATERIALS("Tried to double register a material component. "); + return false; + } + } + + /* + * @Override public String getItemStackDisplayName(final ItemStack p_77653_1_) { return + * (this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME); } + */ + + public final String getMaterialName() { + return this.materialName; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + 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.contains("?")) { + list.add(Utils.sanitizeStringKeepBrackets(this.componentMaterial.vChemicalFormula)); + } else if (this.componentMaterial.vChemicalFormula.contains("?")) { + 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.get() + " | Level: " + this.componentMaterial.vRadiationLevel); + } + } else { + String aChemicalFormula = Material.sChemicalFormula.get(materialName.toLowerCase()); + if (aChemicalFormula != null && aChemicalFormula.length() > 0) { + list.add(Utils.sanitizeStringKeepBrackets(aChemicalFormula)); + } + } + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + if (this.componentMaterial != null) { + if (entityHolding instanceof EntityPlayer) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + EntityUtils.applyRadiationDamageToEntity( + iStack.stackSize, + this.componentMaterial.vRadiationLevel, + world, + entityHolding); + } + } + } + } + + /** + * Rendering Related + * + * @author Alkalus + * + */ + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + if (this.componentType.hasOverlay()) { + return true; + } + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister par1IconRegister) { + if (this.componentType == ComponentTypes.MILLED) { + this.base = par1IconRegister.registerIcon(GTPlusPlus.ID + ":" + "processing/MilledOre/milled"); + if (this.componentType.hasOverlay()) { + this.overlay = par1IconRegister + .registerIcon(GTPlusPlus.ID + ":" + "processing/MilledOre/milled_OVERLAY"); + } + } else if (CORE.ConfigSwitches.useGregtechTextures) { + // Logger.MATERIALS(this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME+" + // is using `"+GregTech.ID + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"' as the + // layer 0 texture path."); + this.base = par1IconRegister + .registerIcon(GregTech.ID + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME); + if (this.componentType.hasOverlay()) { + // Logger.MATERIALS(this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME+" + // is using `"+GregTech.ID + ":" + "materialicons/METALLIC/" + + // this.componentType.COMPONENT_NAME+"_OVERLAY"+"' as the layer 1 texture path."); + this.overlay = par1IconRegister.registerIcon( + GregTech.ID + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME + "_OVERLAY"); + } + } else { + this.base = par1IconRegister.registerIcon(GTPlusPlus.ID + ":" + "item" + this.componentType.getComponent()); + if (this.componentType.hasOverlay()) { + this.overlay = par1IconRegister + .registerIcon(GTPlusPlus.ID + ":" + "item" + this.componentType.getComponent() + "_Overlay"); + } + } + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + if (this.componentType == ComponentTypes.MILLED) { + if (renderPass == 1) { + return Utils.rgbtoHexValue(230, 230, 230); + } + return this.componentColour; + } else { + if (renderPass == 0 && !CORE.ConfigSwitches.useGregtechTextures) { + return this.componentColour; + } + if (renderPass == 1 && CORE.ConfigSwitches.useGregtechTextures) { + return Utils.rgbtoHexValue(230, 230, 230); + } + return this.componentColour; + } + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (pass == 0) { + return this.base; + } + return this.overlay; + } + + public static enum ComponentTypes { + + DUST("dust", "", " Dust", true), + DUSTIMPURE("dustImpure", "Impure ", " Dust", true), + DUSTPURE("dustPure", "Purified ", " Dust", true), + CRUSHED("crushed", "Crushed ", " Ore", true), + CRUSHEDCENTRIFUGED("crushedCentrifuged", "Centrifuged Crushed ", " Ore", true), + CRUSHEDPURIFIED("crushedPurified", "Purified Crushed ", " Ore", true), + RAWORE("oreRaw", "Raw ", " Ore", true), + MILLED("milled", "Milled ", " Ore", true); + + private final String COMPONENT_NAME; + private final String PREFIX; + private final String DISPLAY_NAME; + private final boolean HAS_OVERLAY; + + private ComponentTypes(final String LocalName, final String prefix, final String DisplayName, + final boolean overlay) { + this.COMPONENT_NAME = LocalName; + this.PREFIX = prefix; + this.DISPLAY_NAME = DisplayName; + this.HAS_OVERLAY = overlay; + // dust + Dirty, Impure, Pure, Refined + // crushed + centrifuged, purified + } + + public String getComponent() { + return this.COMPONENT_NAME; + } + + public String getName() { + return this.DISPLAY_NAME; + } + + public boolean hasOverlay() { + return this.HAS_OVERLAY; + } + + public String getPrefix() { + return this.PREFIX; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java new file mode 100644 index 0000000000..0fad7a8258 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java @@ -0,0 +1,23 @@ +package gtPlusPlus.core.item.base.plates; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.util.minecraft.MaterialUtils; + +public class BaseItemPlate extends BaseItemComponent { + + public BaseItemPlate(final Material material) { + super(material, BaseItemComponent.ComponentTypes.PLATE); + } + + public BaseItemPlate(final String unlocalizedName, final String materialName, final MaterialState state, + final short[] colour, final int tier, final int sRadioactivity) { + this( + MaterialUtils.generateQuickMaterial( + materialName, + state, + new short[] { colour[0], colour[1], colour[2], 0 }, + sRadioactivity)); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateDense.java b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateDense.java new file mode 100644 index 0000000000..580e028c00 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateDense.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.plates; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemPlateDense extends BaseItemComponent { + + public BaseItemPlateDense(Material material) { + super(material, ComponentTypes.PLATEDENSE); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java new file mode 100644 index 0000000000..4f5bc12829 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java @@ -0,0 +1,12 @@ +package gtPlusPlus.core.item.base.plates; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemPlateDouble extends BaseItemComponent { + + public BaseItemPlateDouble(final Material material) { + super(material, BaseItemComponent.ComponentTypes.PLATEDOUBLE); + this.setMaxStackSize(32); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate_OLD.java b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate_OLD.java new file mode 100644 index 0000000000..168d5236c6 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate_OLD.java @@ -0,0 +1,91 @@ +package gtPlusPlus.core.item.base.plates; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BaseItemPlate_OLD extends Item { + + protected final int colour; + protected final int sRadiation; + protected final String materialName; + protected final String unlocalName; + protected final String chemicalNotation; + + public BaseItemPlate_OLD(final String unlocalizedName, final String materialName, final int colour, + final int sRadioactivity) { + this(unlocalizedName, materialName, "NullFormula", colour, sRadioactivity); + } + + public BaseItemPlate_OLD(final String unlocalizedName, final String materialName, final String mChemicalFormula, + final int colour, final int sRadioactivity) { + this.setUnlocalizedName("itemPlate" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.unlocalName = "itemPlate" + unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(GTPlusPlus.ID + ":" + "itemPlate"); + this.setMaxStackSize(64); + this.colour = colour; + this.materialName = materialName; + if (mChemicalFormula.equals("") || mChemicalFormula.equals("NullFormula")) { + this.chemicalNotation = StringUtils.subscript(materialName); + } else { + this.chemicalNotation = StringUtils.subscript(mChemicalFormula); + } + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, "itemPlate" + unlocalizedName); + String temp; + if (this.unlocalName.toLowerCase() + .contains("itemplate")) { + temp = this.unlocalName.replace("itemP", "p"); + if ((temp != null) && !temp.equals("")) { + GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this)); + } + } + } + + public final String getMaterialName() { + return this.materialName; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + return this.colour; + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (this.sRadiation > 0) { + list.add(CORE.GT_Tooltip_Radioactive.get()); + } + if (StringUtils.containsSuperOrSubScript(this.chemicalNotation)) { + list.add(this.chemicalNotation); + } + super.addInformation(stack, aPlayer, list, bool); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/rings/BaseItemRing.java b/src/main/java/gtPlusPlus/core/item/base/rings/BaseItemRing.java new file mode 100644 index 0000000000..d25ea02d52 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/rings/BaseItemRing.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.rings; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemRing extends BaseItemComponent { + + public BaseItemRing(final Material material) { + super(material, BaseItemComponent.ComponentTypes.RING); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRod.java b/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRod.java new file mode 100644 index 0000000000..9a9998d63a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRod.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.rods; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemRod extends BaseItemComponent { + + public BaseItemRod(final Material material) { + super(material, BaseItemComponent.ComponentTypes.ROD); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java b/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java new file mode 100644 index 0000000000..bf7dd3bccc --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.rods; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemRodLong extends BaseItemComponent { + + public BaseItemRodLong(final Material material) { + super(material, BaseItemComponent.ComponentTypes.RODLONG); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java b/src/main/java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java new file mode 100644 index 0000000000..c2fae0fc8b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.rotors; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemRotor extends BaseItemComponent { + + public BaseItemRotor(final Material material) { + super(material, BaseItemComponent.ComponentTypes.ROTOR); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java b/src/main/java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java new file mode 100644 index 0000000000..7f0ba8c504 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.screws; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemScrew extends BaseItemComponent { + + public BaseItemScrew(final Material material) { + super(material, BaseItemComponent.ComponentTypes.SCREW); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/wire/BaseItemFineWire.java b/src/main/java/gtPlusPlus/core/item/base/wire/BaseItemFineWire.java new file mode 100644 index 0000000000..3e2cee49a9 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/base/wire/BaseItemFineWire.java @@ -0,0 +1,11 @@ +package gtPlusPlus.core.item.base.wire; + +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.material.Material; + +public class BaseItemFineWire extends BaseItemComponent { + + public BaseItemFineWire(final Material material) { + super(material, BaseItemComponent.ComponentTypes.FINEWIRE); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java new file mode 100644 index 0000000000..92468aa6d8 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java @@ -0,0 +1,133 @@ +package gtPlusPlus.core.item.bauble; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.living.LivingAttackEvent; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + +import baubles.api.BaubleType; +import baubles.api.IBauble; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.enums.Mods; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.NBTUtils; + +@Optional.InterfaceList( + value = { @Optional.Interface(iface = "baubles.api.IBauble", modid = Mods.Names.BAUBLES), + @Optional.Interface(iface = "baubles.api.BaubleType", modid = Mods.Names.BAUBLES) }) +public class BaseBauble extends Item implements IBauble { + + /** + * Implementation suggestions taken from Botania. + */ + private BaubleType mThisBauble; + + private List<String> damageNegations = new ArrayList<>(); + Multimap<String, AttributeModifier> attributes = HashMultimap.create(); + + public BaseBauble(BaubleType type) { + this.mThisBauble = type; + Utils.registerEvent(this); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMisc); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + String key = "gtplusplus." + getUnlocalizedName() + ".name"; + if (key.equals(GT_LanguageManager.getTranslation(key))) { + return super.getItemStackDisplayName(tItem).replaceAll(".name", ""); + } + return GT_LanguageManager.getTranslation(key); + } + + @SubscribeEvent + public void onPlayerAttacked(LivingAttackEvent event) { + if (event.entityLiving instanceof EntityPlayer player) { + if (getCorrectBauble(player) != null && damageNegations.contains(event.source.damageType)) + event.setCanceled(true); + } + } + + @Override + public boolean canEquip(ItemStack arg0, EntityLivingBase arg1) { + return arg1 instanceof EntityPlayer; + } + + @Override + public boolean canUnequip(ItemStack arg0, EntityLivingBase arg1) { + return arg1 instanceof EntityPlayer; + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return mThisBauble; + } + + @Override + public void onEquipped(ItemStack stack, EntityLivingBase entity) { + if (entity instanceof EntityPlayer) { + onEquippedOrLoadedIntoWorld(entity); + setPlayerHashcode(stack, entity.hashCode()); + } + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if (getPlayerHashcode(stack) != player.hashCode()) { + onEquippedOrLoadedIntoWorld(player); + setPlayerHashcode(stack, player.hashCode()); + } + } + + public void onEquippedOrLoadedIntoWorld(EntityLivingBase player) { + attributes.clear(); + player.getAttributeMap() + .applyAttributeModifiers(attributes); + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + player.getAttributeMap() + .removeAttributeModifiers(attributes); + } + + public ItemStack getCorrectBauble(EntityPlayer player) { + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + ItemStack stack1 = baubles.getStackInSlot(1); + ItemStack stack2 = baubles.getStackInSlot(2); + return isCorrectBauble(stack1) ? stack1 : isCorrectBauble(stack2) ? stack2 : null; + } + + private boolean isCorrectBauble(ItemStack stack) { + return stack != null && (stack.getItem() == this); + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + public static int getPlayerHashcode(ItemStack stack) { + return NBTUtils.getInteger(stack, "mPlayerHashcode"); + } + + public static void setPlayerHashcode(ItemStack stack, int hash) { + NBTUtils.setInteger(stack, "mPlayerHashcode", hash); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java new file mode 100644 index 0000000000..881146b15d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java @@ -0,0 +1,261 @@ +package gtPlusPlus.core.item.bauble; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import baubles.api.BaubleType; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; + +public class BatteryPackBaseBauble extends ElectricBaseBauble { + + public BatteryPackBaseBauble(int tier) { + super(BaubleType.BELT, tier, GT_Values.V[tier] * 20 * 300, "GTPP.BattPack.0" + tier + ".name"); + String aUnlocalName = "GTPP.BattPack.0" + tier + ".name"; + this.setCreativeTab(AddToCreativeTab.tabMachines); + if (GameRegistry.findItem(GTPlusPlus.ID, aUnlocalName) == null) { + GameRegistry.registerItem(this, aUnlocalName); + } + } + + @SideOnly(Side.CLIENT) + @Override + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { + ItemStack itemStack = new ItemStack(this, 1); + ItemStack charged; + if (this.getEmptyItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getChargedItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + } + + @Override + public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, + final boolean p_77663_5_) { + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + double aItemCharge = ElectricItem.manager.getCharge(itemStack); + return aItemCharge > 0; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (EnumChatFormatting.BLUE + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return true; + } + + public int secondsLeft(final ItemStack stack) { + double r = 0; + r = this.getCharge(stack) / (10000 * 20); + return (int) MathUtils.decimalRounding(r); + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(""); + String aString1 = StatCollector.translateToLocal("GTPP.battpack.tooltip.1"); + 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"; + + list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); + list.add( + EnumChatFormatting.GREEN + aString2 + + " " + + (int) getTransferLimit(stack) + + aEUT + + " " + + aString3 + + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString4 + EnumChatFormatting.GRAY); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public String getToolTip(final ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override // TODO + public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + + 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)); + } + } else { + // Logger.INFO("5"); + } + } else { + // Logger.INFO("4"); + } + } else { + // Logger.INFO("3"); + } + + } else { + // Logger.INFO("1"); + } + } + } + } + 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) { + 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, 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"); + } + } else { + // Logger.INFO("3"); + } + + } else { + // Logger.INFO("1"); + } + } + } + } + if (this.getCharge(aBaubleStack) > 0) { + continue; + } else { + break; + } + } + } + } + } catch (Throwable t) { + + } + } + } + + @Override + public String getTextureNameForBauble() { + return "chargepack/" + mTier; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java new file mode 100644 index 0000000000..ab17e91232 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java @@ -0,0 +1,220 @@ +package gtPlusPlus.core.item.bauble; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Mods; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.math.MathUtils; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; + +@Optional.InterfaceList( + value = { @Optional.Interface(iface = "baubles.api.IBauble", modid = Mods.Names.BAUBLES), + @Optional.Interface(iface = "baubles.api.BaubleType", modid = Mods.Names.BAUBLES) }) +public abstract class ElectricBaseBauble extends BaseBauble implements IElectricItem, IElectricItemManager, IBauble { + + public final int mTier; + private final double maxValueEU; + private final BaubleType mType; + + public ElectricBaseBauble(BaubleType aType, int aTier, double aMaxEU, String aUnlocalName) { + super(aType); + mType = aType; + mTier = aTier; + maxValueEU = aMaxEU; + this.setUnlocalizedName(aUnlocalName); + this.setTextureName(GTPlusPlus.ID + ":" + getTextureNameForBauble()); + this.setMaxDamage(27); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setCreativeTab(AddToCreativeTab.tabMachines); + if (GameRegistry.findItem(GTPlusPlus.ID, aUnlocalName) == null) { + GameRegistry.registerItem(this, aUnlocalName); + } + } + + public abstract String getTextureNameForBauble(); + + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + @Override + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { + ItemStack itemStack = new ItemStack(this, 1); + ItemStack charged; + if (this.getEmptyItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getChargedItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + } + + @Override + public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, + final boolean p_77663_5_) { + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + double aItemCharge = ElectricItem.manager.getCharge(itemStack); + return aItemCharge > 0; + } + + @Override + public final Item getChargedItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(27); + return x.getItem(); + } + + @Override + public final Item getEmptyItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public final double getMaxCharge(final ItemStack itemStack) { + return maxValueEU; + } + + @Override + public final int getTier(final ItemStack itemStack) { + return mTier; + } + + @Override + public final double getTransferLimit(final ItemStack itemStack) { + return GT_Values.V[mTier]; + } + + @Override + public final double getDurabilityForDisplay(final ItemStack stack) { + return 1.0D - (this.getCharge(stack) / this.getMaxCharge(stack)); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return true; + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(""); + String aEuInfo = StatCollector.translateToLocal("GTPP.info.euInfo"); + String aTier = StatCollector.translateToLocal("GTPP.machines.tier"); + String aInputLimit = StatCollector.translateToLocal("GTPP.info.inputLimit"); + String aCurrentPower = StatCollector.translateToLocal("GTPP.info.currentPower"); + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); + String aEUT = aEU + "/t"; + + list.add(EnumChatFormatting.GOLD + aEuInfo + EnumChatFormatting.GRAY); + list.add( + EnumChatFormatting.GRAY + aTier + + ": [" + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(this.getTier(stack)) + + EnumChatFormatting.GRAY + + "] " + + aInputLimit + + ": [" + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(this.getTransferLimit(stack)) + + EnumChatFormatting.GRAY + + aEUT + + "]"); + list.add( + EnumChatFormatting.GRAY + aCurrentPower + + ": [" + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(this.getCharge(stack)) + + EnumChatFormatting.GRAY + + aEU + + "] [" + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack))) + + EnumChatFormatting.GRAY + + "%]"); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public final double charge(final ItemStack stack, final double amount, final int tier, + final boolean ignoreTransferLimit, final boolean simulate) { + /* + * if (!simulate) { ElectricItem.manager.charge(stack, amount, tier, true, simulate); } + */ + + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public final double discharge(final ItemStack stack, final double amount, final int tier, + final boolean ignoreTransferLimit, final boolean externally, final boolean simulate) { + /* + * if (!simulate) { ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, + * simulate); } + */ + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public final double getCharge(final ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public final boolean canUse(final ItemStack stack, final double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public final boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public final void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(final ItemStack stack) { + // return ElectricItem.manager.getToolTip(stack); + return null; + } + + @Override + public final BaubleType getBaubleType(final ItemStack arg0) { + return mType; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java new file mode 100644 index 0000000000..c3c371ae35 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java @@ -0,0 +1,120 @@ +package gtPlusPlus.core.item.bauble; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.lang.reflect.Field; +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import baubles.api.BaubleType; +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.CORE_Preloader; + +public class FireProtectionBauble extends BaseBauble { + + private static Field isImmuneToFire; + + static { + isImmuneToFire = ReflectionUtils + .getField(Entity.class, !CORE_Preloader.DEV_ENVIRONMENT ? "func_70045_F" : "isImmuneToFire"); + } + + public static boolean fireImmune(Entity aEntity) { + return aEntity.isImmuneToFire(); + } + + public static boolean setEntityImmuneToFire(Entity aEntity, boolean aImmune) { + try { + return ReflectionUtils.setField(aEntity, isImmuneToFire, aImmune); + } catch (Throwable t) {} + return false; + } + + public FireProtectionBauble() { + super(BaubleType.RING); + String aUnlocalName = "GTPP.bauble.fireprotection.0" + ".name"; + this.setUnlocalizedName(aUnlocalName); + this.setTextureName(GTPlusPlus.ID + ":" + getTextureNameForBauble()); + this.setMaxDamage(100); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setCreativeTab(AddToCreativeTab.tabMachines); + if (GameRegistry.findItem(GTPlusPlus.ID, aUnlocalName) == null) { + GameRegistry.registerItem(this, aUnlocalName); + } + } + + @Override + public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, + final boolean p_77663_5_) { + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (EnumChatFormatting.DARK_RED + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return false; + } + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public void onEquipped(final ItemStack arg0, final EntityLivingBase aPlayer) {} + + @Override + public void onUnequipped(final ItemStack arg0, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + if (aPlayer instanceof EntityPlayer bPlayer) { + if (bPlayer.isPotionActive(Potion.fireResistance)) { + bPlayer.removePotionEffect(Potion.fireResistance.id); + } + setEntityImmuneToFire(bPlayer, false); + } + } + } + + @Override + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + if (aPlayer instanceof EntityPlayer bPlayer) { + if (!fireImmune(bPlayer)) { + setEntityImmuneToFire(bPlayer, true); + } + if (!bPlayer.isPotionActive(Potion.fireResistance)) { + bPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 100, 4)); + } + } + } + } + + public String getTextureNameForBauble() { + return "baubles/itemFireProtectGlovesBetter"; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java new file mode 100644 index 0000000000..e14d9f7f08 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -0,0 +1,667 @@ +package gtPlusPlus.core.item.chemistry; + +import static gregtech.api.enums.Mods.BiomesOPlenty; +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.Mods.TinkerConstruct; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.recipe.RecipeMaps.compressorRecipes; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeConstants.UniversalChemical; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.item.circuit.GTPP_IntegratedCircuit_Item; +import gtPlusPlus.core.lib.CORE; +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.xmod.gregtech.api.enums.GregtechItemList; + +public class AgriculturalChem extends ItemPackage { + + private static boolean aBOP; + private static boolean aTiCon; + + private static AutoMap<FluidStack> mBloodFluids = new AutoMap<>(); + + /** + * Fluids + */ + + // Poop Juice + public static Fluid PoopJuice; + // Manure Slurry + public static Fluid ManureSlurry; + // Fertile Manure Slurry + public static Fluid FertileManureSlurry; + // Blood + public static Fluid CustomBlood; + // Red Mud + public static Fluid RedMud; + /** + * 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 + + 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 24 - Pinecone + */ + + 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; + public static ItemStack mPinecone; + public static ItemStack mCrushedPine; + + @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]; + + mAlgae = new ItemAlgaeBase(); + mAgrichemItem1 = new ItemAgrichemBase(); + mBioCircuit = new GTPP_IntegratedCircuit_Item("BioRecipeSelector", "bioscience/BioCircuit"); + 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); + mPinecone = ItemUtils.simpleMetaStack(mAgrichemItem1, 24, 1); + mCrushedPine = ItemUtils.simpleMetaStack(mAgrichemItem1, 25, 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"); + ItemUtils.addItemToOreDictionary(mPinecone, "pinecone"); + ItemUtils.addItemToOreDictionary(mCrushedPine, "crushedPineMaterial"); + + // 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 + public void blocks() { + // None yet + } + + @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); + + RedMud = FluidUtils.generateFluidNoPrefix( + "mud.red.slurry", + "Red Mud Slurry", + 32 + 175, + new short[] { 180, 35, 25, 100 }, + true); + } + + public AgriculturalChem() { + super(); + + aBOP = BiomesOPlenty.isModLoaded(); + aTiCon = TinkerConstruct.isModLoaded(); + + Logger.INFO("Adding Agrochemical content"); + + FluidStack aBlood; + if (aBOP) { + aBlood = FluidUtils.getFluidStack("hell_blood", 100); + if (aBlood != null) { + Logger.INFO("Found Biome's o Plenty, enabled Blood support."); + CustomBlood = aBlood.getFluid(); + mBloodFluids.put(aBlood); + } + } + + if (aTiCon) { + aBlood = FluidUtils.getFluidStack("blood", 100); + if (aBlood != null) { + Logger.INFO("Found Tinker's Construct, enabled Blood support."); + CustomBlood = aBlood.getFluid(); + mBloodFluids.put(FluidUtils.getFluidStack("blood", 100)); + } + } + + // Handle Blood Internally, Create if required. + if (mBloodFluids.isEmpty() || CustomBlood == null) { + Logger.INFO( + "Did not find any existing Blood fluids. Trying to wildcard search the fluid registry, then generate our own if that fails."); + FluidStack aTempBlood = FluidUtils.getWildcardFluidStack("blood", 100); + if (aTempBlood != null) { + CustomBlood = aTempBlood.getFluid(); + } else { + aTempBlood = FluidUtils.getWildcardFluidStack("hell_blood", 100); + if (aTempBlood == null) { + CustomBlood = FluidUtils + .generateFluidNoPrefix("blood", "Blood", 32 + 175, new short[] { 175, 25, 25, 100 }, true); + } else { + CustomBlood = aTempBlood.getFluid(); + } + } + Logger.INFO("Using " + CustomBlood.getName()); + mBloodFluids.put(FluidUtils.getFluidStack(CustomBlood, 100)); + } + } + + private static final AutoMap<ItemStack> mMeats = new AutoMap<>(); + private static final AutoMap<ItemStack> mFish = new AutoMap<>(); + private static final AutoMap<ItemStack> mFruits = new AutoMap<>(); + private static final AutoMap<ItemStack> mVege = new AutoMap<>(); + private static final AutoMap<ItemStack> mNuts = new AutoMap<>(); + private static final AutoMap<ItemStack> mSeeds = new AutoMap<>(); + private static final AutoMap<ItemStack> mPeat = new AutoMap<>(); + private static final AutoMap<ItemStack> mBones = new AutoMap<>(); + private static final AutoMap<ItemStack> mBoneMeal = new AutoMap<>(); + + private static final AutoMap<ItemStack> mList_Master_Meats = new AutoMap<>(); + private static final AutoMap<ItemStack> mList_Master_FruitVege = new AutoMap<>(); + private static final AutoMap<ItemStack> mList_Master_Seeds = new AutoMap<>(); + private static final AutoMap<ItemStack> mList_Master_Bones = new AutoMap<>(); + + 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() { + + ItemStack aManureByprod1 = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + ItemStack aManureByprod2 = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + ItemStack aDirtDust = ItemUtils.getSimpleStack(dustDirt, 1); + + // Poop Juice to Basic Slurry + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(10)) + .itemOutputs(aDirtDust, aDirtDust, aManureByprod1, aManureByprod1, aManureByprod1, aManureByprod1) + .outputChances(2000, 2000, 500, 500, 250, 250) + .fluidInputs(FluidUtils.getFluidStack(PoopJuice, 1000)) + .fluidOutputs(FluidUtils.getFluidStack(ManureSlurry, 250)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + // More Efficient way to get byproducts, less Slurry + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(20)) + .itemOutputs(aDirtDust, aDirtDust, aManureByprod1, aManureByprod1, aManureByprod2, aManureByprod2) + .outputChances(4000, 3000, 1250, 1250, 675, 675) + .fluidInputs(FluidUtils.getFluidStack(PoopJuice, 1000)) + .fluidOutputs(FluidUtils.getFluidStack(ManureSlurry, 50)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_MV / 2) + .addTo(centrifugeRecipes); + } + + private static void addAdvancedSlurryRecipes() { + + ItemStack aCircuit = GT_Utility.getIntegratedCircuit(10); + ItemStack aBone; + ItemStack aMeat; + ItemStack aEmptyCells = Materials.Empty.getCells(2); + ItemStack aInputCells = ItemUtils.getItemStackOfAmountFromOreDict("cellRawAnimalWaste", 2); + FluidStack aOutput = FluidUtils.getFluidStack(FertileManureSlurry, 1000); + + for (FluidStack aBloodStack : mBloodFluids) { + for (ItemStack aBoneStack : mList_Master_Bones) { + aBone = ItemUtils.getSimpleStack(aBoneStack, 2); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + // Poop Juice to Fertile Slurry + GT_Values.RA.stdBuilder() + .itemInputs(aCircuit, aBone, aMeat, aInputCells) + .itemOutputs(aEmptyCells) + .fluidInputs(aBloodStack) + .fluidOutputs(aOutput) + .duration(8 * SECONDS) + .eut(TierEU.RECIPE_MV / 2) + .addTo(mixerRecipes); + } + } + } + } + + private static void addBasicOrganiseFertRecipes() { + FluidStack aInputFluid = FluidUtils.getFluidStack(ManureSlurry, 1000); + ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 3); + ItemStack aPeat; + ItemStack aMeat; + for (ItemStack aPeatStack : mPeat) { + aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + GT_Values.RA.stdBuilder() + .itemInputs(aPeat, aMeat) + .itemOutputs(aOutputDust) + .fluidInputs(aInputFluid) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(UniversalChemical); + } + aPeat = ItemUtils.getSimpleStack(aPeatStack, 2); + for (ItemStack aMeatStack : mList_Master_FruitVege) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 9); + GT_Values.RA.stdBuilder() + .itemInputs(aPeat, aMeat) + .itemOutputs(aOutputDust) + .fluidInputs(aInputFluid) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(UniversalChemical); + } + } + } + + private static void addAdvancedOrganiseFertRecipes() { + FluidStack aInputFluid = FluidUtils.getFluidStack(FertileManureSlurry, 1000); + ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 7); + ItemStack aPeat; + ItemStack aMeat; + for (ItemStack aPeatStack : mPeat) { + aPeat = ItemUtils.getSimpleStack(aPeatStack, 5); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 7); + GT_Values.RA.stdBuilder() + .itemInputs(aPeat, aMeat) + .itemOutputs(aOutputDust) + .fluidInputs(aInputFluid) + .duration(10 * SECONDS) + .eut(140) + .addTo(UniversalChemical); + } + aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); + for (ItemStack aMeatStack : mList_Master_FruitVege) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 12); + GT_Values.RA.stdBuilder() + .itemInputs(aPeat, aMeat) + .itemOutputs(aOutputDust) + .fluidInputs(aInputFluid) + .duration(5 * SECONDS) + .eut(140) + .addTo(UniversalChemical); + } + } + } + + public static ItemStack aFertForestry; + public static ItemStack aFertIC2; + + private static void addMiscRecipes() { + + ItemStack aDustOrganicFert = ItemUtils.getSimpleStack(dustOrganicFertilizer, 1); + ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); + + // Dehydrate Organise Fert to Normal Fert. + + /* + * Forestry Support + */ + if (Forestry.isModLoaded()) { + 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 aForestryFert) { + aFertForestry = ItemUtils.getSimpleStack((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 + */ + 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, aManureByprod }, + new int[] { 10000, 2000, 2000 }, + 20 * 20, + 240); + + // Dirt Production + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(dustDirt, 9)) + .itemOutputs(ItemUtils.getSimpleStack(Blocks.dirt)) + .duration(2 * SECONDS) + .eut(8) + .addTo(compressorRecipes); + + // Centrifuge Byproducts + + // Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(aManureByprod, 4), GT_Utility.getIntegratedCircuit(20)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Phosphorus, 2L), + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Calcium, 2L), + GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Copper, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Carbon, 1L), + ItemUtils.getSimpleStack(dustDirt, 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAmmoniumNitrate", 1)) + .outputChances(2500, 2500, 750, 1000, 5000, 250) + .fluidInputs(Materials.SulfuricAcid.getFluid(250)) + .fluidOutputs(FluidUtils.getFluidStack("sulfuricapatite", 50)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_MV / 2) + .addTo(centrifugeRecipes); + + // Add Fuel Usages + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(PoopJuice, 1000), 12); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(ManureSlurry, 1000), 24); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(FertileManureSlurry, 1000), 32); + + // Red Slurry / Tailings Processing + GT_Values.RA.stdBuilder() + .itemInputs(CI.getNumberedBioCircuit(10)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Iron, 1L), + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Copper, 1L), + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Tin, 1L), + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Sulfur, 1L), + GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Nickel, 1L), + GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Lead, 1L)) + .outputChances(3000, 3000, 2000, 2000, 1000, 1000) + .fluidInputs(FluidUtils.getFluidStack(AgriculturalChem.RedMud, 1000)) + .fluidOutputs(Materials.Water.getFluid(500)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + } + + @Override + public String errorMessage() { + return "Failed to generate recipes for AgroChem."; + } + + @Override + public boolean generateRecipes() { + if (mBloodFluids.isEmpty()) { + Logger.INFO("Could not find, nor create Blood fluid. Unable to add recipes."); + return false; + } + + // Organise OreDict + processAllOreDict(); + + // Slurry Production + addBasicSlurryRecipes(); + addAdvancedSlurryRecipes(); + + // Organic Fert. Production + addBasicOrganiseFertRecipes(); + addAdvancedOrganiseFertRecipes(); + + addMiscRecipes(); + + BioRecipes.init(); + + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/CoalTar.java b/src/main/java/gtPlusPlus/core/item/chemistry/CoalTar.java new file mode 100644 index 0000000000..1fafbb5088 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/chemistry/CoalTar.java @@ -0,0 +1,319 @@ +package gtPlusPlus.core.item.chemistry; + +import static gregtech.api.recipe.RecipeMaps.distillationTowerRecipes; +import static gregtech.api.recipe.RecipeMaps.distilleryRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeConstants.UniversalChemical; +import static gtPlusPlus.api.recipe.GTPPRecipeMaps.chemicalDehydratorRecipes; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.lib.CORE; +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; + +public class CoalTar extends ItemPackage { + + public static Fluid Coal_Gas; + public static Fluid Coal_Oil; + public static Fluid Ethylene; + public static Fluid Ethylbenzene; + public static Fluid Anthracene; + public static Fluid Toluene; + public static Fluid Coal_Tar; + public static Fluid Coal_Tar_Oil; + public static Fluid Sulfuric_Coal_Tar_Oil; + public static Fluid Naphthalene; + + public static void recipeCreateEthylene() { + + FluidStack bioEth1 = FluidUtils.getFluidStack("fluid.bioethanol", 1000); + FluidStack bioEth2 = FluidUtils.getFluidStack("bioethanol", 1000); + + // C2H6O = C2H4 + H2O + if (bioEth1 != null) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(17), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1) }, + bioEth1, + FluidUtils.getWater(1000), + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("cellEthylene", 1) }, + new int[] { 10000 }, + 120 * 20, + 80); + } + + if (bioEth2 != null) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(18), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1) }, + bioEth2, + FluidUtils.getWater(1000), + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("cellEthylene", 1) }, + new int[] { 10000 }, + 120 * 20, + 80); + } + } + + public static void recipeCreateBenzene() { + // C7H8 + 2H = CH4 + C6H6 + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Toluene.getCells(1)) + .itemOutputs(Materials.Benzene.getCells(1)) + .fluidInputs(Materials.Hydrogen.getGas(2000)) + .fluidOutputs(Materials.Methane.getGas(1000)) + .duration(10 * SECONDS) + .eut(90) + .noOptimize() + .addTo(chemicalDehydratorRecipes); + } + + public static void recipeCreateEthylbenzene() { + // C2H4 + C6H6 = C8H10 + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellEthylene", 2), + ItemUtils.getGregtechCircuit(1), + FluidUtils.getFluidStack("benzene", 2000), + FluidUtils.getFluidStack("fluid.ethylbenzene", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + 300); + + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellBenzene", 2), + ItemUtils.getGregtechCircuit(1), + FluidUtils.getFluidStack("ethylene", 2000), + FluidUtils.getFluidStack("fluid.ethylbenzene", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + 300); + } + + public static void recipeCoalToCoalTar() { + // Charcoal + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 32L), + 8, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDirt", 2), + FluidUtils.getFluidStack("fluid.coaltar", 800), + 15, + 120); + // Lignite + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Lignite, 16L), + 8, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDarkAsh", 2), + FluidUtils.getFluidStack("fluid.coaltar", 800), + 45, + 60); + + // Coal + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 12L), + 8, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDarkAsh", 2), + FluidUtils.getFluidStack("fluid.coaltar", 2200), + 30, + 120); + + // Coke + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 8), + 8, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallAsh", 3), + FluidUtils.getFluidStack("fluid.coaltar", 3400), + 15, + 240); + } + + private static void recipeCoalTarToCoalTarOil() { + // v - Distill (60% Tar oil/15% Naphtha/20% Ethylbenzene/5% Anthracene) +60% Kerosene + // Create Coal Tar Oil + + FluidStack[] distOutputs = new FluidStack[] { FluidUtils.getFluidStack("fluid.coaltaroil", 600), + FluidUtils.getFluidStack("liquid_naphtha", 150), FluidUtils.getFluidStack("fluid.ethylbenzene", 200), + FluidUtils.getFluidStack("fluid.anthracene", 50), FluidUtils.getFluidStack("fluid.kerosene", 600) }; + for (int i = 0; i < distOutputs.length; i++) { + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(i + 1)) + .fluidInputs(FluidUtils.getFluidStack("fluid.coaltar", 1000)) + .fluidOutputs(distOutputs[i]) + .duration(30 * SECONDS) + .eut(64) + .addTo(distilleryRecipes); + } + GT_Values.RA.stdBuilder() + .fluidInputs(FluidUtils.getFluidStack("fluid.coaltar", 1000)) + .fluidOutputs(distOutputs) + .duration(15 * SECONDS) + .eut(256) + .addTo(distillationTowerRecipes); + } + + private static void recipeCoalTarOilToSulfuricOilToNaphthalene() { + // SulfuricCoalTarOil + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 8), + ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricAcid", 8), + null, + null, + ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 16), + 20 * 16); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(6), // Circuit + FluidUtils.getFluidStack("fluid.sulfuriccoaltaroil", 1000), // aInput + FluidUtils.getFluidStack("fluid.naphthalene", 1000), // aOutput + 1200, // aDuration + 30, // aEUt + false // Hidden? + ); + } + + private static void recipeNaphthaleneToPhthalicAcid() { + // SulfuricCoalTarOil + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Lithium.getDust(5)) + .fluidInputs(FluidUtils.getFluidStack(Naphthalene, 2000)) + .fluidOutputs(Materials.PhthalicAcid.getFluid(2500)) + .eut(30) + .duration(16 * SECONDS) + .noOptimize() + .addTo(UniversalChemical); + } + + private static void recipePhthalicAcidToPhthalicAnhydride() { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(15) }, + Materials.PhthalicAcid.getFluid(1000), + null, + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("dustPhthalicAnhydride", 15) }, + new int[] { 10000 }, + 60 * 20, + 120); + } + + @Override + public String errorMessage() { + return "Bad Coal Science!"; + } + + @Override + public boolean generateRecipes() { + recipeCreateEthylene(); + recipeCreateBenzene(); + recipeCreateEthylbenzene(); + + recipeCoalToCoalTar(); + recipeCoalTarToCoalTarOil(); + recipeCoalTarOilToSulfuricOilToNaphthalene(); + recipeNaphthaleneToPhthalicAcid(); + recipePhthalicAcidToPhthalicAnhydride(); + + // Burn the coal gas! + GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 96, 1); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), 64); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), 32); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), 16); + + return true; + } + + @Override + public void items() { + // v - Dehydrate at 180C+ + // Create Phthalic Anhydride + ItemUtils.generateSpecialUseDusts( + "PhthalicAnhydride", + "Phthalic Anhydride", + "C6H4(CO)2O", + Utils.rgbtoHexValue(175, 175, 175)); + + // 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 + } + + @Override + public void blocks() {} + + @Override + public void fluids() { + + // Create Coal Gas + Coal_Gas = FluidUtils + .generateFluidNonMolten("CoalGas", "Coal Gas", 500, new short[] { 48, 48, 48, 100 }, null, null); + // Ethanol + // v - Dehydrate cells to remove water + + // 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 Ethylbenzene - Ethylbenzene is produced in on a large scale by combining benzene and ethylene in an + // acid-catalyzed chemical reaction + // Use Chemical Reactor + Ethylbenzene = FluidUtils.generateFluidNonMolten( + "Ethylbenzene", + "Ethylbenzene", + 136, + new short[] { 255, 255, 255, 100 }, + null, + null); + // Create Anthracene + Anthracene = FluidUtils + .generateFluidNonMolten("Anthracene", "Anthracene", 340, new short[] { 255, 255, 255, 100 }, null, null); + // Toluene + if (!FluidUtils.doesFluidExist("liquid_toluene")) { + Toluene = FluidUtils + .generateFluidNonMolten("liquid_toluene", "Toluene", -95, new short[] { 140, 70, 20, 100 }, null, null); + } else { + Toluene = FluidUtils.getWildcardFluidStack("liquid_toluene", 1) + .getFluid(); + } + + // Create Coal Tar + Coal_Tar = FluidUtils + .generateFluidNonMolten("CoalTar", "Coal Tar", 450, new short[] { 32, 32, 32, 100 }, null, null); + // v - Distill (60% Tar oil/15% Naphtha/20% Ethylbenzene/5% Anthracene) + // Create Coal Tar Oil + Coal_Tar_Oil = FluidUtils + .generateFluidNonMolten("CoalTarOil", "Coal Tar Oil", 240, new short[] { 240, 240, 150, 100 }, null, null); + // v - Wash With Sulfuric Acid + // Create Sulfuric Coal Tar Oil + Sulfuric_Coal_Tar_Oil = FluidUtils.generateFluidNonMolten( + "SulfuricCoalTarOil", + "Sulfuric Coal Tar Oil", + 240, + new short[] { 250, 170, 12, 100 }, + null, + null); + // v - Distill (No loss, just time consuming) + // Create Naphthalene + Naphthalene = FluidUtils + .generateFluidNonMolten("Naphthalene", "Naphthalene", 115, new short[] { 210, 185, 135, 100 }, null, null); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java b/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java new file mode 100644 index 0000000000..31ea030c64 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java @@ -0,0 +1,961 @@ +package gtPlusPlus.core.item.chemistry; + +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.recipe.RecipeMaps.blastFurnaceRecipes; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeConstants.COIL_HEAT; +import static gregtech.api.util.GT_RecipeConstants.FUEL_TYPE; +import static gregtech.api.util.GT_RecipeConstants.FUEL_VALUE; +import static gtPlusPlus.api.recipe.GTPPRecipeMaps.chemicalDehydratorRecipes; + +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; + +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.TextureSet; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_RecipeConstants; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; +import gtPlusPlus.core.item.circuit.GTPP_IntegratedCircuit_Item; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MISC_MATERIALS; +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.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.plugin.agrichem.BioRecipes; +import gtPlusPlus.plugin.agrichem.block.AgrichemFluids; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + +public class GenericChem extends ItemPackage { + + /** + * Materials + */ + + // Refined PTFE + public static final Material TEFLON = new Material( + "Teflon", + MaterialState.SOLID, + TextureSet.SET_SHINY, + new short[] { 75, 45, 75 }, + 330, + 640, + -1, + -1, + false, + null, + 0, + new MaterialStack(NONMATERIAL.PTFE, 75), + new MaterialStack(NONMATERIAL.PLASTIC, 15), + new MaterialStack(ELEMENT.getInstance().CARBON, 5), + new MaterialStack(ELEMENT.getInstance().SODIUM, 5)); + + /** + * Fluids + */ + public static Fluid Benzene; + + public static Fluid NitroBenzene; + public static Fluid Aniline; + public static Fluid Polyurethane; + public static Fluid Phenol; // https://en.wikipedia.org/wiki/Phenol#Uses + public static Fluid Cyclohexane; // https://en.wikipedia.org/wiki/Cyclohexane + public static Fluid Cyclohexanone; // https://en.wikipedia.org/wiki/Cyclohexanone + public static Fluid Cadaverine; // https://en.wikipedia.org/wiki/Cadaverine + public static Fluid Putrescine; // https://en.wikipedia.org/wiki/Putrescine + public static Fluid BoricAcid; + public static Fluid HydrochloricAcid; + + public static Fluid Ethylanthraquinone2; + public static Fluid Ethylanthrahydroquinone2; + public static Fluid Hydrogen_Peroxide; + public static Fluid Lithium_Peroxide; + public static Fluid Carbon_Disulfide; + + /** + * Items + */ + + // Phenol Byproducts + + public static ItemGenericChemBase mGenericChemItem1; + public static Item mAdvancedCircuit; + + private ItemStack mCatalystCarrier; + + public static ItemStack mRedCatalyst; + public static ItemStack mYellowCatalyst; + public static ItemStack mBlueCatalyst; + public static ItemStack mOrangeCatalyst; + public static ItemStack mPurpleCatalyst; + public static ItemStack mBrownCatalyst; + public static ItemStack mPinkCatalyst; + public static ItemStack mFormaldehydeCatalyst; + public static ItemStack mSolidAcidCatalyst; + public static ItemStack mInfiniteMutationCatalyst; + + // QFT Catalysts + public static ItemStack mPlatinumGroupCatalyst; + public static ItemStack mPlasticPolymerCatalyst; + public static ItemStack mRubberPolymerCatalyst; + public static ItemStack mAdhesionPromoterCatalyst; + public static ItemStack mTitaTungstenIndiumCatalyst; + public static ItemStack mRadioactivityCatalyst; + public static ItemStack mRareEarthGroupCatalyst; + public static ItemStack mLimpidWaterCatalyst; + public static ItemStack mSimpleNaquadahCatalyst; + public static ItemStack mAdvancedNaquadahCatalyst; + public static ItemStack mRawIntelligenceCatalyst; + public static ItemStack mParticleAccelerationCatalyst; + public static ItemStack mUltimatePlasticCatalyst; + public static ItemStack mBiologicalIntelligenceCatalyst; + public static ItemStack mFlawlessWaterCatalyst; + public static ItemStack TemporalHarmonyCatalyst; + public static ItemStack mSynchrotronCapableCatalyst; + public static ItemStack mAlgagenicGrowthPromoterCatalyst; + + public static ItemStack mMillingBallAlumina; + public static ItemStack mMillingBallSoapstone; + + public static ItemStack mSodiumEthoxide; + public static ItemStack mSodiumEthylXanthate; + public static ItemStack mPotassiumEthylXanthate; + public static ItemStack mPotassiumHydroxide; + + @Override + public void items() { + + MaterialGenerator.generate(TEFLON, false); + + mGenericChemItem1 = new ItemGenericChemBase(); + mAdvancedCircuit = new GTPP_IntegratedCircuit_Item("T3RecipeSelector", "science/general/AdvancedCircuit"); + GregtechItemList.Circuit_T3RecipeSelector.set(mAdvancedCircuit); + + registerItemStacks(); + registerOreDict(); + + GregtechItemList.Milling_Ball_Alumina.set(mMillingBallAlumina); + GregtechItemList.Milling_Ball_Soapstone.set(mMillingBallSoapstone); + } + + 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); + mPinkCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 6, 1); + mMillingBallAlumina = ItemUtils.simpleMetaStack(mGenericChemItem1, 7, 1); + mMillingBallSoapstone = ItemUtils.simpleMetaStack(mGenericChemItem1, 8, 1); + mSodiumEthoxide = ItemUtils.simpleMetaStack(mGenericChemItem1, 9, 1); + mSodiumEthylXanthate = ItemUtils.simpleMetaStack(mGenericChemItem1, 10, 1); + mPotassiumEthylXanthate = ItemUtils.simpleMetaStack(mGenericChemItem1, 11, 1); + mPotassiumHydroxide = ItemUtils.simpleMetaStack(mGenericChemItem1, 12, 1); + mFormaldehydeCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 13, 1); + mSolidAcidCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 14, 1); + mInfiniteMutationCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 15, 1); + + // QFT Catalysts + mPlatinumGroupCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 16, 1); + mPlasticPolymerCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 17, 1); + mRubberPolymerCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 18, 1); + mAdhesionPromoterCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 19, 1); + mTitaTungstenIndiumCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 20, 1); + mRadioactivityCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 21, 1); + mRareEarthGroupCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 22, 1); + mSimpleNaquadahCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 23, 1); + mAdvancedNaquadahCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 24, 1); + mRawIntelligenceCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 25, 1); + mUltimatePlasticCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 26, 1); + mBiologicalIntelligenceCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 27, 1); + TemporalHarmonyCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 28, 1); + mLimpidWaterCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 29, 1); + mFlawlessWaterCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 30, 1); + mParticleAccelerationCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 31, 1); + mSynchrotronCapableCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 32, 1); + mAlgagenicGrowthPromoterCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 33, 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"); + ItemUtils.addItemToOreDictionary(mPinkCatalyst, "catalystPlatinumRhodium"); + ItemUtils.addItemToOreDictionary(mMillingBallAlumina, "millingballAlumina"); + ItemUtils.addItemToOreDictionary(mMillingBallSoapstone, "millingballSoapstone"); + ItemUtils.addItemToOreDictionary(mSodiumEthoxide, "dustSodiumEthoxide"); + ItemUtils.addItemToOreDictionary(mSodiumEthylXanthate, "dustSodiumEthylXanthate"); + ItemUtils.addItemToOreDictionary(mPotassiumEthylXanthate, "dustPotassiumEthylXanthate"); + ItemUtils.addItemToOreDictionary(mPotassiumHydroxide, "dustPotassiumHydroxide"); + ItemUtils.addItemToOreDictionary(mFormaldehydeCatalyst, "catalystFormaldehyde"); + ItemUtils.addItemToOreDictionary(mSolidAcidCatalyst, "catalystSolidAcid"); + ItemUtils.addItemToOreDictionary(mInfiniteMutationCatalyst, "catalystInfiniteMutation"); + ItemUtils.addItemToOreDictionary(mPlatinumGroupCatalyst, "catalystPlatinumGroup"); + ItemUtils.addItemToOreDictionary(mPlasticPolymerCatalyst, "catalystPlasticPolymer"); + ItemUtils.addItemToOreDictionary(mRubberPolymerCatalyst, "catalystRubberPolymer"); + ItemUtils.addItemToOreDictionary(mAdhesionPromoterCatalyst, "catalystAdhesionPromoter"); + ItemUtils.addItemToOreDictionary(mTitaTungstenIndiumCatalyst, "catalystTitaTungstenIndium"); + ItemUtils.addItemToOreDictionary(mRadioactivityCatalyst, "catalystRadioactivity"); + ItemUtils.addItemToOreDictionary(mRareEarthGroupCatalyst, "catalystRareEarthGroup"); + ItemUtils.addItemToOreDictionary(mSimpleNaquadahCatalyst, "catalystSimpleNaquadah"); + ItemUtils.addItemToOreDictionary(mAdvancedNaquadahCatalyst, "catalystAdvancedNaquadah"); + ItemUtils.addItemToOreDictionary(mRawIntelligenceCatalyst, "catalystRawIntelligence"); + ItemUtils.addItemToOreDictionary(mUltimatePlasticCatalyst, "catalystUltimatePlastic"); + ItemUtils.addItemToOreDictionary(mBiologicalIntelligenceCatalyst, "catalystBiologicalIntelligence"); + ItemUtils.addItemToOreDictionary(TemporalHarmonyCatalyst, "catalystTemporalHarmony"); + ItemUtils.addItemToOreDictionary(mLimpidWaterCatalyst, "catalystLimpidWater"); + ItemUtils.addItemToOreDictionary(mFlawlessWaterCatalyst, "catalystFlawlessWater"); + ItemUtils.addItemToOreDictionary(mParticleAccelerationCatalyst, "catalystParticleAcceleration"); + ItemUtils.addItemToOreDictionary(mSynchrotronCapableCatalyst, "catalystSynchrotronCapable"); + ItemUtils.addItemToOreDictionary(mAlgagenicGrowthPromoterCatalyst, "catalystAlgagenicGrowthPromoter"); + } + + @Override + public void blocks() {} + + @Override + public void fluids() { + + if (!FluidRegistry.isFluidRegistered("benzene")) { + Benzene = FluidUtils + .generateFluidNoPrefix("benzene", "Benzene", 278, new short[] { 100, 70, 30, 100 }, true); + } else { + Benzene = FluidRegistry.getFluid("benzene"); + } + + NitroBenzene = FluidUtils + .generateFluidNoPrefix("nitrobenzene", "Nitrobenzene", 278, new short[] { 70, 50, 40, 100 }, true); + + Aniline = FluidUtils.generateFluidNoPrefix("aniline", "Aniline", 266, new short[] { 100, 100, 30, 100 }, true); + + BoricAcid = FluidUtils + .generateFluidNoPrefix("boricacid", "Boric Acid", 278, new short[] { 90, 30, 120, 100 }, true); + + Polyurethane = FluidUtils + .generateFluidNoPrefix("polyurethane", "Polyurethane", 350, new short[] { 100, 70, 100, 100 }, true); + + if (!FluidRegistry.isFluidRegistered("phenol")) { + Phenol = FluidUtils.generateFluidNoPrefix("phenol", "Phenol", 313, new short[] { 100, 70, 30, 100 }, true); + } else { + Phenol = FluidRegistry.getFluid("phenol"); + } + + // Use GT's if it exists, else make our own. + if (FluidRegistry.isFluidRegistered("hydrochloricacid_gt5u")) { + HydrochloricAcid = FluidRegistry.getFluid("hydrochloricacid_gt5u"); + } else { + HydrochloricAcid = FluidUtils.generateFluidNoPrefix( + "hydrochloricacid", + "Hydrochloric Acid", + 285, + new short[] { 183, 200, 196, 100 }, + true); + } + + Cyclohexane = FluidUtils + .generateFluidNoPrefix("cyclohexane", "Cyclohexane", 32 + 175, new short[] { 100, 70, 30, 100 }, true); + Cyclohexanone = FluidUtils + .generateFluidNoPrefix("cyclohexanone", "Cyclohexanone", 32 + 175, new short[] { 100, 70, 30, 100 }, true); + + 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); + + Carbon_Disulfide = FluidUtils + .generateFluidNoPrefix("CarbonDisulfide", "Carbon Disulfide", 350, new short[] { 175, 175, 175, 100 }); + } + + @Override + public String errorMessage() { + return "Failed to generate recipes for GenericChem."; + } + + @Override + public boolean generateRecipes() { + + recipeAdvancedChip(); + recipeCatalystRed(); + recipeCatalystYellow(); + recipeCatalystBlue(); + recipeCatalystOrange(); + recipeCatalystPurple(); + recipeCatalystBrown(); + recipeCatalystPink(); + recipeCatalystFormaldehyde(); + recipeCatalystSolidAcid(); + recipeCatalystInfiniteMutation(); + + recipeGrindingBallAlumina(); + recipeGrindingBallSoapstone(); + + recipeNitroBenzene(); + recipeAniline(); + recipeCadaverineAndPutrescine(); + recipeCyclohexane(); + recipeCyclohexanone(); + + recipe2Ethylanthraquinone(); + recipe2Ethylanthrahydroquinone(); + recipeHydrogenPeroxide(); + recipeLithiumHydroperoxide(); + recipeLithiumPeroxide(); + + recipeSodiumEthoxide(); + recipeCarbonDisulfide(); + recipeEthylXanthates(); + recipePotassiumHydroxide(); + + recipeMutatedLivingSolder(); + + registerFuels(); + + return true; + } + + private void recipeSodiumEthoxide() { + // C2H5OH + Na → C2H5ONa + H + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(16), ELEMENT.getInstance().SODIUM.getDust(1) }, + new FluidStack[] { Materials.Ethanol.getFluid(1000) }, + new ItemStack[] { ItemUtils.getSimpleStack(mSodiumEthoxide, 9) }, + new FluidStack[] { ELEMENT.getInstance().HYDROGEN.getFluidStack(1000) }, + 20 * 20, + 120, + 2); + } + + private void recipePotassiumHydroxide() { + // Ca(OH)2 + K2O + CO2 → CaCO3 + 2 KOH + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(18), Materials.Potash.getDust(3), + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumHydroxide", 5), }, + new FluidStack[] { Materials.CarbonDioxide.getGas(1000) }, + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumCarbonate", 5), + ItemUtils.getSimpleStack(mPotassiumHydroxide, 6) }, + new FluidStack[] {}, + 20 * 30, + 120, + 2); + } + + private void recipeEthylXanthates() { + + // Potassium ethyl xanthate - CH3CH2OH + CS2 + KOH → C3H5KOS2 + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(17), ItemUtils.getSimpleStack(mPotassiumHydroxide, 3), }, + new FluidStack[] { Materials.Ethanol.getFluid(1000), FluidUtils.getFluidStack(Carbon_Disulfide, 1000), }, + new ItemStack[] { ItemUtils.getSimpleStack(mPotassiumEthylXanthate, 12) }, + new FluidStack[] { FluidUtils.getWater(1000) }, + 20 * 60, + 120, + 4); + + // Sodium ethyl xanthate - CH3CH2ONa + CS2 → CH3CH2OCS2Na + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(17), ItemUtils.getSimpleStack(mSodiumEthoxide, 9) }, + new FluidStack[] { FluidUtils.getFluidStack(Carbon_Disulfide, 1000), }, + new ItemStack[] { ItemUtils.getSimpleStack(mSodiumEthylXanthate, 12) }, + new FluidStack[] {}, + 20 * 60, + 120, + 4); + } + + private void recipeCarbonDisulfide() { + + GT_Values.RA.stdBuilder() + .itemInputs( + ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 8), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sulfur, 16L)) + .itemOutputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 1L)) + .fluidOutputs(FluidUtils.getFluidStack(Carbon_Disulfide, 4000)) + .duration(10 * MINUTES) + .eut(TierEU.RECIPE_LV) + .metadata(COIL_HEAT, 1500) + .addTo(blastFurnaceRecipes); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(20), ItemUtils.getSimpleStack(mBrownCatalyst, 0), + ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 4) }, + new FluidStack[] { FluidUtils.getFluidStack(CoalTar.Coal_Gas, 1000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Carbon_Disulfide, 2000) }, + 20 * 60 * 5, + 30, + 2); + } + + private void recipeMutatedLivingSolder() { + + // Endgame soldering alloy meant for the bioware circuit line and beyond. + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(GenericChem.mInfiniteMutationCatalyst, 0), + ItemList.Circuit_Chip_Biocell.get(64), ItemList.Gravistar.get(8), + Materials.InfinityCatalyst.getDust(2) }, + new FluidStack[] { FluidUtils.getFluidStack("plasma.tin", 18000), + FluidUtils.getFluidStack("plasma.bismuth", 18000), FluidUtils.getFluidStack("cryotheum", 4000) }, + new ItemStack[] {}, + new FluidStack[] { MISC_MATERIALS.MUTATED_LIVING_SOLDER.getFluidStack(144 * 280) }, + 20 * 800, + 3842160, + 7); + } + + private static void registerFuels() { + + // Burnables + + // Gas Fuels + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getItemStackOfAmountFromOreDict("cellNitrobenzene", 1)) + .metadata(FUEL_VALUE, 1600) + .metadata(FUEL_TYPE, 1) + .duration(0) + .eut(0) + .addTo(GT_RecipeConstants.Fuel); + } + + private void recipeGrindingBallAlumina() { + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(AgriculturalChem.mAlumina, 64), GT_Utility.getIntegratedCircuit(10)) + .itemOutputs(ItemUtils.getSimpleStack(mMillingBallAlumina, 8)) + .fluidInputs(FluidUtils.getFluidStack(GenericChem.Aniline, 4000)) + .duration(3 * MINUTES) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + } + + private void recipeGrindingBallSoapstone() { + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Soapstone, 32L), + GT_Utility.getIntegratedCircuit(10)) + .itemOutputs(ItemUtils.getSimpleStack(mMillingBallSoapstone, 8)) + .fluidInputs(FluidUtils.getFluidStack(AgrichemFluids.mLiquidResin, 2500)) + .duration(2 * MINUTES) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + } + + private void recipeCyclohexane() { + + // C6H6 + 6H = C6H12 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { getTierTwoChip(), ItemUtils.getSimpleStack(mBrownCatalyst, 0) }, + new FluidStack[] { FluidUtils.getFluidStack(Benzene, 1000), FluidUtils.getFluidStack("hydrogen", 6000) }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Cyclohexane, 1000), }, + 20 * 120, + 120, + 2); + } + + private void recipeCyclohexanone() { + + // C6H12 + 2O(Air) = C6H10O + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { getTierTwoChip(), ItemUtils.getSimpleStack(mBlueCatalyst, 0) }, + new FluidStack[] { FluidUtils.getFluidStack(Cyclohexane, 1000), FluidUtils.getFluidStack("air", 4000) }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Cyclohexanone, 1000), }, + 20 * 120, + 120, + 2); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { getTierTwoChip(), }, + new FluidStack[] { FluidUtils.getFluidStack(Cyclohexane, 1000), FluidUtils.getFluidStack("oxygen", 2000) }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Cyclohexanone, 1000), }, + 20 * 120, + 120, + 2); + } + + private void recipeCatalystRed() { + // Assembler Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + getTierOneChip(), + CI.getEmptyCatalyst(10), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 2L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Copper, 2L)) + .itemOutputs(ItemUtils.getSimpleStack(mRedCatalyst, 10)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(assemblerRecipes); + } + + private void recipeCatalystYellow() { + // Assembler Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + getTierThreeChip(), + CI.getEmptyCatalyst(10), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Tungsten, 4L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Nickel, 4L)) + .itemOutputs(ItemUtils.getSimpleStack(mYellowCatalyst, 10)) + .duration(1 * MINUTES) + .eut(TierEU.RECIPE_EV) + .addTo(assemblerRecipes); + } + + private void recipeCatalystBlue() { + // Assembler Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + getTierTwoChip(), + CI.getEmptyCatalyst(10), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Cobalt, 3L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Titanium, 3L)) + .itemOutputs(ItemUtils.getSimpleStack(mBlueCatalyst, 10)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + } + + private void recipeCatalystOrange() { + // Assembler Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + getTierTwoChip(), + CI.getEmptyCatalyst(10), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Vanadium, 5L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Palladium, 5L)) + .itemOutputs(ItemUtils.getSimpleStack(mOrangeCatalyst, 10)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + } + + private void recipeCatalystPurple() { + // Assembler Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + getTierFourChip(), + CI.getEmptyCatalyst(10), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iridium, 6L), + ELEMENT.getInstance().RUTHENIUM.getDust(6)) + .itemOutputs(ItemUtils.getSimpleStack(mPurpleCatalyst, 10)) + .duration(2 * MINUTES) + .eut(TierEU.RECIPE_IV) + .addTo(assemblerRecipes); + } + + private void recipeCatalystBrown() { + // Assembler Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + getTierOneChip(), + CI.getEmptyCatalyst(10), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Nickel, 4L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Aluminium, 4L)) + .itemOutputs(ItemUtils.getSimpleStack(mBrownCatalyst, 10)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(assemblerRecipes); + } + + private void recipeCatalystPink() { + // Assembler Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + getTierThreeChip(), + CI.getEmptyCatalyst(10), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Platinum, 4L), + ELEMENT.getInstance().RHODIUM.getDust(4)) + .itemOutputs(ItemUtils.getSimpleStack(mPinkCatalyst, 10)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(assemblerRecipes); + } + + private void recipeCatalystFormaldehyde() { + // Assembler Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + getTierThreeChip(), + CI.getEmptyCatalyst(4), + ItemUtils.getSimpleStack(RocketFuels.Formaldehyde_Catalyst_Dust, 8)) + .itemOutputs(ItemUtils.getSimpleStack(mFormaldehydeCatalyst, 4)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_HV / 2) + .addTo(assemblerRecipes); + } + + private void recipeCatalystSolidAcid() { + // Assembler Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + getTierThreeChip(), + CI.getEmptyCatalyst(5), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lapis, 2L)) + .itemOutputs(ItemUtils.getSimpleStack(GenericChem.mSolidAcidCatalyst, 5)) + .fluidInputs(MISC_MATERIALS.SOLID_ACID_MIXTURE.getFluidStack(1000)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(assemblerRecipes); + } + + private void recipeCatalystInfiniteMutation() { + // Assembler Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + getTierThreeChip(), + CI.getEmptyCatalyst(5), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Infinity, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Naquadria, 10L)) + .itemOutputs(ItemUtils.getSimpleStack(GenericChem.mInfiniteMutationCatalyst, 5)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_UHV) + .addTo(assemblerRecipes); + } + + private void recipeCadaverineAndPutrescine() { + + // Basic Recipe + CORE.RA.addChemicalPlantRecipe( + 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.addChemicalPlantRecipe( + 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() { + + // C6H5NO2 + 6H = C6H7N + 2H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { getTierThreeChip(), ItemUtils.getSimpleStack(mBlueCatalyst, 0) }, + new FluidStack[] { FluidUtils.getFluidStack(NitroBenzene, 1000), + FluidUtils.getFluidStack("hydrogen", 6000) }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Aniline, 1000), }, + 20 * 30, + 500, + 3); + } + + private void recipeNitroBenzene() { + + // C6H6 + HNO3 =H2SO4= C6H5NO2 +H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { getTierThreeChip(), }, + new FluidStack[] { FluidUtils.getFluidStack(Benzene, 5000), FluidUtils.getFluidStack("sulfuricacid", 1000), + FluidUtils.getFluidStack("nitricacid", 5000), FluidUtils.getDistilledWater(10000) }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(NitroBenzene, 5000), }, + 20 * 30, + 500, + 4); + } + + private void recipe2Ethylanthraquinone() { + + // C6H4(CO)2O + C6H5CH2CH3 = C6H4(CO)2C6H3CH2CH3 + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(4), + ItemUtils.getItemStackOfAmountFromOreDict("dustPhthalicAnhydride", 15), }, + new FluidStack[] { FluidUtils.getFluidStack(CoalTar.Ethylbenzene, 1000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Ethylanthraquinone2, 1000), }, + 20 * 15, + 120, + 2); + } + + private void recipe2Ethylanthrahydroquinone() { + + // C6H4(CO)2C6H3CH2CH3 + 2H = C6H4(COH)2C6H3CH2CH3 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(4), ItemUtils.getSimpleStack(mOrangeCatalyst, 0), }, + new FluidStack[] { FluidUtils.getFluidStack(Ethylanthraquinone2, 1000), + FluidUtils.getFluidStack("hydrogen", 2000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 1000), }, + 20 * 40, + 120, + 2); + } + + private void recipeLithiumPeroxide() { + // 2HLiO2 = Li2O2 + H2O2 + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 8)) + .fluidOutputs(FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000)) + .itemOutputs(ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumPeroxide", 4)) + .duration(100 * SECONDS) + .eut(120) + .noOptimize() + .addTo(chemicalDehydratorRecipes); + } + + private void recipeLithiumHydroperoxide() { + + // LiOH + H2O2 = HLiO2 + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(4), + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 3), }, + new FluidStack[] { FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000), }, + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 4), }, + new FluidStack[] {}, + 20 * 30, + 240, + 1); + + } + + private void recipeHydrogenPeroxide() { + + // C6H4(COH)2C6H3CH2CH3 + 2O =(C6H4CH)2= H2O2 + C6H4(CO)2C6H3CH2CH3 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(4), }, + new FluidStack[] { FluidUtils.getFluidStack("air", 20000), + FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 5000), + FluidUtils.getFluidStack("fluid.anthracene", 50), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Ethylanthraquinone2, 5000), + FluidUtils.getFluidStack("fluid.hydrogenperoxide", 5000), }, + 20 * 30, + 240, + 1); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(4), }, + new FluidStack[] { Materials.Oxygen.getGas(10000), FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 5000), + FluidUtils.getFluidStack("fluid.anthracene", 50), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Ethylanthraquinone2, 5000), + FluidUtils.getFluidStack("fluid.hydrogenperoxide", 5000), }, + 20 * 5, + 240, + 1); + + } + + private static ItemStack getTierOneChip() { + return CI.getNumberedAdvancedCircuit(4); + } + + private static ItemStack getTierTwoChip() { + return CI.getNumberedAdvancedCircuit(8); + } + + private static ItemStack getTierThreeChip() { + return CI.getNumberedAdvancedCircuit(12); + } + + private static ItemStack getTierFourChip() { + return CI.getNumberedAdvancedCircuit(16); + } + + private static void recipeAdvancedChip() { + GT_ModHandler.addShapelessCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 0L), + 0, + new Object[] { OrePrefixes.circuit.get(Materials.Advanced) }); + + long bits = 0; + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 1L, new Object[0]), + bits, + new Object[] { "d ", " P ", " ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 2L, new Object[0]), + bits, + new Object[] { " d ", " P ", " ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 3L, new Object[0]), + bits, + new Object[] { " d", " P ", " ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 4L, new Object[0]), + bits, + new Object[] { " ", " Pd", " ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 5L, new Object[0]), + bits, + new Object[] { " ", " P ", " d", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 6L, new Object[0]), + bits, + new Object[] { " ", " P ", " d ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 7L, new Object[0]), + bits, + new Object[] { " ", " P ", "d ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 8L, new Object[0]), + bits, + new Object[] { " ", "dP ", " ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 9L, new Object[0]), + bits, + new Object[] { "P d", " ", " ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 10L, new Object[0]), + bits, + new Object[] { "P ", " d", " ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 11L, new Object[0]), + bits, + new Object[] { "P ", " ", " d", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 12L, new Object[0]), + bits, + new Object[] { "P ", " ", " d ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 13L, new Object[0]), + bits, + new Object[] { " P", " ", " d", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 14L, new Object[0]), + bits, + new Object[] { " P", " ", " d ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 15L, new Object[0]), + bits, + new Object[] { " P", " ", "d ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 16L, new Object[0]), + bits, + new Object[] { " P", "d ", " ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 17L, new Object[0]), + bits, + new Object[] { " ", " ", "d P", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 18L, new Object[0]), + bits, + new Object[] { " ", "d ", " P", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 19L, new Object[0]), + bits, + new Object[] { "d ", " ", " P", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 20L, new Object[0]), + bits, + new Object[] { " d ", " ", " P", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 21L, new Object[0]), + bits, + new Object[] { "d ", " ", "P ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 22L, new Object[0]), + bits, + new Object[] { " d ", " ", "P ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 23L, new Object[0]), + bits, + new Object[] { " d", " ", "P ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 24L, new Object[0]), + bits, + new Object[] { " ", " d", "P ", 'P', + GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) }); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/IonParticles.java b/src/main/java/gtPlusPlus/core/item/chemistry/IonParticles.java new file mode 100644 index 0000000000..d4f5e832f6 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/chemistry/IonParticles.java @@ -0,0 +1,171 @@ +package gtPlusPlus.core.item.chemistry; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.HashMap; +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import gregtech.api.enums.Materials; +import gtPlusPlus.core.item.base.misc.BaseItemParticle; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.Utils; + +public class IonParticles extends BaseItemParticle { + + public static HashMap<String, Integer> NameToMetaMap = new HashMap<>(); + public static HashMap<Integer, String> MetaToNameMap = new HashMap<>(); + + public IonParticles() { + super("Ion", ELEMENT.NAMES.length, EnumRarity.rare); + } + + public static IIcon[] overlays = new IIcon[ELEMENT.NAMES.length]; + public static IIcon baseTexture; + + static { + // Generate Ions + int key = 0; + for (String s : ELEMENT.NAMES) { + // Map names to Meta + NameToMetaMap.put(Utils.sanitizeString(s.toLowerCase()), key); + MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase())); + Materials m = Materials.get(s); + int aColour = 0; + if (m == null) { + aColour = Utils.rgbtoHexValue(128, 128, 128); + } else { + aColour = Utils.rgbtoHexValue(m.mRGBa[0], m.mRGBa[1], m.mRGBa[2]); + } + aColourMap.put(key++, aColour); + } + } + + @Override + public String[] getAffixes() { + return new String[] { "", "" }; + } + + @Override + public String getUnlocalizedName() { + return ""; + } + + @Override + public String getUnlocalizedName(final ItemStack itemStack) { + return "item.particle.ion" + "." + ELEMENT.NAMES[itemStack.getItemDamage()]; + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Charge", 0); + tagMain.setTag("Ion", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getChargeState(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("Ion"); + if (aNBT != null) { + return aNBT.getLong("Charge"); + } + } else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setChargeState(final ItemStack aStack, final long aCharge) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("Ion"); + if (aNBT != null) { + aNBT.setLong("Charge", aCharge); + return true; + } + } + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); + } + double chargeState = getChargeState(stack); + return chargeState; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + long aCharge = getChargeState(stack); + String aState = EnumChatFormatting.YELLOW + "Unknown" + EnumChatFormatting.GRAY; + // State not set + if (aCharge == 0) { + list.add( + EnumChatFormatting.GRAY + "A " + + MetaToNameMap.get(stack.getItemDamage()) + + " Ion with an " + + aState + + " charge state"); + } else { + if (aCharge > 0) { + aState = EnumChatFormatting.GREEN + "Positive" + EnumChatFormatting.GRAY; + } else { + aState = EnumChatFormatting.RED + "Negative" + EnumChatFormatting.GRAY; + } + + list.add( + EnumChatFormatting.GRAY + "A " + + MetaToNameMap.get(stack.getItemDamage()) + + " Ion with a " + + aState + + " charge state of " + + aCharge + + ""); + } + super.addInformation(stack, player, list, bool); + } + + @Override + public void registerIcons(IIconRegister reg) { + for (int i = 0; i < IonParticles.overlays.length; i++) { + IonParticles.overlays[i] = reg.registerIcon(GTPlusPlus.ID + ":" + "ion/" + i); + } + IonParticles.baseTexture = reg.registerIcon(GTPlusPlus.ID + ":" + "ion/IonBase"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return IonParticles.overlays[meta]; + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIconFromDamageForRenderPass(int aMeta, int aPass) { + if (aPass == 0) { + return IonParticles.baseTexture; + } else { + return IonParticles.overlays[aMeta]; + } + } + + @Override + public int getRenderPasses(int metadata) { + return 2; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java b/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java new file mode 100644 index 0000000000..5a848d2616 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java @@ -0,0 +1,752 @@ +package gtPlusPlus.core.item.chemistry; + +import static gregtech.api.enums.Mods.BiomesOPlenty; +import static gregtech.api.enums.Mods.Forestry; + +import java.util.HashMap; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.data.Quad; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.item.base.ore.BaseItemMilledOre; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.NONMATERIAL; +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 gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.xmod.bop.HANDLER_BiomesOPlenty; +import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; + +public class MilledOreProcessing extends ItemPackage { + + /** + * Fluids + */ + public static Fluid SphaleriteFlotationFroth; + + public static Fluid ChalcopyriteFlotationFroth; + public static Fluid NickelFlotationFroth; + public static Fluid PlatinumFlotationFroth; + public static Fluid PentlanditeFlotationFroth; + + public static Fluid RedstoneFlotationFroth; + public static Fluid SpessartineFlotationFroth; + public static Fluid GrossularFlotationFroth; + public static Fluid AlmandineFlotationFroth; + public static Fluid PyropeFlotationFroth; + public static Fluid MonaziteFlotationFroth; + + public static Fluid PineOil; + + /** + * Items + */ + + // Zinc, Iron, Indium, Germanium + public static Item milledSphalerite; + + // Copper, Iron, Cadmium, Indium + public static Item milledChalcopyrite; + + // Nickel, Cobalt, Rhodium, Ruthenium + public static Item milledNickel; + + // Platinum, Rhodium, Selenium, Tellurium + public static Item milledPlatinum; + + // Iron, Nickel, Promethium, Hafnium + public static Item milledPentlandite; + + // Redstone, Chrome, Firestone, Dysprosium + public static Item milledRedstone; + + // Manganese, Aluminium, Osmium, Strontium + public static Item milledSpessartine; + + // Calcium, Aluminium, Tungsten, Thallium + public static Item milledGrossular; + + // Aluminium, Magnesium, Yttrium, Ytterbium + public static Item milledAlmandine; + + // Magnesium, Manganese, Borax, Rhenium + public static Item milledPyrope; + + // Erbium, Lanthanum, Praseodymium, Europium + public static Item milledMonazite; + + @Override + public void items() { + + milledSphalerite = BaseItemMilledOre.generate(Materials.Sphalerite, MaterialUtils.getVoltageForTier(6)); + milledChalcopyrite = BaseItemMilledOre.generate(Materials.Chalcopyrite, MaterialUtils.getVoltageForTier(5)); + milledNickel = BaseItemMilledOre.generate(Materials.Nickel, MaterialUtils.getVoltageForTier(5)); + milledPlatinum = BaseItemMilledOre.generate(Materials.Platinum, MaterialUtils.getVoltageForTier(6)); + milledPentlandite = BaseItemMilledOre.generate(Materials.Pentlandite, MaterialUtils.getVoltageForTier(6)); + + milledRedstone = BaseItemMilledOre.generate(Materials.Redstone, MaterialUtils.getVoltageForTier(5)); + milledSpessartine = BaseItemMilledOre.generate(Materials.Spessartine, MaterialUtils.getVoltageForTier(6)); + milledGrossular = BaseItemMilledOre.generate(Materials.Grossular, MaterialUtils.getVoltageForTier(6)); + milledAlmandine = BaseItemMilledOre.generate(Materials.Almandine, MaterialUtils.getVoltageForTier(6)); + milledPyrope = BaseItemMilledOre.generate(Materials.Pyrope, MaterialUtils.getVoltageForTier(4)); + milledMonazite = BaseItemMilledOre.generate(Materials.Monazite, MaterialUtils.getVoltageForTier(7)); + } + + @Override + public void blocks() { + // None yet + } + + @Override + public void fluids() { + + short[] aZincFrothRGB = Materials.Sphalerite.mRGBa; + SphaleriteFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.zincflotation", + "Sphalerite Froth", + 32 + 175, + new short[] { aZincFrothRGB[0], aZincFrothRGB[1], aZincFrothRGB[2], 100 }, + true); + short[] aCopperFrothRGB = Materials.Chalcopyrite.mRGBa; + ChalcopyriteFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.copperflotation", + "Chalcopyrite Froth", + 32 + 175, + new short[] { aCopperFrothRGB[0], aCopperFrothRGB[1], aCopperFrothRGB[2], 100 }, + true); + short[] aNickelFrothRGB = Materials.Nickel.mRGBa; + NickelFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.nickelflotation", + "Nickel Froth", + 32 + 175, + new short[] { aNickelFrothRGB[0], aNickelFrothRGB[1], aNickelFrothRGB[2], 100 }, + true); + short[] aPlatinumFrothRGB = Materials.Platinum.mRGBa; + PlatinumFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.platinumflotation", + "Platinum Froth", + 32 + 175, + new short[] { aPlatinumFrothRGB[0], aPlatinumFrothRGB[1], aPlatinumFrothRGB[2], 100 }, + true); + short[] aPentlanditeFrothRGB = Materials.Pentlandite.mRGBa; + PentlanditeFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.pentlanditeflotation", + "Pentlandite Froth", + 32 + 175, + new short[] { aPentlanditeFrothRGB[0], aPentlanditeFrothRGB[1], aPentlanditeFrothRGB[2], 100 }, + true); + + short[] aRedstoneFrothRGB = Materials.Redstone.mRGBa; + RedstoneFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.redstoneflotation", + "Redstone Froth", + 32 + 175, + new short[] { aRedstoneFrothRGB[0], aRedstoneFrothRGB[1], aRedstoneFrothRGB[2], 100 }, + true); + short[] aSpessartineFrothRGB = Materials.Spessartine.mRGBa; + SpessartineFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.spessartineflotation", + "Spessartine Froth", + 32 + 175, + new short[] { aSpessartineFrothRGB[0], aSpessartineFrothRGB[1], aSpessartineFrothRGB[2], 100 }, + true); + short[] aGrossularFrothRGB = Materials.Grossular.mRGBa; + GrossularFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.grossularflotation", + "Grossular Froth", + 32 + 175, + new short[] { aGrossularFrothRGB[0], aGrossularFrothRGB[1], aGrossularFrothRGB[2], 100 }, + true); + short[] aAlmandineFrothRGB = Materials.Almandine.mRGBa; + AlmandineFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.almandineflotation", + "Almandine Froth", + 32 + 175, + new short[] { aAlmandineFrothRGB[0], aAlmandineFrothRGB[1], aAlmandineFrothRGB[2], 100 }, + true); + short[] aPyropeFrothRGB = Materials.Pyrope.mRGBa; + PyropeFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.pyropeflotation", + "Pyrope Froth", + 32 + 175, + new short[] { aPyropeFrothRGB[0], aPyropeFrothRGB[1], aPyropeFrothRGB[2], 100 }, + true); + short[] aMonaziteFrothRGB = Materials.Monazite.mRGBa; + MonaziteFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.Monaziteflotation", + "Monazite Froth", + 32 + 175, + new short[] { aMonaziteFrothRGB[0], aMonaziteFrothRGB[1], aMonaziteFrothRGB[2], 100 }, + true); + + PineOil = FluidUtils + .generateFluidNoPrefix("pineoil", "Pine Oil", 32 + 175, new short[] { 250, 200, 60, 100 }, true); + } + + public MilledOreProcessing() { + super(); + Logger.INFO("Adding Ore Milling content"); + } + + private static void addMiscRecipes() { + + /* + * First 5 + */ + + // milledSphalerite + registerOreDataForMilledType( + SphaleriteFlotationFroth, + ELEMENT.getInstance().ZINC, + 180, + ELEMENT.getInstance().IRON, + 120, + ELEMENT.getInstance().INDIUM, + 64, + ELEMENT.getInstance().GERMANIUM, + 15); + // milledChalcopyrite + registerOreDataForMilledType( + ChalcopyriteFlotationFroth, + ELEMENT.getInstance().COPPER, + 180, + ELEMENT.getInstance().IRON, + 120, + ELEMENT.getInstance().CADMIUM, + 50, + ELEMENT.getInstance().INDIUM, + 10); + // milledNickel + registerOreDataForMilledType( + NickelFlotationFroth, + ELEMENT.getInstance().NICKEL, + 150, + ELEMENT.getInstance().COBALT, + 120, + ELEMENT.getInstance().RHODIUM, + 32, + ELEMENT.getInstance().RUTHENIUM, + 16); + // milledPlatinum + registerOreDataForMilledType( + PlatinumFlotationFroth, + ELEMENT.getInstance().PLATINUM, + 120, + ELEMENT.getInstance().RHODIUM, + 60, + ELEMENT.getInstance().SELENIUM, + 40, + ELEMENT.getInstance().TELLURIUM, + 10); + // milledPentlandite + registerOreDataForMilledType( + PentlanditeFlotationFroth, + ELEMENT.getInstance().IRON, + 150, + ELEMENT.getInstance().NICKEL, + 100, + ELEMENT.getInstance().PROMETHIUM, + 20, + ELEMENT.getInstance().HAFNIUM, + 10); + + /* + * Second 5 + */ + // milledRedstone + registerOreDataForMilledType( + RedstoneFlotationFroth, + NONMATERIAL.REDSTONE, + 300, + ELEMENT.getInstance().CHROMIUM, + 60, + MaterialUtils.generateMaterialFromGtENUM(Materials.Firestone), + 45, + ELEMENT.getInstance().DYSPROSIUM, + 16); + // milledSpessartine + registerOreDataForMilledType( + SpessartineFlotationFroth, + ELEMENT.getInstance().MANGANESE, + 150, + ELEMENT.getInstance().ALUMINIUM, + 90, + ELEMENT.getInstance().OSMIUM, + 30, + ELEMENT.getInstance().STRONTIUM, + 20); + // milledGrossular + registerOreDataForMilledType( + GrossularFlotationFroth, + ELEMENT.getInstance().CALCIUM, + 180, + ELEMENT.getInstance().ALUMINIUM, + 110, + ELEMENT.getInstance().TUNGSTEN, + 60, + ELEMENT.getInstance().THALLIUM, + 15); + // milledAlmandine + registerOreDataForMilledType( + AlmandineFlotationFroth, + ELEMENT.getInstance().ALUMINIUM, + 150, + ELEMENT.getInstance().MAGNESIUM, + 75, + ELEMENT.getInstance().YTTRIUM, + 25, + ELEMENT.getInstance().YTTERBIUM, + 15); + // milledPyrope + registerOreDataForMilledType( + PyropeFlotationFroth, + ELEMENT.getInstance().MAGNESIUM, + 110, + ELEMENT.getInstance().MANGANESE, + 70, + MaterialUtils.generateMaterialFromGtENUM(Materials.Borax), + 60, + ELEMENT.getInstance().RHENIUM, + 20); + // milledMonazite TODO + registerOreDataForMilledType( + MonaziteFlotationFroth, + ELEMENT.getInstance().ERBIUM, + 64, + ELEMENT.getInstance().LANTHANUM, + 32, + ELEMENT.getInstance().LUTETIUM, + 16, + ELEMENT.getInstance().EUROPIUM, + 8); + } + + @Override + public String errorMessage() { + return "Failed to generate recipes for OreMillingProc."; + } + + @Override + public boolean generateRecipes() { + addMiscRecipes(); + addPineOilExtraction(); + addFlotationRecipes1(); + addFlotationRecipes2(); + addVacuumFurnaceRecipes(); + return true; + } + + private void addVacuumFurnaceRecipes() { + int aCircuitID = 1; + + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(SphaleriteFlotationFroth, 4000) }, + getOutputsFromMap(SphaleriteFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(ChalcopyriteFlotationFroth, 4000) }, + getOutputsFromMap(ChalcopyriteFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(5), + 4500); + + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(NickelFlotationFroth, 4000) }, + getOutputsFromMap(NickelFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(5), + 4500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(PlatinumFlotationFroth, 4000) }, + getOutputsFromMap(PlatinumFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(PentlanditeFlotationFroth, 4000) }, + getOutputsFromMap(PentlanditeFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(RedstoneFlotationFroth, 4000) }, + getOutputsFromMap(RedstoneFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(5), + 4500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(SpessartineFlotationFroth, 4000) }, + getOutputsFromMap(SpessartineFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(GrossularFlotationFroth, 4000) }, + getOutputsFromMap(GrossularFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(AlmandineFlotationFroth, 4000) }, + getOutputsFromMap(AlmandineFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(PyropeFlotationFroth, 4000) }, + getOutputsFromMap(PyropeFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(4), + 3500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { CI.getNumberedCircuit(aCircuitID++) }, + new FluidStack[] { FluidUtils.getFluidStack(MonaziteFlotationFroth, 4000) }, + getOutputsFromMap(MonaziteFlotationFroth), + new FluidStack[] { FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000) }, + 20 * 120, + MaterialUtils.getVoltageForTier(7), + 7500); + } + + private void addFlotationRecipes1() { + + // Sphalerite + CORE.RA.addFlotationRecipe( + Materials.Sphalerite, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 14000), }, + new FluidStack[] { FluidUtils.getFluidStack(SphaleriteFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + + // Chalcopyrite + CORE.RA.addFlotationRecipe( + Materials.Chalcopyrite, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 12000), }, + new FluidStack[] { FluidUtils.getFluidStack(ChalcopyriteFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(5)); + + // Nickel + CORE.RA.addFlotationRecipe( + Materials.Nickel, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 25000), }, + new FluidStack[] { FluidUtils.getFluidStack(NickelFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(5)); + + // Platinum + CORE.RA.addFlotationRecipe( + Materials.Platinum, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 35000), }, + new FluidStack[] { FluidUtils.getFluidStack(PlatinumFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + + // Pentlandite + CORE.RA.addFlotationRecipe( + Materials.Pentlandite, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 14000), }, + new FluidStack[] { FluidUtils.getFluidStack(PentlanditeFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + } + + private void addFlotationRecipes2() { + + // Redstone + CORE.RA.addFlotationRecipe( + Materials.Redstone, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 13000), }, + new FluidStack[] { FluidUtils.getFluidStack(RedstoneFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(5)); + + // Spessartine + CORE.RA.addFlotationRecipe( + Materials.Spessartine, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 35000), }, + new FluidStack[] { FluidUtils.getFluidStack(SpessartineFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + + // Grossular + CORE.RA.addFlotationRecipe( + Materials.Grossular, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 28000), }, + new FluidStack[] { FluidUtils.getFluidStack(GrossularFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + + // Almandine + CORE.RA.addFlotationRecipe( + Materials.Almandine, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 18000), }, + new FluidStack[] { FluidUtils.getFluidStack(AlmandineFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(5)); + + // Pyrope + CORE.RA.addFlotationRecipe( + Materials.Pyrope, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 8000), }, + new FluidStack[] { FluidUtils.getFluidStack(PyropeFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(4)); + + // Monazite + CORE.RA.addFlotationRecipe( + Materials.Monazite, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 30000), }, + new FluidStack[] { FluidUtils.getFluidStack(MonaziteFlotationFroth, 1000) }, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + } + + private void addPineOilExtraction() { + AutoMap<ItemStack> aLogs = new AutoMap<>(); + AutoMap<ItemStack> aLeaves = new AutoMap<>(); + AutoMap<ItemStack> aSaplings = new AutoMap<>(); + AutoMap<ItemStack> aPinecones = new AutoMap<>(); + + ItemStack aCrushedPine = ItemUtils.getSimpleStack(AgriculturalChem.mCrushedPine, 1); + + aLogs.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.log_Pine)); + aLeaves.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.leaves_Pine)); + aSaplings.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Pine)); + aPinecones.add(ItemUtils.getSimpleStack(AgriculturalChem.mPinecone, 1)); + + if (BiomesOPlenty.isModLoaded()) { + aLogs.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.logs4, 0, 1)); + aLeaves.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.colorizedLeaves2, 1, 1)); + aSaplings.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.colorizedSaplings, 5, 1)); + aPinecones.add(ItemUtils.simpleMetaStack(HANDLER_BiomesOPlenty.mPineCone, 13, 1)); + } + if (Forestry.isModLoaded()) { + ItemStack aForestryLog = ItemUtils.getItemStackFromFQRN("Forestry:logs", 1); + if (aForestryLog != null) { + aForestryLog.setItemDamage(20); // Set to Pine + aLogs.add(aForestryLog); + } + ItemStack aForestryLeaves = ItemUtils.getItemStackFromFQRN("Forestry:leaves", 1); + if (aForestryLeaves != null) { + NBTUtils.setString(aForestryLeaves, "species", "forestry.treePine"); // Set to Pine + aLeaves.add(aForestryLeaves); + } + } + + for (ItemStack aLog : aLogs) { + addRecipe(aLog, ItemUtils.getSimpleStack(aCrushedPine, 16), new int[] { 10000, 7500, 5000, 2500 }, 10, 120); + } + for (ItemStack aLeaf : aLeaves) { + addRecipe(aLeaf, ItemUtils.getSimpleStack(aCrushedPine, 2), new int[] { 5000, 5000, 2500, 2500 }, 10, 30); + } + for (ItemStack aSapling : aSaplings) { + addRecipe( + aSapling, + ItemUtils.getSimpleStack(aCrushedPine, 4), + new int[] { 7500, 7500, 2500, 2500 }, + 10, + 60); + } + for (ItemStack aCone : aPinecones) { + addRecipe(aCone, ItemUtils.getSimpleStack(aCrushedPine, 1), new int[] { 7500, 7500, 5000, 2500 }, 10, 60); + } + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(16), ItemUtils.getSimpleStack(aCrushedPine, 64) }, + new FluidStack[] { FluidUtils.getSteam(5000), }, + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5) }, + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 500) }, + new int[] { 2000, 2000, 2000, 2000 }, + 20 * 60, + 120, + 3); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemUtils.getSimpleStack(aCrushedPine, 64) }, + new FluidStack[] { FluidUtils.getSuperHeatedSteam(5000), }, + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5) }, + new FluidStack[] { FluidUtils.getFluidStack(PineOil, 1500) }, + new int[] { 3000, 3000, 3000, 3000 }, + 20 * 45, + 120, + 4); + } + + public boolean addRecipe(ItemStack aInput, ItemStack aOutput1, int[] aChances, int aTime, int aEU) { + aOutput1 = GT_OreDictUnificator.get(true, aOutput1); + ItemStack aOutputs[] = new ItemStack[4]; + for (int i = 0; i < aChances.length; i++) { + aOutputs[i] = aOutput1; + } + aOutputs = cleanArray(aOutputs); + if ((GT_Utility.isStackInvalid(aInput)) + || (GT_Utility.isStackInvalid(aOutput1) || (GT_Utility.getContainerItem(aInput, false) != null))) { + return false; + } + + return CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(14), aInput }, + new FluidStack[] {}, + aOutputs, + new FluidStack[] {}, + aChances, + aTime * 20, + aEU, + 3); + } + + public static ItemStack[] cleanArray(ItemStack[] input) { + int aArraySize = input.length; + AutoMap<ItemStack> aCleanedItems = new AutoMap<>(); + for (ItemStack checkStack : input) { + if (ItemUtils.checkForInvalidItems(checkStack)) { + aCleanedItems.put(checkStack); + } + } + ItemStack[] aOutput = new ItemStack[aCleanedItems.size()]; + for (int i = 0; i < aArraySize; i++) { + ItemStack aMappedStack = aCleanedItems.get(i); + if (aMappedStack != null) { + aOutput[i] = aMappedStack; + } + } + return aOutput; + } + + private static final HashMap<String, Quad<Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>>> aMilledFluidMap = new HashMap<>(); + + public static void registerOreDataForMilledType(Fluid aMilledFluid, Materials aOutput1, int aPerc1, + Materials aOutput2, int aPerc2, Materials aOutput3, int aPerc3, Materials aOutput4, int aPerc4) { + registerOreDataForMilledType( + aMilledFluid, + MaterialUtils.generateMaterialFromGtENUM(aOutput1), + aPerc1, + MaterialUtils.generateMaterialFromGtENUM(aOutput2), + aPerc2, + MaterialUtils.generateMaterialFromGtENUM(aOutput3), + aPerc3, + MaterialUtils.generateMaterialFromGtENUM(aOutput4), + aPerc4); + } + + public static void registerOreDataForMilledType(Fluid aMilledFluid, Material aOutput1, int aPerc1, + Material aOutput2, int aPerc2, Material aOutput3, int aPerc3, Material aOutput4, int aPerc4) { + + Pair<Material, Integer> aFluidOutput1 = new Pair<>(aOutput1, aPerc1); + Pair<Material, Integer> aFluidOutput2 = new Pair<>(aOutput2, aPerc2); + Pair<Material, Integer> aFluidOutput3 = new Pair<>(aOutput3, aPerc3); + Pair<Material, Integer> aFluidOutput4 = new Pair<>(aOutput4, aPerc4); + Quad<Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>> aDataQuad = new Quad<>( + aFluidOutput1, + aFluidOutput2, + aFluidOutput3, + aFluidOutput4); + aMilledFluidMap.put(aMilledFluid.getUnlocalizedName(), aDataQuad); + } + + private static ItemStack[] getOutputsFromMap(Fluid aFluid) { + String aKey = aFluid.getUnlocalizedName(); + return getArrayFromQuad(aMilledFluidMap.get(aKey)); + } + + private static ItemStack[] getArrayFromQuad( + Quad<Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>> aData) { + AutoMap<ItemStack> aOutputs = new AutoMap<>(); + for (Object aPair : aData.values()) { + if (aPair != null && Pair.class.isInstance(aPair)) { + Pair aObj = (Pair) aPair; + Material aMat = (Material) aObj.getKey(); + int aCount = (int) aObj.getValue(); + aOutputs.addAll(getItemStackFromPair(aMat, aCount)); + } + } + ItemStack[] aRealOutputArray = new ItemStack[aOutputs.size()]; + int aIndex = 0; + for (ItemStack aStack : aOutputs) { + aRealOutputArray[aIndex++] = aStack; + } + return aRealOutputArray; + } + + private static AutoMap<ItemStack> getItemStackFromPair(Material aMat, Integer aCount) { + AutoMap<ItemStack> aOutputs = new AutoMap<>(); + if (aCount > 64) { + AutoMap<Integer> sizes = getStackSizes(aCount); + for (int aSplitSize : sizes) { + ItemStack aDustStack = aMat.getDust(aSplitSize); + aOutputs.put(aDustStack); + } + } else { + ItemStack aDustStack = aMat.getDust(aCount); + aOutputs.put(aDustStack); + } + return aOutputs; + } + + private static AutoMap<Integer> getStackSizes(int aBigSize) { + AutoMap<Integer> aSizes = new AutoMap<>(); + if (aBigSize <= 64) { + aSizes.add(aBigSize); + } else { + for (int i = aBigSize; i > 0; i -= 64) { + aSizes.add(i); + } + } + return aSizes; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/NuclearChem.java b/src/main/java/gtPlusPlus/core/item/chemistry/NuclearChem.java new file mode 100644 index 0000000000..d83b5a7cea --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/chemistry/NuclearChem.java @@ -0,0 +1,105 @@ +package gtPlusPlus.core.item.chemistry; + +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeConstants.UniversalChemical; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.util.minecraft.FluidUtils; + +public class NuclearChem extends ItemPackage { + + public static Fluid Burnt_LiFBeF2ThF4UF4; + public static Fluid Burnt_LiFBeF2ZrF4UF4; + public static Fluid Burnt_LiFBeF2ZrF4U235; + + public static Fluid Impure_LiFBeF2; + + public static Fluid GeneticMutagen; + private static boolean generateMutagenRecipe = false; + + @Override + public void items() {} + + @Override + public void blocks() {} + + @Override + public void fluids() { + // Create Used Nuclear Fuels + Burnt_LiFBeF2ThF4UF4 = FluidUtils.generateFluidNonMolten( + "BurntLiFBeF2ThF4UF4", + "Burnt LiFBeF2ThF4UF4 Salt", + 545, + new short[] { 48, 175, 48, 100 }, + null, + null); + Burnt_LiFBeF2ZrF4UF4 = FluidUtils.generateFluidNonMolten( + "BurntLiFBeF2ZrF4UF4", + "Burnt LiFBeF2ZrF4UF4 Salt", + 520, + new short[] { 48, 168, 68, 100 }, + null, + null); + Burnt_LiFBeF2ZrF4U235 = FluidUtils.generateFluidNonMolten( + "BurntLiFBeF2ZrF4U235", + "Burnt LiFBeF2ZrF4U235 Salt", + 533, + new short[] { 68, 185, 48, 100 }, + null, + null); + Impure_LiFBeF2 = FluidUtils.generateFluidNonMolten( + "ImpureLiFBeF2", + "Impure Molten Salt Base", + 533, + new short[] { 110, 75, 186, 100 }, + null, + null); + if (FluidUtils.getFluidStack("fluid.Mutagen", 1) == null) { + GeneticMutagen = FluidUtils.generateFluidNonMolten( + "GeneticMutagen", + "Genetic Mutagen", + 12, + new short[] { 22, 148, 185, 100 }, + null, + null); + generateMutagenRecipe = true; + } else { + GeneticMutagen = FluidUtils.getFluidStack("fluid.Mutagen", 1) + .getFluid(); + } + } + + @Override + public String errorMessage() { + return "Bad Nuclear Chemistry Recipes."; + } + + @Override + public boolean generateRecipes() { + if (generateMutagenRecipe) { + chemReactor_CreateMutagen(); + } + return true; + } + + private static void chemReactor_CreateMutagen() { + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.NetherStar, 2), + GT_Utility.getIntegratedCircuit(20)) + .fluidInputs(FluidRegistry.getFluidStack("mobessence", 5000)) + .fluidOutputs(FluidUtils.getFluidStack(GeneticMutagen, 8000)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(UniversalChemical); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/main/java/gtPlusPlus/core/item/chemistry/RocketFuels.java new file mode 100644 index 0000000000..3fc682e7cc --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -0,0 +1,562 @@ +package gtPlusPlus.core.item.chemistry; + +import static gregtech.api.recipe.RecipeMaps.distilleryRecipes; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.recipe.RecipeMaps.vacuumFreezerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; + +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; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.lib.CORE; +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.minecraft.MaterialUtils; + +public class RocketFuels extends ItemPackage { + + public static HashSet<String> mValidRocketFuelNames = new HashSet<>(); + public static HashMap<Integer, Fluid> mValidRocketFuels = new HashMap<>(); + + public static Fluid Oil_Heavy; + public static Fluid Diesel; + public static Fluid Kerosene; + public static Fluid RP1; + public static Fluid Nitrogen_Tetroxide; + public static Fluid Hydrazine; + public static Fluid Monomethylhydrazine; + public static Fluid Unsymmetrical_Dimethylhydrazine; + 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; + + // Rocket Fuel Mixes + public static Fluid Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide; + public static Fluid RP1_Plus_Liquid_Oxygen; + public static Fluid Dense_Hydrazine_Mix; + public static Fluid Monomethylhydrazine_Plus_Nitric_Acid; + + public static Item Ammonium_Nitrate_Dust; + public static Item Formaldehyde_Catalyst_Dust; + public static ItemStack Formaldehyde_Catalyst_Stack; + + public RocketFuels() { + super(true); + } + + public static void createKerosene() { + + FluidStack fuelA = FluidUtils.getFluidStack("diesel", 3000); + FluidStack fuelB = FluidUtils.getFluidStack("fuel", 3000); + + if (fuelA != null) { + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(23)) + .fluidInputs(fuelA) + .fluidOutputs(FluidUtils.getFluidStack(Kerosene, 1800)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV / 2) + .addTo(distilleryRecipes); + } + if (fuelA == null && fuelB != null) { + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(23)) + .fluidInputs(fuelB) + .fluidOutputs(FluidUtils.getFluidStack(Kerosene, 1800)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV / 2) + .addTo(distilleryRecipes); + } + } + + public static void createRP1() { + FluidStack fuelA = FluidUtils.getFluidStack(Kerosene, 1000); + if (fuelA != null) { + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(23)) + .fluidInputs(fuelA) + .fluidOutputs(FluidUtils.getFluidStack(RP1, 750)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(distilleryRecipes); + } + } + + public static void createNitrogenTetroxide() { + // 2HNO3 + Cu = N2O4 + H2O + CuO + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 1), + ItemUtils.getSimpleStack(GenericChem.mOrangeCatalyst, 0), }, + new FluidStack[] { FluidUtils.getFluidStack("nitricacid", 2000) }, + new ItemStack[] { Materials.CupricOxide.getDust(2), }, + new FluidStack[] { FluidUtils.getFluidStack(Nitrogen_Tetroxide, 1000), }, + new int[] { 100, 100, 50, 50 }, + 20 * 30, + MaterialUtils.getVoltageForTier(3), + 3); + } + + public static void createHydrazine() { + + // H2O2 + 2NH3 = N2H4 + 2H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(21) }, + new FluidStack[] { FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000), + FluidUtils.getFluidStack("ammonia", 2000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Hydrazine, 1000), }, + 20 * 30, + MaterialUtils.getVoltageForTier(2), + 1); + } + + public static void createMonomethylhydrazine() { + + // C + 2H + N2H4 = CH6N2 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(21), ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", 1) }, + new FluidStack[] { FluidUtils.getFluidStack("hydrogen", 2000), FluidUtils.getFluidStack(Hydrazine, 1000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Monomethylhydrazine, 1000), }, + 20 * 48, + 240, + 2); + } + + private static void createLOH() { + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1)) + .itemOutputs(ItemUtils.getItemStackOfAmountFromOreDict("cellLiquidHydrogen", 1)) + .duration(16 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(vacuumFreezerRecipes); + } + + private static void createHydratedAmmoniumNitrateSlurry() { + + // NH3 + HNO3 = NH4NO3 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(21), }, + new FluidStack[] { FluidUtils.getFluidStack("ammonia", 4000), + FluidUtils.getFluidStack("nitricacid", 4000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Hydrated_Ammonium_Nitrate_Slurry, 5184), }, + 20 * 60, + 120, + 1); + } + + private static void createAmmoniumNitrateDust() { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedCircuit(8) }, + FluidUtils.getFluidStack(Hydrated_Ammonium_Nitrate_Slurry, 8 * 144), + FluidUtils.getWater(2000), + new ItemStack[] { ItemUtils.getSimpleStack(Ammonium_Nitrate_Dust, 8) }, + new int[] { 10000 }, + 90 * 20, + 480); + } + + private static void createFormaldehyde() { + + // O + CH4O = CH2O + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(21), + ItemUtils.getSimpleStack(GenericChem.mFormaldehydeCatalyst, 0), }, + new FluidStack[] { FluidUtils.getFluidStack("oxygen", 32000), + FluidUtils.getFluidStack("methanol", 32000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Formaldehyde, 32000), }, + 20 * 90, + 120, + 1); + } + + private static void createFormaldehydeCatalyst() { + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 16L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Vanadium, 1L), + GT_Utility.getIntegratedCircuit(18)) + .itemOutputs(ItemUtils.getSimpleStack(Formaldehyde_Catalyst_Dust, 4)) + .duration(8 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + } + + private static void createUnsymmetricalDimethylhydrazine() { + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(21), + ItemUtils.getSimpleStack(GenericChem.mFormaldehydeCatalyst, 0), }, + new FluidStack[] { FluidUtils.getFluidStack("fluid.hydrazine", 2000), + FluidUtils.getFluidStack(Formaldehyde, 2000), FluidUtils.getFluidStack("hydrogen", 4000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine, 2000), + FluidUtils.getWater(2000) }, + 20 * 60, + 120, + 3); + } + + private static void addRocketFuelsToMap() { + HashMap<Integer, GT_Recipe> mRocketFuels = new LinkedHashMap<>(); + mRocketFuels.put( + 0, + new GT_Recipe( + true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] { FluidUtils.getFluidStack(RP1_Plus_Liquid_Oxygen, 1000) }, + new FluidStack[] {}, + 0, + 0, + 512)); // Fuel Value + + mRocketFuels.put( + 1, + new GT_Recipe( + true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Dense_Hydrazine_Mix, 1000) }, + new FluidStack[] {}, + 0, + 0, + 1024)); // Fuel Value + + mRocketFuels.put( + 2, + new GT_Recipe( + true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Monomethylhydrazine_Plus_Nitric_Acid, 1000) }, + new FluidStack[] {}, + 0, + 0, + 2048)); // Fuel Value + + mRocketFuels.put( + 3, + new GT_Recipe( + true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 1000) }, + new FluidStack[] {}, + 0, + 0, + 4196)); // Fuel Value + + // Add in default Diesel for the Buggy + mValidRocketFuels.put(-1, Diesel); + + mValidRocketFuelNames.add(FluidRegistry.getFluidName(Diesel)); + for (int mID : mRocketFuels.keySet()) { + GT_Recipe aFuelRecipe = mRocketFuels.get(mID); + if (aFuelRecipe != null) { + mValidRocketFuelNames.add(FluidRegistry.getFluidName(aFuelRecipe.mFluidInputs[0].getFluid())); + mValidRocketFuels.put(mID, aFuelRecipe.mFluidInputs[0].getFluid()); + GTPPRecipeMaps.rocketFuels.add(aFuelRecipe); + } + } + } + + private static void createRocketFuels() { + + // RP1_Plus_Liquid_Oxygen + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(1), }, + new FluidStack[] { FluidUtils.getFluidStack(Liquid_Oxygen, 2000), FluidUtils.getFluidStack(RP1, 500), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(RP1_Plus_Liquid_Oxygen, 1500), }, + 20 * 15, + 240, + 3); + + // Dense_Hydrazine_Mix + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(2), }, + new FluidStack[] { FluidUtils.getFluidStack(Hydrazine, 4000), FluidUtils.getFluidStack("methanol", 6000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Dense_Hydrazine_Mix, 10000), }, + 20 * 30, + 240, + 4); + + // Monomethylhydrazine_Plus_Nitric_Acid + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(3), }, + new FluidStack[] { FluidUtils.getFluidStack(Monomethylhydrazine, 2000), + FluidUtils.getFluidStack("nitricacid", 1000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack(Monomethylhydrazine_Plus_Nitric_Acid, 2000), }, + 20 * 45, + 480, + 5); + + // Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedCircuit(4), }, + new FluidStack[] { FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine, 2000), + FluidUtils.getFluidStack(Nitrogen_Tetroxide, 2000), }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 5000), }, + 20 * 60, + 480, + 6); + } + + @Override + public String errorMessage() { + return "Bad Rocket Fuel Science!"; + } + + @Override + public boolean generateRecipes() { + createKerosene(); + createRP1(); + createNitrogenTetroxide(); + createHydrazine(); + createMonomethylhydrazine(); + + createLOH(); + + createHydratedAmmoniumNitrateSlurry(); + createAmmoniumNitrateDust(); + createFormaldehyde(); + createFormaldehydeCatalyst(); + createUnsymmetricalDimethylhydrazine(); + + createRocketFuels(); + addRocketFuelsToMap(); + + return true; + } + + @Override + public void items() { + Formaldehyde_Catalyst_Dust = ItemUtils.generateSpecialUseDusts( + "FormaldehydeCatalyst", + "Formaldehyde Catalyst", + "Fe16V1", + Utils.rgbtoHexValue(25, 5, 25))[0]; + Formaldehyde_Catalyst_Stack = ItemUtils.getSimpleStack(Formaldehyde_Catalyst_Dust); + } + + @Override + public void blocks() {} + + @Override + public void fluids() { + + // Register default fluids + Diesel = MaterialUtils.getMaterial("Fuel", "Diesel") + .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", 233, new short[] { 150, 40, 150, 100 }, null, null); + CoalTar.Coal_Oil = Kerosene; + + // RP! Focket Fuel + 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", + 261, + new short[] { 170, 170, 0, 100 }, + null, + null); + + // Create Hydrazine + Hydrazine = FluidUtils + .generateFluidNonMolten("Hydrazine", "Hydrazine", 275, new short[] { 250, 250, 250, 100 }, null, null); + + // Create Monomethylhydrazine + Monomethylhydrazine = FluidUtils.generateFluidNonMolten( + "Monomethylhydrazine", + "Monomethylhydrazine", + 221, + new short[] { 125, 125, 125, 100 }, + null, + null); + + // Create Anthracene + Nitrous_Oxide = FluidUtils.generateFluidNonMolten( + "NitrousOxide", + "Nitrous Oxide", + 182, + new short[] { 255, 255, 255, 100 }, + null, + null); + + // Nos + if (!FluidUtils.doesFluidExist("NitrousOxide")) { + Nitrous_Oxide = FluidUtils + .generateFluidNoPrefix("NitrousOxide", "Nitrous Oxide", 182, new short[] { 255, 255, 255, 100 }); + } else { + Nitrous_Oxide = FluidUtils.getWildcardFluidStack("NitrousOxide", 1) + .getFluid(); + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellNitrousOxide", 1) == null) { + 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", + 216, + new short[] { 70, 210, 20, 100 }, + null, + null); + } else { + Unsymmetrical_Dimethylhydrazine = FluidUtils.getFluidStack("1,1dimethylhydrazine", 1000) + .getFluid(); + } + + // Create Hydrated_Ammonium_Nitrate_Slurry + Hydrated_Ammonium_Nitrate_Slurry = FluidUtils.generateFluidNonMolten( + "AmmoniumNitrateSlurry", + "Hydrated Ammonium Nitrate Slurry", + 450, + new short[] { 150, 75, 150, 100 }, + null, + null); + + // Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + Ammonium_Nitrate_Dust = ItemUtils.generateSpecialUseDusts( + "AmmoniumNitrate", + "Ammonium Nitrate", + "N2H4O3", + Utils.rgbtoHexValue(150, 75, 150))[0]; + + // Create Liquid_Oxygen + if (FluidUtils.getFluidStack("LiquidOxygen", 1) == null + && FluidUtils.getFluidStack("liquidoxygen", 1) == null) { + Liquid_Oxygen = FluidUtils.generateFluidNonMolten( + "LiquidOxygen", + "Liquid Oxygen", + 54, + new short[] { 75, 75, 220, 100 }, + null, + null); + } else { + if (FluidUtils.getFluidStack("LiquidOxygen", 1) != null) { + Liquid_Oxygen = FluidUtils.getFluidStack("LiquidOxygen", 1) + .getFluid(); + } else { + Liquid_Oxygen = FluidUtils.getFluidStack("liquidoxygen", 1) + .getFluid(); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellLiquidOxygen", 1) == null) { + 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", + 14, + 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", 185, new short[] { 150, 75, 150, 100 }, null, null); + + Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten( + "RocketFuelMixA", + "H8N4C2O4 Rocket Fuel", + 216, + new short[] { 50, 220, 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", + 221, + new short[] { 125, 75, 180, 100 }, + null, + null); + Dense_Hydrazine_Mix = FluidUtils.generateFluidNonMolten( + "RocketFuelMixD", + "Dense Hydrazine Fuel Mixture", + 275, + new short[] { 175, 80, 120, 100 }, + null, + null); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java b/src/main/java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java new file mode 100644 index 0000000000..1604bcb571 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java @@ -0,0 +1,156 @@ +package gtPlusPlus.core.item.chemistry; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.HashMap; +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.base.misc.BaseItemParticle; +import gtPlusPlus.core.material.Particle; +import gtPlusPlus.core.material.Particle.ElementaryGroup; +import gtPlusPlus.core.util.Utils; + +public class StandardBaseParticles extends BaseItemParticle { + + public static HashMap<String, Integer> NameToMetaMap = new HashMap<>(); + public static HashMap<Integer, String> MetaToNameMap = new HashMap<>(); + + public StandardBaseParticles() { + super("Base", aTypes.length, EnumRarity.rare); + } + + private static final String[] aTypes = new String[] { "Graviton", "Up", "Down", "Charm", "Strange", "Top", "Bottom", + "Electron", "Electron Neutrino", "Muon", "Muon Neutrino", "Tau", "Tau Neutrino", "Gluon", "Photon", "Z Boson", + "W Boson", "Higgs Boson", "Proton", "Neutron", "Lambda", "Omega", "Pion", "ETA Meson", "Unknown" }; + + public IIcon[] icons = new IIcon[aTypes.length]; + + static { + // Generate Ions + int key = 0; + + for (String s : aTypes) { + // Map names to Meta + NameToMetaMap.put(Utils.sanitizeString(s.toLowerCase()), key); + MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase())); + for (Particle o : Particle.aMap) { + int aColour = 0; + if (o.mParticleName.toLowerCase() + .equals(s.toLowerCase())) { + if (o.mParticleType == ElementaryGroup.BARYON) { + aColour = Utils.rgbtoHexValue(174, 226, 156); + aColourMap.put(key++, aColour); + } else if (o.mParticleType == ElementaryGroup.BOSON) { + if (o == Particle.HIGGS_BOSON) { + aColour = Utils.rgbtoHexValue(226, 196, 104); + aColourMap.put(key++, aColour); + } else { + aColour = Utils.rgbtoHexValue(226, 52, 66); + aColourMap.put(key++, aColour); + } + } else if (o.mParticleType == ElementaryGroup.LEPTON) { + aColour = Utils.rgbtoHexValue(126, 226, 95); + aColourMap.put(key++, aColour); + } else if (o.mParticleType == ElementaryGroup.MESON) { + aColour = Utils.rgbtoHexValue(90, 154, 226); + aColourMap.put(key++, aColour); + } else { + aColour = Utils.rgbtoHexValue(188, 61, 226); + aColourMap.put(key++, aColour); + } + } + } + } + } + + @Override + public String[] getAffixes() { + return new String[] { "", "" }; + } + + @Override + public String getUnlocalizedName() { + return ""; + } + + @Override + public String getUnlocalizedName(final ItemStack itemStack) { + return "item.particle.base" + "." + aTypes[itemStack.getItemDamage()]; + } + + public static Particle getParticle(ItemStack aStack) { + AutoMap<Particle> g = Particle.aMap; + for (Particle p : g) { + String aPartName = Utils.sanitizeString(p.mParticleName.toLowerCase()); + String expectedPart = Utils.sanitizeString(aTypes[aStack.getItemDamage()].toLowerCase()); + if (aPartName.equals(expectedPart)) { + return p; + } + } + return Particle.UNKNOWN; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + // return Utils.rgbtoHexValue(200, 200, 200); + return super.getColorFromParentClass(stack, HEX_OxFFFFFF); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + Particle aCharge = getParticle(stack); + EnumChatFormatting aColour = EnumChatFormatting.GRAY; + String aState = aColour + "Unknown" + EnumChatFormatting.RESET; + if (aCharge != null) { + String aGroup = aCharge.mParticleType.name() + .toLowerCase(); + if (aGroup.toLowerCase() + .contains("quark")) { + aColour = EnumChatFormatting.LIGHT_PURPLE; + } else if (aGroup.toLowerCase() + .contains("lepton")) { + aColour = EnumChatFormatting.GREEN; + } else if (aCharge == Particle.HIGGS_BOSON) { + aColour = EnumChatFormatting.YELLOW; + } else if (aGroup.toLowerCase() + .contains("boson")) { + aColour = EnumChatFormatting.RED; + } else if (aGroup.toLowerCase() + .contains("baryon")) { + aColour = EnumChatFormatting.BLUE; + } else if (aGroup.toLowerCase() + .contains("meson")) { + aColour = EnumChatFormatting.WHITE; + } else { + aColour = EnumChatFormatting.GRAY; + } + String aFirstLet = aGroup.substring(0, 1) + .toUpperCase(); + aGroup = aGroup.replaceFirst(aGroup.substring(0, 1), aFirstLet); + aState = aColour + aGroup + EnumChatFormatting.RESET; + list.add(EnumChatFormatting.GRAY + "Type: " + aState); + } + super.addInformation(stack, player, list, bool); + } + + @Override + public void registerIcons(IIconRegister reg) { + for (int i = 0; i < this.icons.length; i++) { + this.icons[i] = reg.registerIcon(GTPlusPlus.ID + ":" + "particle/new/" + i); + } + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java b/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java new file mode 100644 index 0000000000..8ef674ac19 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java @@ -0,0 +1,321 @@ +package gtPlusPlus.core.item.chemistry.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +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.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.item.chemistry.GenericChem; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class ItemGenericChemBase extends Item { + + protected final IIcon base[]; + + private final int aMetaSize = 34; + + /* + * 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 6 - Pink + * Metal Catalyst //PtRh 7 - Alumina Grinding Ball 8 - Soapstone Grinding Ball 9 - Sodium Ethoxide // 2 Sodium + 1 + * Ethanol | 2 C2H5OH + 2 Na → 2 C2H5ONa + H2 10 - Sodium Ethyl Xanthate //CH3CH2ONa + CS2 → CH3CH2OCS2Na 11 - + * Potassium Ethyl Xanthate //CH3CH2OH + CS2 + KOH → CH3CH2OCS2K + H2O 12 - Potassium Hydroxide // KOH 13 - + * Formaldehyde Catalyst //Fe16V1 14 - Solid Acid Catalyst //H2SO4 15 - Infinite Mutation Catalyst (for Mutated + * Living Solder) 16 - Platinum Group Catalyst (for platline skip) 17 - Plastic Polymer Catalyst (for early plastics + * skip) 18 - Rubber Polymer Catalyst (for early rubbers skip) 19 - Adhesion Promoter Catalyst (for glue/solder + * skip) 20 - Tita-Tungsten Indium Catalyst (for titanium/tungsten/indium skip) 21 - Radioactivity Catalyst (for + * thorium/uranium/plutonium skip) 22 - Rare-Earth Group Catalyst (for monaline skip) 23 - Simple Naquadah Catalyst + * (for early naqline skip) 24 - Advanced Naquadah Catalyst (for late naqline skip) 25 - Raw Intelligence Catalyst + * (for stem cells skip) 26 - Ultimate Plasticizer Catalyst (for late plastics skip) 27 - Biological Intelligence + * Catalyst (for bio cells skip) 28 - Temporal Harmonizer Catalyst (for Eternity processing) 29 - Limpid Water + * Catalyst (for early waterline skip) 30 - Flawless Water Catalyst (for advanced waterline skip) 33 - Algagenic + * Growth Promoter Catalyst (for seaweed skip) + */ + + 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 int getItemStackLimit(ItemStack stack) { + if (ItemUtils.isMillingBall(stack)) { + return 16; + } + return super.getItemStackLimit(stack); + } + + @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 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 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 = GTPlusPlus.ID + ":" + "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(); + } + + @Override + public double getDurabilityForDisplay(ItemStack aStack) { + if (ItemUtils.isMillingBall(aStack)) { + if (aStack.getTagCompound() == null || aStack.getTagCompound() + .hasNoTags()) { + createMillingBallNBT(aStack); + } + double currentDamage = getMillingBallDamage(aStack); + return currentDamage / getMaxBallDurability(aStack); + } else if (ItemUtils.isCatalyst(aStack)) { + if (aStack.getTagCompound() == null || aStack.getTagCompound() + .hasNoTags()) { + createCatalystNBT(aStack); + } + double currentDamage = getCatalystDamage(aStack); + return currentDamage / getCatalystMaxDamage(aStack); + } else { + return 1D; + } + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack aStack, EntityPlayer player, List list, boolean bool) { + boolean aHasSpecialTooltips = false; + int aMaxDamage = 0; + int aDamageSegment = 0; + int aDam = 0; + EnumChatFormatting durability = EnumChatFormatting.GRAY; + if (ItemUtils.isMillingBall(aStack)) { + list.add(EnumChatFormatting.GRAY + "Tumble Tumble Tumble"); + aMaxDamage = getMillingBallMaxDamage(aStack); + aDamageSegment = aMaxDamage / 5; + aDam = aMaxDamage - getMillingBallDamage(aStack); + aHasSpecialTooltips = true; + } + if (ItemUtils.isCatalyst(aStack)) { + list.add(EnumChatFormatting.GRAY + "Active Reaction Agent"); + aMaxDamage = getCatalystMaxDamage(aStack); + aDamageSegment = aMaxDamage / 5; + aDam = aMaxDamage - getCatalystDamage(aStack); + aHasSpecialTooltips = true; + } + if (aHasSpecialTooltips) { + if (aDam > aDamageSegment * 3) { + durability = EnumChatFormatting.GREEN; + } else if (aDam > aDamageSegment * 2) { + durability = EnumChatFormatting.YELLOW; + } else if (aDam > aDamageSegment) { + durability = EnumChatFormatting.GOLD; + } else if (aDam >= 0) { + durability = EnumChatFormatting.RED; + } + list.add(durability + "" + (aDam) + EnumChatFormatting.GRAY + " / " + aMaxDamage); + } + super.addInformation(aStack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack aStack) { + if (ItemUtils.isMillingBall(aStack)) { + int aDam = getMillingBallDamage(aStack); + if (aDam > 0) { + return true; + } + } else if (ItemUtils.isCatalyst(aStack)) { + int aDam = getCatalystDamage(aStack); + if (aDam > 0) { + return true; + } + } + return false; + } + + public static boolean createMillingBallNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagNBT.setLong("MaxDamage", getMaxBallDurability(rStack)); + tagMain.setTag("MillingBall", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static int getMillingBallDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound() + .hasNoTags()) { + createMillingBallNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("MillingBall") + .getInteger("Damage"); + } + + public static int getMillingBallMaxDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound() + .hasNoTags()) { + createMillingBallNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("MillingBall") + .getInteger("MaxDamage"); + } + + public static void setMillingBallDamage(ItemStack aStack, int aAmount) { + NBTTagCompound aNBT = aStack.getTagCompound(); + aNBT = aNBT.getCompoundTag("MillingBall"); + aNBT.setInteger("Damage", aAmount); + } + + public static int getMaxBallDurability(ItemStack aStack) { + if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallAlumina, true)) { + return 100; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallSoapstone, true)) { + return 50; + } + return 0; + } + + public static boolean createCatalystNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagNBT.setLong("MaxDamage", getMaxCatalystDurability(rStack)); + tagMain.setTag("catalyst", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static int getCatalystDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound() + .hasNoTags()) { + createCatalystNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("catalyst") + .getInteger("Damage"); + } + + public static int getCatalystMaxDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound() + .hasNoTags()) { + createCatalystNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("catalyst") + .getInteger("MaxDamage"); + } + + public static void setCatalystDamage(ItemStack aStack, int aAmount) { + NBTTagCompound aNBT = aStack.getTagCompound(); + aNBT = aNBT.getCompoundTag("catalyst"); + aNBT.setInteger("Damage", aAmount); + } + + public static int getMaxCatalystDurability(ItemStack aStack) { + return 50; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/circuit/GTPP_IntegratedCircuit_Item.java b/src/main/java/gtPlusPlus/core/item/circuit/GTPP_IntegratedCircuit_Item.java new file mode 100644 index 0000000000..11bbac53a3 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/circuit/GTPP_IntegratedCircuit_Item.java @@ -0,0 +1,213 @@ +package gtPlusPlus.core.item.circuit; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.BiFunction; +import java.util.function.Predicate; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.Constants; +import net.minecraftforge.common.util.FakePlayer; + +import org.apache.commons.lang3.tuple.Pair; + +import com.gtnewhorizons.modularui.api.UIInfos; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.INetworkUpdatableItem; +import gregtech.api.net.GT_Packet_UpdateItem; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; +import gregtech.common.gui.modularui.uifactory.SelectItemUIFactory; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class GTPP_IntegratedCircuit_Item extends Item implements INetworkUpdatableItem { + + private final List<ItemStack> ALL_VARIANTS = new ArrayList<>(); + + private final String iconLocation; + protected final IIcon[] iconDamage = new IIcon[25]; + + public GTPP_IntegratedCircuit_Item(String unlocalizedName, String iconLocation) { + this.setHasSubtypes(true); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + this.setUnlocalizedName(unlocalizedName); + this.iconLocation = iconLocation; + GameRegistry.registerItem(this, this.getUnlocalizedName()); + ALL_VARIANTS.add(new ItemStack(this, 0, 0)); + for (int i = 1; i <= 24; i++) { + ItemStack aStack = new ItemStack(this, 0, i); + ALL_VARIANTS.add(aStack); + } + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + try { + aList.add("Configuration == " + aStack.getItemDamage()); + aList.add( + GT_LanguageManager.addStringLocalization( + new StringBuilder().append(getUnlocalizedName()) + .append(".tooltip.0") + .toString(), + "Right click to reconfigure")); + aList.add( + GT_LanguageManager.addStringLocalization( + new StringBuilder().append(getUnlocalizedName()) + .append(".tooltip.1") + .toString(), + "Needs a screwdriver or circuit programming tool")); + } 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 void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { + aList.add(ItemUtils.simpleMetaStack(aItem, 0, 1)); + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public void registerIcons(final IIconRegister u) { + for (int i = 0; i < iconDamage.length; i++) { + this.iconDamage[i] = u.registerIcon(GTPlusPlus.ID + ":" + iconLocation + "/" + i); + } + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.iconDamage[MathUtils.balance(meta, 0, 24)]; + } + + @Override + public boolean receive(ItemStack stack, EntityPlayerMP player, NBTTagCompound tag) { + int meta = tag.hasKey("meta", Constants.NBT.TAG_BYTE) ? tag.getByte("meta") : -1; + if (meta < 0 || meta > 24) return true; + + if (!player.capabilities.isCreativeMode) { + Pair<Integer, BiFunction<ItemStack, EntityPlayerMP, ItemStack>> toolIndex = findConfiguratorInInv(player); + if (toolIndex == null) return true; + + ItemStack[] mainInventory = player.inventory.mainInventory; + mainInventory[toolIndex.getKey()] = toolIndex.getValue() + .apply(mainInventory[toolIndex.getKey()], player); + } + stack.setItemDamage(meta); + + return true; + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + // nothing on server side or fake player + if (player instanceof FakePlayer || !world.isRemote) return stack; + // check if any screwdriver + ItemStack configuratorStack; + if (player.capabilities.isCreativeMode) { + configuratorStack = null; + } else { + Pair<Integer, ?> configurator = findConfiguratorInInv(player); + if (configurator == null) { + int count; + try { + count = Integer + .parseInt(StatCollector.translateToLocal("GT5U.item.programmed_circuit.no_screwdriver.count")); + } catch (NumberFormatException e) { + player.addChatComponentMessage( + new ChatComponentText( + "Error in translation GT5U.item.programmed_circuit.no_screwdriver.count: " + + e.getMessage())); + count = 1; + } + player.addChatComponentMessage( + new ChatComponentTranslation( + "GT5U.item.programmed_circuit.no_screwdriver." + XSTR.XSTR_INSTANCE.nextInt(count))); + return stack; + } + configuratorStack = player.inventory.mainInventory[configurator.getKey()]; + } + openSelectorGui(configuratorStack, stack.getItemDamage(), player); + return stack; + } + + private void openSelectorGui(ItemStack configurator, int meta, EntityPlayer player) { + UIInfos.openClientUI( + player, + buildContext -> new SelectItemUIFactory( + StatCollector.translateToLocal("GT5U.item.programmed_circuit.select.header"), + configurator, + GTPP_IntegratedCircuit_Item::onConfigured, + ALL_VARIANTS, + meta, + true).createWindow(buildContext)); + } + + private static void onConfigured(ItemStack stack) { + NBTTagCompound tag = new NBTTagCompound(); + tag.setByte("meta", (byte) stack.getItemDamage()); + GT_Values.NW.sendToServer(new GT_Packet_UpdateItem(tag)); + } + + private static Pair<Integer, BiFunction<ItemStack, EntityPlayerMP, ItemStack>> findConfiguratorInInv( + EntityPlayer player) { + ItemStack[] mainInventory = player.inventory.mainInventory; + for (int j = 0, mainInventoryLength = mainInventory.length; j < mainInventoryLength; j++) { + ItemStack toolStack = mainInventory[j]; + + if (!GT_Utility.isStackValid(toolStack)) continue; + + for (Map.Entry<Predicate<ItemStack>, BiFunction<ItemStack, EntityPlayerMP, ItemStack>> p : GregTech_API.sCircuitProgrammerList + .entrySet()) + if (p.getKey() + .test(toolStack)) return Pair.of(j, p.getValue()); + } + return null; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java b/src/main/java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java new file mode 100644 index 0000000000..51bff6f12b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java @@ -0,0 +1,92 @@ +package gtPlusPlus.core.item.crafting; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.LinkedHashMap; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.general.ItemGenericToken; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class ItemDummyResearch extends ItemGenericToken { + + public static enum ASSEMBLY_LINE_RESEARCH { + + RESEARCH_1_CONTAINMENT("Containment Fields", "Advanced scientific study"), + RESEARCH_2_BASIC_CHEM("Basic Chemistry", "Time to start at the beginning"), + RESEARCH_3_ADV_CHEM("Advanced Chemistry", "Best learn more than chemical equations"), + 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_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"), + RESEARCH_10_SPARGING("Gas Sparging", "Blowing gas for results"), + RESEARCH_11_MOLECULAR_TRANSFORMER("Molecular Transformation", "Turning things into something better"); + + private final String mName; + private final String mDesc; + + private ASSEMBLY_LINE_RESEARCH(String aName, String aDesc) { + mName = aName; + mDesc = aDesc; + ModItems.itemDummyResearch.register(mName, mDesc); + } + } + + private static Map<String, Integer> mInternalNameToIdMap = new LinkedHashMap<>(); + + public static ItemStack getResearchStack(ASSEMBLY_LINE_RESEARCH aResearchName, int aStacksize) { + Integer aMeta = mInternalNameToIdMap.get(Utils.sanitizeString(aResearchName.mName)); + if (aMeta == null) { + aMeta = 0; + } + return ItemUtils.simpleMetaStack(ModItems.itemDummyResearch, aMeta, aStacksize); + } + + private int aID = 0; + + public ItemDummyResearch() { + super("dummyResearch", "Research", new String[] { "This object requires some further study" }, "research"); + } + + /** + * + * @param aResearchType - What is the research for? + * @param aDescriptThe - tooltip for this research + * @return - Did we register a custom research item? + */ + public boolean register(String aResearchType, String aDescript) { + int aNewID = aID++; + mInternalNameToIdMap.put(Utils.sanitizeString(aResearchType), aNewID); + return register(aNewID, "Research on " + aResearchType, 1, aDescript); + } + + @Override + public boolean register(int id, String aLocalName, int aMaxStack, String aDescript) { + return register( + id, + aLocalName, + 1, + new String[] { aDescript, EnumChatFormatting.DARK_GRAY + "Used to further your knowledge" }, + EnumRarity.common, + EnumChatFormatting.LIGHT_PURPLE); + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(final IIconRegister aIconRegister) { + for (int i = 0, j = mLocalNames.size(); i < j; i++) { + mIcons.put(i, aIconRegister.registerIcon(GTPlusPlus.ID + ":" + "research" + "/" + "note")); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/food/BaseItemMetaFood.java b/src/main/java/gtPlusPlus/core/item/food/BaseItemMetaFood.java new file mode 100644 index 0000000000..a307eb48ac --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/food/BaseItemMetaFood.java @@ -0,0 +1,509 @@ +package gtPlusPlus.core.item.food; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +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.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class BaseItemMetaFood extends ItemFood { + + private static final HashMap<Integer, IIcon> mIconMap = new HashMap<>(); + private static int mTotalMetaItems = 0; + + /* + * 0 - Raw Human Meat 1 - Cooked Human Meat 2 - Raw Horse Meat 3 - Cooked Horse Meat 4 - Raw Wolf Meat 5 - Cooked + * Wolf Meat 6 - Raw Ocelot Meat 7 - Cooked Ocelot Meat 8 - Blaze Flesh + */ + + // listAllmeatraw + // listAllmeatcooked + + public static void registerMetaFoods() { + registerNewMetaFood( + 0, + "I wouldn't eat this unless I was starving", + 2, + 0, + 64, + getPotionEffectPackage(new EffectWeaknessModerate(80), new EffectSlownessModerate(80)), + getOreDictNamesAsArrayList("listAllmeatraw")); + registerNewMetaFood( + 1, + "Doesn't look any better cooked", + 4, + 1, + 64, + getPotionEffectPackage(new EffectWeaknessBasic(50), new EffectSlownessBasic(50)), + getOreDictNamesAsArrayList("listAllmeatcooked")); + registerNewMetaFood( + 2, + "", + 2, + 0, + 64, + getPotionEffectPackage(new EffectWeaknessBasic(30), new EffectSlownessBasic(30)), + getOreDictNamesAsArrayList("listAllmeatraw")); + registerNewMetaFood(3, "", 4, 1, 64, getOreDictNamesAsArrayList("listAllmeatcooked")); + registerNewMetaFood( + 4, + "", + 2, + 0, + 64, + getPotionEffectPackage(new EffectWeaknessBasic(25), new EffectSlownessBasic(30)), + getOreDictNamesAsArrayList("listAllmeatraw")); + registerNewMetaFood(5, "", 4, 1, 64, getOreDictNamesAsArrayList("listAllmeatcooked")); + registerNewMetaFood( + 6, + "", + 2, + 0, + 64, + getPotionEffectPackage(new EffectWeaknessBasic(30), new EffectSlownessBasic(25)), + getOreDictNamesAsArrayList("listAllmeatraw")); + registerNewMetaFood(7, "", 4, 1, 64, getOreDictNamesAsArrayList("listAllmeatcooked")); + registerNewMetaFood( + 8, + "Warm to the touch", + EnumRarity.uncommon, + 4, + 1, + 64, + new AutoMap<>(), + new setOnFire(), + getOreDictNamesAsArrayList("listAllmeatcooked")); + } + + private static final HashMap<Integer, Integer> mMaxStackSizeMap = new HashMap<>(); + private static final HashMap<Integer, String> mTooltipMap = new HashMap<>(); + private static final HashMap<Integer, EnumRarity> mRarityMap = new HashMap<>(); + private static final HashMap<Integer, Integer> mHealAmountMap = new HashMap<>(); + private static final HashMap<Integer, Float> mSaturationAmountMap = new HashMap<>(); + private static final HashMap<Integer, AutoMap<PotionEffectPackage>> mPotionEffectsMap = new HashMap<>(); + private static final HashMap<Integer, Boolean> mHasSpecialBehaviourMap = new HashMap<>(); + private static final HashMap<Integer, SpecialFoodBehaviour> mSpecialBehaviourMap = new HashMap<>(); + private static final HashMap<Integer, ArrayList<String>> mOreDictNames = new HashMap<>(); + + public static void registerNewMetaFood(final int aMetaID, String aTooltip, final int aHealAmount, + final float aSaturationModifier, final int aMaxStacksize) { + registerNewMetaFood( + aMetaID, + aTooltip, + EnumRarity.common, + aHealAmount, + aSaturationModifier, + aMaxStacksize, + new AutoMap<>(), + null, + new ArrayList<>()); + } + + public static void registerNewMetaFood(final int aMetaID, String aTooltip, final int aHealAmount, + final float aSaturationModifier, final int aMaxStacksize, final ArrayList<String> aOreDictNames) { + registerNewMetaFood( + aMetaID, + aTooltip, + EnumRarity.common, + aHealAmount, + aSaturationModifier, + aMaxStacksize, + new AutoMap<>(), + null, + aOreDictNames); + } + + public static void registerNewMetaFood(final int aMetaID, String aTooltip, final int aHealAmount, + final float aSaturationModifier, final int aMaxStacksize, final AutoMap<PotionEffectPackage> aPotionEffects) { + registerNewMetaFood( + aMetaID, + aTooltip, + EnumRarity.common, + aHealAmount, + aSaturationModifier, + aMaxStacksize, + new AutoMap<>(), + null, + new ArrayList<>()); + } + + public static void registerNewMetaFood(final int aMetaID, String aTooltip, final int aHealAmount, + final float aSaturationModifier, final int aMaxStacksize, final AutoMap<PotionEffectPackage> aPotionEffects, + final ArrayList<String> aOreDictNames) { + registerNewMetaFood( + aMetaID, + aTooltip, + EnumRarity.common, + aHealAmount, + aSaturationModifier, + aMaxStacksize, + aPotionEffects, + null, + aOreDictNames); + } + + public static void registerNewMetaFood(final int aMetaID, String aTooltip, EnumRarity aRarity, + final int aHealAmount, final float aSaturationModifier, final int aMaxStacksize, + final AutoMap<PotionEffectPackage> aPotionEffects, final SpecialFoodBehaviour aSpecialBehaviour) { + registerNewMetaFood( + aMetaID, + aTooltip, + EnumRarity.common, + aHealAmount, + aSaturationModifier, + aMaxStacksize, + aPotionEffects, + null, + new ArrayList<>()); + } + + public static void registerNewMetaFood(final int aMetaID, String aTooltip, EnumRarity aRarity, + final int aHealAmount, final float aSaturationModifier, final int aMaxStacksize, + final AutoMap<PotionEffectPackage> aPotionEffects, final SpecialFoodBehaviour aSpecialBehaviour, + final ArrayList<String> aOreDictNames) { + mTotalMetaItems++; + mMaxStackSizeMap.put(aMetaID, aMaxStacksize); + mTooltipMap.put(aMetaID, aTooltip); + mRarityMap.put(aMetaID, aRarity); + mHealAmountMap.put(aMetaID, aHealAmount); + mSaturationAmountMap.put(aMetaID, aSaturationModifier); + mPotionEffectsMap.put(aMetaID, aPotionEffects); + mHasSpecialBehaviourMap.put(aMetaID, (aSpecialBehaviour != null)); + if (aSpecialBehaviour != null) { + mSpecialBehaviourMap.put(aMetaID, aSpecialBehaviour); + } + mOreDictNames.put(aMetaID, aOreDictNames); + } + + public static void registerFoodsToOreDict() { + for (int aMetaID = 0; aMetaID < mTotalMetaItems; aMetaID++) { + ArrayList<String> aOreDictNames = mOreDictNames.get(aMetaID); + if (aOreDictNames != null && !aOreDictNames.isEmpty()) { + ItemStack aFoodStack = ItemUtils.simpleMetaStack(ModItems.itemMetaFood, aMetaID, 1); + for (String aOreName : aOreDictNames) { + ItemUtils.addItemToOreDictionary(aFoodStack, aOreName); + } + } + } + } + + public BaseItemMetaFood() { + super(0, 0, false); + this.setHasSubtypes(true); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + this.setUnlocalizedName("BasicMetaFood"); + this.setCreativeTab(AddToCreativeTab.tabMisc); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + BaseItemMetaFood.registerMetaFoods(); + } + + private static int getMetaKey(ItemStack aStack) { + return aStack.getItemDamage(); + } + + // Heal Amount + @Override + public int func_150905_g(ItemStack aStack) { + return mHealAmountMap.get(getMetaKey(aStack)); + } + + // Saturation Amount + @Override + public float func_150906_h(ItemStack aStack) { + return mSaturationAmountMap.get(getMetaKey(aStack)); + } + + // Whether wolves like this food, sadly doesn't support meta items + @Override + public boolean isWolfsFavoriteMeat() { + return false; + } + + @Override + protected void onFoodEaten(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + // super.onFoodEaten(stack, world, player); + AutoMap<PotionEffectPackage> aPotionEffects = mPotionEffectsMap.get(getMetaKey(aStack)); + if (!aWorld.isRemote && aPotionEffects != null && aPotionEffects.size() > 0) { + for (PotionEffectPackage aFoodEffect : aPotionEffects) { + if (MathUtils.randInt(0, 100) <= aFoodEffect.getChance() || aFoodEffect.getChance() == 100) { + PotionEffect aEffect = aFoodEffect.getEffect(); + if (aEffect != null && aEffect.getPotionID() > 0) { + aPlayer.addPotionEffect( + new PotionEffect( + aEffect.getPotionID(), + aEffect.getDuration() * 20, + aEffect.getAmplifier(), + aEffect.getIsAmbient())); + } + } + } + } + + boolean aHasEpcialBehaviour = mHasSpecialBehaviourMap.get(getMetaKey(aStack)); + if (!aWorld.isRemote && aHasEpcialBehaviour) { + SpecialFoodBehaviour aBehaviour = mSpecialBehaviourMap.get(getMetaKey(aStack)); + if (aBehaviour != null) { + aBehaviour.doBehaviour(aPlayer); + } + } + } + + @Override + public ItemStack onEaten(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + return super.onEaten(aStack, aWorld, aPlayer); + } + + @Override + public int getItemStackLimit(ItemStack aStack) { + return mMaxStackSizeMap.get(getMetaKey(aStack)); + } + + @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 { + String aTooltip = mTooltipMap.get(getMetaKey(aStack)); + if (aTooltip != null && aTooltip.length() > 0) { + aList.add(aTooltip); + } + } catch (Throwable t) { + t.printStackTrace(); + } + super.addInformation(aStack, p_77624_2_, aList, p_77624_4_); + } + + @Override + public EnumRarity getRarity(ItemStack aStack) { + return mRarityMap.get(getMetaKey(aStack)); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return false; + } + + @Override + public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { + for (int i = 0; i < mIconMap.size(); 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 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 < mTotalMetaItems; i++) { + String aPath = GTPlusPlus.ID + ":" + "food/MetaItem1/" + i; + mIconMap.put(i, u.registerIcon(aPath)); + } + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + return mIconMap.get(damage); + } + + @Override + public IIcon getIconFromDamage(int damage) { + return mIconMap.get(damage); + } + + @Override + public IIcon getIcon(ItemStack aStack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return mIconMap.get(getMetaKey(aStack)); + } + + @Override + public IIcon getIcon(ItemStack aStack, int pass) { + return mIconMap.get(getMetaKey(aStack)); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + private static class PotionEffectPackage { + + private final PotionEffect mEffect; + private final int mChance; + + private PotionEffectPackage(PotionEffect aEffect, int aChance) { + mEffect = aEffect; + mChance = aChance; + } + + public PotionEffect getEffect() { + return this.mEffect; + } + + public int getChance() { + return this.mChance; + } + } + + private static AutoMap<PotionEffectPackage> getPotionEffectPackage(PotionEffectPackage... aEffects) { + AutoMap<PotionEffectPackage> aPackage = new AutoMap<>(); + if (aEffects != null && aEffects.length > 0) { + for (PotionEffectPackage aEffect : aEffects) { + aPackage.put(aEffect); + } + } + return aPackage; + } + + private static ArrayList<String> getOreDictNamesAsArrayList(String... aOreDictNames) { + ArrayList<String> aPackage = new ArrayList<>(); + if (aOreDictNames != null && aOreDictNames.length > 0) { + for (String aEffect : aOreDictNames) { + aPackage.add(aEffect); + } + } + return aPackage; + } + + private static class EffectWeaknessBasic extends PotionEffectPackage { + + protected EffectWeaknessBasic(int aChance) { + super(new PotionEffect(Potion.weakness.getId(), 1, 20), aChance); + } + } + + private static class EffectWeaknessModerate extends PotionEffectPackage { + + protected EffectWeaknessModerate(int aChance) { + super(new PotionEffect(Potion.weakness.getId(), 2, 40), aChance); + } + } + + private static class EffectWeaknessSevere extends PotionEffectPackage { + + protected EffectWeaknessSevere(int aChance) { + super(new PotionEffect(Potion.weakness.getId(), 3, 60), aChance); + } + } + + private static class EffectSlownessBasic extends PotionEffectPackage { + + protected EffectSlownessBasic(int aChance) { + super(new PotionEffect(Potion.moveSlowdown.getId(), 1, 20), aChance); + } + } + + private static class EffectSlownessModerate extends PotionEffectPackage { + + protected EffectSlownessModerate(int aChance) { + super(new PotionEffect(Potion.moveSlowdown.getId(), 2, 40), aChance); + } + } + + private static class EffectSlownessSevere extends PotionEffectPackage { + + protected EffectSlownessSevere(int aChance) { + super(new PotionEffect(Potion.moveSlowdown.getId(), 3, 60), aChance); + } + } + + private abstract static class SpecialFoodBehaviour { + + protected final int mChance; + + public SpecialFoodBehaviour(int aChance) { + mChance = aChance; + } + + public final void doBehaviour(EntityPlayer aPlayer) { + if (aPlayer != null && !aPlayer.worldObj.isRemote) { + if (MathUtils.randInt(0, 100) < mChance || mChance == 100) { + behaviour(aPlayer); + } + } + } + + protected abstract void behaviour(EntityPlayer aPlayer); + } + + private static class setOnFire extends SpecialFoodBehaviour { + + public setOnFire() { + super(100); + } + + @Override + public void behaviour(EntityPlayer aPlayer) { + EntityUtils.setEntityOnFire(aPlayer, 5); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/BufferCore.java b/src/main/java/gtPlusPlus/core/item/general/BufferCore.java new file mode 100644 index 0000000000..69257afb0e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/BufferCore.java @@ -0,0 +1,68 @@ +package gtPlusPlus.core.item.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; +import gtPlusPlus.core.item.base.BaseItemWithDamageValue; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; + +public class BufferCore extends BaseItemWithDamageValue { + + public int coreTier = 0; + + public BufferCore(final String unlocalizedName, final int i) { + super(unlocalizedName + i); + this.setTextureName(GTPlusPlus.ID + ":" + unlocalizedName); + this.setMaxStackSize(32); + this.coreTier = i; + } + + @Override + public String getItemStackDisplayName(final ItemStack stack) { + return super.getItemStackDisplayName(stack) /* +" ["+GT_Values.VN[this.coreTier-1]+"]." */; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add( + EnumChatFormatting.GRAY + "A key crafting component for " + + GT_Values.VN[this.coreTier - 1] + + " Applicances"); + } + + public final int getCoreTier() { + return this.coreTier; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + + int[] mTierTypes = new int[] { Utils.rgbtoHexValue(200, 180, 180), Utils.rgbtoHexValue(142, 153, 161), + Utils.rgbtoHexValue(230, 121, 75), Utils.rgbtoHexValue(215, 156, 70), Utils.rgbtoHexValue(97, 97, 96), // EV + Utils.rgbtoHexValue(202, 202, 201), Utils.rgbtoHexValue(247, 159, 157), Utils.rgbtoHexValue(181, 223, 223), + Utils.rgbtoHexValue(187, 219, 185), }; + + if (this.coreTier == 10) { + return Utils + .rgbtoHexValue(MathUtils.randInt(220, 250), MathUtils.randInt(221, 251), MathUtils.randInt(220, 250)); + } + + return mTierTypes[this.coreTier - 1]; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemAirFilter.java b/src/main/java/gtPlusPlus/core/item/general/ItemAirFilter.java new file mode 100644 index 0000000000..e82e6f1b44 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/ItemAirFilter.java @@ -0,0 +1,143 @@ +package gtPlusPlus.core.item.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; + +public class ItemAirFilter extends Item { + + public IIcon[] icons = new IIcon[1]; + + public ItemAirFilter() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemAirFilter"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(1); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(GTPlusPlus.ID + ":" + "itemAirFilter"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[0]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + + if (tItem == null) { + return "Air Filter"; + } + + String itemName = tItem == null ? "Air Filter" : super.getItemStackDisplayName(tItem); + String suffixName = ""; + if (tItem.getItemDamage() == 0) { + suffixName = " [Tier 1]"; + } else if (tItem.getItemDamage() == 1) { + suffixName = " [Tier 2]"; + } + return (itemName + suffixName); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + int meta = stack.getItemDamage(); + if (meta == 1) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(150, 180, 35); + } + return HEX_OxFFFFFF; + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagMain.setTag("AirFilter", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getFilterMaxDamage(final ItemStack aStack) { + return aStack.getItemDamage() == 0 ? 50 : 2500; + } + + public static final long getFilterDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("AirFilter"); + if (aNBT != null) { + return aNBT.getLong("Damage"); + } + } else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("AirFilter"); + if (aNBT != null) { + aNBT.setLong("Damage", aDamage); + return true; + } + } + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); + } + double currentDamage = getFilterDamage(stack); + double meta = getFilterMaxDamage(stack); + double durabilitypercent = currentDamage / meta; + return durabilitypercent; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY + "An Air filter for Atmospheric Reconditioning."); + long maxDamage = getFilterMaxDamage(stack); + list.add(EnumChatFormatting.GRAY + "" + (maxDamage - getFilterDamage(stack)) + "/" + maxDamage + " uses left."); + super.addInformation(stack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java b/src/main/java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java new file mode 100644 index 0000000000..ee1afdb6bf --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java @@ -0,0 +1,152 @@ +package gtPlusPlus.core.item.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; + +public class ItemBasicScrubberTurbine extends Item { + + public IIcon[] icons = new IIcon[1]; + + public ItemBasicScrubberTurbine() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemBasicTurbine"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(1); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(GTPlusPlus.ID + ":" + "itemBasicTurbine"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[0]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 3; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if (tItem == null) { + return "Basic Turbine"; + } + return super.getItemStackDisplayName(tItem); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + int meta = stack.getItemDamage(); + if (meta == 0) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(200, 200, 200); + } + if (meta == 1) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(255, 128, 0); + } + if (meta == 2) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(128, 128, 128); + } + return HEX_OxFFFFFF; + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagMain.setTag("BasicTurbine", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getFilterDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("BasicTurbine"); + if (aNBT != null) { + return aNBT.getLong("Damage"); + } + } else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("BasicTurbine"); + if (aNBT != null) { + aNBT.setLong("Damage", aDamage); + return true; + } + } + return false; + } + + public int getMaxDurability(ItemStack aStack) { + if (aStack != null) { + int aMeta = aStack.getItemDamage(); + if (aMeta == 0) { + return 2000; + } + if (aMeta == 1) { + return 4000; + } + if (aMeta == 2) { + return 6000; + } + } + return 0; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); + } + double currentDamage = getFilterDamage(stack); + double meta = getMaxDurability(stack); + double durabilitypercent = currentDamage / meta; + return durabilitypercent; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY + "An early tier Turbine for Atmospheric Reconditioning."); + int maxDamage = getMaxDurability(stack); + list.add(EnumChatFormatting.GRAY + "" + (maxDamage - getFilterDamage(stack)) + "/" + maxDamage + " uses left."); + super.addInformation(stack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemBlueprint.java b/src/main/java/gtPlusPlus/core/item/general/ItemBlueprint.java new file mode 100644 index 0000000000..c6e0743268 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/ItemBlueprint.java @@ -0,0 +1,297 @@ +package gtPlusPlus.core.item.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.interfaces.IItemBlueprint; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; + +public class ItemBlueprint extends Item implements IItemBlueprint { + + public ItemBlueprint(final String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(GTPlusPlus.ID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMachines); + // this.bpID = MathUtils.randInt(0, 1000); + GameRegistry.registerItem(this, unlocalizedName); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack itemStack, final EntityPlayer aPlayer, final List list, + final boolean bool) { + // Create some NBT if it's not there, otherwise this does nothing. + if (!itemStack.hasTagCompound()) { + this.createNBT(itemStack); + } + // Set up some default variables. + int id = -1; + String name = ""; + boolean blueprint = false; + // Get proper display vars from NBT if it's there + if (itemStack.hasTagCompound()) { + // Utils.LOG_WARNING("Found TagCompound"); + id = (int) this.getNBT(itemStack, "mID"); + name = (String) this.getNBT(itemStack, "mName"); + blueprint = (boolean) this.getNBT(itemStack, "mBlueprint"); + } + // Write to tooltip list for each viable setting. + if (itemStack.hasTagCompound()) { + if (id != -1) { + list.add( + EnumChatFormatting.GRAY + StatCollector + .translateToLocalFormatted(StatCollector.translateToLocal("item.itemBlueprint.tooltip.0"), id)); + } + if (blueprint) { + list.add( + EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted( + StatCollector.translateToLocal("item.itemBlueprint.tooltip.1"), + name)); + } else { + list.add(EnumChatFormatting.RED + StatCollector.translateToLocal("item.itemBlueprint.tooltip.2")); + } + } else { + list.add(EnumChatFormatting.RED + StatCollector.translateToLocal("item.itemBlueprint.tooltip.2")); + } + super.addInformation(itemStack, aPlayer, list, bool); + } + + @Override + public void onCreated(final ItemStack itemStack, final World world, final EntityPlayer player) { + this.createNBT(itemStack); + } + + @Override + public void onUpdate(final ItemStack itemStack, final World par2World, final Entity par3Entity, final int par4, + final boolean par5) {} + + @Override + public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer par3Entity) { + // Let the player know what blueprint is held + if (itemStack.hasTagCompound()) { + PlayerUtils.messagePlayer( + par3Entity, + "This Blueprint holds NBT data. " + "|" + + this.getNBT(itemStack, "mID") + + "|" + + this.getNBT(itemStack, "mBlueprint") + + "|" + + this.getNBT(itemStack, "mName") + + "|" + + ItemUtils.getArrayStackNames(this.readItemsFromNBT(itemStack))); + } else { + this.createNBT(itemStack); + PlayerUtils.messagePlayer(par3Entity, "This is a placeholder. " + this.getNBT(itemStack, "mID")); + } + + return super.onItemRightClick(itemStack, world, par3Entity); + } + + public ItemStack[] readItemsFromNBT(final ItemStack itemStack) { + ItemStack[] blueprint = new ItemStack[9]; + if (itemStack.hasTagCompound()) { + final NBTTagCompound nbt = itemStack.getTagCompound(); + final NBTTagList list = nbt.getTagList("Inventory", 10); + blueprint = 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)) { + blueprint[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + return blueprint; + } + return null; + } + + public ItemStack writeItemsToNBT(final ItemStack itemStack, final ItemStack[] craftingGrid) { + final ItemStack[] blueprint = craftingGrid; + if (itemStack.hasTagCompound()) { + final NBTTagCompound nbt = itemStack.getTagCompound(); + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = blueprint[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Inventory", list); + itemStack.setTagCompound(nbt); + return itemStack; + } + return null; + } + + @Override + public boolean isBlueprint(final ItemStack stack) { + return true; + } + + @Override + public boolean setBlueprint(final ItemStack stack, final IInventory craftingTable, final ItemStack output) { + boolean hasBP = false; + ItemStack[] blueprint = new ItemStack[9]; + + if (stack.hasTagCompound()) { + hasBP = (boolean) this.getNBT(stack, "mBlueprint"); + blueprint = this.readItemsFromNBT(stack); + } + + if (!hasBP) { + try { + for (int o = 0; o < craftingTable.getSizeInventory(); o++) { + blueprint[o] = craftingTable.getStackInSlot(o); + if (blueprint[0] != null) { + blueprint[0].stackSize = 0; + } + } + this.writeItemsToNBT(stack, blueprint); + if (stack.hasTagCompound()) { + if (stack.getTagCompound() + .getCompoundTag("Items") != null) { + stack.stackTagCompound.setBoolean("mBlueprint", true); + } else { + // Invalid BP saved? + } + hasBP = (boolean) this.getNBT(stack, "mBlueprint"); + } + + if (output != null) { + this.setBlueprintName(stack, output.getDisplayName()); + hasBP = true; + return true; + } + return false; + } catch (final Throwable t) { + return false; + } + } + return false; + } + + @Override + public void setBlueprintName(final ItemStack stack, final String name) { + stack.stackTagCompound.setString("mName", name); + } + + @Override + public boolean hasBlueprint(final ItemStack stack) { + if (stack.hasTagCompound()) { + return (boolean) this.getNBT(stack, "mBlueprint"); + } + return false; + } + + @Override + public ItemStack[] getBlueprint(final ItemStack stack) { + ItemStack[] blueprint = new ItemStack[9]; + if (stack.hasTagCompound()) { + blueprint = this.readItemsFromNBT(stack); + } + try { + final ItemStack[] returnStack = new ItemStack[9]; + for (int o = 0; o < blueprint.length; o++) { + returnStack[o] = blueprint[o]; + if (returnStack[0] != null) { + returnStack[0].stackSize = 1; + } + } + return returnStack; + } catch (final Throwable t) { + return null; + } + } + + public boolean createNBT(final ItemStack itemStack) { + if (itemStack.hasTagCompound()) { + if (!itemStack.stackTagCompound.getBoolean("mBlueprint") && !itemStack.stackTagCompound.getString("mName") + .equals("")) { + // No Blueprint and no name Set + Logger.WARNING("No Blueprint and no name Set"); + return false; + } else if (itemStack.stackTagCompound.getBoolean("mBlueprint") + && !itemStack.stackTagCompound.getString("mName") + .equals("")) { + // Has Blueprint but invalid name set + Logger.WARNING("Has Blueprint but invalid name set"); + return false; + } else + if (!itemStack.stackTagCompound.getBoolean("mBlueprint") + && itemStack.stackTagCompound.getString("mName") + .equals("")) { + // Has no Blueprint, but strangely has a name + Logger.WARNING("Has no Blueprint, but strangely has a name"); + return false; + } + return false; + } else if (!itemStack.hasTagCompound()) { + final int bpID = MathUtils.randInt(0, 1000); + final boolean hasRecipe = false; + final String recipeName = ""; + Logger.WARNING("Creating Blueprint, setting up it's NBT data. " + bpID); + itemStack.stackTagCompound = new NBTTagCompound(); + itemStack.stackTagCompound.setInteger("mID", bpID); + itemStack.stackTagCompound.setBoolean("mBlueprint", hasRecipe); + itemStack.stackTagCompound.setString("mName", recipeName); + return true; + } else { + final int bpID = MathUtils.randInt(0, 1000); + final boolean hasRecipe = false; + final String recipeName = ""; + Logger.WARNING("Creating a Blueprint, setting up it's NBT data. " + bpID); + itemStack.stackTagCompound = new NBTTagCompound(); + itemStack.stackTagCompound.setInteger("mID", bpID); + itemStack.stackTagCompound.setBoolean("mBlueprint", hasRecipe); + itemStack.stackTagCompound.setString("mName", recipeName); + return true; + } + } + + public Object getNBT(final ItemStack itemStack, final String tagNBT) { + if (!itemStack.hasTagCompound()) { + return null; + } + Object o = null; + switch (tagNBT) { + case "mID": + o = itemStack.stackTagCompound.getInteger(tagNBT); + break; + case "mBlueprint": + o = itemStack.stackTagCompound.getBoolean(tagNBT); + break; + case "mName": + o = itemStack.stackTagCompound.getString(tagNBT); + break; + case "": + // For More Tag Support + // o = itemStack.stackTagCompound.getInteger(tagNBT); + break; + } + if (o != null) { + return o; + } + return null; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemCloakingDevice.java b/src/main/java/gtPlusPlus/core/item/general/ItemCloakingDevice.java new file mode 100644 index 0000000000..9e5cf0a69d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/ItemCloakingDevice.java @@ -0,0 +1,232 @@ +package gtPlusPlus.core.item.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.Names; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.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 gregtech.api.util.GT_Utility; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; + +@Optional.InterfaceList( + value = { @Optional.Interface(iface = "baubles.api.IBauble", modid = Names.BAUBLES), + @Optional.Interface(iface = "baubles.api.BaubleType", modid = Names.BAUBLES) }) +public class ItemCloakingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble { + + private final String unlocalizedName = "personalCloakingDevice"; + private final ItemStack thisStack; + private static final int maxValueEU = 10000 * 20 * 500; + protected double chargeEU = 0; + + public ItemCloakingDevice(final double charge) { + this.chargeEU = charge; + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(this.unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(GTPlusPlus.ID + ":" + "personalCloakingDevice"); + this.thisStack = ItemUtils.getSimpleStack(this); + this.charge(this.thisStack, charge, 3, true, false); + if (charge == (10000 * 20 * 500)) { + this.setDamage(this.thisStack, 13); + } + GameRegistry.registerItem(this, this.unlocalizedName + "-" + charge); + } + + @Override + public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, + final boolean p_77663_5_) { + if (worldObj.isRemote) { + return; + } + + if (player instanceof EntityPlayer) { + for (final ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { + if (is == itemStack) { + continue; + } + if (is != null) { + if (is.getItem() instanceof final IElectricItem electricItem) { + this.chargeEU = ElectricItem.manager.getCharge(is); + } + } + } + } + + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(final ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(final ItemStack itemStack) { + return 5; + } + + @Override + public double getTransferLimit(final ItemStack itemStack) { + return 8196; + } + + @Override + public double getDurabilityForDisplay(final ItemStack stack) { + // return 1.0D - getEnergyStored(stack) / this.capacity; + return 1.0D - (this.getCharge(stack) / this.getMaxCharge(stack)); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return true; + } + + public int secondsLeft(final ItemStack stack) { + double r; + r = this.getCharge(stack) / (10000 * 20); + return (int) MathUtils.decimalRounding(r); + } + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(""); + list.add(StatCollector.translateToLocal("item.personalCloakingDevice.tooltip.0")); + list.add(StatCollector.translateToLocal("item.personalCloakingDevice.tooltip.1")); + list.add(""); + list.add(StatCollector.translateToLocal("item.personalCloakingDevice.tooltip.2")); + list.add( + StatCollector.translateToLocalFormatted( + "item.personalCloakingDevice.tooltip.3", + GT_Utility.formatNumbers(this.getTier(this.thisStack)), + GT_Utility.formatNumbers(this.getTransferLimit(this.thisStack)))); + list.add( + StatCollector.translateToLocalFormatted( + "item.personalCloakingDevice.tooltip.4", + GT_Utility.formatNumbers(this.getCharge(stack)), + MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack)))); + list.add( + StatCollector.translateToLocalFormatted( + "item.personalCloakingDevice.tooltip.5", + GT_Utility.formatNumbers(this.secondsLeft(stack)))); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public double charge(final ItemStack stack, final double amount, final int tier, final boolean ignoreTransferLimit, + final boolean simulate) { + + if (!simulate) { + ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public double discharge(final ItemStack stack, final double amount, final int tier, + final boolean ignoreTransferLimit, final boolean externally, final boolean simulate) { + if (!simulate) { + ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(final ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(final ItemStack stack, final double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(final ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public BaubleType getBaubleType(final ItemStack arg0) { + return BaubleType.BELT; + } + + @Override // TODO + public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onWornTick(final ItemStack arg0, final EntityLivingBase arg1) { + // Utils.LOG_INFO("Trying to Tick Belt. 1"); + if (!arg1.worldObj.isRemote) { + if (this.getCharge(arg0) >= 10000) { + arg1.addPotionEffect(new PotionEffect(Potion.invisibility.id, 10, 2)); + this.discharge(arg0, 10000, 5, true, true, false); + } else { + if (arg1.isPotionActive((Potion.invisibility))) { + arg1.removePotionEffect(Potion.invisibility.id); + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemEmpty.java b/src/main/java/gtPlusPlus/core/item/general/ItemEmpty.java new file mode 100644 index 0000000000..773a45aa0a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/ItemEmpty.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.item.general; + +import net.minecraft.item.ItemStack; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.CoreItem; + +public class ItemEmpty extends CoreItem { + + public ItemEmpty() { + super("item.empty", AddToCreativeTab.tabMisc); + } + + @Override + public String getItemStackDisplayName(ItemStack tItem) { + return "Empty"; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemGenericToken.java b/src/main/java/gtPlusPlus/core/item/general/ItemGenericToken.java new file mode 100644 index 0000000000..c1bea0b81d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/ItemGenericToken.java @@ -0,0 +1,197 @@ +package gtPlusPlus.core.item.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.HashMap; +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.CoreItem; + +public class ItemGenericToken extends CoreItem { + + public final HashMap<Integer, String> mLocalNames; + public final HashMap<Integer, Integer> mMaxStackSizes; + public final HashMap<Integer, String[]> mDescriptionArrays; + public final HashMap<Integer, EnumRarity> mRarities; + public final HashMap<Integer, EnumChatFormatting> mCustomNameColours; + public final HashMap<Integer, IIcon> mIcons; + private final String mTextureDir; + + public ItemGenericToken() { + this("itemGenericToken", "Token", new String[] { "Can be reclaimed in some way, shape or form" }, "token"); + } + + public ItemGenericToken(String aUnlocalName, String aInternalName, String[] aBaseTooltip, String aTextureDir) { + super( + aUnlocalName, + aInternalName, + AddToCreativeTab.tabMisc, + 64, + 1000, + aBaseTooltip, + EnumRarity.common, + EnumChatFormatting.RESET, + false, + null); + mLocalNames = new HashMap<>(); + mMaxStackSizes = new HashMap<>(); + mDescriptionArrays = new HashMap<>(); + mRarities = new HashMap<>(); + mCustomNameColours = new HashMap<>(); + mIcons = new HashMap<>(); + mTextureDir = aTextureDir; + setMaxStackSize(64); + } + + public boolean register(int id, String aLocalName, int aMaxStack, String aDescript) { + return register(id, aLocalName, aMaxStack, new String[] { aDescript }); + } + + public boolean register(int id, String aLocalName, int aMaxStack, String[] aDescript) { + return register(id, aLocalName, aMaxStack, aDescript, EnumRarity.common, EnumChatFormatting.RESET); + } + + public boolean register(int id, String aLocalName, int aMaxStack, String[] aDescript, EnumRarity aRarity, + EnumChatFormatting aCustomNameColour) { + int[][] sizes = new int[2][6]; + sizes[0][0] = mLocalNames.size(); + sizes[0][1] = mMaxStackSizes.size(); + sizes[0][2] = mDescriptionArrays.size(); + sizes[0][3] = mRarities.size(); + sizes[0][4] = mCustomNameColours.size(); + // sizes[0][5] = mIcons.size(); + mLocalNames.put(id, aLocalName); + GT_LanguageManager + .addStringLocalization("gtplusplus." + this.getUnlocalizedName() + "." + id + ".name", aLocalName); + mMaxStackSizes.put(id, aMaxStack); + mDescriptionArrays.put(id, aDescript); + for (int i = 0; i < aDescript.length; i++) { + GT_LanguageManager.addStringLocalization( + "gtplusplus." + this.getUnlocalizedName() + "." + id + ".tooltip." + i, + aDescript[i]); + } + mRarities.put(id, aRarity); + mCustomNameColours.put(id, aCustomNameColour); + sizes[1][0] = mLocalNames.size(); + sizes[1][1] = mMaxStackSizes.size(); + sizes[1][2] = mDescriptionArrays.size(); + sizes[1][3] = mRarities.size(); + sizes[1][4] = mCustomNameColours.size(); + // sizes[1][5] = mIcons.size(); + boolean b = sizes[0][0] > sizes[1][0] && sizes[0][1] > sizes[1][1] + && sizes[0][2] > sizes[1][2] + && sizes[0][3] > sizes[1][3] + && sizes[0][4] > sizes[1][4]; + return b; + } + + // Handle Sub items + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { + for (int i = 0, j = mIcons.size(); i < j; i++) { + final ItemStack tStack = new ItemStack(this, 1, i); + aList.add(tStack); + } + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + super.addInformation(stack, aPlayer, list, bool); + for (int i = 0;; i++) { + String tooltip = GT_LanguageManager.getTranslation( + "gtplusplus." + this + .getUnlocalizedNameInefficiently(stack) + "." + stack.getItemDamage() + ".tooltip." + i); + if (!("gtplusplus." + this + .getUnlocalizedNameInefficiently(stack) + "." + stack.getItemDamage() + ".tooltip." + i) + .equals(tooltip)) { + list.add(tooltip); + } else break; + } + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + String ret = GT_LanguageManager.getTranslation( + "gtplusplus." + this.getUnlocalizedNameInefficiently(tItem) + "." + tItem.getItemDamage() + ".name"); + EnumChatFormatting format = mCustomNameColours.get(tItem.getItemDamage()); + if (format != null) { + ret = format + ret; + } + return ret; + } + + @Override + public EnumRarity getRarity(ItemStack par1ItemStack) { + return mRarities.get(par1ItemStack.getItemDamage()); + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack, final int pass) { + return false; + } + + @Override + public int getMetadata(int p_77647_1_) { + return 0; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0D; + } + + @Override + public boolean isDamaged(ItemStack stack) { + return false; + } + + @Override + public int getItemStackLimit(ItemStack aStack) { + if (aStack == null) { + return maxStackSize; + } else { + Integer aSize = mMaxStackSizes.get(aStack.getItemDamage()); + if (aSize != null) { + return aSize; + } else { + return maxStackSize; + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister aIconRegister) { + for (int i = 0, j = mLocalNames.size(); i < j; i++) { + mIcons.put(i, aIconRegister.registerIcon(GTPlusPlus.ID + ":" + mTextureDir + "/" + i)); + } + } + + @Override + public final IIcon getIconFromDamage(final int aMetaData) { + if (aMetaData < 0) { + return null; + } + return mIcons.get(aMetaData); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java b/src/main/java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java new file mode 100644 index 0000000000..47cd73a62b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java @@ -0,0 +1,56 @@ +package gtPlusPlus.core.item.general; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gtPlusPlus.core.item.base.BaseItemColourable; +import gtPlusPlus.core.util.Utils; + +public class ItemHalfCompleteCasings extends BaseItemColourable { + + public ItemHalfCompleteCasings(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, + String description, EnumRarity regRarity, EnumChatFormatting colour, boolean Effect, int rgb) { + super(unlocalizedName, creativeTab, stackSize, maxDmg, description, regRarity, colour, Effect, rgb); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 4; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + String prefix = super.getItemStackDisplayName(tItem); + String casingType = ""; + if (tItem.getItemDamage() == 0) { + casingType = " I"; + } else if (tItem.getItemDamage() == 1) { + casingType = " II"; + } else if (tItem.getItemDamage() == 2) { + casingType = " III"; + } else if (tItem.getItemDamage() == 3) { + casingType = " IV"; + } + return (prefix + casingType); + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (this.getDamage(stack) == 0) { + return Utils.rgbtoHexValue(52, 52, 52); + } else if (this.getDamage(stack) == 1) { + return Utils.rgbtoHexValue(80, 90, 222); + } else if (this.getDamage(stack) == 2) { + return Utils.rgbtoHexValue(182, 77, 177); + } else { + return Utils.rgbtoHexValue(77, 175, 182); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java b/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java new file mode 100644 index 0000000000..d80238b99a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java @@ -0,0 +1,419 @@ +package gtPlusPlus.core.item.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.FoodStats; +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 gregtech.api.enums.GT_Values; +import gregtech.api.enums.Mods; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; + +@Optional.InterfaceList( + value = { @Optional.Interface(iface = "baubles.api.IBauble", modid = Mods.Names.BAUBLES), + @Optional.Interface(iface = "baubles.api.BaubleType", modid = Mods.Names.BAUBLES) }) +public class ItemHealingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble { + + private final String unlocalizedName = "personalHealingDevice"; + private static final int maxValueEU = 1000000000; + protected double chargeEU = 0; + + public ItemHealingDevice() { + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(this.unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(GTPlusPlus.ID + ":" + "personalCloakingDevice"); + GameRegistry.registerItem(this, this.unlocalizedName); + } + + @Override + public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, + final boolean p_77663_5_) { + if (worldObj.isRemote) { + return; + } + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(final ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(final ItemStack itemStack) { + return 5; + } + + @Override + public double getTransferLimit(final ItemStack itemStack) { + return GT_Values.V[7]; + } + + @Override + public double getDurabilityForDisplay(final ItemStack stack) { + // return 1.0D - getEnergyStored(stack) / this.capacity; + return 1.0D - (this.getCharge(stack) / this.getMaxCharge(stack)); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return true; + } + + public double secondsLeft(final ItemStack stack) { + + double r = 0; + r = this.getCharge(stack) / (1638400 / 4); + return (int) r; + } + + int EUPerOperation = 1_638_400; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + String aString1 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.1"); + String aString2 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.2"); + String aString3 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.3"); + String aString4 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.4"); + String aString5 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.5"); + + String aString6 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.6"); + + String aStringTooltip = StatCollector.translateToLocal("GTPP.nanohealer.hidden"); + String aEuInfo = StatCollector.translateToLocal("GTPP.info.euInfo"); + String aTier = StatCollector.translateToLocal("GTPP.machines.tier"); + String aInputLimit = StatCollector.translateToLocal("GTPP.info.inputLimit"); + String aCurrentPower = StatCollector.translateToLocal("GTPP.info.currentPower"); + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); + String aEUT = aEU + "/t"; + boolean isShowing = getShowMessages(stack); + + list.add(""); + + list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); + list.add( + EnumChatFormatting.GREEN + aString2 + + GT_Utility.formatNumbers(EUPerOperation) + + aString3 + + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString4 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.RED + aString5 + EnumChatFormatting.GRAY); + + list.add(""); + + list.add(EnumChatFormatting.GOLD + aEuInfo + EnumChatFormatting.GRAY); + list.add( + EnumChatFormatting.GRAY + aTier + + ": [" + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(this.getTier(stack)) + + EnumChatFormatting.GRAY + + "] " + + aInputLimit + + ": [" + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(this.getTransferLimit(stack)) + + EnumChatFormatting.GRAY + + aEUT + + "]"); + list.add( + EnumChatFormatting.GRAY + aCurrentPower + + ": [" + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(this.getCharge(stack)) + + EnumChatFormatting.GRAY + + aEU + + "] [" + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack))) + + EnumChatFormatting.GRAY + + "%]"); + list.add(EnumChatFormatting.GOLD + aString6 + EnumChatFormatting.GRAY); + list.add( + EnumChatFormatting.GOLD + aStringTooltip + + " " + + (!isShowing ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_RED) + + !isShowing + + EnumChatFormatting.GRAY); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public double charge(final ItemStack stack, final double amount, final int tier, final boolean ignoreTransferLimit, + final boolean simulate) { + + if (!simulate) { + ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public double discharge(final ItemStack stack, final double amount, final int tier, + final boolean ignoreTransferLimit, final boolean externally, final boolean simulate) { + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(final ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(final ItemStack stack, final double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(final ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public BaubleType getBaubleType(final ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override // TODO + public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onWornTick(final ItemStack baubleStack, final EntityLivingBase arg1) { + if (arg1 != null && arg1.worldObj != null && !arg1.worldObj.isRemote) { + + // Try Charge First + + // Inv Slots + for (final ItemStack aInvStack : ((EntityPlayer) arg1).inventory.mainInventory) { + if (aInvStack == baubleStack) { + continue; + } + + if (this.getCharge(baubleStack) == this.getMaxCharge(baubleStack)) { + break; + } + + if (aInvStack != null) { + if (ChargingHelper.isItemValid(aInvStack)) { + + double aTransferRate; + double aCurrentChargeForThisBauble; + int mTier; + final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); + + if (electricItem != null) { + + aTransferRate = electricItem.getTransferLimit(aInvStack); + mTier = electricItem.getTier(aInvStack); + aCurrentChargeForThisBauble = ElectricItem.manager.getCharge(baubleStack); + + if (aCurrentChargeForThisBauble < maxValueEU) { + if ((ElectricItem.manager.getCharge(aInvStack) >= aTransferRate)) { + if (electricItem.canProvideEnergy(aInvStack)) { + double d = ElectricItem.manager + .discharge(aInvStack, aTransferRate, mTier, false, true, false); + // Logger.INFO("Charging from "+aInvStack.getDisplayName() +" | "+d); + ElectricItem.manager.charge(baubleStack, d, mTier, true, false); + } + } + } + } + } + } + if (this.getCharge(baubleStack) <= (this.getMaxCharge(baubleStack) - getTransferLimit(baubleStack))) { + continue; + } else { + break; + } + } + + // Try Heal + if (this.getCharge(baubleStack) > 0) { + + if (!(arg1 instanceof EntityPlayer g)) { + return; + } + // health Check + float hp = 0; + if (arg1.getHealth() < arg1.getMaxHealth()) { + final float rx = arg1.getMaxHealth() - arg1.getHealth(); + Logger.INFO("rx:" + rx); + arg1.heal(rx * 2); + hp = rx; + this.discharge(baubleStack, (1638400) * rx, 6, true, true, false); + } + + int hunger = 0; + float saturation = 0; + FoodStats aFood = g.getFoodStats(); + if (aFood != null) { + // Hunger Check + hunger = 20 - aFood.getFoodLevel(); + // Saturation Check + if (hunger > 0) { + saturation = 20f - aFood.getSaturationLevel(); + saturation /= hunger * 2f; + this.discharge(baubleStack, (1638400) * (hunger + saturation), 6, true, true, false); + aFood.addStats(hunger, saturation); + } + } + + // Only show Messages if they're enabled. + if (getShowMessages(baubleStack)) { + if (hp > 0 || hunger > 0 || saturation > 0) PlayerUtils + .messagePlayer((EntityPlayer) arg1, "Your NanoBooster Whirs! Leaving you feeling stronger."); + + if (hp > 0) PlayerUtils + .messagePlayer((EntityPlayer) arg1, "Healed " + GT_Utility.formatNumbers(hp) + " hp."); + + if (hunger > 0) PlayerUtils + .messagePlayer((EntityPlayer) arg1, "Healed " + GT_Utility.formatNumbers(hunger) + " hunger."); + + if (saturation > 0) PlayerUtils.messagePlayer( + (EntityPlayer) arg1, + "Satured Hunger by " + GT_Utility.formatNumbers(saturation) + "."); + + if (hp > 0 || hunger > 0 || saturation > 0) PlayerUtils.messagePlayer( + (EntityPlayer) arg1, + "You check it's remaining uses, it has " + GT_Utility.formatNumbers(secondsLeft(baubleStack)) + + " seconds left."); + } + } + } + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + tagMain.setBoolean("ShowMSG", false); + rStack.setTagCompound(tagMain); + return true; + } + + public static final boolean getShowMessages(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT == null) { + if (!createNBT(aStack)) { + return false; + } else { + aNBT = aStack.getTagCompound(); + } + } + return aNBT.getBoolean("ShowMSG"); + } + + public static final boolean setShowMessages(final ItemStack aStack, final boolean aShow) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT == null) { + if (!createNBT(aStack)) { + return false; + } else { + aNBT = aStack.getTagCompound(); + } + } + aNBT.setBoolean("ShowMSG", aShow); + return true; + } + + @Override + public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, + int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + // TODO Auto-generated method stub + return super.onItemUse( + p_77648_1_, + p_77648_2_, + p_77648_3_, + p_77648_4_, + p_77648_5_, + p_77648_6_, + p_77648_7_, + p_77648_8_, + p_77648_9_, + p_77648_10_); + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + ItemStack superStack = super.onItemRightClick(aStack, aWorld, aPlayer); + boolean isShiftHeld = KeyboardUtils.isShiftKeyDown(); + if (isShiftHeld) { + boolean oldState = getShowMessages(superStack); + boolean newState = !oldState; + ItemHealingDevice.setShowMessages(superStack, newState); + PlayerUtils.messagePlayer(aPlayer, (!oldState ? "Showing info messages" : "Hiding info messages")); + } + return superStack; + } + + @Override + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemLavaFilter.java b/src/main/java/gtPlusPlus/core/item/general/ItemLavaFilter.java new file mode 100644 index 0000000000..2b5dd8883f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/ItemLavaFilter.java @@ -0,0 +1,84 @@ +package gtPlusPlus.core.item.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; + +import gregtech.api.enums.ItemList; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.CoreItem; + +public class ItemLavaFilter extends CoreItem { + + public IIcon[] mIcon = new IIcon[1]; + + public ItemLavaFilter() { + super( + "itemLavaFilter", + AddToCreativeTab.tabMachines, + 1, + 99, + new String[] { "Lava Filter" }, + EnumRarity.common, + EnumChatFormatting.BLACK, + false, + null); + setGregtechItemList(); + } + + private boolean setGregtechItemList() { + ItemList.Component_LavaFilter.set(this); + return ItemList.Component_LavaFilter.get(1) != null ? true : false; + } + + @Override + public void registerIcons(IIconRegister reg) { + this.mIcon[0] = reg.registerIcon(GTPlusPlus.ID + ":" + "itemLavaFilter"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.mIcon[0]; + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("item.itemLavaFilter.tooltip")); + + int maxDurability = stack.getMaxDamage() + 1; + int durability = maxDurability - stack.getItemDamage(); + + EnumChatFormatting formatting = EnumChatFormatting.GRAY; + if (durability > maxDurability * 0.8) { + formatting = EnumChatFormatting.GRAY; + } else if (durability > maxDurability * 0.6) { + formatting = EnumChatFormatting.GREEN; + } else if (durability > maxDurability * 0.4) { + formatting = EnumChatFormatting.YELLOW; + } else if (durability > maxDurability * 0.2) { + formatting = EnumChatFormatting.GOLD; + } else if (durability > 0) { + formatting = EnumChatFormatting.RED; + } + list.add("Uses remaining: " + formatting + durability + EnumChatFormatting.GRAY + " / " + maxDurability); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } + + @Override + public boolean isRepairable() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemMagicFeather.java b/src/main/java/gtPlusPlus/core/item/general/ItemMagicFeather.java new file mode 100644 index 0000000000..9b4dd86525 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/ItemMagicFeather.java @@ -0,0 +1,260 @@ +package gtPlusPlus.core.item.general; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.lang.ref.WeakReference; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.WeakHashMap; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingDeathEvent; + +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.base.CoreItem; + +public class ItemMagicFeather extends CoreItem { + + public static final String NAME = "magicfeather"; + private static final WeakHashMap<EntityPlayer, MagicFeatherData> sPlayerData = new WeakHashMap<>(); + private static final WeakHashMap<EntityPlayer, HashSet<TileEntityBeacon>> sBeaconData = new WeakHashMap<>(); + + public ItemMagicFeather() { + super( + "magicfeather", + AddToCreativeTab.tabMisc, + 1, + 100, + new String[] { "Lets you fly around Beacons" }, + EnumRarity.uncommon, + null, + false, + null); + setMaxStackSize(1); + setUnlocalizedName(GTPlusPlus.ID + ":" + NAME); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + @SuppressWarnings("unchecked") + @Override + @SideOnly(Side.CLIENT) + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add("Does not need to be the item held in your hand to work"); + super.addInformation(stack, aPlayer, list, bool); + list.add("Needs to be within beacon range"); + list.add("Range is beacon level * 10 + 10"); + } + + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } + + private static boolean isInBeaconRange(EntityPlayer player) { + World world = player.getEntityWorld(); + if (world.isRemote) { + return false; + } + HashSet<TileEntityBeacon> aBeaconData = sBeaconData.computeIfAbsent(player, k -> new HashSet<>()); + int chunkXlo = (int) (player.posX - 50) >> 4, chunkXhi = (int) (player.posX + 50) >> 4, + chunkZlo = (int) (player.posZ - 50) >> 4, chunkZhi = (int) (player.posZ + 50) >> 4; + for (int chunkX = chunkXlo; chunkX < chunkXhi; chunkX++) { + for (int chunkZ = chunkZlo; chunkZ < chunkZhi; chunkZ++) { + if (!world.getChunkProvider() + .chunkExists(chunkX, chunkZ)) continue; + findSuitableBeacon( + player, + world.getChunkFromChunkCoords(chunkX, chunkZ).chunkTileEntityMap.values(), + aBeaconData); + } + } + return aBeaconData.size() > 0; + } + + private static void findSuitableBeacon(EntityPlayer player, Collection<TileEntity> tileEntities, + HashSet<TileEntityBeacon> aBeaconData) { + for (TileEntity t : tileEntities) { + if (!(t instanceof TileEntityBeacon beacon)) { + continue; + } + int level = beacon.getLevels(); + if (level == 0) { + continue; + } + int radius = (level * 10 + 10); + int x = beacon.xCoord; + int z = beacon.zCoord; + if (player.posX < (x - radius) || player.posX > (x + radius)) { + continue; + } + if (player.posZ < (z - radius) || player.posZ > (z + radius)) { + continue; + } + aBeaconData.add(beacon); + } + } + + private static void setMayFly(EntityPlayer player, boolean mayFly) { + if (player.capabilities.allowFlying == mayFly) { + return; + } + if (!mayFly) { + // force the player on the ground then remove ability to fly + // this prevent crashing the the ground and dying + // when you accidentally get out of the beacon range + player.capabilities.isFlying = false; + if (player.onGround && player.fallDistance < 1F) { + player.capabilities.allowFlying = false; + } + } else { + player.capabilities.allowFlying = true; + } + player.sendPlayerAbilities(); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerTick(TickEvent.PlayerTickEvent event) { + if (event.side != Side.SERVER || event.phase != Phase.END) { + return; + } + EntityPlayer player = event.player; + HashSet<TileEntityBeacon> aBeaconData = sBeaconData.get(player); + if (aBeaconData != null && !aBeaconData.isEmpty()) { + for (Iterator<TileEntityBeacon> iterator = aBeaconData.iterator(); iterator.hasNext();) { + TileEntityBeacon aBeacon = iterator.next(); + int level = aBeacon.getLevels(); + if (level == 0) { + iterator.remove(); + continue; + } + int radius = (level * 10 + 10); + int x = aBeacon.xCoord; + int z = aBeacon.zCoord; + if (player.posX < (x - radius) || player.posX > (x + radius) + || player.posZ < (z - radius) + || player.posZ > (z + radius)) { + iterator.remove(); + } + } + } + boolean hasItem = hasItem(player, ModItems.itemMagicFeather); + if (!hasItem) { + ItemMagicFeather.sPlayerData.remove(player); + } + MagicFeatherData data = ItemMagicFeather.sPlayerData.get(player); + if (data == null) { + data = new MagicFeatherData(player); + ItemMagicFeather.sPlayerData.put(player, data); + } + data.onTick(); + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onPlayerDeath(LivingDeathEvent event) { + if (event.entityLiving == null) return; + EntityLivingBase aEntity = event.entityLiving; + if (!(aEntity instanceof EntityPlayer aPlayer) || aEntity.worldObj == null || aEntity.worldObj.isRemote) return; + ItemMagicFeather.sPlayerData.remove(aPlayer); + ItemMagicFeather.sBeaconData.remove(aPlayer); + } + + private static boolean hasItem(EntityPlayer player, Item item) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if (stack != null && stack.getItem() != null && stack.getItem() instanceof ItemMagicFeather) { + return true; + } + } + return false; + } + + private static class MagicFeatherData { + + private final WeakReference<EntityPlayer> player; + private boolean hasItem = false; + private int checkTick = 0; + private boolean beaconInRangeCache; + + public MagicFeatherData(EntityPlayer player) { + this.player = new WeakReference<>(player); + this.beaconInRangeCache = player.capabilities.allowFlying; + } + + public void onTick() { + EntityPlayer player = this.player.get(); + if (player == null) return; + try { + boolean hasItem = hasItem(player, ModItems.itemMagicFeather); + if (hasItem != this.hasItem) { + if (hasItem) { + this.onAdd(); + } + if (!hasItem) { + this.onRemove(); + } + this.hasItem = hasItem; + Logger.INFO("Ticking feather " + hasItem); + return; + } + } catch (Throwable t) { + t.printStackTrace(); + } + + if (hasItem) { + // only modify if hasItem. Override other flight methods since you are literally holding this item in + // your own inventory. You have sent your consent. + boolean mayFly = player.capabilities.isCreativeMode || checkBeaconInRange(player); + setMayFly(player, mayFly); + } + } + + private void onAdd() { + if (!ItemMagicFeather.isInBeaconRange(getPlayer())) { + return; + } + setMayFly(getPlayer(), true); + } + + private void onRemove() { + if (getPlayer().capabilities.isCreativeMode) { + return; + } + setMayFly(getPlayer(), false); + } + + private boolean checkBeaconInRange(EntityPlayer player) { + if (checkTick++ % 40 != 0) { + return beaconInRangeCache; + } + beaconInRangeCache = ItemMagicFeather.isInBeaconRange(player); + return beaconInRangeCache; + } + + private EntityPlayer getPlayer() { + return player.get(); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/books/ItemBaseBook.java b/src/main/java/gtPlusPlus/core/item/general/books/ItemBaseBook.java new file mode 100644 index 0000000000..87c5ab3e74 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/books/ItemBaseBook.java @@ -0,0 +1,122 @@ +package gtPlusPlus.core.item.general.books; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gtPlusPlus.core.handler.BookHandler.mBookMap; +import static gtPlusPlus.core.util.Utils.addBookTitleLocalization; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemWritableBook; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.BookHandler; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class ItemBaseBook extends ItemWritableBook { + + public ItemBaseBook() { + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(1); + this.setTextureName(GTPlusPlus.ID + ":" + "itemBook"); + this.setUnlocalizedName("itembookgt"); + GameRegistry.registerItem(this, "bookGT"); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < BookHandler.mBookMap.size(); i++) { + ItemStack bookstack = new ItemStack(item, 1, i); + + /* + * bookstack = Utils.getWrittenBook( bookstack, i, mBookMap.get(i).mMapping, mBookMap.get(i).mTitle, + * mBookMap.get(i).mAuthor, mBookMap.get(i).mPages); + */ + + NBTUtils.createIntegerTagCompound(bookstack, "stats", "mMeta", i); + list.add(bookstack); + } + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if (NBTUtils.hasKey(tItem, "title")) { + return NBTUtils.getString(tItem, "title"); + } else if (tItem.getItemDamage() > -1 && tItem.getItemDamage() <= mBookMap.size()) { + return EnumChatFormatting.ITALIC + "" + + addBookTitleLocalization(mBookMap.get(tItem.getItemDamage()).mTitle); + } + // NBTUtils.tryIterateNBTData(tItem); + return "GT++ Storybook"; + } + + @Override + public void addInformation(ItemStack tItem, EntityPlayer player, List list, boolean bool) { + // TODO Auto-generated method stub + if (NBTUtils.hasKey(tItem, "author")) { + list.add(EnumChatFormatting.GRAY + "Author: " + NBTUtils.getString(tItem, "author")); + } else if (mBookMap.get(tItem.getItemDamage()).mAuthor != null) { + list.add(EnumChatFormatting.WHITE + "Author: " + mBookMap.get(tItem.getItemDamage()).mAuthor); + } + if (NBTUtils.hasKey(tItem, "title")) { + list.add(EnumChatFormatting.GRAY + "Pages: " + NBTUtils.getString(tItem, "pages")); + } else if (mBookMap.get(tItem.getItemDamage()).mPages != null) { + list.add(EnumChatFormatting.WHITE + "Pages: " + mBookMap.get(tItem.getItemDamage()).mPages.length); + } + // super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + // player.displayGUIBook(item); + int i = item.getItemDamage(); + ItemStack bookstack = Utils.getWrittenBook( + null, + mBookMap.get(i).mMeta, + mBookMap.get(i).mMapping, + mBookMap.get(i).mTitle, + mBookMap.get(i).mAuthor, + mBookMap.get(i).mPages); + + if (player.worldObj.isRemote) { + try { + Class<?> clazz = ReflectionUtils.getClass("net.minecraft.client.gui.GuiScreenBook"); + Constructor<?> ctor = clazz.getConstructor(EntityPlayer.class, ItemStack.class, boolean.class); + Object object = ctor.newInstance(new Object[] { player, bookstack, false }); + Minecraft.getMinecraft() + .displayGuiScreen((GuiScreen) object); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | NoSuchMethodException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(player, bookstack, false)); + } + return item; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/chassis/ItemBoilerChassis.java b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemBoilerChassis.java new file mode 100644 index 0000000000..8efcfe6912 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemBoilerChassis.java @@ -0,0 +1,72 @@ +package gtPlusPlus.core.item.general.chassis; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; + +public class ItemBoilerChassis extends Item { + + public IIcon[] icons = new IIcon[1]; + + public ItemBoilerChassis() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemBoilerChassis"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(GTPlusPlus.ID + ":" + "itemBoilerChassis"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[0]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 3; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + return StatCollector.translateToLocalFormatted("item.itemBoilerChassis.name", tItem.getItemDamage()); + } + + @Override // TODO + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + int meta = stack.getItemDamage(); + if (meta == 0) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(10, 110, 30); + } else if (meta == 1) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(150, 180, 35); + } else if (meta == 2) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(200, 85, 40); + } else if (meta == 3) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(255, 100, 50); + } + return HEX_OxFFFFFF; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoil.java b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoil.java new file mode 100644 index 0000000000..24759808ab --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoil.java @@ -0,0 +1,70 @@ +package gtPlusPlus.core.item.general.chassis; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GT_Values; +import gtPlusPlus.core.creative.AddToCreativeTab; + +public class ItemDehydratorCoil extends Item { + + public IIcon[] icons = new IIcon[4]; + + public ItemDehydratorCoil() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemDehydratorCoil"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(GTPlusPlus.ID + ":" + "dehydrator/itemDehydratorCoil_0"); + this.icons[1] = reg.registerIcon(GTPlusPlus.ID + ":" + "dehydrator/itemDehydratorCoil_1"); + this.icons[2] = reg.registerIcon(GTPlusPlus.ID + ":" + "dehydrator/itemDehydratorCoil_2"); + this.icons[3] = reg.registerIcon(GTPlusPlus.ID + ":" + "dehydrator/itemDehydratorCoil_3"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 4; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + return StatCollector + .translateToLocalFormatted("item.itemDehydratorCoil.name", GT_Values.VN[tItem.getItemDamage() + 4]); + } + + /* + * @Override public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { int meta = + * stack.getItemDamage(); if (meta == 0){ HEX_OxFFFFFF = Utils.rgbtoHexValue(10,110,30); } else if (meta == 1){ + * HEX_OxFFFFFF = Utils.rgbtoHexValue(150,180,35); } else if (meta == 2){ HEX_OxFFFFFF = + * Utils.rgbtoHexValue(200,85,40); } else if (meta == 3){ HEX_OxFFFFFF = Utils.rgbtoHexValue(255,150,50); } return + * HEX_OxFFFFFF; } + */ + +} diff --git a/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoilWire.java b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoilWire.java new file mode 100644 index 0000000000..b050e4c65c --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoilWire.java @@ -0,0 +1,70 @@ +package gtPlusPlus.core.item.general.chassis; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GT_Values; +import gtPlusPlus.core.creative.AddToCreativeTab; + +public class ItemDehydratorCoilWire extends Item { + + public IIcon[] icons = new IIcon[4]; + + public ItemDehydratorCoilWire() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemDehydratorCoilWire"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(GTPlusPlus.ID + ":" + "dehydrator/itemDehydratorCoilWire_0"); + this.icons[1] = reg.registerIcon(GTPlusPlus.ID + ":" + "dehydrator/itemDehydratorCoilWire_1"); + this.icons[2] = reg.registerIcon(GTPlusPlus.ID + ":" + "dehydrator/itemDehydratorCoilWire_2"); + this.icons[3] = reg.registerIcon(GTPlusPlus.ID + ":" + "dehydrator/itemDehydratorCoilWire_3"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 4; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + return StatCollector + .translateToLocalFormatted("item.itemDehydratorCoilWire.name", GT_Values.VN[tItem.getItemDamage() + 4]); + } + + /* + * @Override public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { int meta = + * stack.getItemDamage(); if (meta == 0){ HEX_OxFFFFFF = Utils.rgbtoHexValue(10,110,30); } else if (meta == 1){ + * HEX_OxFFFFFF = Utils.rgbtoHexValue(150,180,35); } else if (meta == 2){ HEX_OxFFFFFF = + * Utils.rgbtoHexValue(200,85,40); } else if (meta == 3){ HEX_OxFFFFFF = Utils.rgbtoHexValue(255,150,50); } return + * HEX_OxFFFFFF; } + */ + +} diff --git a/src/main/java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java b/src/main/java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java new file mode 100644 index 0000000000..c186fccd4b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java @@ -0,0 +1,278 @@ +package gtPlusPlus.core.item.general.spawn; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class ItemCustomSpawnEgg extends ItemMonsterPlacer { + + private static final HashMap<Integer, IIcon> mIconMap = new HashMap<>(); + private static int mTotalMetaItems = 0; + + private static final HashMap<Integer, Integer> mMaxStackSizeMap = new HashMap<>(); + private static final HashMap<Integer, EnumRarity> mRarityMap = new HashMap<>(); + private static final HashMap<Integer, ArrayList<String>> mOreDictNames = new HashMap<>(); + + private static final HashMap<Integer, Integer> mColourBaseMap = new HashMap<>(); + private static final HashMap<Integer, Integer> mColourSpotsMap = new HashMap<>(); + private static final HashMap<Integer, String> mEntityNameMap = new HashMap<>(); + private static final HashMap<Integer, String> mEntityFullNameMap = new HashMap<>(); + + private static final HashMap<String, Integer> mReverseEntityMap = new HashMap<>(); + + protected EntityLiving entityToSpawn = null; + + public static void registerEntityForSpawnEgg(final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, + int aSecondaryColor) { + registerEntityForSpawnEgg( + aMetaID, + parEntityToSpawnName, + aPrimaryColor, + aSecondaryColor, + EnumRarity.common, + new ArrayList<String>()); + } + + public static void registerEntityForSpawnEgg(final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, + int aSecondaryColor, EnumRarity aRarity, final ArrayList<String> aOreDictNames) { + mTotalMetaItems++; + mMaxStackSizeMap.put(aMetaID, 64); + mRarityMap.put(aMetaID, aRarity); + mOreDictNames.put(aMetaID, aOreDictNames); + mColourBaseMap.put(aMetaID, aPrimaryColor); + mColourSpotsMap.put(aMetaID, aSecondaryColor); + mReverseEntityMap.put(parEntityToSpawnName, aMetaID); + setEntityToSpawnName(aMetaID, parEntityToSpawnName); + } + + public ItemCustomSpawnEgg() { + super(); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + this.setUnlocalizedName("BasicMetaSpawnEgg"); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + } + + /** + * Callback for item usage. If the item does something special on right clicking, + * + * he will have one of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS + */ + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, + int par5, int par6, int par7, float par8, float par9, float par10) { + if (par3World.isRemote) { + return true; + } else { + Block block = par3World.getBlock(par4, par5, par6); + par4 += Facing.offsetsXForSide[par7]; + par5 += Facing.offsetsYForSide[par7]; + par6 += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if (par7 == 1 && block.getRenderType() == 11) { + d0 = 0.5D; + } + + Entity entity = spawnEntity(par1ItemStack, par3World, par4 + 0.5D, par5 + d0, par6 + 0.5D); + + if (entity != null) { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) { + ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par2EntityPlayer.capabilities.isCreativeMode) { + --par1ItemStack.stackSize; + } + } + + return true; + } + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. + * + * Args: itemStack, world, entityPlayer + */ + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (par2World.isRemote) { + return par1ItemStack; + } else { + MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer( + par2World, + par3EntityPlayer, + true); + + if (movingobjectposition == null) { + return par1ItemStack; + } else { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) { + + return par1ItemStack; + } + + if (par2World.getBlock(i, j, k) instanceof BlockLiquid) { + Entity entity = spawnEntity(par1ItemStack, par2World, i, j, k); + + if (entity != null) { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) { + + ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par3EntityPlayer.capabilities.isCreativeMode) { + --par1ItemStack.stackSize; + } + } + } + } + + return par1ItemStack; + } + } + } + + /** + * Spawns the creature specified by the egg's type in the location specified by + * + * the last three parameters. Parameters: world, entityID, x, y, z. + * + * @param par1ItemStack + */ + public Entity spawnEntity(ItemStack par1ItemStack, World parWorld, double parX, double parY, double parZ) { + + if (!parWorld.isRemote) // never spawn entity on client side + { + int aDamage = par1ItemStack.getItemDamage(); + String entityToSpawnNameFull = mEntityFullNameMap.get(aDamage); + String entityToSpawnName = mEntityNameMap.get(aDamage); + // entityToSpawnNameFull = WildAnimals.MODID + "." + entityToSpawnName; + if (EntityList.stringToClassMapping.containsKey(entityToSpawnNameFull)) { + entityToSpawn = (EntityLiving) EntityList.createEntityByName(entityToSpawnNameFull, parWorld); + entityToSpawn.setLocationAndAngles( + parX, + parY, + parZ, + MathHelper.wrapAngleTo180_float(parWorld.rand.nextFloat() * 360.0F), + 0.0F); + parWorld.spawnEntityInWorld(entityToSpawn); + entityToSpawn.onSpawnWithEgg((IEntityLivingData) null); + entityToSpawn.playLivingSound(); + } else { + // DEBUG + System.out.println("Entity not found " + entityToSpawnName); + } + } + + return entityToSpawn; + } + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { + for (int aMeta : mReverseEntityMap.values()) { + aList.add(ItemUtils.simpleMetaStack(aItem, aMeta, 1)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int parColorType) { + int aID = par1ItemStack.getItemDamage(); + return (parColorType == 0) ? mColourBaseMap.get(aID) : mColourSpotsMap.get(aID); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + // Doing this override means that there is no localization for language + // unless you specifically check for localization here and convert + public String getItemStackDisplayName(ItemStack par1ItemStack) { + return StatCollector.translateToLocalFormatted( + "item.ItemCustomSpawnEgg.name", + StatCollector.translateToLocal("entity." + mEntityNameMap.get(par1ItemStack.getItemDamage()) + ".name")); + } + + @Override + public void registerIcons(final IIconRegister u) { + mIconMap.put(0, u.registerIcon(GTPlusPlus.ID + ":" + "spawn_egg")); + mIconMap.put(1, u.registerIcon(GTPlusPlus.ID + ":" + "spawn_egg_overlay")); + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int renderPass) { + return mIconMap.get(renderPass); + } + + @Override + public IIcon getIconFromDamage(int damage) { + return getIconFromDamageForRenderPass(0, 0); + } + + @Override + public IIcon getIcon(ItemStack aStack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return getIconFromDamageForRenderPass(0, renderPass); + } + + @Override + public IIcon getIcon(ItemStack aStack, int renderPass) { + return getIconFromDamageForRenderPass(0, renderPass); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + public static void setEntityToSpawnName(int aMetaID, String parEntityToSpawnName) { + mEntityNameMap.put(aMetaID, parEntityToSpawnName); + mEntityFullNameMap.put(aMetaID, GTPlusPlus.ID + "." + parEntityToSpawnName); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/init/ItemsFoods.java b/src/main/java/gtPlusPlus/core/item/init/ItemsFoods.java new file mode 100644 index 0000000000..acddd58a7b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/init/ItemsFoods.java @@ -0,0 +1,50 @@ +package gtPlusPlus.core.item.init; + +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.item.ItemStack; + +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.food.BaseItemMetaFood; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; + +public class ItemsFoods { + + public static void load() { + run(); + } + + private static void run() { + + ModItems.itemMetaFood = new BaseItemMetaFood(); + BaseItemMetaFood.registerFoodsToOreDict(); + addCookingRecipes(); + addFoodDropsToMobs(); + } + + private static ItemStack getMetaFoodStack(int aID) { + return ItemUtils.simpleMetaStack(ModItems.itemMetaFood, aID, 1); + } + + private static void addCookingRecipes() { + + RecipeUtils.addSmeltingRecipe(getMetaFoodStack(0), getMetaFoodStack(1), 0.4F); + RecipeUtils.addSmeltingRecipe(getMetaFoodStack(2), getMetaFoodStack(3), 0.35F); + RecipeUtils.addSmeltingRecipe(getMetaFoodStack(4), getMetaFoodStack(5), 0.35F); + RecipeUtils.addSmeltingRecipe(getMetaFoodStack(6), getMetaFoodStack(7), 0.35F); + } + + private static void addFoodDropsToMobs() { + + EntityUtils.registerDropsForMob(EntityVillager.class, getMetaFoodStack(0), 2, 1500); + EntityUtils.registerDropsForMob(EntityHorse.class, getMetaFoodStack(2), 4, 4000); + EntityUtils.registerDropsForMob(EntityWolf.class, getMetaFoodStack(4), 2, 4000); + EntityUtils.registerDropsForMob(EntityOcelot.class, getMetaFoodStack(6), 2, 4000); + EntityUtils.registerDropsForMob(EntityBlaze.class, getMetaFoodStack(8), 1, 500); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/materials/DustDecayable.java b/src/main/java/gtPlusPlus/core/item/materials/DustDecayable.java new file mode 100644 index 0000000000..eaf8c2c9da --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/materials/DustDecayable.java @@ -0,0 +1,97 @@ +package gtPlusPlus.core.item.materials; + +import static gregtech.api.enums.Mods.GregTech; +import static gtPlusPlus.core.util.minecraft.ItemUtils.getSimpleStack; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +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; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class DustDecayable extends BaseItemTickable { + + private final Item turnsIntoItem; + private final int radLevel; + + public DustDecayable(String unlocal, int colour, int maxTicks, String[] desc1, Item turnsInto, int radLevel) { + super(true, true, unlocal, colour, (maxTicks / 1), desc1); + this.turnsIntoItem = turnsInto; + this.radLevel = radLevel; + GT_OreDictUnificator.registerOre(unlocal, ItemUtils.getSimpleStack(this)); + new DecayableRecipe(maxTicks, getSimpleStack(this), getSimpleStack(turnsInto)); + } + + @Override + public void registerIcons(IIconRegister reg) { + String gt = GregTech.ID + ":" + "materialicons/" + "NUCLEAR" + "/" + "dust"; + this.mIcon[0] = reg.registerIcon(gt); + String gt2 = GregTech.ID + ":" + "materialicons/" + "NUCLEAR" + "/" + "dust" + "_OVERLAY"; + this.mIcon[1] = reg.registerIcon(gt2); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + super.addInformation(stack, player, list, bool); + if (this.radLevel > 0) { + list.add(CORE.GT_Tooltip_Radioactive.get()); + } + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + if (world == null || iStack == null) { + return; + } + if (world.isRemote) { + return; + } + + if (entityHolding instanceof EntityPlayer) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.radLevel, world, entityHolding); + } + } + boolean a1, a2; + + a1 = this.isTicking(world, iStack); + a2 = tickItemTag(world, iStack); + + if (!a1 && !a2) { + if (entityHolding instanceof EntityPlayer) { + ItemStack replacement = ItemUtils.getSimpleStack(getDecayResult()); + // Logger.INFO("Replacing "+iStack.getDisplayName()+" with "+replacement.getDisplayName()+"."); + final ItemStack tempTransform = replacement; + if (iStack.stackSize > 1) { + int u = iStack.stackSize; + tempTransform.stackSize = u; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + for (int l = 0; l < u; l++) { + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + + } else { + tempTransform.stackSize = 1; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + } + } + } + + public Item getDecayResult() { + return turnsIntoItem; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java b/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java new file mode 100644 index 0000000000..5ba3aa1531 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java @@ -0,0 +1,1320 @@ +package gtPlusPlus.core.item.tool.misc; + +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.util.GT_Utility.formatNumbers; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.IFluidTank; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gregtech.api.interfaces.IItemBehaviour; +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_MultiInput; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; +import ic2.api.item.ISpecialElectricItem; + +public class GregtechPump extends Item implements ISpecialElectricItem, IElectricItemManager, IFluidContainerItem { + + /** + * Right Click Functions + */ + @Override + public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int a4, + float p_77648_8_, float p_77648_9_, float p_77648_10_) { + if (aStack == null || aPlayer == null || aWorld == null || aWorld.isRemote) { + return false; + } + if (!aWorld.isRemote && tryDrainTile(aStack, aWorld, aPlayer, aX, aY, aZ)) { + return true; + } else { + // return super.onItemUse(aStack, aPlayer, aWorld, aX, aY, aZ, a4, p_77648_8_, p_77648_9_, p_77648_10_); + return false; + } + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + return p_77659_1_; + } + + /** + * GT Code + */ + + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + private final HashMap<Short, ArrayList<IItemBehaviour<GregtechPump>>> mItemBehaviors = new HashMap<>(); + + public final short mOffset, mItemAmount; + public final BitSet mEnabledItems; + public final BitSet mVisibleItems; + /** The unlocalized name of this item. */ + private String unlocalizedName; + + private final HashMap<Integer, IIcon> mIconMap = new LinkedHashMap<>(); + private final HashMap<Integer, EnumRarity> rarity = new LinkedHashMap<>(); + private final HashMap<Integer, String> itemName = new LinkedHashMap<>(); + private final HashMap<Integer, Boolean> hasEffect = new LinkedHashMap<>(); + + public final HashMap<Short, Long[]> mElectricStats = new LinkedHashMap<>(); + public final HashMap<Short, Short> mBurnValues = new LinkedHashMap<>(); + + public void registerPumpType(final int aID, final String aPumpName, final int aEuMax, final int aTier) { + ModItems.toolGregtechPump.registerItem( + aID, // ID + aPumpName, // Name + aEuMax, // Eu Storage + (short) aTier, // Tier/ Tooltip + aTier <= 0 ? EnumRarity.common + : aTier == 1 ? EnumRarity.uncommon + : aTier == 2 ? EnumRarity.rare : aTier == 3 ? EnumRarity.epic : EnumRarity.common, // Rarity + false // Effect? + ); + } + + public GregtechPump() { + this("MU-metatool.01", AddToCreativeTab.tabTools, (short) 1000, (short) 31766); + } + + public GregtechPump(final String unlocalizedName, final CreativeTabs creativeTab, final short aOffset, + final short aItemAmount) { + this.mEnabledItems = new BitSet(aItemAmount); + this.mVisibleItems = new BitSet(aItemAmount); + this.mOffset = (short) Math.min(32766, aOffset); + this.mItemAmount = (short) Math.min(aItemAmount, 32766 - this.mOffset); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(1); + if (GameRegistry.findItem(GTPlusPlus.ID, unlocalizedName) == null) { + GameRegistry.registerItem(this, unlocalizedName); + } + } + + public void registerItem(final int id, final String localizedName, final long euStorage, final int tier) { + this.registerItem(id, localizedName, euStorage, (short) tier, EnumRarity.common, false); + } + + public void registerItem(final int id, final String localizedName, final long euStorage, final int tier, + final int burnTime) { + this.registerItem(id, localizedName, euStorage, (short) tier, EnumRarity.common, false); + this.setBurnValue(id, burnTime); + } + + public void registerItem(final int id, final String localizedName, final long euStorage, final short tier, + final EnumRarity regRarity, final boolean Effect) { + this.addItem( + id, + localizedName, + EnumChatFormatting.GRAY + "Can be used to remove fluids from GT machine input & output slots"); + if (euStorage > 0 && tier > 0) + this.setElectricStats(this.mOffset + id, euStorage, GT_Values.V[tier], tier, -3L, true); + this.rarity.put(id, regRarity); + this.itemName.put(id, localizedName); + this.hasEffect.put(id, Effect); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + int h = getCorrectMetaForItemstack(par1ItemStack); + if (this.rarity.get(h) != null) { + return this.rarity.get(h); + } + return EnumRarity.common; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack, final int pass) { + int h = getCorrectMetaForItemstack(par1ItemStack); + if (this.hasEffect.get(h) != null) { + return this.hasEffect.get(h); + } + return false; + } + + @SuppressWarnings({ "unchecked" }) + @Override + public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { + // aList.add("Meta: "+(aStack.getItemDamage()-mOffset)); + int aOffsetMeta = getCorrectMetaForItemstack(aStack); + aList.add( + GT_LanguageManager + .getTranslation("gtplusplus." + this.getUnlocalizedName(aStack) + "." + aOffsetMeta + ".tooltip")); + + if (aOffsetMeta <= 3) { + FluidStack f = getFluid(aStack); + aList.add(StatCollector.translateToLocal("item.itemGregtechPump.tooltip.0")); + aList.add(StatCollector.translateToLocal("item.itemGregtechPump.tooltip.1")); + aList.add(EnumChatFormatting.DARK_GRAY + StatCollector.translateToLocal("item.itemGregtechPump.tooltip.2")); + aList.add( + EnumChatFormatting.BLUE + (f != null ? f.getLocalizedName() + : StatCollector.translateToLocal("item.itemGregtechPump.tooltip.3"))); + aList.add( + EnumChatFormatting.BLUE + (f != null ? "" + f.amount : "" + 0) + + "L" + + " / " + + formatNumbers(getCapacity(aStack)) + + "L"); + } + + final Long[] tStats = this.getElectricStats(aStack); + if (tStats != null) { + if (tStats[3] > 0) { + aList.add( + EnumChatFormatting.AQUA + StatCollector.translateToLocalFormatted( + "item.itemBaseEuItem.tooltip.1", + formatNumbers(tStats[3]), + (tStats[2] >= 0 ? tStats[2] : 0)) + EnumChatFormatting.GRAY); + } else { + final long tCharge = this.getRealCharge(aStack); + if ((tStats[3] == -2) && (tCharge <= 0)) { + aList.add( + EnumChatFormatting.AQUA + StatCollector.translateToLocal("item.itemBaseEuItem.tooltip.2") + + EnumChatFormatting.GRAY); + } else { + aList.add( + EnumChatFormatting.AQUA + + StatCollector.translateToLocalFormatted( + "item.itemBaseEuItem.tooltip.3", + formatNumbers(tCharge), + formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: ", + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)]) + + EnumChatFormatting.GRAY); + } + } + } + + final ArrayList<IItemBehaviour<GregtechPump>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final IItemBehaviour<GregtechPump> tBehavior : tList) { + aList = tBehavior.getAdditionalToolTips(this, aList, aStack); + } + } + } + + @Override + public final Item getChargedItem(final ItemStack itemStack) { + return this; + } + + @Override + public final Item getEmptyItem(final ItemStack itemStack) { + return this; + } + + @Override + public final double getMaxCharge(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + return Math.abs(tStats[0]); + } + + @Override + public final double getTransferLimit(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + return Math.max(tStats[1], tStats[3]); + } + + @Override + public final int getTier(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + return (int) (tStats == null ? Integer.MAX_VALUE : tStats[2]); + } + + @Override + public final double charge(final ItemStack aStack, final double aCharge, final int aTier, + final boolean aIgnoreTransferLimit, final boolean aSimulate) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[2] > aTier) + || !((tStats[3] == -1) || (tStats[3] == -3) || ((tStats[3] < 0) && (aCharge == Integer.MAX_VALUE))) + || (aStack.stackSize != 1)) { + return 0; + } + final long tChargeBefore = this.getRealCharge(aStack), + tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE + : Math.min( + Math.abs(tStats[0]), + tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); + if (!aSimulate) { + this.setCharge(aStack, tNewCharge); + } + return tNewCharge - tChargeBefore; + } + + @Override + public final double discharge(final ItemStack aStack, final double aCharge, final int aTier, + final boolean aIgnoreTransferLimit, final boolean aBatteryAlike, final boolean aSimulate) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[2] > aTier)) { + return 0; + } + if (aBatteryAlike && !this.canProvideEnergy(aStack)) { + return 0; + } + if (tStats[3] > 0) { + if ((aCharge < tStats[3]) || (aStack.stackSize < 1)) { + return 0; + } + if (!aSimulate) { + aStack.stackSize--; + } + return tStats[3]; + } + final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = Math + .max(0, tChargeBefore - (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); + if (!aSimulate) { + this.setCharge(aStack, tNewCharge); + } + return tChargeBefore - tNewCharge; + } + + @Override + public final double getCharge(final ItemStack aStack) { + return this.getRealCharge(aStack); + } + + @Override + public final boolean canUse(final ItemStack aStack, final double aAmount) { + return this.getRealCharge(aStack) >= aAmount; + } + + @Override + public final boolean use(final ItemStack aStack, final double aAmount, final EntityLivingBase aPlayer) { + this.chargeFromArmor(aStack, aPlayer); + if ((aPlayer instanceof EntityPlayer) && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) { + return true; + } + final double tTransfer = this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true); + if (tTransfer == aAmount) { + this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); + this.chargeFromArmor(aStack, aPlayer); + return true; + } + this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); + this.chargeFromArmor(aStack, aPlayer); + return false; + } + + @Override + public final boolean canProvideEnergy(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return false; + } + return (tStats[3] > 0) || ((aStack.stackSize == 1) && ((tStats[3] == -2) || (tStats[3] == -3))); + } + + @Override + public final void chargeFromArmor(final ItemStack aStack, final EntityLivingBase aPlayer) { + if ((aPlayer == null) || aPlayer.worldObj.isRemote) { + return; + } + for (int i = 1; i < 5; i++) { + final ItemStack tArmor = aPlayer.getEquipmentInSlot(i); + if (GT_ModHandler.isElectricItem(tArmor)) { + final IElectricItem tArmorItem = (IElectricItem) tArmor.getItem(); + if (tArmorItem.canProvideEnergy(tArmor) && (tArmorItem.getTier(tArmor) >= this.getTier(aStack))) { + final double tCharge = ElectricItem.manager.discharge( + tArmor, + this.charge(aStack, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true, true), + Integer.MAX_VALUE, + true, + true, + false); + if (tCharge > 0) { + this.charge(aStack, tCharge, Integer.MAX_VALUE, true, false); + if (aPlayer instanceof EntityPlayer) { + final Container tContainer = ((EntityPlayer) aPlayer).openContainer; + if (tContainer != null) { + tContainer.detectAndSendChanges(); + } + } + } + } + } + } + } + + public final long getRealCharge(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + if (tStats[3] > 0) { + return (int) (long) tStats[3]; + } + final NBTTagCompound tNBT = aStack.getTagCompound(); + return tNBT == null ? 0 : tNBT.getLong("GT.ItemCharge"); + } + + public final boolean setCharge(final ItemStack aStack, long aCharge) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[3] > 0)) { + return false; + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + tNBT.removeTag("GT.ItemCharge"); + aCharge = Math.min(tStats[0] < 0 ? Math.abs(tStats[0] / 2) : aCharge, Math.abs(tStats[0])); + if (aCharge > 0) { + aStack.setItemDamage(this.getChargedMetaData(aStack)); + tNBT.setLong("GT.ItemCharge", aCharge); + } else { + aStack.setItemDamage(this.getEmptyMetaData(aStack)); + } + if (tNBT.hasNoTags()) { + aStack.setTagCompound(null); + } else { + aStack.setTagCompound(tNBT); + } + this.isItemStackUsable(aStack); + return true; + } + + public short getChargedMetaData(final ItemStack aStack) { + return (short) aStack.getItemDamage(); + } + + public short getEmptyMetaData(final ItemStack aStack) { + return (short) aStack.getItemDamage(); + } + + public boolean isItemStackUsable(final ItemStack aStack) { + final ArrayList<IItemBehaviour<GregtechPump>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final IItemBehaviour<GregtechPump> tBehavior : tList) { + if (!tBehavior.isItemStackUsable(this, aStack)) { + return false; + } + } + } + return true; + } + + @Override + public final String getToolTip(final ItemStack aStack) { + return null; + } // This has its own ToolTip Handler, no need to let the IC2 Handler screw us up + // at this Point + + @Override + public final IElectricItemManager getManager(final ItemStack aStack) { + return this; + } // We are our own Manager + + /** + * Sets the Furnace Burn Value for the Item. + * + * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aValue 200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU) + * @return the Item itself for convenience in constructing. + */ + public final GregtechPump setBurnValue(final int aMetaValue, final int aValue) { + if ((aMetaValue < 0) || (aValue < 0)) { + return this; + } + if (aValue == 0) { + this.mBurnValues.remove((short) aMetaValue); + } else { + this.mBurnValues.put((short) aMetaValue, aValue > Short.MAX_VALUE ? Short.MAX_VALUE : (short) aValue); + } + return this; + } + + /** + * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior) + * @param aTransferLimit Transfer Limit. + * @param aTier The electric Tier. + * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). Use -1 if you want to + * make this Battery chargeable (the use and canUse Functions will still discharge if you just + * use this) Use -2 if you want to make this Battery dischargeable. Use -3 if you want to make + * this Battery charge/discharge-able. + * @return the Item itself for convenience in constructing. + */ + public final GregtechPump setElectricStats(final int aMetaValue, final long aMaxCharge, final long aTransferLimit, + final long aTier, final long aSpecialData, final boolean aUseAnimations) { + if (aMetaValue < 0) { + return this; + } + if (aMaxCharge == 0) { + this.mElectricStats.remove((short) aMetaValue); + } else { + this.mElectricStats.put( + (short) aMetaValue, + new Long[] { aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData }); + } + return this; + } + + @SuppressWarnings({ "unchecked" }) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { + for (int i = 0, j = this.mEnabledItems.length(); i < j; i++) { + if (this.mVisibleItems.get(i) || (GT_Values.D1 && this.mEnabledItems.get(i))) { + final Long[] tStats = this.mElectricStats.get((short) (this.mOffset + i)); + if ((tStats != null) && (tStats[3] < 0)) { + final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); + this.setCharge(tStack, Math.abs(tStats[0])); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + if ((tStats == null) || (tStats[3] != -2)) { + final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(final IIconRegister aIconRegister) { + for (short i = 0, j = (short) this.mEnabledItems.length(); i < j; i++) { + if (this.mEnabledItems.get(i)) { + mIconMap.put( + (int) i, + aIconRegister.registerIcon(GTPlusPlus.ID + ":" + (this.getUnlocalizedName() + "/" + i))); + } + } + } + + @Override + public final IIcon getIconFromDamage(final int aMetaData) { + if (aMetaData < 0) { + return null; + } + if (aMetaData < this.mOffset) { + return mIconMap.get(0); + } else { + int newMeta = aMetaData - this.mOffset; + newMeta = (Math.max(0, Math.min(3, newMeta))); + return mIconMap.get(newMeta); + } + } + + /** + * Sets the unlocalized name of this item to the string passed as the parameter" + */ + @Override + public Item setUnlocalizedName(final String p_77655_1_) { + this.unlocalizedName = p_77655_1_; + super.setUnlocalizedName(p_77655_1_); + return this; + } + + /** + * Returns the unlocalized name of this item. + */ + @Override + public String getUnlocalizedName() { + return this.unlocalizedName; + } + + public final Long[] getElectricStats(final ItemStack aStack) { + return this.mElectricStats.get((short) aStack.getItemDamage()); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } + + /** + * Adds a special Item Behaviour to the Item. + * <p/> + * Note: the boolean Behaviours sometimes won't be executed if another boolean Behaviour returned true before. + * + * @param aMetaValue the Meta Value of the Item you want to add it to. [0 - 32765] + * @param aBehavior the Click Behavior you want to add. + * @return the Item itself for convenience in constructing. + */ + public final GregtechPump addItemBehavior(final int aMetaValue, final IItemBehaviour<GregtechPump> aBehavior) { + if ((aMetaValue < 0) || (aMetaValue >= 32766) || (aBehavior == null)) { + return this; + } + ArrayList<IItemBehaviour<GregtechPump>> tList = this.mItemBehaviors.get((short) aMetaValue); + if (tList == null) { + tList = new ArrayList<>(1); + this.mItemBehaviors.put((short) aMetaValue, tList); + } + tList.add(aBehavior); + return this; + } + + /** + * This adds a Custom Item to the ending Range. + * + * @param aID The Id of the assigned Item [0 - mItemAmount] (The MetaData gets auto-shifted by +mOffset) + * @param aEnglish The Default Localized Name of the created Item + * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip + * @param aFoodBehavior The Food Value of this Item. Can be null aswell. Just a convenience thing. + * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things. + * @return An ItemStack containing the newly created Item. + */ + @SuppressWarnings("unchecked") + public final ItemStack addItem(final int aID, final String aEnglish, String aToolTip, final Object... aRandomData) { + if (aToolTip == null) { + aToolTip = ""; + } + if ((aID >= 0) && (aID < this.mItemAmount)) { + final ItemStack rStack = new ItemStack(this, 1, this.mOffset + aID); + GT_ModHandler.registerBoxableItemToToolBox(rStack); + this.mEnabledItems.set(aID); + this.mVisibleItems.set(aID); + GT_LanguageManager + .addStringLocalization("gtplusplus." + this.getUnlocalizedName(rStack) + "." + aID + ".name", aEnglish); + GT_LanguageManager.addStringLocalization( + "gtplusplus." + this.getUnlocalizedName(rStack) + "." + aID + ".tooltip", + aToolTip); + final List<TC_AspectStack> tAspects = new ArrayList<>(); + // Important Stuff to do first + for (final Object tRandomData : aRandomData) { + if (tRandomData instanceof SubTag) { + if (tRandomData == SubTag.INVISIBLE) { + this.mVisibleItems.set(aID, false); + continue; + } + if (tRandomData == SubTag.NO_UNIFICATION) { + GT_OreDictUnificator.addToBlacklist(rStack); + continue; + } + } + } + // now check for the rest + for (final Object tRandomData : aRandomData) { + if (tRandomData != null) { + boolean tUseOreDict = true; + if (tRandomData instanceof IItemBehaviour) { + this.addItemBehavior(this.mOffset + aID, (IItemBehaviour<GregtechPump>) tRandomData); + tUseOreDict = false; + } + if (tRandomData instanceof IItemContainer) { + ((IItemContainer) tRandomData).set(rStack); + tUseOreDict = false; + } + if (tRandomData instanceof SubTag) { + continue; + } + if (tRandomData instanceof TC_AspectStack) { + ((TC_AspectStack) tRandomData).addToAspectList(tAspects); + continue; + } + if (tRandomData instanceof ItemData) { + if (GT_Utility.isStringValid(tRandomData)) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } else { + GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); + } + continue; + } + if (tUseOreDict) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + continue; + } + } + } + if (GregTech_API.sThaumcraftCompat != null) { + GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + } + return rStack; + } + return null; + } + + @Override + public String getItemStackDisplayName(final ItemStack aStack) { + int keyValue = (getCorrectMetaForItemstack(aStack)); + if (keyValue < 0 || keyValue > 3) { + keyValue = 0; + } + return GT_LanguageManager + .getTranslation("gtplusplus." + this.getUnlocalizedName(aStack) + "." + keyValue + ".name"); + } + + /** + * Fluid Handling + */ + + /* + * IFluidContainer Functions + */ + + public void emptyStoredFluid(ItemStack aStack) { + if (aStack.hasTagCompound()) { + NBTTagCompound t = aStack.getTagCompound(); + if (t.hasKey("mInit")) { + t.removeTag("mInit"); + } + if (t.hasKey("mFluid")) { + t.removeTag("mFluid"); + } + if (t.hasKey("mFluidAmount")) { + t.removeTag("mFluidAmount"); + } + } + } + + public void storeFluid(ItemStack aStack, FluidStack aFluid) { + if (aFluid == null) { + return; + } else { + String fluidname = aFluid.getFluid() + .getName(); + int amount = aFluid.amount; + if (fluidname != null && fluidname.length() > 0 && amount > 0) { + NBTUtils.setString(aStack, "mFluid", fluidname); + NBTUtils.setInteger(aStack, "mFluidAmount", amount); + } + } + } + + @Override + public FluidStack getFluid(ItemStack container) { + if (!container.hasTagCompound() || !container.getTagCompound() + .hasKey("mInit")) { + initNBT(container); + } + if (container.getTagCompound() + .hasKey("mInit") + && container.getTagCompound() + .getBoolean("mInit")) { + String fluidname; + Integer amount = 0; + fluidname = NBTUtils.getString(container, "mFluid"); + amount = NBTUtils.getInteger(container, "mFluidAmount"); + if (fluidname != null && amount != null && amount > 0) { + return FluidUtils.getFluidStack(fluidname, amount); + } else { + return null; + } + } + return null; + } + + @Override + public int getCapacity(ItemStack container) { + if (!container.hasTagCompound() || !container.getTagCompound() + .hasKey("mInit")) { + initNBT(container); + } + if (container.getTagCompound() + .hasKey("mInit") + && container.getTagCompound() + .getBoolean("mInit")) { + return container.getTagCompound() + .getInteger("mCapacity"); + } + int aMeta = this.getCorrectMetaForItemstack(container); + int aCapacity = (aMeta == 0 ? 2000 : (aMeta == 1 ? 8000 : (aMeta == 2 ? 32000 : 128000))); + return aCapacity; + } + + public int fill(ItemStack container, FluidStack resource) { + return fill(container, resource, true); + } + + @Override + public int fill(ItemStack container, FluidStack resource, boolean doFill) { + if (!doFill || resource == null) { + return 0; + } + + if (!container.hasTagCompound() || !container.getTagCompound() + .hasKey("mInit")) { + initNBT(container); + } + if (container.getTagCompound() + .hasKey("mInit") + && container.getTagCompound() + .getBoolean("mInit")) { + String aStored; + int aStoredAmount = 0; + int aCapacity = getCapacity(container); + FluidStack aStoredFluid = getFluid(container); + if (aStoredFluid != null) { + aStored = aStoredFluid.getFluid() + .getName(); + aStoredAmount = aStoredFluid.amount; + if (aStoredAmount == aCapacity) { + return 0; + } + } + // Handle no stored fluid first + if (aStoredFluid == null) { + Logger.INFO("Pump is empty, filling with tank fluids."); + FluidStack toConsume; + int amountToConsume = 0; + if (resource.amount >= aCapacity) { + amountToConsume = aCapacity; + } else { + amountToConsume = resource.amount; + } + toConsume = FluidUtils.getFluidStack(resource, amountToConsume); + if (toConsume != null && amountToConsume > 0) { + storeFluid(container, toConsume); + return amountToConsume; + } + } else { + Logger.INFO("Pump is Partially full, filling with tank fluids."); + if (aStoredFluid.isFluidEqual(resource)) { + Logger.INFO("Found matching fluids."); + int aSpaceLeft = (aCapacity - aStoredAmount); + Logger.INFO( + "Capacity: " + aCapacity + " | Stored: " + aStoredAmount + " | Space left: " + aSpaceLeft); + FluidStack toConsume; + int amountToConsume = 0; + if (resource.amount >= aSpaceLeft) { + amountToConsume = aSpaceLeft; + Logger.INFO("More or equal fluid amount to pump container space."); + } else { + amountToConsume = resource.amount; + Logger.INFO("Less fluid than container space"); + } + Logger.INFO("Amount to consume: " + amountToConsume); + toConsume = FluidUtils.getFluidStack(resource, (aStoredAmount + amountToConsume)); + if (toConsume != null && amountToConsume > 0) { + Logger.INFO("Storing Fluid"); + storeFluid(container, toConsume); + return amountToConsume; + } else { + Logger.INFO("Not storing fluid"); + } + } else { + Logger.INFO("Fluids did not match."); + } + } + } + return 0; + } + + public FluidStack drain(ItemStack container, int drainAmt) { + return drain(container, drainAmt, true); + } + + @Override + public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { + if (!doDrain || maxDrain == 0) { + return null; + } + if (!container.hasTagCompound() || !container.getTagCompound() + .hasKey("mInit")) { + initNBT(container); + } + if (container.getTagCompound() + .hasKey("mInit") + && container.getTagCompound() + .getBoolean("mInit")) { + + String aStored; + int aStoredAmount = 0; + FluidStack aStoredFluid = getFluid(container); + + if (aStoredFluid != null) { + aStored = aStoredFluid.getFluid() + .getName(); + aStoredAmount = aStoredFluid.amount; + } + // We cannot drain this if it's empty. + else if (aStoredFluid == null) { + return null; + } + + if (maxDrain >= aStoredAmount) { + emptyStoredFluid(container); + return aStoredFluid; + } else { + // Handle Partial removal + int amountRemaining = (aStoredAmount - maxDrain); + if (amountRemaining == 0) { + emptyStoredFluid(container); + } else { + FluidStack newAmount = FluidUtils.getFluidStack(aStoredFluid, amountRemaining); + FluidStack drained = FluidUtils.getFluidStack(aStoredFluid, maxDrain); + if (newAmount != null && drained != null) { + storeFluid(container, newAmount); + return drained; + } + } + } + } + return null; + } + + /* + * Handle ItemStack NBT + */ + + public void initNBT(ItemStack aStack) { + NBTTagCompound aNewNBT; + if (!aStack.hasTagCompound()) { + aNewNBT = new NBTTagCompound(); + } else { + aNewNBT = aStack.getTagCompound(); + } + + if (!aNewNBT.hasKey("mInit")) { + int aMeta = this.getCorrectMetaForItemstack(aStack); + aNewNBT.setInteger("mMeta", aMeta); + aNewNBT.setBoolean("mInit", true); + aNewNBT.setString("mFluid", "@@@@@"); + aNewNBT.setInteger("mFluidAmount", 0); + int aCapacity = (aMeta == 0 ? 2000 : (aMeta == 1 ? 8000 : (aMeta == 2 ? 32000 : 128000))); + aNewNBT.setInteger("mCapacity", aCapacity); + aStack.setTagCompound(aNewNBT); + } + } + + /** + * Tile Handling + */ + + /* + * Custom Fluid Handling for Tiles and GT Tiles. + */ + + public boolean tryDrainTile(ItemStack aStack, World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ) { + try { + if (aWorld.isRemote || aStack == null) { + return false; + } else { + int aTier = (aStack.getItemDamage() - 1000); + int removal; + if (aTier == 0) { + removal = 0; + } else if (aTier == 1) { + removal = 32; + } else if (aTier == 2) { + removal = 128; + } else if (aTier == 3) { + removal = 512; + } else { + removal = 8; + } + if (!canUse(aStack, removal) && aTier > 0) { + PlayerUtils.messagePlayer(aPlayer, "Not enough power."); + Logger.INFO("No Power"); + return false; + } + + final Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity == null) { + return false; + } else { + double aCharge = this.getCharge(aStack); + boolean didDrain = false; + if (aTier > 0 && aCharge > 0) { + if (discharge(aStack, removal, aTier, true, true, false) > 0) { + didDrain = true; + } + } else if (aTier == 0) { + didDrain = true; + } else { + didDrain = false; + } + + if (didDrain) { + if ((tTileEntity instanceof IGregTechTileEntity)) { + return this.drainTankGT(tTileEntity, aStack, aWorld, aPlayer, aX, aY, aZ); + } + // Try support Standard Fluid Tanks too (May disable if dupes appear again) + else if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { + // return this.drainIFluidTank(tTileEntity, aStack, aWorld, aPlayer, aX, aY, aZ); + return false; + } + } + } + } + } catch (Throwable t) {} + return false; + } + + /* + * Vanilla IFluidTank + */ + + public boolean drainIFluidTank(TileEntity tTileEntity, ItemStack aStack, World aWorld, EntityPlayer aPlayer, int aX, + int aY, int aZ) { + if (tTileEntity == null) { + Logger.INFO("Invalid Tile, somehow."); + return false; + } + if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { + if (this.getFluid(aStack) == null + || (this.getFluid(aStack) != null && this.getFluid(aStack).amount < this.getCapacity(aStack))) { + Logger.INFO("Trying to find Stored Fluid - Behaviour Class."); + FluidStack aStored = getStoredFluidOfVanillaTank(tTileEntity); + if (aStored != null) { + int mAmountInserted = fill(aStack, aStored); + FluidStack newStackRemainingInTank; + if (mAmountInserted > 0) { + if (mAmountInserted == aStored.amount) { + newStackRemainingInTank = null; + } else { + newStackRemainingInTank = FluidUtils + .getFluidStack(aStored, (aStored.amount - mAmountInserted)); + } + boolean b = setStoredFluidOfVanillaTank(tTileEntity, newStackRemainingInTank); + Logger.INFO("Cleared Tank? " + b + " | mAmountInserted: " + mAmountInserted); + Logger.INFO("Returning " + b + " - drainTankVanilla."); + if (b) { + PlayerUtils.messagePlayer( + aPlayer, + "Drained " + mAmountInserted + "L of " + aStored.getLocalizedName() + "."); + } + return b; + } + } else { + Logger.INFO("Found no valid Fluidstack - drainTankVanilla."); + } + } else { + Logger.INFO("Pump is full."); + } + } + Logger.INFO("Could not drain vanilla tank."); + return false; + } + + /* + * GT Tanks + */ + + public boolean drainTankGT(TileEntity tTileEntity, ItemStack aStack, World aWorld, EntityPlayer aPlayer, int aX, + int aY, int aZ) { + if (tTileEntity == null) { + return false; + } + if ((tTileEntity instanceof IGregTechTileEntity)) { + Logger.INFO("Right Clicking on GT Tile - drainTankGT."); + if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) { + Logger.INFO("Returning False - Behaviour Class. Timer < 50"); + return false; + } else if ((!aWorld.isRemote) && (!((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer))) { + Logger.INFO("Returning True - drainTankGT. NotUsable()"); + return true; + } else { + if (this.getFluid(aStack) == null + || (this.getFluid(aStack) != null && this.getFluid(aStack).amount < this.getCapacity(aStack))) { + Logger.INFO("Trying to find Stored Fluid - drainTankGT."); + FluidStack aStored = getStoredFluidOfGTMachine((IGregTechTileEntity) tTileEntity); + if (aStored != null) { + int mAmountInserted = fill(aStack, aStored); + FluidStack newStackRemainingInTank; + if (mAmountInserted > 0) { + if (mAmountInserted == aStored.amount) { + newStackRemainingInTank = null; + } else { + newStackRemainingInTank = FluidUtils + .getFluidStack(aStored, (aStored.amount - mAmountInserted)); + } + boolean b = setStoredFluidOfGTMachine( + (IGregTechTileEntity) tTileEntity, + newStackRemainingInTank); + Logger.INFO("Cleared Tank? " + b + " | mAmountInserted: " + mAmountInserted); + Logger.INFO("Returning " + b + " - drainTankGT."); + if (b) { + PlayerUtils.messagePlayer( + aPlayer, + "Drained " + mAmountInserted + "L of " + aStored.getLocalizedName() + "."); + } else { + drain(aStack, mAmountInserted); + } + return b; + } + } else { + Logger.INFO("Found no valid Fluidstack - drainTankGT."); + } + } else { + Logger.INFO("Pump is full."); + } + } + } + Logger.INFO("Could not drain GT tank."); + return false; + } + + /* + * Vanilla Tanks + */ + + public FluidStack getStoredFluidOfVanillaTank(TileEntity aTileEntity) { + if (aTileEntity == null) { + return null; + } else if ((aTileEntity instanceof IFluidTank || aTileEntity instanceof IFluidHandler)) { + if (aTileEntity instanceof IFluidTank) { + return getStoredFluidOfVanillaTank((IFluidTank) aTileEntity); + } else { + return getStoredFluidOfVanillaTank((IFluidHandler) aTileEntity); + } + } else { + return null; + } + } + + public FluidStack getStoredFluidOfVanillaTank(IFluidTank aTileEntity) { + FluidStack f = aTileEntity.getFluid(); + Logger.INFO( + "Returning Fluid stack from tile. Found: " + + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); + return f; + } + + public FluidStack getStoredFluidOfVanillaTank(IFluidHandler aTileEntity) { + if (aTileEntity instanceof IFluidTank) { + return getStoredFluidOfVanillaTank((IFluidTank) aTileEntity); + } + FluidStack f; + AutoMap<FluidTankInfo[]> m = new AutoMap<>(); + for (int i = 0; i < 6; i++) { + m.put(aTileEntity.getTankInfo(ForgeDirection.getOrientation(i))); + } + if (m.get(0) != null && m.get(0)[0] != null && m.get(0)[0].fluid != null) { + return m.get(0)[0].fluid; + } else { + return null; + } + } + + public boolean setStoredFluidOfVanillaTank(TileEntity aTileEntity, FluidStack aSetFluid) { + Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [1]"); + + if (aTileEntity == null) { + return false; + } else if ((aTileEntity instanceof IFluidTank || aTileEntity instanceof IFluidHandler)) { + if (aTileEntity instanceof IFluidTank) { + Logger.INFO("Tile Was instanceof IFluidTank."); + FluidStack f = ((IFluidTank) aTileEntity).getFluid(); + if (aSetFluid == null) { + aSetFluid = f; + aSetFluid.amount = f.amount; + } + int toDrain = (f.amount - aSetFluid.amount); + FluidStack newStack; + if (toDrain <= 0) { + newStack = f; + } else { + newStack = ((IFluidTank) aTileEntity).drain(toDrain, true); + } + + if (newStack.isFluidEqual(aSetFluid) && newStack.amount == aSetFluid.amount) { + Logger.INFO("Removed fluid from vanilla IFluidTank successfully."); + return true; + } else { + Logger.INFO("Failed trying to remove fluid from vanilla IFluidTank."); + return false; + } + } else { + + // Rewrite Fluid handling for Vanilla type tanks + if (!IFluidHandler.class.isInstance(aTileEntity)) { + Logger.INFO("Tile Was not an instance of IFluidHandler."); + return false; + } + + IFluidHandler aTank = (IFluidHandler) aTileEntity; + FluidStack aTankContents = null; + FluidTankInfo[] a1 = aTank.getTankInfo(ForgeDirection.UNKNOWN); + if (a1 != null) { + if (a1[0] != null) { + aTankContents = a1[0].fluid; + Logger.INFO( + "Found Fluid in Tank. " + aTankContents.getLocalizedName() + " - " + aTankContents.amount); + } + } + if (aSetFluid == null) { + Logger.INFO("Setting fluid to tank contents, as we're going to empty it totally."); + aSetFluid = aTankContents.copy(); + } else { + Logger.INFO("Setting fluid to tank contents, as we're going to empty it totally."); + } + Logger.INFO( + "Tile Was instance of IFluidHandler. Trying to Drain " + aSetFluid.getLocalizedName() + + " - " + + aSetFluid.amount); + + if (a1 == null || aTankContents == null) { + Logger.INFO("Tank is empty."); + return false; + } + // Found some Fluid in the tank + else { + FluidStack aDrainedStack = aTank.drain(ForgeDirection.UNKNOWN, aSetFluid, true); + if (aDrainedStack.isFluidStackIdentical(aSetFluid)) { + Logger.INFO("Drained!"); + return true; + } else { + Logger.INFO("Partially Drained! This is probably an error."); + return true; + } + } + } + } else { + Logger.INFO("Bad Tank Tile to drain."); + return false; + } + } + + /* + * GT Tanks + */ + + public FluidStack getStoredFluidOfGTMachine(IGregTechTileEntity aTileEntity) { + if (aTileEntity == null) { + return null; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();; + if (aMetaTileEntity == null || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MultiInput) { + // blacklist multiinput hatch as it's too complex + return null; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicTank) { + Logger.INFO("Tile Was Instanceof BasicTank."); + return getStoredFluidOfGTMachine((GT_MetaTileEntity_BasicTank) aMetaTileEntity); + } else { + return null; + } + } + + public FluidStack getStoredFluidOfGTMachine(GT_MetaTileEntity_BasicTank aTileEntity) { + FluidStack f = aTileEntity.mFluid; + + // Let's see if this machine has output fluid too + /* + * if (f == null) { Logger.INFO("Could not find any input fluid, checking output if possible."); if (aTileEntity + * instanceof GT_MetaTileEntity_BasicMachine) { GT_MetaTileEntity_BasicMachine g = + * (GT_MetaTileEntity_BasicMachine) aTileEntity; + * Logger.INFO("Tile is a Basic Machine of some sort - "+g.mNEIName); if (g != null) { f = g.mOutputFluid; if (f + * != null) { Logger.INFO("Found output fluid! "+f.getLocalizedName()); } else { + * Logger.INFO("Did not find anything!"); f = g.getFluid(); if (f != null) { + * Logger.INFO("Found fluid! "+f.getLocalizedName()); } else { Logger.INFO("Did not find anything!"); f = + * g.getFluid(); } } } } } + */ + + Logger.INFO( + "Returning Fluid stack from tile. Found: " + + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); + return f; + } + + public boolean setStoredFluidOfGTMachine(IGregTechTileEntity aTileEntity, FluidStack aSetFluid) { + Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [1]"); + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicTank) { + Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [2]"); + return setStoredFluidOfGTMachine((GT_MetaTileEntity_BasicTank) aMetaTileEntity, aSetFluid); + } else { + return false; + } + } + + public boolean setStoredFluidOfGTMachine(GT_MetaTileEntity_BasicTank aTileEntity, FluidStack aSetFluid) { + try { + + // Try Handle Outputs First + /* + * if (aTileEntity.setDrainableStack(aSetFluid) != null) { return true; } + */ + + aTileEntity.mFluid = aSetFluid; + boolean b = aTileEntity.mFluid == aSetFluid; + Logger.INFO("Trying to set Tile's tank. - Behaviour Class. [3] " + b); + return b; + } catch (Throwable t) { + Logger.INFO("Trying to clear Tile's tank. FAILED - Behaviour Class. [x]"); + return false; + } + } + + public int getCorrectMetaForItemstack(ItemStack aStack) { + if (aStack == null) { + return 0; + } else { + if (aStack.getItemDamage() < this.mOffset) { + return 0; + } else { + int newMeta = aStack.getItemDamage() - this.mOffset; + newMeta = (Math.max(0, Math.min(3, newMeta))); + return newMeta; + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/wearable/WearableLoader.java b/src/main/java/gtPlusPlus/core/item/wearable/WearableLoader.java new file mode 100644 index 0000000000..8044b4364f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/wearable/WearableLoader.java @@ -0,0 +1,14 @@ +package gtPlusPlus.core.item.wearable; + +import gtPlusPlus.core.item.wearable.armour.ArmourLoader; + +public class WearableLoader { + + public static void run() { + execute(); + } + + private static void execute() { + ArmourLoader.run(); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/ArmourLoader.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/ArmourLoader.java new file mode 100644 index 0000000000..e929d6cb7f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/ArmourLoader.java @@ -0,0 +1,38 @@ +package gtPlusPlus.core.item.wearable.armour; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor.ArmorMaterial; +import net.minecraftforge.common.util.EnumHelper; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.item.wearable.armour.tinfoil.ArmourTinFoilHat; + +public class ArmourLoader { + + // Glass + public static Item ClearGlassChestplate; + public static Item ClearGlassBoots; + public static Item ClearGlassLeggings; + public static Item ClearGlassHelmet; + + // Tin Foil + public static Item TinFoilHat; + + public static ArmorMaterial ClearGlassArmour = EnumHelper + .addArmorMaterial("ClearGlassArmor", 1, new int[] { 1, 1, 1, 1 }, 100); + public static ArmorMaterial TinFoilArmour = EnumHelper.addArmorMaterial("TINFOIL", 5, new int[] { 1, 1, 1, 1 }, 50); + + public static void run() { + glassArmour(); + tinfoilArmour(); + } + + private static void glassArmour() {} + + private static void tinfoilArmour() { + TinFoilHat = new ArmourTinFoilHat().setUnlocalizedName("itemHatTinFoil"); + GameRegistry.registerItem(TinFoilHat, "itemHatTinFoil", GTPlusPlus.ID); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmour.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmour.java new file mode 100644 index 0000000000..e7ce975eca --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmour.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.item.wearable.armour.base; + +import gtPlusPlus.core.item.wearable.base.BaseItemWearable; + +public abstract class BaseArmour extends BaseItemWearable { + + public BaseArmour(ArmorMaterial material, int renderIndex, int armourType) { + super(material, renderIndex, armourType); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourHelm.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourHelm.java new file mode 100644 index 0000000000..d121a90ade --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourHelm.java @@ -0,0 +1,9 @@ +package gtPlusPlus.core.item.wearable.armour.base; + +public abstract class BaseArmourHelm extends BaseArmour { + + public BaseArmourHelm(ArmorMaterial material, int renderIndex) { + super(material, renderIndex, 0); + // TODO Auto-generated constructor stub + } +} diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ArmourTinFoilHat.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ArmourTinFoilHat.java new file mode 100644 index 0000000000..0703ac3b93 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ArmourTinFoilHat.java @@ -0,0 +1,179 @@ +package gtPlusPlus.core.item.wearable.armour.tinfoil; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityEnderEye; +import net.minecraft.entity.item.EntityEnderPearl; +import net.minecraft.entity.item.EntityExpBottle; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityEgg; +import net.minecraft.entity.projectile.EntityFireball; +import net.minecraft.entity.projectile.EntitySnowball; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.item.wearable.armour.ArmourLoader; +import gtPlusPlus.core.item.wearable.armour.base.BaseArmourHelm; + +public class ArmourTinFoilHat extends BaseArmourHelm { + + public IIcon iconHelm; + + public ArmourTinFoilHat() { + super(ArmourLoader.TinFoilArmour, 0); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ir) { + this.iconHelm = ir.registerIcon(GTPlusPlus.ID + ":itemHatTinFoil"); + } + + @Override + public int getRenderIndex() { + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return this.iconHelm; + } + + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return GTPlusPlus.ID + ":textures/models/TinFoil.png"; + } + + @Override + public EnumRarity getRarity(ItemStack itemstack) { + return EnumRarity.uncommon; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return false; + } + + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + return super.getArmorDisplay(player, armor, slot); + } + + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {} + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + aList.add("DoomSquirter's protection against cosmic radiation!"); + aList.add("General paranoia makes the wearer unable to collect xp"); + aList.add("Movement speed is also reduced, to keep you safe"); + aList.add("This hat may also have other strange powers"); + } + + @Override + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, + int slot) { + return new ArmorProperties(0, 0, 0); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean itemInteractionForEntity(ItemStack p_111207_1_, EntityPlayer p_111207_2_, + EntityLivingBase p_111207_3_) { + return super.itemInteractionForEntity(p_111207_1_, p_111207_2_, p_111207_3_); + } + + @Override + public void onUpdate(ItemStack aStack, World aWorld, Entity aEntity, int p_77663_4_, boolean p_77663_5_) { + super.onUpdate(aStack, aWorld, aEntity, p_77663_4_, p_77663_5_); + } + + @Override + public boolean onEntityItemUpdate(EntityItem entityItem) { + return super.onEntityItemUpdate(entityItem); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { + if (itemStack != null && player != null && world != null && !world.isRemote) { + if (player instanceof EntityPlayer) { + + // Apply Slow + if (!GT_Utility.getPotion(player, Potion.moveSlowdown.id)) { + player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 1, true)); + } + + // Move Xp orbs away + try { + AxisAlignedBB box = player.boundingBox; + box.maxX = player.posX + 5; + box.maxY = player.posY + 5; + box.maxZ = player.posZ + 5; + box.minX = player.posX - 5; + box.minY = player.posY - 5; + box.minZ = player.posZ - 5; + @SuppressWarnings("unchecked") + List<Entity> g = world.getEntitiesWithinAABBExcludingEntity(player, box); + if (g.size() > 0) { + for (Entity e : g) { + if (e != null) { + if (!EntityXPOrb.class.isInstance(e) && !EntityBoat.class.isInstance(e) + && !EntitySnowball.class.isInstance(e) + && !EntityFireball.class.isInstance(e) + && !EntityEgg.class.isInstance(e) + && !EntityExpBottle.class.isInstance(e) + && !EntityEnderEye.class.isInstance(e) + && !EntityEnderPearl.class.isInstance(e)) { + continue; + } else { + // Logger.INFO("Found "+e.getClass().getName()); + double distX = player.posX - e.posX; + double distZ = player.posZ - e.posZ; + double distY = e.posY + 1.5D - player.posY; + double dir = Math.atan2(distZ, distX); + double speed = 1F / e.getDistanceToEntity(player) * 0.5; + speed = -speed; + if (distY < 0) { + e.motionY += speed; + } + e.motionX = Math.cos(dir) * speed; + e.motionZ = Math.sin(dir) * speed; + } + } + } + } + } catch (Throwable t) {} + } + } + + super.onArmorTick(world, player, itemStack); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/wearable/base/BaseItemWearable.java b/src/main/java/gtPlusPlus/core/item/wearable/base/BaseItemWearable.java new file mode 100644 index 0000000000..84b1d2ff51 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/wearable/base/BaseItemWearable.java @@ -0,0 +1,61 @@ +package gtPlusPlus.core.item.wearable.base; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraftforge.common.ISpecialArmor; + +public abstract class BaseItemWearable extends ItemArmor implements ISpecialArmor { + + public BaseItemWearable(ArmorMaterial material, int renderIndex, int armourType) { + super(material, renderIndex, armourType); + } + + public abstract int getRenderIndex(); + + @Override + public abstract ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, + double damage, int slot); + + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public abstract void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, + int slot); + + public void dyeArmour(ItemStack aArmour, int aColour) { + func_82813_b(aArmour, aColour); + } + + @Override + public void func_82813_b(ItemStack p_82813_1_, int p_82813_2_) { + NBTTagCompound nbttagcompound = p_82813_1_.getTagCompound(); + if (nbttagcompound == null) { + nbttagcompound = new NBTTagCompound(); + p_82813_1_.setTagCompound(nbttagcompound); + } + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); + if (!nbttagcompound.hasKey("display", 10)) { + nbttagcompound.setTag("display", nbttagcompound1); + } + nbttagcompound1.setInteger("color", p_82813_2_); + } + + @Override + public void removeColor(ItemStack p_82815_1_) { + NBTTagCompound nbttagcompound = p_82815_1_.getTagCompound(); + if (nbttagcompound != null) { + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); + if (nbttagcompound1.hasKey("color")) { + nbttagcompound1.removeTag("color"); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java b/src/main/java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java new file mode 100644 index 0000000000..e01c89d827 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java @@ -0,0 +1,35 @@ +package gtPlusPlus.core.item.wearable.hazmat; + +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.ic2.CustomInternalName; +import ic2.core.IC2; +import ic2.core.init.InternalName; +import ic2.core.item.armor.ItemArmorHazmat; + +public class ItemArmorHazmatEx extends ItemArmorHazmat { + + public static void init() { + GregtechItemList.Armour_Hazmat_Advanced_Helmet + .set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatHelmetEx, 0))); + GregtechItemList.Armour_Hazmat_Advanced_Chest + .set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatChestEx, 1))); + GregtechItemList.Armour_Hazmat_Advanced_Legs + .set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatLegsEx, 2))); + GregtechItemList.Armour_Hazmat_Advanced_Boots + .set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatBootsEx, 3))); + } + + private ItemArmorHazmatEx(InternalName internalName, int type) { + super(internalName, type); + this.setMaxDamage(256); + } + + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + int suffix = this.armorType == 2 ? 2 : 1; + return IC2.textureDomain + ":textures/armor/" + "hazmatEx_" + suffix + ".png"; + } +} diff --git a/src/main/java/gtPlusPlus/core/lib/CORE.java b/src/main/java/gtPlusPlus/core/lib/CORE.java new file mode 100644 index 0000000000..9f39f1f369 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/lib/CORE.java @@ -0,0 +1,242 @@ +package gtPlusPlus.core.lib; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; +import java.util.WeakHashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Supplier; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.api.objects.XSTR; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +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.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractTerminal; + +public class CORE { + + public static Map PlayerCache; + + // Math Related + public static final float PI = (float) Math.PI; + public static volatile Random RANDOM = new XSTR(); + + public static boolean DEVENV = false;; + + // Mod Variables + public static final String name = "GT++"; + public static final String VERSION = "GRADLETOKEN_VERSION"; + + // Tweakables + public static int EVERGLADES_ID = 227; + public static int EVERGLADESBIOME_ID = 238; + + public static int turbineCutoffBase = 75000; + + // GT++ Fake Player Profile + public static final GameProfile gameProfile = new GameProfile( + UUID.nameUUIDFromBytes("gtplusplus.core".getBytes()), + "[GT++]"); + public static final WeakHashMap<World, EntityPlayerMP> fakePlayerCache = new WeakHashMap<>(); + // Tooltips; + public static final Supplier<String> GT_Tooltip = () -> StatCollector.translateToLocal("GTPP.core.GT_Tooltip"); + public static final Supplier<String> GT_Tooltip_Builder = () -> StatCollector + .translateToLocal("GTPP.core.GT_Tooltip_Builder"); + public static final Supplier<String> GT_Tooltip_Radioactive = () -> StatCollector + .translateToLocal("GTPP.core.GT_Tooltip_Radioactive"); + + public static final String SEPERATOR = "/"; + + /** + * Lists/Maps + */ + + // Burnables List + public static List<Pair<Integer, ItemStack>> burnables = new ArrayList<>(); + + // TesseractMaps + public static final Map<UUID, Map<Integer, GT_MetaTileEntity_TesseractGenerator>> sTesseractGeneratorOwnershipMap = new HashMap<>(); + public static final Map<UUID, Map<Integer, GT_MetaTileEntity_TesseractTerminal>> sTesseractTerminalOwnershipMap = new HashMap<>(); + + // BookMap + public static final Map<String, ItemStack> sBookList = new ConcurrentHashMap<>(); + + /** + * Some Gregtech Material and Recipe Variables + */ + public static IGregtech_RecipeAdder RA; + + public static final GT_Materials[] sMU_GeneratedMaterials = new GT_Materials[1000]; + + public static class ConfigSwitches { + + // Debug + public static boolean MACHINE_INFO = true; + public static boolean showHiddenNEIItems = false; + public static boolean dumpItemAndBlockData = false; + + // Machine Related + public static boolean enableThaumcraftShardUnification = false; + public static boolean disableIC2Recipes = false; + public static int boilerSteamPerSecond = 750; + + // Feature Related + public static boolean enableCustomCapes = false; + public static int enableWatchdogBGM = CORE_Preloader.enableWatchdogBGM; + public static boolean hideUniversalCells = true; + + // Single Block Machines + public static boolean enableMachine_Dehydrators = true; + public static boolean enableMachine_SteamConverter = true; + public static boolean enableMachine_FluidTanks = true; + public static boolean enableMachine_RocketEngines = true; + public static boolean enableMachine_GeothermalEngines = true; + public static boolean enableMachine_Tesseracts = true; + public static boolean enableMachine_SimpleWasher = true; + public static boolean enableMachine_Pollution = true; + public static boolean enableCustom_Pipes = true; + public static boolean enableCustom_Cables = true; + + // Multiblocks + public static boolean enableMultiblock_AlloyBlastSmelter = true; + public static boolean enableMultiblock_QuantumForceTransformer = true; + public static boolean enableMultiblock_IndustrialCentrifuge = true; + public static boolean enableMultiblock_IndustrialCokeOven = true; + public static boolean enableMultiblock_IndustrialElectrolyzer = true; + public static boolean enableMultiblock_IndustrialMacerationStack = true; + public static boolean enableMultiblock_IndustrialPlatePress = true; + public static boolean enableMultiblock_IndustrialWireMill = true; + public static boolean enableMultiblock_MatterFabricator = true; + public static boolean enableMultiblock_MultiTank = true; + public static boolean enableMultiblock_PowerSubstation = true; + public static boolean enableMultiblock_LiquidFluorideThoriumReactor = true; + public static boolean enableMultiblock_NuclearSaltProcessingPlant = true; + public static boolean enableMultiblock_NuclearFuelRefinery = true; + public static boolean enableMultiblock_TreeFarmer = true; + public static boolean enableMultiblock_IndustrialSifter = true; + public static boolean enableMultiblock_IndustrialThermalCentrifuge = true; + public static boolean enableMultiblock_IndustrialWashPlant = true; + public static boolean enableMultiblock_LargeAutoCrafter = true; + public static boolean enableMultiblock_ThermalBoiler = true; + public static boolean enableMultiblock_IndustrialCuttingMachine = true; + public static boolean enableMultiblock_IndustrialFishingPort = true; + public static boolean enableMultiblock_IndustrialExtrudingMachine = true; + public static boolean enableMultiblock_IndustrialMultiMachine = true; + public static boolean enableMultiblock_Cyclotron = true; + + // Visuals + public static boolean useGregtechTextures = true; + public static boolean enableAnimatedTextures = false; + + // Pollution + public static int pollutionPerSecondMultiPackager = 40; + public static int pollutionPerSecondMultiIndustrialAlloySmelter = 300; + public static int pollutionPerSecondMultiIndustrialArcFurnace = 2400; + public static int pollutionPerSecondMultiIndustrialCentrifuge = 300; + public static int pollutionPerSecondMultiIndustrialCokeOven = 80; + public static int pollutionPerSecondMultiIndustrialCuttingMachine = 160; + public static int pollutionPerSecondMultiIndustrialDehydrator = 500; + public static int pollutionPerSecondMultiIndustrialElectrolyzer = 300; + public static int pollutionPerSecondMultiIndustrialExtruder = 1000; + public static int pollutionPerSecondMultiIndustrialMacerator = 400; + public static int pollutionPerSecondMultiIndustrialMixer = 800; + public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal = 400; + public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid = 400; + public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc = 600; + public static int pollutionPerSecondMultiIndustrialPlatePress_ModeForming = 240; + public static int pollutionPerSecondMultiIndustrialPlatePress_ModeBending = 480; + public static int pollutionPerSecondMultiIndustrialForgeHammer = 250; + public static int pollutionPerSecondMultiIndustrialSifter = 40; + public static int pollutionPerSecondMultiIndustrialThermalCentrifuge = 1000; + public static int pollutionPerSecondMultiIndustrialVacuumFreezer = 500; + public static int pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath = 400; + public static int pollutionPerSecondMultiIndustrialWashPlant_ModeWasher = 100; + public static int pollutionPerSecondMultiIndustrialWireMill = 100; + public static int pollutionPerSecondMultiIsaMill = 1280; + public static int pollutionPerSecondMultiAdvDistillationTower_ModeDistillery = 240; + public static int pollutionPerSecondMultiAdvDistillationTower_ModeDT = 480; + public static int pollutionPerSecondMultiAdvEBF = 500; + public static int pollutionPerSecondMultiAdvImplosion = 5000; + public static int pollutionPerSecondMultiABS = 200; + public static int pollutionPerSecondMultiCyclotron = 200; + public static int pollutionPerSecondMultiIndustrialFishingPond = 20; + public static int pollutionPerSecondMultiLargeSemiFluidGenerator = 1280; + public static int pollutionPerSecondMultiMassFabricator = 40; + public static int pollutionPerSecondMultiRefinery = 4000; + public static int pollutionPerSecondMultiTreeFarm = 100; + public static int pollutionPerSecondMultiFrothFlotationCell = 0; + public static int pollutionPerSecondMultiAutoCrafter = 500; + public static int pollutionPerSecondMultiThermalBoiler = 700; + public static int pollutionPerSecondMultiMolecularTransformer = 1000; + public static int pollutionPerSecondMultiAlgaePond = 0; + public static int pollutionPerSecondMultiIndustrialRockBreaker = 100; + public static int pollutionPerSecondMultiIndustrialChisel = 50; + // pollution single blocks + public static int basePollutionPerSecondSemiFluidGenerator = 40; + public static double[] pollutionReleasedByTierSemiFluidGenerator = new double[] { 0, 2.0, 4.0, 8.0, 12.0, 16, + 0 }; + public static int basePollutionPerSecondBoiler = 35; + public static double[] pollutionReleasedByTierBoiler = new double[] { 0, 1.0, 1.43, 1.86 }; + public static int baseMinPollutionPerSecondRocketFuelGenerator = 250; + public static int baseMaxPollutionPerSecondRocketFuelGenerator = 2000; + public static double[] pollutionReleasedByTierRocketFuelGenerator = new double[] { 0, 0, 0, 0, 1, 2, 3 }; + public static int basePollutionPerSecondGeothermalGenerator = 100; + public static double[] pollutionReleasedByTierGeothermalGenerator = new double[] { 0, 0, 0, 0, 1, 1, 1 }; + } + + public static class Everglades { + + public static final String NAME = "GT++ Toxic Everglades"; + public static final String VERSION = "GRADLETOKEN_VERSION"; + } + + public static final void crash() { + crash("Generic Crash"); + } + + public static final void crash(String aReason) { + try { + 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("Reason: " + aReason); + Logger.INFO("=========================================================="); + Logger.INFO("Called from: " + 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)); + Logger.INFO(ReflectionUtils.getMethodName(7)); + Logger.INFO(ReflectionUtils.getMethodName(8)); + Logger.INFO(ReflectionUtils.getMethodName(9)); + Logger.INFO(ReflectionUtils.getMethodName(10)); + Logger.INFO(ReflectionUtils.getMethodName(11)); + Logger.INFO(ReflectionUtils.getMethodName(12)); + Logger.INFO(ReflectionUtils.getMethodName(13)); + Logger.INFO(ReflectionUtils.getMethodName(14)); + Logger.INFO(ReflectionUtils.getMethodName(15)); + } catch (Throwable t) { + t.printStackTrace(); + } + FMLCommonHandler.instance() + .exitJava(0, true); + } +} diff --git a/src/main/java/gtPlusPlus/core/lib/VanillaColours.java b/src/main/java/gtPlusPlus/core/lib/VanillaColours.java new file mode 100644 index 0000000000..70e7902fbf --- /dev/null +++ b/src/main/java/gtPlusPlus/core/lib/VanillaColours.java @@ -0,0 +1,43 @@ +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/main/java/gtPlusPlus/core/material/ALLOY.java b/src/main/java/gtPlusPlus/core/material/ALLOY.java new file mode 100644 index 0000000000..6618c61dd3 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/ALLOY.java @@ -0,0 +1,828 @@ +package gtPlusPlus.core.material; + +import gregtech.api.enums.Materials; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.util.minecraft.MaterialUtils; + +public final class ALLOY { + + // Just some GT Alloys that I need within mine. + public static final Material BRONZE = MaterialUtils.generateMaterialFromGtENUM(Materials.Bronze); + public static final Material STEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.Steel); + public static final Material STEEL_BLACK = MaterialUtils.generateMaterialFromGtENUM(Materials.BlackSteel); + public static final Material INVAR = MaterialUtils.generateMaterialFromGtENUM(Materials.Invar); + public static final Material KANTHAL = MaterialUtils.generateMaterialFromGtENUM(Materials.Kanthal); + public static final Material NICHROME = MaterialUtils.generateMaterialFromGtENUM(Materials.Nichrome); + public static final Material TUNGSTENSTEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.TungstenSteel); + public static final Material STAINLESS_STEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.StainlessSteel); + public static final Material OSMIRIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Osmiridium); + public static final Material POLYETHYLENE = MaterialUtils.generateMaterialFromGtENUM(Materials.Plastic); + public static final Material POLYTETRAFLUOROETHYLENE = MaterialUtils + .generateMaterialFromGtENUM(Materials.Polytetrafluoroethylene); + public static final Material ENERGYCRYSTAL = new Material( + "Energy Crystal", // Material Name + MaterialState.SOLID, // State + new short[] { 228, 255, 0, 0 }, // Material Colour + 4660, // Melting Point in C + 5735, // Boiling Point in C + 90, // Protons + 40, // Neutrons + true, // Uses Blast furnace? + "⬟ ⯂ ⬢ ⬣ ⯃ ⯄", + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().AER, 5), + new MaterialStack(ELEMENT.getInstance().IGNIS, 5), new MaterialStack(ELEMENT.getInstance().TERRA, 5), + new MaterialStack(ELEMENT.getInstance().AQUA, 5) }); + + public static final Material BLOODSTEEL = new Material( + "Blood Steel", // Material Name + MaterialState.SOLID, // State + new short[] { 142, 28, 0, 0 }, // Material Colour + 2500, // Melting Point in C + 0, // Boiling Point in C + 100, // Protons + 100, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.STEEL, 5), new MaterialStack(ELEMENT.getInstance().IGNIS, 5) }); + + public static final Material STABALLOY = new Material( + "Staballoy", // Material Name + MaterialState.SOLID, // State + new short[] { 68, 75, 66, 0 }, // Material Colour + 3450, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().URANIUM238, 9), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 1) }); + + public static final Material TANTALLOY_60 = new Material( + "Tantalloy-60", // Material Name + MaterialState.SOLID, // State + new short[] { 213, 231, 237, 0 }, // Material Colour + 3025, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 4), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 46) }); + + public static final Material TANTALLOY_61 = new Material( + "Tantalloy-61", // Material Name + MaterialState.SOLID, // State + new short[] { 193, 211, 217, 0 }, // Material Colour + 3030, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.TANTALLOY_60, 2), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 12), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 8) }); + + public static final Material TUMBAGA = new Material( + "Tumbaga", // Material Name + MaterialState.SOLID, // State + new short[] { 255, 178, 15, 0 }, // Material Colour + -1, + -1, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().GOLD, 70), + new MaterialStack(ELEMENT.getInstance().COPPER, 30) }); + + public static final Material POTIN = new Material( + "Potin", // Material Name + MaterialState.SOLID, // State + new short[] { 201, 151, 129, 0 }, // Material Colour + -1, + -1, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().LEAD, 40), new MaterialStack(ALLOY.BRONZE, 40), + new MaterialStack(ELEMENT.getInstance().TIN, 20) }); + + /* + * public static final Material BEDROCKIUM = new Material( "Bedrockium", //Material Name new short[]{32, 32, 32, 0}, + * //Material Colour 7735, //Melting Point in C 0, //Boiling Point in C 100, //Protons 100, //Neutrons false, //Uses + * Blast furnace? //Material Stacks with Percentage of required elements. null); + */ + + public static final Material INCONEL_625 = new Material( + "Inconel-625", // Material Name + MaterialState.SOLID, // State + new short[] { 128, 200, 128, 0 }, // Material Colour + 2425, // Melting Point in C + 3758, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().NICKEL, 3), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 7), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 10), new MaterialStack(INVAR, 10), + new MaterialStack(NICHROME, 13) }); + + public static final Material INCONEL_690 = new Material( + "Inconel-690", // Material Name + MaterialState.SOLID, // State + new short[] { 118, 220, 138, 0 }, // Material Colour + 3425, // Melting Point in C + 4895, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CHROMIUM, 5), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 10), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 10), new MaterialStack(NICHROME, 15) }); + + public static final Material INCONEL_792 = new Material( + "Inconel-792", // Material Name + MaterialState.SOLID, // State + new short[] { 108, 240, 118, 0 }, // Material Colour + 3425, // Melting Point in C + 6200, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().NICKEL, 20), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 10), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 20), new MaterialStack(NICHROME, 10) }); + + public static final Material NITINOL_60 = new Material( + "Nitinol 60", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 5651, // Melting Point in C + 8975, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().NICKEL, 40), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 60) }); + + public static final Material ZERON_100 = new Material( + "Zeron-100", // Material Name + MaterialState.SOLID, // State + new short[] { 180, 180, 20, 0 }, // Material Colour + 6100, + 9785, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CHROMIUM, 26), + new MaterialStack(ELEMENT.getInstance().NICKEL, 6), new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 4), + new MaterialStack(ELEMENT.getInstance().COPPER, 20), new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 4), + new MaterialStack(ALLOY.STEEL, 40) }); + + public static final Material MARAGING250 = new Material( + "Maraging Steel 250", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 2413, // Melting Point in C + 4555, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.STEEL, 64), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 4), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), new MaterialStack(ELEMENT.getInstance().NICKEL, 16), + new MaterialStack(ELEMENT.getInstance().COBALT, 8), }); + + public static final Material MARAGING300 = new Material( + "Maraging Steel 300", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 2413, // Melting Point in C + 4555, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.STEEL, 64), new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 4), new MaterialStack(ELEMENT.getInstance().NICKEL, 16), + new MaterialStack(ELEMENT.getInstance().COBALT, 8), }); + + public static final Material MARAGING350 = new Material( + "Maraging Steel 350", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 2413, // Melting Point in C + 4555, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.STEEL, 64), new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 4), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 4), new MaterialStack(ELEMENT.getInstance().NICKEL, 16), + new MaterialStack(ELEMENT.getInstance().COBALT, 8), }); + + public static final Material AQUATIC_STEEL = new Material( + "Watertight Steel", // Material Name + MaterialState.SOLID, // State + new short[] { 120, 120, 180 }, // Material Colour + 2673, // Melting Point in C + 4835, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.STEEL, 60), new MaterialStack(ELEMENT.getInstance().CARBON, 10), + new MaterialStack(ELEMENT.getInstance().MANGANESE, 5), new MaterialStack(ELEMENT.getInstance().SILICON, 10), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 5), new MaterialStack(ELEMENT.getInstance().SULFUR, 5), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 5) }); + + public static final Material STELLITE = new Material( + "Stellite", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4310, // Melting Point in C + 6250, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().COBALT, 35), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 35), + new MaterialStack(ELEMENT.getInstance().MANGANESE, 20), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 10) }); + + public static final Material TALONITE = new Material( + "Talonite", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3454, // Melting Point in C + 5500, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().COBALT, 40), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 30), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 20), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 10) }); + + public static final Material HASTELLOY_W = new Material( + "Hastelloy-W", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3350, // Melting Point in C + 5755, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().IRON, 06), + new MaterialStack(ELEMENT.getInstance().COBALT, 2), new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 24), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 6), + new MaterialStack(ELEMENT.getInstance().NICKEL, 62) }); + + public static final Material HASTELLOY_X = new Material( + "Hastelloy-X", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3350, // Melting Point in C + 5755, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().IRON, 18), + new MaterialStack(ELEMENT.getInstance().MANGANESE, 2), new MaterialStack(ELEMENT.getInstance().SILICON, 2), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 8), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 22), + new MaterialStack(ELEMENT.getInstance().NICKEL, 48) }); + + public static final Material HASTELLOY_N = new Material( + "Hastelloy-N", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4350, // Melting Point in C + 6875, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().YTTRIUM, 8), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 16), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 8), new MaterialStack(ELEMENT.getInstance().TITANIUM, 8), + new MaterialStack(ELEMENT.getInstance().NICKEL, 60) }); + + public static final Material HASTELLOY_C276 = new Material( + "Hastelloy-C276", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4350, // Melting Point in C + 6520, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().COBALT, 2), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 16), + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 2), new MaterialStack(ELEMENT.getInstance().COPPER, 2), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 14), + new MaterialStack(ELEMENT.getInstance().NICKEL, 64) }); + + public static final Material INCOLOY_020 = new Material( + "Incoloy-020", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3425, // Melting Point in C + 5420, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().IRON, 40), + new MaterialStack(ELEMENT.getInstance().COPPER, 4), new MaterialStack(ELEMENT.getInstance().CHROMIUM, 20), + new MaterialStack(ELEMENT.getInstance().NICKEL, 36) }); + + public static final Material INCOLOY_DS = new Material( + "Incoloy-DS", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3425, // Melting Point in C + 5420, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().IRON, 46), + new MaterialStack(ELEMENT.getInstance().COBALT, 18), new MaterialStack(ELEMENT.getInstance().CHROMIUM, 18), + new MaterialStack(ELEMENT.getInstance().NICKEL, 18) }); + + public static final Material INCOLOY_MA956 = new Material( + "Incoloy-MA956", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4425, // Melting Point in C + 6875, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().IRON, 64), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 12), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 20), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 4) }); + + public static final Material TUNGSTEN_CARBIDE = new Material( + "Tungsten Carbide", // Material Name + MaterialState.SOLID, // State + new short[] { 44, 44, 44, 0 }, // Material Colour + 3422, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + false, // Generate cells + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CARBON, 50), + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 50) }); + + public static final Material TUNGSTEN_TITANIUM_CARBIDE = new Material( + "Tungsten Titanium Carbide", // Material Name + MaterialState.SOLID, // State + null, + 4422, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(TUNGSTEN_CARBIDE, 70), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 30) }); + + public static final Material SILICON_CARBIDE = new Material( + "Silicon Carbide", // Material Name + MaterialState.SOLID, // State + new short[] { 40, 48, 36, 0 }, // Material Colour + 1414, // Melting Point in C + -1, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().SILICON, 50), + new MaterialStack(ELEMENT.getInstance().CARBON, 50) }); + + public static final Material TANTALUM_CARBIDE = new Material( + "Tantalum Carbide", // Material Name + MaterialState.SOLID, // State + new short[] { 139, 136, 120, 0 }, // Material Colour + 2980, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().TANTALUM, 50), + new MaterialStack(ELEMENT.getInstance().CARBON, 50) }); + + public static final Material ZIRCONIUM_CARBIDE = new Material( + "Zirconium Carbide", // Material Name + MaterialState.SOLID, // State + new short[] { 222, 202, 180, 0 }, // Material Colour + 1555, // Melting Point in C + -1, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 50), + new MaterialStack(ELEMENT.getInstance().CARBON, 50) }); + + public static final Material NIOBIUM_CARBIDE = new Material( + "Niobium Carbide", // Material Name + MaterialState.SOLID, // State + new short[] { 205, 197, 191, 0 }, // Material Colour + 2477, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().NIOBIUM, 50), + new MaterialStack(ELEMENT.getInstance().CARBON, 50) }); + + public static final Material ARCANITE = new Material( + "Arcanite", // Material Name + MaterialState.SOLID, // State + null, + 5666, // Melting Point in C + 9875, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().THORIUM232, 40), + new MaterialStack(ENERGYCRYSTAL, 40), new MaterialStack(ELEMENT.getInstance().ORDO, 10), + new MaterialStack(ELEMENT.getInstance().PERDITIO, 10) }); + + public static final Material LEAGRISIUM = new Material( + "Grisium", // Material Name + MaterialState.SOLID, // State + new short[] { 53, 93, 106, 0 }, // Material Colour + 3850, // Melting Point in C + 5550, // Boiling Point in C + 96, // Protons + 128, // Neutrons + true, // Uses Blast furnace? + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().TITANIUM, 18), + new MaterialStack(ELEMENT.getInstance().CARBON, 18), new MaterialStack(ELEMENT.getInstance().POTASSIUM, 18), + new MaterialStack(ELEMENT.getInstance().LITHIUM, 18), new MaterialStack(ELEMENT.getInstance().SULFUR, 18), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 10) }); // Material Stacks with Percentage of + // required elements. + + public static final Material EGLIN_STEEL_BASE = new Material( + "Eglin Steel Base Compound", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().IRON, 12), new MaterialStack(KANTHAL, 3), + new MaterialStack(INVAR, 15) }); + + public static final Material EGLIN_STEEL = new Material( + "Eglin Steel", // Material Name + MaterialState.SOLID, // State + new short[] { 139, 69, 19, 0 }, // Material Colour + 1048, // Melting Point in C + 1973, // Boiling Point in C + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.EGLIN_STEEL_BASE, 10), + new MaterialStack(ELEMENT.getInstance().SULFUR, 1), new MaterialStack(ELEMENT.getInstance().SILICON, 4), + new MaterialStack(ELEMENT.getInstance().CARBON, 1) }); + + public static final Material HG1223 = new Material( + "HG-1223", // Material Name + MaterialState.LIQUID, // State + new short[] { 39, 85, 159, 0 }, // Material Colour + 6357, // Melting Point in C + 8563, // Boiling Point in C + -1, + -1, + false, // Uses Blast furnace? + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().MERCURY, 1), + new MaterialStack(ELEMENT.getInstance().BARIUM, 2), new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), + new MaterialStack(ELEMENT.getInstance().COPPER, 3), new MaterialStack(ELEMENT.getInstance().OXYGEN, 8) }); + + public static final Material HS188A = new Material( + "HS188-A", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4870, // Melting Point in C + 7550, // Boiling Point in C + -1, // Protons + -1, // Neutrons + true, // Uses Blast furnace? + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().COBALT, 20), + new MaterialStack(ELEMENT.getInstance().HAFNIUM, 20), new MaterialStack(TALONITE, 16), + new MaterialStack(ELEMENT.getInstance().RHENIUM, 10), new MaterialStack(NIOBIUM_CARBIDE, 10), + new MaterialStack(HASTELLOY_X, 8), new MaterialStack(TUNGSTENSTEEL, 8), + new MaterialStack(ZIRCONIUM_CARBIDE, 8), }); // Material Stacks with Percentage of required + // elements. + + /** + * Stargate Materials - #D2FFA9 210, 255, 170 + */ + public static final Material TRINIUM_TITANIUM = new Material( + "Trinium Titanium Alloy", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3750, // Melting Point in C + 7210, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().TRINIUM_REFINED, 3), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 7) }); + + public static final Material TRINIUM_NAQUADAH = new Material( + "Trinium Naquadah Alloy", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4200, // Melting Point in C + 7400, // Boiling Point in C + -1, + -1, + false, // Uses Blast furnace? + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().TRINIUM_REFINED, 5), + new MaterialStack(ELEMENT.getInstance().NAQUADAH, 9) }); + public static final Material TRINIUM_NAQUADAH_CARBON = new Material( + "Trinium Naquadah Carbonite", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 6500, // Melting Point in C + 9000, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + new MaterialStack[] { new MaterialStack(TRINIUM_NAQUADAH, 9), + new MaterialStack(ELEMENT.getInstance().CARBON, 1) }); + + public static final Material TRINIUM_REINFORCED_STEEL = new Material( + "Arceus Alloy 2B", // Material Name + MaterialState.SOLID, // State + new short[] { 205, 197, 23, 0 }, // Material Colour + 7555, // Melting Point in C + 12350, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().TRINIUM_REFINED, 30), + new MaterialStack(ALLOY.MARAGING350, 40), new MaterialStack(ALLOY.TUNGSTENSTEEL, 20), + new MaterialStack(ALLOY.OSMIRIDIUM, 10), new MaterialStack(ELEMENT.getInstance().STRONTIUM, 10) }); + + /* + * Witchery Material + */ + + public static final Material KOBOLDITE = new Material( + "Koboldite", // Material Name + MaterialState.SOLID, // State + new short[] { 80, 210, 255, 0 }, // Material Colour + -1, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().NICKEL, 35), + new MaterialStack(ELEMENT.getInstance().THAUMIUM, 30), new MaterialStack(ELEMENT.getInstance().IRON, 35) }); + + /* + * Top Tier Alloys + */ + + public static final Material HELICOPTER = new Material( + "HeLiCoPtEr", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 5763, + 8192, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().HELIUM, 20), + new MaterialStack(ELEMENT.getInstance().LITHIUM, 20), new MaterialStack(ELEMENT.getInstance().COBALT, 20), + new MaterialStack(ELEMENT.getInstance().PLATINUM, 20), + new MaterialStack(ELEMENT.getInstance().ERBIUM, 20) }); + + // 0lafe Compound + public static final Material LAFIUM = new Material( + "Lafium Compound", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 6350, // Melting Point in C + 9865, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.HASTELLOY_N, 8), + new MaterialStack(ELEMENT.getInstance().NAQUADAH, 4), new MaterialStack(ELEMENT.getInstance().SAMARIUM, 2), + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 4), new MaterialStack(ELEMENT.getInstance().ARGON, 2), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 6), new MaterialStack(ELEMENT.getInstance().NICKEL, 8), + new MaterialStack(ELEMENT.getInstance().CARBON, 2) }); + + // Cinobi Alloy + public static final Material CINOBITE = new Material( + "Cinobite A243", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 7350, // Melting Point in C + 12565, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.ZERON_100, 16), + new MaterialStack(ELEMENT.getInstance().NAQUADRIA, 7), + new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 5), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 3), new MaterialStack(ELEMENT.getInstance().MERCURY, 2), + new MaterialStack(ELEMENT.getInstance().TIN, 2), new MaterialStack(ELEMENT.getInstance().TITANIUM, 12), + new MaterialStack(ALLOY.OSMIRIDIUM, 6) }); + + // Piky Alloy + public static final Material PIKYONIUM = new Material( + "Pikyonium 64B", // Material Name + MaterialState.SOLID, // State + new short[] { 52, 103, 186, 0 }, // Material Colour + 6850, // Melting Point in C + 11765, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.INCONEL_792, 16), new MaterialStack(ALLOY.EGLIN_STEEL, 10), + new MaterialStack(ELEMENT.getInstance().NAQUADAH_ENRICHED, 8), + new MaterialStack(ELEMENT.getInstance().CERIUM, 6), new MaterialStack(ELEMENT.getInstance().ANTIMONY, 4), + new MaterialStack(ELEMENT.getInstance().PLATINUM, 4), new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), + new MaterialStack(ALLOY.TUNGSTENSTEEL, 8) }); + + // Piky Alloy + public static final Material ABYSSAL = new Material( + "Abyssal Alloy", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 9650, // Melting Point in C + 13765, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.STAINLESS_STEEL, 10), + new MaterialStack(ALLOY.TUNGSTEN_CARBIDE, 10), new MaterialStack(ALLOY.NICHROME, 10), + new MaterialStack(ALLOY.BRONZE, 10), new MaterialStack(ALLOY.INCOLOY_MA956, 10), + new MaterialStack(ELEMENT.getInstance().IODINE, 2), new MaterialStack(ELEMENT.getInstance().RADON, 2), + new MaterialStack(ELEMENT.getInstance().GERMANIUM, 2), }); + + // Alkalus Alloy + public static final Material LAURENIUM = new Material( + "Laurenium", // Material Name + MaterialState.SOLID, // State + new short[] { 244, 168, 255, 0 }, // Material Colour + 6825, // Melting Point in C + 11355, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.EGLIN_STEEL, 40), + new MaterialStack(ELEMENT.getInstance().INDIUM, 10), new MaterialStack(ELEMENT.getInstance().CHROMIUM, 20), + new MaterialStack(ELEMENT.getInstance().DYSPROSIUM, 5), + new MaterialStack(ELEMENT.getInstance().RHENIUM, 5), }); + + // Bot Alloy + public static final Material BOTMIUM = new Material( + "Botmium", // Material Name + MaterialState.SOLID, // State + new short[] { 80, 160, 80, 0 }, // Material Colour + 8220, // Melting Point in C + 10540, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.NITINOL_60, 2), + new MaterialStack(ELEMENT.getInstance().OSMIUM, 12), new MaterialStack(ELEMENT.getInstance().RUTHENIUM, 12), + new MaterialStack(ELEMENT.getInstance().THALLIUM, 6), }); + + // Titansteel + public static final Material TITANSTEEL = new Material( + "Titansteel", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 8250, // Melting Point in C + 11765, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.TUNGSTEN_TITANIUM_CARBIDE, 3), + new MaterialStack(ELEMENT.getInstance().IGNIS, 1), new MaterialStack(ELEMENT.getInstance().TERRA, 1), + new MaterialStack(ELEMENT.getInstance().PERDITIO, 1), }); + + public static final Material OCTIRON = new Material( + "Octiron", // Material Name + MaterialState.SOLID, // State + null, + 9120, // Melting Point in C + 14200, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ARCANITE, 30), new MaterialStack(TITANSTEEL, 30), + new MaterialStack(ENERGYCRYSTAL, 5), new MaterialStack(STEEL_BLACK, 10), + new MaterialStack(ELEMENT.getInstance().THAUMIUM, 25) }); + + public static final Material BLACK_TITANIUM = new Material( + "Black Titanium", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + Materials.Titanium.mMeltingPoint * 4, // Melting Point in C + Materials.Titanium.mMeltingPoint * 16, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().TITANIUM, 55), + new MaterialStack(ELEMENT.getInstance().LANTHANUM, 12), + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 8), new MaterialStack(ELEMENT.getInstance().COBALT, 6), + new MaterialStack(ELEMENT.getInstance().MANGANESE, 4), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 4), + new MaterialStack(ELEMENT.getInstance().PALLADIUM, 4), new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().ARGON, 5) }); + + public static final Material BABBIT_ALLOY = new Material( + "Babbit Alloy", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 268, // Melting Point in C + 589, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().TIN, 10), + new MaterialStack(ELEMENT.getInstance().LEAD, 72), new MaterialStack(ELEMENT.getInstance().ANTIMONY, 16), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 2) }); + + public static final Material INDALLOY_140 = new Material( + "Indalloy 140", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 5200, // Melting Point in C + 6500, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().BISMUTH, 47), + new MaterialStack(ELEMENT.getInstance().LEAD, 25), new MaterialStack(ELEMENT.getInstance().TIN, 13), + new MaterialStack(ELEMENT.getInstance().CADMIUM, 10), new MaterialStack(ELEMENT.getInstance().INDIUM, 5) }); + + // Quantum + public static final Material QUANTUM = new Material( + "Quantum", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 10500, // Melting Point in C + 25000, // Boiling Point in C + 150, // Protons + 200, // Neutrons + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ALLOY.STELLITE, 15), new MaterialStack(ALLOY.ENERGYCRYSTAL, 5), + new MaterialStack(ALLOY.SILICON_CARBIDE, 5), new MaterialStack(ELEMENT.getInstance().GALLIUM, 5), + new MaterialStack(ELEMENT.getInstance().AMERICIUM, 5), + new MaterialStack(ELEMENT.getInstance().PALLADIUM, 5), new MaterialStack(ELEMENT.getInstance().BISMUTH, 5), + new MaterialStack(ELEMENT.getInstance().GERMANIUM, 5) }); +} diff --git a/src/main/java/gtPlusPlus/core/material/ELEMENT.java b/src/main/java/gtPlusPlus/core/material/ELEMENT.java new file mode 100644 index 0000000000..9bcea2a47b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/ELEMENT.java @@ -0,0 +1,651 @@ +package gtPlusPlus.core.material; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.TextureSet; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.client.CustomTextureSet.TextureSets; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; + +public final class ELEMENT { + + public static final String[] NAMES = new String[] { "Hydrogen", "Helium" }; + + // First 50 Elements + public final Material HYDROGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Hydrogen); + public final Material HELIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Helium); + public final Material LITHIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Lithium); + public final Material BERYLLIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Beryllium); + public final Material BORON = MaterialUtils.generateMaterialFromGtENUM(Materials.Boron); + public final Material CARBON = MaterialUtils.generateMaterialFromGtENUM(Materials.Carbon); + public final Material NITROGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Nitrogen); + public final Material OXYGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Oxygen); + public final Material FLUORINE = MaterialUtils.generateMaterialFromGtENUM(Materials.Fluorine); + public final Material NEON = new Material( + "Neon", + MaterialState.PURE_GAS, + new short[] { 240, 180, 30 }, + -248, + -246, + 10, + 10, + false, + "Ne", + 0); // Not a GT Inherited Material + public final Material SODIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Sodium); + public final Material MAGNESIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Magnesium); + public final Material ALUMINIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Aluminium); + public final Material ALUMINIUMOXIDE = MaterialUtils.generateMaterialFromGtENUM(Materials.Aluminiumoxide); + public final Material SILICON = MaterialUtils.generateMaterialFromGtENUM(Materials.Silicon); + public final Material SILICONDIOXIDE = MaterialUtils.generateMaterialFromGtENUM(Materials.SiliconDioxide); + public final Material PHOSPHORUS = MaterialUtils.generateMaterialFromGtENUM(Materials.Phosphorus); + public final Material SULFUR = MaterialUtils.generateMaterialFromGtENUM(Materials.Sulfur); + public final Material CHLORINE = MaterialUtils.generateMaterialFromGtENUM(Materials.Chlorine); + public final Material ARGON = MaterialUtils.generateMaterialFromGtENUM(Materials.Argon); + public final Material POTASSIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Potassium); + public final Material CALCIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Calcium); + public final Material SCANDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Scandium); + public final Material TITANIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Titanium); + public final Material VANADIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Vanadium); + public final Material CHROMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Chrome); + public final Material MANGANESE = MaterialUtils.generateMaterialFromGtENUM(Materials.Manganese); + public final Material IRON = MaterialUtils.generateMaterialFromGtENUM(Materials.Iron); + public final Material COBALT = MaterialUtils.generateMaterialFromGtENUM(Materials.Cobalt); + public final Material NICKEL = MaterialUtils.generateMaterialFromGtENUM(Materials.Nickel); + public final Material COPPER = MaterialUtils.generateMaterialFromGtENUM(Materials.Copper); + public final Material ZINC = MaterialUtils.generateMaterialFromGtENUM(Materials.Zinc); + public final Material GALLIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Gallium); + public final Material GERMANIUM = new Material( + "Germanium", + MaterialState.SOLID, + new short[] { 200, 200, 200 }, + 937, + 2830, + 32, + 41, + false, + "Ge", + 0); // Not a GT Inherited Material + public final Material ARSENIC = MaterialUtils.generateMaterialFromGtENUM(Materials.Arsenic); + public final Material SELENIUM = new Material( + "Selenium", + MaterialState.SOLID, + new short[] { 190, 190, 190 }, + 217, + 685, + 34, + 45, + false, + "Se", + 0); // Not a GT Inherited Material + public final Material BROMINE = new Material( + "Bromine", + MaterialState.PURE_LIQUID, + new short[] { 200, 25, 25 }, + -7, + 58, + 35, + 45, + false, + "Br", + 0); // Not a GT Inherited Material + public final Material KRYPTON = new Material( + "Krypton", + MaterialState.PURE_GAS, + new short[] { 5, 200, 220 }, + -157, + -153, + 36, + 48, + false, + "Kr", + 0); // Not a GT Inherited Material + public final Material RUBIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Rubidium); + public final Material STRONTIUM = MaterialUtils + .generateMaterialFromGtENUM(Materials.Strontium, new short[] { 230, 210, 110 }, TextureSet.SET_FLINT); + public final Material YTTRIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Yttrium); + public final Material ZIRCONIUM = new Material( + "Zirconium", + MaterialState.SOLID, + new short[] { 255, 250, 205 }, + 1855, + 4377, + 40, + 51, + false, + "Zr", + 0); // Not a GT Inherited Material + public final Material NIOBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Niobium); + public final Material MOLYBDENUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Molybdenum); + + public final Material RUTHENIUM = new Material( + "Ruthenium", + MaterialState.SOLID, + new short[] { 220, 220, 220 }, + 2250, + 3900, + 44, + 57, + false, + "Ru", + 0); // Not a GT Inherited Material + public final Material RHODIUM = new Material( + "Rhodium", + MaterialState.SOLID, + new short[] { 220, 220, 220 }, + 1966, + 3727, + 45, + 58, + false, + "Rh", + 0); // Not a GT Inherited Material + public final Material AMERICIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Americium); + public final Material TECHNETIUM = new Material( + "Technetium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 220, 220, 220 }, + 2200, + 4877, + 43, + 55, + false, + "Tc", + 2); // Not a GT Inherited Material + public final Material NEPTUNIUM = new Material( + "Neptunium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 200, 220, 205 }, + 640, + 3902, + 93, + 144, + false, + "Np", + 2); // Not a GT Inherited Material + + public final Material PALLADIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Palladium); + public final Material SILVER = MaterialUtils.generateMaterialFromGtENUM(Materials.Silver); + public final Material CADMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Cadmium); + public final Material INDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Indium); + public final Material TIN = MaterialUtils.generateMaterialFromGtENUM(Materials.Tin); + public final Material ANTIMONY = MaterialUtils.generateMaterialFromGtENUM(Materials.Antimony); + public final Material TELLURIUM = new Material( + "Tellurium", + MaterialState.SOLID, + new short[] { 210, 210, 210 }, + 449, + 989, + 52, + 76, + false, + "Te", + 0); // Not a GT Inherited Material + public final Material IODINE = new Material( + "Iodine", + MaterialState.SOLID, + TextureSet.SET_SHINY, + new short[] { 96, 96, 96 }, + 114, + 184, + 53, + 74, + false, + "I", + 0); // Not a GT Inherited Material + public final Material XENON = new Material( + "Xenon", + MaterialState.PURE_GAS, + new short[] { 5, 105, 210 }, + -111, + -108, + 54, + 77, + false, + "Xe", + 0); // Not a GT Inherited Material + public final Material CAESIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Caesium); + public final Material BARIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Barium); + public final Material LANTHANUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Lanthanum); + public final Material CERIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Cerium); + public final Material PRASEODYMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Praseodymium); + public final Material NEODYMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Neodymium); + public final Material PROMETHIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Promethium); + public final Material SAMARIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Samarium); + public final Material EUROPIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Europium); + public final Material GADOLINIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Gadolinium); + public final Material TERBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Terbium); + public final Material DYSPROSIUM = new Material( + "Dysprosium", + MaterialState.SOLID, + new short[] { 180, 180, 180 }, + 1412, + 2562, + 66, + 97, + false, + "Dy", + 0); // Not a GT Inherited Material + public final Material HOLMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Holmium); + public final Material ERBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Erbium); + public final Material THULIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thulium); + public final Material YTTERBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Ytterbium); + public final Material LUTETIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Lutetium); + public final Material HAFNIUM = new Material( + "Hafnium", + MaterialState.SOLID, + new short[] { 128, 128, 128 }, + 2150, + 5400, + 72, + 106, + false, + "Hf", + 0); // Not a GT Inherited Material + + // Second 50 elements + public final Material TANTALUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Tantalum); + public final Material TUNGSTEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Tungsten); + public final Material RHENIUM = new Material( + "Rhenium", + MaterialState.SOLID, + new short[] { 150, 150, 150 }, + 3180, + 3627, + 75, + 111, + false, + "Re", + 0); // Not a GT Inherited Material + public final Material OSMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Osmium); + public final Material IRIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Iridium); + public final Material PLATINUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Platinum); + public final Material GOLD = MaterialUtils.generateMaterialFromGtENUM(Materials.Gold); + public final Material MERCURY = MaterialUtils.generateMaterialFromGtENUM(Materials.Mercury); // Mercury + public final Material THALLIUM = new Material( + "Thallium", + MaterialState.SOLID, + new short[] { 175, 175, 175 }, + 304, + 1457, + 81, + 123, + false, + "Tl", + 0); // Not a GT Inherited Material + public final Material LEAD = MaterialUtils.generateMaterialFromGtENUM(Materials.Lead); + public final Material BISMUTH = MaterialUtils.generateMaterialFromGtENUM(Materials.Bismuth); + public final Material POLONIUM = new Material( + "Polonium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 180, 170, 180 }, + 254, + 962, + 84, + 125, + false, + "Po", + 1); // Not a GT Inherited Material + + public final Material RADON = MaterialUtils.generateMaterialFromGtENUM(Materials.Radon); + + public final Material RADIUM = new Material( + "Radium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 165, 165, 165 }, + 700, + 1737, + 88, + 138, + false, + "Ra", + 1); // Not a GT Inherited Material + + public final Material THORIUM = new Material( + "Thorium", + MaterialState.SOLID, + Materials.Thorium.mRGBa, + Materials.Thorium.mMeltingPoint, + Materials.Thorium.mBlastFurnaceTemp, + 90, + 142, + false, + StringUtils.superscript("Th"), + 1); + public final Material PROTACTINIUM = new Material( + "Protactinium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 190, 150, 170 }, + 1568, + 4027, + 91, + 140, + false, + "Pa", + 1); // Not a GT Inherited Material + public final Material URANIUM238 = MaterialUtils.generateMaterialFromGtENUM(Materials.Uranium); + public final Material URANIUM235 = MaterialUtils.generateMaterialFromGtENUM(Materials.Uranium235); + public final Material PLUTONIUM241 = MaterialUtils.generateMaterialFromGtENUM(Materials.Plutonium241); + public final Material CURIUM = new Material( + "Curium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 175, 85, 110 }, + 1340, + 3110, + 96, + 151, + false, + "Cm", + 3); // Not a GT Inherited Material + + public final Material CALIFORNIUM = new Material( + "Californium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 85, 110, 205 }, + 899, + 1472, + 98, + 153, + false, + "Cf", + 4); // Not a GT Inherited Material + + public final Material FERMIUM = new Material( + "Fermium", + MaterialState.LIQUID, + TextureSets.NUCLEAR.get(), + new short[] { 75, 90, 25 }, + 1527, + 3850, + 100, + 157, + false, + "Fm", + 5); // Not a GT Inherited Material //Boiling Point is made up + + // Misc + public final Material AER = MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedAir, TextureSets.GEM_A.get()); + public final Material IGNIS = MaterialUtils + .generateMaterialFromGtENUM(Materials.InfusedFire, TextureSets.GEM_A.get()); + public final Material TERRA = MaterialUtils + .generateMaterialFromGtENUM(Materials.InfusedEarth, TextureSets.GEM_A.get()); + public final Material AQUA = MaterialUtils + .generateMaterialFromGtENUM(Materials.InfusedWater, TextureSets.GEM_A.get()); + public final Material PERDITIO = MaterialUtils + .generateMaterialFromGtENUM(Materials.InfusedEntropy, TextureSets.GEM_A.get()); + public final Material ORDO = MaterialUtils + .generateMaterialFromGtENUM(Materials.InfusedOrder, TextureSets.GEM_A.get()); + + public final Material NAQUADAH = MaterialUtils.generateMaterialFromGtENUM(Materials.Naquadah); + public final Material NAQUADAH_ENRICHED = MaterialUtils.generateMaterialFromGtENUM(Materials.NaquadahEnriched); + public final Material NAQUADRIA = MaterialUtils.generateMaterialFromGtENUM(Materials.Naquadria); + public final Material TRINIUM; + public final Material TRINIUM_REFINED; + // https://github.com/Blood-Asp/GT5-Unofficial/issues/609 + + // Custom Isotopes + public final Material LITHIUM7 = new Material( + "Lithium 7", + MaterialState.SOLID, + TextureSet.SET_SHINY, + Materials.Lithium.mRGBa, + Materials.Lithium.mMeltingPoint, + Materials.Lithium.mBlastFurnaceTemp, + Materials.Lithium.getProtons(), + Materials.Lithium.getNeutrons(), + Materials.Lithium.mBlastFurnaceRequired, + StringUtils.superscript("7Li"), + 0, + false); // Not a GT Inherited Material + public final Material URANIUM232 = new Material( + "Uranium 232", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 88, 220, 103, 0 }, + 1132, + 4131, + 92, + 140, + false, + StringUtils.superscript("232U"), + 4); // Not a GT Inherited Material + public final Material URANIUM233 = new Material( + "Uranium 233", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 73, 220, 83, 0 }, + 1132, + 4131, + 92, + 141, + false, + StringUtils.superscript("233U"), + 2); // Not a GT Inherited Material + public final Material THORIUM232 = new Material( + "Thorium 232", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 15, 60, 15, 0 }, + Materials.Thorium.mMeltingPoint, + Materials.Thorium.mBlastFurnaceTemp, + 90, + 142, + false, + StringUtils.superscript("232Th"), + 1, + true); // Not a GT Inherited Material + + // RTG Fuels + public final Material PLUTONIUM238 = new Material( + "Plutonium-238", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + Materials.Plutonium241.mDurability, + Materials.Plutonium241.mRGBa, + Materials.Plutonium241.mMeltingPoint, + Materials.Plutonium241.mBlastFurnaceTemp, + 94, + 144, + false, + StringUtils.superscript("238Pu"), + 2, + false); // Not a GT Inherited Material + + public final Material MAGIC = MaterialUtils + .generateMaterialFromGtENUM(Materials.Magic, new short[] { 10, 185, 140 }); + public final Material THAUMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thaumium); + + static { + Logger.MATERIALS("Initialising Base Elements."); + } + + private static final ELEMENT INSTANCE = new ELEMENT(); + + public ELEMENT() { + // GTNH Trinium Handling + TRINIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Trinium); + TRINIUM_REFINED = TRINIUM; + } + + public static ELEMENT getInstance() { + return INSTANCE; + } + + public static class STANDALONE { + + public static final Material CELESTIAL_TUNGSTEN = new Material( + "Celestial Tungsten", + MaterialState.SOLID, + TextureSets.REFINED.get(), + new short[] { 50, 50, 50, 2 }, + INSTANCE.TUNGSTEN.getMeltingPointC() + 6500, + INSTANCE.TUNGSTEN.getBoilingPointC() + 7500, + 160, + 101, + true, + "✦◆✦", + 0); // Not a GT Inherited Material + public static final Material ASTRAL_TITANIUM = new Material( + "Astral Titanium", + MaterialState.SOLID, + TextureSets.REFINED.get(), + new short[] { 220, 160, 240, 2 }, + INSTANCE.TITANIUM.getMeltingPointC() + 7500, + INSTANCE.TITANIUM.getBoilingPointC() + 7500, + 145, + 133, + true, + "✧◇✧", + 0); // Not a GT Inherited Material + public static final Material CHRONOMATIC_GLASS = new Material( + "Chromatic Glass", + MaterialState.SOLID, + new short[] { 255, 255, 255, 3 }, + 9200, + 17550, + 40, + 51, + false, + "⌘☯𓍰 𓍱 𓍲 𓍳 𓍴 𓍵 𓍶 𓍷 𓍸 ☯⌘ ", + 0); // Not a GT Inherited Material + public static final Material ADVANCED_NITINOL = new Material( + "Advanced Nitinol", + MaterialState.SOLID, + TextureSets.ENRICHED.get(), + ALLOY.NITINOL_60.getRGB(), + 8400, + 14377, + 40, + 51, + true, + StringUtils.subscript("⚷⚙⚷ Ni4Ti6"), + 0); // Not a GT Inherited Material + public static final Material HYPOGEN = new Material( + "Hypogen", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] { 220, 120, 75, 2 }, + 11255, + 19377, + 240, + 251, + true, + "Hy⚶", + 0); // Not a GT Inherited Material + public static final Material RHUGNOR = new Material( + "Rhugnor", + MaterialState.SOLID, + TextureSets.ENRICHED.get(), + new short[] { 190, 0, 255, 0 }, + 8750, + 14757, + 184, + 142, + true, + "Fs⚶", + 0); // Not a GT Inherited Material //funeris + public static final Material FORCE = new Material( + "Force", + MaterialState.SOLID, + TextureSets.ENRICHED.get(), + new short[] { 250, 250, 20, 0 }, + 4550, + 6830, + 63, + 81, + true, + "Fc⚙", + 0); // Not a GT Inherited Material + + // 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().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, + new MaterialStack[] { new MaterialStack(getInstance().OXYGEN, 16), + new MaterialStack(getInstance().IRON, 10), new MaterialStack(getInstance().SILICONDIOXIDE, 10), + new MaterialStack(getInstance().ALUMINIUMOXIDE, 6), new MaterialStack(getInstance().POTASSIUM, 6), + new MaterialStack(getInstance().CALCIUM, 4), new MaterialStack(getInstance().SODIUM, 4), + new MaterialStack(getInstance().YTTERBIUM, 2) }); // 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, + "Rt*", + 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/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java b/src/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java new file mode 100644 index 0000000000..c46b05fbb8 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java @@ -0,0 +1,592 @@ +package gtPlusPlus.core.material; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.TextureSet; +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 separately. Most are + * just compositions which will have dusts assigned to them. + */ + + public static void run() { + MaterialUtils.generateSpecialDustAndAssignToAMaterial(POTASSIUM_NITRATE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_NITRATE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(STRONTIUM_OXIDE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(STRONTIUM_HYDROXIDE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(CYANOACETIC_ACID, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_CYANIDE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(CALCIUM_CHLORIDE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(COPPER_SULFATE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(COPPER_SULFATE_HYDRATED, false); + WATER.registerComponentForMaterial(FluidUtils.getWater(1000)); + } + + public static final Material POTASSIUM_NITRATE = new Material( + "Potassium Nitrate", + MaterialState.SOLID, // State + null, + null, + -1, + -1, + -1, + -1, + false, + "KNO3", + 0, + false, + new MaterialStack(ELEMENT.getInstance().POTASSIUM, 1), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3)); + public static final Material SODIUM_NITRATE = new Material( + "Sodium Nitrate", + MaterialState.SOLID, // State + null, + null, + -1, + -1, + -1, + -1, + false, + "NaNO3", + 0, + false, + new MaterialStack(ELEMENT.getInstance().SODIUM, 1), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3)); + + public static final Material SOLAR_SALT_COLD = new Material( + "Solar Salt (Cold)", + 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(POTASSIUM_NITRATE, 4), + new MaterialStack(SODIUM_NITRATE, 6)); + + public static final Material SOLAR_SALT_HOT = new Material( + "Solar Salt (Hot)", + MaterialState.PURE_LIQUID, // State + new short[] { 200, 25, 25 }, // Material Colour + 1200, // Melting Point in C + 3300, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(POTASSIUM_NITRATE, 4), + new MaterialStack(SODIUM_NITRATE, 6)); + + public static final Material STRONTIUM_OXIDE = new Material( + "Strontium Oxide", + MaterialState.SOLID, + TextureSet.SET_METALLIC, + null, + -1, + -1, + -1, + -1, + false, + "SrO", + 0, + false, + 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(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(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_GAS, // 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(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_GAS, // 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(ELEMENT.getInstance().CARBON, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1)); + + public static final Material CARBON_DIOXIDE = new Material( + "Carbon Dioxide", + MaterialState.PURE_GAS, // 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(ELEMENT.getInstance().CARBON, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2)); + + public static final Material WOODS_GLASS = new Material( + "Wood's Glass", // Material Name + MaterialState.SOLID, // State + TextureSets.GEM_A.get(), // Texture Set + new short[] { 220, 60, 255 }, // Material Colour + -1, + -1, + -1, + -1, + false, + "Si4Ba3Na2Ni", + 0, + false, + new MaterialStack(ELEMENT.getInstance().SILICON, 40), + new MaterialStack(ELEMENT.getInstance().BARIUM, 30), + new MaterialStack(ELEMENT.getInstance().SODIUM, 20), + new MaterialStack(ELEMENT.getInstance().NICKEL, 10)); + + /* + * 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.YTTRIALITE, 1), + new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.NetherQuartz), 1), + new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.Galena), 1), + new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.Chalcopyrite), 1), + new MaterialStack(ORES.CRYOLITE, 1), new MaterialStack(ELEMENT.getInstance().YTTRIUM, 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.SAMARSKITE_Y, 1), + new MaterialStack(ORES.AGARDITE_LA, 1), }); + + public static final Material WATER = new Material( + "Water", + MaterialState.PURE_LIQUID, + 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(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(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(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 4)); + + public static final Material HYDROGEN_CHLORIDE = new Material( + "Hydrogen Chloride", + MaterialState.PURE_GAS, + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1)); + + public static final Material HYDROGEN_CHLORIDE_MIX = new Material( + "Hydrogen Chloride Mix", + 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(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1)); + + public static final Material SODIUM_CHLORIDE = new Material( + "Sodium Chloride", + MaterialState.PURE_GAS, + new MaterialStack(ELEMENT.getInstance().SODIUM, 1), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1)); + + public static final Material SALT_WATER = new Material( + "Salt Water", + MaterialState.PURE_LIQUID, + new MaterialStack(WATER, 3), + new MaterialStack(SODIUM_CHLORIDE, 1)); + + public static final Material BRINE = new Material( + "Brine", + MaterialState.PURE_LIQUID, + new MaterialStack(SALT_WATER, 1), + new MaterialStack(SODIUM_CHLORIDE, 2)); + + public static final Material STRONTIUM_HYDROXIDE = new Material( + "Strontium Hydroxide", + MaterialState.SOLID, + TextureSet.SET_METALLIC, + null, + -1, + -1, + -1, + -1, + false, + "Sr(OH)2", + 0, + false, + new MaterialStack(ELEMENT.getInstance().STRONTIUM, 1), + new MaterialStack(MISC_MATERIALS.HYDROXIDE, 2)); + + // Glue Chemicals + + public static final Material ACETIC_ANHYDRIDE = new Material( + "Acetic Anhydride", + MaterialState.PURE_LIQUID, // State + new short[] { 250, 240, 110 }, // Material Colour + -73, // Melting Point in C + 139, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "(CH3CO)2O", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 4), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 6), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3)); + + public static final Material CHLOROACETIC_ACID = new Material( + "Chloroacetic Acid", + MaterialState.PURE_LIQUID, // State + new short[] { 230, 200, 90 }, // Material Colour + 63, // Melting Point in C + 189, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "ClCH2-COOH", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 3), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1)); + + public static final Material DICHLOROACETIC_ACID = new Material( + "Dichloroacetic Acid", + MaterialState.PURE_LIQUID, // State + new short[] { 190, 160, 60 }, // Material Colour + 13, // Melting Point in C + 194, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "Cl2CH-COOH", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 2)); + + public static final Material TRICHLOROACETIC_ACID = new Material( + "Trichloroacetic Acid", + MaterialState.PURE_LIQUID, // State + new short[] { 120, 100, 30 }, // Material Colour + 57, // Melting Point in C + 196, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "Cl3C-COOH", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); + + public static final Material CHLOROACETIC_MIXTURE = new Material( + "Chloroacetic Mixture", + MaterialState.LIQUID, // State + null, + new short[] { 210, 160, 10 }, + 40, + 192, + -1, + -1, + false, + "Cl?H?C-COOH", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 6), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 6), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 6), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 6)); + + public static final Material SODIUM_CYANIDE = new Material( + "Sodium Cyanide", + MaterialState.SOLID, // State + new short[] { 180, 190, 255 }, // Material Colour + 563, // Melting Point in C + 1496, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "NaCN", + 0, + false, + new MaterialStack(ELEMENT.getInstance().SODIUM, 1), + new MaterialStack(ELEMENT.getInstance().CARBON, 1), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1)); + + public static final Material CALCIUM_CHLORIDE = new Material( + "Calcium Chloride", + MaterialState.SOLID, // State + new short[] { 180, 190, 255 }, // Material Colour + 563, // Melting Point in C + 1496, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "CaCl2", + 0, + false, + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 2)); + + public static final Material CYANOACETIC_ACID = new Material( + "Cyanoacetic Acid", + MaterialState.SOLID, // State + new short[] { 130, 130, 40 }, // Material Colour + 66, // Melting Point in C + 108, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "C3H3NO2", + 0, + false, + new MaterialStack(ELEMENT.getInstance().CARBON, 3), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 3), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2)); + + public static final Material SOLID_ACID_MIXTURE = new Material( + "Solid Acid Catalyst Mixture", + MaterialState.LIQUID, // State + new short[] { 80, 40, 0 }, // Material Colour + -10, // Melting Point in C + 337, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "?H2SO4?", + 0, + true, + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().SULFUR, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); + + public static final Material COPPER_SULFATE = new Material( + "Copper(II) Sulfate", + MaterialState.SOLID, // State + new short[] { 200, 200, 200 }, // Material Colour + 590, // Melting Point in C + 650, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "CuSO4", + 0, + false, + new MaterialStack(ELEMENT.getInstance().COPPER, 1), + new MaterialStack(ELEMENT.getInstance().SULFUR, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); + + public static final Material COPPER_SULFATE_HYDRATED = new Material( + "Copper(II) Sulfate Pentahydrate", + MaterialState.SOLID, // State + new short[] { 90, 170, 255 }, // Material Colour + 590, // Melting Point in C + 650, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "CuSO4∙(H2O)5", + 0, + false, + new MaterialStack(ELEMENT.getInstance().COPPER, 1), + new MaterialStack(ELEMENT.getInstance().SULFUR, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); + + public static final Material ETHYL_CYANOACETATE = new Material( + "Ethyl Cyanoacetate", + MaterialState.PURE_LIQUID, // State + new short[] { 0, 75, 160 }, // Material Colour + -22, // Melting Point in C + 210, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "C5H7NO2", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); + + public static final Material CYANOACRYLATE_POLYMER = new Material( + "Cyanoacrylate Polymer", + MaterialState.LIQUID, // State + new short[] { 140, 150, 160 }, // Material Colour + -25, // Melting Point in C + 55, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "(-C6H7NO2-)n", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); + + public static final Material ETHYL_CYANOACRYLATE = new Material( + "Ethyl Cyanoacrylate (Super Glue)", + MaterialState.PURE_LIQUID, // State + new short[] { 170, 190, 200 }, // Material Colour + -25, // Melting Point in C + 55, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "C6H7NO2", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); + + public static final Material MUTATED_LIVING_SOLDER = new Material( + "Mutated Living Solder", + MaterialState.PURE_LIQUID, // State + new short[] { 147, 109, 155 }, // Material Colour + -200, // Melting Point in C + 500, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "?Sn?Bi?", + 0, + true, + new MaterialStack(ELEMENT.getInstance().TIN, 1), + new MaterialStack(ELEMENT.getInstance().BISMUTH, 1)); +} diff --git a/src/main/java/gtPlusPlus/core/material/Material.java b/src/main/java/gtPlusPlus/core/material/Material.java new file mode 100644 index 0000000000..fec80060ac --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/Material.java @@ -0,0 +1,1725 @@ +package gtPlusPlus.core.material; + +import static gregtech.api.enums.GT_Values.M; +import static gregtech.api.enums.Mods.TinkerConstruct; +import static gtPlusPlus.core.util.math.MathUtils.safeCast_LongToInt; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.base.BaseItemComponent.ComponentTypes; +import gtPlusPlus.core.item.base.cell.BaseItemCell; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.xmod.tinkers.material.BaseTinkersMaterial; + +public class Material { + + public static final Set<Material> mMaterialMap = new HashSet<>(); + public static HashMap<String, Material> mMaterialCache = new HashMap<>(); + + public static final Map<String, Map<String, ItemStack>> mComponentMap = new HashMap<>(); + + public static HashMap<String, String> sChemicalFormula = new HashMap<>(); + + private String unlocalizedName; + private String localizedName; + private String translatedName; + + private MaterialState materialState; + private TextureSet textureSet; + + private Fluid mFluid; + private Fluid mPlasma; + + private boolean vGenerateCells; + + protected Object dataVar = MathUtils.generateSingularRandomHexValue(); + + private ArrayList<MaterialStack> vMaterialInput = new ArrayList<>(); + public long[] vSmallestRatio; + public short vComponentCount; + + private short[] RGBA; + + private boolean usesBlastFurnace; + public boolean isRadioactive; + public byte vRadiationLevel; + + private int meltingPointK; + private int boilingPointK; + private int meltingPointC; + private int boilingPointC; + private long vProtons; + private long vNeutrons; + private long vMass; + public int smallestStackSizeWhenProcessing; // Add a check for <=0 || > 64 + public int vTier; + public int vVoltageMultiplier; + public String vChemicalFormula; + public String vChemicalSymbol; + + public long vDurability; + public int vToolQuality; + public int vHarvestLevel; + + public BaseTinkersMaterial vTiConHandler; + + public short werkstoffID; + + public static AutoMap<Materials> invalidMaterials = new AutoMap<>(); + + 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(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); + } + + public Material(String materialName, MaterialState defaultState, short[] rgba, int j, int k, int l, int m, + int radiationLevel, MaterialStack[] materialStacks) { + 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 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) { + this( + materialName, + defaultState, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + "", + 0, + inputs); + } + + 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 String chemSymbol, final MaterialStack... inputs) { + this( + materialName, + defaultState, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemSymbol, + 0, + inputs); + } + + 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, boolean generateCells, final MaterialStack... inputs) { + this( + materialName, + defaultState, + null, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + "", + 0, + generateCells, + true, + inputs); + } + + 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 int radiationLevel, final MaterialStack... inputs) { + this( + materialName, + defaultState, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + "", + radiationLevel, + inputs); + } + + public Material(final String materialName, final MaterialState defaultState, final long durability, + final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, + final boolean blastFurnace, final int radiationLevel, final MaterialStack... inputs) { + this( + materialName, + defaultState, + durability, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + "", + radiationLevel, + inputs); + } + + 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 String chemicalSymbol, final int radiationLevel, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + inputs); + } + + 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 String chemicalSymbol, final int radiationLevel, boolean addCells, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + null, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + addCells, + true, + inputs); + } + + public Material(final String materialName, final MaterialState defaultState, TextureSet textureSet, + final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, + final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + textureSet, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + true, + true, + inputs); + } + + public Material(final String materialName, final MaterialState defaultState, TextureSet textureSet, + final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, + final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, boolean addCells, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + textureSet, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + addCells, + true, + inputs); + } + + private Material(final String materialName, final MaterialState defaultState, final long durability, + final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, + final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + null, + durability, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + true, + true, + inputs); + } + + public Material(final String materialName, final MaterialState defaultState, final TextureSet set, + final long durability, final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, + final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, + boolean generateCells, final MaterialStack... inputs) { + this( + materialName, + defaultState, + set, + durability, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + true, + true, + inputs); + } + + public Material(final String materialName, final MaterialState defaultState, final TextureSet set, + final long durability, short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, + final long neutrons, final boolean blastFurnace, String chemicalSymbol, final int radiationLevel, + boolean generateCells, boolean generateFluid, final MaterialStack... inputs) { + + if (mMaterialMap.add(this)) {} + + if (defaultState == MaterialState.ORE) { + rgba = null; + } + + mComponentMap.put(unlocalizedName, new HashMap<>()); + + try { + this.unlocalizedName = Utils.sanitizeString(materialName); + this.localizedName = materialName; + this.translatedName = GT_LanguageManager + .addStringLocalization("gtplusplus.material." + unlocalizedName, localizedName); + mMaterialCache.put(getLocalizedName().toLowerCase(), this); + Logger.INFO("Stored " + getLocalizedName() + " to cache with key: " + getLocalizedName().toLowerCase()); + + this.materialState = defaultState; + + Logger.MATERIALS(this.getLocalizedName() + " is " + defaultState.name() + "."); + + this.vGenerateCells = generateCells; + + // Add Components to an array. + if (inputs == null) { + this.vMaterialInput = null; + } else { + if (inputs.length != 0) { + for (int i = 0; i < inputs.length; i++) { + if (inputs[i] != null) { + this.vMaterialInput.add(i, inputs[i]); + } + } + } + } + + // set RGB + + if (rgba == null) { + if (vMaterialInput.size() > 0) { + + try { + Short[] mMixedRGB = new Short[3]; + AutoMap<Material> mMaterialSet = MaterialUtils.getCompoundMaterialsRecursively(this); + for (int mnh = 0; mnh < 3; mnh++) { + AutoMap<Short> aDataSet = new AutoMap<>(); + Set<Material> set4 = new HashSet<>(); + for (Material u : mMaterialSet) { + // if (u.getState() == MaterialState.ORE || u.getState() == MaterialState.SOLID) + set4.add(u); + } + for (Material e : set4) { + aDataSet.put(e.getRGB()[mnh]); + } + + Short aAverage = MathUtils.getShortAverage(aDataSet); + if (aAverage > Short.MAX_VALUE || aAverage < Short.MIN_VALUE + || aAverage < 0 + || aAverage > 255) { + if (aAverage > 255) { + while (aAverage > 255) { + aAverage = (short) (aAverage / 2); + } + } + aAverage = (short) Math.max(Math.min(aAverage, 255), 0); + } + mMixedRGB[mnh] = aAverage; + } + + if (mMixedRGB != null && mMixedRGB[0] != null && mMixedRGB[1] != null && mMixedRGB[2] != null) { + this.RGBA = new short[] { mMixedRGB[0], mMixedRGB[1], mMixedRGB[2], 0 }; + } else { + this.RGBA = Materials.Steel.mRGBa; + } + } catch (Throwable t) { + t.printStackTrace(); + this.RGBA = Materials.Steel.mRGBa; + } + } else { + // Boring Grey Material + + int aValueForGen = this.getUnlocalizedName() + .hashCode(); + int hashSize = MathUtils.howManyPlaces(aValueForGen); + + String a = String.valueOf(aValueForGen); + String b = ""; + + if (hashSize < 9) { + int aSecondHash = this.materialState.hashCode(); + int hashSize2 = MathUtils.howManyPlaces(aSecondHash); + if (hashSize2 + hashSize >= 9) { + b = String.valueOf(aValueForGen); + } else { + String c = b; + while (MathUtils.howManyPlaces(hashSize + c.length()) < 9) { + c = c + c.hashCode(); + } + b = c; + } + } + + String valueR; + if (b != null) { + valueR = a + b; + } else { + valueR = a; + } + short fc[] = new short[3]; + int aIndex = 0; + for (char gg : valueR.toCharArray()) { + short ui = Short.parseShort("" + gg); + if (ui > 255 || ui < 0) { + if (ui > 255) { + while (ui > 255) { + ui = (short) (ui / 2); + } + } else { + ui = 0; + } + } + fc[aIndex++] = ui; + } + this.RGBA = fc; + } + } else { + this.RGBA = rgba; + } + + // Set Melting/Boiling point, if value is -1 calculate it from compound inputs. + if (meltingPoint != -1) { + this.meltingPointC = meltingPoint; + } else { + this.meltingPointC = this.calculateMeltingPoint(); + } + if (boilingPoint != -1) { + if (boilingPoint != 0) { + this.boilingPointC = boilingPoint; + } else { + this.boilingPointC = meltingPoint * 4; + } + } else { + this.boilingPointC = this.calculateBoilingPoint(); + } + + this.meltingPointK = (int) MathUtils.celsiusToKelvin(this.meltingPointC); + this.boilingPointK = (int) MathUtils.celsiusToKelvin(this.boilingPointC); + + // Set Proton/Neutron count, if value is -1 calculate it from compound inputs. + if (protons != -1) { + this.vProtons = protons; + } else { + this.vProtons = this.calculateProtons(); + } + if (boilingPoint != -1) { + this.vNeutrons = neutrons; + } else { + this.vNeutrons = this.calculateNeutrons(); + } + + this.vMass = this.getMass(); + + // Sets tool Durability + if (durability != 0) { + this.vDurability = durability; + } else { + long aTempDura = 0; + for (MaterialStack g : this.getComposites()) { + if (g != null) { + aTempDura += safeCast_LongToInt( + g.getStackMaterial() + .getMass() * 2000); + } + } + this.vDurability = aTempDura > 0 ? aTempDura + : (this.getComposites() + .isEmpty() ? 51200 + : 32000 * this.getComposites() + .size()); + } + + if ((this.vDurability >= 0) && (this.vDurability < 64000)) { + this.vToolQuality = 1; + this.vHarvestLevel = 2; + } else if ((this.vDurability >= 64000) && (this.vDurability < 128000)) { + this.vToolQuality = 2; + this.vHarvestLevel = 2; + } else if ((this.vDurability >= 128000) && (this.vDurability < 256000)) { + this.vToolQuality = 3; + this.vHarvestLevel = 2; + } else if ((this.vDurability >= 256000) && (this.vDurability < 512000)) { + this.vToolQuality = 3; + this.vHarvestLevel = 3; + } else if ((this.vDurability >= 512000) && (this.vDurability <= Integer.MAX_VALUE)) { + this.vToolQuality = 4; + this.vHarvestLevel = 4; + } else { + this.vToolQuality = 1; + this.vHarvestLevel = 1; + } + + // Sets the Rad level + if (radiationLevel > 0) { + Logger.MATERIALS(this.getLocalizedName() + " is radioactive. Level: " + radiationLevel + "."); + this.isRadioactive = true; + this.vRadiationLevel = (byte) radiationLevel; + } else { + if (vMaterialInput.size() > 0) { + AutoMap<Byte> aDataSet = new AutoMap<>(); + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put(m.getStackMaterial().vRadiationLevel); + } + byte aAverage = MathUtils.getByteAverage(aDataSet); + if (aAverage > 0) { + Logger.MATERIALS( + this.getLocalizedName() + " is radioactive due to trace elements. Level: " + + aAverage + + "."); + this.isRadioactive = true; + this.vRadiationLevel = aAverage; + } else { + Logger.MATERIALS(this.getLocalizedName() + " is not radioactive."); + this.isRadioactive = false; + this.vRadiationLevel = 0; + } + } else { + Logger.MATERIALS(this.getLocalizedName() + " is not radioactive."); + this.isRadioactive = false; + this.vRadiationLevel = 0; + } + } + + /* + * if (vMaterialInput.size() > 0) { AutoMap<Integer> aDataSet = new AutoMap<Integer>(); int bonus = 0; bonus + * += this.vMaterialInput.size(); bonus += MathUtils.roundToClosestInt(meltingPointC/1000); + * aDataSet.put(bonus); for (MaterialStack m : this.vMaterialInput) { + * aDataSet.put(m.getStackMaterial().vTier); } int aAverage = MathUtils.getIntAverage(aDataSet); if + * (aAverage > Integer.MAX_VALUE || aAverage < Integer.MIN_VALUE) { aAverage = 0; } if (aAverage > 0) { + * this.vTier = Math.min(aAverage, 10); } else { this.vTier = MaterialUtils.getTierOfMaterial((int) + * MathUtils.celsiusToKelvin(meltingPoint)); } } else { this.vTier = MaterialUtils.getTierOfMaterial((int) + * MathUtils.celsiusToKelvin(meltingPoint)); } + */ + this.vTier = MaterialUtils.getTierOfMaterial(meltingPoint); + + // Sets the materials 'tier'. Will probably replace this logic. + + this.usesBlastFurnace = blastFurnace; + this.vVoltageMultiplier = MaterialUtils.getVoltageForTier(vTier); + + this.vComponentCount = this.getComponentCount(inputs); + this.vSmallestRatio = this.getSmallestRatio(this.vMaterialInput); + int tempSmallestSize = 0; + + if (this.vSmallestRatio != null) { + for (long l : this.vSmallestRatio) { + tempSmallestSize = (int) (tempSmallestSize + l); + } + this.smallestStackSizeWhenProcessing = tempSmallestSize; // Valid stacksizes + } else { + this.smallestStackSizeWhenProcessing = 1; // Valid stacksizes + } + + // Makes a Fancy Chemical Tooltip + + if (chemicalSymbol == null) { + chemicalSymbol = ""; + } + + this.vChemicalSymbol = chemicalSymbol; + if (this.vMaterialInput != null) { + this.vChemicalFormula = this.getToolTip(chemicalSymbol, OrePrefixes.dust.mMaterialAmount / M, true); + } else if (!this.vChemicalSymbol.equals("")) { + Logger.MATERIALS("materialInput is null, using a valid chemical symbol."); + this.vChemicalFormula = this.vChemicalSymbol; + } else { + Logger.MATERIALS("MaterialInput == null && chemicalSymbol probably equals nothing"); + this.vChemicalSymbol = "??"; + this.vChemicalFormula = "??"; + } + + if (generateFluid) { + final Materials aGregtechMaterial = tryFindGregtechMaterialEquivalent(); + FluidStack aTest = FluidUtils.getWildcardFluidStack(localizedName, 1); + if (aTest != null) { + this.mFluid = aTest.getFluid(); + checkForCellAndGenerate(this); + } else { + if (aGregtechMaterial != null && !MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { + aTest = FluidUtils.getWildcardFluidStack(aGregtechMaterial, 1); + } + if (aTest != null) { + this.mFluid = aTest.getFluid(); + checkForCellAndGenerate(this); + } else { + mFluid = generateFluid(); + } + } + // Don't generate plasma for composites + if (this.getComposites() + .isEmpty()) { + this.mPlasma = this.generatePlasma(); + } + } else { + this.mFluid = null; + this.mPlasma = null; + } + String ratio = ""; + if (this.vSmallestRatio != null) { + for (long l : this.vSmallestRatio) { + if (ratio.equals("")) { + ratio = String.valueOf(l); + } else { + ratio = ratio + ":" + l; + } + } + } + + this.textureSet = setTextureSet(set, vTier); + + if (TinkerConstruct.isModLoaded() && this.materialState == MaterialState.SOLID) { + if (this.getProtons() >= 98 || this.getComposites() + .size() > 1 || this.getMeltingPointC() >= 3600) { + this.vTiConHandler = new BaseTinkersMaterial(this); + } + } + + sChemicalFormula.put(materialName.toLowerCase(), this.vChemicalFormula); + Logger.MATERIALS("Creating a Material instance for " + materialName); + Logger.MATERIALS( + "Formula: " + this.vChemicalFormula + + " Smallest Stack: " + + this.smallestStackSizeWhenProcessing + + " Smallest Ratio:" + + ratio); + Logger.MATERIALS("Protons: " + this.vProtons); + Logger.MATERIALS("Neutrons: " + this.vNeutrons); + Logger.MATERIALS("Mass: " + this.vMass + "/units"); + Logger.MATERIALS("Melting Point: " + this.meltingPointC + "C."); + Logger.MATERIALS("Boiling Point: " + this.boilingPointC + "C."); + } catch (Throwable t) { + Logger.MATERIALS("Stack Trace for " + materialName); + t.printStackTrace(); + } + } + + private static void checkForCellAndGenerate(Material material) { + if (!material.vGenerateCells) { + return; + } + String aName = Utils.sanitizeString(material.unlocalizedName); + String aName2 = Utils.sanitizeString(material.unlocalizedName.toLowerCase()); + String aName3 = (material.localizedName == null) ? aName : material.localizedName; + ItemStack aTestCell1 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aName, 1); + ItemStack aTestCell2 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aName2, 1); + ItemStack aTestCell3 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aName3, 1); + if (aTestCell1 == null && aTestCell2 == null && aTestCell3 == null) { + Logger.INFO("Generating cell for " + material.localizedName); + new BaseItemCell(material); + } else { + if (aTestCell1 != null) { + Logger.INFO("Registering existing cell for " + material.localizedName + ", " + aName); + material.registerComponentForMaterial(OrePrefixes.cell, aTestCell1); + } else if (aTestCell2 != null) { + Logger.INFO("Registering existing cell for " + material.localizedName + ", " + aName2); + material.registerComponentForMaterial(OrePrefixes.cell, aTestCell2); + } else if (aTestCell3 != null) { + Logger.INFO("Registering existing cell for " + material.localizedName + ", " + aName3); + material.registerComponentForMaterial(OrePrefixes.cell, aTestCell3); + } + } + } + + public final TextureSet getTextureSet() { + synchronized (this) { + return textureSet; + } + } + + public TextureSet setTextureSet(TextureSet set) { + return setTextureSet(set, vTier); + } + + public TextureSet setTextureSet(TextureSet set, int aTier) { + if (set != null) { + Logger.MATERIALS( + "Set textureset for " + this.localizedName + + " to be " + + set.mSetName + + ". This textureSet was supplied."); + return set; + } + + int aGem = 0; + int aShiny = 0; + TextureSet aSet = null; + + // Check Mixture Contents + for (MaterialStack m : this.getComposites()) { + + // Gems + if (m.getStackMaterial() == ELEMENT.getInstance().AER) { + aGem++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().AQUA) { + aGem++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().IGNIS) { + aGem++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().TERRA) { + aGem++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().MAGIC) { + aGem++; + } + // Shiny Materials + if (m.getStackMaterial() == ELEMENT.getInstance().GOLD) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().SILVER) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().PLATINUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().TITANIUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().GERMANIUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().GALLIUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().MERCURY) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().MAGIC) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().SAMARIUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().TANTALUM) { + aShiny++; + } + } + + if (aSet == null) { + if (aGem >= this.getComposites() + .size() / 2) { + if (MathUtils.isNumberEven(aGem)) { + Logger.MATERIALS( + "Set textureset for " + this.localizedName + + " to be " + + TextureSet.SET_GEM_HORIZONTAL.mSetName + + "."); + return TextureSet.SET_GEM_HORIZONTAL; + } else { + Logger.MATERIALS( + "Set textureset for " + this.localizedName + + " to be " + + TextureSet.SET_GEM_VERTICAL.mSetName + + "."); + return TextureSet.SET_GEM_VERTICAL; + } + } + } + + if (aSet == null) { + if (aShiny >= this.getComposites() + .size() / 3) { + Logger.MATERIALS( + "Set textureset for " + this.localizedName + " to be " + TextureSet.SET_SHINY.mSetName + "."); + return TextureSet.SET_SHINY; + } + } + + // build hash table with count + AutoMap<Material> sets = new AutoMap<>(); + if (this.vMaterialInput != null) { + for (MaterialStack r : this.vMaterialInput) { + if (r.getStackMaterial() + .getTextureSet().mSetName.toLowerCase() + .contains("fluid")) { + sets.put(ELEMENT.getInstance().GOLD); + } else { + sets.put(r.getStackMaterial()); + } + } + TextureSet mostUsedTypeTextureSet = MaterialUtils.getMostCommonTextureSet(new ArrayList<>(sets.values())); + if (mostUsedTypeTextureSet != null && mostUsedTypeTextureSet instanceof TextureSet) { + Logger.MATERIALS( + "Set textureset for " + this.localizedName + " to be " + mostUsedTypeTextureSet.mSetName + "."); + return mostUsedTypeTextureSet; + } + } + Logger.MATERIALS( + "Set textureset for " + this.localizedName + " to be " + Materials.Iron.mIconSet.mSetName + ". [Fallback]"); + return Materials.Gold.mIconSet; + } + + public final String getLocalizedName() { + if (this.localizedName != null) { + return this.localizedName; + } + return "ERROR BAD LOCALIZED NAME"; + } + + public final String getUnlocalizedName() { + if (this.unlocalizedName != null) { + return this.unlocalizedName; + } + return "ERROR.BAD.UNLOCALIZED.NAME"; + } + + public final String getTranslatedName() { + if (this.translatedName != null) { + return this.translatedName; + } + return "ERROR.BAD.TRANSLATED.NAME"; + } + + public final MaterialState getState() { + return this.materialState; + } + + public final short[] getRGB() { + if (this.RGBA != null) { + return this.RGBA; + } + return new short[] { 255, 0, 0 }; + } + + public final short[] getRGBA() { + if (this.RGBA != null) { + if (this.RGBA.length == 4) { + return this.RGBA; + } else { + return new short[] { this.RGBA[0], this.RGBA[1], this.RGBA[2], 0 }; + } + } + return new short[] { 255, 0, 0, 0 }; + } + + public final int getRgbAsHex() { + + final int returnValue = Utils.rgbtoHexValue(this.RGBA[0], this.RGBA[1], this.RGBA[2]); + if (returnValue == 0) { + return (int) this.dataVar; + } + return Utils.rgbtoHexValue(this.RGBA[0], this.RGBA[1], this.RGBA[2]); + } + + public final long getProtons() { + return this.vProtons; + } + + public final long getNeutrons() { + return this.vNeutrons; + } + + public final long getMass() { + return this.vProtons + this.vNeutrons; + } + + public final int getMeltingPointC() { + return this.meltingPointC; + } + + public final int getBoilingPointC() { + return this.boilingPointC; + } + + public final int getMeltingPointK() { + return this.meltingPointK; + } + + public final int getBoilingPointK() { + return this.boilingPointK; + } + + public final boolean requiresBlastFurnace() { + return this.usesBlastFurnace; + } + + public final ItemStack getComponentByPrefix(OrePrefixes aPrefix, int stacksize) { + String aKey = aPrefix.name(); + Map<String, ItemStack> g = mComponentMap.get(this.unlocalizedName); + if (g == null) { + Map<String, ItemStack> aMap = new HashMap<>(); + mComponentMap.put(unlocalizedName, aMap); + g = aMap; + } + ItemStack i = g.get(aKey); + if (i != null) { + return ItemUtils.getSimpleStack(i, stacksize); + } else { + // Try get a GT Material + Materials Erf = MaterialUtils.getMaterial(this.unlocalizedName); + if (Erf != null && !MaterialUtils.isNullGregtechMaterial(Erf)) { + ItemStack Erg = ItemUtils.getOrePrefixStack(aPrefix, Erf, stacksize); + if (Erg != null && ItemUtils.checkForInvalidItems(Erg)) { + Logger.MATERIALS("Found \"" + aKey + this.unlocalizedName + "\" using backup GT Materials option."); + g.put(aKey, Erg); + mComponentMap.put(unlocalizedName, g); + return Erg; + } else { + // Try get a molten cell + if (aPrefix == OrePrefixes.cell) { + Erg = ItemUtils.getOrePrefixStack(OrePrefixes.cellMolten, Erf, stacksize); + if (Erg != null && ItemUtils.checkForInvalidItems(Erg)) { + Logger.MATERIALS( + "Found \"" + OrePrefixes.cellMolten.name() + + this.unlocalizedName + + "\" using backup GT Materials option."); + g.put(aKey, Erg); + mComponentMap.put(unlocalizedName, g); + return Erg; + } + } + } + } else { + ItemStack u = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(aKey + this.unlocalizedName, stacksize); + if (u != null) { + g.put(aKey, u); + mComponentMap.put(unlocalizedName, g); + return u; + } + } + // Logger.MATERIALS("Unabled to find \"" + aKey + this.unlocalizedName + "\""); + return ItemUtils.getErrorStack(stacksize, (aKey + this.unlocalizedName + " x" + stacksize)); + } + } + + public final Block getBlock() { + Block b = Block.getBlockFromItem(getBlock(1).getItem()); + if (b == null) { + Logger.INFO( + "[ERROR] Tried to get invalid block for " + this.getLocalizedName() + + ", returning debug block instead."); + } + return b != null ? b : Blocks.lit_furnace; + } + + public final ItemStack getBlock(final int stacksize) { + ItemStack i = getComponentByPrefix(OrePrefixes.block, stacksize); + return i != null ? i + : ItemUtils.getItemStackOfAmountFromOreDictNoBroken("block" + this.unlocalizedName, stacksize); + } + + public final ItemStack getDust(final int stacksize) { + ItemStack i = getComponentByPrefix(OrePrefixes.dust, stacksize); + return i != null ? i : ItemUtils.getGregtechDust("dust" + this.unlocalizedName, stacksize); + } + + public final ItemStack getSmallDust(final int stacksize) { + return getComponentByPrefix(OrePrefixes.dustSmall, stacksize); + } + + public final ItemStack getTinyDust(final int stacksize) { + return getComponentByPrefix(OrePrefixes.dustTiny, stacksize); + } + + public final ItemStack getIngot(final int stacksize) { + return getComponentByPrefix(OrePrefixes.ingot, stacksize); + } + + public final ItemStack getHotIngot(final int stacksize) { + return getComponentByPrefix(OrePrefixes.ingotHot, stacksize); + } + + public final ItemStack getPlate(final int stacksize) { + return getComponentByPrefix(OrePrefixes.plate, stacksize); + } + + public final ItemStack getPlateDouble(final int stacksize) { + return getComponentByPrefix(OrePrefixes.plateDouble, stacksize); + } + + public final ItemStack getPlateDense(final int stacksize) { + return getComponentByPrefix(OrePrefixes.plateDense, stacksize); + } + + public final ItemStack getGear(final int stacksize) { + return getComponentByPrefix(OrePrefixes.gearGt, stacksize); + } + + public final ItemStack getRod(final int stacksize) { + return getComponentByPrefix(OrePrefixes.stick, stacksize); + } + + public final ItemStack getLongRod(final int stacksize) { + return getComponentByPrefix(OrePrefixes.stickLong, stacksize); + } + + public final ItemStack getBolt(final int stacksize) { + return getComponentByPrefix(OrePrefixes.bolt, stacksize); + } + + public final ItemStack getScrew(final int stacksize) { + return getComponentByPrefix(OrePrefixes.screw, stacksize); + } + + public final ItemStack getFineWire(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireFine, stacksize); + } + + public final ItemStack getFoil(final int stacksize) { + return getComponentByPrefix(OrePrefixes.foil, stacksize); + } + + public final ItemStack getRing(final int stacksize) { + return getComponentByPrefix(OrePrefixes.ring, stacksize); + } + + public final ItemStack getRotor(final int stacksize) { + return getComponentByPrefix(OrePrefixes.rotor, stacksize); + } + + public final ItemStack getFrameBox(final int stacksize) { + return getComponentByPrefix(OrePrefixes.frameGt, stacksize); + } + + public final ItemStack getCell(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cell, stacksize); + } + + public final ItemStack getPlasmaCell(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cellPlasma, stacksize); + } + + public final ItemStack getNugget(final int stacksize) { + return getComponentByPrefix(OrePrefixes.nugget, stacksize); + } + + public final ItemStack getWire01(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt01, stacksize); + } + + public final ItemStack getWire02(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt02, stacksize); + } + + public final ItemStack getWire04(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt04, stacksize); + } + + public final ItemStack getWire08(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt08, stacksize); + } + + public final ItemStack getWire12(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt12, stacksize); + } + + public final ItemStack getWire16(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt16, stacksize); + } + + public final ItemStack getCable01(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt01, stacksize); + } + + public final ItemStack getCable02(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt02, stacksize); + } + + public final ItemStack getCable04(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt04, stacksize); + } + + public final ItemStack getCable08(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt08, stacksize); + } + + public final ItemStack getCable12(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt12, stacksize); + } + + public final ItemStack getCable16(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt16, stacksize); + } + + /** + * Ore Components + * + * @return + */ + public final ItemStack getOre(final int stacksize) { + return ItemUtils.getItemStackOfAmountFromOreDictNoBroken( + "ore" + Utils.sanitizeString(this.getUnlocalizedName()), + stacksize); + } + + public final Block getOreBlock(final int stacksize) { + // Logger.DEBUG_MATERIALS("Trying to get ore block for "+this.getLocalizedName()+". Looking for + // '"+"ore"+Utils.sanitizeString(this.getUnlocalizedName())+"'."); + try { + ItemStack a1 = getOre(1); + Item a2 = a1.getItem(); + Block a3 = Block.getBlockFromItem(a2); + if (a3 != null) { + return a3; + } + + Block x = Block.getBlockFromItem( + ItemUtils + .getItemStackOfAmountFromOreDictNoBroken( + "ore" + Utils.sanitizeString(this.unlocalizedName), + stacksize) + .getItem()); + if (x != null) { + return x; + } + } catch (Throwable t) { + // t.printStackTrace(); + } + // Logger.MATERIALS("Failed getting the Ore Block for "+this.getLocalizedName()+"."); + return Blocks.stone; + } + + public final ItemStack getCrushed(final int stacksize) { + return getComponentByPrefix(OrePrefixes.crushed, stacksize); + } + + public final ItemStack getCrushedPurified(final int stacksize) { + return getComponentByPrefix(OrePrefixes.crushedPurified, stacksize); + } + + public final ItemStack getCrushedCentrifuged(final int stacksize) { + return getComponentByPrefix(OrePrefixes.crushedCentrifuged, stacksize); + } + + public final ItemStack getDustPurified(final int stacksize) { + return getComponentByPrefix(OrePrefixes.dustPure, stacksize); + } + + public final ItemStack getDustImpure(final int stacksize) { + return getComponentByPrefix(OrePrefixes.dustImpure, stacksize); + } + + public final ItemStack getMilled(final int stacksize) { + return getComponentByPrefix(OrePrefixes.milled, stacksize); + } + + public final ItemStack getRawOre(final int stacksize) { + return getComponentByPrefix(OrePrefixes.rawOre, stacksize); + } + + public final boolean hasSolidForm() { + if (ItemUtils + .checkForInvalidItems(new ItemStack[] { getDust(1), getBlock(1), getTinyDust(1), getSmallDust(1) })) { + return true; + } + return false; + } + + public final ItemStack[] getMaterialComposites() { + if (this.vMaterialInput != null && !this.vMaterialInput.isEmpty()) { + final ItemStack[] temp = new ItemStack[this.vMaterialInput.size()]; + for (int i = 0; i < this.vMaterialInput.size(); i++) { + // Utils.LOG_MATERIALS("i:"+i); + ItemStack testNull = null; + try { + testNull = this.vMaterialInput.get(i) + .getValidStack(); + } catch (final Throwable r) { + Logger.MATERIALS("Failed gathering material stack for " + this.localizedName + "."); + Logger.MATERIALS("What Failed: Length:" + this.vMaterialInput.size() + " current:" + i); + } + try { + if (testNull != null) { + // Utils.LOG_MATERIALS("not null"); + temp[i] = this.vMaterialInput.get(i) + .getValidStack(); + } + } catch (final Throwable r) { + Logger.MATERIALS("Failed setting slot " + i + ", using " + this.localizedName); + } + } + return temp; + } + return new ItemStack[] {}; + } + + public final ArrayList<MaterialStack> getComposites() { + return this.vMaterialInput; + } + + public final int[] getMaterialCompositeStackSizes() { + if (!this.vMaterialInput.isEmpty()) { + final int[] temp = new int[this.vMaterialInput.size()]; + for (int i = 0; i < this.vMaterialInput.size(); i++) { + if (this.vMaterialInput.get(i) != null) { + temp[i] = this.vMaterialInput.get(i) + .getDustStack().stackSize; + } else { + temp[i] = 0; + } + } + return temp; + } + return new int[] {}; + } + + private short getComponentCount(final MaterialStack[] inputs) { + + if (inputs == null || inputs.length < 1) { + return 1; + } + int counterTemp = 0; + for (final MaterialStack m : inputs) { + if (m.getStackMaterial() != null) { + counterTemp++; + } + } + if (counterTemp != 0) { + return (short) counterTemp; + } else { + return 1; + } + } + + public final long[] getSmallestRatio(final ArrayList<MaterialStack> tempInput) { + if (tempInput != null) { + if (!tempInput.isEmpty()) { + Logger.MATERIALS("length: " + tempInput.size()); + Logger.MATERIALS("(inputs != null): " + (tempInput != null)); + // Utils.LOG_MATERIALS("length: "+inputs.length); + final long[] tempRatio = new long[tempInput.size()]; + for (int x = 0; x < tempInput.size(); x++) { + if (tempInput.get(x) != null) { + tempRatio[x] = tempInput.get(x) + .getPartsPerOneHundred(); + } + } + + final long[] smallestRatio = MathUtils.simplifyNumbersToSmallestForm(tempRatio); + + if (smallestRatio.length > 0) { + String tempRatioStringThing1 = ""; + for (long value : tempRatio) { + tempRatioStringThing1 = tempRatioStringThing1 + value + " : "; + } + Logger.MATERIALS("Default Ratio: " + tempRatioStringThing1); + + String tempRatioStringThing = ""; + int tempSmallestCraftingUseSize = 0; + for (long l : smallestRatio) { + tempRatioStringThing = tempRatioStringThing + l + " : "; + tempSmallestCraftingUseSize = (int) (tempSmallestCraftingUseSize + l); + } + // this.smallestStackSizeWhenProcessing = tempSmallestCraftingUseSize; + Logger.MATERIALS("Smallest Ratio: " + tempRatioStringThing); + return smallestRatio; + } + } + } + return new long[] {}; + } + + public final String getToolTip(final String chemSymbol, final long aMultiplier, final boolean aShowQuestionMarks) { + if (!aShowQuestionMarks && (this.vChemicalFormula.equals("?") || this.vChemicalFormula.equals("??"))) { + return ""; + } + Logger.MATERIALS("===============| Calculating Atomic Formula for " + this.localizedName + " |==============="); + if (!chemSymbol.equals("")) { + return chemSymbol; + } + final ArrayList<MaterialStack> tempInput = this.vMaterialInput; + if (tempInput != null) { + if (!tempInput.isEmpty()) { + String dummyFormula = ""; + final long[] dummyFormulaArray = this.getSmallestRatio(tempInput); + if (dummyFormulaArray != null) { + if (dummyFormulaArray.length >= 1) { + for (int e = 0; e < tempInput.size(); e++) { + MaterialStack g = tempInput.get(e); + if (g != null) { + if (g.getStackMaterial() != null) { + + String aChemSymbol = g.getStackMaterial().vChemicalSymbol; + String aChemFormula = g.getStackMaterial().vChemicalFormula; + + if (aChemSymbol == null) { + aChemSymbol = "??"; + } + if (aChemFormula == null) { + aChemFormula = "??"; + } + + if (!aChemSymbol.equals("??")) { + if (dummyFormulaArray[e] > 1) { + + if (aChemFormula.length() > 3 + || StringUtils.uppercaseCount(aChemFormula) > 1) { + dummyFormula = dummyFormula + "(" + + aChemFormula + + ")" + + dummyFormulaArray[e]; + } else { + dummyFormula = dummyFormula + aChemFormula + dummyFormulaArray[e]; + } + } else if (dummyFormulaArray[e] == 1) { + if (aChemFormula.length() > 3 + || StringUtils.uppercaseCount(aChemFormula) > 1) { + dummyFormula = dummyFormula + "(" + aChemFormula + ")"; + } else { + dummyFormula = dummyFormula + aChemFormula; + } + } else { + dummyFormula = dummyFormula + "??"; + } + } else { + dummyFormula = dummyFormula + "??"; + } + } else { + dummyFormula = dummyFormula + "??"; + } + } + } + return StringUtils.subscript(dummyFormula); + // return dummyFormula; + } + Logger.MATERIALS("dummyFormulaArray <= 0"); + } + Logger.MATERIALS("dummyFormulaArray == null"); + } + Logger.MATERIALS("tempInput.length <= 0"); + } + Logger.MATERIALS("tempInput == null"); + return "??"; + } + + public final boolean queueFluidGeneration() { + return isFluidQueued = true; + } + + public static final void generateQueuedFluids() { + for (Material m : mMaterialMap) { + if (m.isFluidQueued) {} + } + } + + // If we need a fluid, let's just queue it for later. + public boolean isFluidQueued = false; + + public final Fluid generateFluid() { + if (this.materialState == MaterialState.ORE) { + return null; + } + + Fluid aGTBaseFluid = null; + + // 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 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 (f1 != null) { + aGTBaseFluid = f1.getFluid(); + } else if (f2 != null) { + aGTBaseFluid = f2.getFluid(); + } else if (f3 != null) { + aGTBaseFluid = f3.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, 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); + Logger.MATERIALS("Generated a cell for " + this.getUnlocalizedName()); + } else { + 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(), + "Molten " + this.getLocalizedName(), + this.RGBA, + 4, + this.getMeltingPointK(), + aFullCell, + ItemUtils.getEmptyCell(), + 1000, + this.vGenerateCells); + } else if (this.materialState == MaterialState.LIQUID || this.materialState == MaterialState.PURE_LIQUID) { + return FluidUtils.addGTFluid( + this.getUnlocalizedName(), + this.getLocalizedName(), + this.RGBA, + 0, + this.getMeltingPointK(), + aFullCell, + ItemUtils.getEmptyCell(), + 1000, + this.vGenerateCells); + } else if (this.materialState == MaterialState.GAS || this.materialState == MaterialState.PURE_GAS) { + return FluidUtils + .generateGas(unlocalizedName, this.getLocalizedName(), getMeltingPointK(), getRGBA(), vGenerateCells); + /* + * return FluidUtils.addGTFluid( this.getUnlocalizedName(), this.getLocalizedName()+" Gas", this.RGBA, 2, + * this.getMeltingPointK(), aFullCell, ItemUtils.getEmptyCell(), 1000, this.vGenerateCells); + */ + } else { // Plasma + return this.generatePlasma(); + } + } + + public final Fluid generatePlasma() { + if (this.materialState == MaterialState.ORE) { + return null; + } + final Materials isValid = tryFindGregtechMaterialEquivalent(); + + if (!this.vGenerateCells) { + return null; + } + if (isValid != null) { + for (Materials m : invalidMaterials.values()) { + if (isValid == m) { + return null; + } + } + if (isValid.mPlasma != null) { + Logger.MATERIALS("Using a pre-defined Plasma from GT."); + return isValid.mPlasma; + } + } + Logger.MATERIALS("Generating our own Plasma."); + return FluidUtils.addGTPlasma(this); + } + + public Fluid getFluid() { + return mFluid; + } + + public Fluid getPlasma() { + return mPlasma; + } + + public final FluidStack getFluidStack(final int fluidAmount) { + if (this.mFluid == null) { + return null; + } + final FluidStack moltenFluid = new FluidStack(this.mFluid, fluidAmount); + return moltenFluid; + } + + public final boolean setFluid(Fluid aFluid) { + if (this.mFluid == null) { + this.mFluid = aFluid; + return true; + } + return false; + } + + public final int calculateMeltingPoint() { + try { + AutoMap<Integer> aDataSet = new AutoMap<>(); + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put( + m.getStackMaterial() + .getMeltingPointC()); + } + long aAverage = MathUtils.getIntAverage(aDataSet); + return MathUtils.safeInt(aAverage); + } catch (Throwable r) { + r.printStackTrace(); + return 500; + } + } + + public final int calculateBoilingPoint() { + try { + + AutoMap<Integer> aDataSet = new AutoMap<>(); + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put( + m.getStackMaterial() + .getBoilingPointC()); + } + long aAverage = MathUtils.getIntAverage(aDataSet); + return MathUtils.safeInt(aAverage); + } catch (Throwable r) { + r.printStackTrace(); + return 2500; + } + } + + public final long calculateProtons() { + try { + + AutoMap<Long> aDataSet = new AutoMap<>(); + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put( + m.getStackMaterial() + .getProtons()); + } + long aAverage = MathUtils.getLongAverage(aDataSet); + return MathUtils.safeInt(aAverage); + } catch (Throwable r) { + r.printStackTrace(); + return 50; + } + } + + public final long calculateNeutrons() { + try { + + AutoMap<Long> aDataSet = new AutoMap<>(); + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put( + m.getStackMaterial() + .getNeutrons()); + } + long aAverage = MathUtils.getLongAverage(aDataSet); + return MathUtils.safeInt(aAverage); + } catch (Throwable r) { + r.printStackTrace(); + return 75; + } + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (!Material.class.isInstance(obj)) { + return false; + } + Material aObj = (Material) obj; + if (aObj.unlocalizedName.equals(this.unlocalizedName)) { + if (aObj.localizedName.equals(this.localizedName)) { + return true; + } + } + return false; + } + + public boolean registerComponentForMaterial(FluidStack aStack) { + return registerComponentForMaterial(this, aStack); + } + + private static boolean registerComponentForMaterial(Material componentMaterial, FluidStack aStack) { + if (componentMaterial != null && aStack != null && componentMaterial.mFluid == null) { + componentMaterial.mFluid = aStack.getFluid(); + return true; + } + return false; + } + + public boolean registerComponentForMaterial(ComponentTypes aPrefix, ItemStack aStack) { + return registerComponentForMaterial(this, aPrefix.getGtOrePrefix(), aStack); + } + + public boolean registerComponentForMaterial(OrePrefixes aPrefix, ItemStack aStack) { + return registerComponentForMaterial(this, aPrefix, aStack); + } + + public static boolean registerComponentForMaterial(Material componentMaterial, ComponentTypes aPrefix, + ItemStack aStack) { + return registerComponentForMaterial(componentMaterial, aPrefix.getGtOrePrefix(), aStack); + } + + public static boolean registerComponentForMaterial(Material componentMaterial, OrePrefixes aPrefix, + ItemStack aStack) { + if (componentMaterial == null) { + return false; + } + // Register Component + Map<String, ItemStack> aMap = Material.mComponentMap.get(componentMaterial.getUnlocalizedName()); + if (aMap == null) { + aMap = new HashMap<>(); + } + String aKey = aPrefix.name(); + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, aStack); + Logger.MATERIALS( + "Registering a material component. Item: [" + componentMaterial.getUnlocalizedName() + + "] Map: [" + + aKey + + "]"); + Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap); + return true; + } else { + // Bad + Logger.MATERIALS("Tried to double register a material component. "); + return false; + } + } + + public Materials tryFindGregtechMaterialEquivalent() { + return tryFindGregtechMaterialEquivalent(this); + } + + public static Materials tryFindGregtechMaterialEquivalent(Material aMaterial) { + String aMaterialName = aMaterial.getLocalizedName(); + Materials aGregtechMaterial = Materials.get(aMaterialName); + if (aGregtechMaterial == null || MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { + aMaterialName = aMaterialName.replace(" ", "_"); + aGregtechMaterial = Materials.get(aMaterialName); + if (aGregtechMaterial == null || MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { + aMaterialName = aMaterialName.replace(" ", ""); + aGregtechMaterial = Materials.get(aMaterialName); + if (aGregtechMaterial == null || MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { + return null; + } else { + return aGregtechMaterial; + } + } else { + return aGregtechMaterial; + } + } else { + return aGregtechMaterial; + } + } + + public void setWerkstoffID(short werkstoffID) { + this.werkstoffID = werkstoffID; + } +} diff --git a/src/main/java/gtPlusPlus/core/material/MaterialGenerator.java b/src/main/java/gtPlusPlus/core/material/MaterialGenerator.java new file mode 100644 index 0000000000..df2abd0acb --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/MaterialGenerator.java @@ -0,0 +1,428 @@ +package gtPlusPlus.core.material; + +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; +import gtPlusPlus.core.block.base.BlockBaseModular; +import gtPlusPlus.core.block.base.BlockBaseOre; +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.item.base.BaseItemComponent.ComponentTypes; +import gtPlusPlus.core.item.base.bolts.BaseItemBolt; +import gtPlusPlus.core.item.base.dusts.BaseItemDust; +import gtPlusPlus.core.item.base.dusts.BaseItemDust.DustState; +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.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.ore.BaseItemRawOre; +import gtPlusPlus.core.item.base.plates.BaseItemPlate; +import gtPlusPlus.core.item.base.plates.BaseItemPlateDense; +import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; +import gtPlusPlus.core.item.base.rings.BaseItemRing; +import gtPlusPlus.core.item.base.rods.BaseItemRod; +import gtPlusPlus.core.item.base.rods.BaseItemRodLong; +import gtPlusPlus.core.item.base.rotors.BaseItemRotor; +import gtPlusPlus.core.item.base.screws.BaseItemScrew; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +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.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_Fluorite; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_MaterialProcessing; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_MetalRecipe; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Ore; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Plasma; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Plates; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_ShapedCrafting; + +public class MaterialGenerator { + + public static final AutoMap<Set<RunnableWithInfo<Material>>> mRecipeMapsToGenerate = new AutoMap<>(); + + @SuppressWarnings("unused") + private static volatile Item temp; + + @SuppressWarnings("unused") + private static volatile Block tempBlock; + + @Deprecated + public static boolean addFluidCannerRecipe(ItemStack aEmpty, ItemStack aFullContainer, FluidStack aFluidIn, + FluidStack rFluidOut) { + return addFluidCannerRecipe(aEmpty, aFullContainer, aFluidIn, rFluidOut, null, null); + } + + @Deprecated + public static boolean addFluidCannerRecipe(ItemStack aEmpty, ItemStack aFullContainer, FluidStack aFluidIn, + FluidStack rFluidOut, Integer aTime, Integer aEu) { + + 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) { + generate(matInfo, true); + } + + public static void generate(final Material matInfo, final boolean generateEverything) { + generate(matInfo, generateEverything, true); + } + + public static boolean generate(final Material matInfo, final boolean generateEverything, + final boolean generateBlastSmelterRecipes) { + try { + final String unlocalizedName = matInfo.getUnlocalizedName(); + final String materialName = matInfo.getLocalizedName(); + final short[] C = matInfo.getRGBA(); + final int Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); + final boolean hotIngot = matInfo.requiresBlastFurnace(); + int materialTier = matInfo.vTier; // TODO + + if ((materialTier > 10) || (materialTier <= 0)) { + materialTier = 2; + } + + int sRadiation = 0; + if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)) { + sRadiation = matInfo.vRadiationLevel; + } + + if (matInfo.getState() == MaterialState.SOLID) { + if (generateEverything == true) { + if (sRadiation >= 1) { + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + temp = new BaseItemIngot(matInfo); + + temp = new BaseItemDust(matInfo); + temp = new BaseItemNugget(matInfo); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemRod(matInfo); + temp = new BaseItemRodLong(matInfo); + } else { + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + tempBlock = new BlockBaseModular(matInfo, BlockTypes.FRAME); + temp = new BaseItemIngot(matInfo); + if (hotIngot) { + temp = new BaseItemIngotHot(matInfo); + } + temp = new BaseItemDust(matInfo); + temp = new BaseItemNugget(matInfo); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); + temp = new BaseItemBolt(matInfo); + temp = new BaseItemRod(matInfo); + temp = new BaseItemRodLong(matInfo); + temp = new BaseItemRing(matInfo); + temp = new BaseItemScrew(matInfo); + temp = new BaseItemRotor(matInfo); + temp = new BaseItemGear(matInfo); + temp = new BaseItemPlateDense(matInfo); + } + } else { + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + + temp = new BaseItemIngot(matInfo); + temp = new BaseItemDust(matInfo); + temp = new BaseItemNugget(matInfo); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); + } + } else if (matInfo.getState() == MaterialState.LIQUID) { + if (generateEverything == true) { + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + } + temp = new BaseItemIngot(matInfo); + temp = new BaseItemDust(matInfo); + temp = new BaseItemNugget(matInfo); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); + } else if (matInfo.getState() == MaterialState.GAS) { + temp = new BaseItemDust(matInfo); + FluidUtils.generateGas(unlocalizedName, materialName, matInfo.getMeltingPointK(), C, true); + } else if (matInfo.getState() == MaterialState.PURE_GAS) { + FluidUtils.generateGas(unlocalizedName, materialName, matInfo.getMeltingPointK(), C, true); + return true; + } else if (matInfo.getState() == MaterialState.PURE_LIQUID) { + FluidUtils.generateFluidNoPrefix(unlocalizedName, materialName, matInfo.getMeltingPointK(), C); + return true; + } else if (matInfo.getState() == MaterialState.ORE) { + + } + + // Add A jillion Recipes - old code + new RecipeGen_AlloySmelter(matInfo); + new RecipeGen_Assembler(matInfo); + if (generateBlastSmelterRecipes) { + new RecipeGen_BlastSmelter(matInfo); + } + new RecipeGen_MetalRecipe(matInfo); + new RecipeGen_Extruder(matInfo); + new RecipeGen_Fluids(matInfo); + new RecipeGen_Plates(matInfo); + new RecipeGen_ShapedCrafting(matInfo); + new RecipeGen_MaterialProcessing(matInfo); + + new RecipeGen_DustGeneration(matInfo); + new RecipeGen_Recycling(matInfo); + new RecipeGen_Plasma(matInfo); + + return true; + + } catch (final Throwable t) { + + Logger.MATERIALS("" + matInfo.getLocalizedName() + " failed to generate."); + return false; + } + } + + public static void generateDusts(final Material matInfo) { + final String unlocalizedName = matInfo.getUnlocalizedName(); + final String materialName = matInfo.getLocalizedName(); + final short[] C = matInfo.getRGBA(); + final int Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); + int materialTier = matInfo.vTier; // TODO + + if ((materialTier > 10) || (materialTier <= 0)) { + materialTier = 2; + } + + int sRadiation = 0; + if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)) { + sRadiation = matInfo.vRadiationLevel; + } + + if (matInfo.getState() == MaterialState.SOLID) { + temp = new BaseItemDust(matInfo); + } + + // Add A jillion Recipes - old code + try { + RecipeGen_DustGeneration.addMixerRecipe_Standalone(matInfo); + new RecipeGen_Fluids(matInfo); + new RecipeGen_MaterialProcessing(matInfo); + } catch (Throwable t) { + Logger.MATERIALS("Failed to generate some recipes for " + materialName); + Logger.ERROR("Failed to generate some recipes for " + materialName); + t.printStackTrace(); + } + // RecipeGen_Recycling.generateRecipes(matInfo); + } + + public static void generateNuclearMaterial(final Material matInfo) { + generateNuclearMaterial(matInfo, true); + } + + public static void generateNuclearDusts(final Material matInfo) { + generateNuclearDusts(matInfo, true); + } + + public static void generateNuclearDusts(final Material matInfo, boolean generateDehydratorRecipe) { + generateNuclearMaterial(matInfo, false, true, false, false, true); + if (generateDehydratorRecipe && matInfo.getFluid() != null && matInfo.getDust(0) != null) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedCircuit(20) }, + matInfo.getFluidStack(144), + null, + new ItemStack[] { matInfo.getDust(1), }, + new int[] { 10000 }, + 10 * (matInfo.vVoltageMultiplier / 5), // Time in ticks + matInfo.vVoltageMultiplier); // EU + } else { + Logger.INFO( + "Nuclear Dehydrator: Did not generate recipe for " + matInfo.getLocalizedName() + + " | Null Fluid? " + + (matInfo.getFluid() == null) + + " | Null Dust? " + + (matInfo.getDust(0) == null)); + } + } + + public static void generateNuclearMaterial(final Material matInfo, final boolean generatePlates) { + generateNuclearMaterial(matInfo, true, true, true, generatePlates, true); + } + + public static void generateNuclearMaterial(final Material matInfo, final boolean generateBlock, + final boolean generateDusts, final boolean generateIngot, final boolean generatePlates, + final boolean disableOptionalRecipes) { + try { + + if (generateBlock) { + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + } + if (generateDusts) { + temp = new BaseItemDust(matInfo); + } + if (generateIngot) { + temp = new BaseItemIngot(matInfo); + temp = new BaseItemNugget(matInfo); + } + + if (generatePlates) { + temp = new BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); + new RecipeGen_Plates(matInfo); + new RecipeGen_Extruder(matInfo); + new RecipeGen_Assembler(matInfo); + } + + if (!disableOptionalRecipes) { + new RecipeGen_ShapedCrafting(matInfo); + new RecipeGen_Fluids(matInfo); + new RecipeGen_MaterialProcessing(matInfo); + new RecipeGen_Recycling(matInfo); + } + + new RecipeGen_MetalRecipe(matInfo); + new RecipeGen_DustGeneration(matInfo, disableOptionalRecipes); + new RecipeGen_Plasma(matInfo); + + } catch (final Throwable t) { + Logger.MATERIALS("" + matInfo.getLocalizedName() + " failed to generate."); + } + } + + public static void generateOreMaterial(final Material matInfo) { + generateOreMaterial(matInfo, true, true, true, matInfo.getRGBA()); + } + + @SuppressWarnings("unused") + public static void generateOreMaterial(final Material matInfo, boolean generateOre, boolean generateDust, + boolean generateSmallTinyDusts, short[] customRGB) { + try { + + if (matInfo == null) { + Logger.DEBUG_MATERIALS("Invalid Material while constructing null material."); + return; + } + + final String unlocalizedName = matInfo.getUnlocalizedName(); + final String materialName = matInfo.getLocalizedName(); + final short[] C = customRGB; + final Integer Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); + + if (Colour == null) { + Logger.DEBUG_MATERIALS("Invalid Material while constructing " + materialName + "."); + return; + } + + int sRadiation = 0; + if (matInfo.vRadiationLevel > 0) { + sRadiation = matInfo.vRadiationLevel; + } + + if (generateOre) { + tempBlock = new BlockBaseOre(matInfo, BlockTypes.ORE); + } + + DustState aState = new DustState(generateDust, generateSmallTinyDusts, generateSmallTinyDusts); + + if (!aState.generatesDust()) { + if (aState.generatesSmallDust()) { + temp = new BaseItemComponent(matInfo, ComponentTypes.DUSTSMALL); + } + if (aState.generatesTinyDust()) { + temp = new BaseItemComponent(matInfo, ComponentTypes.DUSTTINY); + } + } else { + temp = new BaseItemDust(aState, matInfo); + } + + temp = new BaseItemCrushedOre(matInfo); + temp = new BaseItemCentrifugedCrushedOre(matInfo); + temp = new BaseItemPurifiedCrushedOre(matInfo); + temp = new BaseItemImpureDust(matInfo); + temp = new BaseItemPurifiedDust(matInfo); + temp = new BaseItemRawOre(matInfo); + + Logger.MATERIALS( + "Generated all ore components for " + matInfo.getLocalizedName() + + ", now generating processing recipes."); + + if (matInfo == FLUORIDES.FLUORITE) { + new RecipeGen_Fluorite(matInfo); + } else { + new RecipeGen_Ore(matInfo); + } + + } catch (final Throwable t) { + Logger.MATERIALS( + "[Error] " + (matInfo != null ? matInfo.getLocalizedName() : "Null Material") + " failed to generate."); + t.printStackTrace(); + } + } + + public static boolean generateOreMaterialWithAllExcessComponents(final Material matInfo) { + try { + if (matInfo == null) { + Logger.DEBUG_MATERIALS("Invalid Material while constructing null material."); + return false; + } + final short[] C = matInfo.getRGBA(); + final Integer Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); + + tempBlock = new BlockBaseOre(matInfo, BlockTypes.ORE); + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + temp = new BaseItemIngot(matInfo); + temp = new BaseItemDust(matInfo); + temp = new BaseItemNugget(matInfo); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); + + temp = new BaseItemCrushedOre(matInfo); + temp = new BaseItemCentrifugedCrushedOre(matInfo); + temp = new BaseItemPurifiedCrushedOre(matInfo); + temp = new BaseItemImpureDust(matInfo); + temp = new BaseItemPurifiedDust(matInfo); + temp = new BaseItemRawOre(matInfo); + + Logger.MATERIALS( + "Generated all ore & base components for " + matInfo.getLocalizedName() + + ", now generating processing recipes."); + + new RecipeGen_Ore(matInfo, true); + new RecipeGen_AlloySmelter(matInfo); + new RecipeGen_Assembler(matInfo); + new RecipeGen_BlastSmelter(matInfo); + new RecipeGen_MetalRecipe(matInfo); + new RecipeGen_Extruder(matInfo); + new RecipeGen_Fluids(matInfo); + new RecipeGen_Plates(matInfo); + new RecipeGen_ShapedCrafting(matInfo); + new RecipeGen_MaterialProcessing(matInfo); + new RecipeGen_DustGeneration(matInfo); + new RecipeGen_Recycling(matInfo); + new RecipeGen_Plasma(matInfo); + return true; + } catch (final Throwable t) { + Logger.MATERIALS("" + matInfo.getLocalizedName() + " failed to generate."); + t.printStackTrace(); + return false; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/material/MaterialStack.java b/src/main/java/gtPlusPlus/core/material/MaterialStack.java new file mode 100644 index 0000000000..37070a35ec --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/MaterialStack.java @@ -0,0 +1,116 @@ +package gtPlusPlus.core.material; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.OrePrefixes; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.bartworks.BW_Utils; + +public class MaterialStack { + + private final transient int[] vAmount; + private final Material stackMaterial; + private final double vPercentageToUse; + + public MaterialStack(final Material inputs, final double partOutOf100) { + this.stackMaterial = inputs; + // Logger.INFO("Tried getting MaterialStack for "+inputs.getLocalizedName()); + this.vPercentageToUse = partOutOf100; + this.vAmount = this.math(partOutOf100); + } + + private int[] math(final double val) { + double i; + // Cast to a BigDecimal to round it. + final BigDecimal bd = new BigDecimal(val).setScale(2, RoundingMode.HALF_EVEN); + i = bd.doubleValue(); + // Split the string into xx.xx + final String[] arr = String.valueOf(i) + .split("\\."); + final int[] intArr = new int[2]; + intArr[0] = Integer.parseInt(arr[0]); + intArr[1] = Integer.parseInt(arr[1]); + return intArr; + } + + public ItemStack getValidStack() { + if (this.stackMaterial.getDust(1) == null) { + // if (this.stackMaterial.getCell(1) == null){ + return null; + // } + // return this.stackMaterial.getCell(this.vAmount[0]); + } + return this.stackMaterial.getDust(this.vAmount[0]); + } + + public ItemStack getDustStack() { + return this.stackMaterial.getDust(this.vAmount[0]); + } + + public ItemStack getDustStack(final int amount) { + return this.stackMaterial.getDust(amount); + } + + public ItemStack getUnificatedDustStack(final int amount) { + if (this.stackMaterial.werkstoffID != 0) { + ItemStack stack = BW_Utils + .getCorrespondingItemStack(OrePrefixes.dust, this.stackMaterial.werkstoffID, amount); + if (stack != null) { + return stack; + } + } + return getDustStack(amount); + } + + public Material getStackMaterial() { + if (this.stackMaterial == null) { + Logger.MATERIALS("Tried getStackMaterial, got an invalid material."); + Logger.MATERIALS(ReflectionUtils.getMethodName(0)); + Logger.MATERIALS(ReflectionUtils.getMethodName(1)); + Logger.MATERIALS(ReflectionUtils.getMethodName(2)); + Logger.MATERIALS(ReflectionUtils.getMethodName(3)); + return null; + } + return this.stackMaterial; + } + + public double getvPercentageToUse() { + return this.vPercentageToUse; + } + + public long[] getSmallestStackSizes() { + return this.stackMaterial.getSmallestRatio(this.stackMaterial.getComposites()); + } + + public int getPartsPerOneHundred() { + if (this.vAmount != null) { + if ((this.vAmount[0] >= 1) && (this.vAmount[0] <= 100)) { + return this.vAmount[0]; + } + } + return 100; + } + + public ItemStack getLeftOverStacksFromDecimalValue() { + final int temp = this.vAmount[1]; + int getCount; + if ((temp >= 25) && (temp <= 99)) { + getCount = temp / 25; + return this.stackMaterial.getSmallDust(getCount); + } else if ((temp >= 11) && (temp <= 24)) { + getCount = temp / 11; + return this.stackMaterial.getTinyDust(getCount); + } else { + return null; + } + } + + public ItemStack[] getValidItemStacks() { + return ItemUtils.validItemsForOreDict(this.stackMaterial.getUnlocalizedName()); + } +} diff --git a/src/main/java/gtPlusPlus/core/material/NONMATERIAL.java b/src/main/java/gtPlusPlus/core/material/NONMATERIAL.java new file mode 100644 index 0000000000..5e084b84bf --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/NONMATERIAL.java @@ -0,0 +1,42 @@ +package gtPlusPlus.core.material; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.TextureSet; +import gtPlusPlus.core.util.minecraft.MaterialUtils; + +public class NONMATERIAL { + + // Soul Sand + public static final Material SOULSAND = MaterialUtils.generateMaterialFromGtENUM(Materials.SoulSand); + + // Redstone + public static final Material REDSTONE = MaterialUtils.generateMaterialFromGtENUM(Materials.Redstone); + + // Glowstone Dust + public static final Material GLOWSTONE = MaterialUtils.generateMaterialFromGtENUM(Materials.Glowstone); + + // Enderpearl + public static final Material ENDERPEARL = MaterialUtils.generateMaterialFromGtENUM(Materials.EnderPearl); + + // Raw Flesh + public static final Material MEAT = MaterialUtils.generateMaterialFromGtENUM(Materials.MeatRaw); + + // Clay + public static final Material CLAY = MaterialUtils.generateMaterialFromGtENUM(Materials.Clay); + + // Wrought Iron + public static final Material WROUGHT_IRON = MaterialUtils.generateMaterialFromGtENUM(Materials.WroughtIron); + + // PTFE + public static final Material PTFE = MaterialUtils + .generateMaterialFromGtENUM(MaterialUtils.getMaterial("Polytetrafluoroethylene", "Plastic")); + + // Plastic + public static final Material PLASTIC = MaterialUtils + .generateMaterialFromGtENUM(MaterialUtils.getMaterial("Plastic", "Rubber")); + + static { + MEAT.setTextureSet(TextureSet.SET_ROUGH); + CLAY.setTextureSet(TextureSet.SET_ROUGH); + } +} diff --git a/src/main/java/gtPlusPlus/core/material/ORES.java b/src/main/java/gtPlusPlus/core/material/ORES.java new file mode 100644 index 0000000000..5079639e38 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/ORES.java @@ -0,0 +1,701 @@ +package gtPlusPlus.core.material; + +import gregtech.api.enums.TextureSet; +import gtPlusPlus.core.client.CustomTextureSet.TextureSets; +import gtPlusPlus.core.material.state.MaterialState; + +public final class ORES { + + public static final Material AGARDITE_CD = new Material( + "Agardite (Cd)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 170, 188, 33, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (CdCa)Cu7(AsO2)4(O2H)5·3H2O + new MaterialStack(ELEMENT.getInstance().CADMIUM, 1), new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().COPPER, 7), new MaterialStack(ELEMENT.getInstance().ARSENIC, 4), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 21), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 11) }); + + public static final Material AGARDITE_LA = new Material( + "Agardite (La)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] { 206, 232, 9, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (LaCa)Cu5(AsO6)2(OH)4·3H2O + new MaterialStack(ELEMENT.getInstance().LANTHANUM, 1), new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().COPPER, 5), new MaterialStack(ELEMENT.getInstance().ARSENIC, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 19), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 10) }); + + public static final Material AGARDITE_ND = new Material( + "Agardite (Nd)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 225, 244, 78, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (NdCa)Cu6(As3O3)2(O2H)6·3H2O + new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 1), new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().COPPER, 6), new MaterialStack(ELEMENT.getInstance().ARSENIC, 6), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 21), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 12) }); + + public static final Material AGARDITE_Y = new Material( + "Agardite (Y)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 210, 232, 44, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (YCa)Cu5(As2O4)3(OH)6·3H2O + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().COPPER, 5), new MaterialStack(ELEMENT.getInstance().ARSENIC, 6), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 21), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 12) }); + + // Alburnite + // Ag8GeTe2S4 + public static final Material ALBURNITE = new Material( + "Alburnite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 16, 5, 105, 0 }, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().GOLD, 8), new MaterialStack(ELEMENT.getInstance().GERMANIUM, 1), + new MaterialStack(ELEMENT.getInstance().TELLURIUM, 2), + new MaterialStack(ELEMENT.getInstance().SULFUR, 4) }); + + public static final Material CERITE = new Material( + "Cerite", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] { 68, 13, 0, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (Ce,La,Ca)9(Mg,Fe+3)(SiO4)6(SiO3OH)(OH)3 + new MaterialStack(ELEMENT.getInstance().CERIUM, 9), new MaterialStack(ELEMENT.getInstance().LANTHANUM, 9), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 9), new MaterialStack(ELEMENT.getInstance().MAGNESIUM, 3), + new MaterialStack(ELEMENT.getInstance().IRON, 3), new MaterialStack(ELEMENT.getInstance().SILICON, 7), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 20), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 4) }); + + // Comancheite + // Hg55N24(NH2,OH)4(Cl,Br)34 + public static final Material COMANCHEITE = new Material( + "Comancheite", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] { 65, 205, 105, 0 }, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().MERCURY, 54 / 4), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 28 / 4), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 12 / 4), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 8 / 4), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 34 / 4), + new MaterialStack(ELEMENT.getInstance().BROMINE, 34 / 4) }); + + public static final Material CROCROITE = new Material( + "Crocoite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_GEM_VERTICAL, // Texture Set + new short[] { 255, 143, 84, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { 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 CRYOLITE = new Material( + "Cryolite (F)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_SHINY, // Texture Set + new short[] { 205, 205, 255, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().SODIUM, 3), new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) }); + + // Demicheleite-(Br) + // BiSBr + public static final Material DEMICHELEITE_BR = new Material( + "Demicheleite (Br)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_SHINY, // Texture Set + new short[] { 165, 75, 75, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().BISMUTH, 13), new MaterialStack(ELEMENT.getInstance().SULFUR, 11), + new MaterialStack(ELEMENT.getInstance().BROMINE, 1) }); + + public static final Material FLORENCITE = new Material( + "Florencite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 249, 249, 124, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // SmAl3(PO4)2(OH)6 + new MaterialStack(ELEMENT.getInstance().SAMARIUM, 1), new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 3), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 1), new MaterialStack(ELEMENT.getInstance().OXYGEN, 10), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 6) }); + + public static final Material FLUORCAPHITE = new Material( + "Fluorcaphite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] { 255, 255, 30, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (Ca,Sr,Ce,Na)5(PO4)3F + new MaterialStack(ELEMENT.getInstance().CALCIUM, 5), new MaterialStack(MISC_MATERIALS.STRONTIUM_OXIDE, 5), + new MaterialStack(ELEMENT.getInstance().CERIUM, 5), new MaterialStack(ELEMENT.getInstance().SODIUM, 5), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 3), new MaterialStack(ELEMENT.getInstance().OXYGEN, 12), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 6), }); + + // Gadolinite_Ce + public static final Material GADOLINITE_CE = new Material( + "Gadolinite (Ce)", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] { 15, 159, 59, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CERIUM, 4), + new MaterialStack(ELEMENT.getInstance().ERBIUM, 2), new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), + new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), + new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 1), + new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 2), new MaterialStack(ELEMENT.getInstance().SILICON, 7), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 14), }); + + // Gadolinite_Y + public static final Material GADOLINITE_Y = new Material( + "Gadolinite (Y)", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] { 35, 189, 99, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CERIUM, 2), + new MaterialStack(ELEMENT.getInstance().ERBIUM, 2), new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), + new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), new MaterialStack(ELEMENT.getInstance().YTTRIUM, 4), + new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 2), + new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 3), new MaterialStack(ELEMENT.getInstance().SILICON, 4), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 9), }); + + public static final Material GEIKIELITE = new Material( + "Geikielite", // Material Name + MaterialState.ORE, // State + TextureSets.GEM_A.get(), // Texture Set + new short[] { 187, 193, 204, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().MAGNESIUM, 1), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 1), new MaterialStack(ELEMENT.getInstance().OXYGEN, 3) }); + + 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, 1), + new MaterialStack(ELEMENT.getInstance().SULFUR, 1), }); + + public static final Material HIBONITE = new Material( + "Hibonite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 58, 31, 0, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // ((Ca,Ce)(Al,Ti,Mg)12O19) + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), new MaterialStack(ELEMENT.getInstance().CERIUM, 1), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 12), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 12), + new MaterialStack(ELEMENT.getInstance().MAGNESIUM, 12), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 19), }); + + // Honeaite + // Au3TlTe2 + public static final Material HONEAITE = new Material( + "Honeaite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] { 165, 165, 5, 0 }, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().GOLD, 3), new MaterialStack(ELEMENT.getInstance().THALLIUM, 1), + new MaterialStack(ELEMENT.getInstance().TELLURIUM, 2) }); + + // Irarsite + // (Ir,Ru,Rh,Pt)AsS + public static final Material IRARSITE = new Material( + "Irarsite", // Material Name + MaterialState.ORE, // State + TextureSets.ENRICHED.get(), // Texture Set + new short[] { 125, 105, 105, 0 }, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().IRIDIUM, 1), new MaterialStack(ELEMENT.getInstance().RUTHENIUM, 1), + new MaterialStack(ELEMENT.getInstance().RHODIUM, 1), new MaterialStack(ELEMENT.getInstance().PLATINUM, 1), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 1), new MaterialStack(ELEMENT.getInstance().SULFUR, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1) }); + + // Kashinite + // (Ir,Rh)2S3 + public static final Material KASHINITE = new Material( + "Kashinite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_SHINY, // Texture Set + new short[] { 75, 105, 75, 0 }, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().IRIDIUM, 2), new MaterialStack(ELEMENT.getInstance().RHODIUM, 2), + new MaterialStack(ELEMENT.getInstance().SULFUR, 3) }); + + // Tl(Cl,Br) + public static final Material LAFOSSAITE = new Material( + "Lafossaite", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] { 165, 105, 205, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1), new MaterialStack(ELEMENT.getInstance().BROMINE, 1), + new MaterialStack(ELEMENT.getInstance().THALLIUM, 1) }); + + public static final Material LANTHANITE_CE = new Material( + "Lanthanite (Ce)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 186, 113, 179, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (Ce)2(CO3)3·8(H2O) + new MaterialStack(ELEMENT.getInstance().CERIUM, 2), new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 3), new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), }); + + public static final Material LANTHANITE_LA = new Material( + "Lanthanite (La)", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] { 219, 160, 214, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (La)2(CO3)3·8(H2O) + new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 3), new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), }); + + public static final Material LANTHANITE_ND = new Material( + "Lanthanite (Nd)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 153, 76, 145, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (Nd)2(CO3)3·8(H2O) + new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 3), new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), }); + + // Iodine Source + public static final Material LAUTARITE = new Material( + "Lautarite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] { 165, 105, 205, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), new MaterialStack(ELEMENT.getInstance().IODINE, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 6) }); + + public static final Material LEPERSONNITE = new Material( + "Lepersonnite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_EMERALD, // Texture Set + new short[] { 175, 175, 20, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 3), + new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 2), + new MaterialStack(ELEMENT.getInstance().DYSPROSIUM, 2), + new MaterialStack(ELEMENT.getInstance().URANIUM235, 2), new MaterialStack(ELEMENT.getInstance().OXYGEN, 29), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 24) }); + + // Miessiite + // Pd11Te2Se2 + public static final Material MIESSIITE = new Material( + "Miessiite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] { 75, 75, 75, 0 }, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().PALLADIUM, 11), + new MaterialStack(ELEMENT.getInstance().TELLURIUM, 2), + new MaterialStack(ELEMENT.getInstance().SELENIUM, 2) }); + + public static final Material NICHROMITE = new Material( + "Nichromite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 22, 19, 19, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().NICKEL, 1), + new MaterialStack(ELEMENT.getInstance().COBALT, 1), new MaterialStack(ELEMENT.getInstance().IRON, 3), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 2), new MaterialStack(ELEMENT.getInstance().CHROMIUM, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 8) }); + + // Perroudite + // Hg5Ag4S5(I,Br)2Cl2 + public static final Material PERROUDITE = new Material( + "Perroudite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 77, 165, 174, 0 }, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().SULFUR, 5), + new MaterialStack(ELEMENT.getInstance().SILVER, 4), new MaterialStack(ELEMENT.getInstance().IODINE, 2), + new MaterialStack(ELEMENT.getInstance().MERCURY, 5), new MaterialStack(ELEMENT.getInstance().BROMINE, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 2) }); + + public static final Material POLYCRASE = new Material( + "Polycrase", // Material Name + MaterialState.ORE, // State + TextureSet.SET_ROUGH, // Texture Set + new short[] { 51, 0, 11, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), new MaterialStack(ELEMENT.getInstance().CERIUM, 1), + new MaterialStack(ELEMENT.getInstance().URANIUM235, 1), new MaterialStack(ELEMENT.getInstance().THORIUM, 1), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 2), new MaterialStack(ELEMENT.getInstance().OXYGEN, 6) }); + + // Radiobarite + // Radium, Barium, Barite? + public static final Material RADIOBARITE = new Material( + "Barite (Rd)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FLINT, // Texture Set + new short[] { 205, 205, 205, 0 }, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().BARIUM, 32), new MaterialStack(ELEMENT.getInstance().RADIUM, 1), + new MaterialStack(ELEMENT.getInstance().SULFUR, 16), new MaterialStack(ELEMENT.getInstance().OXYGEN, 15) }); + + // Samarskite_Y + public static final Material SAMARSKITE_Y = new Material( + "Samarskite (Y)", // Material Name + MaterialState.ORE, // State + TextureSets.ENRICHED.get(), // Texture Set + new short[] { 65, 163, 164, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), // Y not YT/YB + new MaterialStack(ELEMENT.getInstance().IRON, 10), new MaterialStack(ELEMENT.getInstance().URANIUM235, 2), + new MaterialStack(ELEMENT.getInstance().THORIUM, 3), new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 3) }); + + // Samarskite_YB + public static final Material SAMARSKITE_YB = new Material( + "Samarskite (Yb)", // Material Name + MaterialState.ORE, // State + TextureSets.ENRICHED.get(), // Texture Set + new short[] { 95, 193, 194, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), // Y not YT/YB + new MaterialStack(ELEMENT.getInstance().IRON, 9), new MaterialStack(ELEMENT.getInstance().URANIUM235, 3), + new MaterialStack(ELEMENT.getInstance().THORIUM, 2), new MaterialStack(ELEMENT.getInstance().NIOBIUM, 3), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 2) }); + + public static final Material TITANITE = new Material( + "Titanite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 184, 198, 105, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), new MaterialStack(ELEMENT.getInstance().SILICON, 2), + new MaterialStack(ELEMENT.getInstance().THORIUM, 1), new MaterialStack(ELEMENT.getInstance().OXYGEN, 10) }); + + public static final Material XENOTIME = new Material( + "Xenotime", // Material Name + MaterialState.ORE, // State + TextureSet.SET_OPAL, // Texture Set + new short[] { 235, 89, 199, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), + new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), new MaterialStack(ELEMENT.getInstance().ERBIUM, 2), + new MaterialStack(ELEMENT.getInstance().EUROPIUM, 1), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 8) }); + + public static final Material YTTRIAITE = new Material( // TODO + "Yttriaite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] { 255, 143, 84, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), // Y not YT/YB + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), new MaterialStack(ELEMENT.getInstance().IRON, 4), + new MaterialStack(ELEMENT.getInstance().TIN, 1), new MaterialStack(ELEMENT.getInstance().NITROGEN, 2) }); + + public static final Material YTTRIALITE = new Material( + "Yttrialite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_RUBY, // Texture Set + new short[] { 35, 189, 99, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), + new MaterialStack(ELEMENT.getInstance().THORIUM, 2), new MaterialStack(ELEMENT.getInstance().SILICON, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 7), }); + + public static final Material YTTROCERITE = new Material( + "Yttrocerite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_DIAMOND, // Texture Set + new short[] { 35, 19, 199, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CERIUM, 1), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), new MaterialStack(ELEMENT.getInstance().FLUORINE, 5), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), }); + + public static final Material ZIMBABWEITE = new Material( + "Zimbabweite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] { 193, 187, 131, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), + new MaterialStack(ELEMENT.getInstance().POTASSIUM, 2), new MaterialStack(ELEMENT.getInstance().LEAD, 1), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 4), new MaterialStack(ELEMENT.getInstance().NIOBIUM, 4), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 4), new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 18) }); + + public static final Material ZIRCON = new Material( + "Zircon", // Material Name + MaterialState.ORE, // State + TextureSets.GEM_A.get(), // Texture Set + new short[] { 195, 19, 19, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), + new MaterialStack(ELEMENT.getInstance().SILICON, 1), new MaterialStack(ELEMENT.getInstance().OXYGEN, 4), }); + + public static final Material ZIRCONILITE = new Material( + "Zirconolite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] { 45, 26, 0, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), + new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 2), new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), + new MaterialStack(ELEMENT.getInstance().CERIUM, 1), new MaterialStack(ELEMENT.getInstance().OXYGEN, 14) }); + + public static final Material ZIRCOPHYLLITE = new Material( + "Zircophyllite", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] { 30, 0, 6, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().POTASSIUM, 3), + new MaterialStack(ELEMENT.getInstance().SODIUM, 3), new MaterialStack(ELEMENT.getInstance().MANGANESE, 7), + new MaterialStack(ELEMENT.getInstance().IRON, 7), new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 2), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().SILICON, 8), new MaterialStack(ELEMENT.getInstance().OXYGEN, 13), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 7), }); + + public static final Material ZIRKELITE = new Material( + "Zirkelite", // Material Name + MaterialState.ORE, // State + TextureSets.GEM_A.get(), // Texture Set + new short[] { 229, 208, 48, 0 }, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (Ca,Th,Ce)Zr(Ti,Nb)2O7 + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), new MaterialStack(ELEMENT.getInstance().THORIUM, 1), + new MaterialStack(ELEMENT.getInstance().CERIUM, 1), new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 7) }); + + public static final Material DEEP_EARTH_REACTOR_FUEL_DEPOSIT = new Material( + "Radioactive Mineral Mix", // Material Name + MaterialState.ORE, // State + TextureSets.NUCLEAR.get(), // Texture Set + null, // Material Colour + -1, + -1, + -1, + -1, + 4, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().RADON, 2), new MaterialStack(ELEMENT.getInstance().RADIUM, 1), + new MaterialStack(ELEMENT.getInstance().URANIUM235, 1), + new MaterialStack(ELEMENT.getInstance().URANIUM238, 10), + new MaterialStack(ELEMENT.getInstance().THORIUM, 25), + new MaterialStack(ELEMENT.getInstance().THORIUM232, 4), new MaterialStack(FLUORCAPHITE, 6), + new MaterialStack(SAMARSKITE_Y, 8), new MaterialStack(TITANITE, 4) }); +} diff --git a/src/main/java/gtPlusPlus/core/material/Particle.java b/src/main/java/gtPlusPlus/core/material/Particle.java new file mode 100644 index 0000000000..b5cd30184e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/Particle.java @@ -0,0 +1,154 @@ +package gtPlusPlus.core.material; + +import net.minecraft.item.ItemStack; + +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.chemistry.IonParticles; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class Particle { + + public static final Particle GRAVITON; + + public static final Particle UP; + public static final Particle DOWN; + public static final Particle CHARM; + public static final Particle STRANGE; + public static final Particle TOP; + public static final Particle BOTTOM; + + public static final Particle ELECTRON; + public static final Particle ELECTRON_NEUTRINO; + public static final Particle MUON; + public static final Particle MUON_NEUTRINO; + public static final Particle TAU; + public static final Particle TAU_NEUTRINO; + + public static final Particle GLUON; + public static final Particle PHOTON; + public static final Particle Z_BOSON; + public static final Particle W_BOSON; + public static final Particle HIGGS_BOSON; + + public static final Particle PROTON; + public static final Particle NEUTRON; + public static final Particle LAMBDA; + public static final Particle OMEGA; + + public static final Particle PION; + public static final Particle ETA_MESON; + + public static final Particle UNKNOWN; + + public static final AutoMap<Particle> aMap = new AutoMap<>(); + + static { + + /* + * Standard Model of Physics + */ + + // I exist, because I must. + GRAVITON = new Particle(ElementaryGroup.BOSON, "Graviton"); + + // Quarks + UP = new Particle(ElementaryGroup.QUARK, "Up"); + DOWN = new Particle(ElementaryGroup.QUARK, "Down"); + CHARM = new Particle(ElementaryGroup.QUARK, "Charm"); + STRANGE = new Particle(ElementaryGroup.QUARK, "Strange"); + TOP = new Particle(ElementaryGroup.QUARK, "Top"); + BOTTOM = new Particle(ElementaryGroup.QUARK, "Bottom"); + + // Leptons + ELECTRON = new Particle(ElementaryGroup.LEPTON, "Electron"); + MUON = new Particle(ElementaryGroup.LEPTON, "Muon"); + TAU = new Particle(ElementaryGroup.LEPTON, "Tau"); + ELECTRON_NEUTRINO = new Particle(ElementaryGroup.LEPTON, "Electron Neutrino"); + MUON_NEUTRINO = new Particle(ElementaryGroup.LEPTON, "Muon Neutrino"); + TAU_NEUTRINO = new Particle(ElementaryGroup.LEPTON, "Tau Neutrino"); + + // Bosons + GLUON = new Particle(ElementaryGroup.BOSON, "Gluon"); + PHOTON = new Particle(ElementaryGroup.BOSON, "Photon"); + Z_BOSON = new Particle(ElementaryGroup.BOSON, "Z Boson"); + W_BOSON = new Particle(ElementaryGroup.BOSON, "W Boson"); + HIGGS_BOSON = new Particle(ElementaryGroup.BOSON, "Higgs Boson"); + + /* + * Composite Particles + */ + + // Baryons + PROTON = new Particle(ElementaryGroup.BARYON, "Proton", new Particle[] { UP, UP, DOWN }); + NEUTRON = new Particle(ElementaryGroup.BARYON, "Neutron", new Particle[] { UP, DOWN, DOWN }); + LAMBDA = new Particle(ElementaryGroup.BARYON, "Lambda", new Particle[] { UP, DOWN, STRANGE }); + OMEGA = new Particle(ElementaryGroup.BARYON, "Omega", new Particle[] { STRANGE, STRANGE, STRANGE }); + + // Mesons + PION = new Particle(ElementaryGroup.MESON, "Pion", new Particle[] { MUON, MUON_NEUTRINO }); + ETA_MESON = new Particle(ElementaryGroup.MESON, "ETA Meson", new Particle[] { PION, PION, PION }); + + // Wildcard + UNKNOWN = new Particle(ElementaryGroup.UNKNOWN, "Unknown"); + } + + public static enum ElementaryGroup { + QUARK, + LEPTON, + BOSON, + BARYON, + MESON, + UNKNOWN; + } + + public final ElementaryGroup mParticleType; + public final String mParticleName; + public final Particle[] mComposition; + + public Particle(ElementaryGroup aParticleType, String aParticleName) { + this(aParticleType, aParticleName, null); + } + + public Particle(ElementaryGroup aParticleType, String aParticleName, Particle[] aComposition) { + mParticleType = aParticleType; + mParticleName = aParticleName; + mComposition = aComposition == null ? new Particle[] { this } : aComposition; + aMap.put(this); + } + + public static ItemStack getIon(String aElementName, int aCharge) { + for (String g : gtPlusPlus.core.item.chemistry.IonParticles.NameToMetaMap.keySet()) { + if (g.toLowerCase() + .equals(Utils.sanitizeString(aElementName.toLowerCase()))) { + Integer meta = gtPlusPlus.core.item.chemistry.IonParticles.NameToMetaMap + .get(Utils.sanitizeString(aElementName.toLowerCase())); + if (meta == null) { + meta = 0; + } + ItemStack aIon = ItemUtils.simpleMetaStack(ModItems.itemIonParticleBase, meta, 1); + if (aCharge != 0) { + IonParticles.setChargeState(aIon, aCharge); + } + return aIon; + } + } + return null; + } + + public static ItemStack getBaseParticle(Particle aParticle) { + String aPartName = Utils.sanitizeString(aParticle.mParticleName.toLowerCase()); + for (String g : gtPlusPlus.core.item.chemistry.StandardBaseParticles.NameToMetaMap.keySet()) { + if (g.toLowerCase() + .equals(aPartName)) { + Integer meta = gtPlusPlus.core.item.chemistry.StandardBaseParticles.NameToMetaMap.get(aPartName); + if (meta == null) { + meta = 0; + } + return ItemUtils.simpleMetaStack(ModItems.itemStandarParticleBase, meta, 1); + } + } + return null; + } +} diff --git a/src/main/java/gtPlusPlus/core/material/nuclear/FLUORIDES.java b/src/main/java/gtPlusPlus/core/material/nuclear/FLUORIDES.java new file mode 100644 index 0000000000..5a50a604da --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/nuclear/FLUORIDES.java @@ -0,0 +1,244 @@ +package gtPlusPlus.core.material.nuclear; + +import gregtech.api.enums.Materials; +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; + +public class FLUORIDES { + + public static final Material FLUORITE = new Material( + "Fluorite (F)", // Material Name + MaterialState.ORE, // State + null, // Material Colour + Materials.Fluorine.mMeltingPoint, // Melting Point in C + Materials.Fluorine.mBlastFurnaceTemp, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + false, // Generate cells + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().CALCIUM, 16), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 32), new MaterialStack(ELEMENT.getInstance().IRON, 4), + new MaterialStack(ELEMENT.getInstance().CARBON, 2) }); + + // ThF4 + public static final Material THORIUM_TETRAFLUORIDE = new Material( + "Thorium Tetrafluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().THORIUM232, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) }); + + // ThF6 + public static final Material THORIUM_HEXAFLUORIDE = new Material( + "Thorium Hexafluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().THORIUM232, 1), + new MaterialStack(ELEMENT.getInstance().THORIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 12) }); + + // UF4 + public static final Material URANIUM_TETRAFLUORIDE = new Material( + "Uranium Tetrafluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().URANIUM233, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) }); + + // UF6 + public static final Material URANIUM_HEXAFLUORIDE = new Material( + "Uranium Hexafluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) }); + + // ZrF4 + + public static final Material ZIRCONIUM_TETRAFLUORIDE = new Material( + "Zirconium Tetrafluoride", // Material Name + MaterialState.LIQUID, // State + null, // Texture Set (Autogenerated) + 0, + null, // Material Colour + -1, + -1, + -1, + -1, + false, + "ZrF\u2084", + -1, + true, + false, + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) }); + + /* + * public static final Material ZIRCONIUM_TETRAFLUORIDE = new Material( "Zirconium Tetrafluoride", //Material Name + * MaterialState.LIQUID, //State null, //Material Colour -1, //Melting Point in C -1, //Boiling Point in C -1, + * //Protons -1, //Neutrons false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new + * MaterialStack[]{ new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), new + * MaterialStack(ELEMENT.getInstance().FLUORINE, 4) }); + */ + + // BeF2 + public static final Material BERYLLIUM_FLUORIDE = new Material( + "Beryllium Fluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, + -1, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) }); + + // LiF + public static final Material LITHIUM_FLUORIDE = new Material( + "Lithium Fluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().LITHIUM7, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 1) }); + + // LFTR sub components + + // (NH4)HF2 + public static final Material AMMONIUM_BIFLUORIDE = new Material( + "Ammonium Bifluoride", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + 126, // Melting Point in C + 240, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(MISC_MATERIALS.AMMONIUM, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) }); + + // Be(OH)2 + public static final Material BERYLLIUM_HYDROXIDE = new Material( + "Beryllium Hydroxide", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 1), + new MaterialStack(MISC_MATERIALS.HYDROXIDE, 2) }); + + // (NH4)2BeF4 + public static final Material AMMONIUM_TETRAFLUOROBERYLLATE = new Material( + "Ammonium Tetrafluoroberyllate", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + 280, // 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(MISC_MATERIALS.AMMONIUM, 2), + new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) }); + + // LFTR Output + public static final Material NEPTUNIUM_HEXAFLUORIDE = new Material( + "Neptunium Hexafluoride", // Material Name + MaterialState.GAS, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().NEPTUNIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) }); + + public static final Material TECHNETIUM_HEXAFLUORIDE = new Material( + "Technetium Hexafluoride", // Material Name + MaterialState.GAS, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().TECHNETIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) }); + + public static final Material SELENIUM_HEXAFLUORIDE = new Material( + "Selenium Hexafluoride", // Material Name + MaterialState.GAS, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().SELENIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) }); + + public static final Material SODIUM_FLUORIDE = new Material( + "Sodium Fluoride", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().SODIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 1) }); + + private static final FLUORIDES INSTANCE = new FLUORIDES(); + + public static FLUORIDES getInstance() { + return INSTANCE; + } +} diff --git a/src/main/java/gtPlusPlus/core/material/nuclear/NUCLIDE.java b/src/main/java/gtPlusPlus/core/material/nuclear/NUCLIDE.java new file mode 100644 index 0000000000..ebd24bad07 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/nuclear/NUCLIDE.java @@ -0,0 +1,311 @@ +package gtPlusPlus.core.material.nuclear; + +import gtPlusPlus.core.client.CustomTextureSet.TextureSets; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.util.data.StringUtils; + +public final class NUCLIDE { + + public static final Material Li2BeF4 = new Material( + "Lithium Tetrafluoroberyllate (LFTB)", // Material Name + MaterialState.LIQUID, // State + TextureSets.NUCLEAR.get(), + null, // Material Colour + 566, // Melting Point in C + 870, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "Li2BeF4"), // Chemical Formula + 4, // Radioactivity Level + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 2), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1) }); + + public static final Material LiFBeF2ThF4UF4 = new Material( + "LFTR Fuel 3", // Material Name + MaterialState.LIQUID, // State + TextureSets.NUCLEAR.get(), + null, // Material Colour + 566, // Melting Point in C + 870, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2ThF4UF4"), // Chemical Formula + 5, // Radioactivity Level + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 65), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 28), new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1), + new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1) }); + + public static final Material LiFBeF2ZrF4UF4 = new Material( + "LFTR Fuel 2", // Material Name + MaterialState.LIQUID, // State + TextureSets.NUCLEAR.get(), + null, // Material Colour + 650, // Melting Point in C + 940, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2ZrF4UF4"), // Chemical Formula + 5, // Radioactivity Level + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 65), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 28), + new MaterialStack(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE, 5), + new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 2) }); + + public static final Material LiFBeF2ZrF4U235 = new Material( + "LFTR Fuel 1", // Material Name + MaterialState.LIQUID, // State + TextureSets.NUCLEAR.get(), + null, // Material Colour + 590, // Melting Point in C + 890, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2ZrF4") + StringUtils.superscript("235U"), // Chemical + // Formula + 5, // Radioactivity Level + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 55), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 25), + new MaterialStack(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE, 6), + new MaterialStack(ELEMENT.getInstance().URANIUM235, 14) }); + + // Misc + public static final Material BurntLftrFuel_MK1 = new Material( + "Burnt Reactor Fuel I", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiBeF2UF4FP"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().LITHIUM, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) }); + + public static final Material BurntLftrFuel_MK2 = new Material( + "Burnt Reactor Fuel II", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiBeF2UF4FP"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(ELEMENT.getInstance().LITHIUM, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) }); + + // LFTR Core Fluids + public static final Material LiFBeF2UF4FP = new Material( + "Uranium Depleted Molten Salt (U Salt)", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2UF4FP"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) }); + + public static final Material Sparged_LiFBeF2UF4FP = new Material( + "Helium Sparged U Salt", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2UF4FP"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) }); + + public static final Material UF6F2FP = new Material( + "Phosphorous Uranium Hexafluoride (P-UF6)", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript("UF6F2FP"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.URANIUM_HEXAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 3), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 1) }); + + public static final Material LiFBeF2 = new Material( + "Stable Molten Salt Base", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1) }); + + public static final Material LiFBeF2UF4 = new Material( + "LFTR Fuel Base", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2UF4"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(LiFBeF2, 1), new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1) }); + + // LFTR Blanket Fluids + + // Tier 1 Fuel blanket output + public static final Material LiFThF4 = new Material( + "Thorium Depleted Molten Salt (T Salt)", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFThF4"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) }); + + // Tier 2 Fuel blanket output + public static final Material LiFBeF2ThF4 = new Material( + "Thorium-Beryllium Depleted Molten Salt (TB Salt)", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2ThF4"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) }); + + // Tier 1 Fuel blanket output + public static final Material Sparged_LiFThF4 = new Material( + "Fluorine Sparged T Salt", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFThF4"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) }); + + // Tier 2 Fuel blanket output + public static final Material Sparged_LiFBeF2ThF4 = new Material( + "Fluorine Sparged TB Salt", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2ThF4"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) }); + + public static final Material UF6F2 = new Material( + "Fluorinated Uranium Hexafluoride (F-UF6)", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript("UF6F2"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { new MaterialStack(FLUORIDES.URANIUM_HEXAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) }); + + // Secondary material is molten metal + public static final Material NAQ_FUEL_T1 = new Material( + "Naquadah Fuel", + 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().NAQUADAH, 2), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 3) }); + + // Secondary material is a plasma + public static final Material NAQ_FUEL_T2 = new Material( + "Enriched Naquadah Fuel", + 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().NAQUADAH_ENRICHED, 2), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 3) }); + + // Secondary material is a plasma + public static final Material NAQ_FUEL_T3 = new Material( + "Naquadria Fuel", + 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().NAQUADRIA, 2), + new MaterialStack(ELEMENT.getInstance().AMERICIUM, 3) }); + + private static final NUCLIDE INSTANCE = new NUCLIDE(); + + public static NUCLIDE getInstance() { + return INSTANCE; + } +} diff --git a/src/main/java/gtPlusPlus/core/material/state/MaterialState.java b/src/main/java/gtPlusPlus/core/material/state/MaterialState.java new file mode 100644 index 0000000000..9fb5cde101 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/material/state/MaterialState.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.material.state; + +public enum MaterialState { + + SOLID(0), + LIQUID(1), + GAS(2), + PLASMA(3), + PURE_LIQUID(4), + ORE(5), + PURE_GAS(6); + + private final int STATE; + + private MaterialState(final int State) { + this.STATE = State; + } + + public int ID() { + return this.STATE; + } +} diff --git a/src/main/java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java b/src/main/java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java new file mode 100644 index 0000000000..383f22dc23 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java @@ -0,0 +1,14 @@ +package gtPlusPlus.core.network.handler; + +import net.minecraft.entity.player.EntityPlayer; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; + +public abstract class AbstractClientMessageHandler<T extends IMessage> extends AbstractMessageHandler<T> { + + @Override + public final IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx) { + return null; + } +} diff --git a/src/main/java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java b/src/main/java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java new file mode 100644 index 0000000000..a50bee6092 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java @@ -0,0 +1,38 @@ +package gtPlusPlus.core.network.handler; + +import net.minecraft.entity.player.EntityPlayer; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.GTplusplus; + +public abstract class AbstractMessageHandler<T extends IMessage> implements IMessageHandler<T, IMessage> { + + /** + * Handle a message received on the client side + * + * @return a message to send back to the Server, or null if no reply is necessary + */ + @SideOnly(Side.CLIENT) + public abstract IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx); + + /** + * Handle a message received on the server side + * + * @return a message to send back to the Client, or null if no reply is necessary + */ + public abstract IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx); + + @Override + public IMessage onMessage(T message, MessageContext ctx) { + if (ctx.side.isClient()) { + return handleClientMessage(GTplusplus.proxy.getPlayerEntity(ctx), message, ctx); + } else { + // server side proxy will return the server side EntityPlayer + return handleServerMessage(GTplusplus.proxy.getPlayerEntity(ctx), message, ctx); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java b/src/main/java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java new file mode 100644 index 0000000000..a45bf8dd17 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java @@ -0,0 +1,14 @@ +package gtPlusPlus.core.network.handler; + +import net.minecraft.entity.player.EntityPlayer; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; + +public abstract class AbstractServerMessageHandler<T extends IMessage> extends AbstractMessageHandler<T> { + + @Override + public final IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx) { + return null; + } +} diff --git a/src/main/java/gtPlusPlus/core/network/packet/AbstractPacket.java b/src/main/java/gtPlusPlus/core/network/packet/AbstractPacket.java new file mode 100644 index 0000000000..ef43795206 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/network/packet/AbstractPacket.java @@ -0,0 +1,8 @@ +package gtPlusPlus.core.network.packet; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; + +public interface AbstractPacket extends IMessage { + + public abstract String getPacketName(); +} diff --git a/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java b/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java new file mode 100644 index 0000000000..9dfa1dbad5 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java @@ -0,0 +1,127 @@ +package gtPlusPlus.core.network.packet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.network.handler.AbstractServerMessageHandler; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import io.netty.buffer.ByteBuf; + +public class Packet_VolumetricFlaskGui extends AbstractServerMessageHandler<Packet_VolumetricFlaskGui> + implements AbstractPacket { + + private int x; + private int y; + private int z; + private int flaskValue; + + public Packet_VolumetricFlaskGui() {} + + public Packet_VolumetricFlaskGui(TileEntityVolumetricFlaskSetter tile, int aCustomValue) { + x = tile.xCoord; + y = tile.yCoord; + z = tile.zCoord; + flaskValue = aCustomValue; + Logger.INFO("Created Packet with values (" + x + ", " + y + ", " + z + " | " + flaskValue + ")"); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(x); + buf.writeInt(y); + buf.writeInt(z); + buf.writeInt(flaskValue); + Logger.INFO("Writing to byte buffer."); + } + + @Override + public void fromBytes(ByteBuf buf) { + x = buf.readInt(); + y = buf.readInt(); + z = buf.readInt(); + flaskValue = buf.readInt(); + Logger.INFO("Reading from byte buffer."); + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public int getZ() { + return z; + } + + public void setZ(int z) { + this.z = z; + } + + public int getCustomValue() { + return flaskValue; + } + + public void setCustomValue(int aVal) { + this.flaskValue = aVal; + } + + protected TileEntityVolumetricFlaskSetter getTileEntity(Packet_VolumetricFlaskGui message, MessageContext ctx) { + Logger.INFO("Trying to get tile."); + World worldObj = getWorld(ctx); + if (worldObj == null) { + Logger.INFO("Bad world object."); + return null; + } + TileEntity te = worldObj.getTileEntity(message.getX(), message.getY(), message.getZ()); + if (te == null) { + Logger.INFO("Bad Tile."); + return null; + } + if (te instanceof TileEntityVolumetricFlaskSetter) { + Logger.INFO("Found Tile."); + return (TileEntityVolumetricFlaskSetter) te; + } + Logger.INFO("Error."); + return null; + } + + protected World getWorld(MessageContext ctx) { + if (ctx.side == Side.SERVER) { + return ctx.getServerHandler().playerEntity.worldObj; + } else { + return GTplusplus.proxy.getClientWorld(); + } + } + + @Override + public IMessage handleServerMessage(EntityPlayer player, Packet_VolumetricFlaskGui message, MessageContext ctx) { + TileEntityVolumetricFlaskSetter te = getTileEntity(message, ctx); + if (te != null) { + Logger.INFO("Setting value on tile. " + message.getCustomValue()); + te.setCustomValue(message.getCustomValue()); + // return new Packet_VolumetricFlaskGui2(te, message.getCustomValue()); + } + return null; + } + + @Override + public String getPacketName() { + return "Packet_VoluemtricFlaskSetter_ToServer"; + } +} diff --git a/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java b/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java new file mode 100644 index 0000000000..599469191b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java @@ -0,0 +1,126 @@ +package gtPlusPlus.core.network.packet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.network.handler.AbstractClientMessageHandler; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import io.netty.buffer.ByteBuf; + +public class Packet_VolumetricFlaskGui2 extends AbstractClientMessageHandler<Packet_VolumetricFlaskGui2> + implements AbstractPacket { + + private int x; + private int y; + private int z; + private int flaskValue; + + public Packet_VolumetricFlaskGui2() {} + + public Packet_VolumetricFlaskGui2(TileEntityVolumetricFlaskSetter tile, int aCustomValue) { + x = tile.xCoord; + y = tile.yCoord; + z = tile.zCoord; + flaskValue = aCustomValue; + Logger.INFO("Created Packet with values (" + x + ", " + y + ", " + z + " | " + flaskValue + ")"); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(x); + buf.writeInt(y); + buf.writeInt(z); + buf.writeInt(flaskValue); + Logger.INFO("Writing to byte buffer."); + } + + @Override + public void fromBytes(ByteBuf buf) { + x = buf.readInt(); + y = buf.readInt(); + z = buf.readInt(); + flaskValue = buf.readInt(); + Logger.INFO("Reading from byte buffer."); + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public int getZ() { + return z; + } + + public void setZ(int z) { + this.z = z; + } + + public int getCustomValue() { + return flaskValue; + } + + public void setCustomValue(int aVal) { + this.flaskValue = aVal; + } + + protected TileEntityVolumetricFlaskSetter getTileEntity(Packet_VolumetricFlaskGui2 message, MessageContext ctx) { + Logger.INFO("Trying to get tile."); + World worldObj = getWorld(ctx); + if (worldObj == null) { + Logger.INFO("Bad world object."); + return null; + } + TileEntity te = worldObj.getTileEntity(message.getX(), message.getY(), message.getZ()); + if (te == null) { + Logger.INFO("Bad Tile."); + return null; + } + if (te instanceof TileEntityVolumetricFlaskSetter) { + Logger.INFO("Found Tile."); + return (TileEntityVolumetricFlaskSetter) te; + } + Logger.INFO("Error."); + return null; + } + + protected World getWorld(MessageContext ctx) { + if (ctx.side == Side.SERVER) { + return ctx.getServerHandler().playerEntity.worldObj; + } else { + return GTplusplus.proxy.getClientWorld(); + } + } + + @Override + public String getPacketName() { + return "Packet_VoluemtricFlaskSetter_ToClient"; + } + + @Override + public IMessage handleClientMessage(EntityPlayer player, Packet_VolumetricFlaskGui2 message, MessageContext ctx) { + TileEntityVolumetricFlaskSetter te = getTileEntity(message, ctx); + if (te != null) { + Logger.INFO("Setting value on tile. " + message.getCustomValue()); + te.setCustomValue(message.getCustomValue()); + } + return null; + } +} diff --git a/src/main/java/gtPlusPlus/core/potion/GtPotionEffect.java b/src/main/java/gtPlusPlus/core/potion/GtPotionEffect.java new file mode 100644 index 0000000000..65e7d20af0 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/potion/GtPotionEffect.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.potion; + +import net.minecraft.potion.PotionEffect; + +public class GtPotionEffect extends PotionEffect { + + public GtPotionEffect(int aPotionID, int aDurationInSecs, int aLevel) { + super(aPotionID, aDurationInSecs * 20, aLevel, false); + } +} diff --git a/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java b/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java new file mode 100644 index 0000000000..5f6f93542e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java @@ -0,0 +1,190 @@ +package gtPlusPlus.core.proxy; + +import java.util.ArrayList; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.RenderFireball; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +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.core.client.renderer.CustomItemBlockRenderer; +import gtPlusPlus.core.client.renderer.CustomOreBlockRenderer; +import gtPlusPlus.core.client.renderer.RenderDecayChest; +import gtPlusPlus.core.client.renderer.RenderMiningExplosivesPrimed; +import gtPlusPlus.core.client.renderer.RenderSickBlaze; +import gtPlusPlus.core.client.renderer.RenderStaballoyConstruct; +import gtPlusPlus.core.client.renderer.RenderToxinball; +import gtPlusPlus.core.common.CommonProxy; +import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; +import gtPlusPlus.core.entity.monster.EntitySickBlaze; +import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; +import gtPlusPlus.core.entity.projectile.EntityLightningAttack; +import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.CORE.ConfigSwitches; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; +import gtPlusPlus.nei.NEI_GTPP_Config; +import gtPlusPlus.xmod.gregtech.common.render.GTPP_CapeRenderer; +import gtPlusPlus.xmod.gregtech.common.render.GTPP_FlaskRenderer; +import gtPlusPlus.xmod.gregtech.common.render.GTPP_Render_MachineBlock; +import ic2.core.item.ItemFluidCell; + +public class ClientProxy extends CommonProxy implements Runnable { + + private final GTPP_CapeRenderer mCapeRenderer; + + @SideOnly(Side.CLIENT) + public static boolean mFancyGraphics = false; + + public ClientProxy() { + mCapeRenderer = new GTPP_CapeRenderer(); + // Get Graphics Mode. + mFancyGraphics = Minecraft.isFancyGraphicsEnabled(); + } + + @SubscribeEvent + public void receiveRenderSpecialsEvent(net.minecraftforge.client.event.RenderPlayerEvent.Specials.Pre aEvent) { + if (ConfigSwitches.enableCustomCapes) { + mCapeRenderer.receiveRenderSpecialsEvent(aEvent); + } + } + + @SideOnly(Side.CLIENT) + public static String playerName = ""; + + @Override + public void preInit(final FMLPreInitializationEvent e) { + super.preInit(e); + if (ConfigSwitches.enableCustomCapes) { + onPreLoad(); + } + // Do this weird things for textures. + GTplusplus.loadTextures(); + } + + @Override + public void init(final FMLInitializationEvent e) { + + /** + * Custom Block Renderers + */ + new CustomOreBlockRenderer(); + new CustomItemBlockRenderer(); + new GTPP_Render_MachineBlock(); + + new GTPP_FlaskRenderer(); + + MinecraftForge.EVENT_BUS.register(new NEI_GTPP_Config()); + + super.init(e); + } + + @Override + public void postInit(final FMLPostInitializationEvent e) { + super.postInit(e); + } + + @Override + public void registerRenderThings() { + + // Standard GT++ + + /** + * Entities + */ + RenderingRegistry + .registerEntityRenderingHandler(EntityPrimedMiningExplosive.class, new RenderMiningExplosivesPrimed()); + RenderingRegistry.registerEntityRenderingHandler(EntitySickBlaze.class, new RenderSickBlaze()); + RenderingRegistry + .registerEntityRenderingHandler(EntityStaballoyConstruct.class, new RenderStaballoyConstruct()); + RenderingRegistry.registerEntityRenderingHandler(EntityToxinballSmall.class, new RenderToxinball(1F)); + RenderingRegistry.registerEntityRenderingHandler(EntityLightningAttack.class, new RenderFireball(1F)); + + /** + * Tiles + */ + Logger.INFO("Registering Custom Renderer for the Lead Lined Chest."); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDecayablesChest.class, new RenderDecayChest()); + Logger.INFO("Registering Custom Renderer for the Egg Box."); + + /** + * Items + */ + for (Pair<Item, IItemRenderer> sItemRenderMappings : mItemRenderMappings) { + MinecraftForgeClient.registerItemRenderer(sItemRenderMappings.getKey(), sItemRenderMappings.getValue()); + } + } + + @Override + public int addArmor(final String armor) { + return RenderingRegistry.addNewArmourRendererPrefix(armor); + } + + @Override + public void serverStarting(final FMLServerStartingEvent e) {} + + public void onPreLoad() { + + } + + @Override + public void run() { + + } + + @Override + public void onLoadComplete(FMLLoadCompleteEvent event) { + if (CORE.ConfigSwitches.hideUniversalCells) { + hideUniversalCells(); + } + super.onLoadComplete(event); + } + + public void hideUniversalCells() { + ArrayList<ItemStack> itemList = new ArrayList<>(); + for (Fluid fluid : FluidRegistry.getRegisteredFluids() + .values()) { + if (fluid == null) { + continue; + } + itemList.add(ItemFluidCell.getUniversalFluidCell(new FluidStack(fluid, 2147483647))); + } + for (ItemStack aCell : itemList) { + codechicken.nei.api.API.hideItem(aCell); + } + } + + @Override + public World getClientWorld() { + return FMLClientHandler.instance() + .getClient().theWorld; + } + + @Override + public EntityPlayer getPlayerEntity(MessageContext ctx) { + return (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : super.getPlayerEntity(ctx)); + } +} diff --git a/src/main/java/gtPlusPlus/core/proxy/ServerProxy.java b/src/main/java/gtPlusPlus/core/proxy/ServerProxy.java new file mode 100644 index 0000000000..73b027af10 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/proxy/ServerProxy.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.proxy; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gtPlusPlus.core.common.CommonProxy; + +@SuppressWarnings("unused") +public class ServerProxy extends CommonProxy { + + @Override + public void preInit(final FMLPreInitializationEvent e) { + // TODO Auto-generated method stub + super.preInit(e); + } + + @Override + public void init(final FMLInitializationEvent e) { + // TODO Auto-generated method stub + super.init(e); + } + + @Override + public void postInit(final FMLPostInitializationEvent e) { + // TODO Auto-generated method stub + super.postInit(e); + } +} diff --git a/src/main/java/gtPlusPlus/core/recipe/LOADER_Machine_Components.java b/src/main/java/gtPlusPlus/core/recipe/LOADER_Machine_Components.java new file mode 100644 index 0000000000..a10d2cd05b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/LOADER_Machine_Components.java @@ -0,0 +1,114 @@ +package gtPlusPlus.core.recipe; + +import gregtech.api.enums.ItemList; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class LOADER_Machine_Components { + + public static void initialise() { + registerDefaultComponents(); + + registerGTNHComponents(); + } + + private static void registerDefaultComponents() { + // Machine Components + CI.electricMotor_LV = ItemList.Electric_Motor_LV.get(1); + CI.electricMotor_MV = ItemList.Electric_Motor_MV.get(1); + CI.electricMotor_HV = ItemList.Electric_Motor_HV.get(1); + CI.electricMotor_EV = ItemList.Electric_Motor_EV.get(1); + CI.electricMotor_IV = ItemList.Electric_Motor_IV.get(1); + CI.electricPump_LV = ItemList.Electric_Pump_LV.get(1); + CI.electricPump_MV = ItemList.Electric_Pump_MV.get(1); + CI.electricPump_HV = ItemList.Electric_Pump_HV.get(1); + CI.electricPump_EV = ItemList.Electric_Pump_EV.get(1); + CI.electricPump_IV = ItemList.Electric_Pump_IV.get(1); + CI.electricPiston_LV = ItemList.Electric_Piston_LV.get(1); + CI.electricPiston_MV = ItemList.Electric_Piston_MV.get(1); + CI.electricPiston_HV = ItemList.Electric_Piston_HV.get(1); + CI.electricPiston_EV = ItemList.Electric_Piston_EV.get(1); + CI.electricPiston_IV = ItemList.Electric_Piston_IV.get(1); + CI.robotArm_LV = ItemList.Robot_Arm_LV.get(1); + CI.robotArm_MV = ItemList.Robot_Arm_MV.get(1); + CI.robotArm_HV = ItemList.Robot_Arm_HV.get(1); + CI.robotArm_EV = ItemList.Robot_Arm_EV.get(1); + CI.robotArm_IV = ItemList.Robot_Arm_IV.get(1); + CI.conveyorModule_LV = ItemList.Conveyor_Module_LV.get(1); + CI.conveyorModule_MV = ItemList.Conveyor_Module_MV.get(1); + CI.conveyorModule_HV = ItemList.Conveyor_Module_HV.get(1); + CI.conveyorModule_EV = ItemList.Conveyor_Module_EV.get(1); + CI.conveyorModule_IV = ItemList.Conveyor_Module_IV.get(1); + CI.emitter_LV = ItemList.Emitter_LV.get(1); + CI.emitter_MV = ItemList.Emitter_MV.get(1); + CI.emitter_HV = ItemList.Emitter_HV.get(1); + CI.emitter_EV = ItemList.Emitter_EV.get(1); + CI.emitter_IV = ItemList.Emitter_IV.get(1); + CI.fieldGenerator_LV = ItemList.Field_Generator_LV.get(1); + CI.fieldGenerator_MV = ItemList.Field_Generator_MV.get(1); + CI.fieldGenerator_HV = ItemList.Field_Generator_HV.get(1); + CI.fieldGenerator_EV = ItemList.Field_Generator_EV.get(1); + CI.fieldGenerator_IV = ItemList.Field_Generator_IV.get(1); + CI.sensor_LV = ItemList.Sensor_LV.get(1); + CI.sensor_MV = ItemList.Sensor_MV.get(1); + CI.sensor_HV = ItemList.Sensor_HV.get(1); + CI.sensor_EV = ItemList.Sensor_EV.get(1); + CI.sensor_IV = ItemList.Sensor_IV.get(1); + CI.fluidRegulator_LV = ItemList.FluidRegulator_LV.get(1); + CI.fluidRegulator_MV = ItemList.FluidRegulator_MV.get(1); + CI.fluidRegulator_HV = ItemList.FluidRegulator_HV.get(1); + CI.fluidRegulator_EV = ItemList.FluidRegulator_EV.get(1); + CI.fluidRegulator_IV = ItemList.FluidRegulator_IV.get(1); + } + + private static void registerGTNHComponents() { + // Machine Components + CI.electricMotor_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32606, 1); + CI.electricMotor_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32607, 1); + CI.electricMotor_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32608, 1); + + CI.electricPump_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32615, 1); + CI.electricPump_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32616, 1); + CI.electricPump_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32617, 1); + + CI.electricPiston_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32645, 1); + CI.electricPiston_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32646, 1); + CI.electricPiston_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32647, 1); + + CI.robotArm_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32655, 1); + CI.robotArm_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32656, 1); + CI.robotArm_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32657, 1); + + CI.conveyorModule_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32635, 1); + CI.conveyorModule_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32636, 1); + CI.conveyorModule_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32637, 1); + + CI.emitter_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32685, 1); + CI.emitter_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32686, 1); + CI.emitter_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32687, 1); + + CI.fieldGenerator_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32675, 1); + CI.fieldGenerator_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32676, 1); + CI.fieldGenerator_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32677, 1); + + CI.sensor_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32695, 1); + CI.sensor_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32696, 1); + CI.sensor_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32697, 1); + + CI.fluidRegulator_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32665, 1); + CI.fluidRegulator_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32666, 1); + CI.fluidRegulator_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32667, 1); + + // Thanks 0lafe + CI.electricMotor_UHV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32596, 1); + CI.electricPump_UHV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32618, 1); + CI.electricPiston_UHV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32648, 1); + CI.robotArm_UHV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32658, 1); + CI.conveyorModule_UHV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32638, 1); + CI.emitter_UHV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32688, 1); + CI.fieldGenerator_UHV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32678, 1); + CI.sensor_UHV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32698, 1); + + } + +} diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java new file mode 100644 index 0000000000..0900bbb4fa --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -0,0 +1,1806 @@ +package gtPlusPlus.core.recipe; + +import static gregtech.api.enums.Mods.Backpack; +import static gregtech.api.enums.Mods.Baubles; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.recipe.RecipeMaps.alloySmelterRecipes; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.recipe.RecipeMaps.blastFurnaceRecipes; +import static gregtech.api.recipe.RecipeMaps.brewingRecipes; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.recipe.RecipeMaps.compressorRecipes; +import static gregtech.api.recipe.RecipeMaps.cutterRecipes; +import static gregtech.api.recipe.RecipeMaps.distillationTowerRecipes; +import static gregtech.api.recipe.RecipeMaps.distilleryRecipes; +import static gregtech.api.recipe.RecipeMaps.electrolyzerRecipes; +import static gregtech.api.recipe.RecipeMaps.extruderRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidHeaterRecipes; +import static gregtech.api.recipe.RecipeMaps.fusionRecipes; +import static gregtech.api.recipe.RecipeMaps.laserEngraverRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.recipe.RecipeMaps.multiblockChemicalReactorRecipes; +import static gregtech.api.util.GT_RecipeBuilder.BUCKETS; +import static gregtech.api.util.GT_RecipeBuilder.HOURS; +import static gregtech.api.util.GT_RecipeBuilder.INGOTS; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; +import static gregtech.api.util.GT_RecipeConstants.AssemblyLine; +import static gregtech.api.util.GT_RecipeConstants.COIL_HEAT; +import static gregtech.api.util.GT_RecipeConstants.FUEL_TYPE; +import static gregtech.api.util.GT_RecipeConstants.FUEL_VALUE; +import static gregtech.api.util.GT_RecipeConstants.FUSION_THRESHOLD; +import static gregtech.api.util.GT_RecipeConstants.RESEARCH_ITEM; +import static gregtech.api.util.GT_RecipeConstants.RESEARCH_TIME; +import static gregtech.api.util.GT_RecipeConstants.UniversalChemical; +import static gtPlusPlus.api.recipe.GTPPRecipeMaps.thermalBoilerRecipes; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import cpw.mods.fml.common.Loader; +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.TierEU; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_RecipeConstants; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.item.chemistry.GenericChem; +import gtPlusPlus.core.item.chemistry.IonParticles; +import gtPlusPlus.core.item.crafting.ItemDummyResearch; +import gtPlusPlus.core.item.crafting.ItemDummyResearch.ASSEMBLY_LINE_RESEARCH; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.material.ORES; +import gtPlusPlus.core.material.Particle; +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.MaterialUtils; +import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + +public class RECIPES_GREGTECH { + + public static void run() { + Logger.INFO("Loading Recipes through GregAPI for Industrial Multiblocks."); + execute(); + } + + private static void execute() { + electrolyzerRecipes(); + assemblerRecipes(); + distilleryRecipes(); + extractorRecipes(); + fluidExtractorRecipes(); + chemicalReactorRecipes(); + dehydratorRecipes(); + blastFurnaceRecipes(); + largeChemReactorRecipes(); + fusionRecipes(); + compressorRecipes(); + mixerRecipes(); + macerationRecipes(); + centrifugeRecipes(); + cyclotronRecipes(); + blastSmelterRecipes(); + extruderRecipes(); + cuttingSawRecipes(); + breweryRecipes(); + laserEngraverRecipes(); + assemblyLineRecipes(); + fluidHeaterRecipes(); + chemplantRecipes(); + alloySmelterRecipes(); + thermalBoilerRecipes(); + + /* + * Special Recipe handlers + */ + RECIPES_SeleniumProcessing.init(); + RECIPES_RareEarthProcessing.init(); + + addFuels(); + } + + private static void alloySmelterRecipes() { + + // Wood's Glass Laser Lens + GT_Values.RA.stdBuilder() + .itemInputs(MISC_MATERIALS.WOODS_GLASS.getDust(5), ItemList.Shape_Mold_Ball.get(0)) + .itemOutputs(GregtechItemList.Laser_Lens_WoodsGlass.get(1)) + .duration(5 * MINUTES) + .eut(TierEU.RECIPE_HV) + .addTo(alloySmelterRecipes); + } + + private static void chemplantRecipes() { + + // This is subsequently absorbed in water to form nitric acid and nitric oxide. + // 3 NO2 (g) + H2O (l) → 2 HNO3 (aq) + NO (g) (ΔH = −117 kJ/mol) + // The nitric oxide is cycled back for reoxidation. Alternatively, if the last step is carried out in air: + // 4 NO2 (g) + O2 (g) + 2 H2O (l) → 4 HNO3 (aq) + + // Advanced method for Nitric Acid Production + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(17), CI.getPinkCatalyst(0), }, + new FluidStack[] { Materials.NitrogenDioxide.getGas(4000L), FluidUtils.getAir(4000), + FluidUtils.getWater(2000), }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack("nitricacid", 4000), }, + 10 * 20, + 480, + 3); + + // Advanced recipe for Fluorine Production + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(17), CI.getPurpleCatalyst(0), + ItemUtils.getSimpleStack(Blocks.sandstone, 64), ItemUtils.getSimpleStack(Blocks.sandstone, 64) }, + new FluidStack[] { FluidUtils.getFluidStack("nitricacid", 4000), FluidUtils.getAir(8000) }, + new ItemStack[] { FLUORIDES.FLUORITE.getOre(8), FLUORIDES.FLUORITE.getOre(4), FLUORIDES.FLUORITE.getOre(4), + FLUORIDES.FLUORITE.getOre(4), }, + new FluidStack[] {}, + new int[] { 0, 2500, 2000, 1500 }, + 10 * 20, + 1024, + 5); + + // Advanced recipe for Fluorine Production + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(17), CI.getPurpleCatalyst(0), + ItemUtils.getSimpleStack(Blocks.sand, 64), ItemUtils.getSimpleStack(Blocks.sand, 64) }, + new FluidStack[] { FluidUtils.getFluidStack("nitricacid", 5000), FluidUtils.getAir(12000) }, + new ItemStack[] { FLUORIDES.FLUORITE.getOre(4), FLUORIDES.FLUORITE.getOre(2), FLUORIDES.FLUORITE.getOre(2), + FLUORIDES.FLUORITE.getOre(2), }, + new FluidStack[] {}, + new int[] { 7500, 1500, 1000, 500 }, + 10 * 20, + 1024, + 5); + + // 3NO2 + H2O = 2HNO3 + NO + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(16), CI.getPinkCatalyst(0), }, + new FluidStack[] { Materials.NitrogenDioxide.getGas(3000L), FluidUtils.getDistilledWater(1000) }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getFluidStack("nitricacid", 2000), Materials.NitricOxide.getGas(1000L), }, + 10 * 20, + 480, + 2); + + // Produce Boric Acid + // Na2B4O7·10H2O + 2HCl = 4B(OH)3 + 2NaCl + 5H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(21), + ItemUtils.getItemStackOfAmountFromOreDict("dustBorax", 23), }, + new FluidStack[] { FluidUtils.getFluidStack(GenericChem.HydrochloricAcid, 2000) }, + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("dustSalt", 4), }, + new FluidStack[] { FluidUtils.getFluidStack("boricacid", 4000), FluidUtils.getWater(5000) }, + 20 * 30, + MaterialUtils.getVoltageForTier(3), + 3); + + // Produce Th232 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(22), ELEMENT.getInstance().THORIUM.getDust(16) }, + new FluidStack[] { FluidUtils.getDistilledWater(2000), FluidUtils.getFluidStack("boricacid", 1500) }, + new ItemStack[] { ELEMENT.getInstance().THORIUM.getSmallDust(32), + ELEMENT.getInstance().THORIUM232.getDust(2), ELEMENT.getInstance().THORIUM232.getSmallDust(2), + ELEMENT.getInstance().URANIUM232.getDust(1), }, + new FluidStack[] {}, + new int[] { 0, 0, 1000, 250 }, + 20 * 300, + MaterialUtils.getVoltageForTier(4), + 4); + + // Modify Sapling into Pine Sapling + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(6), ItemUtils.getSimpleStack(Blocks.sapling, 32) }, + new FluidStack[] { FluidUtils.getFluidStack("fluid.geneticmutagen", 2000), + FluidUtils.getDistilledWater(8000) }, + new ItemStack[] { ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Pine, 16) }, + new FluidStack[] {}, + 120 * 20, + 64, + 2); + + int aLaureniumTier = ALLOY.LAURENIUM.vTier; + // Adding Recipes for Casings + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(12), CI.getTieredMachineCasing(aLaureniumTier - 1), + ALLOY.LAURENIUM.getPlate(8), CI.getGear(aLaureniumTier, 2) }, + new FluidStack[] { CI.getTieredFluid(aLaureniumTier, 2 * 144), + CI.getAlternativeTieredFluid(aLaureniumTier - 1, 4 * 144), + CI.getTertiaryTieredFluid(aLaureniumTier - 2, 6 * 144) }, + new ItemStack[] { GregtechItemList.Casing_Machine_Custom_3.get(1) }, + new FluidStack[] {}, + 20 * 20, + MaterialUtils.getVoltageForTier(aLaureniumTier - 2), + 5); + + int aBotmiumTier = ALLOY.BOTMIUM.vTier; + // Adding Recipes for Casings + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(12), CI.getTieredMachineCasing(aBotmiumTier - 1), + ALLOY.BOTMIUM.getPlate(8), CI.getGear(aBotmiumTier, 2) }, + new FluidStack[] { CI.getTieredFluid(aBotmiumTier, 2 * 144), + CI.getAlternativeTieredFluid(aBotmiumTier - 1, 4 * 144), + CI.getTertiaryTieredFluid(aBotmiumTier - 2, 6 * 144) }, + new ItemStack[] { GregtechItemList.Casing_Machine_Custom_4.get(1) }, + new FluidStack[] {}, + 20 * 20, + MaterialUtils.getVoltageForTier(aBotmiumTier - 2), + 6); + + // Refine GT HF into GT++ HF + if (FluidUtils.doesHydrofluoricAcidGtExist()) { + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(22), }, + new FluidStack[] { FluidUtils.getHydrofluoricAcid(2000), FluidUtils.getHydrofluoricAcidGT(5000) }, + new ItemStack[] {}, + new FluidStack[] { FluidUtils.getHydrofluoricAcid(4500) }, + 30 * 20, + 480, + 3); + } + } + + private static void fluidHeaterRecipes() { + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(20)) + .fluidInputs(Materials.Water.getFluid(1000)) + .fluidOutputs(FluidUtils.getHotWater(1000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(fluidHeaterRecipes); + } + + private static void fusionRecipes() { + // Hypogen + GT_Values.RA.stdBuilder() + .fluidInputs( + ELEMENT.STANDALONE.DRAGON_METAL.getFluidStack(144), + ELEMENT.STANDALONE.RHUGNOR.getFluidStack(288)) + .fluidOutputs(ELEMENT.STANDALONE.HYPOGEN.getFluidStack(36)) + .duration(6 * MINUTES + 49 * SECONDS + 12 * TICKS) + .eut(TierEU.RECIPE_UHV) + .metadata(FUSION_THRESHOLD, 1_200_000_000) + .addTo(fusionRecipes); + + // Rhugnor + GT_Values.RA.stdBuilder() + .fluidInputs( + MaterialUtils.getMaterial("Infinity", "Neutronium") + .getMolten(144), + ALLOY.QUANTUM.getFluidStack(288)) + .fluidOutputs(ELEMENT.STANDALONE.RHUGNOR.getFluidStack(144)) + .duration(25 * SECONDS + 12 * TICKS) + .eut(TierEU.RECIPE_UV) + .metadata(FUSION_THRESHOLD, 2_000_000_000) + .addTo(fusionRecipes); + } + + private static void assemblyLineRecipes() { + + // Containment Casings + GT_Values.RA.stdBuilder() + .metadata( + RESEARCH_ITEM, + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_1_CONTAINMENT, 1)) + .metadata(RESEARCH_TIME, 30 * MINUTES) + .itemInputs( + ItemList.Field_Generator_IV.get(32), + ItemList.Electric_Motor_EV.get(64), + ItemList.Energy_LapotronicOrb.get(32), + CI.getTieredComponent(OrePrefixes.cableGt12, 7, 32), + CI.getTieredComponent(OrePrefixes.wireGt16, 6, 64), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Naquadria, 64L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Gadolinium, 32L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Samarium, 16L), + ALLOY.ARCANITE.getGear(8), + new Object[] { CI.getTieredCircuitOreDictName(5), 64 }, + new Object[] { CI.getTieredCircuitOreDictName(6), 32 }, + new Object[] { CI.getTieredCircuitOreDictName(7), 16 }, + GregtechItemList.Laser_Lens_Special.get(1), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 3, 64)) + .fluidInputs( + ALLOY.NITINOL_60.getFluidStack(144 * 9 * 4), + ALLOY.ENERGYCRYSTAL.getFluidStack(144 * 9 * 8), + ALLOY.TUMBAGA.getFluidStack(144 * 9 * 32), + Materials.Nichrome.getMolten(16 * INGOTS)) + .itemOutputs(ItemUtils.getSimpleStack(ModBlocks.blockCasings3Misc, 15, 32)) + .eut(TierEU.RECIPE_LuV) + .duration(20 * MINUTES) + .addTo(AssemblyLine); + + // Turbine Automation Port + GT_Values.RA.stdBuilder() + .metadata( + RESEARCH_ITEM, + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_8_TURBINE_AUTOMATION, 1)) + .metadata(RESEARCH_TIME, 24 * HOURS) + .itemInputs( + CI.getTieredMachineHull(8, 4), + CI.getConveyor(8, 24), + CI.getElectricMotor(7, 32), + CI.getElectricPiston(7, 16), + CI.getEnergyCore(6, 8), + CI.getPlate(8, 24), + CI.getTieredComponent(OrePrefixes.screw, 8, 48), + CI.getTieredComponent(OrePrefixes.bolt, 7, 32), + CI.getTieredComponent(OrePrefixes.rod, 6, 12), + new Object[] { CI.getTieredCircuitOreDictName(7), 20 }, + CI.getTieredComponent(OrePrefixes.rotor, 6, 16)) + .fluidInputs( + CI.getTieredFluid(8, 144 * 32), + CI.getAlternativeTieredFluid(7, 144 * 16), + CI.getTertiaryTieredFluid(7, 144 * 16), + ALLOY.BABBIT_ALLOY.getFluidStack(128 * 144)) + .itemOutputs(GregtechItemList.Hatch_Input_TurbineHousing.get(4)) + .eut(TierEU.RECIPE_UV) + .duration(2 * HOURS) + .addTo(AssemblyLine); + + /* + * Containment casings + */ + ItemStack[] aCoilWire = new ItemStack[] { ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 0, 64), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 1, 64), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 2, 64), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 3, 64), }; + ItemStack[] aGemCasings = new ItemStack[] { GregtechItemList.Battery_Casing_Gem_1.get(1), + GregtechItemList.Battery_Casing_Gem_2.get(1), GregtechItemList.Battery_Casing_Gem_3.get(1), + GregtechItemList.Battery_Casing_Gem_4.get(1), }; + ItemStack[] aResearch = new ItemStack[] { Particle.getBaseParticle(Particle.UNKNOWN), + GregtechItemList.Battery_Casing_Gem_1.get(1), GregtechItemList.Battery_Casing_Gem_2.get(1), + GregtechItemList.Battery_Casing_Gem_3.get(1), }; + + int aCasingSlot = 0; + for (int j = 6; j < 10; j++) { + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, aResearch[aCasingSlot]) + .metadata(RESEARCH_TIME, 1 * HOURS) + .itemInputs( + CI.getTieredComponent(OrePrefixes.plate, j - 1, 16), + CI.getTieredComponent(OrePrefixes.cableGt08, j + 1, 32), + CI.getTieredComponent(OrePrefixes.gearGt, j - 1, 4), + aCoilWire[aCasingSlot]) + .fluidInputs( + CI.getTieredFluid(j, 144 * 8), + CI.getTertiaryTieredFluid(j - 2, 144 * 16), + CI.getAlternativeTieredFluid(j, 144 * 16)) + .itemOutputs(aGemCasings[aCasingSlot++]) + .eut(GT_Values.V[j]) + .duration(2 * MINUTES) + .addTo(AssemblyLine); + } + + /* + * Gem Battery Recipes + */ + + ItemStack[] aGemBatteries = new ItemStack[] { GregtechItemList.Battery_Gem_1.get(1), + GregtechItemList.Battery_Gem_2.get(1), GregtechItemList.Battery_Gem_3.get(1), + GregtechItemList.Battery_Gem_4.get(1), }; + + ItemStack[] aExoticInputs = new ItemStack[] { Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.ELECTRON), Particle.getBaseParticle(Particle.CHARM), + Particle.getBaseParticle(Particle.GRAVITON) }; + aCasingSlot = 0; + for (int j = 6; j < 10; j++) { + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, aExoticInputs[aCasingSlot]) + .metadata(RESEARCH_TIME, 5 * HOURS) + .itemInputs( + aGemCasings[aCasingSlot], + ItemUtils.getSimpleStack(aExoticInputs[aCasingSlot], 16), + CI.getTieredComponent(OrePrefixes.plate, j, 16), + new Object[] { CI.getTieredCircuitOreDictName(j), 8 }, + CI.getTieredComponent(OrePrefixes.wireGt16, j + 1, 32), + CI.getTieredComponent(OrePrefixes.bolt, j, 8), + CI.getTieredComponent(OrePrefixes.screw, j - 1, 8)) + .fluidInputs( + CI.getTieredFluid(j, 144 * 1 * 16), + CI.getTertiaryTieredFluid(j - 2, 144 * 2 * 16), + CI.getAlternativeTieredFluid(j, 144 * 16), + CI.getTertiaryTieredFluid(j - 1, 144 * 16)) + .itemOutputs(aGemBatteries[aCasingSlot++]) + .eut(GT_Values.V[j]) + .duration(2 * MINUTES) + .addTo(AssemblyLine); + } + + if (Baubles.isModLoaded()) { + // Nano Healer + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, ItemUtils.simpleMetaStack(Items.golden_apple, 1, 1)) + .metadata(RESEARCH_TIME, 10 * MINUTES) + .itemInputs( + ItemUtils.getSimpleStack(aGemCasings[2], 4), + CI.getTieredComponent(OrePrefixes.plate, 8, 32), + new Object[] { CI.getTieredCircuitOreDictName(7), 16 }, + CI.getTieredComponent(OrePrefixes.cableGt02, 7, 16), + CI.getTieredComponent(OrePrefixes.gearGt, 6, 6), + CI.getTieredComponent(OrePrefixes.screw, 7, 16), + CI.getTieredComponent(OrePrefixes.bolt, 5, 24), + CI.getTieredComponent(OrePrefixes.frameGt, 4, 12), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 3, 64)) + .fluidInputs( + CI.getTieredFluid(7, 144 * 18 * 16), + CI.getTertiaryTieredFluid(7, 144 * 18 * 16), + CI.getAlternativeTieredFluid(6, 144 * 18 * 16), + CI.getAlternativeTieredFluid(7, 144 * 18 * 16)) + .itemOutputs(ItemUtils.getItemStackFromFQRN("miscutils:personalHealingDevice", 1)) + .eut(TierEU.RECIPE_ZPM) + .duration(1 * HOURS) + .addTo(AssemblyLine); + + // Charge Pack LuV-UV + + ItemStack[] aChargeResearch = new ItemStack[] { + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", 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), }; + + int aCurrSlot = 0; + for (int h = 6; h < 10; h++) { + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, aChargeResearch[aCurrSlot]) + .metadata(RESEARCH_TIME, 10 * (aCurrSlot + 1) * MINUTES) + .itemInputs( + ItemUtils.getSimpleStack(aGemBatteries[aCurrSlot], 2), + aCoilWire[aCurrSlot], + CI.getTieredComponent(OrePrefixes.plate, h, 8), + new Object[] { CI.getTieredCircuitOreDictName(h), 4 }, + new Object[] { CI.getTieredCircuitOreDictName(h - 1), 8 }, + CI.getTieredComponent(OrePrefixes.cableGt12, h - 1, 16), + CI.getTieredComponent(OrePrefixes.screw, h, 16), + CI.getTieredComponent(OrePrefixes.bolt, h - 2, 32), + CI.getFieldGenerator(h - 1, 1)) + .fluidInputs( + CI.getTieredFluid(h, 144 * 4 * 8), + CI.getTertiaryTieredFluid(h - 1, 144 * 4 * 8), + CI.getAlternativeTieredFluid(h - 1, 144 * 4 * 8), + CI.getAlternativeTieredFluid(h - 2, 144 * 4 * 8)) + .itemOutputs(aChargeOutputs[aCurrSlot]) + .eut(GT_Values.V[h]) + .duration((aCurrSlot + 1) * HOURS) + .addTo(AssemblyLine); + aCurrSlot++; + } + + // Cloaking device + GT_Values.RA.stdBuilder() + .metadata( + RESEARCH_ITEM, + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_9_CLOAKING, 1)) + .metadata(RESEARCH_TIME, 10 * MINUTES) + .itemInputs( + ItemUtils.getSimpleStack(aGemCasings[3], 4), + CI.getTieredComponent(OrePrefixes.plate, 8, 32), + new Object[] { CI.getTieredCircuitOreDictName(7), 16 }, + CI.getTieredComponent(OrePrefixes.cableGt04, 8, 16), + CI.getTieredComponent(OrePrefixes.gearGt, 7, 6), + CI.getTieredComponent(OrePrefixes.screw, 8, 16), + CI.getTieredComponent(OrePrefixes.bolt, 7, 24), + CI.getTieredComponent(OrePrefixes.frameGt, 5, 12), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 3, 64)) + .fluidInputs( + CI.getTieredFluid(8, 144 * 18 * 16), + CI.getTertiaryTieredFluid(8, 144 * 18 * 16), + CI.getAlternativeTieredFluid(7, 144 * 18 * 16), + CI.getAlternativeTieredFluid(8, 144 * 18 * 16)) + .itemOutputs(ItemUtils.getItemStackFromFQRN("miscutils:personalCloakingDevice-0.0", 1)) + .eut(TierEU.RECIPE_UV) + .duration(1 * HOURS) + .addTo(AssemblyLine); + } + + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, GregtechItemList.Industrial_AlloyBlastSmelter.get(1, new Object() {})) + .metadata(RESEARCH_TIME, 30 * MINUTES) + .itemInputs( + GregtechItemList.Industrial_AlloyBlastSmelter.get(64L, new Object() {}), + GregtechItemList.Industrial_AlloyBlastSmelter.get(64L, new Object() {}), + GregtechItemList.Industrial_AlloyBlastSmelter.get(64L, new Object() {}), + GregtechItemList.Industrial_AlloyBlastSmelter.get(64L, new Object() {}), + ItemList.UV_Coil.get(16L, new Object() {}), + ItemList.Conveyor_Module_UV.get(4L, new Object() {}), + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 8 }, + new Object[] { OrePrefixes.circuit.get(Materials.Ultimate), 16 }, + ItemList.Circuit_Chip_PPIC.get(16, new Object() {}), + ALLOY.PIKYONIUM.getPlate(16), + ALLOY.CINOBITE.getScrew(32)) + .fluidInputs( + ALLOY.PIKYONIUM.getFluidStack(144 * 8), + ALLOY.INDALLOY_140.getFluidStack(144 * 9), + Materials.SolderingAlloy.getMolten(144 * 10)) + .itemOutputs(GregtechItemList.Mega_AlloyBlastSmelter.get(1L)) + .eut(TierEU.RECIPE_UHV / 2) + .duration(1 * MINUTES) + .addTo(AssemblyLine); + } + + private static void laserEngraverRecipes() { + + // Laser Sensors and Emitters together + GregtechItemList[] aTransParts = new GregtechItemList[] { GregtechItemList.TransmissionComponent_LV, + GregtechItemList.TransmissionComponent_MV, GregtechItemList.TransmissionComponent_HV, + GregtechItemList.TransmissionComponent_EV, GregtechItemList.TransmissionComponent_IV, + GregtechItemList.TransmissionComponent_LuV, GregtechItemList.TransmissionComponent_ZPM, + GregtechItemList.TransmissionComponent_UV, GregtechItemList.TransmissionComponent_UHV, }; + for (int i = 1; i < aTransParts.length; i++) { + GT_Values.RA.stdBuilder() + .itemInputs(CI.getEmitter(i, 2), CI.getSensor(i, 2)) + .itemOutputs(aTransParts[i - 1].get(1)) + .duration(5 * SECONDS) + .eut(GT_Values.VP[i]) + .addTo(laserEngraverRecipes); + } + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Tungsten, 6L), + GregtechItemList.Laser_Lens_Special.get(0)) + .itemOutputs(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.getDust(1)) + .duration(3 * MINUTES) + .eut(MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.vTier)) + .addTo(laserEngraverRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Titanium, 8L), + GregtechItemList.Laser_Lens_Special.get(0)) + .itemOutputs(ELEMENT.STANDALONE.ASTRAL_TITANIUM.getDust(1)) + .duration(2 * MINUTES) + .eut(MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.ASTRAL_TITANIUM.vTier)) + .addTo(laserEngraverRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ALLOY.NITINOL_60.getBlock(2), GregtechItemList.Laser_Lens_Special.get(0)) + .itemOutputs(ELEMENT.STANDALONE.ADVANCED_NITINOL.getBlock(1)) + .duration(1 * MINUTES) + .eut(MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.ADVANCED_NITINOL.vTier)) + .addTo(laserEngraverRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Glass, 64L), + GregtechItemList.Laser_Lens_Special.get(0)) + .itemOutputs(ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getDust(1)) + .duration(5 * MINUTES) + .eut(MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.CHRONOMATIC_GLASS.vTier)) + .addTo(laserEngraverRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(CI.getFieldGenerator(6, 1), CI.getEmitter(7, 2)) + .itemOutputs(ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_1_CONTAINMENT, 1)) + .duration(5 * MINUTES) + .eut(TierEU.RECIPE_IV) + .addTo(laserEngraverRecipes); + + // Distillus Upgrade Chip + GT_Values.RA.stdBuilder() + .itemInputs( + GregtechItemList.Laser_Lens_WoodsGlass.get(0), + ItemUtils.simpleMetaStack(AgriculturalChem.mBioCircuit, 20, 1)) + .itemOutputs(GregtechItemList.Distillus_Upgrade_Chip.get(1)) + .duration(5 * MINUTES) + .eut(TierEU.RECIPE_IV) + .addTo(laserEngraverRecipes); + } + + private static void breweryRecipes() { + + if (Loader.isModLoaded("OpenBlocks")) { + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(14)) + .fluidInputs(FluidRegistry.getFluidStack("mobessence", 100)) + .fluidOutputs(FluidRegistry.getFluidStack("liquidxp", 1332)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(brewingRecipes); + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(14)) + .fluidInputs(FluidRegistry.getFluidStack("liquidxp", 1332)) + .fluidOutputs(FluidRegistry.getFluidStack("mobessence", 100)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(brewingRecipes); + } + + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest)) + .fluidInputs(Materials.Water.getFluid(100L)) + .fluidOutputs(Materials.Biomass.getFluid(100L)) + .duration(1 * MINUTES) + .eut(3) + .addTo(brewingRecipes); + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest)) + .fluidInputs(Materials.Honey.getFluid(100L)) + .fluidOutputs(Materials.Biomass.getFluid(100L)) + .duration(1 * MINUTES) + .eut(3) + .addTo(brewingRecipes); + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest)) + .fluidInputs(FluidUtils.getFluidStack("juice", 100)) + .fluidOutputs(Materials.Biomass.getFluid(100L)) + .duration(1 * MINUTES) + .eut(3) + .addTo(brewingRecipes); + } + + private static void cuttingSawRecipes() { + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1)) + .itemOutputs(ItemUtils.getItemStackOfAmountFromOreDict("plateMeatRaw", 9)) + .duration(16 * TICKS) + .eut(TierEU.RECIPE_ULV) + .addTo(cutterRecipes); + } + + private static void electrolyzerRecipes() { + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(ModItems.dustDecayedRadium226, 1)) + .fluidOutputs(FluidUtils.getFluidStack("radon", 144)) + .duration(1 * MINUTES + 30 * SECONDS) + .eut(TierEU.RECIPE_HV / 2) + .addTo(electrolyzerRecipes); + } + + private static void extruderRecipes() { + // Osmium Credits + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getItemStackOfAmountFromOreDict("blockOsmium", 1), ItemList.Shape_Mold_Credit.get(0)) + .itemOutputs(ItemList.Credit_Greg_Osmium.get(1)) + .duration(6 * MINUTES + 20 * SECONDS) + .eut(TierEU.RECIPE_EV / 2) + .addTo(extruderRecipes); + } + + private static void blastSmelterRecipes() { + + // Eglin Steel + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(6), ELEMENT.getInstance().IRON.getDust(4), + ALLOY.KANTHAL.getDust(1), ALLOY.INVAR.getDust(5), ELEMENT.getInstance().SULFUR.getDust(1), + ELEMENT.getInstance().CARBON.getDust(1), ELEMENT.getInstance().SILICON.getDust(4) }, + ALLOY.EGLIN_STEEL.getFluidStack(16 * 144), + 0, + 20 * 45, + 120); + + // HG1223 + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(5), ELEMENT.getInstance().BARIUM.getDust(2), + ELEMENT.getInstance().CALCIUM.getDust(2), ELEMENT.getInstance().COPPER.getDust(3), }, + new FluidStack[] { ELEMENT.getInstance().OXYGEN.getFluidStack(8000), + ELEMENT.getInstance().MERCURY.getFluidStack(1000), }, + ALLOY.HG1223.getFluidStack(16 * 144), + null, + new int[] { 10000 }, // Output Chance + 20 * 120, + 30720); + + // NITINOL_60 + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(2), ELEMENT.getInstance().TITANIUM.getDust(3), + ELEMENT.getInstance().NICKEL.getDust(2) }, + ALLOY.NITINOL_60.getFluidStack(5 * 144), + 0, + 20 * 75, + 7680); + + // INDALLOY_140 + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(5), ELEMENT.getInstance().BISMUTH.getDust(47), + ELEMENT.getInstance().LEAD.getDust(25), ELEMENT.getInstance().TIN.getDust(13), + ELEMENT.getInstance().CADMIUM.getDust(10), ELEMENT.getInstance().INDIUM.getDust(5) }, + ALLOY.INDALLOY_140.getFluidStack(100 * 144), + 0, + 20 * 40, + 7680); + + // Germanium Roasting + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(15), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedSphalerite", 8), + ELEMENT.getInstance().CARBON.getDust(32), }, + Materials.SulfuricAcid.getFluid(2000), + ELEMENT.getInstance().GERMANIUM.getFluidStack(288), + 0, + 20 * 300, + 4000); + + // Rhenium Roasting + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(20), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedScheelite", 8), + ELEMENT.getInstance().CARBON.getDust(32), }, + Materials.SulfuricAcid.getFluid(10000), + ELEMENT.getInstance().RHENIUM.getFluidStack(144), + 0, + 20 * 300, + 4000); + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(20), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedMolybdenite", 8), + ELEMENT.getInstance().CARBON.getDust(32), }, + Materials.SulfuricAcid.getFluid(7500), + ELEMENT.getInstance().RHENIUM.getFluidStack(144), + 0, + 20 * 300, + 4000); + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(20), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedMolybdenum", 8), + ELEMENT.getInstance().CARBON.getDust(32), }, + Materials.SulfuricAcid.getFluid(5000), + ELEMENT.getInstance().RHENIUM.getFluidStack(288), + 0, + 20 * 300, + 4000); + + // Thallium Roasting + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(21), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedZinc", 3), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedPyrite", 4), + ELEMENT.getInstance().CARBON.getDust(16), }, + Materials.SulfuricAcid.getFluid(1250), + ELEMENT.getInstance().THALLIUM.getFluidStack(288), + new ItemStack[] {}, + new int[] { 0 }, + 20 * 75, + 8000, + 3700, + false); + + // Strontium processing + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(21), MISC_MATERIALS.STRONTIUM_OXIDE.getDust(8), + ELEMENT.getInstance().ALUMINIUM.getDust(8), }, + (FluidStack) null, + ELEMENT.getInstance().OXYGEN.getFluidStack(8000), + new ItemStack[] { ELEMENT.getInstance().ALUMINIUM.getIngot(8), + ELEMENT.getInstance().STRONTIUM.getIngot(8) }, + new int[] { 10000, 10000 }, // Output Chance + 20 * 120, + 480 * 4); + + // molten botmium + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(4), + ItemUtils.getItemStackOfAmountFromOreDict("dustNitinol60", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustOsmium", 6), + ItemUtils.getItemStackOfAmountFromOreDict("dustRuthenium", 6), + ItemUtils.getItemStackOfAmountFromOreDict("dustThallium", 3) }, + GT_Values.NF, + ALLOY.BOTMIUM.getFluidStack(2304), + 0, + 20 * 120, + 491520); + + // molten precious metals alloy + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(6), + ItemUtils.getItemStackOfAmountFromOreDict("dustRuthenium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRhodium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustPalladium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustPlatinum", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustOsmium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustIridium", 1) }, + GT_Values.NF, + FluidUtils.getFluidStack("molten.precious metals alloy", 864), + 0, + 20 * 540, + 7864320); + } + + private static void dehydratorRecipes() { + Logger.INFO("Loading Recipes for Chemical Dehydrator."); + + ItemStack cropGrape = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cropGrape", 1); + ItemStack foodRaisins = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foodRaisins", 1); + + if (cropGrape != null && foodRaisins != null) CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(20), cropGrape }, // Item + null, // Fluid input (slot 1) + null, // Fluid output (slot 2) + new ItemStack[] { foodRaisins }, // Output + new int[] { 10000 }, + 10, // Time in ticks + 2); // EU + + // Process Waste Water + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(21) }, + FluidUtils.getFluidStack("fluid.sludge", 1000), + FluidUtils.getFluidStack("nitricacid", 10), + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("dustTinyIron", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyCopper", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyTin", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyNickel", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyCobalt", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAluminium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinySilver", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyGold", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyIridium", 1) }, + new int[] { 10, 5, 5, 4, 4, 3, 2, 2, 1 }, + 2 * 20, + 500); // EU + + // C8H10 = C8H8 + 2H + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), CI.emptyCells(3) }, + FluidUtils.getFluidStack("fluid.ethylbenzene", 1000), + null, + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("cellStyrene", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 2) }, + new int[] { 10000, 10000 }, + 3 * 20, + 30); + + /* + * Add custom recipes for drying leather + */ + if (Backpack.isModLoaded()) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), new ItemStack(Items.leather, 2) }, + FluidUtils.getFluidStack("fluid.ethylbenzene", 1000), + null, + new ItemStack[] { ItemUtils.getCorrectStacktype("Backpack:tannedLeather", 1) }, + new int[] { 10000 }, + 5 * 20, + 180); + if (NewHorizonsCoreMod.isModLoaded()) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), + GT_ModHandler.getModItem(NewHorizonsCoreMod.ID, "item.ArtificialLeather", 2L, 0) }, + FluidUtils.getFluidStack("fluid.ethylbenzene", 1000), + null, + new ItemStack[] { ItemUtils.getCorrectStacktype("Backpack:tannedLeather", 1) }, + new int[] { 10000 }, + 5 * 20, + 180); + } + } + // Alternative ACETIC ANHYDRIDE recipe for Kevlar Line + // 2C2H4O2 = C4H6O3 + H2O + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), CI.emptyCells(1) }, + FluidUtils.getFluidStack("aceticacid", 2000), + MISC_MATERIALS.ACETIC_ANHYDRIDE.getFluidStack(1000), + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("cellWater", 1), }, + new int[] { 10000 }, + 30 * 20, + 480); + } + + private static void largeChemReactorRecipes() { + // Styrene + // C8H10 = C8H8 + 2H + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(24)) + .itemOutputs() + .fluidInputs(FluidUtils.getFluidStack("fluid.ethylbenzene", 1000)) + .fluidOutputs(Materials.Styrene.getFluid(1000L), Materials.Hydrogen.getGas(2000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(multiblockChemicalReactorRecipes); + + // Short-cut Styrene + // C6H6 + C2H4 = C8H8 + 2H + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(24)) + .itemOutputs() + .fluidInputs(Materials.Ethylene.getGas(500L), Materials.Benzene.getFluid(500L)) + .fluidOutputs(Materials.Styrene.getFluid(500L), Materials.Hydrogen.getGas(1000)) + .duration(12 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(multiblockChemicalReactorRecipes); + } + + private static void assemblerRecipes() { + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Vanadium, 32L), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.VanadiumSteel, 8L)) + .itemOutputs(ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 0, 4)) + .fluidInputs(Materials.Oxygen.getGas(8000L)) + .duration(16 * SECONDS) + .eut(TierEU.RECIPE_MV / 2) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 0, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.VanadiumGallium, 8L)) + .itemOutputs(ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 1, 8)) + .fluidInputs(Materials.Tantalum.getMolten(4 * INGOTS)) + .duration(32 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 1, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Lead, 4L), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(3), 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorHV, 2L)) + .itemOutputs(ItemUtils.getSimpleStack(GregtechItemList.Casing_Vanadium_Redox.get(1), 1)) + .fluidInputs(Materials.Oxygen.getGas(16 * BUCKETS)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(TierEU.RECIPE_HV / 2) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GregtechItemList.Casing_Vanadium_Redox.get(1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Titanium, 4L), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(4), 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorEV, 2L)) + .itemOutputs(GregtechItemList.Casing_Vanadium_Redox_IV.get(1)) + .fluidInputs(Materials.Nitrogen.getGas(16 * BUCKETS)) + .duration(6 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GregtechItemList.Casing_Vanadium_Redox_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.TungstenSteel, 4L), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(5), 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorIV, 2L)) + .itemOutputs(GregtechItemList.Casing_Vanadium_Redox_LuV.get(1)) + .fluidInputs(Materials.Helium.getGas(8 * BUCKETS)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_IV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GregtechItemList.Casing_Vanadium_Redox_LuV.get(1), + ItemUtils.getItemStackOfAmountFromOreDict("plateAlloyIridium", 16), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorLuV, 2L)) + .itemOutputs(GregtechItemList.Casing_Vanadium_Redox_ZPM.get(1)) + .fluidInputs(Materials.Argon.getGas(4 * BUCKETS)) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GregtechItemList.Casing_Vanadium_Redox_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Naquadah, 4L), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorZPM, 2L)) + .itemOutputs(GregtechItemList.Casing_Vanadium_Redox_UV.get(1)) + .fluidInputs(Materials.Radon.getGas(4 * BUCKETS)) + .duration(50 * SECONDS) + .eut(TierEU.RECIPE_ZPM) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GregtechItemList.Casing_Vanadium_Redox_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Americium, 4L), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(8), 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUV, 2L)) + .itemOutputs(GregtechItemList.Casing_Vanadium_Redox_MAX.get(1)) + .fluidInputs(FluidUtils.getFluidStack("krypton", 500)) + .duration(1 * MINUTES + 40 * SECONDS) + .eut(TierEU.RECIPE_UV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + ItemUtils.getSimpleStack(CI.explosiveITNT, 2), + ItemUtils.getSimpleStack(CI.explosiveTNT, 4), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sulfur, 2L), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Iron, 1L)) + .itemOutputs(ItemUtils.getSimpleStack(ModBlocks.blockMiningExplosive, 3)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_MV / 2) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.NetherStar, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 8L), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.BlackSteel, 8L)) + .itemOutputs(ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard, 64)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + CI.fluidRegulator_LV, + CI.electricMotor_LV, + CI.getTieredComponent(OrePrefixes.bolt, 1, 8), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 1L), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Brass, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Steel, 2L)) + .itemOutputs(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + CI.fluidRegulator_MV, + CI.electricMotor_MV, + CI.getTieredComponent(OrePrefixes.bolt, 2, 8), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 1L), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Invar, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Aluminium, 2L)) + .itemOutputs(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + CI.fluidRegulator_HV, + CI.electricMotor_HV, + CI.getTieredComponent(OrePrefixes.bolt, 3, 8), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Chrome, 1L), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Chrome, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.StainlessSteel, 2L)) + .itemOutputs(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + CI.fluidRegulator_EV, + CI.electricMotor_EV, + CI.getTieredComponent(OrePrefixes.bolt, 4, 8), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Titanium, 1L), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Titanium, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 2L)) + .itemOutputs(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1), GT_Utility.getIntegratedCircuit(20)) + .itemOutputs(ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1000, 1)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1), GT_Utility.getIntegratedCircuit(20)) + .itemOutputs(ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1001, 1)) + .duration(6 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1), GT_Utility.getIntegratedCircuit(20)) + .itemOutputs(ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1002, 1)) + .duration(24 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1), GT_Utility.getIntegratedCircuit(20)) + .itemOutputs(ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1003, 1)) + .duration(1 * MINUTES + 36 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(assemblerRecipes); + + // Low tier Charge Packs + + final ItemStack[] aPackBatteries = new ItemStack[] { ItemList.Battery_RE_LV_Lithium.get(4), + ItemList.Battery_RE_MV_Lithium.get(4), ItemList.Battery_RE_HV_Lithium.get(4), + GregtechItemList.Battery_RE_EV_Lithium.get(4), ItemList.Energy_LapotronicOrb.get(4), }; + final ItemStack[] aPackPlates = new ItemStack[] { CI.getPlate(1, 8), CI.getPlate(2, 8), CI.getPlate(3, 8), + CI.getPlate(4, 8), CI.getPlate(5, 8), }; + final ItemStack[] aPackWire = new ItemStack[] { CI.getTieredComponent(OrePrefixes.wireGt02, 1, 6), + CI.getTieredComponent(OrePrefixes.wireGt04, 2, 6), CI.getTieredComponent(OrePrefixes.wireGt08, 3, 6), + CI.getTieredComponent(OrePrefixes.wireGt12, 4, 6), CI.getTieredComponent(OrePrefixes.wireGt16, 5, 6), }; + final ItemStack[] aPackCircuit = new ItemStack[] { CI.getTieredComponent(OrePrefixes.circuit, 1, 4), + CI.getTieredComponent(OrePrefixes.circuit, 2, 4), CI.getTieredComponent(OrePrefixes.circuit, 3, 4), + CI.getTieredComponent(OrePrefixes.circuit, 4, 4), CI.getTieredComponent(OrePrefixes.circuit, 5, 4), }; + final ItemStack[] aPackRing = new ItemStack[] { CI.getTieredComponent(OrePrefixes.ring, 1, 12), + CI.getTieredComponent(OrePrefixes.ring, 2, 12), CI.getTieredComponent(OrePrefixes.ring, 3, 12), + CI.getTieredComponent(OrePrefixes.ring, 4, 12), CI.getTieredComponent(OrePrefixes.ring, 5, 12), }; + final ItemStack[] aPackOutput = new ItemStack[] { ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_2), + ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_3), + ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_4), + ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_5) }; + + for (int i = 1; i < 6; i++) { + + int aAS = i - 1; + + GT_Values.RA.stdBuilder() + .itemInputs( + aPackPlates[aAS], + aPackRing[aAS], + aPackWire[aAS], + aPackCircuit[aAS], + aPackBatteries[aAS], + CI.getSensor(i, 4)) + .itemOutputs(aPackOutput[aAS]) + .fluidInputs(CI.getTieredFluid(i, (144 * 4))) + .duration(30 * i * SECONDS) + .eut(GT_Values.V[i]) + .addTo(assemblerRecipes); + } + + if (Baubles.isModLoaded()) { + + // Turbine Housing Research Page + GT_Values.RA.stdBuilder() + .itemInputs( + GT_Utility.getIntegratedCircuit(17), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Trinium, 64L), + CI.getSensor(6, 6), + CI.getBolt(7, 64), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Platinum, 64L), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), 12)) + .itemOutputs( + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_8_TURBINE_AUTOMATION, 1)) + .fluidInputs(CI.getAlternativeTieredFluid(7, 144 * 32)) + .duration(5 * MINUTES) + .eut(TierEU.RECIPE_LuV) + .addTo(assemblerRecipes); + + // Cloaking Device Research Page + GT_Values.RA.stdBuilder() + .itemInputs( + GT_Utility.getIntegratedCircuit(17), + ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR, 4), + CI.getFieldGenerator(6, 16), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Palladium, 32L), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), 12)) + .itemOutputs(ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_9_CLOAKING, 1)) + .fluidInputs(CI.getAlternativeTieredFluid(7, 144 * 32)) + .duration(10 * MINUTES) + .eut(TierEU.RECIPE_ZPM) + .addTo(assemblerRecipes); + } + } + + private static void distilleryRecipes() { + Logger.INFO("Registering Distillery/Distillation Tower Recipes."); + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(4)) + .fluidInputs(Materials.Air.getGas(1000L)) + .fluidOutputs(Materials.Helium.getGas(1L)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(distilleryRecipes); + + GT_Values.RA.stdBuilder() + .fluidInputs(Materials.Air.getGas(20000L)) + .fluidOutputs(Materials.Helium.getGas(25L)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV / 2) + .addTo(distillationTowerRecipes); + + // Apatite Distillation + /* + * so if you dissolve aparite in sulphuric acid you'll get a mixture of SO2, H2O, HF and HCl + */ + + GT_Values.RA.stdBuilder() + .fluidInputs(FluidUtils.getFluidStack("sulfuricapatite", 5200)) + .fluidOutputs( + FluidUtils.getFluidStack("sulfurousacid", 3800), + FluidUtils.getFluidStack("hydrogenchloride", 1000), + FluidUtils.getFluidStack("hydrofluoricacid", 400)) + .duration(45 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(distillationTowerRecipes); + + GT_Values.RA.stdBuilder() + .fluidInputs(FluidUtils.getFluidStack("sulfurousacid", 1000)) + .fluidOutputs(Materials.SulfurDioxide.getGas(500), Materials.Water.getFluid(500)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV / 2) + .addTo(distillationTowerRecipes); + } + + private static void thermalBoilerRecipes() { + Logger.INFO("Registering Thermal Boiler Recipes."); + + // Recipes with special value -1 display additional tooltip in NEI about lava filters. + + // Lava + + GT_Values.RA.stdBuilder() + .fluidInputs(FluidUtils.getLava(1000), FluidUtils.getWater(16_000 / GT_Values.STEAM_PER_WATER)) + .fluidOutputs(FluidUtils.getPahoehoeLava(1000), FluidUtils.getSteam(16_000)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Copper, 1), + GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Tin, 1), + GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Gold, 1), + GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Silver, 1), + GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Tantalum, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Tungstate, 1), + new ItemStack(Blocks.obsidian, 1, 0)) + .outputChances(444, 222, 56, 56, 56, 125, 1000) + .specialValue(-1) + .duration(1 * SECONDS) + .eut(0) + .addTo(thermalBoilerRecipes); + + // Pahoehoe Lava + + GT_Values.RA.stdBuilder() + .fluidInputs(FluidUtils.getPahoehoeLava(1000), FluidUtils.getWater(16_000 / GT_Values.STEAM_PER_WATER)) + .fluidOutputs(FluidUtils.getSteam(16_000)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Bronze, 1), + GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Electrum, 1), + GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Tantalum, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Tungstate, 1), + new ItemStack(Blocks.obsidian, 1, 0)) + .outputChances(167, 56, 56, 125, 3700) + .specialValue(-1) + .duration(1 * SECONDS) + .eut(0) + .addTo(thermalBoilerRecipes); + + // Hot Coolant + + GT_Values.RA.stdBuilder() + .fluidInputs( + FluidUtils.getFluidStack("ic2hotcoolant", 500), + FluidUtils.getWater(100_000 / GT_Values.STEAM_PER_WATER)) + .fluidOutputs(FluidUtils.getFluidStack("ic2coolant", 500), FluidUtils.getSuperHeatedSteam(100_000)) + .duration(1 * SECONDS) + .eut(0) + .addTo(thermalBoilerRecipes); + + // Solar Salt (Hot) + + GT_Values.RA.stdBuilder() + .fluidInputs( + MISC_MATERIALS.SOLAR_SALT_HOT.getFluidStack(100), + FluidUtils.getWater(100_000 / GT_Values.STEAM_PER_WATER)) + .fluidOutputs(MISC_MATERIALS.SOLAR_SALT_COLD.getFluidStack(100), FluidUtils.getSuperHeatedSteam(100_000)) + .duration(1 * SECONDS) + .eut(0) + .addTo(thermalBoilerRecipes); + } + + private static void addFuels() { + Logger.INFO("Registering New Fuels."); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(Items.lava_bucket)) + .metadata(FUEL_VALUE, 32) + .metadata(FUEL_TYPE, 2) + .duration(0) + .eut(0) + .addTo(GT_RecipeConstants.Fuel); + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getIC2Cell(2)) + .metadata(FUEL_VALUE, 32) + .metadata(FUEL_TYPE, 2) + .duration(0) + .eut(0) + .addTo(GT_RecipeConstants.Fuel); + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getIC2Cell(11)) + .metadata(FUEL_VALUE, 24) + .metadata(FUEL_TYPE, 2) + .duration(0) + .eut(0) + .addTo(GT_RecipeConstants.Fuel); + } + + private static void extractorRecipes() { + Logger.INFO("Registering Extractor Recipes."); + GT_ModHandler.addExtractionRecipe( + GregtechItemList.Battery_RE_EV_Sodium.get(1L, new Object[0]), + ItemList.Battery_Hull_HV.get(4L, new Object[0])); + GT_ModHandler.addExtractionRecipe( + GregtechItemList.Battery_RE_EV_Cadmium.get(1L, new Object[0]), + ItemList.Battery_Hull_HV.get(4L, new Object[0])); + GT_ModHandler.addExtractionRecipe( + GregtechItemList.Battery_RE_EV_Lithium.get(1L, new Object[0]), + ItemList.Battery_Hull_HV.get(4L, new Object[0])); + } + + private static void fluidExtractorRecipes() { + // Gelid Cryotheum + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Cryotheum, 1L)) + .fluidOutputs(FluidUtils.getFluidStack("cryotheum", 250)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_HV / 2) + .addTo(fluidExtractionRecipes); + + // Ender Fluid + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(Items.ender_pearl)) + .fluidOutputs(FluidUtils.getFluidStack("ender", 250)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(fluidExtractionRecipes); + + // Blazing Pyrotheum + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Pyrotheum, 1L)) + .fluidOutputs(FluidUtils.getFluidStack("pyrotheum", 250)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_HV / 2) + .addTo(fluidExtractionRecipes); + } + + private static void centrifugeRecipes() { + + GT_Values.RA.stdBuilder() + .itemInputs(CI.getNumberedAdvancedCircuit(2), MISC_MATERIALS.SOLAR_SALT_COLD.getCell(1)) + .itemOutputs( + MISC_MATERIALS.SODIUM_NITRATE.getDust(3), + MISC_MATERIALS.POTASSIUM_NITRATE.getDust(2), + CI.emptyCells(1)) + .duration(6 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(centrifugeRecipes); + } + + private static void mixerRecipes() { + + GT_Values.RA.stdBuilder() + .itemInputs( + CI.getNumberedAdvancedCircuit(2), + CI.emptyCells(1), + MISC_MATERIALS.SODIUM_NITRATE.getDust(3), + MISC_MATERIALS.POTASSIUM_NITRATE.getDust(2)) + .itemOutputs(MISC_MATERIALS.SOLAR_SALT_COLD.getCell(1)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + CI.getNumberedAdvancedCircuit(2), + Materials.Titanium.getDust(9), + Materials.Carbon.getDust(9), + Materials.Potassium.getDust(9), + Materials.Lithium.getDust(9), + Materials.Sulfur.getDust(9)) + .itemOutputs(ALLOY.LEAGRISIUM.getDust(50)) + .fluidInputs(Materials.Hydrogen.getGas(5000)) + .duration(1 * MINUTES) + .eut(TierEU.RECIPE_EV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + CI.getNumberedAdvancedCircuit(2), + Materials.Steel.getDust(16), + Materials.Molybdenum.getDust(1), + Materials.Titanium.getDust(1), + Materials.Nickel.getDust(4), + Materials.Cobalt.getDust(2)) + .itemOutputs(ALLOY.MARAGING250.getDust(24)) + .duration(1 * MINUTES) + .eut(TierEU.RECIPE_EV) + .addTo(mixerRecipes); + } + + private static void chemicalReactorRecipes() { + + GT_Values.RA.stdBuilder() + .itemInputs( + CI.getNumberedAdvancedCircuit(21), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Apatite, 32L)) + .itemOutputs(GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Sulfur, 8L)) + .fluidInputs(FluidUtils.getFluidStack("sulfuricacid", 4000)) + .fluidOutputs(FluidUtils.getFluidStack("sulfuricapatite", 8000)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // KOH + HNO3 = KNO3 + H2O + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(GenericChem.mPotassiumHydroxide, 3), CI.getNumberedAdvancedCircuit(1)) + .itemOutputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.PotassiumNitrade, 5L)) + .fluidInputs(Materials.NitricAcid.getFluid(1000)) + .fluidOutputs(Materials.Water.getFluid(1000)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // Na2CO3 + 2HNO3 = 2NaNO3 + CO2 + H2O + GT_Values.RA.stdBuilder() + .itemInputs( + ItemUtils.getSimpleStack(AgriculturalChem.mSodiumCarbonate, 6), + CI.getNumberedAdvancedCircuit(1)) + .itemOutputs(MISC_MATERIALS.SODIUM_NITRATE.getDust(10)) + .fluidInputs(Materials.NitricAcid.getFluid(2000)) + .fluidOutputs(Materials.CarbonDioxide.getGas(1000)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + } + + private static void blastFurnaceRecipes() { + + // Synthetic Graphite + GT_Values.RA.stdBuilder() + .itemInputs(ALLOY.SILICON_CARBIDE.getDust(16), GT_Utility.getIntegratedCircuit(22)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Graphite, 8L), + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Silicon, 8L)) + .fluidInputs(Materials.Nitrogen.getGas(4000)) + .fluidOutputs() + .duration(1 * MINUTES) + .eut(TierEU.RECIPE_IV) + .metadata(COIL_HEAT, 4500) + .addTo(blastFurnaceRecipes); + + } + + private static void compressorRecipes() { + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Clay, 1L)) + .itemOutputs(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Clay, 1L)) + .duration(15 * SECONDS) + .eut(2) + .addTo(compressorRecipes); + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.MeatRaw, 9L)) + .itemOutputs(GT_OreDictUnificator.get(OrePrefixes.block, Materials.MeatRaw, 1L)) + .duration(15 * SECONDS) + .eut(2) + .addTo(compressorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.FusionComputer_UV.get(9)) + .itemOutputs(GregtechItemList.Compressed_Fusion_Reactor.get(1)) + .duration(1 * HOURS + 50 * MINUTES) + .eut(TierEU.RECIPE_UV) + .addTo(compressorRecipes); + } + + private static void macerationRecipes() { + + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.block, Materials.MeatRaw, 1L)) + .itemOutputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.MeatRaw, 9L)) + .duration(44 * SECONDS) + .eut(4) + .addTo(maceratorRecipes); + + if (ItemUtils.simpleMetaStack("chisel:limestone", 0, 1) != null) { + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getItemStackOfAmountFromOreDict("limestone", 1)) + .itemOutputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Calcite, 4L)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + } + } + + private static void cyclotronRecipes() { + + // Polonium + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.bismuth", 1), + new ItemStack[] { GregtechItemList.Pellet_RTG_PO210.get(1) }, + null, + new int[] { 100 }, + 20 * 300 * 100, + 2040 * 4, + 500 * 20); + + // Americium + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.americium", 1), + new ItemStack[] { GregtechItemList.Pellet_RTG_AM241.get(4) }, + null, + new int[] { 2500 }, + 20 * 300 * 100, + 1020 * 4, + 500 * 20); // PO Special Value + + // Strontium u235 + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.uranium235", 10), + new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, + null, + new int[] { 570 }, + 20 * 300 * 100, + 1020 * 4, + 500 * 20); // PO Special Value + + // Strontium u233 + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.uranium233", 10), + new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, + null, + new int[] { 660 }, + 20 * 300 * 100, + 1020 * 4, + 500 * 20); // PO Special Value + + // Strontium pu239 + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.plutonium", 10), + new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, + null, + new int[] { 220 }, + 20 * 300 * 100, + 1020 * 4, + 500 * 20); // PO Special Value + + // Plutonium + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.plutonium238", 1), + new ItemStack[] { GregtechItemList.Pellet_RTG_PU238.get(2) }, + null, + new int[] { 780 }, + 20 * 300 * 100, + 1020 * 4, + 500 * 20); // PO Special Value + + // Neptunium + CORE.RA.addCyclotronRecipe( + new ItemStack[] { ELEMENT.getInstance().URANIUM238.getDust(1) }, + FluidUtils.getFluidStack("deuterium", 400), + new ItemStack[] { ItemUtils.getSimpleStack(ModItems.dustNeptunium238) }, + null, + new int[] { 500 }, + 20 * 5, + 500 * 4, + 500 * 20); // PO Special Value + + /* + * Particle Science + */ + + // Quark Smash + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(3), + FluidUtils.getFluidStack("plasma.hydrogen", 100), + new ItemStack[] { Particle.getBaseParticle(Particle.UP), Particle.getBaseParticle(Particle.DOWN), + Particle.getBaseParticle(Particle.CHARM), Particle.getBaseParticle(Particle.STRANGE), + Particle.getBaseParticle(Particle.TOP), Particle.getBaseParticle(Particle.BOTTOM), }, + null, + new int[] { 50, 50, 50, 50, 50, 50 }, + 20 * 300 * 9, + (int) MaterialUtils.getVoltageForTier(7), + 750 * 20); + + // Lepton Smash + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(6), + FluidUtils.getFluidStack("plasma.helium", 1500), + new ItemStack[] { Particle.getBaseParticle(Particle.ELECTRON), Particle.getBaseParticle(Particle.MUON), + Particle.getBaseParticle(Particle.TAU), Particle.getBaseParticle(Particle.ELECTRON_NEUTRINO), + Particle.getBaseParticle(Particle.MUON_NEUTRINO), Particle.getBaseParticle(Particle.TAU_NEUTRINO), }, + null, + new int[] { 600, 40, 20, 15, 10, 5 }, + 20 * 300 * 8, + (int) MaterialUtils.getVoltageForTier(7), + 750 * 20); + + // Boson Smash + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(9), + FluidUtils.getFluidStack("plasma.helium", 1500), + new ItemStack[] { Particle.getBaseParticle(Particle.GLUON), Particle.getBaseParticle(Particle.PHOTON), + Particle.getBaseParticle(Particle.Z_BOSON), Particle.getBaseParticle(Particle.W_BOSON), + Particle.getBaseParticle(Particle.HIGGS_BOSON), }, + null, + new int[] { 160, 260, 150, 150, 1 }, + 20 * 300 * 6, + (int) MaterialUtils.getVoltageForTier(7), + 750 * 20); + + // Mixed Smash 1 + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(12), + Materials.Americium.getPlasma(2500), + new ItemStack[] { Particle.getBaseParticle(Particle.GRAVITON), Particle.getBaseParticle(Particle.ETA_MESON), + Particle.getBaseParticle(Particle.PION), Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.NEUTRON), Particle.getBaseParticle(Particle.LAMBDA), + Particle.getBaseParticle(Particle.OMEGA), Particle.getBaseParticle(Particle.HIGGS_BOSON), }, + null, + new int[] { 50, 50, 50, 40, 30, 20, 20, 10 }, + 1000 * 20, + (int) MaterialUtils.getVoltageForTier(8), + 750 * 20); + + // Mixed Smash 1 + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(12), + new FluidStack(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.getPlasma(), 2500), + new ItemStack[] { Particle.getBaseParticle(Particle.GRAVITON), Particle.getBaseParticle(Particle.ETA_MESON), + Particle.getBaseParticle(Particle.PION), Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.NEUTRON), Particle.getBaseParticle(Particle.LAMBDA), + Particle.getBaseParticle(Particle.OMEGA), Particle.getBaseParticle(Particle.HIGGS_BOSON), }, + null, + new int[] { 5000, 200, 200, 100, 80, 60, 40, 30 }, + 100 * 20, + (int) MaterialUtils.getVoltageForTier(8), + 750 * 20); + + // Graviton Smash + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(15), + FluidUtils.getFluidStack("plasma.hydrogen", 100), + new ItemStack[] { Particle.getBaseParticle(Particle.GRAVITON), Particle.getBaseParticle(Particle.UNKNOWN) }, + null, + new int[] { 1000, 100 }, + 20 * (90), + (int) MaterialUtils.getVoltageForTier(6), + 1000 * 20); + + FluidStack aPlasma = Materials.Duranium.getMolten(40); + FluidStack aPlasma_NULL = Materials._NULL.getPlasma(1); + + if (aPlasma == null || aPlasma.isFluidEqual(aPlasma_NULL)) { + aPlasma = Materials.Americium.getMolten(20); + } + + // Quantum Anomaly + CORE.RA.addCyclotronRecipe( + new ItemStack[] { CI.getNumberedCircuit(24), Particle.getBaseParticle(Particle.UNKNOWN), }, + aPlasma, + new ItemStack[] { GregtechItemList.Laser_Lens_Special.get(1) }, + null, + new int[] { 100 }, + 20 * (25), + (int) MaterialUtils.getVoltageForTier(8), + 500 * 20); + + /* + * Ions + */ + + int IonCount = 2; + int tenCountA = 2; + int tenCountB = 0; + for (String y : IonParticles.MetaToNameMap.values()) { + if (y.toLowerCase() + .contains("hydrogen")) { + continue; + } + FluidStack aPlasma2 = FluidUtils.getFluidStack("plasma." + y.toLowerCase(), 2); + Materials aTestMat = MaterialUtils.getMaterial(y); + FluidStack aPlasma3 = aTestMat != null ? aTestMat.getPlasma(2) : aPlasma2; + + // Ionize Plasma + if ((aPlasma2 != null && !aPlasma2.isFluidEqual(aPlasma_NULL)) + || (aPlasma3 != null && !aPlasma3.isFluidEqual(aPlasma_NULL))) { + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1 + (tenCountA - 1)), + aPlasma2 != null ? aPlasma2 : aPlasma3, + new ItemStack[] { Particle.getIon(y, 1), Particle.getIon(y, 2), Particle.getIon(y, 3), + Particle.getIon(y, -1), Particle.getIon(y, -2), Particle.getIon(y, -3), Particle.getIon(y, 1), + Particle.getIon(y, 2), Particle.getIon(y, -1), }, + null, + new int[] { 275, 250, 225, 275, 250, 225, 275, 250, 275 }, + 20 * 20 * (IonCount++) * tenCountA, + (int) MaterialUtils.getVoltageForTier(7), + 1500 * 20 * tenCountA); + } else { + Logger.INFO("Plasma for " + y + " does not exist, please report this to Alkalus."); + } + + if (tenCountB == 12) { + tenCountB = 0; + tenCountA++; + } else { + tenCountB++; + } + } + + // Generate Hydrogen Ion Recipe + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(24), + FluidUtils.getWildcardFluidStack("hydrogen", 1000), + new ItemStack[] { Particle.getIon("Hydrogen", 1), Particle.getIon("Hydrogen", 2), + Particle.getIon("Hydrogen", 3), Particle.getIon("Hydrogen", 1), Particle.getIon("Hydrogen", 2), + Particle.getIon("Hydrogen", 3), Particle.getIon("Hydrogen", -1), Particle.getIon("Hydrogen", -2), + Particle.getIon("Hydrogen", -3) }, + null, + new int[] { 500, 500, 500, 500, 500, 500, 500, 500, 500 }, + 20 * 20, + (int) MaterialUtils.getVoltageForTier(6), + 2500); + + // Generate Hydrogen Plasma Recipe + CORE.RA.addCyclotronRecipe( + new ItemStack[] { CI.getNumberedCircuit(21), Particle.getIon("Hydrogen", 0), }, + FluidUtils.getFluidStack("hydrogen", 1000), + new ItemStack[] { Particle.getBaseParticle(Particle.PROTON), Particle.getBaseParticle(Particle.NEUTRON), + Particle.getBaseParticle(Particle.ELECTRON), Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), Particle.getBaseParticle(Particle.UNKNOWN), }, + FluidUtils.getFluidStack("plasma.hydrogen", 100), + new int[] { 1250, 1250, 1250, 750, 750, 750 }, + 20 * 60 * 2, + (int) MaterialUtils.getVoltageForTier(6), + 750 * 20); + + // Generate Protons Easily + CORE.RA.addCyclotronRecipe( + new ItemStack[] { CI.getNumberedCircuit(20), Particle.getIon("Hydrogen", 0) }, + FluidUtils.getWildcardFluidStack("hydrogen", 100), + new ItemStack[] { Particle.getBaseParticle(Particle.PROTON), Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), }, + null, + new int[] { 750, 750, 750, 750, 750, 750, 750, 750, 750 }, + 20 * 20, + (int) MaterialUtils.getVoltageForTier(6), + 1500); + + CORE.RA.addCyclotronRecipe( + new ItemStack[] { CI.getNumberedCircuit(22), Particle.getBaseParticle(Particle.UNKNOWN), }, + FluidUtils.getWildcardFluidStack("hydrogen", 100), + new ItemStack[] { Particle.getBaseParticle(Particle.PROTON), Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), }, + null, + new int[] { 375, 375, 375, 375, 375, 375, 375, 375, 375 }, + 20 * 20, + (int) MaterialUtils.getVoltageForTier(6), + 1500); + + // Create Strange Dust + CORE.RA.addCyclotronRecipe( + new ItemStack[] { ELEMENT.getInstance().PLUTONIUM238.getDust(1), Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), }, + FluidUtils.getFluidStack(FluidUtils.getWildcardFluidStack("ender", 1000), 1000), + new ItemStack[] { ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT.getDust(1) }, + null, + new int[] { 2500 }, + 20 * 60 * 15, + (int) MaterialUtils.getVoltageForTier(7), + 250); + } +} diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_General.java new file mode 100644 index 0000000000..5e198bfac4 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -0,0 +1,475 @@ +package gtPlusPlus.core.recipe; + +import static gregtech.api.enums.Mods.EnderIO; +import static gregtech.api.enums.Mods.Thaumcraft; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +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 net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.Material; +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.common.helpers.VolumetricFlaskHelper; + +public class RECIPES_General { + + static final ItemStack NULL = null; + static ItemStack RECIPE_Paper; + static ItemStack RECIPE_Dirt; + static ItemStack RECIPE_Snow; + static ItemStack RECIPE_Obsidian; + static String RECIPE_LapisDust = "dustLazurite"; + static ItemStack OUTPUT_Blueprint; + static ItemStack RECIPE_CraftingTable; + static ItemStack RECIPE_BasicCasingIC2; + + public static void loadRecipes() { + RECIPE_Paper = ItemUtils.getSimpleStack(Items.paper); + RECIPE_Dirt = ItemUtils.getSimpleStack(Blocks.dirt); + RECIPE_Snow = ItemUtils.getSimpleStack(Blocks.snow); + RECIPE_Obsidian = ItemUtils.getSimpleStack(Blocks.obsidian); + RECIPE_CraftingTable = ItemUtils.getSimpleStack(Blocks.crafting_table); + RECIPE_BasicCasingIC2 = ItemUtils.getItemStackFromFQRN("IC2:blockMachine", 1); + OUTPUT_Blueprint = ItemUtils.getSimpleStack(ModItems.itemBlueprintBase, 2); + run(); + addCompressedObsidian(); + migratedRecipes(); + } + + private static void run() { + // Workbench Blueprint + RecipeUtils.addShapedRecipe( + RECIPE_Paper, + RECIPE_LapisDust, + NULL, + RECIPE_Paper, + RECIPE_LapisDust, + NULL, + RECIPE_LapisDust, + RECIPE_LapisDust, + NULL, + OUTPUT_Blueprint); + + // Rainforest oak Sapling + if (RecipeUtils.addShapedRecipe( + "stickWood", + "stickWood", + "stickWood", + "stickWood", + "treeSapling", + "stickWood", + "stickWood", + "dustBone", + "stickWood", + ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest))) { + Logger.INFO("Added a recipe for Rainforest oak Saplings."); + } + + // Iron bars + final ItemStack ironBars = ItemUtils.getItemStackFromFQRN("dreamcraft:item.SteelBars", 1); + + // Fish Trap + if (RecipeUtils.addShapedRecipe( + ironBars, + ironBars, + ironBars, + ironBars, + "frameGtWroughtIron", + ironBars, + ironBars, + ironBars, + ironBars, + ItemUtils.getSimpleStack(ModBlocks.blockFishTrap))) { + Logger.INFO("Added a recipe for the Fish Trap."); + } + + // 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))) { + Logger.INFO("Added shapeless recipe for Tumbaga Mix."); + } + if (RecipeUtils.addShapelessGregtechRecipe( + new Object[] { ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + "dustGold" }, + ALLOY.TUMBAGA.getDust(10))) { + Logger.INFO("Added shapeless recipe for Tumbaga Dust."); + } + + if (CORE.ConfigSwitches.enableMachine_Pollution) { + RecipeUtils.addShapedRecipe( + CI.craftingToolFile, + "plateIron", + "stickIron", + "plateIron", + "ringIron", + "plateIron", + "stickIron", + "plateIron", + CI.craftingToolHammer_Hard, + ItemUtils.simpleMetaStack(ModItems.itemBasicTurbine, 0, 1)); + RecipeUtils.addShapedRecipe( + CI.craftingToolFile, + "plateBronze", + "stickBronze", + "plateBronze", + "ringBronze", + "plateBronze", + "stickBronze", + "plateBronze", + CI.craftingToolHammer_Hard, + ItemUtils.simpleMetaStack(ModItems.itemBasicTurbine, 1, 1)); + RecipeUtils.addShapedRecipe( + CI.craftingToolFile, + "plateSteel", + "stickSteel", + "plateSteel", + "ringSteel", + "plateSteel", + "stickSteel", + "plateSteel", + CI.craftingToolHammer_Hard, + ItemUtils.simpleMetaStack(ModItems.itemBasicTurbine, 2, 1)); + } + + GT_Values.RA.stdBuilder() + .itemInputs( + ItemUtils.getSimpleStack(Blocks.glass, 16), + ItemUtils.getSimpleStack(Blocks.glowstone, 16), + ItemList.Large_Fluid_Cell_Steel.get(1), + CI.getNumberedAdvancedCircuit(4)) + .itemOutputs(VolumetricFlaskHelper.getLargeVolumetricFlask(2)) + .fluidInputs(FluidUtils.getFluidStack("molten.borosilicateglass", 2000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + ItemUtils.getSimpleStack(Blocks.glass, 64), + ItemUtils.getSimpleStack(Blocks.glowstone, 64), + ItemList.Large_Fluid_Cell_TungstenSteel.get(1), + CI.getNumberedAdvancedCircuit(5)) + .itemOutputs(VolumetricFlaskHelper.getGiganticVolumetricFlask(2)) + .fluidInputs(FluidUtils.getFluidStack("molten.borosilicateglass", 8000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(assemblerRecipes); + + // Mining Explosive + Logger.RECIPE("[Inspection] Explosives"); + if (RecipeUtils.addShapedRecipe( + CI.explosiveITNT, + CI.explosiveTNT, + CI.explosiveITNT, + CI.explosiveTNT, + "frameGtIron", + CI.explosiveTNT, + "dustSulfur", + CI.explosiveTNT, + "dustSulfur", + ItemUtils.getSimpleStack(ModBlocks.blockMiningExplosive, 3))) { + Logger.INFO("Added a recipe for Mining Explosives."); + } + + // Alkalus Coin + if (RecipeUtils.addShapedRecipe( + "gemExquisiteRuby", + "gemFlawlessDiamond", + "gemExquisiteDiamond", + "gemFlawlessRuby", + ItemList.Credit_Greg_Osmium.get(1), + "gemFlawlessSapphire", + "gemExquisiteEmerald", + "gemFlawlessEmerald", + "gemExquisiteSapphire", + ItemUtils.getSimpleStack(ModItems.itemAlkalusDisk))) { + Logger.INFO("Added a recipe for The Alkalus Disk."); + } + + /* + * final String fancyGems[] = new String[]{"gemExquisiteDiamond", "gemExquisiteEmerald", "gemExquisiteRuby", + * "gemExquisiteSapphire"}; final ItemStack gemShards[] = new + * ItemStack[]{ItemUtils.simpleMetaStack(ModItems.itemGemShards, 0, 1), + * ItemUtils.simpleMetaStack(ModItems.itemGemShards, 1, 1), ItemUtils.simpleMetaStack(ModItems.itemGemShards, 2, + * 1), ItemUtils.simpleMetaStack(ModItems.itemGemShards, 3, 1)}; int l=0; for (final String gem : fancyGems){ + * GameRegistry.addShapelessRecipe( gemShards[l], ItemUtils.getItemStackOfAmountFromOreDict(gem, 1), new + * ItemStack(ModItems.itemAlkalusDisk, 1, OreDictionary.WILDCARD_VALUE)); l++; } + */ + + Logger.RECIPE("[Inspection] Wither Cage"); + if (RecipeUtils.addShapedRecipe( + "stickBlackSteel", + "plateTungstenSteel", + "stickBlackSteel", + "plateTungstenSteel", + getSimpleStack(Items.nether_star), + "plateTungstenSteel", + "stickBlackSteel", + "plateTungstenSteel", + "stickBlackSteel", + ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard, 32))) { + Logger.INFO("Added a recipe for Wither Cages."); + } + + // Magic Feather + GT_Values.RA.stdBuilder() + .itemInputs( + ItemUtils.getSimpleStack(Items.feather, 64), + ItemUtils.getSimpleStack(Blocks.emerald_block, 32), + ItemUtils.getSimpleStack(Blocks.diamond_block, 32), + Materials.Ruby.getBlocks(32), + Materials.Sapphire.getBlocks(32), + ItemUtils.getSimpleStack(Blocks.gold_block, 32)) + .itemOutputs(ItemUtils.getSimpleStack(ModItems.itemMagicFeather, 1)) + .fluidInputs(Materials.Silver.getMolten(32 * 144)) + .duration(2 * MINUTES) + .eut(TierEU.RECIPE_EV) + .addTo(assemblerRecipes); + + // Pest Killer + GT_Values.RA.stdBuilder() + .itemInputs( + CI.getTieredMachineCasing(1), + CI.getElectricPump(2, 1), + CI.getPlate(2, 4), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(0), 2), + CI.getNumberedCircuit(16)) + .itemOutputs(ItemUtils.getSimpleStack(ModBlocks.blockPestKiller)) + .fluidInputs(FluidUtils.getHotWater(500)) + .duration(1 * MINUTES) + .eut(TierEU.RECIPE_LV / 2) + .addTo(assemblerRecipes); + } + + private static boolean addCompressedObsidian() { + // Invert Obsidian + ItemStack aInvertedObsidian = ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1); + if (RecipeUtils.addShapedRecipe( + getSimpleStack(Items.redstone), + getSimpleStack(Items.glowstone_dust), + getSimpleStack(Items.redstone), + getSimpleStack(Items.glowstone_dust), + ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 1, 1), + getSimpleStack(Items.glowstone_dust), + getSimpleStack(Items.redstone), + getSimpleStack(Items.glowstone_dust), + getSimpleStack(Items.redstone), + aInvertedObsidian)) { + Logger.INFO("Added a recipe for Inverted Obsidian."); + } + + final ItemStack[] mItems = new ItemStack[6]; + mItems[0] = ItemUtils.getSimpleStack(Blocks.obsidian); + for (int r = 0; r < 5; r++) { + mItems[r + 1] = ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, r, 1); + } + + final ItemStack[] mItems2 = new ItemStack[6]; + mItems2[0] = ItemUtils.getSimpleStack(Blocks.glowstone); + for (int r = 0; r < 5; r++) { + mItems2[r + 1] = ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 6 + r, 1); + } + + // Compressed Obsidian 1-5 + for (int r = 0; r < 5; r++) { + + final ItemStack input = mItems[r]; + final ItemStack output = mItems[r + 1]; + + if (RecipeUtils.addShapedRecipe(input, input, input, input, input, input, input, input, input, output)) { + Logger.INFO("Added a recipe for Compressed Obsidian [" + r + "]"); + } + + if (RecipeUtils + .addShapelessGregtechRecipe(new ItemStack[] { output }, ItemUtils.getSimpleStack(input, 9))) { + Logger.INFO("Added a shapeless recipe for Compressed Obsidian [" + r + "]"); + } + } + + // Compressed Glowstone 1-5 + for (int r = 0; r < 5; r++) { + + final ItemStack input = mItems2[r]; + final ItemStack output = mItems2[r + 1]; + + if (RecipeUtils.addShapedRecipe( + input, + input, + input, + input, + r == 2 ? aInvertedObsidian : input, + input, + input, + input, + input, + output)) { + Logger.INFO("Added a recipe for Compressed Glowstone [" + r + "]"); + } + + if (RecipeUtils + .addShapelessGregtechRecipe(new ItemStack[] { output }, ItemUtils.getSimpleStack(input, 9))) { + Logger.INFO("Added a shapeless recipe for Compressed Glowstone [" + r + "]"); + } + } + return true; + } + + private static void migratedRecipes() { + + RecipeUtils.generateMortarRecipe( + ItemUtils.getSimpleStack(ModItems.itemPlateRawMeat), + ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 1)); + + generateWireRecipes(ELEMENT.getInstance().ZIRCONIUM); + generateWireRecipes(ALLOY.HG1223); + generateWireRecipes(ALLOY.LEAGRISIUM); + generateWireRecipes(ALLOY.TRINIUM_TITANIUM); + generateWireRecipes(ELEMENT.STANDALONE.HYPOGEN); + generateWireRecipes(ELEMENT.STANDALONE.CHRONOMATIC_GLASS); + + // No Material for void, natch. + if (Thaumcraft.isModLoaded()) { + generatePipeRecipes(GT_Materials.Void.mDefaultLocalName, GT_Materials.Void.getMass(), 16); + } + + Material[] gtpp = new Material[] { ALLOY.STABALLOY, ALLOY.TANTALLOY_60, ALLOY.TANTALLOY_61, ALLOY.POTIN, + ALLOY.MARAGING300, ALLOY.MARAGING350, ALLOY.INCONEL_690, ALLOY.INCONEL_792, ALLOY.HASTELLOY_X, + ALLOY.TRINIUM_NAQUADAH_CARBON }; + + for (Material mat : gtpp) { + // generatePipeRecipes multiplies the voltage multiplier by 8 because ??! reasons. + generatePipeRecipes(mat.getLocalizedName(), mat.getMass(), mat.vVoltageMultiplier / 8); + } + + Materials[] h = new Materials[] { Materials.Europium, Materials.Tungsten, Materials.DarkSteel, Materials.Clay, + Materials.Lead, }; + + for (Materials e : h) { + if (e == Materials.DarkSteel) { + if (!EnderIO.isModLoaded()) { + continue; + } + } + int tVoltageMultiplier = (e.mBlastFurnaceTemp >= 2800) ? 64 : 16; + generatePipeRecipes(e.mDefaultLocalName, e.getMass(), tVoltageMultiplier); + } + + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[6], + ALLOY.MARAGING250.getGear(1), + CI.component_Plate[6], + CI.getTieredCircuitOreDictName(4), + GregtechItemList.Casing_AdvancedVacuum.get(1), + CI.getTieredCircuitOreDictName(4), + CI.component_Plate[5], + ItemList.Hatch_Input_IV.get(1), + CI.component_Plate[5], + GregtechItemList.Hatch_Input_Cryotheum.get(1L)); + + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[6], + ALLOY.MARAGING300.getGear(1), + CI.component_Plate[6], + CI.getTieredCircuitOreDictName(5), + GregtechItemList.Casing_Adv_BlastFurnace.get(1), + CI.getTieredCircuitOreDictName(5), + CI.component_Plate[6], + ItemList.Hatch_Input_IV.get(1), + CI.component_Plate[6], + GregtechItemList.Hatch_Input_Pyrotheum.get(1L)); + + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[8], + ALLOY.PIKYONIUM.getGear(1), + CI.component_Plate[9], + CI.getTieredCircuitOreDictName(7), + GregtechItemList.Casing_Naq_Reactor_A.get(1), + CI.getTieredCircuitOreDictName(7), + CI.component_Plate[9], + ItemList.Hatch_Input_ZPM.get(1), + CI.component_Plate[8], + GregtechItemList.Hatch_Input_Naquadah.get(1L, new Object[0])); + + 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) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_MV.get(1L, new Object[0]), + bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MV.get(1), + Character.valueOf('P'), GregtechItemList.Pollution_Cleaner_MV.get(1) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_HV.get(1L, new Object[0]), + bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_HV.get(1), + Character.valueOf('P'), GregtechItemList.Pollution_Cleaner_HV.get(1) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_EV.get(1L, new Object[0]), + bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_EV.get(1), + Character.valueOf('P'), GregtechItemList.Pollution_Cleaner_EV.get(1) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_IV.get(1L, new Object[0]), + bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_IV.get(1), + Character.valueOf('P'), GregtechItemList.Pollution_Cleaner_IV.get(1) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_LuV.get(1L, new Object[0]), + bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LuV.get(1), + Character.valueOf('P'), GregtechItemList.Pollution_Cleaner_LuV.get(1) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_ZPM.get(1L, new Object[0]), + bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_ZPM.get(1), + Character.valueOf('P'), GregtechItemList.Pollution_Cleaner_ZPM.get(1) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_UV.get(1L, new Object[0]), + bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_UV.get(1), + Character.valueOf('P'), GregtechItemList.Pollution_Cleaner_UV.get(1) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_MAX.get(1L, new Object[0]), + bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MAX.get(1), + Character.valueOf('P'), GregtechItemList.Pollution_Cleaner_MAX.get(1) }); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_LaserEngraver.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_LaserEngraver.java new file mode 100644 index 0000000000..1f8d5d9a8e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_LaserEngraver.java @@ -0,0 +1,135 @@ +package gtPlusPlus.core.recipe; + +import static gregtech.api.recipe.RecipeMaps.laserEngraverRecipes; +import static gregtech.api.util.GT_RecipeBuilder.HOURS; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OreDictNames; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.IOreRecipeRegistrator; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.everglades.dimension.Dimension_Everglades; + +public class RECIPES_LaserEngraver implements IOreRecipeRegistrator { + + public RECIPES_LaserEngraver() { + OrePrefixes.crafting.add(this); + } + + @Override + public void registerOre(final OrePrefixes aPrefix, final Materials aMaterial, final String aOreDictName, + final String aModName, final ItemStack aStack) { + if (aOreDictName.equals(OreDictNames.craftingLensWhite.toString())) { + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lithium, 2L), + GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(ItemUtils.getItemStackOfAmountFromOreDict("plateDoubleLithium7", 1)) + .duration(4 * MINUTES) + .eut(TierEU.RECIPE_EV) + .addTo(laserEngraverRecipes); + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lithium, 3L), + GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(ItemUtils.getItemStackOfAmountFromOreDict("dustLithium7", 1)) + .duration(2 * MINUTES) + .eut(TierEU.RECIPE_EV) + .addTo(laserEngraverRecipes); + + } else if (aOreDictName.equals(OreDictNames.craftingLensLime.toString())) { + // Coil Wires + ItemStack coilWire1 = ItemUtils + .getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire", "coilWire1", 0, 1); + ItemStack coilWire2 = ItemUtils + .getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:1", "coilWire2", 1, 1); + ItemStack coilWire3 = ItemUtils + .getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:2", "coilWire3", 2, 1); + ItemStack coilWire4 = ItemUtils + .getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:3", "coilWire4", 3, 1); + + // Simple Life + String wire = "wireGt02"; + + // Wires to Laser + ItemStack wireT1a = ItemUtils.getItemStackOfAmountFromOreDict(wire + "Aluminium", 1); + ItemStack wireT1b = ItemUtils.getItemStackOfAmountFromOreDict(wire + "Nichrome", 1); + ItemStack wireT2a = ItemUtils.getItemStackOfAmountFromOreDict(wire + "Osmium", 1); + ItemStack wireT2b = ItemUtils.getItemStackOfAmountFromOreDict(wire + "Platinum", 1); + ItemStack wireT3a = ItemUtils.getItemStackOfAmountFromOreDict(wire + "VanadiumGallium", 1); + ItemStack wireT3b = ItemUtils.getItemStackOfAmountFromOreDict(wire + "YttriumBariumCuprate", 1); + ItemStack wireT3c = ItemUtils.getItemStackOfAmountFromOreDict(wire + "NiobiumTitanium", 1); + ItemStack wireT4a = ItemUtils.getItemStackOfAmountFromOreDict(wire + "Naquadah", 1); + + // T1 + GT_Values.RA.stdBuilder() + .itemInputs(wireT1a, GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(coilWire1) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(laserEngraverRecipes); + GT_Values.RA.stdBuilder() + .itemInputs(wireT1b, GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(coilWire1) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(laserEngraverRecipes); + // T2 + GT_Values.RA.stdBuilder() + .itemInputs(wireT2a, GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(coilWire2) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(laserEngraverRecipes); + GT_Values.RA.stdBuilder() + .itemInputs(wireT2b, GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(coilWire2) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(laserEngraverRecipes); + // T3 + GT_Values.RA.stdBuilder() + .itemInputs(wireT3a, GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(coilWire3) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(laserEngraverRecipes); + GT_Values.RA.stdBuilder() + .itemInputs(wireT3b, GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(coilWire3) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(laserEngraverRecipes); + GT_Values.RA.stdBuilder() + .itemInputs(wireT3c, GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(coilWire3) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(laserEngraverRecipes); + // T4 + GT_Values.RA.stdBuilder() + .itemInputs(wireT4a, GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(coilWire4) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .addTo(laserEngraverRecipes); + + } else if (aOreDictName.equals(OreDictNames.craftingLensOrange.toString())) { + GT_Values.RA.stdBuilder() + .itemInputs(ItemUtils.getSimpleStack(ModItems.itemAlkalusDisk), GT_Utility.copyAmount(0L, aStack)) + .itemOutputs(ItemUtils.getSimpleStack(Dimension_Everglades.portalItem)) + .duration(3 * HOURS) + .eut(TierEU.RECIPE_IV) + .addTo(laserEngraverRecipes); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java new file mode 100644 index 0000000000..4929872caa --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.recipe; + +public class RECIPES_MachineComponents { + + // Fluid Pipe + public static String pipeTier7 = "pipeHugeSteel"; + public static String pipeTier8 = "pipeHugeStainlessSteel"; + public static String pipeTier9 = "pipeHugeTitanium"; + +} diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java new file mode 100644 index 0000000000..2f9e347b52 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -0,0 +1,2960 @@ +package gtPlusPlus.core.recipe; + +import static gregtech.api.enums.Mods.BartWorks; +import static gregtech.api.enums.Mods.EternalSingularity; +import static gregtech.api.enums.Mods.GoodGenerator; +import static gregtech.api.enums.Mods.GregTech; +import static gregtech.api.enums.Mods.Railcraft; +import static gregtech.api.enums.Mods.RemoteIO; + +import java.util.List; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import com.github.technus.tectech.recipe.TT_recipeAdder; +import com.github.technus.tectech.thing.CustomItemList; +import com.google.common.collect.ImmutableList; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.item.crafting.ItemDummyResearch; +import gtPlusPlus.core.item.crafting.ItemDummyResearch.ASSEMBLY_LINE_RESEARCH; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +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.helpers.VolumetricFlaskHelper; + +public class RECIPES_Machines { + + // Outputs + public static ItemStack RECIPE_Buffer_ULV = GregtechItemList.Energy_Buffer_1by1_ULV.get(1); + public static ItemStack RECIPE_Buffer_LV = GregtechItemList.Energy_Buffer_1by1_LV.get(1); + public static ItemStack RECIPE_Buffer_MV = GregtechItemList.Energy_Buffer_1by1_MV.get(1); + public static ItemStack RECIPE_Buffer_HV = GregtechItemList.Energy_Buffer_1by1_HV.get(1); + public static ItemStack RECIPE_Buffer_EV = GregtechItemList.Energy_Buffer_1by1_EV.get(1); + public static ItemStack RECIPE_Buffer_IV = GregtechItemList.Energy_Buffer_1by1_IV.get(1); + public static ItemStack RECIPE_Buffer_LuV = GregtechItemList.Energy_Buffer_1by1_LuV.get(1); + public static ItemStack RECIPE_Buffer_ZPM = GregtechItemList.Energy_Buffer_1by1_ZPM.get(1); + public static ItemStack RECIPE_Buffer_UV = GregtechItemList.Energy_Buffer_1by1_UV.get(1); + public static ItemStack RECIPE_Buffer_MAX = GregtechItemList.Energy_Buffer_1by1_MAX.get(1); + // Industrial Centrifuge + public static ItemStack RECIPE_IndustrialCentrifugeController; + public static ItemStack RECIPE_IndustrialCentrifugeCasing; + // Industrial Coke Oven + public static ItemStack RECIPE_IndustrialCokeOvenController; + public static ItemStack RECIPE_IndustrialCokeOvenFrame; + public static ItemStack RECIPE_IndustrialCokeOvenCasingA; + public static ItemStack RECIPE_IndustrialCokeOvenCasingB; + // Industrial Electrolyzer + public static ItemStack RECIPE_IndustrialElectrolyzerController; + public static ItemStack RECIPE_IndustrialElectrolyzerFrame; + // Industrial Material Press + public static ItemStack RECIPE_IndustrialMaterialPressController; + public static ItemStack RECIPE_IndustrialMaterialPressFrame; + // Industrial Maceration Stack + public static ItemStack RECIPE_IndustrialMacerationStackController; + public static ItemStack RECIPE_IndustrialMacerationStackFrame; + // Industrial Wire Factory + public static ItemStack RECIPE_IndustrialWireFactoryController; + public static ItemStack RECIPE_IndustrialWireFactoryFrame; + // Industrial Multi Tank + public static ItemStack RECIPE_IndustrialMultiTankController; + public static ItemStack RECIPE_IndustrialMultiTankFrame; + // Industrial Matter Fabricator + public static ItemStack RECIPE_IndustrialMatterFabController; + public static ItemStack RECIPE_IndustrialMatterFabFrame; + public static ItemStack RECIPE_IndustrialMatterFabCoil; + // Industrial Blast Smelter + public static ItemStack RECIPE_IndustrialBlastSmelterController; + public static ItemStack RECIPE_IndustrialBlastSmelterFrame; + public static ItemStack RECIPE_IndustrialBlastSmelterCoil; + // Industrial Sieve + public static ItemStack RECIPE_IndustrialSieveController; + public static ItemStack RECIPE_IndustrialSieveFrame; + public static ItemStack RECIPE_IndustrialSieveGrate; + // Industrial Tree Farmer + public static ItemStack RECIPE_TreeFarmController; + public static ItemStack RECIPE_TreeFarmFrame; + // Tesseracts + public static ItemStack RECIPE_TesseractGenerator; + public static ItemStack RECIPE_TesseractTerminal; + // Thermal Boiler + public static ItemStack RECIPE_ThermalBoilerController; + public static ItemStack RECIPE_ThermalBoilerCasing; + + // Thorium Reactor + public static ItemStack RECIPE_LFTRController; + public static ItemStack RECIPE_LFTROuterCasing; + public static ItemStack RECIPE_LFTRInnerCasing; + + // Nuclear Salt Processing Plant + public static ItemStack RECIPE_SaltPlantController; + + // Cyclotron + public static ItemStack RECIPE_CyclotronController; + public static ItemStack RECIPE_CyclotronOuterCasing; + public static ItemStack RECIPE_CyclotronInnerCoil; + + // Wire + public static String cableTier4 = "cableGt04Gold"; + public static String cableTier6 = "cableGt04Tungsten"; + + public static String pipeTier1 = "pipeHuge" + "Clay"; + public static String pipeTier2 = "pipeHuge" + "Potin"; + public static String pipeTier3 = "pipeHuge" + "Steel"; + public static String pipeTier4 = "pipeHuge" + "StainlessSteel"; + public static String pipeTier7 = "pipeHuge" + "Tantalloy60"; + + // EV/IV MACHINES + public static ItemStack IV_MACHINE_Electrolyzer; + public static ItemStack EV_MACHINE_Centrifuge; + public static ItemStack EV_MACHINE_BendingMachine; + public static ItemStack IV_MACHINE_Wiremill; + public static ItemStack EV_MACHINE_Macerator; + public static ItemStack IV_MACHINE_Macerator; + public static ItemStack IV_MACHINE_Cutter; + public static ItemStack IV_MACHINE_Extruder; + public static ItemStack HV_MACHINE_Sifter; + public static ItemStack EV_MACHINE_ThermalCentrifuge; + public static ItemStack EV_MACHINE_OreWasher; + public static ItemStack IV_MACHINE_AlloySmelter; + public static ItemStack IV_MACHINE_Mixer; + public static ItemStack EV_MACHINE_ChemicalBath; + + // Plates + public static String plateBronze = "plateBronze"; + public static String plateSteel = "plateSteel"; + + // Pipes + public static String pipeHugeStainlessSteel = "pipeHugeStainlessSteel"; + + // Lava Boiler + public static ItemStack boiler_Coal; + public static ItemStack IC2MFE; + public static ItemStack IC2MFSU; + + // Misc + public static ItemStack INPUT_RCCokeOvenBlock; + + public static final void loadRecipes() { + run(); + Logger.INFO("Loading Recipes for the Various machine blocks."); + } + + private static void run() { + + initModItems(); + tieredMachineHulls(); + energyCores(); + wirelessChargers(); + largeArcFurnace(); + industrialVacuumFurnace(); + fakeMachineCasingCovers(); + overflowValveCovers(); + superBuses(); + distillus(); + algaeFarm(); + chemPlant(); + zyngen(); + milling(); + sparging(); + chisels(); + rockBreaker(); + thermicFluidHeater(); + advHeatExchanger(); + chiselBuses(); + solidifierHatches(); + + gt4FarmManager(); + gt4Inventory(); + + multiForgeHammer(); + multiMolecularTransformer(); + multiXlTurbines(); + multiSolarTower(); + multiElementalDuplicator(); + + resonanceChambers(); + modulators(); + } + + private static void thermicFluidHeater() { + + RecipeUtils.addShapedGregtechRecipe( + CI.getPlate(5, 1), + CI.circuitTier5, + CI.getPlate(5, 1), + pipeTier7, + ItemList.Machine_IV_FluidHeater.get(1), + pipeTier7, + CI.getPlate(5, 1), + CI.circuitTier4, + CI.getPlate(5, 1), + GregtechItemList.Controller_IndustrialFluidHeater.get(1)); + } + + private static void advHeatExchanger() { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.Machine_Multi_HeatExchanger.get(1), + CI.getDoublePlate(6, 8), CI.getScrew(6, 16), CI.getCircuit(5, 8) }, + CI.tieredMaterials[5].getMolten(144 * 8), + GregtechItemList.XL_HeatExchanger.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(6)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.Casing_StableTitanium.get(1), + CI.getPlate(5, 4), CI.getScrew(5, 8), }, + CI.tieredMaterials[5].getMolten(144 * 2), + GregtechItemList.Casing_XL_HeatExchanger.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(6)); + } + + private static void gt4FarmManager() { + + ItemList[] aInputHatches = new ItemList[] { ItemList.Hatch_Input_LV, ItemList.Hatch_Input_MV, + ItemList.Hatch_Input_HV, ItemList.Hatch_Input_EV, ItemList.Hatch_Input_IV, ItemList.Hatch_Input_LuV, + ItemList.Hatch_Input_ZPM, ItemList.Hatch_Input_UV }; + GregtechItemList[] aOutputMachines = new GregtechItemList[] { GregtechItemList.GT4_Crop_Harvester_LV, + GregtechItemList.GT4_Crop_Harvester_MV, GregtechItemList.GT4_Crop_Harvester_HV, + GregtechItemList.GT4_Crop_Harvester_EV, GregtechItemList.GT4_Crop_Harvester_IV, + GregtechItemList.GT4_Crop_Harvester_LuV, GregtechItemList.GT4_Crop_Harvester_ZPM, + GregtechItemList.GT4_Crop_Harvester_UV }; + + int aTier = 1; + for (int i = 0; i < 8; i++) { + RecipeUtils.addShapedRecipe( + CI.getRobotArm(aTier, 1), + CI.getSensor(aTier, 1), + CI.getRobotArm(aTier, 1), + ItemUtils.getOrePrefixStack(OrePrefixes.toolHeadSense, CI.tieredMaterials[aTier], 1), + CI.getTieredMachineHull(aTier, 1), + ItemUtils.getOrePrefixStack(OrePrefixes.toolHeadSense, CI.tieredMaterials[aTier], 1), + CI.getTieredCircuitOreDictName(aTier), + aInputHatches[i].get(1), + CI.getTieredCircuitOreDictName(aTier), + aOutputMachines[i].get(1)); + aTier++; + } + } + + private static void gt4Inventory() { + + GregtechItemList[] aOutputElectricCraftingTable = new GregtechItemList[] { + GregtechItemList.GT4_Electric_Auto_Workbench_LV, GregtechItemList.GT4_Electric_Auto_Workbench_MV, + GregtechItemList.GT4_Electric_Auto_Workbench_HV, GregtechItemList.GT4_Electric_Auto_Workbench_EV, + GregtechItemList.GT4_Electric_Auto_Workbench_IV, GregtechItemList.GT4_Electric_Auto_Workbench_LuV, + GregtechItemList.GT4_Electric_Auto_Workbench_ZPM, GregtechItemList.GT4_Electric_Auto_Workbench_UV }; + + int aTier = 1; + for (int i = 0; i < 8; i++) { + RecipeUtils.addShapedRecipe( + ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), + ItemUtils.getSimpleStack(Blocks.crafting_table), + ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), + CI.getTieredCircuitOreDictName(aTier), + CI.getTieredMachineHull(aTier), + CI.getTieredCircuitOreDictName(aTier), + ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), + CI.getRobotArm(aTier, 1), + ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), + aOutputElectricCraftingTable[i].get(1)); + aTier++; + } + } + + private static void multiForgeHammer() { + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(CI.machineHull_IV, 2), ItemList.Machine_IV_Hammer.get(1), + CI.getPlate(4, 8), CI.getBolt(5, 32), ELEMENT.getInstance().ZIRCONIUM.getFineWire(32), + ItemUtils.getItemStackOfAmountFromOreDict("circuitElite", 4) }, + CI.getTieredFluid(4, 144 * 12), + GregtechItemList.Controller_IndustrialForgeHammer.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(5)); + + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Casing_IndustrialForgeHammer.get(1), + CI.bitsd, + new Object[] { "IBI", "HCH", "IHI", 'I', CI.getPlate(4, 1), 'B', ALLOY.BABBIT_ALLOY.getPlate(1), 'C', + ItemList.Casing_HeatProof.get(1), 'H', ALLOY.HASTELLOY_X.getRod(1) }); + } + + private static void multiMolecularTransformer() { + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getTieredGTPPMachineCasing(6, 1), CI.getPlate(5, 16), CI.getBolt(5, 32), + ALLOY.HG1223.getFineWire(64), CI.getEmitter(4, 8), + ItemUtils.getItemStackOfAmountFromOreDict("circuitMaster", 10) }, + CI.getTieredFluid(5, 144 * 16), + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_11_MOLECULAR_TRANSFORMER, 1), + 20 * 60, + MaterialUtils.getVoltageForTier(5)); + + CORE.RA.addAssemblylineRecipe( + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_11_MOLECULAR_TRANSFORMER, 1), + 20 * 60 * 30, + new Object[] { ALLOY.HG1223.getFineWire(64), ALLOY.HG1223.getFineWire(64), + ItemList.Electric_Motor_IV.get(16), ItemList.Energy_LapotronicOrb.get(16), + CI.getTieredComponent(OrePrefixes.cableGt12, 6, 16), CI.getTieredComponent(OrePrefixes.wireGt16, 5, 32), + ALLOY.ZERON_100.getFrameBox(4), ALLOY.ZIRCONIUM_CARBIDE.getPlateDouble(32), + ALLOY.BABBIT_ALLOY.getPlate(64), ALLOY.LEAGRISIUM.getGear(8), + new Object[] { CI.getTieredCircuitOreDictName(4), 64 }, + new Object[] { CI.getTieredCircuitOreDictName(5), 32 }, + new Object[] { CI.getTieredCircuitOreDictName(6), 16 }, + GregtechItemList.Laser_Lens_WoodsGlass.get(1), }, + new FluidStack[] { ALLOY.NITINOL_60.getFluidStack(144 * 9 * (2)), + ALLOY.INCOLOY_MA956.getFluidStack(144 * 9 * (8)), ALLOY.KANTHAL.getFluidStack(144 * 1 * (4)), }, + GregtechItemList.Controller_MolecularTransformer.get(1), + 20 * 60 * 10 * (1), + MaterialUtils.getVoltageForTier(6)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(16), CI.getPlate(6, 4), CI.getScrew(6, 8), + ELEMENT.getInstance().PALLADIUM.getFineWire(16), CI.getSensor(5, 2), + ItemUtils.getItemStackOfAmountFromOreDict("circuitElite", 4) }, + CI.getTieredFluid(5, 144 * 4), + GregtechItemList.Casing_Molecular_Transformer_1.get(1), + 20 * 20, + MaterialUtils.getVoltageForTier(5)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(16), CI.getPlate(5, 4), CI.getScrew(5, 8), + ItemList.Casing_Coil_Nichrome.get(2), CI.getFieldGenerator(3, 2), + ItemUtils.getItemStackOfAmountFromOreDict("circuitData", 8) }, + CI.getTieredFluid(5, 144 * 4), + GregtechItemList.Casing_Molecular_Transformer_2.get(1), + 20 * 20, + MaterialUtils.getVoltageForTier(5)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(16), ItemUtils.getSimpleStack(Blocks.glowstone, 16), + CI.getGear(5, 8), ELEMENT.getInstance().TITANIUM.getWire04(4), CI.getFieldGenerator(4, 2), + ItemUtils.getItemStackOfAmountFromOreDict("circuitData", 8) }, + CI.getTieredFluid(5, 144 * 4), + GregtechItemList.Casing_Molecular_Transformer_3.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(5)); + } + + private static void multiXlTurbines() { + + RecipeUtils.addShapedRecipe( + CI.getDoublePlate(4, 1), + CI.getElectricMotor(3, 1), + CI.getDoublePlate(4, 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellLubricant", 1), + ItemList.Casing_Gearbox_Titanium.get(1), + ItemUtils.getItemStackOfAmountFromOreDict("cellLubricant", 1), + CI.getDoublePlate(4, 1), + CI.getElectricMotor(3, 1), + CI.getDoublePlate(4, 1), + GregtechItemList.Casing_Turbine_Shaft.get(1)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.Casing_Turbine.get(1), CI.getPlate(4, 4), + CI.getScrew(4, 8), CI.getCircuit(4, 4), CI.getGear(3, 8) }, + CI.tieredMaterials[3].getMolten(144 * 8), + GregtechItemList.Hatch_Turbine_Rotor.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(4)); + + // Steam + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.Casing_Turbine.get(1), CI.getPlate(3, 4), + CI.getScrew(3, 8), }, + CI.tieredMaterials[2].getMolten(144 * 2), + GregtechItemList.Casing_Turbine_LP.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(3)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.LargeSteamTurbine.get(1), CI.getPlate(4, 8), + CI.getScrew(4, 16), CI.getGear(4, 4), CI.getCircuit(4, 8) }, + CI.tieredMaterials[4].getMolten(144 * 8), + GregtechItemList.Large_Steam_Turbine.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(4)); + + // Gas + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.Casing_Turbine1.get(1), CI.getPlate(4, 4), + CI.getScrew(4, 8), }, + CI.tieredMaterials[3].getMolten(144 * 2), + GregtechItemList.Casing_Turbine_Gas.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(4)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.LargeGasTurbine.get(1), CI.getPlate(5, 8), + CI.getScrew(5, 16), CI.getGear(5, 4), CI.getCircuit(5, 8) }, + CI.tieredMaterials[5].getMolten(144 * 8), + GregtechItemList.Large_Gas_Turbine.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(5)); + + // HP Steam + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.Casing_Turbine2.get(1), CI.getPlate(5, 4), + CI.getScrew(5, 8), }, + CI.tieredMaterials[4].getMolten(144 * 2), + GregtechItemList.Casing_Turbine_HP.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(5)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.LargeHPSteamTurbine.get(1), CI.getPlate(6, 8), + CI.getScrew(6, 16), CI.getGear(6, 4), CI.getCircuit(6, 8) }, + CI.tieredMaterials[6].getMolten(144 * 8), + GregtechItemList.Large_HPSteam_Turbine.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(6)); + + // Plasma + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.Casing_Turbine3.get(1), CI.getPlate(6, 4), + CI.getScrew(6, 8), }, + CI.tieredMaterials[5].getMolten(144 * 2), + GregtechItemList.Casing_Turbine_Plasma.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(6)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), ItemList.LargePlasmaTurbine.get(1), CI.getPlate(7, 8), + CI.getScrew(7, 16), CI.getGear(7, 4), CI.getCircuit(7, 8) }, + CI.tieredMaterials[7].getMolten(144 * 8), + GregtechItemList.Large_Plasma_Turbine.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(7)); + if (GoodGenerator.isModLoaded()) { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), + GT_ModHandler.getModItem(GoodGenerator.ID, "supercriticalFluidTurbineCasing", 1), + GT_ModHandler.getModItem(BartWorks.ID, "gt.bwMetaGeneratedplate", 4, 10101), + GT_ModHandler.getModItem(BartWorks.ID, "gt.bwMetaGeneratedscrew", 8, 10101) }, + FluidRegistry.getFluidStack("molten.adamantium alloy", 144 * 2), + GregtechItemList.Casing_Turbine_SC.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(6)); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(18), + GT_ModHandler.getModItem(GregTech.ID, "gt.blockmachines", 1, 32016), + GT_ModHandler.getModItem(BartWorks.ID, "gt.bwMetaGeneratedplate", 8, 10104), + GT_ModHandler.getModItem(BartWorks.ID, "gt.bwMetaGeneratedscrew", 16, 10104), + GT_ModHandler.getModItem(BartWorks.ID, "gt.bwMetaGeneratedgearGt", 4, 10104), CI.getCircuit(7, 8) }, + FluidRegistry.getFluidStack("molten.hikarium", 144 * 8), + GregtechItemList.Large_SCSteam_Turbine.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(7)); + } + } + + private static void multiSolarTower() { + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(17), CI.getTieredGTPPMachineCasing(3, 4), + ALLOY.MARAGING250.getPlate(8), ALLOY.MARAGING250.getBolt(8), ALLOY.MARAGING250.getScrew(8), + CI.getCircuit(5, 8) }, + CI.getTieredFluid(3, 144 * 16), + GregtechItemList.Industrial_Solar_Tower.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(4)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(17), ALLOY.MARAGING350.getFrameBox(1), + ALLOY.STAINLESS_STEEL.getPlate(4), ALLOY.MARAGING350.getScrew(8) }, + CI.getTieredFluid(3, 144 * 4), + GregtechItemList.Casing_SolarTower_Structural.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(3)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(17), ALLOY.MARAGING250.getFrameBox(1), + ALLOY.STAINLESS_STEEL.getPlate(4), ALLOY.MARAGING250.getBolt(16), + ELEMENT.getInstance().ALUMINIUM.getScrew(8) }, + CI.getTieredFluid(3, 144 * 4), + GregtechItemList.Casing_SolarTower_SaltContainment.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(3)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(17), ALLOY.MARAGING250.getFrameBox(1), + ALLOY.STEEL_BLACK.getPlate(4), ALLOY.MARAGING250.getScrew(8) }, + CI.getAlternativeTieredFluid(3, 144 * 4), + GregtechItemList.Casing_SolarTower_HeatContainment.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(3)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(17), CI.getTieredGTPPMachineCasing(2, 1), CI.getPlate(3, 2), + CI.getGear(3, 4), CI.getElectricMotor(3, 2), CI.getCircuit(3, 4) }, + CI.getTertiaryTieredFluid(3, 144 * 4), + GregtechItemList.Solar_Tower_Reflector.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(3)); + } + + private static void multiElementalDuplicator() { + + CORE.RA.addAssemblylineRecipe( + ItemList.Machine_IV_Replicator.get(1), + 20 * 60 * 60 * 12, + new Object[] { CI.getTieredMachineHull(7, 4), CI.getFieldGenerator(5, 16), CI.getElectricMotor(7, 16), + CI.getElectricPiston(7, 4), CI.getEnergyCore(6, 2), CI.getPlate(7, 16), CI.getScrew(7, 32), + CI.getBolt(6, 32), CI.getTieredComponent(OrePrefixes.rod, 6, 10), + new Object[] { CI.getTieredCircuitOreDictName(7), 20 }, ItemList.Tool_DataOrb.get(32), + GregtechItemList.Laser_Lens_Special.get(1) }, + new FluidStack[] { CI.getTieredFluid(7, 144 * 32), CI.getAlternativeTieredFluid(6, 144 * 16), + CI.getTertiaryTieredFluid(6, 144 * 16), ALLOY.BABBIT_ALLOY.getFluidStack(128 * 144), }, + GregtechItemList.Controller_ElementalDuplicator.get(1), + 20 * 60 * 60, + (int) MaterialUtils.getVoltageForTier(7)); + + CORE.RA.addAssemblylineRecipe( + GregtechItemList.Modulator_III.get(1), + 20 * 60 * 60 * 4, + new Object[] { CI.getTieredGTPPMachineCasing(7, 2), CI.getFieldGenerator(4, 4), CI.getEnergyCore(4, 2), + CI.getPlate(7, 8), CI.getScrew(6, 16), CI.getBolt(6, 16), CI.getTieredComponent(OrePrefixes.rod, 5, 16), + new Object[] { CI.getTieredCircuitOreDictName(6), 32 }, ItemList.Tool_DataOrb.get(32), }, + new FluidStack[] { CI.getTieredFluid(6, 144 * 16), CI.getAlternativeTieredFluid(5, 144 * 8), + CI.getTertiaryTieredFluid(5, 144 * 8), ALLOY.BABBIT_ALLOY.getFluidStack(64 * 144), }, + GregtechItemList.Hatch_Input_Elemental_Duplicator.get(1), + 20 * 60 * 60 * (2), + (int) MaterialUtils.getVoltageForTier(6)); + + CORE.RA.addAssemblylineRecipe( + GregtechItemList.ResonanceChamber_III.get(1), + 20 * 60 * 60 * 2, + new Object[] { CI.getTieredMachineHull(6, 5), CI.getFieldGenerator(3, 16), CI.getEnergyCore(2, 2), + CI.getPlate(7, 4), CI.getScrew(7, 4), CI.getBolt(6, 8), CI.getTieredComponent(OrePrefixes.rod, 5, 4), + new Object[] { CI.getTieredCircuitOreDictName(5), 4 }, ItemList.Tool_DataStick.get(4), }, + new FluidStack[] { CI.getTieredFluid(5, 144 * 16), CI.getAlternativeTieredFluid(4, 144 * 8), + CI.getTertiaryTieredFluid(4, 144 * 8), ALLOY.BABBIT_ALLOY.getFluidStack(16 * 144), }, + GregtechItemList.Casing_ElementalDuplicator.get(1), + 20 * 60 * (10), + (int) MaterialUtils.getVoltageForTier(6)); + } + + private static void resonanceChambers() { + int aFieldTier = 1; + int aCasingTier = 4; + for (int i = 0; i < 4; i++) { + RecipeUtils.addShapedRecipe( + CI.getDoublePlate(aCasingTier, 1), + CI.getFieldGenerator(aFieldTier, 1), + CI.getDoublePlate(aCasingTier, 1), + CI.getFieldGenerator(aFieldTier, 1), + CI.getTieredMachineCasing(aCasingTier), + CI.getFieldGenerator(aFieldTier, 1), + CI.getDoublePlate(aCasingTier, 1), + CI.getFieldGenerator(aFieldTier, 1), + CI.getDoublePlate(aCasingTier, 1), + ItemUtils.simpleMetaStack(ModBlocks.blockSpecialMultiCasings2, i, 1)); + aCasingTier++; + aFieldTier++; + } + } + + private static void modulators() { + int aCasingTier = 4; + for (int i = 4; i < 8; i++) { + RecipeUtils.addShapedRecipe( + CI.getTieredCircuitOreDictName(aCasingTier), + CI.getPlate(aCasingTier, 1), + CI.getTieredCircuitOreDictName(aCasingTier), + CI.getPlate(aCasingTier, 1), + CI.getTieredMachineCasing(aCasingTier), + CI.getPlate(aCasingTier, 1), + CI.getTieredCircuitOreDictName(aCasingTier), + CI.getPlate(aCasingTier, 1), + CI.getTieredCircuitOreDictName(aCasingTier), + ItemUtils.simpleMetaStack(ModBlocks.blockSpecialMultiCasings2, i, 1)); + aCasingTier++; + } + } + + private static void zyngen() { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(6), CI.getTieredMachineHull(4), + ItemList.Machine_IV_AlloySmelter.get(1), CI.getGear(3, 16), CI.getBolt(3, 64), CI.getPlate(4, 16) }, + CI.getAlternativeTieredFluid(4, 144 * 8), + GregtechItemList.Industrial_AlloySmelter.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(4)); + } + + private static void chemPlant() { + + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Casing_Machine_Custom_1.get(2L, new Object[0]), + CI.bits, + new Object[] { "PhP", "PFP", "PwP", 'P', OrePrefixes.plate.get(Materials.Bronze), 'F', + OrePrefixes.frameGt.get(Materials.Bronze) }); + + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Casing_Machine_Custom_2.get(2L, new Object[0]), + CI.bits, + new Object[] { "PPP", "hFw", "PPP", 'P', OrePrefixes.plate.get(Materials.Aluminium), 'F', + OrePrefixes.frameGt.get(Materials.Aluminium) }); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(19), CI.getTieredGTPPMachineCasing(2, 4), + CI.getTieredComponentOfMaterial(Materials.Aluminium, OrePrefixes.gearGt, 4), + CI.getTieredComponentOfMaterial(Materials.AnnealedCopper, OrePrefixes.plate, 16), + CI.getTieredComponentOfMaterial(Materials.Plastic, OrePrefixes.pipeLarge, 4), + CI.getTieredComponent(OrePrefixes.frameGt, 2, 4), }, + ALLOY.STEEL_BLACK.getFluidStack(2 * (144 * 4)), + GregtechItemList.ChemicalPlant_Controller.get(1), + 120 * 20, + MaterialUtils.getVoltageForTier(2)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(15), CI.getTieredGTPPMachineCasing(1, 2), + ItemList.Hatch_Input_Bus_MV.get(1), + CI.getTieredComponentOfMaterial(Materials.Bronze, OrePrefixes.gearGt, 8), + CI.getTieredComponentOfMaterial(Materials.Lead, OrePrefixes.plate, 48), + CI.getTieredComponentOfMaterial(Materials.SolderingAlloy, OrePrefixes.wireFine, 16), }, + ALLOY.BRONZE.getFluidStack(2 * (144 * 4)), + GregtechItemList.Bus_Catalysts.get(1), + 60 * 20, + MaterialUtils.getVoltageForTier(2)); + } + + private static void algaeFarm() { + + // Give the bad algae a use. + CORE.RA.addDistilleryRecipe( + ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, 32), + null, + null, + ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, 4), + 20 * 15, + 16, + false); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(21), CI.getTieredGTPPMachineCasing(0, 4), + CI.getTieredComponentOfMaterial(Materials.Aluminium, OrePrefixes.rod, 12), + CI.getTieredComponentOfMaterial(Materials.Wood, OrePrefixes.plate, 32), + CI.getTieredComponentOfMaterial(Materials.Steel, OrePrefixes.bolt, 16), + CI.getTieredComponentOfMaterial(Materials.Redstone, OrePrefixes.dust, 32), }, + ALLOY.POTIN.getFluidStack(2 * (144 * 4)), + GregtechItemList.AlgaeFarm_Controller.get(1), + 60 * 20, + MaterialUtils.getVoltageForTier(2)); + } + + private static void distillus() { + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(19), ItemList.Distillation_Tower.get(2), + GregtechItemList.GTPP_Casing_IV.get(16), CI.getTieredComponent(OrePrefixes.circuit, 6, 8) }, + new FluidStack[] { ALLOY.AQUATIC_STEEL.getFluidStack(144 * 32), ALLOY.BABBIT_ALLOY.getFluidStack(144 * 16), + ALLOY.BRONZE.getFluidStack(144 * 64), ALLOY.KANTHAL.getFluidStack(144 * 16), }, + new ItemStack[] { GregtechItemList.Machine_Adv_DistillationTower.get(1) }, + new FluidStack[] {}, + 20 * 600, + MaterialUtils.getVoltageForTier(6), + 5); + } + + private static void overflowValveCovers() { + ItemStack aOutputs[] = new ItemStack[] { GregtechItemList.Cover_Overflow_LV.get(1L), + GregtechItemList.Cover_Overflow_MV.get(1L), GregtechItemList.Cover_Overflow_HV.get(1L), + GregtechItemList.Cover_Overflow_EV.get(1L), GregtechItemList.Cover_Overflow_IV.get(1L), }; + + for (int tier = 1; tier < aOutputs.length + 1; tier++) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(19), CI.getElectricPump(tier, 2), + CI.getElectricMotor(tier, 2), CI.getPlate(tier, 4) }, + Materials.SolderingAlloy.getFluid(tier * (144)), + aOutputs[tier - 1].copy(), + 20 * 20, + MaterialUtils.getVoltageForTier(tier)); + } + } + + private static void tieredMachineHulls() { + + GregtechItemList[] aHulls = new GregtechItemList[] { GregtechItemList.GTPP_Casing_ULV, + GregtechItemList.GTPP_Casing_LV, GregtechItemList.GTPP_Casing_MV, GregtechItemList.GTPP_Casing_HV, + GregtechItemList.GTPP_Casing_EV, GregtechItemList.GTPP_Casing_IV, GregtechItemList.GTPP_Casing_LuV, + GregtechItemList.GTPP_Casing_ZPM, GregtechItemList.GTPP_Casing_UV, GregtechItemList.GTPP_Casing_UHV }; + + for (int i = 0; i < 10; i++) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(20), CI.getTieredMachineCasing(i), CI.getPlate(i, 8), + CI.getGear(i, 2), CI.getTieredComponent(OrePrefixes.cableGt02, i, 4), + CI.getTieredComponent(OrePrefixes.circuit, i, 2) }, + CI.getAlternativeTieredFluid(i, 144 * (i + 1) * 2), + aHulls[i].get(1), + 20 * 20, + MaterialUtils.getVoltageForTier(i)); + } + } + + private static void initModItems() { + IC2MFE = ItemUtils.getItemStackWithMeta(true, "IC2:blockElectric", "IC2_MFE", 1, 1); + IC2MFSU = ItemUtils.getItemStackWithMeta(true, "IC2:blockElectric", "IC2_MFSU", 2, 1); + + // Lava Boiler + boiler_Coal = ItemList.Machine_Bronze_Boiler.get(1); + + // IV/EV/HV MACHINES + IV_MACHINE_Electrolyzer = ItemList.Machine_IV_Electrolyzer.get(1); + EV_MACHINE_Centrifuge = ItemList.Machine_EV_Centrifuge.get(1); + EV_MACHINE_BendingMachine = ItemList.Machine_EV_Bender.get(1); + IV_MACHINE_Wiremill = ItemList.Machine_IV_Wiremill.get(1); + EV_MACHINE_Macerator = ItemList.Machine_EV_Macerator.get(1); + IV_MACHINE_Macerator = ItemList.Machine_IV_Macerator.get(1); + IV_MACHINE_Cutter = ItemList.Machine_IV_Cutter.get(1); + IV_MACHINE_Extruder = ItemList.Machine_IV_Extruder.get(1); + HV_MACHINE_Sifter = ItemList.Machine_HV_Sifter.get(1); + EV_MACHINE_ThermalCentrifuge = ItemList.Machine_EV_ThermalCentrifuge.get(1); + EV_MACHINE_OreWasher = ItemList.Machine_EV_OreWasher.get(1); + IV_MACHINE_AlloySmelter = ItemList.Machine_IV_AlloySmelter.get(1); + IV_MACHINE_Mixer = ItemList.Machine_IV_Mixer.get(1); + EV_MACHINE_ChemicalBath = ItemList.Machine_EV_ChemicalBath.get(1); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialCokeOven) { + if (Railcraft.isModLoaded()) { + // Misc + INPUT_RCCokeOvenBlock = ItemUtils + .getItemStackWithMeta(Railcraft.isModLoaded(), "Railcraft:machine.alpha", "Coke_Oven_RC", 7, 1); + } + } + runModRecipes(); + } + + private static void runModRecipes() { + // Computer Cube + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(CI.getDataOrb(), 4 * (1)), ItemList.Cover_Screen.get(4), + CI.machineHull_IV, ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), 2) }, + ELEMENT.getInstance().TANTALUM.getFluidStack(144 * 16), + GregtechItemList.Gregtech_Computer_Cube.get(1), + 60 * 20 * 3, + 8000); + + // Circuit programmer + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(CI.robotArm_LV, 4 * (1)), + ItemList.Cover_Controller.get(1, CI.electricMotor_MV), CI.machineHull_MV, + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(1), 2), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(2), 2) }, + ELEMENT.getInstance().IRON.getFluidStack(144 * 4), + ItemUtils.getSimpleStack(ModBlocks.blockCircuitProgrammer), + 60 * 10 * 1, + 30); + + // Lead Lined Chest + for (ItemStack plateRubber : OreDictionary.getOres("plateAnyRubber")) CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.machineHull_LV, GT_Utility.copyAmount(32, plateRubber), + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseLead", 9), + ItemUtils.getSimpleStack(Blocks.chest) }, + ELEMENT.getInstance().LEAD.getFluidStack(144 * 16), + ItemUtils.getSimpleStack(ModBlocks.blockDecayablesChest), + 60 * 10 * 3, + 60); + + // RTG + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getItemStackWithMeta(true, "IC2:blockGenerator:6", "IC2-RTG", 6, 1), + ALLOY.NITINOL_60.getPlate(8), ALLOY.MARAGING350.getGear(4), + ItemUtils.getSimpleStack(CI.fieldGenerator_EV, 8), + ItemUtils.getItemStackOfAmountFromOreDict("wireFinePlatinum", 32), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), 4) }, + ALLOY.NIOBIUM_CARBIDE.getFluidStack(144 * 16), + GregtechItemList.RTG.get(1), + 60 * 20 * 10, + 8000); + + // Super Jukebox + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.machineHull_LV, ItemUtils.getItemStackOfAmountFromOreDict("circuitBasic", 4), + ItemUtils.getItemStackOfAmountFromOreDict("plateTumbaga", 8), + ItemUtils.getSimpleStack(Blocks.jukebox) }, + ELEMENT.getInstance().COPPER.getFluidStack(144 * 2), + ItemUtils.getSimpleStack(ModBlocks.blockCustomJukebox), + 20 * 30, + 30); + + // Poo Collector + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.machineHull_MV, ItemList.FluidRegulator_MV.get(2), + CI.getTieredComponent(OrePrefixes.pipeMedium, 2, 2), ALLOY.EGLIN_STEEL.getPlate(4), + ALLOY.POTIN.getScrew(6) }, + ALLOY.TUMBAGA.getFluidStack(144 * 4), + ItemUtils.getSimpleStack(ModBlocks.blockPooCollector), + 20 * 60, + 30); + + // Adv. Poo Collector + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getTieredMachineHull(-1), ItemUtils.getSimpleStack(ModBlocks.blockPooCollector), + ItemList.FluidRegulator_IV.get(2), CI.getTieredComponent(OrePrefixes.pipeHuge, 6, 4), + CI.getTieredComponent(OrePrefixes.screw, 6, 16) }, + CI.getAlternativeTieredFluid(5, 144 * 9), + ItemUtils.getSimpleStack(ModBlocks.blockPooCollector, 8, 1), + 20 * 60 * 5, + 500); + + ItemStack aBronzeBricks = ItemUtils.simpleMetaStack(GregTech_API.sBlockCasings1, 10, 1); + // Steam Macerator Multi + RecipeUtils.addShapedGregtechRecipe( + aBronzeBricks, + "gemDiamond", + aBronzeBricks, + "craftingPiston", + ALLOY.TUMBAGA.getFrameBox(1), + "craftingPiston", + aBronzeBricks, + "gemDiamond", + aBronzeBricks, + GregtechItemList.Controller_SteamMaceratorMulti.get(1)); + // Steam Compressor Multi + RecipeUtils.addShapedGregtechRecipe( + aBronzeBricks, + "craftingPiston", + aBronzeBricks, + ALLOY.TUMBAGA.getGear(1), + ALLOY.TUMBAGA.getFrameBox(1), + ALLOY.TUMBAGA.getGear(1), + aBronzeBricks, + "craftingPiston", + aBronzeBricks, + GregtechItemList.Controller_SteamCompressorMulti.get(1)); + + // Steam Hatch + RecipeUtils.addShapedGregtechRecipe( + "plateBronze", + "pipeMediumBronze", + "plateBronze", + "plateBronze", + GregtechItemList.GT_FluidTank_ULV.get(1), + "plateBronze", + "plateBronze", + "pipeMediumBronze", + "plateBronze", + GregtechItemList.Hatch_Input_Steam.get(1)); + + // Steam Input Bus + RecipeUtils.addShapedGregtechRecipe( + "plateBronze", + ALLOY.TUMBAGA.getPlate(1), + "plateBronze", + "plateTin", + ItemUtils.getSimpleStack(Blocks.hopper), + "plateTin", + "plateBronze", + ALLOY.TUMBAGA.getPlate(1), + "plateBronze", + GregtechItemList.Hatch_Input_Bus_Steam.get(1)); + + // Steam Output Bus + RecipeUtils.addShapedGregtechRecipe( + "plateBronze", + "plateTin", + "plateBronze", + ALLOY.TUMBAGA.getPlate(1), + ItemUtils.getSimpleStack(Blocks.hopper), + ALLOY.TUMBAGA.getPlate(1), + "plateBronze", + "plateTin", + "plateBronze", + GregtechItemList.Hatch_Output_Bus_Steam.get(1)); + + // Flask Configurator + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(8), CI.getTieredMachineHull(2), + ItemUtils.getSimpleStack(ModBlocks.blockCircuitProgrammer), VolumetricFlaskHelper.getVolumetricFlask(8), + CI.getTieredComponent(OrePrefixes.pipeSmall, 2, 2), CI.getPlate(2, 4) }, + CI.getAlternativeTieredFluid(1, 144 * 8), + ItemUtils.getSimpleStack(ModBlocks.blockVolumetricFlaskSetter, 1), + 20 * 60, + 120); + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialCentrifuge) { + // Industrial Centrifuge + RECIPE_IndustrialCentrifugeController = GregtechItemList.Industrial_Centrifuge.get(1); + RECIPE_IndustrialCentrifugeCasing = GregtechItemList.Casing_Centrifuge1.get(1); + + // Industrial Centrifuge + RecipeUtils.addShapedGregtechRecipe( + CI.circuitTier4, + pipeHugeStainlessSteel, + CI.circuitTier4, + CI.component_Plate[6], + EV_MACHINE_Centrifuge, + CI.component_Plate[6], + CI.component_Plate[8], + CI.machineCasing_EV, + CI.component_Plate[8], + RECIPE_IndustrialCentrifugeController); + // Centrifuge Casing + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[6], + "stickTumbaga", + CI.component_Plate[6], + CI.component_Plate[8], + "stickTumbaga", + CI.component_Plate[8], + CI.component_Plate[6], + "stickTumbaga", + CI.component_Plate[6], + RECIPE_IndustrialCentrifugeCasing); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.MARAGING250.getPlate(4), ALLOY.INCONEL_792.getPlate(2), ALLOY.TUMBAGA.getRod(3), + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialCentrifugeCasing, + 50, + 16); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialCokeOven) { + // Industrial Coke Oven + RECIPE_IndustrialCokeOvenController = GregtechItemList.Industrial_CokeOven.get(1); + RECIPE_IndustrialCokeOvenFrame = GregtechItemList.Casing_CokeOven.get(1); + RECIPE_IndustrialCokeOvenCasingA = GregtechItemList.Casing_CokeOven_Coil1.get(1); + RECIPE_IndustrialCokeOvenCasingB = GregtechItemList.Casing_CokeOven_Coil2.get(1); + + if (Railcraft.isModLoaded()) { + // Industrial Coke Oven + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[7], + CI.circuitTier4, + CI.component_Plate[7], + CI.machineCasing_EV, + INPUT_RCCokeOvenBlock, + CI.machineCasing_EV, + CI.component_Plate[7], + CI.circuitTier4, + CI.component_Plate[7], + RECIPE_IndustrialCokeOvenController); + } + // Coke Oven Frame Casing + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[7], + CI.component_Rod[7], + CI.component_Plate[7], + CI.component_Rod[7], + "frameGtTantalloy61", + CI.component_Rod[7], + CI.component_Plate[7], + CI.component_Rod[7], + CI.component_Plate[7], + RECIPE_IndustrialCokeOvenFrame); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.TANTALLOY_61.getPlate(4), ALLOY.TANTALLOY_61.getRod(4), + ALLOY.TANTALLOY_61.getFrameBox(1), GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialCokeOvenFrame, + 50, + 16); + // Coke Oven Coil 1 + RecipeUtils.addShapedGregtechRecipe( + plateBronze, + plateBronze, + plateBronze, + "frameGtBronze", + CI.gearboxCasing_Tier_1, + "frameGtBronze", + plateBronze, + plateBronze, + plateBronze, + RECIPE_IndustrialCokeOvenCasingA); + // Coke Oven Coil 2 + RecipeUtils.addShapedGregtechRecipe( + plateSteel, + plateSteel, + plateSteel, + "frameGtSteel", + CI.gearboxCasing_Tier_2, + "frameGtSteel", + plateSteel, + plateSteel, + plateSteel, + RECIPE_IndustrialCokeOvenCasingB); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialElectrolyzer) { + // Industrial Electrolyzer + RECIPE_IndustrialElectrolyzerController = GregtechItemList.Industrial_Electrolyzer.get(1); + RECIPE_IndustrialElectrolyzerFrame = GregtechItemList.Casing_Electrolyzer.get(1); + + // Electrolyzer Frame Casing + RecipeUtils.addShapedGregtechRecipe( + "platePotin", + "stickLongChrome", + "platePotin", + "stickLongPotin", + "frameGtPotin", + "stickLongPotin", + "platePotin", + "stickLongPotin", + "platePotin", + RECIPE_IndustrialElectrolyzerFrame); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.POTIN.getPlate(4), ALLOY.POTIN.getLongRod(3), + GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Chrome, 1), ALLOY.POTIN.getFrameBox(1), + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialElectrolyzerFrame, + 50, + 16); + // Industrial Electrolyzer + RecipeUtils.addShapedGregtechRecipe( + "plateStellite", + CI.circuitTier5, + "plateStellite", + CI.machineCasing_IV, + IV_MACHINE_Electrolyzer, + CI.machineCasing_IV, + "plateStellite", + "rotorStellite", + "plateStellite", + RECIPE_IndustrialElectrolyzerController); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialPlatePress) { + // Industrial Material Press + RECIPE_IndustrialMaterialPressController = GregtechItemList.Industrial_PlatePress.get(1); + RECIPE_IndustrialMaterialPressFrame = GregtechItemList.Casing_MaterialPress.get(1); + + // Material Press Frame Casing + RecipeUtils.addShapedGregtechRecipe( + "plateTitanium", + "stickLongTumbaga", + "plateTitanium", + "stickTantalloy60", + "frameGtTumbaga", + "stickTantalloy60", + "plateTitanium", + "stickLongTumbaga", + "plateTitanium", + RECIPE_IndustrialMaterialPressFrame); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 4), + ALLOY.TANTALLOY_60.getRod(2), ALLOY.TUMBAGA.getLongRod(2), ALLOY.TUMBAGA.getFrameBox(1), + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialMaterialPressFrame, + 50, + 16); + // Industrial Material Press + RecipeUtils.addShapedGregtechRecipe( + "plateTitanium", + CI.circuitTier4, + "plateTitanium", + CI.machineCasing_EV, + EV_MACHINE_BendingMachine, + CI.machineCasing_EV, + "plateTitanium", + CI.circuitTier4, + "plateTitanium", + RECIPE_IndustrialMaterialPressController); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialMacerationStack) { + // Industrial Maceration Stack + RECIPE_IndustrialMacerationStackController = GregtechItemList.Industrial_MacerationStack.get(1); + RECIPE_IndustrialMacerationStackFrame = GregtechItemList.Casing_MacerationStack.get(1); + + // Maceration Frame Casing + RecipeUtils.addShapedGregtechRecipe( + "platePalladium", + "platePalladium", + "platePalladium", + "stickPlatinum", + "frameGtInconel625", + "stickPlatinum", + "platePalladium", + "stickLongPalladium", + "platePalladium", + RECIPE_IndustrialMacerationStackFrame); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Palladium, 5), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Platinum, 2), + GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Palladium, 1), + ALLOY.INCONEL_625.getFrameBox(1), GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialMacerationStackFrame, + 50, + 16); + // Industrial Maceration stack + RecipeUtils.addShapedGregtechRecipe( + "plateTitanium", + EV_MACHINE_Macerator, + "plateTitanium", + EV_MACHINE_Macerator, + CI.circuitTier4, + EV_MACHINE_Macerator, + "plateTitanium", + EV_MACHINE_Macerator, + "plateTitanium", + RECIPE_IndustrialMacerationStackController); + // T2-Upgrade Card + RecipeUtils.addShapedGregtechRecipe( + "plateTungstenCarbide", + IV_MACHINE_Macerator, + "plateTungstenCarbide", + IV_MACHINE_Macerator, + CI.circuitTier7, + IV_MACHINE_Macerator, + "plateTungstenCarbide", + IV_MACHINE_Macerator, + "plateTungstenCarbide", + GregtechItemList.Maceration_Upgrade_Chip.get(1)); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialWireMill) { + // Industrial Wire Factory + RECIPE_IndustrialWireFactoryController = GregtechItemList.Industrial_WireFactory.get(1); + RECIPE_IndustrialWireFactoryFrame = GregtechItemList.Casing_WireFactory.get(1); + + // Wire Factory Frame Casing + RecipeUtils.addShapedGregtechRecipe( + "plateBlueSteel", + "stickBlueSteel", + "plateBlueSteel", + "stickBlueSteel", + "frameGtBlueSteel", + "stickBlueSteel", + "plateBlueSteel", + "stickBlueSteel", + "plateBlueSteel", + RECIPE_IndustrialWireFactoryFrame); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlueSteel, 4), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.BlueSteel, 4), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.BlueSteel, 1), + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialWireFactoryFrame, + 50, + 16); + // Industrial Wire Factory + RecipeUtils.addShapedGregtechRecipe( + "plateZeron100", + CI.machineCasing_IV, + "plateZeron100", + CI.circuitTier5, + IV_MACHINE_Wiremill, + CI.circuitTier5, + "plateZeron100", + CI.machineCasing_IV, + "plateZeron100", + RECIPE_IndustrialWireFactoryController); + } + + // Tiered Tanks + if (CORE.ConfigSwitches.enableMachine_FluidTanks) { + CI.component_Plate[1] = "plateTin"; + pipeTier1 = "pipeLargeClay"; + CI.circuitTier1 = ItemList.Circuit_Primitive.get(1); + CI.component_Plate[2] = "plateCopper"; + pipeTier2 = "pipeHugeClay"; + CI.component_Plate[3] = "plateBronze"; + pipeTier3 = "pipeMediumBronze"; + CI.component_Plate[4] = "plateIron"; + pipeTier4 = "pipeMediumSteel"; + CI.component_Plate[5] = "plateSteel"; + CI.component_Plate[6] = "plateRedstone"; + CI.component_Plate[7] = "plateAluminium"; + CI.component_Plate[8] = "plateDarkSteel"; + ItemStack waterBucket = ItemUtils.getSimpleStack(Items.water_bucket); + + // Allows clearing stored fluids. + GregtechItemList[] aTanks = new GregtechItemList[] { GregtechItemList.GT_FluidTank_ULV, + GregtechItemList.GT_FluidTank_LV, GregtechItemList.GT_FluidTank_MV, GregtechItemList.GT_FluidTank_HV }; + for (GregtechItemList aTank : aTanks) { + RecipeUtils.addShapelessGregtechRecipe(new Object[] { aTank.get(1) }, aTank.get(1)); + } + + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[1], + CI.component_Plate[5], + CI.component_Plate[1], + CI.component_Plate[4], + pipeTier1, + CI.component_Plate[4], + CI.component_Plate[4], + waterBucket, + CI.component_Plate[4], + GregtechItemList.GT_FluidTank_ULV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[5], + CI.component_Plate[4], + CI.component_Plate[5], + CI.component_Plate[3], + pipeTier2, + CI.component_Plate[3], + CI.component_Plate[3], + CI.electricPump_LV, + CI.component_Plate[3], + GregtechItemList.GT_FluidTank_LV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[8], + CI.component_Plate[3], + CI.component_Plate[8], + CI.component_Plate[5], + pipeTier3, + CI.component_Plate[5], + CI.component_Plate[5], + CI.electricPump_LV, + CI.component_Plate[5], + GregtechItemList.GT_FluidTank_MV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.circuitTier1, + CI.component_Plate[7], + CI.circuitTier1, + CI.component_Plate[8], + pipeTier4, + CI.component_Plate[8], + CI.circuitTier1, + CI.electricPump_MV, + CI.circuitTier1, + GregtechItemList.GT_FluidTank_HV.get(1)); + } + + if (CORE.ConfigSwitches.enableMultiblock_MultiTank) { + // Industrial Multi Tank + // RECIPE_IndustrialMultiTankController = GregtechItemList.Industrial_MultiTank.get(1); + RECIPE_IndustrialMultiTankFrame = GregtechItemList.Casing_MultitankExterior.get(1); + + // Industrial Multi Tank Casing + RecipeUtils.addShapedGregtechRecipe( + "stickGrisium", + "plateGrisium", + "stickGrisium", + "plateGrisium", + "frameGtGrisium", + "plateGrisium", + "plateGrisium", + "plateGrisium", + "plateGrisium", + RECIPE_IndustrialMultiTankFrame); + // Industrial Multi Tank + RecipeUtils.addShapedGregtechRecipe( + "pipeHugeTantalloy60", + "gearGrisium", + "pipeHugeTantalloy60", + CI.circuitTier4, + RECIPE_IndustrialMultiTankFrame, + CI.circuitTier4, + "plateDoubleGrisium", + "rotorGrisium", + "plateDoubleGrisium", + RECIPE_IndustrialMultiTankController); + } + // TODO + + // Semi-Fluid Generators + ItemStack[][] aSemiFluidInputs = new ItemStack[5][10]; + aSemiFluidInputs[0] = new ItemStack[] { CI.getNumberedBioCircuit(14), CI.getTieredMachineHull(1, 1), + CI.getElectricMotor(1, 2), CI.getElectricPiston(1, 2), CI.getTieredComponent(OrePrefixes.cableGt01, 1, 1), + CI.getTieredComponent(OrePrefixes.circuit, 1, 1), CI.getGear(1, 2) }; + aSemiFluidInputs[1] = new ItemStack[] { CI.getNumberedBioCircuit(14), CI.getTieredMachineHull(2, 1), + CI.getElectricMotor(2, 2), CI.getElectricPiston(2, 2), CI.getTieredComponent(OrePrefixes.cableGt01, 2, 1), + CI.getTieredComponent(OrePrefixes.circuit, 2, 1), CI.getGear(2, 2) }; + aSemiFluidInputs[2] = new ItemStack[] { CI.getNumberedBioCircuit(14), CI.getTieredMachineHull(3, 1), + CI.getElectricMotor(3, 2), CI.getElectricPiston(3, 2), CI.getTieredComponent(OrePrefixes.cableGt01, 3, 1), + CI.getTieredComponent(OrePrefixes.circuit, 3, 1), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Chrome, 2) }; + aSemiFluidInputs[3] = new ItemStack[] { CI.getNumberedBioCircuit(14), CI.getTieredMachineHull(4, 1), + CI.getElectricMotor(4, 2), CI.getElectricPiston(4, 2), CI.getTieredComponent(OrePrefixes.cableGt01, 4, 1), + CI.getTieredComponent(OrePrefixes.circuit, 4, 1), CI.getGear(4, 2) }; + aSemiFluidInputs[4] = new ItemStack[] { CI.getNumberedBioCircuit(14), CI.getTieredMachineHull(5, 1), + CI.getElectricMotor(5, 2), CI.getElectricPiston(5, 2), CI.getTieredComponent(OrePrefixes.cableGt01, 5, 1), + CI.getTieredComponent(OrePrefixes.circuit, 5, 1), CI.getGear(5, 2) }; + FluidStack[] aSemiFluidFluidInputs = new FluidStack[] { ALLOY.POLYETHYLENE.getFluidStack(144), + ALLOY.POLYETHYLENE.getFluidStack(144), ALLOY.POLYETHYLENE.getFluidStack(144), + ALLOY.POLYETHYLENE.getFluidStack(144), ALLOY.POLYTETRAFLUOROETHYLENE.getFluidStack(144) }; + + ItemStack[] aSemifluids = new ItemStack[] { GregtechItemList.Generator_SemiFluid_LV.get(1), + GregtechItemList.Generator_SemiFluid_MV.get(1), GregtechItemList.Generator_SemiFluid_HV.get(1), + GregtechItemList.Generator_SemiFluid_EV.get(1), GregtechItemList.Generator_SemiFluid_IV.get(1) }; + for (int o = 0; o < 5; o++) { + CORE.RA.addSixSlotAssemblingRecipe( + aSemiFluidInputs[o], + aSemiFluidFluidInputs[o], + aSemifluids[o], + 20 * 30, + MaterialUtils.getVoltageForTier(o + 1)); + } + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Generator_SemiFluid_LV.get(1L), + new Object[] { "PCP", "EME", "GWG", 'M', ItemList.Hull_LV, 'P', ItemList.Electric_Piston_LV, 'E', + ItemList.Electric_Motor_LV, 'C', OrePrefixes.circuit.get(Materials.Basic), 'W', + OrePrefixes.cableGt01.get(Materials.Tin), 'G', ALLOY.TUMBAGA.getGear(2) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Generator_SemiFluid_MV.get(1L), + new Object[] { "PCP", "EME", "GWG", 'M', ItemList.Hull_MV, 'P', ItemList.Electric_Piston_MV, 'E', + ItemList.Electric_Motor_MV, 'C', OrePrefixes.circuit.get(Materials.Good), 'W', + OrePrefixes.cableGt01.get(Materials.AnyCopper), 'G', ALLOY.EGLIN_STEEL.getGear(2) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Generator_SemiFluid_HV.get(1L), + new Object[] { "PCP", "EME", "GWG", 'M', ItemList.Hull_HV, 'P', ItemList.Electric_Piston_HV, 'E', + ItemList.Electric_Motor_HV, 'C', OrePrefixes.circuit.get(Materials.Advanced), 'W', + OrePrefixes.cableGt01.get(Materials.Gold), 'G', + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Chrome, 1) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Generator_SemiFluid_EV.get(1L), + new Object[] { "PCP", "EME", "GWG", 'M', ItemList.Hull_EV, 'P', ItemList.Electric_Piston_EV, 'E', + ItemList.Electric_Motor_EV, 'C', OrePrefixes.circuit.get(Materials.Data), 'W', + OrePrefixes.cableGt01.get(Materials.Aluminium), 'G', ALLOY.INCOLOY_DS.getGear(1) }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Generator_SemiFluid_IV.get(1L), + new Object[] { "PCP", "EME", "GWG", 'M', ItemList.Hull_IV, 'P', ItemList.Electric_Piston_IV, 'E', + ItemList.Electric_Motor_IV, 'C', OrePrefixes.circuit.get(Materials.Elite), 'W', + OrePrefixes.cableGt01.get(Materials.Tungsten), 'G', ALLOY.NITINOL_60.getGear(1) }); + + if (CORE.ConfigSwitches.enableMultiblock_AlloyBlastSmelter) { + // Industrial Blast Smelter + RECIPE_IndustrialBlastSmelterController = GregtechItemList.Industrial_AlloyBlastSmelter.get(1); + RECIPE_IndustrialBlastSmelterFrame = GregtechItemList.Casing_BlastSmelter.get(1); + RECIPE_IndustrialBlastSmelterCoil = GregtechItemList.Casing_Coil_BlastSmelter.get(1); + + // Blast Smelter + RecipeUtils.addShapedGregtechRecipe( + "plateZirconiumCarbide", + CI.circuitTier5, + "plateZirconiumCarbide", + cableTier6, + IV_MACHINE_AlloySmelter, + cableTier6, + "plateZirconiumCarbide", + CI.circuitTier5, + "plateZirconiumCarbide", + RECIPE_IndustrialBlastSmelterController); + // Blast Smelter Frame Casing + RecipeUtils.addShapedGregtechRecipe( + "plateZirconiumCarbide", + CI.craftingToolHammer_Hard, + "plateZirconiumCarbide", + "plateZirconiumCarbide", + "frameGtZirconiumCarbide", + "plateZirconiumCarbide", + "plateZirconiumCarbide", + CI.craftingToolWrench, + "plateZirconiumCarbide", + RECIPE_IndustrialBlastSmelterFrame); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.ZIRCONIUM_CARBIDE.getPlate(6), ALLOY.ZIRCONIUM_CARBIDE.getFrameBox(1), + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialBlastSmelterFrame, + 50, + 16); + // Blast Smelter Coil + RecipeUtils.addShapedGregtechRecipe( + "plateStaballoy", + "plateStaballoy", + "plateStaballoy", + "frameGtStaballoy", + CI.gearboxCasing_Tier_3, + "frameGtStaballoy", + "plateStaballoy", + "plateStaballoy", + "plateStaballoy", + RECIPE_IndustrialBlastSmelterCoil); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.STABALLOY.getPlate(6), ALLOY.STABALLOY.getFrameBox(2), CI.gearboxCasing_Tier_3, + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialBlastSmelterCoil, + 50, + 16); + } + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemList.Casing_Coil_Infinity.get(1), ItemList.Reactor_Coolant_Sp_6.get(4), + ALLOY.LAURENIUM.getPlateDouble(2), CustomItemList.eM_Coil.get(1) }, + ALLOY.QUANTUM.getFluidStack(144 * 4), + GregtechItemList.Casing_Coil_QuantumForceTransformer.get(1), + 60 * 30, + MaterialUtils.getVoltageForTier(6)); + + TT_recipeAdder.addResearchableAssemblylineRecipe( + GregtechItemList.Casing_Coil_QuantumForceTransformer.get(1), + 2048 * 120 * 20, + 2048, + (int) GT_Values.VP[11], + 16, + new Object[] { GregtechItemList.Controller_MolecularTransformer.get(1), + GT_ModHandler.getModItem(EternalSingularity.ID, "eternal_singularity", 1), + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 8 }, ItemList.Electric_Pump_UEV.get(4), + ItemList.Field_Generator_UEV.get(4), GregtechItemList.Laser_Lens_Special.get(1) }, + new FluidStack[] { MISC_MATERIALS.MUTATED_LIVING_SOLDER.getFluidStack(144 * 10), + ALLOY.PIKYONIUM.getFluidStack(144 * 32) }, + GregtechItemList.QuantumForceTransformer.get(1), + 1200 * 20, + (int) GT_Values.VP[11]); + + if (CORE.ConfigSwitches.enableMultiblock_MatterFabricator) { + // Industrial Matter Fabricator + RECIPE_IndustrialMatterFabController = GregtechItemList.Industrial_MassFab.get(1); + RECIPE_IndustrialMatterFabFrame = GregtechItemList.Casing_MatterFab.get(1); + RECIPE_IndustrialMatterFabCoil = GregtechItemList.Casing_MatterGen.get(1); + + // Matter Fabricator CPU + RecipeUtils.addShapedGregtechRecipe( + CI.getPlate(8, 1), + CI.circuitTier8, + CI.getPlate(8, 1), + GT_OreDictUnificator.get(OrePrefixes.cableGt04.get(Materials.NaquadahAlloy), 1L), + CI.machineCasing_UV, + GT_OreDictUnificator.get(OrePrefixes.cableGt04.get(Materials.NaquadahAlloy), 1L), + CI.getPlate(8, 1), + CI.circuitTier8, + CI.getPlate(8, 1), + RECIPE_IndustrialMatterFabController); + // Matter Fabricator Frame Casing + RecipeUtils.addShapedGregtechRecipe( + "plateNiobiumCarbide", + CI.component_Rod[8], + "plateNiobiumCarbide", + CI.component_Rod[8], + "frameGtInconel690", + CI.component_Rod[8], + "plateNiobiumCarbide", + CI.component_Rod[8], + "plateNiobiumCarbide", + RECIPE_IndustrialMatterFabFrame); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.NIOBIUM_CARBIDE.getPlate(4), ALLOY.INCONEL_792.getRod(4), + ALLOY.INCONEL_690.getFrameBox(1), GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialMatterFabFrame, + 50, + 16); + // Matter Fabricator Coil + RecipeUtils.addShapedGregtechRecipe( + CI.getPlate(6, 1), + CI.getPlate(7, 1), + CI.getPlate(6, 1), + "frameGtStellite", + CI.machineCasing_UV, + "frameGtStellite", + CI.getPlate(6, 1), + CI.getPlate(7, 1), + CI.getPlate(6, 1), + RECIPE_IndustrialMatterFabCoil); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CI.machineCasing_UV, ALLOY.ZERON_100.getPlate(4), ALLOY.PIKYONIUM.getPlate(2), + ALLOY.STELLITE.getFrameBox(2), GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialMatterFabCoil, + 50, + 16); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialSifter) { + // Industrial Sieve + RECIPE_IndustrialSieveController = GregtechItemList.Industrial_Sifter.get(1); + RECIPE_IndustrialSieveFrame = GregtechItemList.Casing_Sifter.get(1); + RECIPE_IndustrialSieveGrate = GregtechItemList.Casing_SifterGrate.get(1); + + // Industrial Sieve + RecipeUtils.addShapedGregtechRecipe( + "plateEglinSteel", + CI.circuitTier3, + "plateEglinSteel", + cableTier4, + HV_MACHINE_Sifter, + cableTier4, + "plateEglinSteel", + CI.circuitTier3, + "plateEglinSteel", + RECIPE_IndustrialSieveController); + // Industrial Sieve Casing + RecipeUtils.addShapedGregtechRecipe( + "plateEglinSteel", + "plateEglinSteel", + "plateEglinSteel", + "plateEglinSteel", + "frameGtTumbaga", + "plateEglinSteel", + "plateEglinSteel", + "plateEglinSteel", + "plateEglinSteel", + RECIPE_IndustrialSieveFrame); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.EGLIN_STEEL.getPlate(8), ALLOY.TUMBAGA.getFrameBox(1), + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialSieveFrame, + 50, + 16); + // Industrial Sieve Grate + RecipeUtils.addShapedGregtechRecipe( + "frameGtEglinSteel", + "wireFineSteel", + "frameGtEglinSteel", + "wireFineSteel", + "wireFineSteel", + "wireFineSteel", + "frameGtEglinSteel", + "wireFineSteel", + "frameGtEglinSteel", + RECIPE_IndustrialSieveGrate); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Steel, 5), + ALLOY.EGLIN_STEEL.getFrameBox(4), GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + RECIPE_IndustrialSieveGrate, + 50, + 16); + } + + if (CORE.ConfigSwitches.enableMultiblock_TreeFarmer) { + // Industrial Tree Farmer + RECIPE_TreeFarmController = GregtechItemList.Industrial_TreeFarm.get(1); + RECIPE_TreeFarmFrame = GregtechItemList.Casing_PLACEHOLDER_TreeFarmer.get(1); + // Industrial Tree Farm Controller + RecipeUtils.addShapedGregtechRecipe( + ItemList.Field_Generator_IV.get(1), + ALLOY.INCOLOY_MA956.getRotor(1), + ItemList.Field_Generator_IV.get(1), + ALLOY.NITINOL_60.getPlate(1), + GregtechItemList.GTPP_Casing_IV.get(1), + ALLOY.NITINOL_60.getPlate(1), + ItemList.Field_Generator_IV.get(1), + ALLOY.INCONEL_792.getComponentByPrefix(OrePrefixes.pipeMedium, 1), + ItemList.Field_Generator_IV.get(1), + RECIPE_TreeFarmController); + // Industrial Tree Farm Frame + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_Utility.getIntegratedCircuit(2), ALLOY.TUMBAGA.getFrameBox(1), + ItemUtils.getItemStackOfAmountFromOreDict("pipeTinySteel", 1), ItemList.MV_Coil.get(1), + ItemList.IC2_Plantball.get(4), GT_OreDictUnificator.get(OrePrefixes.plank, Materials.Wood, 8), }, + GT_ModHandler.getDistilledWater(2000), + RECIPE_TreeFarmFrame, + 200, + 64); + } + + if (CORE.ConfigSwitches.enableMachine_Tesseracts) { + // Tesseracts + RECIPE_TesseractGenerator = GregtechItemList.GT4_Tesseract_Generator.get(1); + RECIPE_TesseractTerminal = GregtechItemList.GT4_Tesseract_Terminal.get(1); + // Tesseract Generator + RecipeUtils.addShapedGregtechRecipe( + "plateTitanium", + "circuitMaster", + "plateTitanium", + "circuitMaster", + ItemUtils.getSimpleStack(Blocks.ender_chest), + "circuitMaster", + "plateTitanium", + GregtechItemList.Gregtech_Computer_Cube.get(1), + "plateTitanium", + RECIPE_TesseractGenerator); + // Tesseract Terminal + RecipeUtils.addShapedGregtechRecipe( + "plateTitanium", + "circuitElite", + "plateTitanium", + "circuitElite", + ItemUtils.getSimpleStack(Blocks.ender_chest), + "circuitElite", + "plateTitanium", + CI.machineHull_EV, + "plateTitanium", + RECIPE_TesseractTerminal); + } + + if (CORE.ConfigSwitches.enableMachine_SimpleWasher) { + final List<ItemStack> washers = ImmutableList.of( + GregtechItemList.SimpleDustWasher_LV.get(1), + GregtechItemList.SimpleDustWasher_MV.get(1), + GregtechItemList.SimpleDustWasher_HV.get(1), + GregtechItemList.SimpleDustWasher_EV.get(1), + GregtechItemList.SimpleDustWasher_IV.get(1), + GregtechItemList.SimpleDustWasher_LuV.get(1), + GregtechItemList.SimpleDustWasher_ZPM.get(1), + GregtechItemList.SimpleDustWasher_UV.get(1)); + + for (int i = 0; i < washers.size(); i++) { + final int tier = i + 1; + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getTieredMachineHull(tier), + CI.getTieredComponent(OrePrefixes.screw, tier, tier * 4), + CI.getTieredComponent(OrePrefixes.plate, tier - 1, tier * 2), + CI.getTieredComponent(OrePrefixes.rod, tier, tier), + CI.getTieredComponent(OrePrefixes.circuit, tier, 1) }, + CI.getTieredFluid(tier, 144 * tier), + washers.get(i), + 20 * 5 * tier, + (int) GT_Values.V[tier]); + } + } + + if (CORE.ConfigSwitches.enableMachine_Pollution && PollutionUtils.isPollutionEnabled()) { + + RecipeUtils.addShapedGregtechRecipe( + "plateCarbon", + "plateCarbon", + "plateCarbon", + "dustCarbon", + "dustCarbon", + "dustCarbon", + "plateCarbon", + "plateCarbon", + "plateCarbon", + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1)); + + RecipeUtils.addShapedGregtechRecipe( + "plateCarbon", + "plateCarbon", + "plateCarbon", + "cellLithiumPeroxide", + "dustCarbon", + "cellLithiumPeroxide", + "plateCarbon", + "plateCarbon", + "plateCarbon", + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1)); + + // Pollution Detector + RecipeUtils.addShapedGregtechRecipe( + "plateSteel", + CI.sensor_LV, + "plateSteel", + "plateSteel", + CI.electricMotor_LV, + "plateSteel", + CI.getTieredCircuit(1), + CI.machineHull_LV, + CI.getTieredCircuit(1), + GregtechItemList.Pollution_Detector.get(1)); + + // LV + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[1], + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1), + CI.component_Plate[1], + CI.component_Plate[1], + CI.electricMotor_LV, + CI.component_Plate[1], + CI.getTieredCircuit(1), + CI.machineHull_LV, + CI.getTieredCircuit(1), + GregtechItemList.Pollution_Cleaner_LV.get(1)); + // MV + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[2], + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1), + CI.component_Plate[2], + CI.component_Plate[2], + CI.electricMotor_MV, + CI.component_Plate[2], + CI.getTieredCircuit(2), + CI.machineHull_MV, + CI.getTieredCircuit(2), + GregtechItemList.Pollution_Cleaner_MV.get(1)); + // HV + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[3], + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1), + CI.component_Plate[3], + CI.component_Plate[3], + CI.electricMotor_HV, + CI.component_Plate[3], + CI.getTieredCircuit(3), + CI.machineHull_HV, + CI.getTieredCircuit(3), + GregtechItemList.Pollution_Cleaner_HV.get(1)); + // EV + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[4], + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1), + CI.component_Plate[4], + CI.component_Plate[4], + CI.electricMotor_EV, + CI.component_Plate[4], + CI.getTieredCircuit(4), + CI.machineHull_EV, + CI.getTieredCircuit(4), + GregtechItemList.Pollution_Cleaner_EV.get(1)); + // IV + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[5], + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1), + CI.component_Plate[5], + CI.component_Plate[5], + CI.electricMotor_IV, + CI.component_Plate[5], + CI.getTieredCircuit(5), + CI.machineHull_IV, + CI.getTieredCircuit(5), + GregtechItemList.Pollution_Cleaner_IV.get(1)); + // LuV + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[6], + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1), + CI.component_Plate[6], + CI.component_Plate[6], + CI.electricMotor_LuV, + CI.component_Plate[6], + CI.getTieredCircuit(6), + CI.machineHull_LuV, + CI.getTieredCircuit(6), + GregtechItemList.Pollution_Cleaner_LuV.get(1)); + // ZPM + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[7], + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1), + CI.component_Plate[7], + CI.component_Plate[7], + CI.electricMotor_ZPM, + CI.component_Plate[7], + CI.getTieredCircuit(7), + CI.machineHull_ZPM, + CI.getTieredCircuit(7), + GregtechItemList.Pollution_Cleaner_ZPM.get(1)); + // UV + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[8], + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1), + CI.component_Plate[8], + CI.component_Plate[8], + CI.electricMotor_UV, + CI.component_Plate[8], + CI.getTieredCircuit(8), + CI.machineHull_UV, + CI.getTieredCircuit(8), + GregtechItemList.Pollution_Cleaner_UV.get(1)); + // MAX + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[9], + ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1), + CI.component_Plate[9], + CI.component_Plate[9], + CI.electricMotor_UHV, + CI.component_Plate[9], + CI.getTieredCircuit(9), + CI.machineHull_UHV, + CI.getTieredCircuit(9), + GregtechItemList.Pollution_Cleaner_MAX.get(1)); + } + + if (CORE.ConfigSwitches.enableMultiblock_ThermalBoiler) { + RECIPE_ThermalBoilerController = GregtechItemList.GT4_Thermal_Boiler.get(1); + RECIPE_ThermalBoilerCasing = GregtechItemList.Casing_ThermalContainment.get(2); + ItemStack centrifugeEV = ItemList.Machine_EV_Centrifuge.get(1); + + RecipeUtils.addShapedGregtechRecipe( + "craftingGeothermalGenerator", + centrifugeEV, + "craftingGeothermalGenerator", + "gearGtTitanium", + CI.getTieredCircuitOreDictName(6), + "gearGtTitanium", + "craftingGeothermalGenerator", + centrifugeEV, + "craftingGeothermalGenerator", + RECIPE_ThermalBoilerController); + + RecipeUtils.addShapedGregtechRecipe( + "craftingGeothermalGenerator", + centrifugeEV, + "craftingGeothermalGenerator", + "gearGtTungstenSteel", + CI.getTieredCircuitOreDictName(5), + "gearGtTungstenSteel", + "craftingGeothermalGenerator", + centrifugeEV, + "craftingGeothermalGenerator", + RECIPE_ThermalBoilerController); + + RecipeUtils.addShapedGregtechRecipe( + ALLOY.MARAGING350.getPlate(1), + "plateStainlessSteel", + ALLOY.MARAGING350.getPlate(1), + "circuitAdvanced", + CI.machineCasing_HV, + "circuitAdvanced", + ALLOY.MARAGING350.getPlate(1), + ALLOY.MARAGING350.getPlate(1), + ALLOY.MARAGING350.getPlate(1), + RECIPE_ThermalBoilerCasing); + + // Lava Filter Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedCircuit(18), + ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", 32), + ItemUtils.getItemStackOfAmountFromOreDict("wireFineSteel", 32), + ItemUtils.getItemStackOfAmountFromOreDict("ringTumbaga", 16), + ItemUtils.getItemStackOfAmountFromOreDict("foilCopper", 4), + ItemUtils.getItemStackWithMeta(true, "IC2:itemPartCarbonMesh", "RawCarbonMesh", 0, 64), }, + CI.getTieredFluid(3, 144), + ItemUtils.getSimpleStack(ModItems.itemLavaFilter, 16), + 1600, + 240); + } + + // Air Intake Hatch + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[6], + ItemList.Casing_Grate.get(1), + CI.component_Plate[6], + CI.component_Plate[6], + CI.getFluidRegulator(5, 1), + CI.component_Plate[6], + CI.getTieredCircuit(5), + ItemList.Hatch_Input_IV.get(1), + CI.getTieredCircuit(5), + GregtechItemList.Hatch_Air_Intake.get(1)); + + RecipeUtils.addShapedGregtechRecipe( + CI.getPlate(7, 1), + GregtechItemList.Hatch_Air_Intake.get(1), + CI.getPlate(7, 1), + CI.getPlate(7, 1), + CI.getFluidRegulator(7, 1), + CI.getPlate(7, 1), + CI.getTieredCircuit(7), + ItemList.Hatch_Input_ZPM.get(1), + CI.getTieredCircuit(7), + GregtechItemList.Hatch_Air_Intake_Extreme.get(1)); + + if (CORE.ConfigSwitches.enableMultiblock_LiquidFluorideThoriumReactor) { + + // Thorium Reactor + RECIPE_LFTRController = GregtechItemList.ThoriumReactor.get(1); + RECIPE_LFTRInnerCasing = GregtechItemList.Casing_Reactor_II.get(1); // Zeron + RECIPE_LFTROuterCasing = GregtechItemList.Casing_Reactor_I.get(1); // Hastelloy + + ItemStack controlCircuit = ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR); + RecipeUtils.addShapedGregtechRecipe( + controlCircuit, + "cableGt12Naquadah", + controlCircuit, + "plateDoubleHastelloyN", + GregtechItemList.Gregtech_Computer_Cube.get(1), + "plateDoubleHastelloyN", + "plateThorium232", + CI.machineHull_IV, + "plateThorium232", + RECIPE_LFTRController); + RecipeUtils.addShapedGregtechRecipe( + "plateDoubleHastelloyC276", + CI.craftingToolScrewdriver, + "plateDoubleHastelloyC276", + "gearGtTalonite", + CI.fieldGenerator_LV, + "gearGtTalonite", + "plateDoubleHastelloyC276", + CI.craftingToolHammer_Hard, + "plateDoubleHastelloyC276", + RECIPE_LFTRInnerCasing); + + ItemStack IC2HeatPlate = ItemUtils.getItemStackFromFQRN("IC2:reactorPlatingHeat", 1); + RecipeUtils.addShapedGregtechRecipe( + "plateDoubleHastelloyN", + IC2HeatPlate, + "plateDoubleHastelloyN", + IC2HeatPlate, + "frameGtHastelloyC276", + IC2HeatPlate, + "plateDoubleHastelloyN", + IC2HeatPlate, + "plateDoubleHastelloyN", + RECIPE_LFTROuterCasing); + + // LFTR Control Circuit + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), 1), + CI.fieldGenerator_HV }, + null, + controlCircuit, + 240 * 20, + 500); + + // Fission Fuel Plant + RecipeUtils.addShapedGregtechRecipe( + CI.getTieredCircuitOreDictName(5), + CI.craftingToolSolderingIron, + CI.getTieredCircuitOreDictName(5), + "plateDenseTungstenSteel", + GregtechItemList.Gregtech_Computer_Cube.get(1), + "plateDenseTungstenSteel", + "gearGtStellite", + CI.machineHull_IV, + "gearGtStellite", + GregtechItemList.Industrial_FuelRefinery.get(1)); + + ItemStack mInnerTank = ItemList.Super_Tank_IV.get(1); + + // Incoloy Casing + RecipeUtils.addShapedGregtechRecipe( + "plateIncoloyDS", + "pipeHugeStaballoy", + "plateIncoloyDS", + "gearGtIncoloyDS", + mInnerTank, + "gearGtIncoloyDS", + "plateIncoloyDS", + "pipeHugeStaballoy", + "plateIncoloyDS", + GregtechItemList.Casing_Refinery_Internal.get(1)); + + // Hastelloy-N Sealant Casing + RecipeUtils.addShapedGregtechRecipe( + "plateIncoloyMA956", + "plateHastelloyN", + "plateIncoloyMA956", + "plateHastelloyN", + "frameGtHastelloyC276", + "plateHastelloyN", + "plateIncoloyMA956", + "plateHastelloyN", + "plateIncoloyMA956", + GregtechItemList.Casing_Refinery_External.get(1)); + + // Hastelloy-X Structural Casing + RecipeUtils.addShapedGregtechRecipe( + "ringInconel792", + "gearGtHastelloyX", + CI.component_Plate[5], + CI.craftingToolHammer_Hard, + "frameGtHastelloyC276", + CI.craftingToolWrench, + CI.component_Plate[5], + CI.getTieredMachineCasing(4), + "ringInconel792", + GregtechItemList.Casing_Refinery_Structural.get(1)); + + RecipeUtils.addShapedGregtechRecipe( + CI.getPlate(5, 1), + ALLOY.HASTELLOY_X.getPlateDouble(1), + CI.getPlate(5, 1), + CI.getPlate(5, 1), + CI.getTieredMachineCasing(5), + CI.getPlate(5, 1), + CI.getRobotArm(5, 1), + ItemList.Casing_FrostProof.get(1), + CI.getRobotArm(5, 1), + GregtechItemList.ColdTrap_IV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.getPlate(7, 1), + ALLOY.HS188A.getPlateDouble(1), + CI.getPlate(7, 1), + CI.getPlate(7, 1), + GregtechItemList.ColdTrap_IV.get(1), + CI.getPlate(7, 1), + CI.getRobotArm(7, 1), + ItemList.Casing_FrostProof.get(1), + CI.getRobotArm(7, 1), + GregtechItemList.ColdTrap_ZPM.get(1)); + + RecipeUtils.addShapedGregtechRecipe( + CI.getFieldGenerator(3, 1), + CI.getRobotArm(5, 1), + CI.getPlate(5, 1), + ALLOY.HASTELLOY_N.getPlateDouble(1), + ItemList.Machine_IV_ChemicalReactor.get(1), + ALLOY.HASTELLOY_N.getPlateDouble(1), + CI.getPlate(5, 1), + ALLOY.HASTELLOY_N.getPlateDouble(1), + CI.getFieldGenerator(3, 1), + GregtechItemList.ReactorProcessingUnit_IV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.getFieldGenerator(5, 1), + CI.getRobotArm(7, 1), + CI.getPlate(7, 1), + ALLOY.HS188A.getPlateDouble(1), + GregtechItemList.ReactorProcessingUnit_IV.get(1), + ALLOY.HS188A.getPlateDouble(1), + CI.getPlate(7, 1), + ALLOY.HS188A.getPlateDouble(1), + CI.getFieldGenerator(5, 1), + GregtechItemList.ReactorProcessingUnit_ZPM.get(1)); + + // Nuclear Salt Processing Plant Controller + RECIPE_SaltPlantController = GregtechItemList.Nuclear_Salt_Processing_Plant.get(1); + + RecipeUtils.addShapedGregtechRecipe( + "plateOsmiridium", + GregtechItemList.ReactorProcessingUnit_IV.get(1), + "plateOsmiridium", + "plateRuridit", + CI.getTieredCircuitOreDictName(7), + "plateRuridit", + "plateOsmiridium", + GregtechItemList.ColdTrap_IV.get(1), + "plateOsmiridium", + RECIPE_SaltPlantController); + } + + // Cyclotron + if (CORE.ConfigSwitches.enableMultiblock_Cyclotron) { + RECIPE_CyclotronController = GregtechItemList.COMET_Cyclotron.get(1); + RECIPE_CyclotronOuterCasing = GregtechItemList.Casing_Cyclotron_External.get(1); + RECIPE_CyclotronInnerCoil = GregtechItemList.Casing_Cyclotron_Coil.get(1); + + // Outer Casing + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemList.Casing_FrostProof.get(1), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 0, 4), ALLOY.INCOLOY_DS.getPlate(8), + ALLOY.INCONEL_690.getScrew(16), ALLOY.EGLIN_STEEL.getLongRod(4), CI.getElectricPiston(3, 2) }, + ALLOY.ZIRCONIUM_CARBIDE.getFluidStack(144 * 8), // Input Fluid + RECIPE_CyclotronOuterCasing, + 30 * 20 * 2, + MaterialUtils.getVoltageForTier(4)); + + // Inner Coil + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemList.Casing_Coil_Nichrome.get(1), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 1, 8), + ALLOY.INCOLOY_MA956.getPlate(8), ALLOY.TANTALLOY_61.getBolt(16), ALLOY.INCOLOY_020.getScrew(32), + CI.getFieldGenerator(4, 1) }, + ALLOY.HG1223.getFluidStack(144 * 5), // Input Fluid + RECIPE_CyclotronInnerCoil, + 60 * 20 * 2, + MaterialUtils.getVoltageForTier(5)); + + // Controller + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.machineHull_IV, ItemUtils.getSimpleStack(RECIPE_CyclotronInnerCoil, 2), + ALLOY.INCOLOY_020.getPlate(8), ALLOY.TANTALLOY_61.getGear(2), ALLOY.INCOLOY_MA956.getScrew(16), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(5), 16) }, + ALLOY.INCOLOY_020.getFluidStack(144 * 9), // Input Fluid + RECIPE_CyclotronController, + 60 * 20 * 5, + MaterialUtils.getVoltageForTier(5)); + } + + // Mazut + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Controller_LargeSemifluidGenerator.get(1L), + CI.bitsd, + new Object[] { "PCP", "EME", "GWG", 'M', ItemList.Hull_EV, 'P', ItemList.Electric_Piston_EV, 'E', + ItemList.Electric_Pump_EV, 'C', OrePrefixes.circuit.get(Materials.Data), 'W', + OrePrefixes.cableGt08.get(Materials.Electrum), 'G', ALLOY.INCONEL_792.getGear(1) }); + + if (CORE.ConfigSwitches.enableMultiblock_PowerSubstation) { + RecipeUtils.addShapedRecipe( + "screwTitanium", + "plateIncoloy020", + "screwTitanium", + "plateIncoloy020", + "frameGtIncoloyMA956", + "plateIncoloy020", + "screwTitanium", + "plateIncoloy020", + "screwTitanium", + GregtechItemList.Casing_Power_SubStation.get(1)); + + ItemStack mBattery = ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR); + + RecipeUtils.addShapedRecipe( + "plateIncoloyMA956", + mBattery, + "plateIncoloyMA956", + GregtechItemList.Casing_Power_SubStation.get(1), + GregtechItemList.Casing_Vanadium_Redox.get(1), + GregtechItemList.Casing_Power_SubStation.get(1), + "plateIncoloy020", + "plateIncoloyMA956", + "plateIncoloy020", + GregtechItemList.PowerSubStation.get(1)); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialThermalCentrifuge) { + RecipeUtils.addShapedRecipe( + "plateRedSteel", + CI.craftingToolHammer_Hard, + "plateRedSteel", + "plateRedSteel", + "frameGtBlackSteel", + "plateRedSteel", + "plateRedSteel", + CI.craftingToolWrench, + "plateRedSteel", + GregtechItemList.Casing_ThermalCentrifuge.get(1)); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.plate, Materials.RedSteel, 6), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.BlackSteel, 1), + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + GregtechItemList.Casing_ThermalCentrifuge.get(1L), + 50, + 16); + + RecipeUtils.addShapedRecipe( + "plateRedSteel", + "circuitData", + "plateRedSteel", + "stickTalonite", + EV_MACHINE_ThermalCentrifuge, + "stickTalonite", + "plateRedSteel", + "gearGtTalonite", + "plateRedSteel", + GregtechItemList.Industrial_ThermalCentrifuge.get(1)); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialWashPlant) { + RecipeUtils.addShapedRecipe( + "plateGrisium", + CI.craftingToolHammer_Hard, + "plateGrisium", + "plateTalonite", + "frameGtGrisium", + "plateTalonite", + "plateGrisium", + CI.craftingToolWrench, + "plateGrisium", + GregtechItemList.Casing_WashPlant.get(1)); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.LEAGRISIUM.getPlate(4), ALLOY.TALONITE.getPlate(2), + ALLOY.LEAGRISIUM.getFrameBox(1), GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + GregtechItemList.Casing_WashPlant.get(1L), + 50, + 16); + + RecipeUtils.addShapedRecipe( + "plateGrisium", + EV_MACHINE_OreWasher, + "plateGrisium", + "plateTalonite", + "circuitData", + "plateTalonite", + "plateGrisium", + EV_MACHINE_ChemicalBath, + "plateGrisium", + GregtechItemList.Industrial_WashPlant.get(1)); + } + + if (CORE.ConfigSwitches.enableMultiblock_LargeAutoCrafter) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), 1), + ItemList.Block_IridiumTungstensteel.get(1), CI.getTieredComponent(OrePrefixes.circuit, 2, 16), + CI.getTieredComponent(OrePrefixes.screw, 5, 32), CI.getTieredComponent(OrePrefixes.bolt, 5, 12), + CI.getTieredComponent(OrePrefixes.plate, 6, 8), }, + CI.getTertiaryTieredFluid(6, 144 * (4)), + GregtechItemList.Casing_Autocrafter.get(1), + 20 * 60 * 2, + MaterialUtils.getVoltageForTier(5)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { GregtechItemList.Casing_Refinery_Structural.get(4), + ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR, 1), + CI.getTieredComponent(OrePrefixes.cableGt08, 6, 16), CI.getTransmissionComponent(5, 2), + GregtechItemList.Gregtech_Computer_Cube.get(1), }, + CI.getTieredFluid(7, 144 * 8), + GregtechItemList.GT4_Multi_Crafter.get(1), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(5)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), 1), + CI.getEmitter(4, 2), CI.getRobotArm(4, 2), CI.getTieredComponent(OrePrefixes.circuit, 2, 8), + CI.getTieredComponent(OrePrefixes.screw, 3, 8), CI.getTieredComponent(OrePrefixes.plate, 5, 4), }, + CI.getAlternativeTieredFluid(5, 144 * 4), + ItemUtils.getSimpleStack(ModBlocks.blockProjectTable), + 20 * 30 * 3, + MaterialUtils.getVoltageForTier(4)); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialCuttingMachine) { + ItemStack plate = ALLOY.MARAGING300.getPlate(1); + RecipeUtils.addShapedRecipe( + plate, + CI.craftingToolHammer_Hard, + plate, + "plateStellite", + "frameGtTalonite", + "plateStellite", + plate, + CI.craftingToolWrench, + plate, + GregtechItemList.Casing_CuttingFactoryFrame.get(1)); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.MARAGING300.getPlate(4), ALLOY.STELLITE.getPlate(2), + ALLOY.TALONITE.getFrameBox(1), GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + GregtechItemList.Casing_CuttingFactoryFrame.get(1L), + 50, + 16); + + RecipeUtils.addShapedRecipe( + plate, + CI.getTieredCircuit(4), + plate, + "wireFinePlatinum", + IV_MACHINE_Cutter, + "wireFinePlatinum", + plate, + CI.getTieredCircuit(4), + plate, + GregtechItemList.Industrial_CuttingFactoryController.get(1)); + } + + // IV_MACHINE_Extruder + if (CORE.ConfigSwitches.enableMultiblock_IndustrialExtrudingMachine) { + ItemStack plate = ALLOY.INCONEL_690.getPlate(1); + RecipeUtils.addShapedRecipe( + plate, + CI.craftingToolHammer_Hard, + plate, + "plateTalonite", + "frameGtStaballoy", + "plateTalonite", + plate, + CI.craftingToolWrench, + plate, + GregtechItemList.Casing_Extruder.get(1)); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.INCONEL_690.getPlate(4), ALLOY.TALONITE.getPlate(2), + ALLOY.STABALLOY.getFrameBox(1), GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + GregtechItemList.Casing_Extruder.get(1L), + 50, + 16); + + RecipeUtils.addShapedRecipe( + plate, + CI.getTieredCircuit(5), + plate, + CI.electricPiston_IV, + IV_MACHINE_Extruder, + CI.electricPiston_IV, + plate, + CI.getTieredCircuit(5), + plate, + GregtechItemList.Industrial_Extruder.get(1)); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialFishingPort) { + ItemStack plate = ALLOY.AQUATIC_STEEL.getPlate(1); + RecipeUtils.addShapedRecipe( + plate, + CI.craftingToolHammer_Hard, + plate, + "plateEglinSteel", + "frameGtEglinSteel", + "plateEglinSteel", + plate, + CI.craftingToolWrench, + plate, + GregtechItemList.Casing_FishPond.get(1)); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.AQUATIC_STEEL.getPlate(4), ALLOY.EGLIN_STEEL.getPlate(2), + ALLOY.EGLIN_STEEL.getFrameBox(1), GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + GregtechItemList.Casing_FishPond.get(1L), + 50, + 16); + RecipeUtils.addShapedRecipe( + plate, + CI.getTieredCircuit(5), + plate, + "wireFineElectrum", + ItemUtils.getSimpleStack(ModBlocks.blockFishTrap), + "wireFineElectrum", + plate, + CI.getTieredCircuit(5), + plate, + GregtechItemList.Industrial_FishingPond.get(1)); + } + + if (true) { + // Advanced Vacuum Freezer + ItemStack plate = ALLOY.HG1223.getPlateDouble(1); + ItemStack gear = ALLOY.INCOLOY_MA956.getGear(1); + ItemStack frame = ALLOY.LAFIUM.getFrameBox(1); + ItemStack cell1 = ItemList.Reactor_Coolant_He_6.get(1); + ItemStack cell2 = ItemList.Reactor_Coolant_NaK_6.get(1); + + RecipeUtils.addShapedRecipe( + plate, + gear, + plate, + cell1, + frame, + cell2, + plate, + gear, + plate, + GregtechItemList.Casing_AdvancedVacuum.get(1)); + RecipeUtils.addShapedRecipe( + gear, + CI.getTieredCircuit(6), + gear, + CI.electricPiston_IV, + GregtechItemList.Casing_AdvancedVacuum.get(1), + CI.electricPiston_IV, + plate, + GregtechItemList.Gregtech_Computer_Cube.get(1), + plate, + GregtechItemList.Industrial_Cryogenic_Freezer.get(1)); + + // Advanced Blast Furnace + plate = ALLOY.HASTELLOY_N.getPlateDouble(1); + gear = ALLOY.HASTELLOY_W.getGear(1); + frame = ALLOY.HASTELLOY_X.getFrameBox(1); + cell1 = ItemUtils.simpleMetaStack("IC2:reactorHeatSwitchDiamond:1", 1, 1); + cell2 = ItemUtils.simpleMetaStack("IC2:reactorVentGold:1", 1, 1); + ItemStack cell3 = ItemUtils.simpleMetaStack("IC2:reactorVentDiamond:1:1", 1, 1); + + RecipeUtils.addShapedRecipe( + plate, + cell1, + plate, + cell3, + frame, + cell2, + plate, + gear, + plate, + GregtechItemList.Casing_Adv_BlastFurnace.get(1)); + RecipeUtils.addShapedRecipe( + gear, + CI.getTieredCircuit(6), + gear, + CI.robotArm_IV, + GregtechItemList.Casing_Adv_BlastFurnace.get(1), + CI.robotArm_IV, + plate, + GregtechItemList.Gregtech_Computer_Cube.get(1), + plate, + GregtechItemList.Machine_Adv_BlastFurnace.get(1)); + // Hatch_Input_Pyrotheum + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Input_IV.get(1), GregtechItemList.Casing_Adv_BlastFurnace.get(1), + ALLOY.MARAGING250.getPlate(4), ALLOY.MARAGING300.getGear(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 2), + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + GregtechItemList.Hatch_Input_Pyrotheum.get(1L), + 50, + 16); + // Casing_Adv_BlastFurnace + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.HASTELLOY_X.getFrameBox(1), ALLOY.HASTELLOY_N.getPlateDouble(4), + ALLOY.HASTELLOY_W.getGear(1), ItemUtils.simpleMetaStack("IC2:reactorHeatSwitchDiamond:1", 1, 1), + ItemUtils.simpleMetaStack("IC2:reactorVentGold:1", 1, 1), + ItemUtils.simpleMetaStack("IC2:reactorVentDiamond:1:1", 1, 1), + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + GregtechItemList.Casing_Adv_BlastFurnace.get(1L), + 50, + 16); + + // Advanced Implosion Compressor + plate = ItemUtils.getItemStackOfAmountFromOreDict("plateAlloyIridium", 1); + gear = ALLOY.LEAGRISIUM.getGear(1); + frame = ALLOY.CINOBITE.getFrameBox(1); + cell1 = ItemUtils.simpleMetaStack("IC2:reactorHeatSwitchDiamond:1", 1, 1); + cell2 = ItemUtils.simpleMetaStack("IC2:reactorVentGold:1", 1, 1); + + RecipeUtils.addShapedRecipe( + gear, + CI.getTieredCircuit(6), + gear, + CI.fieldGenerator_IV, + CI.machineHull_ZPM, + CI.robotArm_IV, + plate, + GregtechItemList.Gregtech_Computer_Cube.get(1), + plate, + GregtechItemList.Machine_Adv_ImplosionCompressor.get(1)); + + // Supply Depot + plate = ALLOY.TUNGSTEN_CARBIDE.getPlateDouble(1); + gear = ALLOY.TRINIUM_TITANIUM.getRing(1); + frame = ALLOY.TUNGSTEN_CARBIDE.getFrameBox(1); + cell1 = CI.conveyorModule_LuV; + cell2 = CI.electricMotor_LuV; + ItemStack casingAmazon = GregtechItemList.Casing_AmazonWarehouse.get(1); + + RecipeUtils.addShapedRecipe( + plate, + ItemUtils.getItemStackOfAmountFromOreDict("cableGt12VanadiumGallium", 1), + plate, + cell1, + frame, + cell2, + plate, + gear, + plate, + GregtechItemList.Casing_AmazonWarehouse.get(1)); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.TUNGSTEN_CARBIDE.getFrameBox(1), ALLOY.TUNGSTEN_CARBIDE.getPlateDouble(4), + ALLOY.TRINIUM_TITANIUM.getRing(1), ItemList.Electric_Motor_LuV.get(1), + ItemList.Conveyor_Module_LuV.get(1), + ItemUtils.getItemStackOfAmountFromOreDict("cableGt12VanadiumGallium", 1), + GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + GregtechItemList.Casing_AmazonWarehouse.get(1L), + 50, + 16); + RecipeUtils.addShapedRecipe( + casingAmazon, + CI.getTieredCircuit(7), + casingAmazon, + CI.robotArm_LuV, + ItemList.Machine_LuV_Unboxinator.get(1), + CI.robotArm_LuV, + CI.conveyorModule_LuV, + GregtechItemList.Gregtech_Computer_Cube.get(1), + CI.conveyorModule_LuV, + GregtechItemList.Amazon_Warehouse_Controller.get(1)); + + // Industrial Mixing Machine + RecipeUtils.addShapedRecipe( + "plateStaballoy", + CI.getTieredCircuit(5), + "plateStaballoy", + "plateZirconiumCarbide", + IV_MACHINE_Mixer, + "plateZirconiumCarbide", + "plateStaballoy", + CI.getTieredCircuit(5), + "plateStaballoy", + GregtechItemList.Industrial_Mixer.get(1)); + } + + if (CORE.ConfigSwitches.enableMultiblock_IndustrialMultiMachine) { + ItemStack plate = ALLOY.STABALLOY.getPlate(1); + + ItemStack o_Compressor = ItemList.Machine_IV_Compressor.get(1); + ItemStack o_Lathe = ItemList.Machine_IV_Lathe.get(1); + ItemStack o_Electromagnet = ItemList.Machine_IV_Polarizer.get(1); + ItemStack o_Fermenter = ItemList.Machine_IV_Fermenter.get(1); + ItemStack o_Distillery = ItemList.Machine_IV_FluidExtractor.get(1); + ItemStack o_Extractor = ItemList.Machine_IV_Extractor.get(1); + + RecipeUtils.addShapedRecipe( + plate, + CI.craftingToolHammer_Hard, + plate, + "plateStainlessSteel", + "frameGtZirconiumCarbide", + "plateStainlessSteel", + plate, + CI.craftingToolWrench, + plate, + GregtechItemList.Casing_Multi_Use.get(1)); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ALLOY.STABALLOY.getPlate(4), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.StainlessSteel, 2), + ALLOY.ZIRCONIUM_CARBIDE.getFrameBox(1), GT_Utility.getIntegratedCircuit(1), }, + GT_Values.NF, + GregtechItemList.Casing_Multi_Use.get(1L), + 50, + 16); + + RecipeUtils.addShapedRecipe( + o_Compressor, + o_Lathe, + o_Electromagnet, + plate, + ItemUtils.getSimpleStack(ModBlocks.blockProjectTable), + plate, + o_Fermenter, + o_Distillery, + o_Extractor, + GregtechItemList.Industrial_MultiMachine.get(1)); + } + + /* + * 6/1/19 - Content additions + */ + + // Drilling Platform Casings + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("frameGtTriniumNaquadahCarbonite", 4), + ItemUtils.getItemStackOfAmountFromOreDict("plateDoubleTriniumTitaniumAlloy", 1 * (1)), + ItemUtils.getItemStackOfAmountFromOreDict("gearGtPikyonium64B", 2 * (1)), + ALLOY.TRINIUM_REINFORCED_STEEL.getPlateDouble(4 * 1), + ItemUtils.getSimpleStack((CI.machineHull_LuV), 1 * 1), }, + ALLOY.MARAGING350.getFluidStack(144 * 16 * 1), + GregtechItemList.Casing_BedrockMiner.get(1), + (int) GT_Values.V[4], + (int) GT_Values.V[6]); + + int aCostMultiplier = 1; + + // Reservoir Hatch + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Input_EV.get(1), GT_ModHandler.getModItem(RemoteIO.ID, "tile.machine", 1), + ItemList.Electric_Pump_EV.get(1) }, + GT_Values.NF, + GregtechItemList.Hatch_Reservoir.get(1), + 100, + 1920); + + // Mystic Frame + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { GregtechItemList.Casing_Multi_Use.get(1), + ItemList.Field_Generator_MV.get(1, CI.circuitTier7), + ItemList.Field_Generator_HV.get(1, CI.circuitTier7), ItemList.Emitter_HV.get(1, CI.circuitTier7), + ItemList.Sensor_HV.get(1, CI.circuitTier7), + CI.getTieredComponent(OrePrefixes.plate, 7, 8 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.wireGt08, 8, 4 * aCostMultiplier), }, + CI.getTieredFluid(6, (144 * 8)), // Input Fluid + ItemUtils.getSimpleStack(Dimension_Everglades.blockPortalFrame, 2), + 45 * 20 * 1 * (6), + MaterialUtils.getVoltageForTier(6)); + + // Player Doors + ItemStack[] aDoorInputs = new ItemStack[] { ItemUtils.getSimpleStack(Blocks.log2), + ItemUtils.getSimpleStack(Blocks.iron_block), ItemUtils.getSimpleStack(Blocks.glass), + ItemUtils.getSimpleStack(Blocks.packed_ice), ItemUtils.getSimpleStack(Blocks.cactus), }; + ItemStack[] aDoorOutputs = new ItemStack[] { ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorWooden), + ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorIron), + ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorCustom_Glass), + ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorCustom_Ice), + ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorCustom_Cactus), }; + + for (int y = 0; y < aDoorInputs.length; y++) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(Items.iron_door), aDoorInputs[y], + ItemList.Sensor_LV.get(1, CI.circuitTier7), + CI.getTieredComponent(OrePrefixes.plate, 1, 2 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.wireGt02, 1, 2 * aCostMultiplier), + ItemUtils.getSimpleStack(Items.redstone, 16) }, + CI.getTieredFluid(1, (144 * 2)), // Input Fluid + aDoorOutputs[y], + 100, + MaterialUtils.getVoltageForTier(1)); + } + + Logger.INFO("Done loading recipes for the Various machine blocks."); + } + + private static void energyCores() { + + ItemStack[] aBufferOutput = new ItemStack[] { RECIPE_Buffer_ULV, RECIPE_Buffer_LV, RECIPE_Buffer_MV, + RECIPE_Buffer_HV, RECIPE_Buffer_EV, RECIPE_Buffer_IV, RECIPE_Buffer_LuV, RECIPE_Buffer_ZPM, + RECIPE_Buffer_UV, RECIPE_Buffer_MAX }; + + ItemStack[] aOutput = new ItemStack[] { + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "1", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "2", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "3", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "4", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "5", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "6", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "10", 1) }; + + for (int i = 0; i < 10; i++) { + + ItemStack aPrevTier = (i == 0 ? CI.getTieredMachineHull(1) : aOutput[i - 1]); + aPrevTier.stackSize = 1; + int aTier = (i + 1); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { aPrevTier, CI.getTieredComponent(OrePrefixes.plate, aTier, 4), + CI.getTieredComponent(OrePrefixes.cableGt04, i, 2), + CI.getTieredComponent(OrePrefixes.circuit, aTier, 2), + CI.getTieredComponent(OrePrefixes.screw, aTier, 6), + CI.getTieredComponent(OrePrefixes.bolt, i, 12), }, + CI.getTieredFluid(i, (144 * 4 * aTier)), // Input Fluid + aOutput[i], + 45 * 10 * 1 * (aTier), + MaterialUtils.getVoltageForTier(i)); + + // Energy Buffer + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(aOutput[i], 4), + CI.getTieredComponent(OrePrefixes.plate, aTier, 8), + CI.getTieredComponent(OrePrefixes.wireGt08, i, 4), CI.getTieredComponent(OrePrefixes.circuit, i, 4), + CI.getTieredComponent(OrePrefixes.stickLong, aTier, 4), + CI.getTieredComponent(OrePrefixes.gearGt, i, 5), }, + CI.getTieredFluid(aTier, (144 * 16 * aTier)), // Input Fluid + aBufferOutput[i], + 45 * 20 * 1 * (aTier), + MaterialUtils.getVoltageForTier(i)); + } + } + + private static void wirelessChargers() { + + ItemStack[] aChargers = new ItemStack[] { GregtechItemList.Charger_LV.get(1), + GregtechItemList.Charger_MV.get(1), GregtechItemList.Charger_HV.get(1), GregtechItemList.Charger_EV.get(1), + GregtechItemList.Charger_IV.get(1), GregtechItemList.Charger_LuV.get(1), + GregtechItemList.Charger_ZPM.get(1), GregtechItemList.Charger_UV.get(1), + GregtechItemList.Charger_UHV.get(1) }; + + for (int tier = 1; tier < aChargers.length + 1; tier++) { + + ItemStack[] aInputs = new ItemStack[] { CI.getTieredMachineHull(tier, 1), + CI.getTransmissionComponent(tier, 2), CI.getFieldGenerator(tier, 1), + CI.getTieredComponent(OrePrefixes.plate, tier + 1, 4), + CI.getTieredComponent(OrePrefixes.circuit, tier + 1, 2), }; + CORE.RA.addSixSlotAssemblingRecipe( + aInputs, + CI.getAlternativeTieredFluid(tier, (144 * 2 * (tier + 1))), // Input Fluid + aChargers[tier - 1], + 45 * 10 * (tier + 1), + MaterialUtils.getVoltageForTier(tier)); + } + } + + private static void largeArcFurnace() { + int aCostMultiplier = 1; + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { GregtechItemList.Casing_Multi_Use.get(aCostMultiplier), + CI.getTransmissionComponent(2, 2 * aCostMultiplier), CI.getElectricPiston(4, 2 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.plate, 5, 4 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.pipeSmall, 4, 1 * aCostMultiplier), }, + CI.getAlternativeTieredFluid(5, (144 * 2 * 4)), // Input Fluid + GregtechItemList.Casing_Industrial_Arc_Furnace.get(1), + 20 * 10 * 1 * (6), + MaterialUtils.getVoltageForTier(5)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { GregtechItemList.Casing_Industrial_Arc_Furnace.get(1), + CI.getFieldGenerator(4, 2 * aCostMultiplier), CI.getRobotArm(5, 4 * aCostMultiplier), + CI.getEnergyCore(4, 2 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.plate, 6, 8 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.circuit, 5, 8 * aCostMultiplier), }, + CI.getAlternativeTieredFluid(6, (144 * 4 * 5)), // Input Fluid + GregtechItemList.Industrial_Arc_Furnace.get(1), + 60 * 20 * 8, + MaterialUtils.getVoltageForTier(6)); + } + + private static void industrialVacuumFurnace() { + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { GregtechItemList.Casing_Multi_Use.get(1), CI.getHeatCoil(2), CI.getElectricPiston(3, 2), + CI.getTieredComponent(OrePrefixes.plate, 6, 4), CI.getTieredComponent(OrePrefixes.gearGt, 6, 2), }, + CI.getTertiaryTieredFluid(5, (144 * 2 * 4)), // Input Fluid + GregtechItemList.Casing_Vacuum_Furnace.get(1), + 20 * 10 * 6, + MaterialUtils.getVoltageForTier(6)); + + ; + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { GregtechItemList.Casing_Vacuum_Furnace.get(1), + CI.getTieredComponent(OrePrefixes.wireGt16, 7, 4), CI.getEnergyCore(5, 1), CI.getRobotArm(4, 4), + CI.getTieredComponent(OrePrefixes.plate, 6, 8), CI.getTieredComponent(OrePrefixes.circuit, 6, 8), }, + CI.getTieredFluid(6, (144 * 4 * 5)), // Input Fluid + GregtechItemList.Controller_Vacuum_Furnace.get(1), + 60 * 20 * 12, + MaterialUtils.getVoltageForTier(6)); + } + + private static void milling() { + + /* + * public static ItemStack RECIPE_ISAMill_Controller; public static ItemStack RECIPE_ISAMill_Gearbox; public + * static ItemStack RECIPE_ISAMill_Casing; public static ItemStack RECIPE_ISAMill_Hatch; public static ItemStack + * RECIPE_Flotation_Controller; public static ItemStack RECIPE_Flotation_Casing; + */ + + // Isa Mill Controller + CORE.RA.addAssemblylineRecipe( + ItemList.Machine_IV_Macerator.get(1), + 20 * 60 * 20, + new Object[] { GregtechItemList.Casing_IsaMill_Gearbox.get(4), CI.getTieredGTPPMachineCasing(6, 4), + ItemList.Component_Grinder_Tungsten.get(16), new Object[] { CI.getTieredCircuitOreDictName(6), 8 }, + ALLOY.INCONEL_625.getGear(8), ALLOY.INCONEL_625.getPlate(32), ALLOY.ZERON_100.getPlateDouble(8), + ALLOY.ZERON_100.getPlateDouble(8), ALLOY.ZERON_100.getScrew(64), + CI.getTieredComponentOfMaterial(Materials.NiobiumTitanium, OrePrefixes.wireFine, 32), + CI.getTieredComponentOfMaterial(Materials.NiobiumTitanium, OrePrefixes.wireFine, 32), + CI.getTieredComponentOfMaterial(Materials.Titanium, OrePrefixes.foil, 16), + CI.getTieredComponentOfMaterial(Materials.Titanium, OrePrefixes.foil, 16), }, + new FluidStack[] { CI.getTieredFluid(6, 16 * 144), CI.getAlternativeTieredFluid(6, 32 * 144), + CI.getTertiaryTieredFluid(6, 32 * 144) }, + GregtechItemList.Controller_IsaMill.get(1), + 20 * 60 * 10, + MaterialUtils.getVoltageForTier(6)); + + // Isa Mill Gearbox + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(7), ItemList.Casing_Gearbox_Titanium.get(2), + ALLOY.INCONEL_625.getGear(4), + CI.getTieredComponentOfMaterial(Materials.HSSE, OrePrefixes.gearGtSmall, 8), + ALLOY.INCONEL_625.getPlate(16), ALLOY.ZERON_100.getBolt(16), }, + ALLOY.TUNGSTENSTEEL.getFluidStack(8 * 144), + GregtechItemList.Casing_IsaMill_Gearbox.get(1), + 60 * 20 * 2, + MaterialUtils.getVoltageForTier(6)); + + // Isa Mill Casing + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(7), CI.getTieredGTPPMachineCasing(5, 1), + ALLOY.INCONEL_625.getPlate(8), ALLOY.ZERON_100.getRod(4), + CI.getTieredComponentOfMaterial(Materials.HSSG, OrePrefixes.gearGtSmall, 4), + ALLOY.ZERON_100.getScrew(8), }, + ELEMENT.getInstance().TITANIUM.getFluidStack(4 * 144), + GregtechItemList.Casing_IsaMill_Casing.get(1), + 60 * 20 * 2, + MaterialUtils.getVoltageForTier(6)); + + // Isa Mill Pipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(7), CI.getTieredGTPPMachineCasing(4, 2), + ALLOY.INCONEL_625.getPlateDouble(4), ALLOY.INCOLOY_MA956.getRing(8), + CI.getTieredComponentOfMaterial(Materials.HSSE, OrePrefixes.plate, 8), + ALLOY.INCOLOY_MA956.getBolt(16), }, + ELEMENT.getInstance().ALUMINIUM.getFluidStack(8 * 144), + GregtechItemList.Casing_IsaMill_Pipe.get(1), + 60 * 20 * 8, + MaterialUtils.getVoltageForTier(4)); + + // Flotation Cell Controller + CORE.RA.addAssemblylineRecipe( + ItemList.Distillation_Tower.get(1), + 20 * 60 * 20, + new Object[] { GregtechItemList.Casing_Flotation_Cell.get(4), CI.getTieredGTPPMachineCasing(5, 4), + ItemList.Machine_IV_Distillery.get(1), new Object[] { CI.getTieredCircuitOreDictName(6), 8 }, + ALLOY.STELLITE.getGear(8), ALLOY.STELLITE.getPlate(32), ALLOY.HASTELLOY_N.getPlateDouble(8), + ALLOY.HASTELLOY_N.getPlateDouble(8), ALLOY.HASTELLOY_N.getScrew(64), + CI.getTieredComponentOfMaterial(Materials.YttriumBariumCuprate, OrePrefixes.wireFine, 64), + CI.getTieredComponentOfMaterial(Materials.YttriumBariumCuprate, OrePrefixes.wireFine, 64), + CI.getTieredComponentOfMaterial(Materials.Platinum, OrePrefixes.foil, 32), + CI.getTieredComponentOfMaterial(Materials.Platinum, OrePrefixes.foil, 32), }, + new FluidStack[] { CI.getTieredFluid(5, 16 * 144), CI.getAlternativeTieredFluid(4, 32 * 144), + CI.getTertiaryTieredFluid(4, 32 * 144) }, + GregtechItemList.Controller_Flotation_Cell.get(1), + 20 * 60 * 10, + MaterialUtils.getVoltageForTier(6)); + + // Flotation Cell Casing + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(7), CI.getTieredGTPPMachineCasing(4, 1), + ALLOY.AQUATIC_STEEL.getPlate(8), ALLOY.STELLITE.getRing(8), + CI.getTieredComponentOfMaterial(Materials.HSSG, OrePrefixes.plateDouble, 4), + ALLOY.HASTELLOY_N.getScrew(8), }, + ALLOY.STAINLESS_STEEL.getFluidStack(8 * 144), + GregtechItemList.Casing_Flotation_Cell.get(1), + 60 * 20 * 2, + MaterialUtils.getVoltageForTier(6)); + + // Milling Bus + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(7), CI.getTieredGTPPMachineCasing(5, 1), + ItemList.Hatch_Input_Bus_EV.get(1), + CI.getTieredComponentOfMaterial(Materials.Titanium, OrePrefixes.gearGt, 8), + CI.getTieredComponentOfMaterial(Materials.TungstenSteel, OrePrefixes.plate, 32), + CI.getTieredComponentOfMaterial(Materials.SolderingAlloy, OrePrefixes.wireFine, 16), }, + ELEMENT.getInstance().TUNGSTEN.getFluidStack(8 * 144), + GregtechItemList.Bus_Milling_Balls.get(1), + 60 * 20 * 4, + MaterialUtils.getVoltageForTier(5)); + } + + private static void sparging() { + + // Sparge Tower Research + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(8), ELEMENT.getInstance().HELIUM.getCell(8), + ELEMENT.getInstance().FLUORINE.getCell(8), ALLOY.HS188A.getIngot(8), + ItemList.Distillation_Tower.get(1) }, + null, + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_10_SPARGING, 1), + 60 * 20 * 5, + MaterialUtils.getVoltageForTier(5)); + + // Sparge Tower Controller + CORE.RA.addAssemblylineRecipe( + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_10_SPARGING, 1), + 20 * 60 * 20, + new Object[] { GregtechItemList.Casing_Sparge_Tower_Exterior.get(4), CI.getTieredGTPPMachineCasing(4, 4), + ItemList.Machine_IV_Distillery.get(1), new Object[] { CI.getTieredCircuitOreDictName(5), 8 }, + ALLOY.HS188A.getGear(8), ALLOY.HS188A.getPlate(32), ALLOY.HASTELLOY_N.getPlateDouble(8), + ALLOY.HASTELLOY_N.getPlateDouble(8), ALLOY.HASTELLOY_N.getScrew(64), + CI.getTieredComponentOfMaterial(Materials.YttriumBariumCuprate, OrePrefixes.wireFine, 64), + CI.getTieredComponentOfMaterial(Materials.YttriumBariumCuprate, OrePrefixes.wireFine, 64), + CI.getTieredComponentOfMaterial(Materials.Platinum, OrePrefixes.foil, 32), + CI.getTieredComponentOfMaterial(Materials.Platinum, OrePrefixes.foil, 32), }, + new FluidStack[] { CI.getTieredFluid(4, 16 * 144), CI.getAlternativeTieredFluid(3, 32 * 144), + CI.getTertiaryTieredFluid(3, 32 * 144) }, + GregtechItemList.Controller_Sparge_Tower.get(1), + 20 * 60 * 10, + MaterialUtils.getVoltageForTier(6)); + + // Sparge Tower Casing + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(8), CI.getTieredGTPPMachineCasing(3, 1), + ALLOY.HS188A.getPlate(2), ALLOY.HASTELLOY_N.getRing(4), + CI.getTieredComponentOfMaterial(Materials.TungstenSteel, OrePrefixes.plateDouble, 4), + ALLOY.HASTELLOY_N.getScrew(4), }, + ALLOY.STAINLESS_STEEL.getFluidStack(8 * 144), + GregtechItemList.Casing_Sparge_Tower_Exterior.get(1), + 60 * 20 * 2, + MaterialUtils.getVoltageForTier(5)); + } + + private static void chisels() { + ItemStack[] aChisels = new ItemStack[] { GregtechItemList.GT_Chisel_LV.get(1), + GregtechItemList.GT_Chisel_MV.get(1), GregtechItemList.GT_Chisel_HV.get(1), }; + for (int i = 1; i < 4; i++) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(10 + i), CI.getTieredMachineCasing(i), CI.getPlate(i, 4), + CI.getElectricMotor(i, 2), CI.getConveyor(i, 2), CI.getRobotArm(i, 1) }, + CI.getTieredFluid(i, 144 * 4), + aChisels[i - 1], + 20 * 20, + MaterialUtils.getVoltageForTier(i)); + } + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(14), aChisels[2], CI.getPlate(4, 8), CI.getElectricMotor(4, 8), + CI.getConveyor(4, 8), CI.getRobotArm(4, 4) }, + CI.getTieredFluid(4, 144 * 8), + GregtechItemList.Controller_IndustrialAutoChisel.get(1), + 20 * 20, + MaterialUtils.getVoltageForTier(4)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedBioCircuit(14), ItemList.Casing_SolidSteel.get(2), CI.getPlate(4, 2), + CI.getTieredComponent(OrePrefixes.plate, 3, 4), CI.getTieredComponent(OrePrefixes.ring, 3, 8), + CI.getTieredComponent(OrePrefixes.rod, 2, 4), }, + CI.getTieredFluid(2, 144 * 2), + GregtechItemList.Casing_IndustrialAutoChisel.get(1), + 20 * 20, + MaterialUtils.getVoltageForTier(3)); + } + + private static void rockBreaker() { + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(12), ItemList.Machine_EV_RockBreaker.get(1), + ALLOY.STAINLESS_STEEL.getPlate(8), ALLOY.STAINLESS_STEEL.getRing(4), + CI.getTieredComponentOfMaterial(Materials.Aluminium, OrePrefixes.plateDouble, 8), + ALLOY.EGLIN_STEEL.getScrew(8), }, + ELEMENT.getInstance().ALUMINIUM.getFluidStack(144 * 8), + GregtechItemList.Controller_IndustrialRockBreaker.get(1), + 60 * 20 * 2, + MaterialUtils.getVoltageForTier(4)); + } + + private static void fakeMachineCasingCovers() { + int aMaxTier = GT_Values.VOLTAGE_NAMES.length; + ItemStack aTier[] = new ItemStack[aMaxTier]; + for (int i = 0; i < aMaxTier; i++) { + aTier[i] = ItemUtils.simpleMetaStack(CoverManager.Cover_Gt_Machine_Casing, i, 7); + } + // 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 superBuses() { + GregtechItemList[] mSuperBusesInput = new GregtechItemList[] { 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_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), }; + + // Input Buses + for (int tier = 1; tier < mSuperBusesInput.length + 1; tier++) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedCircuit(17), mInputHatch[tier - 1], CI.getElectricMotor(tier, 2), + CI.getConveyor(tier, 5), CI.getBolt(tier, 16), + CI.getTieredComponent(OrePrefixes.circuit, tier, 2) }, + CI.getAlternativeTieredFluid(tier, 144 * 8), + mSuperBusesInput[tier - 1].get(1), + 20 * 30 * 2, + (int) GT_Values.V[tier]); + } + // Output Buses + for (int tier = 1; tier < mSuperBusesOutput.length + 1; tier++) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedCircuit(18), mOutputHatch[tier - 1], CI.getElectricPiston(tier, 2), + CI.getConveyor(tier, 5), CI.getGear(tier, 3), CI.getTieredComponent(OrePrefixes.circuit, tier, 2) }, + CI.getTertiaryTieredFluid(tier, 144 * 8), + mSuperBusesOutput[tier - 1].get(1), + 20 * 30 * 2, + (int) GT_Values.V[tier]); + } + } + + private static void chiselBuses() { + ItemStack[] mSuperBusesInput = new ItemStack[] { GregtechItemList.Hatch_SuperBus_Input_LV.get(1), + GregtechItemList.Hatch_SuperBus_Input_MV.get(1), GregtechItemList.Hatch_SuperBus_Input_HV.get(1), }; + + ItemStack[] mChiselBuses = new ItemStack[] { GregtechItemList.GT_MetaTileEntity_ChiselBus_LV.get(1), + GregtechItemList.GT_MetaTileEntity_ChiselBus_MV.get(1), + GregtechItemList.GT_MetaTileEntity_ChiselBus_HV.get(1), }; + + for (int tier = 1; tier < mChiselBuses.length + 1; tier++) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedCircuit(17), mSuperBusesInput[tier - 1], CI.getSensor(tier, 1), + CI.getRobotArm(tier, 2), CI.getBolt(tier, 16), ItemUtils.getSimpleStack(Blocks.chest) }, + CI.getAlternativeTieredFluid(tier, 144 * 2), + mChiselBuses[tier - 1], + 20 * 30 * 2, + (int) GT_Values.VP[tier + 1]); + } + } + + private static void solidifierHatches() { + ItemStack[] mSuperBusesInput = new ItemStack[] { ItemList.Hatch_Input_IV.get(1), + ItemList.Hatch_Input_LuV.get(1), ItemList.Hatch_Input_ZPM.get(1), ItemList.Hatch_Input_UV.get(1), }; + + ItemStack[] mSolidifierHatches = new ItemStack[] { GregtechItemList.GT_MetaTileEntity_Solidifier_I.get(1), + GregtechItemList.GT_MetaTileEntity_Solidifier_II.get(1), + GregtechItemList.GT_MetaTileEntity_Solidifier_III.get(1), + GregtechItemList.GT_MetaTileEntity_Solidifier_IV.get(1), }; + + for (int i = 0; i < 4; i++) { + int componentTier = i + 5; + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedCircuit(17), mSuperBusesInput[i], CI.getSensor(componentTier, 1), + CI.getFluidRegulator(componentTier, 1), + CI.getTieredComponent(OrePrefixes.circuit, componentTier + 1, 4), + ItemUtils.getSimpleStack(Blocks.chest) }, + CI.getTieredFluid(componentTier, 144 * 2), + mSolidifierHatches[i], + 20 * 30, + (int) GT_Values.VP[componentTier]); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java new file mode 100644 index 0000000000..0cf0152c53 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java @@ -0,0 +1,168 @@ +package gtPlusPlus.core.recipe; + +import static gregtech.api.recipe.RecipeMaps.brewingRecipes; +import static gregtech.api.recipe.RecipeMaps.chemicalBathRecipes; +import static gregtech.api.recipe.RecipeMaps.electrolyzerRecipes; +import static gregtech.api.recipe.RecipeMaps.laserEngraverRecipes; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gtPlusPlus.core.material.MISC_MATERIALS.BRINE; +import static gtPlusPlus.core.material.MISC_MATERIALS.HYDROGEN_CHLORIDE; +import static gtPlusPlus.core.material.MISC_MATERIALS.HYDROGEN_CHLORIDE_MIX; +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 net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +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.TierEU; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.item.ModItems; +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.xmod.gregtech.api.enums.GregtechItemList; + +public class RECIPES_RareEarthProcessing { + + public static void init() { + + // Brine Check and assignment + FluidStack mBrine = FluidUtils.getFluidStack("brine", 1000); + if (mBrine == null) { + Fluid f = BRINE.generateFluid(); + BRINE.registerComponentForMaterial(FluidUtils.getFluidStack(f, 1000)); + mBrine = BRINE.getFluidStack(1000); + } else { + BRINE.registerComponentForMaterial(FluidUtils.getFluidStack(mBrine, 1000)); + } + + // Hydrogen Chloride Check and assignment + FluidStack mHydrogenChloride = FluidUtils.getFluidStack("hydrogenchloride", 1000); + if (mHydrogenChloride == null) { + HYDROGEN_CHLORIDE.generateFluid(); + mHydrogenChloride = BRINE.getFluidStack(1000); + } else { + HYDROGEN_CHLORIDE.registerComponentForMaterial(FluidUtils.getFluidStack(mHydrogenChloride, 1000)); + } + + // Add Process for creating Brine + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Salt, 16L)) + .fluidInputs(Materials.SaltWater.getFluid(2000L)) + .fluidOutputs(FluidUtils.getFluidStack(mBrine, 4000)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(brewingRecipes); + + // Chloralkali process + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(1), ItemList.Cell_Empty.get(2L)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Chlorine, 1L), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SodiumHydroxide, 1L)) + .fluidInputs(FluidUtils.getFluidStack(mBrine, 2000)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + // Generate Special Laser Recipe + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Chlorine, 1L), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 1L), + CI.getNumberedBioCircuit(2)) + .itemOutputs(ItemUtils.getSimpleStack(ModItems.cellHydrogenChlorideMix, 2)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(GregtechItemList.Laser_Lens_WoodsGlass.get(0)) + .fluidInputs(HYDROGEN_CHLORIDE_MIX.getFluidStack(4000)) + .fluidOutputs(HYDROGEN_CHLORIDE.getFluidStack(4000)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_HV) + .noOptimize() + .addTo(laserEngraverRecipes); + + // 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); + + // industrial strength HCl + Fluid aHydrochloric = FluidUtils.getFluidStack("hydrogenchloride", 1) + .getFluid(); + + // LV Rare Earth + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.RareEarth, 3L)) + .itemOutputs(RARE_EARTH_LOW.getCrushed(2), RARE_EARTH_LOW.getCrushed(2), RARE_EARTH_LOW.getCrushed(2)) + .fluidInputs(Materials.SulfuricAcid.getFluid(1000L)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(chemicalBathRecipes); + + // HV Rare Earth + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.RareEarth, 3L)) + .itemOutputs(RARE_EARTH_MID.getCrushed(2), RARE_EARTH_MID.getCrushed(2), RARE_EARTH_MID.getCrushed(2)) + .outputChances(10000, 9000, 8000) + .fluidInputs(FluidUtils.getFluidStack(aHydrochloric, 1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(chemicalBathRecipes); + + // IV Rare Earth + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.RareEarth, 3L)) + .itemOutputs(RARE_EARTH_HIGH.getCrushed(2), RARE_EARTH_HIGH.getCrushed(2), RARE_EARTH_HIGH.getCrushed(2)) + .outputChances(10000, 9000, 8000) + .fluidInputs(FluidUtils.getHydrofluoricAcid(1000)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(chemicalBathRecipes); + + // IV Rare Earth + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.RareEarth, 3L)) + .itemOutputs(RARE_EARTH_HIGH.getCrushed(2), RARE_EARTH_HIGH.getCrushed(2), RARE_EARTH_HIGH.getCrushed(2)) + .outputChances(9000, 8000, 7000) + .fluidInputs(Materials.HydrofluoricAcid.getFluid(2000L)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(chemicalBathRecipes); + } +} diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java new file mode 100644 index 0000000000..b7a7b43549 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java @@ -0,0 +1,142 @@ +package gtPlusPlus.core.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MISC_MATERIALS; +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 gtPlusPlus.core.util.reflect.AddGregtechRecipe; + +public class RECIPES_SeleniumProcessing { + + public static void init() { + + // We need this + MaterialUtils.generateSpecialDustAndAssignToAMaterial(MISC_MATERIALS.SELENIUM_DIOXIDE, false); + + // Makes Selenium Dioxide + processCopperRecipes(); + + // Liquify the Dried Dioxide + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), + 13, + FluidUtils.getSteam(500), + null, + MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(1000), + 20, + 1024); + + // Produce Selenious Acid + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + MISC_MATERIALS.SELENIUM_DIOXIDE.getCell(1), + 14, + FluidUtils.getHotWater(4000), + CI.emptyCells(1), + MISC_MATERIALS.SELENIOUS_ACID.getFluidStack(1000), + 20, + 2048); + + // Make Selenium + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { ItemUtils.getGregtechCircuit(14), ELEMENT.getInstance().CARBON.getDust(16), }, + new FluidStack[] { MISC_MATERIALS.SELENIOUS_ACID.getFluidStack(750), + Materials.SulfuricAcid.getFluid(8000), }, + ELEMENT.getInstance().SELENIUM.getFluidStack(144 * 1), + new ItemStack[] { ELEMENT.getInstance().SELENIUM.getIngot(1), ELEMENT.getInstance().SELENIUM.getIngot(1), }, + new int[] { 10000, 2000, 2000 }, + 20 * 300, + 7200); + + /* + * // Old recipes for Selenium Roasting CORE.RA.addBlastSmelterRecipe( new ItemStack[] { + * ItemUtils.getGregtechCircuit(16), ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedPyrite", 8), + * ELEMENT.getInstance().CARBON.getDust(32), }, Materials.SulfuricAcid.getFluid(4000), + * ELEMENT.getInstance().SELENIUM.getFluid(144), 0, 20 * 300, 2000); CORE.RA.addBlastSmelterRecipe( new + * ItemStack[] { ItemUtils.getGregtechCircuit(17), + * ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedChalcopyrite", 8), + * ELEMENT.getInstance().CARBON.getDust(32), }, Materials.SulfuricAcid.getFluid(4000), + * ELEMENT.getInstance().SELENIUM.getFluid(144), 0, 20 * 300, 2000); CORE.RA.addBlastSmelterRecipe( new + * ItemStack[] { ItemUtils.getGregtechCircuit(18), + * ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedGalena", 8), + * ELEMENT.getInstance().CARBON.getDust(32), }, Materials.SulfuricAcid.getFluid(4000), + * ELEMENT.getInstance().SELENIUM.getFluid(144), 0, 20 * 300, 2000); + */ + } + + public static void processCopperRecipes() { + + // Copper + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(23), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Copper, 1), // Item Input + }, + FluidUtils.getHotWater(1000), // Fluid + MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(20), // Fluid + new ItemStack[] { 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), MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), }, // Output + new int[] { 10000, 100, 100, 500, 500, 500, 1000, 1000, 1000 }, + 40 * 20, // Time in ticks + 1024); // EU + + // Tetra + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(23), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Tetrahedrite, 1), // Item + // Input + }, + FluidUtils.getHotWater(1000), // Fluid + MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(10), // Fluid + new ItemStack[] { 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), MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), }, // Output + new int[] { 10000, 100, 100, 300, 300, 300, 800, 800, 800 }, + 40 * 20, // Time in ticks + 1024); // EU + + // Chalco + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(23), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Chalcopyrite, 1), // Item + // Input + }, + FluidUtils.getHotWater(1000), // Fluid + MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(10), // Fluid + new ItemStack[] { 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), MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), }, // Output + new int[] { 10000, 100, 100, 300, 300, 300, 800, 800, 800 }, + 40 * 20, // Time in ticks + 1024); // EU + + // Malachite + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedAdvancedCircuit(23), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Malachite, 1), // Item Input + }, + FluidUtils.getHotWater(1000), // Fluid + MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(10), // Fluid + new ItemStack[] { 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), MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), }, // Output + new int[] { 10000, 100, 100, 300, 300, 300, 800, 800, 800 }, + 40 * 20, // Time in ticks + 1024); // EU + } +} diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Tools.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Tools.java new file mode 100644 index 0000000000..229b7cc045 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Tools.java @@ -0,0 +1,118 @@ +package gtPlusPlus.core.recipe; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class RECIPES_Tools { + + // Outputs + public static ItemStack RECIPE_SandStone = new ItemStack(Blocks.sandstone, 2); + public static ItemStack RECIPE_Sand = new ItemStack(Blocks.sand, 4); + + public static ItemStack RECIPE_DivisionSigil; + + // MC Items + public static Item Apple = Items.apple; + + // MC Blocks + public static Block CobbleStone = Blocks.cobblestone; + public static Block Dirt = Blocks.dirt; + public static Block Sand = Blocks.sand; + public static Block Gravel = Blocks.gravel; + public static Block Sandstone = Blocks.sandstone; + + // null + public static String empty = " "; + + // Batteries + public static String batteryBasic = "batteryBasic"; + public static String batteryAdvanced = "batteryAdvanced"; + public static String batteryElite = "batteryElite"; + public static String batteryMaster = "batteryMaster"; + public static String batteryUltimate = "batteryUltimate"; + + // Circuits + public static String circuitPrimitive = "circuitPrimitive"; + public static String circuitBasic = "circuitBasic"; + public static String circuitGood = "circuitGood"; + public static String circuitAdvanced = "circuitAdvanced"; + public static String circuitElite = "circuitElite"; + public static String circuitMaster = "circuitMaster"; + public static String circuitUltimate = "circuitUltimate"; + + // Cables + public static String cableGt01Electrum = "cableGt01Electrum"; + public static String cableGt02Electrum = "cableGt02Electrum"; + public static String cableGt01RedstoneAlloy = "cableGt01RedstoneAlloy"; + public static String cableGt02RedstoneAlloy = "cableGt02RedstoneAlloy"; + public static String cableGt01Copper = "cableGt01Copper"; + public static String cableGt02Copper = "cableGt02Copper"; + public static String cableGt01AnnealedCopper = "cableGt01AnnealedCopper"; + public static String cableGt02AnnealedCopper = "cableGt02AnnealedCopper"; + + // Rods + public static String stickWood = "stickWood"; + public static String stickStaballoy = "stickStaballoy"; + public static String stickTitanium = "stickTitanium"; + public static String stickIron = "stickIron"; + public static String stickGold = "stickGold"; + public static String stickSilver = "stickSilver"; + public static String stickSteel = "stickSteel"; + public static String stickBronze = "stickBronze"; + public static String stickTungsten = "stickTungsten"; + public static String stickRedAlloy = "stickRedAlloy"; + public static String stickInvar = "stickInvar"; + public static String stickElectrum = "stickElectrum"; + public static String stickElectricalSteel = "stickElectricalSteel"; + + // Plates + public static String plateStaballoy = "plateStaballoy"; + public static String plateTitanium = "plateTitanium"; + public static String plateIron = "plateIron"; + public static String plateGold = "plateGold"; + public static String plateSilver = "plateSilver"; + public static String plateSteel = "plateSteel"; + public static String plateBronze = "plateBronze"; + public static String plateTungsten = "plateTungsten"; + public static String plateRedAlloy = "plateRedAlloy"; + public static String plateInvar = "plateInvar"; + public static String plateElectrum = "plateElectrum"; + public static String plateElectricalSteel = "plateElectricalSteel"; + + // Ingots + public static String ingotStaballoy = "ingotStaballoy"; + public static String ingotTitanium = "ingotTitanium"; + public static String ingotIron = "ingotIron"; + public static String ingotGold = "ingotGold"; + public static String ingotSilver = "ingotSilver"; + public static String ingotSteel = "ingotSteel"; + public static String ingotBronze = "ingotBronze"; + public static String ingotTungsten = "ingotTungsten"; + public static String ingotRedAlloy = "ingotRedAlloy"; + public static String ingotInvar = "ingotInvar"; + public static String ingotElectrum = "ingotElectrum"; + public static String ingotUranium = "ingotUranium"; + public static String ingotElectricalSteel = "ingotElectricalSteel"; + + // Crafting Tools + public static String craftingToolHardHammer = "craftingToolHardHammer"; + public static String craftingToolSoftHammer = "craftingToolSoftHammer"; + public static String craftingToolFile = "craftingToolFile"; + public static String craftingToolSaw = "craftingToolSaw"; + public static String craftingToolPickaxe = "craftingToolPickaxe"; + public static String craftingToolWrench = "craftingToolWrench"; + public static String craftingToolCrowbar = "craftingToolCrowbar"; + public static String craftingToolKnife = "craftingToolKnife"; + public static String craftingToolScrewdriver = "craftingToolScrewdriver"; + + public static ItemStack personalCloakingDevice = ItemUtils.getSimpleStack(ModItems.itemPersonalCloakingDevice); + public static String plateDoubleNiChrome = "plateDoubleNichrome"; + public static String plateIridiumAlloy = "plateAlloyIridium"; + +} diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPE_Batteries.java b/src/main/java/gtPlusPlus/core/recipe/RECIPE_Batteries.java new file mode 100644 index 0000000000..4369fdbfa3 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPE_Batteries.java @@ -0,0 +1,62 @@ +package gtPlusPlus.core.recipe; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.ItemList; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + +public class RECIPE_Batteries { + + static ItemStack RECIPE_Battery_Sodium = GregtechItemList.Battery_RE_EV_Sodium.get(1); + static ItemStack RECIPE_Battery_Cadmium = GregtechItemList.Battery_RE_EV_Cadmium.get(1); + static ItemStack RECIPE_Battery_Lithium = GregtechItemList.Battery_RE_EV_Lithium.get(1); + static ItemStack GT_Battery_Sodium = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32539, 1); + static ItemStack GT_Battery_Cadmium = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32537, 1); + static ItemStack GT_Battery_Lithium = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32538, 1); + static ItemStack machineTransformer_EV; + + public static void loadRecipes() { + machineTransformer_EV = ItemList.Transformer_EV_HV.get(1); + run(); + } + + private static void run() { + + RecipeUtils.addShapedGregtechRecipe( + GT_Battery_Sodium, + RECIPES_Machines.cableTier4, + GT_Battery_Sodium, + CI.circuitTier3, + machineTransformer_EV, + CI.circuitTier3, + GT_Battery_Sodium, + RECIPES_Machines.cableTier4, + GT_Battery_Sodium, + RECIPE_Battery_Sodium); + RecipeUtils.addShapedGregtechRecipe( + GT_Battery_Cadmium, + RECIPES_Machines.cableTier4, + GT_Battery_Cadmium, + CI.circuitTier3, + machineTransformer_EV, + CI.circuitTier3, + GT_Battery_Cadmium, + RECIPES_Machines.cableTier4, + GT_Battery_Cadmium, + RECIPE_Battery_Cadmium); + RecipeUtils.addShapedGregtechRecipe( + GT_Battery_Lithium, + RECIPES_Machines.cableTier4, + GT_Battery_Lithium, + CI.circuitTier3, + machineTransformer_EV, + CI.circuitTier3, + GT_Battery_Lithium, + RECIPES_Machines.cableTier4, + GT_Battery_Lithium, + RECIPE_Battery_Lithium); + } +} diff --git a/src/main/java/gtPlusPlus/core/recipe/ShapedRecipeObject.java b/src/main/java/gtPlusPlus/core/recipe/ShapedRecipeObject.java new file mode 100644 index 0000000000..18c1c2c70c --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/ShapedRecipeObject.java @@ -0,0 +1,50 @@ +package gtPlusPlus.core.recipe; + +import net.minecraft.item.ItemStack; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.RecipeUtils; + +public class ShapedRecipeObject { + + public Object object_A; + public Object object_B; + public Object object_C; + public Object object_D; + public Object object_E; + public Object object_F; + public Object object_G; + public Object object_H; + public Object object_I; + public ItemStack object_OUTPUT; + + public ShapedRecipeObject(final Object input_A, final Object input_B, final Object input_C, final Object input_D, + final Object input_E, final Object input_F, final Object input_G, final Object input_H, final Object input_I, + final ItemStack input_Output) { + this.object_A = input_A; + this.object_B = input_B; + this.object_C = input_C; + this.object_D = input_D; + this.object_E = input_E; + this.object_F = input_F; + this.object_G = input_G; + this.object_H = input_H; + this.object_I = input_I; + this.object_OUTPUT = input_Output; + Logger.SPECIFIC_WARNING("ShapedRecipeObject", "New object created.", 36); + } + + public void buildRecipe() { + RecipeUtils.recipeBuilder( + this.object_A, + this.object_B, + this.object_C, + this.object_D, + this.object_E, + this.object_F, + this.object_G, + this.object_H, + this.object_I, + this.object_OUTPUT); + } +} diff --git a/src/main/java/gtPlusPlus/core/recipe/common/CI.java b/src/main/java/gtPlusPlus/core/recipe/common/CI.java new file mode 100644 index 0000000000..5c1620160d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/recipe/common/CI.java @@ -0,0 +1,1008 @@ +package gtPlusPlus.core.recipe.common; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.item.chemistry.GenericChem; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.recipe.LOADER_Machine_Components; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import ic2.core.Ic2Items; + +public class CI { + + // null + public static ItemStack _NULL = ItemUtils.getErrorStack(1); + + // bits + public static long bits = GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE + | GT_ModHandler.RecipeBits.BUFFERED; + public static long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE + | GT_ModHandler.RecipeBits.BUFFERED; + + // Circuits + public static Object circuitPrimitive; + public static Object circuitTier1; + public static Object circuitTier2; + public static Object circuitTier3; + public static Object circuitTier4; + public static Object circuitTier5; + public static Object circuitTier6; + public static Object circuitTier7; + public static Object circuitTier8; + public static Object circuitTier9; + + // Machine Components + public static ItemStack electricMotor_LV; + public static ItemStack electricMotor_MV; + public static ItemStack electricMotor_HV; + public static ItemStack electricMotor_EV; + public static ItemStack electricMotor_IV; + public static ItemStack electricMotor_LuV; + public static ItemStack electricMotor_ZPM; + public static ItemStack electricMotor_UV; + public static ItemStack electricMotor_UHV; + public static ItemStack electricPump_LV; + public static ItemStack electricPump_MV; + public static ItemStack electricPump_HV; + public static ItemStack electricPump_EV; + public static ItemStack electricPump_IV; + public static ItemStack electricPump_LuV; + public static ItemStack electricPump_ZPM; + public static ItemStack electricPump_UV; + public static ItemStack electricPump_UHV; + public static ItemStack electricPiston_LV; + public static ItemStack electricPiston_MV; + public static ItemStack electricPiston_HV; + public static ItemStack electricPiston_EV; + public static ItemStack electricPiston_IV; + public static ItemStack electricPiston_LuV; + public static ItemStack electricPiston_ZPM; + public static ItemStack electricPiston_UV; + public static ItemStack electricPiston_UHV; + public static ItemStack robotArm_LV; + public static ItemStack robotArm_MV; + public static ItemStack robotArm_HV; + public static ItemStack robotArm_EV; + public static ItemStack robotArm_IV; + public static ItemStack robotArm_LuV; + public static ItemStack robotArm_ZPM; + public static ItemStack robotArm_UV; + public static ItemStack robotArm_UHV; + public static ItemStack conveyorModule_LV; + public static ItemStack conveyorModule_MV; + public static ItemStack conveyorModule_HV; + public static ItemStack conveyorModule_EV; + public static ItemStack conveyorModule_IV; + public static ItemStack conveyorModule_LuV; + public static ItemStack conveyorModule_ZPM; + public static ItemStack conveyorModule_UV; + public static ItemStack conveyorModule_UHV; + public static ItemStack emitter_LV; + public static ItemStack emitter_MV; + public static ItemStack emitter_HV; + public static ItemStack emitter_EV; + public static ItemStack emitter_IV; + public static ItemStack emitter_LuV; + public static ItemStack emitter_ZPM; + public static ItemStack emitter_UV; + public static ItemStack emitter_UHV; + public static ItemStack fieldGenerator_LV; + public static ItemStack fieldGenerator_MV; + public static ItemStack fieldGenerator_HV; + public static ItemStack fieldGenerator_EV; + public static ItemStack fieldGenerator_IV; + public static ItemStack fieldGenerator_LuV; + public static ItemStack fieldGenerator_ZPM; + public static ItemStack fieldGenerator_UV; + public static ItemStack fieldGenerator_UHV; + public static ItemStack sensor_LV; + public static ItemStack sensor_MV; + public static ItemStack sensor_HV; + public static ItemStack sensor_EV; + public static ItemStack sensor_IV; + public static ItemStack sensor_LuV; + public static ItemStack sensor_ZPM; + public static ItemStack sensor_UV; + public static ItemStack sensor_UHV; + + public static ItemStack fluidRegulator_LV; + public static ItemStack fluidRegulator_MV; + public static ItemStack fluidRegulator_HV; + public static ItemStack fluidRegulator_EV; + public static ItemStack fluidRegulator_IV; + public static ItemStack fluidRegulator_LuV; + public static ItemStack fluidRegulator_ZPM; + public static ItemStack fluidRegulator_UV; + + // Machine Casings + public static ItemStack machineCasing_ULV; + public static ItemStack machineCasing_LV; + public static ItemStack machineCasing_MV; + public static ItemStack machineCasing_HV; + public static ItemStack machineCasing_EV; + public static ItemStack machineCasing_IV; + public static ItemStack machineCasing_LuV; + public static ItemStack machineCasing_ZPM; + public static ItemStack machineCasing_UV; + public static ItemStack machineCasing_UHV; + + // Machine Hulls + public static ItemStack machineHull_ULV; + public static ItemStack machineHull_LV; + public static ItemStack machineHull_MV; + public static ItemStack machineHull_HV; + public static ItemStack machineHull_EV; + public static ItemStack machineHull_IV; + public static ItemStack machineHull_LuV; + public static ItemStack machineHull_ZPM; + public static ItemStack machineHull_UV; + public static ItemStack machineHull_UHV; + + // Gearbox Casings + public static ItemStack gearboxCasing_Tier_1; + public static ItemStack gearboxCasing_Tier_2; + public static ItemStack gearboxCasing_Tier_3; + public static ItemStack gearboxCasing_Tier_4; + + public static String[] component_Plate; + public static String[] component_Rod; + public static String[] component_Ingot; + + // Crafting Tools + public static String craftingToolWrench = "craftingToolWrench"; + public static String craftingToolHammer_Hard = "craftingToolHardHammer"; + public static String craftingToolScrewdriver = "craftingToolScrewdriver"; + public static String craftingToolFile = "craftingToolFile"; + public static String craftingToolMortar = "craftingToolMortar"; + public static String craftingToolSaw = "craftingToolSaw"; + public static String craftingToolWireCutter = "craftingToolWirecutter"; + public static String craftingToolSolderingIron = "craftingToolSolderingIron"; + + // Explosives + public static ItemStack explosivePowderKeg; + public static ItemStack explosiveTNT; + public static ItemStack explosiveITNT; + + public static Materials[] tieredMaterials = new Materials[] { Materials.Iron, Materials.Steel, Materials.Aluminium, + Materials.StainlessSteel, Materials.Titanium, Materials.TungstenSteel, Materials.Chrome, Materials.Iridium, + Materials.Osmium, Materials.Neutronium }; + + public static void preInit() { + + // Tiered Components + component_Plate = new String[] { getTieredComponent(OrePrefixes.plate, 0), + getTieredComponent(OrePrefixes.plate, 1), getTieredComponent(OrePrefixes.plate, 2), + getTieredComponent(OrePrefixes.plate, 3), getTieredComponent(OrePrefixes.plate, 4), + getTieredComponent(OrePrefixes.plate, 5), getTieredComponent(OrePrefixes.plate, 6), + getTieredComponent(OrePrefixes.plate, 7), getTieredComponent(OrePrefixes.plate, 8), + getTieredComponent(OrePrefixes.plate, 9), getTieredComponent(OrePrefixes.plate, 10), + getTieredComponent(OrePrefixes.plate, 11) }; + component_Rod = new String[] { getTieredComponent(OrePrefixes.stick, 0), + getTieredComponent(OrePrefixes.stick, 1), getTieredComponent(OrePrefixes.stick, 2), + getTieredComponent(OrePrefixes.stick, 3), getTieredComponent(OrePrefixes.stick, 4), + getTieredComponent(OrePrefixes.stick, 5), getTieredComponent(OrePrefixes.stick, 6), + getTieredComponent(OrePrefixes.stick, 7), getTieredComponent(OrePrefixes.stick, 8), + getTieredComponent(OrePrefixes.stick, 9), getTieredComponent(OrePrefixes.stick, 10), + getTieredComponent(OrePrefixes.stick, 11) }; + component_Ingot = new String[] { getTieredComponent(OrePrefixes.ingot, 0), + getTieredComponent(OrePrefixes.ingot, 1), getTieredComponent(OrePrefixes.ingot, 2), + getTieredComponent(OrePrefixes.ingot, 3), getTieredComponent(OrePrefixes.ingot, 4), + getTieredComponent(OrePrefixes.ingot, 5), getTieredComponent(OrePrefixes.ingot, 6), + getTieredComponent(OrePrefixes.ingot, 7), getTieredComponent(OrePrefixes.ingot, 8), + getTieredComponent(OrePrefixes.ingot, 9), getTieredComponent(OrePrefixes.ingot, 10), + getTieredComponent(OrePrefixes.ingot, 11) }; + + // Circuits + circuitPrimitive = getTieredCircuit(0); + circuitTier1 = getTieredCircuit(1); + circuitTier2 = getTieredCircuit(2); + circuitTier3 = getTieredCircuit(3); + circuitTier4 = getTieredCircuit(4); + circuitTier5 = getTieredCircuit(5); + circuitTier6 = getTieredCircuit(6); + circuitTier7 = getTieredCircuit(7); + circuitTier8 = getTieredCircuit(8); + circuitTier9 = getTieredCircuit(9); + } + + public static Object getTieredCircuit(int tier) { + return getTieredCircuitOreDictName(tier); + } + + public static String getTieredCircuitOreDictName(int tier) { + if (tier == 0) { + return "circuitPrimitive"; + } else if (tier == 1) { + return "circuitBasic"; + } else if (tier == 2) { + return "circuitGood"; + } else if (tier == 3) { + return "circuitAdvanced"; + } else if (tier == 4) { + return "circuitData"; + } else if (tier == 5) { + return "circuitElite"; + } else if (tier == 6) { + return "circuitMaster"; + } else if (tier == 7) { + return "circuitUltimate"; + } else if (tier == 8) { + return "circuitSuperconductor"; + } else if (tier == 9) { + return "circuitInfinite"; + } else if (tier == 10) { + return "circuitQuantum"; + } else { + return "circuitPrimitive"; + } + } + + public static ItemStack getNumberedCircuit(int Meta) { + return ItemUtils.getGregtechCircuit(Meta); + } + + private static Object getMaterialFromTier(int tier) { + if (tier == 0) { + return Materials.Wood; + } else if (tier == 1) { + return Materials.Lead; + } else if (tier == 2) { + return Materials.Bronze; + } else if (tier == 3) { + return Materials.Steel; + } else if (tier == 4) { + return ALLOY.EGLIN_STEEL; + } else if (tier == 5) { + return Materials.Aluminium; + } else if (tier == 6) { + return ALLOY.MARAGING250; + } else if (tier == 7) { + return ALLOY.TANTALLOY_61; + } else if (tier == 8) { + return ALLOY.INCONEL_792; + } else if (tier == 9) { + return ALLOY.ZERON_100; + } else if (tier == 10) { + return Materials.NaquadahEnriched; + } else if (tier == 11) { + return Materials.Neutronium; + } + return Materials._NULL; + } + + public static String getTieredComponent(OrePrefixes type, int tier) { + Object material = getMaterialFromTier(tier); + if (material != null) { + if (material instanceof Materials) { + // return (ItemStack) type.get(material); + String materialName = ((Materials) material).mDefaultLocalName; + Logger.INFO("Searching for a component named " + type.name() + materialName); + // return ItemUtils.getItemStackOfAmountFromOreDict(type.name()+materialName, 1); + return (type.name() + materialName); + } else { + String materialName = (Utils.sanitizeString(((Material) material).getLocalizedName())); + Logger.INFO("Searching for a component named " + type.name() + materialName); + // return ItemUtils.getItemStackOfAmountFromOreDict(type.name()+materialName, 1); + return (type.name() + materialName); + } + } + Logger.INFO("[Components] Failed getting a tiered component. " + type.name() + " | " + tier); + return null; + } + + public static ItemStack getDataOrb() { + return ItemList.Tool_DataOrb.get(1); + } + + public static ItemStack getDataStick() { + return ItemList.Tool_DataStick.get(1); + } + + public static ItemStack getTieredMachineHull(int tier) { + if (tier == 0) { + return machineHull_ULV; + } else if (tier == 1) { + return machineHull_LV; + } else if (tier == 2) { + return machineHull_MV; + } else if (tier == 3) { + return machineHull_HV; + } else if (tier == 4) { + return machineHull_EV; + } else if (tier == 5) { + return machineHull_IV; + } else if (tier == 6) { + return machineHull_LuV; + } else if (tier == 7) { + return machineHull_ZPM; + } else if (tier == 8) { + return machineHull_UV; + } else if (tier == 9) { + return machineHull_UHV; + } else { + return GregtechItemList.Casing_Multi_Use.get(1); + } + } + + public static ItemStack getTieredMachineCasing(int tier) { + if (tier == 0) { + if (machineCasing_ULV == null) { + machineCasing_ULV = ItemList.Casing_ULV.get(1); + } + return machineCasing_ULV; + } else if (tier == 1) { + return machineCasing_LV; + } else if (tier == 2) { + return machineCasing_MV; + } else if (tier == 3) { + return machineCasing_HV; + } else if (tier == 4) { + return machineCasing_EV; + } else if (tier == 5) { + return machineCasing_IV; + } else if (tier == 6) { + return machineCasing_LuV; + } else if (tier == 7) { + return machineCasing_ZPM; + } else if (tier == 8) { + return machineCasing_UV; + } else if (tier == 9) { + return machineCasing_UHV; + } else { + return GregtechItemList.Casing_Multi_Use.get(1); + } + } + + public static void init() { + // Set Explosives + explosivePowderKeg = ItemList.Block_Powderbarrel.get(1); + explosiveTNT = ItemUtils.getSimpleStack(Blocks.tnt) + .copy(); + explosiveITNT = Ic2Items.industrialTnt.copy(); + + // Machine Casings + machineCasing_ULV = ItemList.Casing_ULV.get(1); + machineCasing_LV = ItemList.Casing_LV.get(1); + machineCasing_MV = ItemList.Casing_MV.get(1); + machineCasing_HV = ItemList.Casing_HV.get(1); + machineCasing_EV = ItemList.Casing_EV.get(1); + machineCasing_IV = ItemList.Casing_IV.get(1); + machineCasing_LuV = ItemList.Casing_LuV.get(1); + machineCasing_ZPM = ItemList.Casing_ZPM.get(1); + machineCasing_UV = ItemList.Casing_UV.get(1); + machineCasing_UHV = ItemList.Casing_MAX.get(1); + + // Machine Hulls + machineHull_ULV = ItemList.Hull_ULV.get(1); + machineHull_LV = ItemList.Hull_LV.get(1); + machineHull_MV = ItemList.Hull_MV.get(1); + machineHull_HV = ItemList.Hull_HV.get(1); + machineHull_EV = ItemList.Hull_EV.get(1); + machineHull_IV = ItemList.Hull_IV.get(1); + machineHull_LuV = ItemList.Hull_LuV.get(1); + machineHull_ZPM = ItemList.Hull_ZPM.get(1); + machineHull_UV = ItemList.Hull_UV.get(1); + machineHull_UHV = ItemList.Hull_MAX.get(1); + + // Gear box Casings + gearboxCasing_Tier_1 = ItemList.Casing_Gearbox_Bronze.get(1); + gearboxCasing_Tier_2 = ItemList.Casing_Gearbox_Steel.get(1); + gearboxCasing_Tier_3 = ItemList.Casing_Gearbox_Titanium.get(1); + gearboxCasing_Tier_4 = ItemList.Casing_Gearbox_TungstenSteel.get(1); + + // Machine Components + LOADER_Machine_Components.initialise(); + } + + public static ItemStack emptyCells(int i) { + return ItemUtils.getEmptyCell(i); + } + + private static final Material[] aMaterial_Main = new Material[] { ALLOY.POTIN, ALLOY.TUMBAGA, ALLOY.EGLIN_STEEL, + ALLOY.INCONEL_625, ALLOY.INCOLOY_DS, ALLOY.NITINOL_60, ALLOY.ZERON_100, ALLOY.PIKYONIUM, + ELEMENT.STANDALONE.ADVANCED_NITINOL, ALLOY.ABYSSAL, ALLOY.QUANTUM, ELEMENT.STANDALONE.HYPOGEN }; + + private static final Material[] aMaterial_Secondary = new Material[] { ALLOY.STEEL, ALLOY.SILICON_CARBIDE, + ALLOY.BLOODSTEEL, ALLOY.TANTALUM_CARBIDE, ALLOY.INCONEL_792, ALLOY.ARCANITE, ALLOY.LAFIUM, ALLOY.CINOBITE, + ALLOY.TITANSTEEL, ALLOY.OCTIRON, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN, ELEMENT.STANDALONE.HYPOGEN }; + + private static final Material[] aMaterial_Tertiary = new Material[] { ELEMENT.getInstance().LEAD, + ELEMENT.getInstance().ALUMINIUM, ELEMENT.STANDALONE.BLACK_METAL, ELEMENT.getInstance().TITANIUM, + ALLOY.HASTELLOY_N, ALLOY.ENERGYCRYSTAL, ALLOY.TRINIUM_NAQUADAH_CARBON, ALLOY.TRINIUM_REINFORCED_STEEL, // Arceus + ALLOY.TITANSTEEL, ELEMENT.STANDALONE.ASTRAL_TITANIUM, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN, + ELEMENT.STANDALONE.HYPOGEN }; + + private static final Materials[] aMaterial_Cables = new Materials[] { Materials.Tin, Materials.Cobalt, + Materials.AnnealedCopper, Materials.Gold, Materials.Titanium, Materials.Nichrome, Materials.Platinum, + Materials.YttriumBariumCuprate, Materials.Naquadah, Materials.Duranium, Materials.SuperconductorUHV, }; + + private static final Materials[] aMaterial_Circuits = new Materials[] { Materials.Primitive, Materials.Basic, + Materials.Good, Materials.Advanced, Materials.Data, Materials.Data, Materials.Elite, Materials.Master, + Materials.Ultimate, Materials.SuperconductorUHV, Materials.Infinite, }; + + private static final Material[][] aMaster = new Material[][] { aMaterial_Main, aMaterial_Secondary, + aMaterial_Tertiary }; + + public static FluidStack getTieredFluid(int aTier, int aAmount) { + return getTieredFluid(aTier, aAmount, 0); + } + + public static FluidStack getAlternativeTieredFluid(int aTier, int aAmount) { + return getTieredFluid(aTier, aAmount, 1); + } + + public static FluidStack getTertiaryTieredFluid(int aTier, int aAmount) { + return getTieredFluid(aTier, aAmount, 2); + } + + public static FluidStack getTieredFluid(int aTier, int aAmount, int aType) { + // 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); + * } + */ + + // Modern Handling + FluidStack a = aMaster[aType][aTier].getFluidStack(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; + } + + public static ItemStack getEnergyCore(int aTier, int aAmount) { + ItemStack[] aOutput = new ItemStack[] { + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "1", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "2", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "3", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "4", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "5", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "6", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "10", 1) }; + return ItemUtils.getSimpleStack(aOutput[MathUtils.balance(aTier, 0, 9)], aAmount); + } + + public static ItemStack getPlate(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.plate, aTier, aAmount); + } + + public static ItemStack getDoublePlate(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.plateDouble, aTier, aAmount); + } + + public static ItemStack getGear(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.gearGt, aTier, aAmount); + } + + public static ItemStack getIngot(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.ingot, aTier, aAmount); + } + + public static ItemStack getBolt(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.bolt, aTier, aAmount); + } + + public static ItemStack getScrew(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.screw, aTier, aAmount); + } + + public static ItemStack getCircuit(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.circuit, aTier, aAmount); + } + + public static ItemStack getTieredComponent(OrePrefixes aPrefix, int aTier, int aAmount) { + aTier = Math.max(0, aTier); + + Material m; + + if (aPrefix == OrePrefixes.liquid) { + int aMatID = (aTier == 0 || aTier == 2 || aTier == 5 || aTier == 8 ? 0 + : (aTier == 1 || aTier == 3 || aTier == 6 || aTier == 9 ? 1 : 2)); + ItemStack aCell = aMaster[aMatID][aTier].getCell(aAmount); + return aCell; + } + + if (aPrefix == OrePrefixes.circuit) { + /* + * if (aTier == 4) { return ItemUtils.getSimpleStack(CI.getDataStick(), aAmount); } else if (aTier == 5) { + * return ItemUtils.getSimpleStack(CI.getDataOrb(), aAmount); } + */ + return ItemUtils.getOrePrefixStack(OrePrefixes.circuit, aMaterial_Circuits[aTier], aAmount); + } + + // Check for Cables first, catch SuperConductor case and swap to wire. + if (aPrefix == OrePrefixes.cableGt01 || aPrefix == OrePrefixes.cableGt02 + || aPrefix == OrePrefixes.cableGt04 + || aPrefix == OrePrefixes.cableGt08 + || aPrefix == OrePrefixes.cableGt12) { + // Special Handler + if (aTier == 10) { + if (aPrefix == OrePrefixes.cableGt01) { + aPrefix = OrePrefixes.wireGt02; + } else if (aPrefix == OrePrefixes.cableGt02) { + aPrefix = OrePrefixes.wireGt04; + } else if (aPrefix == OrePrefixes.cableGt04) { + aPrefix = OrePrefixes.wireGt08; + } else if (aPrefix == OrePrefixes.cableGt08) { + aPrefix = OrePrefixes.wireGt12; + } else if (aPrefix == OrePrefixes.cableGt12) { + aPrefix = OrePrefixes.wireGt16; + } + } else { + return ItemUtils.getOrePrefixStack(aPrefix, aMaterial_Cables[aTier], aAmount); + } + } + if (aPrefix == OrePrefixes.wireGt01 || aPrefix == OrePrefixes.wireGt02 + || aPrefix == OrePrefixes.wireGt04 + || aPrefix == OrePrefixes.wireGt08 + || aPrefix == OrePrefixes.wireGt12 + || aPrefix == OrePrefixes.wireGt16) { + return ItemUtils.getOrePrefixStack(aPrefix, aMaterial_Cables[aTier], aAmount); + } + + if (aPrefix == OrePrefixes.pipeTiny || aPrefix == OrePrefixes.pipeSmall + || aPrefix == OrePrefixes.pipe + || aPrefix == OrePrefixes.pipeMedium + || aPrefix == OrePrefixes.pipeLarge + || aPrefix == OrePrefixes.pipeHuge) { + + if (aPrefix == OrePrefixes.pipe) { + aPrefix = OrePrefixes.pipeMedium; + } + + if (aTier == 0) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Lead, aAmount); + } else if (aTier == 1) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Steel, aAmount); + } else if (aTier == 2) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.StainlessSteel, aAmount); + } else if (aTier == 3) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Tungsten, aAmount); + } else if (aTier == 4) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.TungstenSteel, aAmount); + } else if (aTier == 5) { + return ItemUtils.getOrePrefixStack(aPrefix, ALLOY.MARAGING350, aAmount); + } else if (aTier == 6) { + return ItemUtils.getOrePrefixStack(aPrefix, ALLOY.STABALLOY, aAmount); + } else if (aTier == 7) { + return ItemUtils.getOrePrefixStack(aPrefix, ALLOY.HASTELLOY_X, aAmount); + } else if (aTier == 8) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Ultimate, aAmount); + } else if (aTier == 9) { + return ItemUtils.getOrePrefixStack(OrePrefixes.pipeMedium, Materials.SuperconductorUHV, aAmount); + } else if (aTier == 10) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Europium, aAmount); + } else { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Titanium, aAmount); + } + } + + if (aPrefix == OrePrefixes.rod) { + aPrefix = OrePrefixes.stick; + } + + if (aPrefix == OrePrefixes.gear || aPrefix == OrePrefixes.gearGt) { + m = aMaster[0][aTier]; + } else if (aPrefix == OrePrefixes.rod || aPrefix == OrePrefixes.stick) { + m = aMaster[0][aTier]; + } else if (aPrefix == OrePrefixes.stickLong) { + m = aMaster[1][aTier]; + } else if (aPrefix == OrePrefixes.bolt) { + m = aMaster[2][aTier]; + } else if (aPrefix == OrePrefixes.screw) { + m = aMaster[0][aTier]; + } else if (aPrefix == OrePrefixes.rotor) { + m = aMaster[1][aTier]; + } else if (aPrefix == OrePrefixes.frame || aPrefix == OrePrefixes.frameGt) { + m = aMaster[2][aTier]; + } else if (aPrefix == OrePrefixes.ingot) { + m = aMaster[1][aTier]; + } else if (aPrefix == OrePrefixes.plate) { + m = aMaster[0][aTier]; + } else if (aPrefix == OrePrefixes.plateDouble) { + m = aMaster[0][aTier]; + } else if (aPrefix == OrePrefixes.ring) { + m = aMaster[2][aTier]; + } else if (aPrefix == OrePrefixes.cell) { + m = aMaster[1][aTier]; + } else { + m = aMaterial_Main[aTier]; + } + + ItemStack aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); + + // If Invalid, Try First Material + if (!ItemUtils.checkForInvalidItems(aReturn)) { + m = aMaster[0][aTier]; + aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); + + // If Invalid, Try Second Material + if (!ItemUtils.checkForInvalidItems(aReturn)) { + m = aMaster[1][aTier]; + aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); + + // If Invalid, Try Third Material + if (!ItemUtils.checkForInvalidItems(aReturn)) { + m = aMaster[2][aTier]; + aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); + + // All Invalid? + // Let's add a special error ingot. + if (!ItemUtils.checkForInvalidItems(aReturn)) { + aReturn = ItemUtils.getErrorStack(1, (aPrefix + m.getLocalizedName() + " x" + aAmount)); + } + } + } + } + + return aReturn; + } + + public static ItemStack getElectricMotor(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 1; + if (aTier == aLazyTier++) { + aType = CI.electricMotor_LV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_MV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_HV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_EV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_IV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_UV; + } else if (aTier == aLazyTier) { + aType = CI.electricMotor_UHV; + } else { + throw new IllegalArgumentException(); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getFluidRegulator(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_LV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_LV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_MV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_HV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_EV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_IV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_UV; + } else if (aTier == aLazyTier) { + aType = CI.fluidRegulator_UV; + } else { + throw new IllegalArgumentException(); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getElectricPiston(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 1; + if (aTier == aLazyTier++) { + aType = CI.electricPiston_LV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_MV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_HV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_EV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_IV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_UV; + } else if (aTier == aLazyTier) { + aType = CI.electricPiston_UHV; + } else { + throw new IllegalArgumentException(); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getElectricPump(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 1; + if (aTier == aLazyTier++) { + aType = CI.electricPump_LV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_MV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_HV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_EV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_IV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_UV; + } else if (aTier == aLazyTier) { + aType = CI.electricPump_UHV; + } else { + throw new IllegalArgumentException(); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getRobotArm(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 1; + if (aTier == aLazyTier++) { + aType = CI.robotArm_LV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_MV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_HV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_EV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_IV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_UV; + } else if (aTier == aLazyTier) { + aType = CI.robotArm_UHV; + } else { + throw new IllegalArgumentException(); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getConveyor(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 1; + if (aTier == aLazyTier++) { + aType = CI.conveyorModule_LV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_MV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_HV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_EV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_IV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_UV; + } else if (aTier == aLazyTier) { + aType = CI.conveyorModule_UHV; + } else { + throw new IllegalArgumentException(); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getEmitter(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 1; + if (aTier == aLazyTier++) { + aType = CI.emitter_LV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_MV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_HV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_EV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_IV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_UV; + } else if (aTier == aLazyTier) { + aType = CI.emitter_UHV; + } else { + throw new IllegalArgumentException(); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getSensor(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 1; + if (aTier == aLazyTier++) { + aType = CI.sensor_LV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_MV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_HV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_EV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_IV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_UV; + } else if (aTier == aLazyTier) { + aType = CI.sensor_UHV; + } else { + throw new IllegalArgumentException(); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getFieldGenerator(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 1; + if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_LV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_MV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_HV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_EV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_IV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_UV; + } else if (aTier == aLazyTier) { + aType = CI.fieldGenerator_UHV; + } else { + throw new IllegalArgumentException(); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getTieredMachineHull(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.machineHull_ULV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_LV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_MV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_HV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_EV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_IV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_UV; + } else if (aTier == aLazyTier) { + aType = CI.machineHull_UHV; + } else { + throw new IllegalArgumentException(); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getHeatCoil(int i) { + if (i > 8) { + i = 8; + } + return ItemUtils.simpleMetaStack(GregTech_API.sBlockCasings5, i, 1); + } + + public static ItemStack getNumberedBioCircuit(int i) { + return ItemUtils.simpleMetaStack(AgriculturalChem.mBioCircuit, i, 0); + } + + public static ItemStack getNumberedAdvancedCircuit(int i) { + return ItemUtils.simpleMetaStack(GenericChem.mAdvancedCircuit, i, 0); + } + + public static ItemStack getTieredGTPPMachineCasing(int aTier, int aAmount) { + GregtechItemList[] aHulls = new GregtechItemList[] { GregtechItemList.GTPP_Casing_ULV, + GregtechItemList.GTPP_Casing_LV, GregtechItemList.GTPP_Casing_MV, GregtechItemList.GTPP_Casing_HV, + GregtechItemList.GTPP_Casing_EV, GregtechItemList.GTPP_Casing_IV, GregtechItemList.GTPP_Casing_LuV, + GregtechItemList.GTPP_Casing_ZPM, GregtechItemList.GTPP_Casing_UV, GregtechItemList.GTPP_Casing_UHV }; + return aHulls[aTier].get(aAmount); + } + + public static ItemStack getTieredComponentOfMaterial(Materials aMaterial, OrePrefixes aPrefix, int aAmount) { + return ItemUtils.getOrePrefixStack(aPrefix, aMaterial, aAmount); + } + + public static ItemStack getTransmissionComponent(int aTier, int aAmount) { + GregtechItemList[] aTransParts = new GregtechItemList[] { null, GregtechItemList.TransmissionComponent_LV, + GregtechItemList.TransmissionComponent_MV, GregtechItemList.TransmissionComponent_HV, + GregtechItemList.TransmissionComponent_EV, GregtechItemList.TransmissionComponent_IV, + GregtechItemList.TransmissionComponent_LuV, GregtechItemList.TransmissionComponent_ZPM, + GregtechItemList.TransmissionComponent_UV, GregtechItemList.TransmissionComponent_UHV, }; + return aTransParts[aTier].get(aAmount); + } + + public static ItemStack getEmptyCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 13, aAmount); + } + + /** + * Aluminium + Silver Catalyst + * + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getGreenCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 14, aAmount); + } + + /** + * Iridium + Ruthenium Catalyst + * + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getPurpleCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 4, aAmount); + } + + /** + * Platinum + Rhodium Catalyst + * + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getPinkCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 6, aAmount); + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java b/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java new file mode 100644 index 0000000000..323943b950 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java @@ -0,0 +1,154 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemHoe; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.stats.AchievementList; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; + +import cpw.mods.fml.common.FMLCommonHandler; + +public class SlotCrafting extends Slot { + + /** The craft matrix inventory linked to this result slot. */ + private final IInventory craftMatrix; + /** The player that is using the GUI where this slot resides. */ + private final EntityPlayer thePlayer; + /** + * The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. + */ + private int amountCrafted; + + public SlotCrafting(final EntityPlayer p_i1823_1_, final IInventory p_i1823_2_, final IInventory p_i1823_3_, + final int p_i1823_4_, final int p_i1823_5_, final int p_i1823_6_) { + super(p_i1823_3_, p_i1823_4_, p_i1823_5_, p_i1823_6_); + this.thePlayer = p_i1823_1_; + this.craftMatrix = p_i1823_2_; + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for the armor slots. + */ + @Override + public boolean isItemValid(final ItemStack p_75214_1_) { + return false; + } + + /** + * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new + * stack. + */ + @Override + public ItemStack decrStackSize(final int p_75209_1_) { + if (this.getHasStack()) { + this.amountCrafted += Math.min(p_75209_1_, this.getStack().stackSize); + } + + return super.decrStackSize(p_75209_1_); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an + * internal count then calls onCrafting(item). + */ + @Override + protected void onCrafting(final ItemStack p_75210_1_, final int p_75210_2_) { + this.amountCrafted += p_75210_2_; + this.onCrafting(p_75210_1_); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. + */ + @Override + protected void onCrafting(final ItemStack p_75208_1_) { + p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); + this.amountCrafted = 0; + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { + this.thePlayer.addStat(AchievementList.buildWorkBench, 1); + } + + if (p_75208_1_.getItem() instanceof ItemPickaxe) { + this.thePlayer.addStat(AchievementList.buildPickaxe, 1); + } + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.furnace)) { + this.thePlayer.addStat(AchievementList.buildFurnace, 1); + } + + if (p_75208_1_.getItem() instanceof ItemHoe) { + this.thePlayer.addStat(AchievementList.buildHoe, 1); + } + + if (p_75208_1_.getItem() == Items.bread) { + this.thePlayer.addStat(AchievementList.makeBread, 1); + } + + if (p_75208_1_.getItem() == Items.cake) { + this.thePlayer.addStat(AchievementList.bakeCake, 1); + } + + if ((p_75208_1_.getItem() instanceof ItemPickaxe) + && (((ItemPickaxe) p_75208_1_.getItem()).func_150913_i() != Item.ToolMaterial.WOOD)) { + this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); + } + + if (p_75208_1_.getItem() instanceof ItemSword) { + this.thePlayer.addStat(AchievementList.buildSword, 1); + } + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { + this.thePlayer.addStat(AchievementList.enchantments, 1); + } + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { + this.thePlayer.addStat(AchievementList.bookcase, 1); + } + } + + @Override + public void onPickupFromSlot(final EntityPlayer p_82870_1_, final ItemStack p_82870_2_) { + FMLCommonHandler.instance() + .firePlayerCraftingEvent(p_82870_1_, p_82870_2_, this.craftMatrix); + this.onCrafting(p_82870_2_); + + for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { + final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); + + if (itemstack1 != null) { + this.craftMatrix.decrStackSize(i, 1); + + if (itemstack1.getItem() + .hasContainerItem(itemstack1)) { + final ItemStack itemstack2 = itemstack1.getItem() + .getContainerItem(itemstack1); + + if ((itemstack2 != null) && itemstack2.isItemStackDamageable() + && (itemstack2.getItemDamage() > itemstack2.getMaxDamage())) { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2)); + continue; + } + + if (!itemstack1.getItem() + .doesContainerItemLeaveCraftingGrid(itemstack1) + || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { + if (this.craftMatrix.getStackInSlot(i) == null) { + this.craftMatrix.setInventorySlotContents(i, itemstack2); + } else { + this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); + } + } + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java b/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java new file mode 100644 index 0000000000..03581ef705 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java @@ -0,0 +1,139 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemHoe; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.stats.AchievementList; + +import cpw.mods.fml.common.FMLCommonHandler; + +public class SlotCraftingNoCollect extends SlotCrafting { + + /** The craft matrix inventory linked to this result slot. */ + private final IInventory craftMatrix; + /** The player that is using the GUI where this slot resides. */ + private EntityPlayer thePlayer; + /** + * The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. + */ + private int amountCrafted; + + public SlotCraftingNoCollect(EntityPlayer player, IInventory inventory, IInventory inventory2, int x, int y, + int z) { + super(player, inventory, inventory2, x, y, z); + this.thePlayer = player; + this.craftMatrix = inventory; + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for the armor slots. + */ + @Override + public boolean isItemValid(ItemStack p_75214_1_) { + return false; + } + + /** + * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new + * stack. + */ + @Override + public ItemStack decrStackSize(int amount) { + if (this.getHasStack()) { + this.amountCrafted += Math.min(amount, this.getStack().stackSize); + } + + return super.decrStackSize(amount); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an + * internal count then calls onCrafting(item). + */ + @Override + protected void onCrafting(ItemStack output, int amount) { + this.amountCrafted += amount; + this.onCrafting(output); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. + */ + @Override + protected void onCrafting(ItemStack output) { + output.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); + this.amountCrafted = 0; + + if (output.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { + this.thePlayer.addStat(AchievementList.buildWorkBench, 1); + } + + if (output.getItem() instanceof ItemPickaxe) { + this.thePlayer.addStat(AchievementList.buildPickaxe, 1); + } + + if (output.getItem() == Item.getItemFromBlock(Blocks.furnace)) { + this.thePlayer.addStat(AchievementList.buildFurnace, 1); + } + + if (output.getItem() instanceof ItemHoe) { + this.thePlayer.addStat(AchievementList.buildHoe, 1); + } + + if (output.getItem() == Items.bread) { + this.thePlayer.addStat(AchievementList.makeBread, 1); + } + + if (output.getItem() == Items.cake) { + this.thePlayer.addStat(AchievementList.bakeCake, 1); + } + + if (output.getItem() instanceof ItemPickaxe + && ((ItemPickaxe) output.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) { + this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); + } + + if (output.getItem() instanceof ItemSword) { + this.thePlayer.addStat(AchievementList.buildSword, 1); + } + + if (output.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { + this.thePlayer.addStat(AchievementList.enchantments, 1); + } + + if (output.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { + this.thePlayer.addStat(AchievementList.bookcase, 1); + } + } + + @Override + public void onPickupFromSlot(EntityPlayer player, ItemStack output) { + FMLCommonHandler.instance() + .firePlayerCraftingEvent(player, output, craftMatrix); + this.onCrafting(output); + + /* + * for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { ItemStack itemstack1 = + * this.craftMatrix.getStackInSlot(i); if (itemstack1 != null) { this.craftMatrix.decrStackSize(i, 1); if + * (itemstack1.getItem().hasContainerItem(itemstack1)) { ItemStack itemstack2 = + * itemstack1.getItem().getContainerItem(itemstack1); if (itemstack2 != null && + * itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) { + * MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2)); continue; } if + * (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || + * !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { if (this.craftMatrix.getStackInSlot(i) == + * null) { this.craftMatrix.setInventorySlotContents(i, itemstack2); } else { + * this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); } } } } } + */ + } + + @Override + public boolean canTakeStack(EntityPlayer player) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java b/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java new file mode 100644 index 0000000000..3b39da877a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java @@ -0,0 +1,42 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.recipe.common.CI; + +public class SlotDataStick extends Slot { + + public SlotDataStick(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } + + public static ItemStack[] mDataItems = new ItemStack[2]; + + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + boolean isValid = false; + if (itemstack != null) { + if (mDataItems[0] == null) { + mDataItems[0] = CI.getDataStick(); + } + if (mDataItems[1] == null) { + mDataItems[1] = CI.getDataOrb(); + } + if (mDataItems[0] != null && mDataItems[1] != null) { + if (GT_Utility.areStacksEqual(itemstack, mDataItems[0], true) + || GT_Utility.areStacksEqual(itemstack, mDataItems[1], true)) { + isValid = true; + } + } + } + return isValid; + } + + @Override + public int getSlotStackLimit() { + return 1; + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java b/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java new file mode 100644 index 0000000000..bfb384efe8 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotGeneric extends Slot { + + public SlotGeneric(final IInventory inventory, final int aSlotID, final int x, final int y) { + super(inventory, aSlotID, x, y); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + return true; + } + + @Override + public int getSlotStackLimit() { + return 64; + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java b/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java new file mode 100644 index 0000000000..dc75c88369 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java @@ -0,0 +1,110 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import gtPlusPlus.core.recipe.common.CI; + +public class SlotIntegratedCircuit extends Slot { + + public static Item mCircuitItem; + public static Item mCircuitItem2; + public static Item mCircuitItem3; + 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) { + mCircuitLock = -1; + } else { + mCircuitLock = (short) mTypeLock; + } + } + + @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 (mCircuitItem2 == null) { + mCircuitItem2 = CI.getNumberedBioCircuit(0) + .getItem(); + } + if (mCircuitItem3 == null) { + mCircuitItem3 = CI.getNumberedAdvancedCircuit(0) + .getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { + if (itemstack != null) { + if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2 + || itemstack.getItem() == mCircuitItem3) { + if (aLockedCircuitNumber == -1) { + isValid = true; + } else { + if (itemstack.getItemDamage() == aLockedCircuitNumber) { + isValid = true; + } + } + } + } + } + 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 (mCircuitItem3 == null) { + mCircuitItem3 = CI.getNumberedAdvancedCircuit(0) + .getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { + if (itemstack != null) { + if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2 + || itemstack.getItem() == mCircuitItem3) { + if (itemstack.getItem() == mCircuitItem) { + return 0; + } else if (itemstack.getItem() == mCircuitItem2) { + return 1; + } else if (itemstack.getItem() == mCircuitItem3) { + return 2; + } + } + } + } + return -1; + } + + @Override + public int getSlotStackLimit() { + return 64; + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java b/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java new file mode 100644 index 0000000000..1351e5c188 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java @@ -0,0 +1,35 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemRecord; +import net.minecraft.item.ItemStack; + +public class SlotJukebox extends SlotGeneric { + + private final boolean isDisplay; + + public SlotJukebox(IInventory inventory, int x, int y, int z) { + this(inventory, x, y, z, false); + } + + public SlotJukebox(IInventory inventory, int x, int y, int z, boolean display) { + super(inventory, x, y, z); + isDisplay = display; + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return (itemstack != null && itemstack.getItem() instanceof ItemRecord); + } + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return !isDisplay; + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java b/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java new file mode 100644 index 0000000000..d4e8696075 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotNoInput extends Slot { + + public SlotNoInput(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 false; + } + + @Override + public int getSlotStackLimit() { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java b/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java new file mode 100644 index 0000000000..c84c88a0b5 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; + +public class SlotVolumetricFlask extends Slot { + + public SlotVolumetricFlask(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } + + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(itemstack); + } + + public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { + return VolumetricFlaskHelper.isVolumetricFlask(itemstack); + } + + @Override + public int getSlotStackLimit() { + return 16; + } +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java new file mode 100644 index 0000000000..56cf2fdbab --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -0,0 +1,35 @@ +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.tileentities.general.TileEntityCircuitProgrammer; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; +import gtPlusPlus.core.tileentities.general.TileEntityInfiniteFluid; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import gtPlusPlus.core.tileentities.machines.TileEntityAdvPooCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; + +public class ModTileEntities { + + public static void init() { + Logger.INFO("Registering Tile Entities."); + GameRegistry.registerTileEntity(TileEntityPooCollector.class, "TileEntityPooCollector"); + GameRegistry.registerTileEntity(TileEntityAdvPooCollector.class, "TileEntityAdvPooCollector"); + GameRegistry.registerTileEntity(TileEntityFishTrap.class, "TileFishTrap"); + GameRegistry.registerTileEntity(TileEntityInfiniteFluid.class, "TileInfiniteFluid"); + GameRegistry.registerTileEntity(TileEntityProjectTable.class, "TileProjectTable"); + GameRegistry.registerTileEntity(TileEntityCircuitProgrammer.class, "TileCircuitProgrammer"); + GameRegistry.registerTileEntity(TileEntityDecayablesChest.class, "TileDecayablesChest"); + GameRegistry.registerTileEntity(TileEntitySuperJukebox.class, "TileEntitySuperJukebox"); + GameRegistry.registerTileEntity(TileEntitySuperLight.class, "TileEntitySuperLight"); + GameRegistry.registerTileEntity(TileEntityPestKiller.class, "TileEntityPestKiller"); + + GameRegistry.registerTileEntity(TileEntityVolumetricFlaskSetter.class, "TileEntityVolumetricFlaskSetter"); + } + +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java new file mode 100644 index 0000000000..98f1d67439 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java @@ -0,0 +1,1419 @@ +package gtPlusPlus.core.tileentities.base; + +import java.util.UUID; + +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.IFluidHandler; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.IDescribable; +import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.net.GT_Packet_Block_Event; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.ISerializableObject; +import gregtech.common.covers.CoverInfo; +import gtPlusPlus.api.interfaces.ILazyCoverable; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BTF_Inventory; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import ic2.api.Direction; + +public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregTechDeviceInformation, IDescribable { + + private String customName; + public String mOwnerName = "null"; + public String mOwnerUUID = "null"; + private boolean mIsOwnerOP = false; + + public final BTF_Inventory mInventory; + + public TileEntityBase(int aCapacity) { + mInventory = new BTF_Inventory(aCapacity, this); + } + + 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.setBoolean("mIsOwnerOP", this.mIsOwnerOP); + nbt.setString("mOwnerName", this.mOwnerName); + nbt.setString("mOwnerUUID", this.mOwnerUUID); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + + super.readFromNBT(nbt); + + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + + this.mIsOwnerOP = nbt.getBoolean("mIsOwnerOP"); + this.mOwnerName = nbt.getString("mOwnerName"); + this.mOwnerUUID = nbt.getString("mOwnerUUID"); + } + + @Override + public void updateEntity() { + long aTick = System.currentTimeMillis(); + this.isDead = false; + if (!firstTicked) { + onFirstTick(); + } + try { + if (this.isServerSide()) { + onPreTick(aTick); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's pre-tick stage."); + t.printStackTrace(); + } + try { + if (this.isServerSide()) { + onTick(aTick); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's tick stage."); + t.printStackTrace(); + } + try { + if (this.isServerSide()) { + onPostTick(aTick); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's post-tick stage."); + t.printStackTrace(); + } + } + + public boolean onPreTick(long aTick) { + return true; + } + + public boolean onTick(long aTick) { + try { + if (this.isServerSide()) { + processRecipe(); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's processing of a recipe stage."); + t.printStackTrace(); + } + return true; + } + + public boolean onPostTick(long aTick) { + return true; + } + + public boolean processRecipe() { + return true; + } + + @Override + public boolean canUpdate() { + return true; + } + + public String getOwner() { + if (this.mOwnerName == null) { + return "null"; + } + return this.mOwnerName; + } + + public UUID getOwnerUUID() { + return UUID.fromString(this.mOwnerUUID); + } + + public boolean isOwnerOP() { + return mIsOwnerOP; + } + + public void setOwnerInformation(String mName, String mUUID, boolean mOP) { + if (isServerSide()) { + if (this.mOwnerName == null || this.mOwnerUUID == null + || this.mOwnerName.equals("null") + || this.mOwnerUUID.equals("null")) { + this.mOwnerName = mName; + this.mOwnerUUID = mUUID; + this.mIsOwnerOP = mOP; + } + } + } + + @Override + public boolean isServerSide() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + return true; + } + } + return false; + } + + @Override + public final boolean isClientSide() { + return this.worldObj.isRemote; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.tileentity.name"; + } + + @Override + public boolean hasCustomInventoryName() { + return this.customName != null && !this.customName.equals(""); + } + + @Override + public int getSizeInventory() { + return this.mInventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int aIndex) { + return this.mInventory.getStackInSlot(aIndex); + } + + @Override + public ItemStack decrStackSize(int aIndex, int aAmount) { + if (canAccessData()) { + mInventoryChanged = true; + return mInventory.decrStackSize(aIndex, aAmount); + } + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + return this.mInventory.getStackInSlotOnClosing(p_70304_1_); + } + + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + this.mInventory.setInventorySlotContents(p_70299_1_, p_70299_2_); + } + + @Override + public int getInventoryStackLimit() { + return this.mInventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return this.mInventory.isUseableByPlayer(p_70300_1_); + } + + @Override + public void openInventory() { + this.mInventory.openInventory(); + } + + @Override + public void closeInventory() { + this.mInventory.closeInventory(); + } + + /** + * Can put aStack into Slot + */ + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + return canAccessData() && mInventory.isItemValidForSlot(aIndex, aStack); + } + + /** + * returns all valid Inventory Slots, no matter which Side (Unless it's covered). The Side Stuff is done in the + * following two Functions. + */ + @Override + public int[] getAccessibleSlotsFromSide(int ordinalSide) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + CoverInfo coverInfo = getCoverInfoAtSide(side); + if (canAccessData() && (coverInfo.letsItemsOut(-1) || coverInfo.letsItemsIn(-1))) + return mInventory.getAccessibleSlotsFromSide(ordinalSide); + return new int[0]; + } + + /** + * Can put aStack into Slot at Side + */ + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + return canAccessData() && (mRunningThroughTick || !mInputDisabled) + && getCoverInfoAtSide(side).letsItemsIn(aIndex) + && mInventory.canInsertItem(aIndex, aStack, ordinalSide); + } + + /** + * Can pull aStack out of Slot from Side + */ + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int ordinalSide) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + return canAccessData() && (mRunningThroughTick || !mOutputDisabled) + && getCoverInfoAtSide(side).letsItemsOut(aIndex) + && mInventory.canExtractItem(aIndex, aStack, ordinalSide); + } + + @Override + public boolean isValidSlot(int aIndex) { + return this.canAccessData() ? this.mInventory.isValidSlot(aIndex) : false; + } + + private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[] { GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior }; + protected TileEntityBase mMetaTileEntity; + protected long mStoredEnergy = 0; + protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; + protected boolean mReleaseEnergy = false; + protected int[] mAverageEUInput = new int[11], mAverageEUOutput = new int[11]; + private boolean[] mActiveEUInputs = new boolean[] { false, false, false, false, false, false }, + mActiveEUOutputs = new boolean[] { false, false, false, false, false, false }; + private byte[] mSidedRedstone = new byte[] { 15, 15, 15, 15, 15, 15 }; + private int[] mCoverSides = new int[] { 0, 0, 0, 0, 0, 0 }, mCoverData = new int[] { 0, 0, 0, 0, 0, 0 }, + mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; + private boolean mHasEnoughEnergy = true; + protected boolean mRunningThroughTick = false; + protected boolean mInputDisabled = false; + protected boolean mOutputDisabled = false; + private boolean mMuffler = false; + private boolean mLockUpgrade = false; + private boolean mActive = false; + private boolean mRedstone = false; + private boolean mWorkUpdate = false; + private boolean mSteamConverter = false; + private boolean mInventoryChanged = false; + private boolean mWorks = true; + private boolean mNeedsUpdate = true; + private boolean mNeedsBlockUpdate = true; + private boolean mSendClientData = false; + private boolean oRedstone = false; + private boolean mEnergyStateReady = false; + private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, + oTexturePage = 0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, + oFacing = 0, mWorkData = 0; + private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; + private short mID = 0; + protected long mTickTimer = 0; + private long oOutput = 0; + private long mAcceptedAmperes = Long.MAX_VALUE; + + /** + * Cover Support + */ + public void issueClientUpdate() { + this.mSendClientData = true; + } + + protected final boolean canAccessData() { + return !isDead() && !this.isInvalid(); + } + + @Override + public void issueBlockUpdate() { + super.markDirty(); + } + + @Override + public void issueCoverUpdate(ForgeDirection side) { + this.issueClientUpdate(); + } + + @Override + public void receiveCoverData(ForgeDirection coverSide, int coverID, int coverData) { + if (coverSide != ForgeDirection.UNKNOWN && (mCoverSides[coverSide.ordinal()] == coverID)) + setCoverDataAtSide(coverSide, coverData); + } + + @Override + public long getTimer() { + return this.mTickTimer; + } + + @Override + public long getOutputAmperage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxAmperesOut() : 0L; + } + + @Override + public long getOutputVoltage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput() + ? this.mMetaTileEntity.maxEUOutput() + : 0L; + } + + @Override + public long getInputAmperage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxAmperesIn() : 0L; + } + + @Override + public long getInputVoltage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxEUInput() + : 2147483647L; + } + + @Override + public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { + return !this.canAccessData() ? false + : (this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy)); + } + + @Override + public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) { + if (!this.canAccessData()) { + return false; + } else if (this.getStoredEU() >= this.getEUCapacity() && !aIgnoreTooMuchEnergy) { + return false; + } else { + this.setStoredEU(this.mMetaTileEntity.getEUVar() + aEnergy); + return true; + } + } + + @Override + public boolean inputEnergyFrom(ForgeDirection side) { + return side == ForgeDirection.UNKNOWN ? true + : (!this.isServerSide() ? this.isEnergyInputSide(side) + : side != ForgeDirection.UNKNOWN && this.mActiveEUInputs[side.ordinal()] && !this.mReleaseEnergy); + } + + @Override + public boolean outputsEnergyTo(ForgeDirection side) { + return side == ForgeDirection.UNKNOWN ? true + : (!this.isServerSide() ? this.isEnergyOutputSide(side) + : side != ForgeDirection.UNKNOWN && this.mActiveEUOutputs[side.ordinal()] || this.mReleaseEnergy); + } + + private boolean isEnergyInputSide(ForgeDirection side) { + if (side != ForgeDirection.UNKNOWN) { + if (!this.getCoverInfoAtSide(side) + .letsEnergyIn()) { + return false; + } + + if (this.isInvalid() || this.mReleaseEnergy) { + return false; + } + + if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetInput()) { + return this.mMetaTileEntity.isInputFacing(side); + } + } + + return false; + } + + private boolean isEnergyOutputSide(ForgeDirection side) { + if (side != ForgeDirection.UNKNOWN) { + if (!this.getCoverInfoAtSide(side) + .letsEnergyOut()) { + return false; + } + + if (this.isInvalid() || this.mReleaseEnergy) { + return this.mReleaseEnergy; + } + + if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput()) { + return this.mMetaTileEntity.isOutputFacing(side); + } + } + + return false; + } + + public boolean isOutputFacing(ForgeDirection side) { + return false; + } + + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + private final TileEntity[] mBufferedTileEntities = new TileEntity[6]; + public boolean ignoreUnloadedChunks = true; + public boolean isDead = false; + + private void clearNullMarkersFromTileEntityBuffer() { + for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { + if (this.mBufferedTileEntities[i] == this) { + this.mBufferedTileEntities[i] = null; + } + } + } + + protected final void clearTileEntityBuffer() { + for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { + this.mBufferedTileEntities[i] = null; + } + } + + @Override + public final World getWorld() { + return this.worldObj; + } + + @Override + public final int getXCoord() { + return this.xCoord; + } + + @Override + public final short getYCoord() { + return (short) this.yCoord; + } + + @Override + public final int getZCoord() { + return this.zCoord; + } + + @Override + public final int getOffsetX(ForgeDirection side, int aMultiplier) { + return this.xCoord + side.offsetX * aMultiplier; + } + + @Override + public final short getOffsetY(ForgeDirection side, int aMultiplier) { + return (short) (this.yCoord + side.offsetY * aMultiplier); + } + + @Override + public final int getOffsetZ(ForgeDirection side, int aMultiplier) { + return this.zCoord + side.offsetZ * aMultiplier; + } + + @Override + public final int getRandomNumber(int aRange) { + return this.worldObj.rand.nextInt(aRange); + } + + @Override + public final BiomeGenBase getBiome(int aX, int aZ) { + return this.worldObj.getBiomeGenForCoords(aX, aZ); + } + + @Override + public final BiomeGenBase getBiome() { + return this.getBiome(this.xCoord, this.zCoord); + } + + @Override + public final Block getBlockOffset(int aX, int aY, int aZ) { + return this.getBlock(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public final Block getBlockAtSide(ForgeDirection side) { + return this.getBlockAtSideAndDistance(side, 1); + } + + @Override + public final Block getBlockAtSideAndDistance(ForgeDirection side, int aDistance) { + return this.getBlock( + this.getOffsetX(side, aDistance), + this.getOffsetY(side, aDistance), + this.getOffsetZ(side, aDistance)); + } + + @Override + public final byte getMetaIDOffset(int aX, int aY, int aZ) { + return this.getMetaID(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public final byte getMetaIDAtSide(ForgeDirection side) { + return this.getMetaIDAtSideAndDistance(side, 1); + } + + @Override + public final byte getMetaIDAtSideAndDistance(ForgeDirection side, int aDistance) { + return this.getMetaID( + this.getOffsetX(side, aDistance), + this.getOffsetY(side, aDistance), + this.getOffsetZ(side, aDistance)); + } + + @Override + public final byte getLightLevelOffset(int aX, int aY, int aZ) { + return this.getLightLevel(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public final byte getLightLevelAtSide(ForgeDirection side) { + return this.getLightLevelAtSideAndDistance(side, 1); + } + + @Override + public final byte getLightLevelAtSideAndDistance(ForgeDirection side, int aDistance) { + return this.getLightLevel( + this.getOffsetX(side, aDistance), + this.getOffsetY(side, aDistance), + this.getOffsetZ(side, aDistance)); + } + + @Override + public final boolean getOpacityOffset(int aX, int aY, int aZ) { + return this.getOpacity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public final boolean getOpacityAtSide(ForgeDirection side) { + return this.getOpacityAtSideAndDistance(side, 1); + } + + @Override + public final boolean getOpacityAtSideAndDistance(ForgeDirection side, int aDistance) { + return this.getOpacity( + this.getOffsetX(side, aDistance), + this.getOffsetY(side, aDistance), + this.getOffsetZ(side, aDistance)); + } + + @Override + public final boolean getSkyOffset(int aX, int aY, int aZ) { + return this.getSky(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public final boolean getSkyAtSide(ForgeDirection side) { + return this.getSkyAtSideAndDistance(side, 1); + } + + @Override + public final boolean getSkyAtSideAndDistance(ForgeDirection side, int aDistance) { + return this.getSky( + this.getOffsetX(side, aDistance), + this.getOffsetY(side, aDistance), + this.getOffsetZ(side, aDistance)); + } + + @Override + public final boolean getAirOffset(int aX, int aY, int aZ) { + return this.getAir(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public final boolean getAirAtSide(ForgeDirection side) { + return this.getAirAtSideAndDistance(side, 1); + } + + @Override + public final boolean getAirAtSideAndDistance(ForgeDirection side, int aDistance) { + return this.getAir( + this.getOffsetX(side, aDistance), + this.getOffsetY(side, aDistance), + this.getOffsetZ(side, aDistance)); + } + + @Override + public final TileEntity getTileEntityOffset(int aX, int aY, int aZ) { + return this.getTileEntity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public final TileEntity getTileEntityAtSideAndDistance(ForgeDirection side, int aDistance) { + return aDistance == 1 ? this.getTileEntityAtSide(side) + : this.getTileEntity( + this.getOffsetX(side, aDistance), + this.getOffsetY(side, aDistance), + this.getOffsetZ(side, aDistance)); + } + + @Override + public final IInventory getIInventory(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; + } + + @Override + public final IInventory getIInventoryOffset(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); + return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; + } + + @Override + public final IInventory getIInventoryAtSide(ForgeDirection side) { + TileEntity tTileEntity = this.getTileEntityAtSide(side); + return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; + } + + @Override + public final IInventory getIInventoryAtSideAndDistance(ForgeDirection side, int aDistance) { + TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(side, aDistance); + return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; + } + + @Override + public final IFluidHandler getITankContainer(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; + } + + @Override + public final IFluidHandler getITankContainerOffset(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); + return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; + } + + @Override + public final IFluidHandler getITankContainerAtSide(ForgeDirection side) { + TileEntity tTileEntity = this.getTileEntityAtSide(side); + return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; + } + + @Override + public final IFluidHandler getITankContainerAtSideAndDistance(ForgeDirection side, int aDistance) { + TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(side, aDistance); + return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntity(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntityOffset(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntityAtSide(ForgeDirection side) { + TileEntity tTileEntity = this.getTileEntityAtSide(side); + return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(ForgeDirection side, int aDistance) { + TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(side, aDistance); + return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; + } + + @Override + public final Block getBlock(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? Blocks.air + : this.worldObj.getBlock(aX, aY, aZ); + } + + @Override + public final byte getMetaID(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? 0 + : (byte) this.worldObj.getBlockMetadata(aX, aY, aZ); + } + + @Override + public final byte getLightLevel(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? 0 + : (byte) ((int) (this.worldObj.getLightBrightness(aX, aY, aZ) * 15.0F)); + } + + @Override + public final boolean getSky(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? true + : this.worldObj.canBlockSeeTheSky(aX, aY, aZ); + } + + @Override + public final boolean getOpacity(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? false + : GT_Utility.isOpaqueBlock(this.worldObj, aX, aY, aZ); + } + + @Override + public final boolean getAir(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? true + : GT_Utility.isBlockAir(this.worldObj, aX, aY, aZ); + } + + @Override + public final TileEntity getTileEntity(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? null + : this.worldObj.getTileEntity(aX, aY, aZ); + } + + @Override + public final TileEntity getTileEntityAtSide(ForgeDirection side) { + final int ordinalSide = side.ordinal(); + if (side != ForgeDirection.UNKNOWN && this.mBufferedTileEntities[ordinalSide] != this) { + int tX = this.getOffsetX(side, 1); + short tY = this.getOffsetY(side, 1); + int tZ = this.getOffsetZ(side, 1); + if (this.crossedChunkBorder(tX, tZ)) { + this.mBufferedTileEntities[ordinalSide] = null; + if (this.ignoreUnloadedChunks && !this.worldObj.blockExists(tX, tY, tZ)) { + return null; + } + } + + if (this.mBufferedTileEntities[ordinalSide] == null) { + this.mBufferedTileEntities[ordinalSide] = this.worldObj.getTileEntity(tX, tY, tZ); + if (this.mBufferedTileEntities[ordinalSide] == null) { + this.mBufferedTileEntities[ordinalSide] = this; + return null; + } else { + return this.mBufferedTileEntities[ordinalSide]; + } + } else if (this.mBufferedTileEntities[ordinalSide].isInvalid()) { + this.mBufferedTileEntities[ordinalSide] = null; + return this.getTileEntityAtSide(side); + } else { + return this.mBufferedTileEntities[ordinalSide].xCoord == tX + && this.mBufferedTileEntities[ordinalSide].yCoord == tY + && this.mBufferedTileEntities[ordinalSide].zCoord == tZ ? this.mBufferedTileEntities[ordinalSide] + : null; + } + } else { + return null; + } + } + + @Override + public boolean isDead() { + return this.isDead || this.isInvalidTileEntity(); + } + + @Override + public void validate() { + this.clearNullMarkersFromTileEntityBuffer(); + super.validate(); + } + + @Override + public void invalidate() { + this.clearNullMarkersFromTileEntityBuffer(); + super.invalidate(); + } + + @Override + public void onChunkUnload() { + this.clearNullMarkersFromTileEntityBuffer(); + super.onChunkUnload(); + this.isDead = true; + } + + public final void onAdjacentBlockChange(int aX, int aY, int aZ) { + this.clearNullMarkersFromTileEntityBuffer(); + } + + @Override + public final void sendBlockEvent(byte aID, byte aValue) { + GT_Values.NW.sendPacketToAllPlayersInRange( + this.worldObj, + new GT_Packet_Block_Event(this.xCoord, (short) this.yCoord, this.zCoord, aID, aValue), + this.xCoord, + this.zCoord); + } + + private boolean crossedChunkBorder(int aX, int aZ) { + return aX >> 4 != this.xCoord >> 4 || aZ >> 4 != this.zCoord >> 4; + } + + public final void setOnFire() { + GT_Utility.setCoordsOnFire(this.worldObj, this.xCoord, this.yCoord, this.zCoord, false); + } + + public final void setToFire() { + this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Blocks.fire); + } + + @Override + public byte getInternalInputRedstoneSignal(ForgeDirection side) { + return (byte) (getCoverBehaviorAtSide(side).getRedstoneInput( + side, + getInputRedstoneSignal(side), + getCoverIDAtSide(side), + getCoverDataAtSide(side), + this) & 15); + } + + @Override + public byte getInputRedstoneSignal(ForgeDirection side) { + return (byte) (worldObj + .getIndirectPowerLevelTo(getOffsetX(side, 1), getOffsetY(side, 1), getOffsetZ(side, 1), side.ordinal()) + & 15); + } + + @Override + public byte getOutputRedstoneSignal(ForgeDirection side) { + return getCoverBehaviorAtSide(side) + .manipulatesSidedRedstoneOutput(side, getCoverIDAtSide(side), getCoverDataAtSide(side), this) + ? mSidedRedstone[side.ordinal()] + : getGeneralRS(side); + } + + public boolean allowGeneralRedstoneOutput() { + return false; + } + + @Override + public byte getGeneralRS(ForgeDirection side) { + return allowGeneralRedstoneOutput() ? mSidedRedstone[side.ordinal()] : 0; + } + + @Override + public void setInternalOutputRedstoneSignal(ForgeDirection side, byte aStrength) { + if (!getCoverBehaviorAtSide(side) + .manipulatesSidedRedstoneOutput(side, getCoverIDAtSide(side), getCoverDataAtSide(side), this)) + setOutputRedstoneSignal(side, aStrength); + } + + @Override + public void setOutputRedstoneSignal(ForgeDirection side, byte aStrength) { + aStrength = (byte) Math.min(Math.max(0, aStrength), 15); + if (side != ForgeDirection.UNKNOWN && mSidedRedstone[side.ordinal()] != aStrength) { + mSidedRedstone[side.ordinal()] = aStrength; + issueBlockUpdate(); + } + } + + @Override + public boolean hasInventoryBeenModified() { + return mInventoryChanged; + } + + @Override + public void setGenericRedstoneOutput(boolean aOnOff) { + mRedstone = aOnOff; + } + + @Override + public GT_CoverBehavior getCoverBehaviorAtSide(ForgeDirection side) { + return side != ForgeDirection.UNKNOWN ? mCoverBehaviors[side.ordinal()] : GregTech_API.sNoBehavior; + } + + @Override + public void setCoverIDAtSide(ForgeDirection side, int aID) { + if (setCoverIDAtSideNoUpdate(side, aID)) { + issueCoverUpdate(side); + issueBlockUpdate(); + } + } + + @Override + public boolean setCoverIDAtSideNoUpdate(ForgeDirection side, int aID) { + if (side != ForgeDirection.UNKNOWN) { + final int ordinalSide = side.ordinal(); + mCoverSides[ordinalSide] = aID; + mCoverData[ordinalSide] = 0; + mCoverBehaviors[ordinalSide] = (GT_CoverBehavior) GregTech_API.getCoverBehaviorNew(aID); + return true; + } + return false; + } + + @Override + public void setCoverIdAndDataAtSide(ForgeDirection side, int aId, ISerializableObject aData) { + setCoverIDAtSide(side, aId); + setCoverDataAtSide(side, aData); + } + + @Override + public void setCoverItemAtSide(ForgeDirection side, ItemStack aCover) { + GregTech_API.getCoverBehaviorNew(aCover) + .placeCover(side, aCover, this); + } + + @Override + public int getCoverIDAtSide(ForgeDirection side) { + if (side != ForgeDirection.UNKNOWN) return mCoverSides[side.ordinal()]; + return 0; + } + + @Override + public ItemStack getCoverItemAtSide(ForgeDirection side) { + return GT_Utility.intToStack(getCoverIDAtSide(side)); + } + + @Override + public boolean canPlaceCoverIDAtSide(ForgeDirection side, int aID) { + return getCoverIDAtSide(side) == 0; + } + + @Override + public boolean canPlaceCoverItemAtSide(ForgeDirection side, ItemStack aCover) { + return getCoverIDAtSide(side) == 0; + } + + @Override + public void setCoverDataAtSide(ForgeDirection side, int aData) { + if (side != ForgeDirection.UNKNOWN) mCoverData[side.ordinal()] = aData; + } + + @Override + public int getCoverDataAtSide(ForgeDirection side) { + if (side != ForgeDirection.UNKNOWN) return mCoverData[side.ordinal()]; + return 0; + } + + public byte getLightValue() { + return mLightValue; + } + + @Override + public void setLightValue(byte aLightValue) { + mLightValue = (byte) (aLightValue & 15); + } + + @Override + public long getAverageElectricInput() { + int rEU = 0; + for (int i = 0; i < mAverageEUInput.length; i++) { + if (i != mAverageEUInputIndex) rEU += mAverageEUInput[i]; + } + return rEU / (mAverageEUInput.length - 1); + } + + @Override + public long getAverageElectricOutput() { + int rEU = 0; + for (int i = 0; i < mAverageEUOutput.length; i++) { + if (i != mAverageEUOutputIndex) rEU += mAverageEUOutput[i]; + } + return rEU / (mAverageEUOutput.length - 1); + } + + public boolean hasSidedRedstoneOutputBehavior() { + return false; + } + + @Override + public boolean dropCover(ForgeDirection side, ForgeDirection droppedSide, boolean aForced) { + if (getCoverBehaviorAtSide(side) + .onCoverRemoval(side, getCoverIDAtSide(side), mCoverData[side.ordinal()], this, aForced) || aForced) { + ItemStack tStack = getCoverBehaviorAtSide(side) + .getDrop(side, getCoverIDAtSide(side), getCoverDataAtSide(side), this); + if (tStack != null) { + tStack.setTagCompound(null); + EntityItem tEntity = new EntityItem( + worldObj, + getOffsetX(droppedSide, 1) + 0.5, + getOffsetY(droppedSide, 1) + 0.5, + getOffsetZ(droppedSide, 1) + 0.5, + tStack); + tEntity.motionX = 0; + tEntity.motionY = 0; + tEntity.motionZ = 0; + worldObj.spawnEntityInWorld(tEntity); + } + setCoverIDAtSide(side, 0); + if (mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { + setOutputRedstoneSignal(side, (byte) 0); + } else { + setOutputRedstoneSignal(side, (byte) 15); + } + return true; + } + return false; + } + + public String getOwnerName() { + if (GT_Utility.isStringInvalid(mOwnerName)) return "Player"; + return mOwnerName; + } + + public String setOwnerName(String aName) { + if (GT_Utility.isStringInvalid(aName)) return mOwnerName = "Player"; + return mOwnerName = aName; + } + + @Override + public byte getComparatorValue(ForgeDirection side) { + return canAccessData() ? mMetaTileEntity.getComparatorValue(side) : 0; + } + + @Override + public byte getStrongOutputRedstoneSignal(ForgeDirection side) { + final int ordinalSide = side.ordinal(); + return side != ForgeDirection.UNKNOWN && (mStrongRedstone & (1 << ordinalSide)) != 0 + ? (byte) (mSidedRedstone[ordinalSide] & 15) + : 0; + } + + @Override + public void setStrongOutputRedstoneSignal(ForgeDirection side, byte aStrength) { + mStrongRedstone |= (1 << side.ordinal()); + setOutputRedstoneSignal(side, aStrength); + } + + @Override + public long injectEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage) { + if (!canAccessData() || !mMetaTileEntity.isElectric() + || !inputEnergyFrom(side) + || aAmperage <= 0 + || aVoltage <= 0 + || getStoredEU() >= getEUCapacity() + || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes) return 0; + if (aVoltage > getInputVoltage()) { + doExplosion(aVoltage); + return 0; + } + if (increaseStoredEnergyUnits( + aVoltage * (aAmperage = Math.min( + aAmperage, + Math.min( + mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes, + 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))), + true)) { + mAverageEUInput[mAverageEUInputIndex] += aVoltage * aAmperage; + mAcceptedAmperes += aAmperage; + return aAmperage; + } + return 0; + } + + @Override + public boolean drainEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage) { + if (!canAccessData() || !mMetaTileEntity.isElectric() + || !outputsEnergyTo(side) + || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) return false; + if (decreaseStoredEU(aVoltage * aAmperage, false)) { + mAverageEUOutput[mAverageEUOutputIndex] += aVoltage * aAmperage; + return true; + } + return false; + } + + public double getOutputEnergyUnitsPerTick() { + return oOutput; + } + + public boolean isTeleporterCompatible(ForgeDirection side) { + return false; + } + + public double demandedEnergyUnits() { + if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0; + return getEUCapacity() - getStoredEU(); + } + + public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) { + return injectEnergyUnits(aDirection, (int) aAmount, 1) > 0 ? 0 : aAmount; + } + + public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) { + return inputEnergyFrom(aDirection); + } + + public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) { + return outputsEnergyTo(aDirection); + } + + public double getOfferedEnergy() { + return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput) + ? Math.max(0, oOutput) + : 0; + } + + public void drawEnergy(double amount) { + mAverageEUOutput[mAverageEUOutputIndex] += amount; + decreaseStoredEU((int) amount, true); + } + + public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) { + return injectEnergyUnits(aForgeDirection, aAmount, 1) > 0 ? 0 : aAmount; + } + + public int addEnergy(int aEnergy) { + if (!canAccessData()) return 0; + if (aEnergy > 0) increaseStoredEnergyUnits(aEnergy, true); + else decreaseStoredEU(-aEnergy, true); + return (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getEUVar()); + } + + public boolean isAddedToEnergyNet() { + return false; + } + + public int demandsEnergy() { + if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0; + return getCapacity() - getStored(); + } + + public int getCapacity() { + return (int) Math.min(Integer.MAX_VALUE, getEUCapacity()); + } + + public int getStored() { + return (int) Math.min(Integer.MAX_VALUE, Math.min(getStoredEU(), getCapacity())); + } + + public void setStored(int aEU) { + if (canAccessData()) setStoredEU(aEU); + } + + public int getMaxSafeInput() { + return (int) Math.min(Integer.MAX_VALUE, getInputVoltage()); + } + + public int getMaxEnergyOutput() { + if (mReleaseEnergy) return Integer.MAX_VALUE; + return getOutput(); + } + + public int getOutput() { + return (int) Math.min(Integer.MAX_VALUE, oOutput); + } + + public int injectEnergy(Direction aDirection, int aAmount) { + return injectEnergyUnits(aDirection.toForgeDirection(), aAmount, 1) > 0 ? 0 : aAmount; + } + + public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) { + return inputEnergyFrom(aDirection.toForgeDirection()); + } + + public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) { + return outputsEnergyTo(aDirection.toForgeDirection()); + } + + @Override + public boolean isInvalidTileEntity() { + return isInvalid(); + } + + @Override + public boolean addStackToSlot(int aIndex, ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return true; + if (aIndex < 0 || aIndex >= getSizeInventory()) return false; + ItemStack tStack = getStackInSlot(aIndex); + if (GT_Utility.isStackInvalid(tStack)) { + setInventorySlotContents(aIndex, aStack); + return true; + } + aStack = GT_OreDictUnificator.get(aStack); + if (GT_Utility.areStacksEqual(tStack, aStack) + && tStack.stackSize + aStack.stackSize <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { + tStack.stackSize += aStack.stackSize; + return true; + } + return false; + } + + @Override + public boolean addStackToSlot(int aIndex, ItemStack aStack, int aAmount) { + return addStackToSlot(aIndex, GT_Utility.copyAmount(aAmount, aStack)); + } + + @Override + public void markDirty() { + super.markDirty(); + mInventoryChanged = true; + } + + /** + * To Do + */ + public boolean isElectric() { + return true; + } + + public boolean isEnetOutput() { + return false; + } + + public boolean isEnetInput() { + return false; + } + + public long maxEUStore() { + return 0L; + } + + public long maxEUInput() { + return 0L; + } + + public long maxEUOutput() { + return 0L; + } + + public long maxAmperesOut() { + return 1L; + } + + public long maxAmperesIn() { + return 1L; + } + + public void doEnergyExplosion() { + if (this.getUniversalEnergyCapacity() > 0L + && this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 5L) { + this.doExplosion( + this.oOutput * (long) (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() ? 4 + : (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 2L ? 2 : 1))); + GT_Mod arg9999 = GT_Mod.instance; + GT_Mod.achievements.issueAchievement( + this.getWorldObj() + .getPlayerEntityByName(this.mOwnerName), + "electricproblems"); + } + } + + public void doExplosion(long aAmount) { + if (this.canAccessData()) { + if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) { + try { + this.mReleaseEnergy = true; + Util.emitEnergyToNetwork(GT_Values.V[5], Math.max(1L, this.getStoredEU() / GT_Values.V[5]), this); + } catch (Exception arg4) {} + } + this.mReleaseEnergy = false; + this.onExplosion(); + PollutionUtils.addPollution(this, 100000); + this.mMetaTileEntity.doExplosion(aAmount); + } + } + + public void onExplosion() {} + + @Override + public String[] getDescription() { + return this.canAccessData() ? this.mMetaTileEntity.getDescription() : new String[0]; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return null; + } + + public long getEUVar() { + return this.mStoredEnergy; + } + + public void setEUVar(long aEnergy) { + this.mStoredEnergy = aEnergy; + } + + @Override + public long getStoredEU() { + return this.canAccessData() ? Math.min(this.mMetaTileEntity.getEUVar(), this.getEUCapacity()) : 0L; + } + + @Override + public long getEUCapacity() { + return this.canAccessData() ? this.mMetaTileEntity.maxEUStore() : 0L; + } + + public long getMinimumStoredEU() { + return 512L; + } + + public boolean setStoredEU(long aEnergy) { + if (!this.canAccessData()) { + return false; + } else { + if (aEnergy < 0L) { + aEnergy = 0L; + } + + this.mMetaTileEntity.setEUVar(aEnergy); + return true; + } + } + + public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) { + if (!this.canAccessData()) { + return false; + } else if (this.mMetaTileEntity.getEUVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) { + return false; + } else { + this.setStoredEU(this.mMetaTileEntity.getEUVar() - aEnergy); + if (this.mMetaTileEntity.getEUVar() < 0L) { + this.setStoredEU(0L); + return false; + } else { + return true; + } + } + } + + // Required as of 5.09.32-pre5 + public boolean energyStateReady() { + return false; + } + + private boolean firstTicked = false; + + public boolean onFirstTick() { + if (!firstTicked) { + firstTicked = true; + if (this.mInventory != null) { + this.mInventory.purgeNulls(); + return true; + } + } + 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/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java new file mode 100644 index 0000000000..0be6959b8f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java @@ -0,0 +1,313 @@ +package gtPlusPlus.core.tileentities.general; + +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 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 { + + private int tickCount = 0; + private final InventoryCircuitProgrammer inventoryContents; + private String customName; + public int locationX; + public int locationY; + public int locationZ; + private int aCurrentMode = 0; + + public TileEntityCircuitProgrammer() { + this.inventoryContents = new InventoryCircuitProgrammer(); + this.setTileLocation(); + } + + public boolean setTileLocation() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + this.locationX = this.xCoord; + this.locationY = this.yCoord; + this.locationZ = this.zCoord; + return true; + } + } + return false; + } + + // Rename to hasCircuitToConfigure + public final boolean hasCircuitToConfigure() { + for (ItemStack i : this.getInventory() + .getInventory()) { + if (i == null) { + continue; + } else { + return true; + } + } + return false; + } + + public InventoryCircuitProgrammer getInventory() { + return this.inventoryContents; + } + + public boolean addOutput() { + ItemStack[] aInputs = this.getInventory() + .getInventory() + .clone(); + // Check if there is output in slot. + Boolean hasOutput = false; + if (aInputs[25] != null) { + hasOutput = true; + } + AutoMap<Integer> aValidSlots = new AutoMap<>(); + int aSlotCount = 0; + for (ItemStack i : aInputs) { + if (i != null) { + aValidSlots.put(aSlotCount); + } + aSlotCount++; + } + for (int e : aValidSlots) { + boolean doAdd = false; + ItemStack g = this.getStackInSlot(e); + int aSize = 0; + 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); + 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(); + aInputStack.stackSize = (aSize - 64); + } + doAdd = true; + } + } + } + if (doAdd) { + // Check Circuit Type + ItemStack aOutput; + if (aTypeInSlot == 0) { + aOutput = CI.getNumberedCircuit(e); + } else if (aTypeInSlot == 1) { + aOutput = CI.getNumberedBioCircuit(e); + } else if (aTypeInSlot == 2) { + aOutput = CI.getNumberedAdvancedCircuit(e); + } else { + aOutput = null; + } + + if (aOutput != null) { + aOutput.stackSize = aSize; + this.setInventorySlotContents(e, aInputStack); + this.setInventorySlotContents(25, aOutput); + return true; + } + } + } + continue; + } + return false; + } + + @Override + public void updateEntity() { + try { + if (!this.worldObj.isRemote) { + if (tickCount % 10 == 0) { + if (hasCircuitToConfigure()) { + this.addOutput(); + this.markDirty(); + } + } + this.tickCount++; + } + } catch (final Throwable t) {} + } + + 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); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + nbt.setInteger("aCurrentMode", aCurrentMode); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + aCurrentMode = nbt.getInteger("aCurrentMode"); + } + + @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 p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return p_102007_1_ >= 0 && p_102007_1_ <= 24; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return p_102008_1_ == 25; + } + + 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.circuitprogrammer"; + } + + @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 onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { + try { + if (aCurrentMode == 24) { + aCurrentMode = 0; + } else { + aCurrentMode++; + } + PlayerUtils.messagePlayer(player, "Now configuring units for type " + aCurrentMode + "."); + return true; + } catch (Throwable t) { + return false; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java new file mode 100644 index 0000000000..b641f2e99e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java @@ -0,0 +1,378 @@ +package gtPlusPlus.core.tileentities.general; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.inventories.Inventory_DecayablesChest; +import gtPlusPlus.core.item.materials.DustDecayable; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class TileEntityDecayablesChest extends TileEntity implements ISidedInventory { + + private final Inventory_DecayablesChest inventoryContents; + + /** Determines if the check for adjacent chests has taken place. */ + public boolean adjacentChestChecked; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityDecayablesChest adjacentChestZNeg; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityDecayablesChest adjacentChestXPos; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityDecayablesChest adjacentChestXNeg; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityDecayablesChest adjacentChestZPos; + /** The current angle of the lid (between 0 and 1) */ + public float lidAngle; + /** The angle of the lid last tick */ + public float prevLidAngle; + /** The number of players currently using this chest */ + public int numPlayersUsing; + + private String customName; + + private int cachedChestType; + private int tickCount = 0; + + public TileEntityDecayablesChest() { + this.inventoryContents = new Inventory_DecayablesChest(); + } + + public Inventory_DecayablesChest getInventory() { + return this.inventoryContents; + } + + @Override + public void updateEntity() { + + // Try do chesty stuff + try { + this.updateEntityChest(); + } catch (Throwable t) { + + } + + try { + if (!this.worldObj.isRemote) { + this.tickCount++; + if ((this.tickCount % 10) == 0) { + cachedChestType = 1; + } + + if ((this.tickCount % 20) == 0) { + for (ItemStack inv : this.getInventory() + .getInventory()) { + if (inv == null) { + continue; + } + if (inv.getItem() instanceof DustDecayable D) { + tryUpdateDecayable(D, inv, this.worldObj); + } + } + } + updateSlots(); + } + } catch (final Throwable t) {} + } + + public void tryUpdateDecayable(final DustDecayable b, ItemStack iStack, final World world) { + if (world == null || iStack == null) { + return; + } + if (world.isRemote) { + return; + } + + boolean a1, a2; + int u = 0; + a1 = b.isTicking(world, iStack); + a2 = false; + int SECONDS_TO_PROCESS = 1; + while (u < (20 * SECONDS_TO_PROCESS)) { + if (!a1) { + break; + } + a1 = b.isTicking(world, iStack); + a2 = b.tickItemTag(world, iStack); + u++; + } + Logger.MACHINE_INFO("| " + b.getUnlocalizedName() + " | " + a1 + "/" + a2); + + if (!a1 && !a2) { + ItemStack replacement = ItemUtils.getSimpleStack(b.getDecayResult()); + replacement.stackSize = 1; + // iStack = replacement.copy(); + for (int fff = 0; fff < this.inventoryContents.getSizeInventory(); fff++) { + if (this.inventoryContents.getStackInSlot(fff) == iStack) { + this.inventoryContents.setInventorySlotContents(fff, replacement.copy()); + } + } + + updateSlots(); + this.inventoryContents.markDirty(); + } + } + + 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); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.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() { + if (this.numPlayersUsing < 0) { + this.numPlayersUsing = 0; + } + if (!this.worldObj.isRemote) { + this.numPlayersUsing++; + cachedChestType = 1; + } + this.worldObj + .addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + 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() { + if (!this.worldObj.isRemote) { + this.numPlayersUsing--; + cachedChestType = 1; + } + this.worldObj + .addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + 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 p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return this.getInventory() + .isItemValidForSlot(0, p_102007_2_); + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return this.getInventory() + .isItemValidForSlot(0, p_102008_2_); + } + + 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.DecayablesChest"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + /** + * Causes the TileEntity to reset all it's cached values for it's container Block, metadata and in the case of + * chests, the adjacent chest check + */ + @Override + public void updateContainingBlockInfo() { + super.updateContainingBlockInfo(); + this.adjacentChestChecked = false; + } + + /** + * Performs the check for adjacent chests to determine if this chest is double or not. + */ + public void checkForAdjacentChests() { + if (!this.adjacentChestChecked) { + this.adjacentChestChecked = true; + this.adjacentChestZNeg = null; + this.adjacentChestXPos = null; + this.adjacentChestXNeg = null; + this.adjacentChestZPos = null; + } + } + + public void updateEntityChest() { + float f; + this.prevLidAngle = this.lidAngle; + f = 0.04F; + double d2; + if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F + && this.adjacentChestZNeg == null + && this.adjacentChestXNeg == null) { + double d1 = (double) this.xCoord + 0.5D; + d2 = (double) this.zCoord + 0.5D; + this.worldObj.playSoundEffect( + d1, + (double) this.yCoord + 0.5D, + d2, + "random.chestopen", + 0.5F, + this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) { + float f1 = this.lidAngle; + if (this.numPlayersUsing > 0) { + // this.lidAngle += f; + this.lidAngle += (float) (f * (1 + 0.10 * 0.01)); + } else { + // this.lidAngle -= f; + this.lidAngle -= (float) (f * (1 + 0.10 * 0.01)); + } + if (this.lidAngle > 1.0F) { + this.lidAngle = 1.0F; + } + float f2 = 0.5F; + if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) { + d2 = (double) this.xCoord + 0.5D; + double d0 = (double) this.zCoord + 0.5D; + this.worldObj.playSoundEffect( + d2, + (double) this.yCoord + 0.5D, + d0, + "random.chestclosed", + 0.5F, + this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.lidAngle < 0.0F) { + this.lidAngle = 0.0F; + } + } + } + + /** + * Called when a client event is received with the event number and argument, see World.sendClientEvent + */ + @Override + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { + if (p_145842_1_ == 1) { + this.numPlayersUsing = p_145842_2_; + return true; + } else { + return super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + } + + /** + * invalidates a tile entity + */ + @Override + public final void invalidate() { + super.invalidate(); + cachedChestType = 1; + this.updateContainingBlockInfo(); + this.checkForAdjacentChests(); + } + + private int updateSlots() { + // Have slots changed? + if (cachedChestType == 0) { + return 0; + } + ItemUtils.organiseInventory(getInventory()); + cachedChestType = 0; + return cachedChestType; + } +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java new file mode 100644 index 0000000000..1a09b6b423 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java @@ -0,0 +1,294 @@ +package gtPlusPlus.core.tileentities.general; + +import static gregtech.api.enums.Mods.PamsHarvestCraft; + +import java.util.Random; + +import javax.annotation.Nullable; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.FishingHooks; + +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.InventoryFishTrap; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class TileEntityFishTrap extends TileEntity implements ISidedInventory { + + private int tickCount = 0; + private final InventoryFishTrap inventoryContents; + private String customName; + // The number of water blocks is used as an index to get the tick rate. + private final static short[] waterBlocksToTickRate = new short[] { 0, 0, 5600, 4400, 3200, 2000, 1750 }; + private int surroundingWaterBlocks = 0; + + public TileEntityFishTrap() { + this.inventoryContents = new InventoryFishTrap(); + } + + private int getNumberOfSurroundingWater() { + if (!this.hasWorldObj() || this.getWorldObj().isRemote) { + return 0; + } + final Block[] surroundingBlocks = new Block[6]; + surroundingBlocks[0] = this.worldObj.getBlock(this.xCoord, this.yCoord + 1, this.zCoord); // Above + surroundingBlocks[1] = this.worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord); // Below + surroundingBlocks[2] = this.worldObj.getBlock(this.xCoord + 1, this.yCoord, this.zCoord); + surroundingBlocks[3] = this.worldObj.getBlock(this.xCoord - 1, this.yCoord, this.zCoord); + surroundingBlocks[4] = this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord + 1); + surroundingBlocks[5] = this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord - 1); + int waterCount = 0; + int trapCount = 0; + for (final Block checkBlock : surroundingBlocks) { + if (checkBlock == ModBlocks.blockFishTrap) { + trapCount++; + } else if ((checkBlock == Blocks.water) || (checkBlock == Blocks.flowing_water)) { + waterCount++; + } + } + // Explicitly check for at least 2 water blocks. + if (waterCount < 2) { + return 0; + } + // Only allow the first four traps to count towards valid neighbor blocks. + return waterCount + Math.min(trapCount, 4); + } + + public InventoryFishTrap getInventory() { + return this.inventoryContents; + } + + private void tryAddLoot() { + ItemUtils.organiseInventory(getInventory()); + final ItemStack loot = this.generateLootForFishTrap(); + if (loot == null) { + return; + } + for (final ItemStack contents : this.getInventory() + .getInventory()) { + if (GT_Utility.areStacksEqual(loot, contents)) { + if (contents.stackSize < contents.getMaxStackSize()) { + contents.stackSize++; + this.markDirty(); + return; + } + } + } + int checkingSlot = 0; + for (final ItemStack contents : this.getInventory() + .getInventory()) { + if (contents == null) { + this.getInventory() + .setInventorySlotContents(checkingSlot, loot); + this.markDirty(); + return; + } + checkingSlot++; + } + } + + @Nullable + private ItemStack generateLootForFishTrap() { + final int lootWeight = MathUtils.randInt(0, 100); + ItemStack loot = null; + if (lootWeight <= 5) { + loot = ItemUtils.getSimpleStack(Items.slime_ball); + } else if (lootWeight <= 10) { + loot = ItemUtils.getSimpleStack(Items.bone); + } else if (lootWeight <= 15) { + loot = ItemUtils.getSimpleStack(Blocks.sand); + } else if (lootWeight <= 20) { + loot = ItemUtils.simpleMetaStack(Items.dye, 0, 1); + } + // Junk Loot + else if (lootWeight <= 23) { + if (PamsHarvestCraft.isModLoaded()) { + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cropSeaweed", 1); + } else { + loot = ItemUtils.getSimpleStack(Blocks.dirt); + } + } + // Pam Fish + else if (lootWeight <= 99) { + final Random xstr = new Random(); + loot = FishingHooks.getRandomFishable(xstr, 100); + } else if (lootWeight == 100) { + final int rareLoot = MathUtils.randInt(1, 10); + if (rareLoot <= 4) { + loot = Materials.Iron.getNuggets(1); + } else if (rareLoot <= 7) { + loot = ItemUtils.getSimpleStack(Items.gold_nugget); + } else if (rareLoot <= 9) { + loot = ItemUtils.getSimpleStack(Items.emerald); + } else { + loot = ItemUtils.getSimpleStack(Items.diamond); + } + } + if (loot != null) { + loot.stackSize = 1; + } + return loot; + } + + @Override + public void updateEntity() { + if (this.worldObj.isRemote) { + return; + } + + this.tickCount++; + // Only recalculate the amount of neighboring water/trap blocks every 20 ticks. + if ((this.tickCount % 20) == 0) { + this.surroundingWaterBlocks = getNumberOfSurroundingWater(); + } + + if ((waterBlocksToTickRate[this.surroundingWaterBlocks] != 0) + && this.tickCount > waterBlocksToTickRate[this.surroundingWaterBlocks]) { + int aExtraLootChance = MathUtils.randInt(1, 1000); + if (aExtraLootChance >= 999) { + this.tryAddLoot(); + this.tryAddLoot(); + this.tryAddLoot(); + } else { + this.tryAddLoot(); + } + this.markDirty(); + + this.tickCount = 0; + } + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.inventoryContents.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 p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return true; + } + + 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.fishtrap"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.isEmpty(); + } +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java new file mode 100644 index 0000000000..fd528c589d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java @@ -0,0 +1,148 @@ +package gtPlusPlus.core.tileentities.general; + +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.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; + +public class TileEntityInfiniteFluid extends TileEntity implements IFluidHandler { + + public FluidTank tank = new FluidTank(Integer.MAX_VALUE); + private boolean needsUpdate = false; + private int updateTimer = 0; + + public TileEntityInfiniteFluid() {} + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + needsUpdate = true; + return this.tank.fill(resource, doFill); + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + needsUpdate = true; + return this.tank.drain(resource.amount, doDrain); + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + needsUpdate = true; + FluidStack fluid = this.tank.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.tank, + 0)); + } + } + return stack; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] { this.tank.getInfo() }; + } + + public float getAdjustedVolume() { + needsUpdate = true; + float amount = tank.getFluidAmount(); + float capacity = tank.getCapacity(); + float volume = (amount / capacity) * 0.8F; + return volume; + } + + @Override + public void updateEntity() { + + if (this.tank.getFluid() != null) { + FluidStack bigStorage = this.tank.getFluid(); + bigStorage.amount = this.tank.getCapacity(); + this.tank.setFluid(bigStorage); + } + + if (needsUpdate) { + + if (this.tank.getFluid() != null) { + FluidStack bigStorage = this.tank.getFluid(); + bigStorage.amount = this.tank.getCapacity(); + this.tank.setFluid(bigStorage); + } + + if (updateTimer == 0) { + updateTimer = 10; // every 10 ticks it will send an update + } else { + --updateTimer; + if (updateTimer == 0) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + needsUpdate = false; + } + } + } + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + tank.readFromNBT(tag); + super.readFromNBT(tag); + } + + @Override + public void writeToNBT(NBTTagCompound tag) { + tank.writeToNBT(tag); + super.writeToNBT(tag); + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound tag = pkt.func_148857_g(); + readFromNBT(tag); + } +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java new file mode 100644 index 0000000000..a9bc2b0049 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -0,0 +1,418 @@ +package gtPlusPlus.core.tileentities.general; + +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.minecraftforge.fluids.FluidStack; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.container.Container_VolumetricFlaskSetter; +import gtPlusPlus.core.inventories.Inventory_VolumetricFlaskSetter; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; + +public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISidedInventory { + + private int tickCount = 0; + private final Inventory_VolumetricFlaskSetter inventoryContents; + private String customName; + public int locationX; + public int locationY; + public int locationZ; + private int aCurrentMode = 0; + private int aCustomValue = 1000; + + public TileEntityVolumetricFlaskSetter() { + this.inventoryContents = new Inventory_VolumetricFlaskSetter(); + this.setTileLocation(); + } + + public int getCustomValue() { + // Logger.INFO("Value: "+this.aCustomValue); + return this.aCustomValue; + } + + public void setCustomValue(int aVal) { + log("Old Value: " + this.aCustomValue); + this.aCustomValue = (short) MathUtils.balance(aVal, 0, Short.MAX_VALUE); + log("New Value: " + this.aCustomValue); + markDirty(); + } + + public boolean setTileLocation() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + this.locationX = this.xCoord; + this.locationY = this.yCoord; + this.locationZ = this.zCoord; + return true; + } + } + return false; + } + + // Rename to hasCircuitToConfigure + public final boolean hasFlask() { + for (int i = 0; i < this.getInventory() + .getInventory().length - 1; i++) { + if (i == Container_VolumetricFlaskSetter.SLOT_OUTPUT) { + continue; + } + if (this.getInventory() + .getInventory()[i] != null) { + return true; + } + } + return false; + } + + public Inventory_VolumetricFlaskSetter getInventory() { + return this.inventoryContents; + } + + private int getFlaskType(ItemStack aStack) { + if (VolumetricFlaskHelper.isNormalVolumetricFlask(aStack)) { + return 1; + } else if (VolumetricFlaskHelper.isLargeVolumetricFlask(aStack)) { + return 2; + } else if (VolumetricFlaskHelper.isGiganticVolumetricFlask(aStack)) { + return 3; + } + return 0; + } + + private int getCapacityForSlot(int aSlot) { + return switch (aSlot) { + case 0 -> // 16 + 16; + case 1 -> // 36 + 36; + case 2 -> // 144 + 144; + case 3 -> // 432 + 432; + case 4 -> // 576 + 576; + case 5 -> // 720 + 720; + case 6 -> // 864 + 864; + case 7 -> // Custom + getCustomValue(); + default -> 1000; + }; + } + + public boolean addOutput() { + + // Don't do anything unless we have items + if (!hasFlask()) { + Logger.INFO("No Flasks."); + return false; + } + + ItemStack[] aInputs = this.getInventory() + .getInventory() + .clone(); + + // Check if there is output in slot. + Boolean hasOutput = false; + if (aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT] != null) { + hasOutput = true; + if (aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT].stackSize >= 16) { + return false; + } + } + AutoMap<Integer> aValidSlots = new AutoMap<>(); + int aSlotCount = 0; + for (ItemStack i : aInputs) { + if (i != null) { + aValidSlots.put(aSlotCount); + } + aSlotCount++; + } + for (int e : aValidSlots) { + + // Skip slot 7 (Custom) unless it has a value > 0 + if (e == 7 && getCustomValue() <= 0) { + log("Skipping Custom slot as value <= 0"); + continue; + } + if (e == Container_VolumetricFlaskSetter.SLOT_OUTPUT) { + continue; + } + + boolean doAdd = false; + ItemStack g = this.getStackInSlot(e); + FluidStack aInputFluidStack = VolumetricFlaskHelper.getFlaskFluid(g); + int aSize = 0; + ItemStack aInputStack = null; + int aTypeInSlot = getFlaskType(g); + if (aTypeInSlot > 0 && g != null) { + // No Existing Output + if (!hasOutput) { + aSize = g.stackSize; + doAdd = true; + } + // Existing Output + else { + ItemStack f = aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT]; + FluidStack aFluidInCheckedSlot = VolumetricFlaskHelper.getFlaskFluid(f); + int aTypeInCheckedSlot = getFlaskType(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() + && VolumetricFlaskHelper.getFlaskCapacity(f) == getCapacityForSlot(e) + && ((aInputFluidStack == null && aFluidInCheckedSlot == null) + || aInputFluidStack.isFluidEqual(aFluidInCheckedSlot))) { + log( + "Input Slot Flask Contains: " + + (aInputFluidStack != null ? aInputFluidStack.getLocalizedName() : "Empty")); + log( + "Output Slot Flask Contains: " + + (aFluidInCheckedSlot != null ? aFluidInCheckedSlot.getLocalizedName() : "Empty")); + aSize = f.stackSize + g.stackSize; + if (aSize > 16) { + aInputStack = g.copy(); + aInputStack.stackSize = (aSize - 16); + } + doAdd = true; + } + } + } + if (doAdd) { + // Check Circuit Type + ItemStack aOutput; + FluidStack aOutputFluid = null; + if (!VolumetricFlaskHelper.isFlaskEmpty(g)) { + aOutputFluid = aInputFluidStack.copy(); + } + if (aTypeInSlot == 1) { + aOutput = VolumetricFlaskHelper.getVolumetricFlask(1); + } else if (aTypeInSlot == 2) { + aOutput = VolumetricFlaskHelper.getLargeVolumetricFlask(1); + } else if (aTypeInSlot == 3) { + aOutput = VolumetricFlaskHelper.getGiganticVolumetricFlask(1); + } else { + aOutput = null; + } + if (aOutput != null) { + aOutput.stackSize = aSize; + int aCapacity = getCapacityForSlot(e); + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, aCapacity); + if (aOutputFluid != null) { + if (aOutputFluid.amount > aCapacity) { + aOutputFluid.amount = aCapacity; + } + VolumetricFlaskHelper.setFluid(aOutput, aOutputFluid); + } + this.setInventorySlotContents(e, aInputStack); + this.setInventorySlotContents(Container_VolumetricFlaskSetter.SLOT_OUTPUT, aOutput); + return true; + } + } + } + continue; + } + return false; + } + + @Override + public void updateEntity() { + try { + if (!this.worldObj.isRemote) { + if (tickCount % 10 == 0) { + if (hasFlask()) { + this.addOutput(); + this.markDirty(); + } + } + this.tickCount++; + } + } catch (final Throwable t) {} + } + + 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); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + nbt.setInteger("aCustomValue", aCustomValue); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + nbt.setInteger("aCurrentMode", aCurrentMode); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + this.aCustomValue = nbt.getInteger("aCustomValue"); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + aCurrentMode = nbt.getInteger("aCurrentMode"); + } + + @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 p_102007_2_, final int p_102007_3_) { + return aSlot == aCurrentMode; + } + + @Override + public boolean canExtractItem(final int aSlot, final ItemStack p_102008_2_, final int p_102008_3_) { + return aSlot == Container_VolumetricFlaskSetter.SLOT_OUTPUT; + } + + 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.VolumetricFlaskSetter"; + } + + @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 onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { + + if (player.isSneaking()) { + PlayerUtils.messagePlayer(player, "Value: " + this.getCustomValue()); + } + + try { + if (aCurrentMode == 7) { + aCurrentMode = 0; + } else { + aCurrentMode++; + } + PlayerUtils.messagePlayer(player, "Slot " + aCurrentMode + " is now default."); + return true; + } catch (Throwable t) { + return false; + } + } + + public void log(String aString) { + Logger.INFO("[Flask-Tile] " + aString); + } +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java new file mode 100644 index 0000000000..5e0aaf8370 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java @@ -0,0 +1,140 @@ +package gtPlusPlus.core.tileentities.machines; + +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.passive.IAnimals; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; + +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { + + public TileEntityAdvPooCollector() { + super(18, 128000); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public void onPreLogicTick() {} + + @Override + public <V> boolean addDrop(V aPooMaker) { + int aChance = MathUtils.randInt(0, 50000); + if (aChance > 0) { + ItemStack aPoop; + if (aChance <= 200) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); + } else if (aChance <= 1000) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + } else if (aChance <= 2000) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + } else { + return false; + } + + // Add to inventory if not full, else espawn in world + if (!this.mInventory.addItemStack(aPoop)) { + EntityItem entity = new EntityItem(worldObj, xCoord, yCoord + 1.5, zCoord, aPoop); + worldObj.spawnEntityInWorld(entity); + } + } + + return false; + } + + private static AutoMap<Class> aEntityToDrain = new AutoMap<>(); + + @Override + public AutoMap<Class> aThingsToLookFor() { + if (aEntityToDrain.isEmpty()) { + aEntityToDrain.add(EntityAnimal.class); + aEntityToDrain.add(IAnimals.class); + aEntityToDrain.add(EntityVillager.class); + aEntityToDrain.add(EntityPlayer.class); + } + return aEntityToDrain; + } + + @Override + public <V> int onPostTick(V aPooMaker) { + if (this.tank.getFluidAmount() < this.tank.getCapacity()) { + int aPooAmount = 0; + // Vanilla Animals + if (aPooMaker instanceof EntityChicken) { + aPooAmount = MathUtils.randInt(1, 40); + } else if (aPooMaker instanceof EntityHorse) { + aPooAmount = MathUtils.randInt(20, 40); + } else if (aPooMaker instanceof EntityCow) { + aPooAmount = MathUtils.randInt(18, 45); + } else if (aPooMaker instanceof EntityMooshroom) { + aPooAmount = 17; + } else if (aPooMaker instanceof EntitySheep) { + aPooAmount = MathUtils.randInt(8, 30); + } else { + if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) { + aPooAmount = MathUtils.randInt(5, 35); + } else if (aPooMaker instanceof EntityVillager) { + aPooAmount = MathUtils.randInt(25, 30); + } else if (aPooMaker instanceof EntityPlayer) { + aPooAmount = MathUtils.randInt(1, 3); + } else { + aPooAmount = MathUtils.randInt(1, 10); + } + } + aPooAmount = Math.max(Math.min(this.tank.getCapacity() - this.tank.getFluidAmount(), aPooAmount), 1); + return Math.max( + 1, + (aPooAmount + * MathUtils + .getRandomFromArray(new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4 }) + / 10)); + } else { + return 0; + } + } + + @Override + public Fluid fluidToProvide() { + return AgriculturalChem.PoopJuice; + } + + @Override + public ItemStack itemToSpawnInWorldIfTankIsFull() { + int a = MathUtils.randInt(0, 75); + ItemStack aItem = null; + if (a <= 30) { + aItem = ItemUtils.getSimpleStack(AgriculturalChem.dustDirt); + } else if (a <= 40) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); + } else if (a <= 55) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + } + return aItem; + } + + @Override + public int getBaseTickRate() { + return MathUtils.randInt(50, 200); + } +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java new file mode 100644 index 0000000000..6340415e82 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java @@ -0,0 +1,241 @@ +package gtPlusPlus.core.tileentities.machines; + +import java.util.List; + +import net.minecraft.entity.item.EntityItem; +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.util.AxisAlignedBB; +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 gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.tileentities.base.TileEntityBase; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public abstract class TileEntityBaseFluidCollector extends TileEntityBase implements IFluidHandler { + + public final FluidTank tank; + private boolean needsUpdate = false; + private int updateTimer = 0; + private long internalTickCounter = 0; + private BlockPos internalBlockLocation; + + public TileEntityBaseFluidCollector(int aInvSlotCount, int aTankCapcity) { + super(aInvSlotCount); + tank = new BTF_FluidTank(aTankCapcity); + } + + @Override + public final int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + needsUpdate = true; + return this.tank.fill(resource, doFill); + } + + @Override + public final FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + needsUpdate = true; + return this.tank.drain(resource.amount, doDrain); + } + + @Override + public final FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + needsUpdate = true; + FluidStack fluid = this.tank.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.tank, + 0)); + } + } + return stack; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public final FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] { this.tank.getInfo() }; + } + + @Override + public final void updateEntity() { + super.updateEntity(); + onPreLogicTick(); + logicTick(); + if (needsUpdate) { + if (updateTimer == 0) { + updateTimer = 10; // every 10 ticks it will send an update + } else { + --updateTimer; + if (updateTimer == 0) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + needsUpdate = false; + } + } + } + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + tank.readFromNBT(tag); + super.readFromNBT(tag); + } + + @Override + public void writeToNBT(NBTTagCompound tag) { + tank.writeToNBT(tag); + super.writeToNBT(tag); + } + + @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 int getBaseTickRate() { + return MathUtils.randInt(200, 300); + } + + public abstract AutoMap<Class> aThingsToLookFor(); + + public abstract void onPreLogicTick(); + + public final void logicTick() { + + if (this.worldObj == null || this.worldObj.isRemote) { + return; + } + if (internalTickCounter % getBaseTickRate() == 0) { + if (internalBlockLocation == null) { + internalBlockLocation = new BlockPos(this); + } + BlockPos p = internalBlockLocation; + if (p != null) { + if (p.world != null) { + World w = this.worldObj; + if (w == null) { + return; + } + Chunk c = w.getChunkFromBlockCoords(p.xPos, p.zPos); + if (c != null) { + if (c.isChunkLoaded) { + int startX = p.xPos - 2; + int startY = p.yPos; + int startZ = p.zPos - 2; + int endX = p.xPos + 3; + int endY = p.yPos + 5; + int endZ = p.zPos + 3; + AxisAlignedBB box = AxisAlignedBB.getBoundingBox(startX, startY, startZ, endX, endY, endZ); + if (box != null) { + for (Class c2 : aThingsToLookFor()) { + tickEntityType(w, box, c2); + } + } else { + return; + } + } + } + } + } + } + + internalTickCounter++; + } + + @SuppressWarnings("unchecked") + public final void tickEntityType(World w, AxisAlignedBB box, Class aClassToFind) { + List<?> entities = w.getEntitiesWithinAABB(aClassToFind, box); + if (entities != null && !entities.isEmpty()) { + interactWithEntities(entities); + } + } + + public final <V> void interactWithEntities(List<V> entities) { + for (V aEntity : entities) { + addDrop(aEntity); + if (this.tank.getFluidAmount() < this.tank.getCapacity()) { + int aFluidAmount = onPostTick(aEntity); + aFluidAmount = Math + .max(Math.min(this.tank.getCapacity() - this.tank.getFluidAmount(), aFluidAmount), 1); + this.tank.fill(FluidUtils.getFluidStack(fluidToProvide(), aFluidAmount), true); + } else { + ItemStack aDirtStack = ItemUtils.getSimpleStack(itemToSpawnInWorldIfTankIsFull(), 1); + if (!ItemUtils.checkForInvalidItems(aDirtStack)) { + return; + } + if (!this.mInventory.addItemStack(aDirtStack)) { + EntityItem entity = new EntityItem(worldObj, xCoord, yCoord + 1.5, zCoord, aDirtStack); + worldObj.spawnEntityInWorld(entity); + } + } + } + } + + /** + * Return the amount of fluid for this entity type + * + * @param aEntity + * @return + */ + public abstract <V> int onPostTick(V aEntity); + + public abstract <V> boolean addDrop(V aPooMaker); + + public abstract Fluid fluidToProvide(); + + public abstract ItemStack itemToSpawnInWorldIfTankIsFull(); +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java new file mode 100644 index 0000000000..dfdb7104b0 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java @@ -0,0 +1,532 @@ +package gtPlusPlus.core.tileentities.machines; + +import static gregtech.api.enums.Mods.Forestry; + +import java.util.ArrayList; +import java.util.List; + +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; + +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.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; + +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<>(); + + static { + mEntityMap.put(EntityBat.class); + if (Forestry.isModLoaded()) { + 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 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; + } + case 2 -> { + min = -4; + max = 5; + } + default -> {} + // code block + } + int aChunkCount = 0; + AutoMap<Entity> entities = new AutoMap<>(); + 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); + } + } + 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.getFluidStack(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.getFluidStack(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 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/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java new file mode 100644 index 0000000000..d0d4ee3661 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java @@ -0,0 +1,128 @@ +package gtPlusPlus.core.tileentities.machines; + +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.IAnimals; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; + +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class TileEntityPooCollector extends TileEntityBaseFluidCollector { + + public TileEntityPooCollector() { + super(9, 8000); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public void onPreLogicTick() {} + + @Override + public <V> boolean addDrop(V aPooMaker) { + int aChance = MathUtils.randInt(0, 50000); + if (aChance > 0) { + ItemStack aPoop; + if (aChance <= 100) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); + } else if (aChance <= 500) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + } else if (aChance <= 1250) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + } else { + return false; + } + if (!ItemUtils.checkForInvalidItems(aPoop)) { + return false; + } + + // Add poop to world + // Logger.INFO("Adding animal waste for "+aPooMaker.getCommandSenderName()); + + // Add to inventory if not full, else espawn in world + if (!this.mInventory.addItemStack(aPoop)) { + EntityItem entity = new EntityItem(worldObj, xCoord, yCoord + 1.5, zCoord, aPoop); + worldObj.spawnEntityInWorld(entity); + } + } + + return false; + } + + private static AutoMap<Class> aEntityToDrain = new AutoMap<>(); + + @Override + public AutoMap<Class> aThingsToLookFor() { + if (aEntityToDrain.isEmpty()) { + aEntityToDrain.add(EntityAnimal.class); + aEntityToDrain.add(IAnimals.class); + } + return aEntityToDrain; + } + + @Override + public <V> int onPostTick(V aPooMaker) { + if (this.tank.getFluidAmount() < this.tank.getCapacity()) { + int aPooAmount = 0; + // Vanilla Animals + if (aPooMaker instanceof EntityChicken) { + aPooAmount = MathUtils.randInt(1, 40); + } else if (aPooMaker instanceof EntityHorse) { + aPooAmount = MathUtils.randInt(20, 40); + } else if (aPooMaker instanceof EntityCow) { + aPooAmount = MathUtils.randInt(18, 45); + } else if (aPooMaker instanceof EntityMooshroom) { + aPooAmount = 17; + } else if (aPooMaker instanceof EntitySheep) { + aPooAmount = MathUtils.randInt(8, 30); + } else { + if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) { + aPooAmount = MathUtils.randInt(5, 35); + } else { + aPooAmount = MathUtils.randInt(1, 10); + } + } + aPooAmount = Math.max((Math.min(this.tank.getCapacity() - this.tank.getFluidAmount(), aPooAmount) / 10), 1); + return aPooAmount; + } else { + return 0; + } + } + + @Override + public Fluid fluidToProvide() { + return AgriculturalChem.PoopJuice; + } + + @Override + public ItemStack itemToSpawnInWorldIfTankIsFull() { + int a = MathUtils.randInt(0, 100); + ItemStack aItem = null; + if (a <= 30) { + aItem = ItemUtils.getSimpleStack(AgriculturalChem.dustDirt); + } else if (a <= 40) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + } else if (a <= 55) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + } + return aItem; + } +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java new file mode 100644 index 0000000000..7c90ddc1c2 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java @@ -0,0 +1,165 @@ +package gtPlusPlus.core.tileentities.machines; + +import java.util.List; +import java.util.Vector; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import gregtech.api.enums.ItemList; +import gregtech.common.items.GT_MetaGenerated_Item_01; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.inventories.projecttable.InventoryProjectMain; +import gtPlusPlus.core.inventories.projecttable.InventoryProjectOutput; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; +import ic2.api.network.INetworkDataProvider; +import ic2.api.network.INetworkUpdateListener; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; + +public class TileEntityProjectTable extends TileEntity + implements INetworkDataProvider, INetworkUpdateListener, IWrenchable { + + public InventoryProjectMain inventoryGrid; + public InventoryProjectOutput inventoryOutputs; + + private Container_ProjectTable container; + + public TileEntityProjectTable() { + this.inventoryGrid = new InventoryProjectMain(); // number of slots - without product slot + this.inventoryOutputs = new InventoryProjectOutput(); // number of slots - without product slot + this.canUpdate(); + } + + public void setContainer(Container_ProjectTable container) { + this.container = container; + } + + 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); + nbt.setShort("facing", this.facing); + this.inventoryGrid.writeToNBT(this.getTag(nbt, "ContentsGrid")); + this.inventoryOutputs.writeToNBT(this.getTag(nbt, "ContentsOutput")); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.prevFacing = (this.facing = nbt.getShort("facing")); + this.inventoryGrid.readFromNBT(nbt.getCompoundTag("ContentsGrid")); + this.inventoryOutputs.readFromNBT(nbt.getCompoundTag("ContentsOutput")); + } + + @Override + public List<String> getNetworkedFields() { + final List<String> ret = new Vector(2); + ret.add("facing"); + return ret; + } + + @Override + public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final int side) { + return false; + } + + private short facing = 0; + public short prevFacing = 0; + + @Override + public void setFacing(final short facing1) { + this.facing = facing1; + if (this.prevFacing != facing1) { + IC2.network.get() + .updateTileEntityField(this, "facing"); + } + this.prevFacing = facing1; + } + + @Override + public short getFacing() { + return this.facing; + } + + @Override + public boolean wrenchCanRemove(final EntityPlayer entityPlayer) { + return true; + } + + @Override + public float getWrenchDropRate() { + return 1.0F; + } + + @Override + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { + return new ItemStack( + this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord), + 1, + this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); + } + + @Override + public void onNetworkUpdate(final String field) { + this.prevFacing = this.facing; + } + + @Override + public void updateEntity() { + if (!this.worldObj.isRemote) { + // Data stick + ItemStack dataStick = this.inventoryOutputs.getStackInSlot(0); + if (dataStick != null && this.container != null && container.getOutputContent() != null) { + if ((dataStick.getItem() instanceof GT_MetaGenerated_Item_01 && dataStick.getItemDamage() == 32708) + || (dataStick == ItemList.Tool_DataStick.get(1)) + || (dataStick == GregtechItemList.Old_Tool_DataStick.get(1)) + || (dataStick.getItem() instanceof MetaGeneratedGregtechItems + && dataStick.getItemDamage() == 32208)) { + + Logger.INFO("Found Data Stick and valid container."); + + ItemStack outputComponent = container.getOutputContent(); + ItemStack[] craftInputComponent = container.getInputComponents(); + + ItemStack newStick = NBTUtils + .writeItemsToNBT(dataStick, new ItemStack[] { outputComponent }, "Output"); + newStick = NBTUtils.writeItemsToNBT(newStick, craftInputComponent); + NBTUtils.setBookTitle(newStick, "Encrypted Project Data"); + NBTUtils.setBoolean(newStick, "mEncrypted", true); + int slotm = 0; + Logger.WARNING("Uploading to Data Stick."); + for (ItemStack is : NBTUtils.readItemsFromNBT(newStick)) { + if (is != null) { + Logger.WARNING("Uploaded " + is.getDisplayName() + " into memory slot " + slotm + "."); + } else { + Logger.WARNING("Left memory slot " + slotm + " blank."); + } + slotm++; + } + Logger.WARNING("Encrypting Data Stick."); + this.inventoryOutputs.setInventorySlotContents(1, newStick); + this.inventoryOutputs.setInventorySlotContents(0, null); + } + } + + } + super.updateEntity(); + } + + @Override + public boolean canUpdate() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/MovingAverageLong.java b/src/main/java/gtPlusPlus/core/util/MovingAverageLong.java new file mode 100644 index 0000000000..7111fbd5e1 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/MovingAverageLong.java @@ -0,0 +1,59 @@ +package gtPlusPlus.core.util; + +import java.math.BigInteger; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; + +import net.minecraft.nbt.NBTTagCompound; + +public class MovingAverageLong { + + private final long[] storage; + private int ptr; + + public MovingAverageLong(int sampleSize) { + storage = new long[sampleSize]; + } + + public void set(long average) { + Arrays.fill(storage, average); + } + + public void sample(long data) { + storage[ptr] = data; + ptr = (ptr + 1) % storage.length; + } + + public long get() { + BigInteger result = BigInteger.ZERO; + for (long l : storage) { + result = result.add(BigInteger.valueOf(l)); + } + return result.divide(BigInteger.valueOf(storage.length)) + .longValue(); + } + + public void write(NBTTagCompound tagCompound, String key) { + ByteBuffer buf = ByteBuffer.allocate(storage.length * Long.BYTES) + .order(ByteOrder.nativeOrder()); + buf.asLongBuffer() + .put(storage); + tagCompound.setByteArray(key, buf.array()); + } + + /** + * if read failed, the internal states would not be changed. + * + * @return true if successful, false otherwise. + */ + public boolean read(NBTTagCompound tagCompound, String key) { + ByteBuffer buf = ByteBuffer.wrap(tagCompound.getByteArray(key)); + if (buf.remaining() != storage.length * Long.BYTES) + // not very good... + return false; + buf.asLongBuffer() + .get(storage); + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/Utils.java b/src/main/java/gtPlusPlus/core/util/Utils.java new file mode 100644 index 0000000000..610cc4f8fa --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/Utils.java @@ -0,0 +1,436 @@ +package gtPlusPlus.core.util; + +import java.awt.Color; +import java.io.File; +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +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.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.EnumHelper; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.EnumUtils; + +import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.api.GregTech_API; +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.api.objects.Logger; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import ic2.core.Ic2Items; +import ic2.core.init.InternalName; +import ic2.core.item.resources.ItemCell; + +public class Utils { + + public static boolean isServer() { + return FMLCommonHandler.instance() + .getEffectiveSide() + .isServer(); + } + + public static boolean isClient() { + return FMLCommonHandler.instance() + .getEffectiveSide() + .isClient(); + } + + public static TC_AspectStack getTcAspectStack(final TC_Aspects aspect, final long size) { + return getTcAspectStack(aspect.name(), (int) size); + } + + public static TC_AspectStack getTcAspectStack(final String aspect, final long size) { + return getTcAspectStack(aspect, (int) size); + } + + public static TC_AspectStack getTcAspectStack(final TC_Aspects aspect, final int size) { + return getTcAspectStack(aspect.name(), size); + } + + public static TC_AspectStack getTcAspectStack(final String aspect, final int size) { + + TC_AspectStack returnValue = null; + + if (aspect.equalsIgnoreCase("COGNITIO")) { + // Adds in Compat for older GT Versions which Misspell aspects. + try { + if (EnumUtils.isValidEnum(TC_Aspects.class, "COGNITIO")) { + Logger.WARNING("TC Aspect found - " + aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); + } else { + Logger.INFO( + "Fallback TC Aspect found - " + aspect + + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); + } + } catch (final NoSuchFieldError r) { + Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + } + } else if (aspect.equalsIgnoreCase("EXANIMUS")) { + // Adds in Compat for older GT Versions which Misspell aspects. + try { + if (EnumUtils.isValidEnum(TC_Aspects.class, "EXANIMUS")) { + Logger.WARNING("TC Aspect found - " + aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); + } else { + Logger.INFO( + "Fallback TC Aspect found - " + aspect + + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); + } + } catch (final NoSuchFieldError r) { + Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + } + + } else if (aspect.equalsIgnoreCase("PRAECANTATIO")) { + // Adds in Compat for older GT Versions which Misspell aspects. + try { + if (EnumUtils.isValidEnum(TC_Aspects.class, "PRAECANTATIO")) { + Logger.WARNING("TC Aspect found - " + aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); + } else { + Logger.INFO( + "Fallback TC Aspect found - " + aspect + + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); + } + } catch (final NoSuchFieldError r) { + Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + } + } else { + Logger.WARNING("TC Aspect found - " + aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf(aspect), size); + } + + return returnValue; + } + + // Register an event to both busses. + public static void registerEvent(Object o) { + MinecraftForge.EVENT_BUS.register(o); + FMLCommonHandler.instance() + .bus() + .register(o); + } + + // Send a message to all players on the server + public static void sendServerMessage(final String translationKey) { + sendServerMessage(new ChatComponentText(translationKey)); + } + + // Send a message to all players on the server + public static void sendServerMessage(final IChatComponent chatComponent) { + MinecraftServer.getServer() + .getConfigurationManager() + .sendChatMsg(chatComponent); + } + + /** + * Returns if that Liquid is IC2Steam. + */ + public static boolean isIC2Steam(final FluidStack aFluid) { + if (aFluid == null) { + return false; + } + return aFluid.isFluidEqual(getIC2Steam(1)); + } + + /** + * Returns a Liquid Stack with given amount of IC2Steam. + */ + public static FluidStack getIC2Steam(final long aAmount) { + return FluidRegistry.getFluidStack("ic2steam", (int) aAmount); + } + + public static int rgbtoHexValue(final int r, final int g, final int b) { + if ((r > 255) || (g > 255) || (b > 255) || (r < 0) || (g < 0) || (b < 0)) { + return 0; + } + final Color c = new Color(r, g, b); + String temp = Integer.toHexString(c.getRGB() & 0xFFFFFF) + .toUpperCase(); + temp = Utils.appenedHexNotationToString(temp); + return Integer.decode(temp); + } + + /* + * http://javadevnotes.com/java-left-pad-string-with-zeros-examples + */ + public static String padWithZerosLefts(final String originalString, final int length) { + final StringBuilder sb = new StringBuilder(); + while ((sb.length() + originalString.length()) < length) { + sb.append('0'); + } + sb.append(originalString); + return sb.toString(); + } + + /* + * Original Code by Chandana Napagoda - https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator. + * html + */ + public static Map<Integer, String> hexColourGeneratorRandom(final int colorCount) { + final HashMap<Integer, String> hexColorMap = new HashMap<>(); + for (int a = 0; a < colorCount; a++) { + String code = "" + (int) (Math.random() * 256); + code = code + code + code; + final int i = Integer.parseInt(code); + hexColorMap.put( + a, + Integer.toHexString(0x1000000 | i) + .substring(1) + .toUpperCase()); + Logger.WARNING( + "" + Integer.toHexString(0x1000000 | i) + .substring(1) + .toUpperCase()); + } + return hexColorMap; + } + + public static String appenedHexNotationToString(final Object hexAsStringOrInt) { + final String hexChar = "0x"; + String result; + if (hexAsStringOrInt.getClass() == String.class) { + + if (((String) hexAsStringOrInt).length() != 6) { + final String temp = padWithZerosLefts((String) hexAsStringOrInt, 6); + } + result = hexChar + hexAsStringOrInt; + return result; + } else if (hexAsStringOrInt.getClass() == Integer.class) { + String aa = String.valueOf(hexAsStringOrInt); + if (aa.length() != 6) { + result = padWithZerosLefts(aa, 6); + } else { + result = hexChar + hexAsStringOrInt; + } + return result; + } else { + return null; + } + } + + public static File getMcDir() { + if (Utils.isClient()) { + if (Minecraft.getMinecraft() != null) { + return Minecraft.getMinecraft().mcDataDir; + } + } + return new File("."); + } + + private static short cellID = 15; + + public static ItemStack createInternalNameAndFluidCell(final String s) { + Logger.WARNING("1"); + final InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); + Logger.WARNING("2 " + yourName.name()); + final ItemCell item = (ItemCell) Ic2Items.cell.getItem(); + Logger.WARNING("3 " + item.getUnlocalizedName()); + try { + Logger.WARNING("4"); + final Class<? extends ItemCell> clz = item.getClass(); + Logger.WARNING("5 " + clz.getSimpleName()); + final Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); + Logger.WARNING("6 " + methode.getName()); + methode.setAccessible(true); + Logger.WARNING("7 " + methode.isAccessible()); + final ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); + Logger.WARNING("Successfully created " + temp.getDisplayName() + "s."); + FluidContainerRegistry.registerFluidContainer( + FluidUtils.getFluidStack(s.toLowerCase(), 1000), + temp.copy(), + Ic2Items.cell.copy()); + ItemUtils.addItemToOreDictionary(temp.copy(), "cell" + s); + return temp; + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String sanitizeString(final String input, final char[] dontRemove) { + + // List of characters to remove + final HashSet<Character> toRemoveSet = new HashSet<>(); + Collections.addAll( + toRemoveSet, + ' ', + '-', + '_', + '~', + '?', + '!', + '@', + '#', + '$', + '%', + '^', + '&', + '*', + '(', + ')', + '{', + '}', + '[', + ']'); + + // Remove characters from the toRemoveSet if they are in dontRemove + for (char e : dontRemove) { + toRemoveSet.remove(e); + } + + // Construct a sanitized string + StringBuilder sanitized = new StringBuilder(); + for (char c : input.toCharArray()) { + if (!toRemoveSet.contains(c)) { + sanitized.append(c); + } + } + + return sanitized.toString(); + } + + public static String sanitizeString(final String input) { + String temp; + String output; + + temp = input.replace(" ", ""); + temp = temp.replace("-", ""); + temp = temp.replace("_", ""); + temp = temp.replace("?", ""); + temp = temp.replace("!", ""); + temp = temp.replace("@", ""); + temp = temp.replace("#", ""); + temp = temp.replace("(", ""); + temp = temp.replace(")", ""); + temp = temp.replace("{", ""); + temp = temp.replace("}", ""); + temp = temp.replace("[", ""); + temp = temp.replace("]", ""); + temp = temp.replace(" ", ""); + output = temp; + return output; + } + + public static String sanitizeStringKeepBrackets(final String input) { + String temp; + String output; + + temp = input.replace(" ", ""); + temp = temp.replace("-", ""); + temp = temp.replace("_", ""); + temp = temp.replace("?", ""); + temp = temp.replace("!", ""); + temp = temp.replace("@", ""); + temp = temp.replace("#", ""); + temp = temp.replace(" ", ""); + output = temp; + return output; + } + + public static String addBookTitleLocalization(final String aTitle) { + return GT_LanguageManager + .addStringLocalization("Book." + aTitle + ".Name", aTitle, !GregTech_API.sPostloadFinished); + } + + public static String[] addBookPagesLocalization(final String aTitle, final String[] aPages) { + String[] aLocalizationPages = new String[aPages.length]; + for (byte i = 0; i < aPages.length; i = (byte) (i + 1)) { + aLocalizationPages[i] = GT_LanguageManager.addStringLocalization( + "Book." + aTitle + ".Page" + ((i < 10) ? "0" + i : Byte.valueOf(i)), + aPages[i], + !GregTech_API.sPostloadFinished); + } + return aLocalizationPages; + } + + public static ItemStack getWrittenBook(ItemStack book, int ID, String mapping, String title, String author, + String[] pages) { + + if (GT_Utility.isStringInvalid(mapping)) { + return null; + } + + ItemStack stack = CORE.sBookList.get(mapping); + if (stack != null) { + return GT_Utility.copyAmount(1L, stack); + } + + if (GT_Utility.isStringInvalid(title) || GT_Utility.isStringInvalid(author) || pages.length <= 0) { + return null; + } + + stack = (book == null) ? new ItemStack(ModItems.itemCustomBook, 1, ID) : book; + + NBTTagCompound NBT = new NBTTagCompound(); + String localizationTitle = addBookTitleLocalization(title); + NBT.setString("title", localizationTitle); + NBT.setString("author", author); + + NBTTagList NBTList = new NBTTagList(); + String[] localizationPages = addBookPagesLocalization(title, pages); + + for (byte i = 0; i < pages.length; i++) { + pages[i] = localizationPages[i].replaceAll("<BR>", "\n"); + if (i < 48) { + if (pages[i].length() < 256) { + NBTList.appendTag(new NBTTagString(pages[i])); + } else { + Logger.INFO("WARNING: String for written Book too long! -> " + pages[i]); + GT_Log.err.println("WARNING: String for written Book too long! -> " + pages[i]); + } + } else { + Logger.INFO("WARNING: Too much Pages for written Book! -> " + title); + GT_Log.err.println("WARNING: Too much Pages for written Book! -> " + title); + break; + } + } + + String credits = String.format( + "Credits to %s for writing this Book. This was Book Nr. %d at its creation. Gotta get 'em all!", + author, + ID); + NBTList.appendTag(new NBTTagString(credits)); + NBT.setTag("pages", NBTList); + + stack.setTagCompound(NBT); + + String logMessage = String.format( + "GT++_Mod: Added Book to Book++ List - Mapping: '%s' - Name: '%s' - Author: '%s'", + mapping, + title, + author); + GT_Log.out.println(logMessage); + + NBTUtils.createIntegerTagCompound(stack, "stats", "mMeta", ID); + CORE.sBookList.put(mapping, stack); + + Logger.INFO(String.format("Creating book: %s by %s. Using Meta %d.", title, author, ID)); + + return GT_Utility.copy(stack); + } + +} diff --git a/src/main/java/gtPlusPlus/core/util/data/AES.java b/src/main/java/gtPlusPlus/core/util/data/AES.java new file mode 100644 index 0000000000..85f20a3367 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/data/AES.java @@ -0,0 +1,135 @@ +package gtPlusPlus.core.util.data; + +import java.io.UnsupportedEncodingException; +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; +import java.util.Base64; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + +public class AES { + + private final String secret; + + private final SecretKeySpec secretKey; + + private final byte[] key; + + public AES() { + + this("Darkness In Their Hearts"); + } + + public AES(String aSecret) { + + secret = aSecret; + + key = getBytes(getHashedString(secret)); + + secretKey = generateKey(key); + } + + private static String getHashedString(String aString) { + + return toHexString(getSHA(aString)); + } + + private static byte[] getSHA(String input) { + + MessageDigest md; + + try { + + md = MessageDigest.getInstance("SHA-256"); + + return md.digest(input.getBytes(StandardCharsets.UTF_8)); + + } catch (NoSuchAlgorithmException e) { + + e.printStackTrace(); + } + + return new byte[] {}; + } + + private static String toHexString(byte[] hash) { + + BigInteger number = new BigInteger(1, hash); + + StringBuilder hexString = new StringBuilder(number.toString(16)); + + while (hexString.length() < 32) { + + hexString.insert(0, '0'); + } + + return hexString.toString(); + } + + private byte[] getBytes(String aKey) { + + byte[] aKeyData; + + MessageDigest sha; + + try { + + sha = MessageDigest.getInstance("SHA-256"); + + return sha.digest(aKey.getBytes(StandardCharsets.UTF_8)); + + } catch (NoSuchAlgorithmException e1) { + + e1.printStackTrace(); + + try { + + aKeyData = aKey.getBytes("UTF-8"); + + sha = MessageDigest.getInstance("SHA-1"); + + aKeyData = sha.digest(key); + + aKeyData = Arrays.copyOf(key, 16); + + return aKeyData; + + } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + + e.printStackTrace(); + + } + } + + return new byte[] {}; + } + + private SecretKeySpec generateKey(byte[] aKey) { + + return new SecretKeySpec(aKey, "AES"); + } + + public String decode(String strToDecrypt) { + + try { + + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING"); + + cipher.init(Cipher.DECRYPT_MODE, secretKey); + + return new String( + cipher.doFinal( + Base64.getDecoder() + .decode(strToDecrypt))); + + } catch (Exception ignored) { + + } + + return null; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java b/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java new file mode 100644 index 0000000000..d5ab990917 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java @@ -0,0 +1,44 @@ +package gtPlusPlus.core.util.data; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import net.minecraft.item.ItemStack; + +public class ArrayUtils { + + public static <V> V[] insertElementAtIndex(V[] aArray, int aIndex, V aObjectToInsert) { + V[] newArray = Arrays.copyOf(aArray, aArray.length + 1); + for (int i = 0; i < aIndex; i++) { + newArray[i] = aArray[i]; + } + newArray[aIndex] = aObjectToInsert; + for (int i = (aIndex + 1); i < newArray.length; i++) { + newArray[i] = aArray[i - 1]; + } + return newArray; + } + + public static Object[] removeNulls(final Object[] v) { + List<Object> list = new ArrayList<>(Arrays.asList(v)); + list.removeAll(Collections.singleton((Object) null)); + return list.toArray(new Object[list.size()]); + } + + public static ItemStack[] removeNulls(final ItemStack[] v) { + List<ItemStack> list = new ArrayList<>(Arrays.asList(v)); + list.removeAll(Collections.singleton((ItemStack) null)); + return list.toArray(new ItemStack[list.size()]); + } + + 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/main/java/gtPlusPlus/core/util/data/FileUtils.java b/src/main/java/gtPlusPlus/core/util/data/FileUtils.java new file mode 100644 index 0000000000..b2e5d04375 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/data/FileUtils.java @@ -0,0 +1,112 @@ +package gtPlusPlus.core.util.data; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.ArrayList; +import java.util.List; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.Utils; + +public class FileUtils { + + private static final Charset utf8 = StandardCharsets.UTF_8; + + public static boolean doesFileExist(File f) { + if (f != null && f.exists() && !f.isDirectory()) { + return true; + } + return false; + } + + public static File createFile(String path, String filename, String extension) { + File file = new File(Utils.getMcDir(), path + filename + extension); + return createFile(file); + } + + public static File createFile(File aFile) { + boolean blnCreated = false; + Logger.INFO("Trying to use path " + aFile.getPath()); + try { + Logger.INFO("Trying to use path " + aFile.getCanonicalPath()); + Logger.INFO("Trying to use absolute path " + aFile.getAbsolutePath()); + blnCreated = aFile.createNewFile(); + } catch (IOException ioe) { + Logger.INFO("Error while creating a new empty file :" + ioe); + return null; + } + return blnCreated ? aFile : null; + } + + public static File getFile(String filename, String extension) { + return getFile("", filename, extension); + } + + public static File getFile(String path, String filename, String extension) { + if (path == null || path.length() <= 0) { + path = ""; + } else { + path = path + "/"; + } + if (filename == null || filename.length() <= 0) { + return null; + } + if (extension == null || extension.length() <= 0) { + extension = ".txt"; + } else { + extension = "." + extension; + } + File file = new File(Utils.getMcDir(), path + filename + extension); + boolean doesExist = doesFileExist(file); + + if (doesExist) { + Logger.INFO("Found File: " + file.getAbsolutePath()); + return file; + } else { + Logger.INFO("Creating file, as it was not found."); + return createFile(path, filename, extension); + } + } + + public static void appendListToFile(File file, List<String> content) { + try { + long oldSize; + long newSize; + if (doesFileExist(file)) { + Path p = Paths.get(file.getPath()); + if (p != null && Files.isWritable(p)) { + oldSize = Files.size(p); + try { + Files.write(p, content, utf8, StandardOpenOption.APPEND); + } catch (IOException e) { + e.printStackTrace(); + } + newSize = Files.size(p); + } + } + } catch (IOException ignored) {} + } + + /** + * Reads the contents of a file line by line to a List of Strings using the default encoding for the VM. The file is + * always closed. + * + * @param file the file to read, must not be {@code null} + * @return the list of Strings representing each line in the file, never {@code null} + * @throws IOException in case of an I/O error + * @since 1.3 + */ + public static List<String> readLines(File file) { + try { + return org.apache.commons.io.FileUtils.readLines(file, utf8); + } catch (IOException e) { + return new ArrayList<>(); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/data/LocaleUtils.java b/src/main/java/gtPlusPlus/core/util/data/LocaleUtils.java new file mode 100644 index 0000000000..f72e5c6a51 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/data/LocaleUtils.java @@ -0,0 +1,86 @@ +package gtPlusPlus.core.util.data; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GTPlusPlusEverglades; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.registry.GameData; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class LocaleUtils { + + public static void generateFakeLocaleFile() { + for (ModContainer modcontainer : Loader.instance() + .getModList()) { + if (modcontainer.getModId() + .toLowerCase() + .equals(GTPlusPlus.ID)) { + String S = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; + writeToFile(S); + dumpItemsAndBlocksForModContainer(modcontainer); + } + } + } + + public static void dumpItemsAndBlocksForModContainer(ModContainer mod) { + writeToFile("Dumping Items from " + mod.getModId() + "."); + for (Object C : GameData.getItemRegistry()) { + + try { + + if (C != null) { + if (C instanceof Item R) { + ItemStack IS = ItemUtils.getSimpleStack(R); + String modid = ItemUtils.getModId(IS); + if (modid.equals(GTPlusPlus.ID) || modid.equals(GTPlusPlusEverglades.ID)) { + String S = "[" + modid + "] " + IS.getUnlocalizedName() + ".name="; + writeToFile(S); + } + } + } + + } catch (Throwable ignored) {} + } + writeToFile("Dumping Blocks from " + mod.getModId() + "."); + for (Object B : GameData.getBlockRegistry()) { + + try { + + if (B != null) { + if (B instanceof Block R) { + ItemStack IS = ItemUtils.getSimpleStack(R); + String modid = ItemUtils.getModId(IS); + if (modid.equals(GTPlusPlus.ID) || modid.equals(GTPlusPlusEverglades.ID)) { + String S = "[" + modid + "] " + IS.getUnlocalizedName() + ".name="; + writeToFile(S); + } + } + } + + } catch (Throwable ignored) {} + } + + } + + public static void writeToFile(String S) { + try { + File F = new File(Utils.getMcDir(), "config/GTplusplus/en_US.lang"); + BufferedWriter writer; + writer = new BufferedWriter(new FileWriter(F, true)); + writer.write(S); + writer.newLine(); + writer.close(); + } catch (IOException ignored) {} + } +} diff --git a/src/main/java/gtPlusPlus/core/util/data/StringUtils.java b/src/main/java/gtPlusPlus/core/util/data/StringUtils.java new file mode 100644 index 0000000000..77efadbc9a --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/data/StringUtils.java @@ -0,0 +1,177 @@ +package gtPlusPlus.core.util.data; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.Utils; + +public class StringUtils { + + public static String superscript(String str) { + str = str.replaceAll("0", "\u2070"); + str = str.replaceAll("1", "\u00B9"); + str = str.replaceAll("2", "\u00B2"); + str = str.replaceAll("3", "\u00B3"); + str = str.replaceAll("4", "\u2074"); + str = str.replaceAll("5", "\u2075"); + str = str.replaceAll("6", "\u2076"); + str = str.replaceAll("7", "\u2077"); + str = str.replaceAll("8", "\u2078"); + str = str.replaceAll("9", "\u2079"); + return str; + } + + public static String subscript(String str) { + str = str.replaceAll("0", "\u2080"); + str = str.replaceAll("1", "\u2081"); + str = str.replaceAll("2", "\u2082"); + str = str.replaceAll("3", "\u2083"); + str = str.replaceAll("4", "\u2084"); + str = str.replaceAll("5", "\u2085"); + str = str.replaceAll("6", "\u2086"); + str = str.replaceAll("7", "\u2087"); + str = str.replaceAll("8", "\u2088"); + str = str.replaceAll("9", "\u2089"); + return str; + } + + public static boolean containsSuperOrSubScript(final String s) { + if (s.contains(StringUtils.superscript("0"))) { + return true; + } else if (s.contains(StringUtils.superscript("1"))) { + return true; + } else if (s.contains(StringUtils.superscript("2"))) { + return true; + } else if (s.contains(StringUtils.superscript("3"))) { + return true; + } else if (s.contains(StringUtils.superscript("4"))) { + return true; + } else if (s.contains(StringUtils.superscript("5"))) { + return true; + } else if (s.contains(StringUtils.superscript("6"))) { + return true; + } else if (s.contains(StringUtils.superscript("7"))) { + return true; + } else if (s.contains(StringUtils.superscript("8"))) { + return true; + } else if (s.contains(StringUtils.superscript("9"))) { + return true; + } + if (s.contains(StringUtils.subscript("0"))) { + return true; + } else if (s.contains(StringUtils.subscript("1"))) { + return true; + } else if (s.contains(StringUtils.subscript("2"))) { + return true; + } else if (s.contains(StringUtils.subscript("3"))) { + return true; + } else if (s.contains(StringUtils.subscript("4"))) { + return true; + } else if (s.contains(StringUtils.subscript("5"))) { + return true; + } else if (s.contains(StringUtils.subscript("6"))) { + return true; + } else if (s.contains(StringUtils.subscript("7"))) { + return true; + } else if (s.contains(StringUtils.subscript("8"))) { + return true; + } else if (s.contains(StringUtils.subscript("9"))) { + return true; + } + return false; + } + + public static String firstLetterCaps(String data) { + String firstLetter = data.substring(0, 1) + .toUpperCase(); + String restLetters = data.substring(1) + .toLowerCase(); + return firstLetter + restLetters; + } + + public static <V> String getDataStringFromArray(V[] parameterTypes) { + if (parameterTypes == null || parameterTypes.length == 0) { + return "empty/null"; + } else { + StringBuilder aData = new StringBuilder(); + for (V y : parameterTypes) { + if (y != null) { + aData.append(", ") + .append(y); + } + } + return aData.toString(); + } + } + + /** + * Is this a special regex character for delimination? (.$|()[]{}^?*+\\) + * + * @param aChar - The char to test + * @return - Is this a special character? + */ + public static boolean isSpecialCharacter(char aChar) { + return aChar == '"' || aChar == '.' + || aChar == '$' + || aChar == '|' + || aChar == '(' + || aChar == ')' + || aChar == '[' + || aChar == ']' + || aChar == '{' + || aChar == '}' + || aChar == '^' + || aChar == '?' + || aChar == '*' + || aChar == '+' + || aChar == '\\'; + } + + public static boolean isEscaped(String aString) { + return aString.charAt(0) == '\\'; + } + + public static String splitAndUppercase(String aInput, String aDelim) { + + if (!isEscaped(aDelim)) { + boolean isSpecial = false; + for (int o = 0; o < aInput.length(); o++) { + if (isSpecialCharacter(aInput.charAt(o))) { + isSpecial = true; + } + } + if (isSpecial) { + aDelim = "\\" + aDelim; + } + } + + Logger.INFO("Splitting " + aInput); + String[] aSplit = aInput.split(aDelim); + Logger.INFO("Split into " + aSplit == null ? "" + 0 : aSplit.length + " parts."); + if (aSplit == null || aSplit.length == 0) { + return aInput; + } else { + AutoMap<String> aTemp = new AutoMap<>(); + for (String s : aSplit) { + Logger.INFO("Found: " + s); + s = s.replace(".", ""); + s = Utils.sanitizeString(s); + s = firstLetterCaps(s); + Logger.INFO("Formatted & Captilized: " + s); + aTemp.put(s); + } + Logger.INFO("Rebuilding"); + StringBuilder aReturn = new StringBuilder(); + for (String s : aTemp) { + aReturn.append(s); + Logger.INFO("Step: " + aReturn); + } + return aReturn.toString(); + } + } + + public static long uppercaseCount(String aString) { + return aString.chars() + .filter(Character::isUpperCase) + .count(); + } +} diff --git a/src/main/java/gtPlusPlus/core/util/math/MathUtils.java b/src/main/java/gtPlusPlus/core/util/math/MathUtils.java new file mode 100644 index 0000000000..ac3ef2e947 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/math/MathUtils.java @@ -0,0 +1,528 @@ +package gtPlusPlus.core.util.math; + +import java.text.NumberFormat; +import java.util.Map; +import java.util.Random; + +import gregtech.api.enums.GT_Values; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; + +public class MathUtils { + + static final Random rand = CORE.RANDOM; + + /** Formats a number with group separator and at most 2 fraction digits. */ + private static final NumberFormat sNumberFormat = NumberFormat.getInstance(); + + static { + sNumberFormat.setMaximumFractionDigits(2); + } + + /** + * Returns a psuedo-random number between min and max, inclusive. The difference between min and max can be at most + * Integer.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Integer between min and max, inclusive. + * @see java.util.Random#nextInt(int) + */ + public static int randInt(final int min, final int max) { + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + return rand.nextInt((max - min) + 1) + min; + } + + /** + * Returns a psuedo-random number between min and max, inclusive. The difference between min and max can be at most + * Long.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Long between min and max, inclusive. + * @see java.util.Random#nextLong(long) + */ + public static long randLong(final long min, final long max) { + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + return MathUtils.nextLong(rand, (max - min) + 1) + min; + } + + private static long nextLong(final Random rng, final long n) { + // error checking and 2^x checking removed for simplicity. + long bits, val; + do { + bits = (rng.nextLong() << 1) >>> 1; + val = bits % n; + } while (((bits - val) + (n - 1)) < 0L); + return val; + } + + /** + * Returns a psuedo-random number between min and max, inclusive. The difference between min and max can be at most + * Double.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Double between min and max, inclusive. + * @see java.util.Random#nextDouble(double) + */ + public static double randDouble(final double min, final double max) { + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + return MathUtils.nextDouble(rand, (max - min) + 1) + min; + } + + private static double nextDouble(final Random rng, final double n) { + // error checking and 2^x checking removed for simplicity. + double bits, val; + do { + bits = (rng.nextLong() << 1) >>> 1; + val = bits % n; + } while (((bits - val) + (n - 1)) < 0L); + return val; + } + + /** + * Returns a psuedo-random number between min and max, inclusive. The difference between min and max can be at most + * Float.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Float between min and max, inclusive. + * @see java.util.Random#nextFloat(float) + */ + public static float randFloat(final float min, final float max) { + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + return MathUtils.nextFloat(rand, (max - min) + 1) + min; + } + + private static float nextFloat(final Random rng, final float n) { + // error checking and 2^x checking removed for simplicity. + float bits, val; + do { + bits = (rng.nextLong() << 1) >>> 1; + val = bits % n; + } while (((bits - val) + (n - 1)) < 0L); + return val; + } + + /** + * Returns a percentage. The returned number is the % of X in Y. Supports Doubles. + * + * @param current Current value. + * @param max Maximim value. Must be greater than min. + * @return double between min and max, inclusive. + */ + public static double findPercentage(final double current, final double max) { + return Math.round(((current / max) * 100) * 100.00) / 100.00; + } + + /** + * Returns a percentage. The returned number is the % of X in Y. Supports Floats. + * + * @param current Current value. + * @param max Maximim value. Must be greater than min. + * @return double between min and max, inclusive. + */ + public static float findPercentage(final float current, final float max) { + return (float) (Math.round(((current / max) * 100) * 100.00) / 100.00); + } + + public static int findPercentageOfInt(long input, float percentage) { + return (int) (input * (percentage / 100.0f)); + } + + // Smooth Rounding Function + /** + * Returns a double. The returned number is d rounded to the nearest d.01. Supports Doubles. + * + * @return double Rounded value. + */ + public static double decimalRounding(final double d) { + return Math.round(d * 2) / 2.0; + } + + // Smooth Rounding Function (Nearest 5) + /** + * Returns a double. The returned number is d rounded to the nearest d.5. Supports Doubles. + * + * @return double Rounded value. + */ + public static double decimalRoundingToWholes(final double d) { + return 5 * (Math.round(d / 5)); + } + + // Smooth Rounding Function + /** + * Returns a integer. The returned number is d rounded to the nearest flat integer. Supports Doubles as input. + * + * @return integer Rounded value. + */ + public static int roundToClosestInt(final double d) { + return (int) (Math.round(d * 2) / 2.0); + } + + // Smooth Rounding Function + /** + * Returns a long. The returned number is d rounded to the nearest flat long. Supports Doubles as input. + * + * @return long Rounded value. + */ + public static long roundToClosestLong(final double d) { + return (long) (Math.round(d * 2) / 2.0); + } + + /** + * Returns a boolean. The returned boolean is based on the odd/eveness of the input. Supports ints. + * + * @param x Value A. + * @return boolean Whether or not it divides evenly. + */ + public static boolean isNumberEven(final long x) { + if ((x % 2) == 0) { + return true; + } + return false; + } + + /** + * Returns an int. The returned number is the value on i + 273.15F. Supports ints. + * + * @param i Temp in Celcius. + * @return int The celcius temp returned as Kelvin, rounded to the readest whole. + */ + public static float celsiusToKelvin(final int i) { + final double f = i + 273.15F; + return (int) decimalRoundingToWholes(f); + } + + /** + * Returns a random hex value. The returned value is between 000000-ffffff. + * + * @return hexInteger between min and max, inclusive. + */ + public static int generateSingularRandomHexValue() { + String temp; + final int randomInt = randInt(1, 5); + final Map<Integer, String> colours = Utils.hexColourGeneratorRandom(5); + + if ((colours.get(randomInt) != null) && (colours.size() > 0)) { + temp = colours.get(randomInt); + } else { + temp = "0F0F0F"; + } + + Logger.WARNING("Operating with " + temp); + temp = Utils.appenedHexNotationToString(String.valueOf(temp)); + return Integer.decode(temp); + } + + public static long[] simplifyNumbersToSmallestForm(final long[] inputArray) { + final long GCD = gcd(inputArray); + final long[] outputArray = new long[inputArray.length]; + for (int i = 0; i < inputArray.length; i++) { + if (GCD != 0) { + outputArray[i] = (inputArray[i] / GCD); + } else { + outputArray[i] = inputArray[i]; + } + } + if (outputArray.length > 0) { + return outputArray; + } + return new long[] {}; + } + + private static long gcd(long a, long b) { + while (b > 0) { + final long temp = b; + b = a % b; // % is remainder + a = temp; + } + return a; + } + + private static long gcd(final long[] input) { + long result = input[0]; + for (int i = 1; i < input.length; i++) { + result = gcd(result, input[i]); + } + return result; + } + + public static int getRgbAsHex(final short[] RGBA) { + final int returnValue = Utils.rgbtoHexValue(RGBA[0], RGBA[1], RGBA[2]); + return (returnValue == 0) ? 0 : returnValue; + } + + public static byte safeByte(long number) { + return number > Byte.MAX_VALUE ? Byte.MAX_VALUE : (byte) number; + } + + public static short safeShort(long number) { + return number > Short.MAX_VALUE ? Short.MAX_VALUE : (short) number; + } + + public static int safeInt(long number, int margin) { + return number > Integer.MAX_VALUE - margin ? Integer.MAX_VALUE - margin : (int) number; + } + + public static int safeInt(long number) { + return number > GT_Values.V[GT_Values.V.length - 1] ? safeInt(GT_Values.V[GT_Values.V.length - 1], 1) + : number < Integer.MIN_VALUE ? Integer.MIN_VALUE : (int) number; + } + + public static int getRandomFromArray(int[] mValues) { + int[] mLargeChanceArray = new int[(mValues.length - 1) * 1000]; + int mValueSelection; + for (int g = 0; g < mLargeChanceArray.length; g++) { + mValueSelection = randInt(0, mValues.length - 1); + mLargeChanceArray[g] = mValues[mValueSelection]; + } + return mLargeChanceArray[randInt(0, mLargeChanceArray.length - 1)]; + } + + /* + * Averages + */ + + public static byte getByteAverage(AutoMap<Byte> aDataSet) { + byte[] aNewSet = new byte[aDataSet.size()]; + for (int u = 0; u < aDataSet.size(); u++) { + byte b = getSafeByte(aDataSet.get(u)); + aNewSet[u] = b; + } + return getByteAverage(aNewSet); + } + + public static short getShortAverage(AutoMap<Short> aDataSet) { + short[] aNewSet = new short[aDataSet.size()]; + for (int u = 0; u < aDataSet.size(); u++) { + short b = getSafeShort(aDataSet.get(u)); + aNewSet[u] = b; + } + return getShortAverage(aNewSet); + } + + public static int getIntAverage(AutoMap<Integer> aDataSet) { + int[] aNewSet = new int[aDataSet.size()]; + for (int u = 0; u < aDataSet.size(); u++) { + int b = getSafeInt(aDataSet.get(u)); + aNewSet[u] = b; + } + return getIntAverage(aNewSet); + } + + public static long getLongAverage(AutoMap<Long> aDataSet) { + long[] aNewSet = new long[aDataSet.size()]; + for (int u = 0; u < aDataSet.size(); u++) { + long b = getSafeLong(aDataSet.get(u)); + aNewSet[u] = b; + } + return getLongAverage(aNewSet); + } + + public static byte getByteAverage(byte[] aDataSet) { + if (aDataSet.length == 0) { + return 0; + } + int divisor = aDataSet.length; + byte total = 0; + for (byte i : aDataSet) { + total += i; + } + byte result = safeByte(total / divisor); + return result; + } + + public static short getShortAverage(short[] aDataSet) { + if (aDataSet.length == 0) { + return 0; + } + int divisor = aDataSet.length; + Logger.WARNING("Calculating Average Short. Divisor: " + divisor); + short total = 0; + for (short i : aDataSet) { + Logger.WARNING("Adding " + i); + total += i; + } + short result = safeShort((total / divisor)); + Logger.WARNING("Average: " + result); + return result; + } + + public static int getIntAverage(int[] aDataSet) { + if (aDataSet.length == 0) { + return 0; + } + int divisor = aDataSet.length; + int total = 0; + for (int i : aDataSet) { + total += i; + } + int result = safeInt(total / divisor); + return result; + } + + public static long getLongAverage(long[] aDataSet) { + if (aDataSet.length == 0) { + return 0; + } + int divisor = aDataSet.length; + long total = 0; + for (long i : aDataSet) { + total += i; + } + return (total / divisor); + } + + public static int howManyPlaces(int aValueForGen) { + if (aValueForGen < 0) { + aValueForGen = makeNegative(aValueForGen); + } + String a = String.valueOf(aValueForGen); + return a.length(); + } + + /** + * Inverts the value, making Positives into Negatives and vice versa. + * + * @param aPositive - An int value, either positive or negative. + * @return - Inverted int Value. + */ + public static int makeNegative(int aPositive) { + if (aPositive > 0) { + return -aPositive; + } else if (aPositive < 0) { + return +aPositive; + } else { + return 0; + } + } + + public static <V> V safeCast(Object aNumberType) { + long a1; + double a2; + a1 = Long.parseLong(aNumberType.toString()); + a2 = Double.parseDouble(aNumberType.toString()); + + if ((aNumberType.getClass() == byte.class) || (aNumberType instanceof Byte)) { + if (a1 >= Byte.MIN_VALUE && a1 <= Byte.MAX_VALUE) { + String s = String.valueOf(a1); + Byte s1 = Byte.valueOf(s); + return (V) s1; + } + } else if ((aNumberType.getClass() == short.class) || (aNumberType instanceof Short)) { + if (a1 >= Short.MIN_VALUE && a1 <= Short.MAX_VALUE) { + String s = String.valueOf(a1); + Short s1 = Short.valueOf(s); + return (V) s1; + } + } else if ((aNumberType.getClass() == int.class) || (aNumberType instanceof Integer)) { + if (a1 >= Integer.MIN_VALUE && a1 <= Integer.MAX_VALUE) { + String s = String.valueOf(a1); + Integer s1 = Integer.valueOf(s); + return (V) s1; + } + } else if ((aNumberType.getClass() == long.class) || (aNumberType instanceof Long)) { + if (a1 >= Long.MIN_VALUE && a1 <= Long.MAX_VALUE) { + String s = String.valueOf(a1); + Long s1 = Long.valueOf(s); + return (V) s1; + } + } else if ((aNumberType.getClass() == float.class) || (aNumberType instanceof Float)) { + if (a2 >= Float.MIN_VALUE && a2 <= Float.MAX_VALUE) { + String s = String.valueOf(a1); + Float s1 = Float.valueOf(s); + return (V) s1; + } + } else if ((aNumberType.getClass() == double.class) || (aNumberType instanceof Double)) { + if (a2 >= Double.MIN_VALUE && a2 <= Double.MAX_VALUE) { + String s = String.valueOf(a1); + Double s1 = Double.valueOf(s); + return (V) s1; + } + } + + Integer o = 0; + return (V) o; + } + + public static byte getSafeByte(Byte b) { + Byte a = safeCast(b); + return a; + } + + public static short getSafeShort(Short b) { + Short a = safeCast(b); + return a; + } + + public static int getSafeInt(Integer b) { + Integer a = safeCast(b); + return a; + } + + public static long getSafeLong(Long b) { + Long a = safeCast(b); + return a; + } + + public static int safeCast_LongToInt(long o) { + if (o > Integer.MAX_VALUE) { + return Integer.MAX_VALUE; + } else { + int i = (int) o; + return i; + } + } + + /** + * 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 balance(int aInput, int aMin, int aMax) { + return Math.max(Math.min(aInput, aMax), aMin); + } + + /** + * 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; + } + + public static String formatNumbers(long aNumber) { + return sNumberFormat.format(aNumber); + } + + public static String formatNumbers(double aNumber) { + return sNumberFormat.format(aNumber); + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/EntityUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/EntityUtils.java new file mode 100644 index 0000000000..87bd0e60c6 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/EntityUtils.java @@ -0,0 +1,146 @@ +package gtPlusPlus.core.util.minecraft; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.handler.events.EntityDeathHandler; +import ic2.core.IC2Potion; +import ic2.core.item.armor.ItemArmorHazmat; + +public class EntityUtils { + + public static void setEntityOnFire(final Entity aEntity, final int length) { + if (!isEntityImmuneToFire(aEntity)) { + aEntity.setFire(length); + } + } + + public static boolean isEntityImmuneToFire(Entity aEntity) { + return aEntity.isImmuneToFire(); + } + + public static BlockPos findBlockPosUnderEntity(final Entity parEntity) { + final int blockX = MathHelper.floor_double(parEntity.posX); + final int blockY = MathHelper.floor_double(parEntity.boundingBox.minY) - 1; + final int blockZ = MathHelper.floor_double(parEntity.posZ); + return new BlockPos(blockX, blockY, blockZ, parEntity.worldObj); + } + + public static BlockPos findBlockPosOfEntity(final Entity parEntity) { + final int blockX = MathHelper.floor_double(parEntity.posX); + final int blockY = MathHelper.floor_double(parEntity.boundingBox.minY); + final int blockZ = MathHelper.floor_double(parEntity.posZ); + return new BlockPos(blockX, blockY, blockZ, parEntity.worldObj); + } + + public static void applyRadiationDamageToEntity(final int stackSize, final int radiationLevel, final World world, + final Entity entityHolding) { + if (!world.isRemote) { + if ((radiationLevel > 0) && (entityHolding instanceof final EntityLivingBase entityLiving)) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving) + && !GT_Utility.isWearingFullRadioHazmat(entityLiving)) { + if (entityLiving.getActivePotionEffect(IC2Potion.radiation) != null) { + entityLiving.getActivePotionEffect(IC2Potion.radiation); + } + applyRadioactivity(entityLiving, radiationLevel, stackSize); + } + } + } + } + } + + public static void applyRadioactivity(EntityLivingBase aEntity, int aLevel, int aAmountOfItems) { + if (aLevel > 0 && aEntity != null + && aEntity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD + && aEntity.getCreatureAttribute() != EnumCreatureAttribute.ARTHROPOD + && !ItemArmorHazmat.hasCompleteHazmat(aEntity)) { + PotionEffect tEffect; + aEntity.addPotionEffect( + new PotionEffect( + Potion.moveSlowdown.id, + aLevel * 140 * aAmountOfItems + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.moveSlowdown)) == null ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect( + new PotionEffect( + Potion.digSlowdown.id, + aLevel * 150 * aAmountOfItems + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.digSlowdown)) == null ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect( + new PotionEffect( + Potion.confusion.id, + aLevel * 130 * aAmountOfItems + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.confusion)) == null ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect( + new PotionEffect( + Potion.weakness.id, + aLevel * 150 * aAmountOfItems + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.weakness)) == null ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect( + new PotionEffect( + Potion.hunger.id, + aLevel * 130 * aAmountOfItems + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.hunger)) == null ? 0 : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect( + new PotionEffect( + IC2Potion.radiation.id, + aLevel * 180 * aAmountOfItems + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.potionTypes[24])) == null ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + } + } + + public static void applyHeatDamageToEntity(final int heatLevel, final World world, final Entity entityHolding) { + if (!world.isRemote) { + if ((heatLevel > 0) && (entityHolding instanceof final EntityLivingBase entityLiving)) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + if (!GT_Utility.isWearingFullHeatHazmat(entityLiving)) { + GT_Utility.applyHeatDamage(entityLiving, heatLevel); + } + } + } + } + } + + public static void doDamage(Entity entity, DamageSource dmg, int i) { + entity.attackEntityFrom(dmg, i); + } + + /** + * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. + * + * @param aMobClass - The Base Class you want to drop this item. + * @param aStack - The ItemStack, stack size is not respected. + * @param aMaxAmount - The maximum size of the ItemStack which drops. + * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) + */ + public static void registerDropsForMob(Class<?> aMobClass, ItemStack aStack, int aMaxAmount, int aChance) { + EntityDeathHandler.registerDropsForMob(aMobClass, aStack, aMaxAmount, aChance); + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java new file mode 100644 index 0000000000..2b6e96541d --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java @@ -0,0 +1,667 @@ +package gtPlusPlus.core.util.minecraft; + +import static gregtech.api.recipe.RecipeMaps.fluidCannerRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import java.util.HashMap; + +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; +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.material.Material; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; + +public class FluidUtils { + + private static HashMap<String, Fluid> sFluidCache = new HashMap<>(); + + public static FluidStack getWater(final int amount) { + return FluidUtils.getFluidStack("water", amount); + } + + public static FluidStack getDistilledWater(final int amount) { + return FluidUtils.getFluidStack("ic2distilledwater", amount); + } + + public static FluidStack getHotWater(final int amount) { + return FluidUtils.getFluidStack("ic2hotwater", amount); + } + + public static FluidStack getLava(final int amount) { + return FluidUtils.getFluidStack("lava", amount); + } + + public static FluidStack getPahoehoeLava(final int amount) { + return FluidUtils.getFluidStack("ic2pahoehoelava", amount); + } + + public static FluidStack getSteam(final int amount) { + return FluidUtils.getFluidStack("steam", amount); + } + + public static FluidStack getSuperHeatedSteam(final int amount) { + return FluidUtils.getFluidStack("ic2superheatedsteam", amount); + } + + public static FluidStack getHydrofluoricAcid(int amount) { + return FluidUtils.getFluidStack("hydrofluoricacid", amount); + } + + public static Fluid sGregtechHydrofluoricAcid = null; + + public static FluidStack getHydrofluoricAcidGT(int amount) { + if (sGregtechHydrofluoricAcid == null) { + FluidStack aGTHF = FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 1); + sGregtechHydrofluoricAcid = aGTHF != null ? aGTHF.getFluid() : getHydrofluoricAcid(1).getFluid(); + } + return FluidUtils.getFluidStack(sGregtechHydrofluoricAcid, amount); + } + + public static boolean doesHydrofluoricAcidGtExist() { + if (sGregtechHydrofluoricAcid == null) { + getHydrofluoricAcidGT(1); + } + return sGregtechHydrofluoricAcid != null && sGregtechHydrofluoricAcid != getHydrofluoricAcid(1).getFluid(); + } + + private static FluidStack createFluidStack(Fluid aFluid, int aAmount) { + if (aFluid != null) { + return new FluidStack(aFluid, aAmount); + } + return null; + } + + public static FluidStack getFluidStack(final String aFluidName, final int aAmount) { + Fluid aFluid = sFluidCache.get(aFluidName); + if (aFluid != null) { + return createFluidStack(aFluid, aAmount); + } else { + Fluid aLookupFluid = FluidRegistry.getFluid(aFluidName); + if (aLookupFluid != null) { + sFluidCache.put(aFluidName, aLookupFluid); + return createFluidStack(aLookupFluid, aAmount); + } + } + return null; + } + + public static FluidStack getFluidStack(final FluidStack aFluidStack, final int aAmount) { + if (aFluidStack == null) { + return null; + } + return new FluidStack(aFluidStack, aAmount); + } + + public static FluidStack getFluidStack(final Fluid aFluid, final int aAmount) { + if (aFluid == null) { + return null; + } + return new FluidStack(aFluid, aAmount); + } + + 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) { + return addGtFluid( + aName, + aLocalized, + aMaterial, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + true); + } + + 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 != null ? aMaterial.mRGBa : new short[] { 255, 255, 255, 0 }, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + aGenerateCell); + if (aMaterial != null) { + switch (aState) { + case 1 -> { + aMaterial.mFluid = (g); + } + case 2 -> { + aMaterial.mGas = (g); + } + case 3 -> { + aMaterial.mPlasma = (g); + } + } + } + return g; + } + + public static Fluid addGTFluid(final String aName, final String aLocalized, final short[] aRGBa, final int aState, + final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, + final int aFluidAmount, final boolean aGenerateCell) { + return addGTFluid( + "molten." + aName, + "molten.autogenerated", + aLocalized, + aRGBa, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + aGenerateCell); + } + + public static Fluid addGTFluidNonMolten(final String aName, final String aLocalized, final short[] aRGBa, + final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, + final int aFluidAmount, final boolean aGenerateCell) { + return addGTFluid( + "fluid." + aName, + "fluid.autogenerated", + aLocalized, + aRGBa, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + aGenerateCell); + } + + public static Fluid addGTFluidNoPrefix(final String aName, final String aLocalized, final short[] aRGBa, + final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, + final int aFluidAmount, final boolean aGenerateCell) { + return addGTFluid( + aName, + "fluid.autogenerated", + aLocalized, + aRGBa, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + aGenerateCell); + } + + // Gas + public static Fluid addGtGas(final String aName, final String aLocalized, final short[] aRGBa, final int aState, + final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, + final int aFluidAmount, final boolean aGenerateCell) { + return addGTFluid( + aName, + "fluid.autogenerated", + aLocalized, + aRGBa, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + aGenerateCell); + } + + public static Fluid addGTPlasma(final Material aMaterial) { + if (aMaterial.getLocalizedName() + .toLowerCase() + .contains("clay") + || (aMaterial.getComposites() + .size() > 1) + || aMaterial.getLocalizedName() + .toLowerCase() + .contains("wrought")) { + return null; + } + Logger.INFO("Generating a " + aMaterial.getLocalizedName() + " Plasma Cell"); + if (aMaterial.vComponentCount != 1) { + Logger.INFO("Compound made from: "); + for (final MaterialStack x : aMaterial.getComposites()) { + Logger.INFO( + x.getStackMaterial() + .getLocalizedName()); + } + Logger.INFO("Material is a composite, not generating plasma."); + return null; + } + + ItemStack temp = null; + // Generate a Cell if we need to + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellPlasma" + aMaterial.getUnlocalizedName(), 1) + == null) { + new BaseItemPlasmaCell(aMaterial); + temp = aMaterial.getPlasmaCell(1); + } else { + temp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellPlasma" + aMaterial.getUnlocalizedName(), 1); + } + if (temp != null) { + return addGTFluid( + "plasma." + Utils.sanitizeString( + aMaterial.getLocalizedName() + .toLowerCase()), + "plasma.autogenerated", + aMaterial.getLocalizedName() + " Plasma", + aMaterial.getRGBA(), + 3, + 10000, + temp, + ItemUtils.getEmptyCell(), + 1000, + false); + } + return null; + } + + public static Fluid addGTFluid(String aName, final String aTexture, final String aLocalized, final short[] aRGBa, + final int aState, final long aTemperatureK, ItemStack aFullContainer, final ItemStack aEmptyContainer, + final int aFluidAmount, final boolean aGenerateFilledCell) { + + String aNameOriginal = aName; + Logger.INFO("Generating Fluid for " + aName); + + aName = Utils.sanitizeString(aName.toLowerCase()); + + String aLocalName = (aLocalized == null) ? aName : aLocalized; + + Fluid rFluid; + Fluid gFluid = FluidRegistry.getFluid(aName); + FluidStack aCheck = FluidUtils.getWildcardFluidStack(aName.toLowerCase(), 1000); + boolean register = false; + if (aCheck != null) { + rFluid = aCheck.getFluid(); + } else if (gFluid != null) { + rFluid = gFluid; + } else { + rFluid = new FluidGT6(aName, aTexture, (aRGBa != null) ? aRGBa : Dyes._NULL.getRGBA()); + register = true; + } + + if (register) { + GT_LanguageManager.addStringLocalization(rFluid.getUnlocalizedName(), aLocalName); + if (FluidRegistry.registerFluid(rFluid)) { + switch (aState) { + case 0 -> { + rFluid.setGaseous(false); + rFluid.setViscosity(10000); + } + case 1, 4 -> { + rFluid.setGaseous(false); + rFluid.setViscosity(1000); + } + case 2 -> { + rFluid.setGaseous(true); + rFluid.setDensity(-100); + rFluid.setViscosity(200); + } + case 3 -> { + rFluid.setGaseous(true); + rFluid.setDensity(-10000); + rFluid.setViscosity(10); + rFluid.setLuminosity(15); + } + } + } + } + + String aNameNonMolten = aLocalName.contains("Molten") ? aLocalName.replace("Molten", "") : aLocalName; + + if (aFullContainer == null) { + ItemStack oreStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aLocalName, 1); + aFullContainer = oreStack; + if (aFullContainer == null) { + oreStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aNameOriginal, 1); + aFullContainer = oreStack; + if (aFullContainer == null) { + oreStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aNameNonMolten, 1); + aFullContainer = oreStack; + if (aFullContainer != null) { + Logger.INFO("Found cell for " + aNameNonMolten); + } + } else { + Logger.INFO("Found cell for " + aNameOriginal); + } + } else { + Logger.INFO("Found cell for " + aLocalName); + } + } + + Item tempCell = null; + // Generate a Cell if we need to + if (aGenerateFilledCell && aFullContainer == null) { + String aMatName = aNameOriginal; + if (aMatName.contains("molten.")) { + aMatName = aMatName.replace("molten.", ""); + aMatName = aMatName.substring(0, 1) + .toUpperCase() + aMatName.substring(1); + } + if (aMatName.contains("fluid.")) { + aMatName = aMatName.replace("fluid.", ""); + aMatName = aMatName.substring(0, 1) + .toUpperCase() + aMatName.substring(1); + } + Logger.INFO("Generating cell for " + aMatName + ", " + aLocalName); + tempCell = new BaseItemComponent(aMatName, aLocalName, aRGBa); + aFullContainer = ItemUtils.getSimpleStack(tempCell); + } + + if ((rFluid.getTemperature() == new Fluid("test").getTemperature()) || (rFluid.getTemperature() <= 0)) { + rFluid.setTemperature((int) (aTemperatureK)); + } + if ((aFullContainer != null) && (aEmptyContainer != null) + && !FluidContainerRegistry + .registerFluidContainer(new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) { + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Cell_Empty.get(1L)) + .itemOutputs(aFullContainer) + .fluidInputs(new FluidStack(rFluid, aFluidAmount)) + .duration(4) + .eut(1) + .addTo(fluidCannerRecipes); + } + return rFluid; + } + + public static boolean valid(final Object aStack) { + return (aStack instanceof ItemStack) && (((ItemStack) aStack).getItem() != null) + && (((ItemStack) aStack).stackSize >= 0); + } + + public static boolean invalid(final Object aStack) { + return !(aStack instanceof ItemStack) || (((ItemStack) aStack).getItem() == null) + || (((ItemStack) aStack).stackSize < 0); + } + + public static boolean equal(final ItemStack aStack1, final ItemStack aStack2) { + return equal(aStack1, aStack2, false); + } + + public static boolean equal(final ItemStack aStack1, final ItemStack aStack2, final boolean aIgnoreNBT) { + return (aStack1 != null) && (aStack2 != null) && equal_(aStack1, aStack2, aIgnoreNBT); + } + + public static boolean equal_(final ItemStack aStack1, final ItemStack aStack2, final boolean aIgnoreNBT) { + return (aStack1.getItem() == aStack2.getItem()) + && (aIgnoreNBT || ((aStack1.getTagCompound() == null == (aStack2.getTagCompound() == null)) + && ((aStack1.getTagCompound() == null) || aStack1.getTagCompound() + .equals(aStack2.getTagCompound())))) + && ((meta(aStack1) == meta(aStack2)) || (meta(aStack1) == 32767) || (meta(aStack2) == 32767)); + } + + public static ItemStack copy(final Object... aStacks) { + for (final Object tStack : aStacks) { + if (valid(tStack)) { + return ((ItemStack) tStack).copy(); + } + } + return null; + } + + public static ItemStack copyMeta(final long aMetaData, final Object... aStacks) { + final ItemStack rStack = copy(aStacks); + if (invalid(rStack)) { + return null; + } + return meta(rStack, aMetaData); + } + + public static short meta(final ItemStack aStack) { + return (short) Items.feather.getDamage(aStack); + } + + public static ItemStack meta(final ItemStack aStack, final long aMeta) { + Items.feather.setDamage(aStack, (short) aMeta); + return aStack; + } + + public static ItemStack amount(final long aAmount, final Object... aStacks) { + final ItemStack rStack = copy(aStacks); + if (invalid(rStack)) { + return null; + } + rStack.stackSize = (int) aAmount; + return rStack; + } + + public static ItemStack container(final ItemStack aStack, final boolean aCheckIFluidContainerItems) { + if (invalid(aStack)) { + return null; + } + if (aStack.getItem() + .hasContainerItem(aStack)) { + return aStack.getItem() + .getContainerItem(aStack); + } + if (equal(aStack, ItemUtils.getEmptyCell(), true)) { + return null; + } + if (aCheckIFluidContainerItems && (aStack.getItem() instanceof IFluidContainerItem) + && (((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0)) { + final ItemStack tStack = amount(1L, aStack); + ((IFluidContainerItem) aStack.getItem()).drain(tStack, Integer.MAX_VALUE, true); + if (!equal(aStack, tStack)) { + return tStack; + } + return null; + } + if (equal(aStack, ItemList.IC2_ForgeHammer.get(1)) || equal(aStack, ItemList.IC2_WireCutter.get(1))) { + return copyMeta(meta(aStack) + 1, aStack); + } + return null; + } + + public static ItemStack container(final ItemStack aStack, final boolean aCheckIFluidContainerItems, + final int aStacksize) { + return amount(aStacksize, container(aStack, aCheckIFluidContainerItems)); + } + + public static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, + final int MeltingPoint, final short[] RGBA, final ItemStack dustStack, final ItemStack dustStack2) { + return generateFluidNonMolten( + unlocalizedName, + localizedName, + MeltingPoint, + RGBA, + dustStack, + dustStack2, + 144, + true); + } + + public static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, + final int MeltingPoint, final short[] RGBA, final ItemStack dustStack, final ItemStack dustStack2, + final boolean aGenerateCell) { + return generateFluidNonMolten( + unlocalizedName, + localizedName, + MeltingPoint, + RGBA, + dustStack, + dustStack2, + 144, + aGenerateCell); + } + + public static final Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, + final int MeltingPoint, final short[] RGBA, ItemStack dustStack, final ItemStack dustStack2, + final int amountPerItem, final boolean aGenerateCell) { + if (dustStack == null) { + dustStack = ItemUtils + .getItemStackOfAmountFromOreDictNoBroken("dust" + Utils.sanitizeString(localizedName), 1); + } + FluidStack aFStack = (FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1)); + if (aFStack == null) { + Logger.WARNING("Generating our own fluid."); + + final Fluid gtFluid = FluidUtils.addGTFluidNonMolten( + unlocalizedName, + localizedName, + RGBA, + 4, + MeltingPoint, + null, + ItemUtils.getEmptyCell(), + 1000, + aGenerateCell); + + if (dustStack != null) { + GT_Values.RA.stdBuilder() + .itemInputs(dustStack) + .fluidOutputs(FluidUtils.getFluidStack(gtFluid, amountPerItem)) + .duration(1 * SECONDS) + .eut(16) + .addTo(fluidExtractionRecipes); + } + if (dustStack2 != null) { + GT_Values.RA.stdBuilder() + .itemInputs(dustStack2) + .fluidOutputs(FluidUtils.getFluidStack(gtFluid, amountPerItem)) + .duration(1 * SECONDS) + .eut(16) + .addTo(fluidExtractionRecipes); + } + + return gtFluid; + } else { + Logger.INFO("FLUID GENERATION FAILED FOR " + localizedName + ", ALREADY EXISTS"); + return aFStack.getFluid(); + } + } + + public static Fluid generateFluidNoPrefix(final String unlocalizedName, final String localizedName, + final int MeltingPoint, final short[] RGBA) { + return generateFluidNoPrefix(unlocalizedName, localizedName, MeltingPoint, RGBA, true); + } + + public static Fluid generateFluidNoPrefix(final String unlocalizedName, final String localizedName, + final int MeltingPoint, final short[] RGBA, final boolean aGenerateCell) { + Fluid gtFluid; + if (FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1) == null) { + Logger.WARNING("Generating our own fluid."); + gtFluid = FluidUtils.addGTFluidNoPrefix( + unlocalizedName, + localizedName, + RGBA, + 4, + MeltingPoint, + null, + ItemUtils.getEmptyCell(), + 1000, + aGenerateCell); + } else { + gtFluid = FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1) + .getFluid(); + } + return gtFluid; + } + + public static Fluid generateGas(final String unlocalizedName, final String localizedName, final int MeltingPoint, + final short[] RGBA, final boolean aGenerateCell) { + Fluid gtFluid; + if (FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1) == null) { + Logger.WARNING("Generating our own gas."); + gtFluid = FluidUtils.addGtGas( + unlocalizedName, + localizedName, + RGBA, + 3, + MeltingPoint, + null, + ItemUtils.getEmptyCell(), + 1000, + aGenerateCell); + } else { + gtFluid = FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1) + .getFluid(); + } + return gtFluid; + } + + public static boolean doesFluidExist(String aFluidName) { + 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)); + return aFStack1 != null || aFStack2 != null + || aFStack3 != null + || aFStack4 != null + || aFStack5 != null + || aFStack6 != null; + } + + public static FluidStack getWildcardFluidStack(String aFluidName, int amount) { + FluidStack aFStack1 = (FluidUtils.getFluidStack(aFluidName, amount)); + FluidStack aFStack2 = (FluidUtils.getFluidStack(aFluidName.toLowerCase(), amount)); + FluidStack aFStack3 = (FluidUtils.getFluidStack("molten" + "." + aFluidName.toLowerCase(), amount)); + FluidStack aFStack4 = (FluidUtils.getFluidStack("fluid" + "." + aFluidName.toLowerCase(), amount)); + FluidStack aFStack5 = (FluidUtils.getFluidStack("liquid_" + aFluidName.toLowerCase(), amount)); + FluidStack aFStack6 = (FluidUtils.getFluidStack("liquid" + "." + aFluidName.toLowerCase(), amount)); + if (aFStack1 != null) { + return aFStack1; + } + if (aFStack2 != null) { + return aFStack2; + } + if (aFStack3 != null) { + return aFStack3; + } + if (aFStack4 != null) { + return aFStack4; + } + if (aFStack5 != null) { + return aFStack5; + } + if (aFStack6 != null) { + return aFStack6; + } + 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; + } + } + + public static FluidStack getAir(int aAmount) { + return FluidUtils.getFluidStack("air", aAmount); + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java new file mode 100644 index 0000000000..c8a7ed26da --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java @@ -0,0 +1,68 @@ +package gtPlusPlus.core.util.minecraft; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class InventoryUtils { + + private static final Random mRandom = new Random(); + + public static void dropInventoryItems(World world, int x, int y, int z, Block block) { + TileEntity tileentity = world.getTileEntity(x, y, z); + + if (tileentity != null && tileentity instanceof IInventory aTileInv + && ((IInventory) tileentity).getSizeInventory() > 0) { + + int aMinSlot = 0; + int aMaxSlot = aTileInv.getSizeInventory() - 1; + + for (int i1 = aMinSlot; i1 < aMaxSlot; ++i1) { + ItemStack itemstack = aTileInv.getStackInSlot(i1); + + if (itemstack != null) { + float f = mRandom.nextFloat() * 0.8F + 0.1F; + float f1 = mRandom.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = mRandom.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world + .spawnEntityInWorld(entityitem)) { + int j1 = mRandom.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + entityitem = new EntityItem( + world, + x + f, + y + f1, + z + f2, + new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) mRandom.nextGaussian() * f3; + entityitem.motionY = (float) mRandom.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) mRandom.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) { + entityitem.getEntityItem() + .setTagCompound( + (NBTTagCompound) itemstack.getTagCompound() + .copy()); + } + } + } + } + + world.func_147453_f(x, y, z, block); + } + } + +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java new file mode 100644 index 0000000000..16a71133c6 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -0,0 +1,1012 @@ +package gtPlusPlus.core.util.minecraft; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GregTech; +import static gregtech.api.enums.Mods.IndustrialCraft2; +import static gregtech.api.enums.Mods.Minecraft; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +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.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +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; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.base.dusts.BaseItemDustUnique; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.item.chemistry.GenericChem; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.CORE_Preloader; +import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_DustGeneration; + +public class ItemUtils { + + public static ItemStack getSimpleStack(final Item x) { + return getSimpleStack(x, 1); + } + + 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); + } + + public static ItemStack getSimpleStack(final Block x, int meta, int i) { + return simpleMetaStack(Item.getItemFromBlock(x), meta, i); + } + + public static ItemStack getSimpleStack(final Item x, final int i) { + return new ItemStack(x, i); + } + + public static ItemStack getSimpleStack(final ItemStack x, final int i) { + if (x == null) { + return null; + } + final ItemStack r = x.copy(); + r.stackSize = i; + return r; + } + + public static final int WILDCARD_VALUE = Short.MAX_VALUE; + + public static ItemStack getWildcardStack(final ItemStack x) { + return ItemUtils.simpleMetaStack(x, WILDCARD_VALUE, 1); + } + + public static ItemStack getIC2Cell(final int meta) { + return GT_ModHandler.getModItem(IndustrialCraft2.ID, "itemCellEmpty", 1L, meta); + } + + public static ItemStack getEmptyCell() { + return getEmptyCell(1); + } + + public static ItemStack getEmptyCell(int i) { + if (ItemList.Cell_Empty.hasBeenSet()) { + return ItemList.Cell_Empty.get(i); + } + final ItemStack temp = GT_ModHandler.getModItem(IndustrialCraft2.ID, "itemCellEmpty", i, 0); + return temp != null ? temp : null; + } + + public static void getItemForOreDict(final String FQRN, final String oreDictName, final String itemName, + final int meta) { + try { + Item em = null; + final Item em1 = getItemFromFQRN(FQRN); + + if (em1 != null) { + em = em1; + } + + if (em != null) { + + final ItemStack metaStack = new ItemStack(em, 1, meta); + GT_OreDictUnificator.registerOre(oreDictName, metaStack); + + } + } catch (final NullPointerException e) { + Logger.ERROR(itemName + " not found. [NULL]"); + } + } + + public static void addItemToOreDictionary(ItemStack stack, final String oreDictName, boolean useWildcardMeta) { + if (useWildcardMeta) { + stack = ItemUtils.getWildcardStack(stack); + } + try { + OreDictionary.registerOre(oreDictName, stack); + } catch (final NullPointerException e) { + Logger.ERROR(ItemUtils.getItemName(stack) + " not registered. [NULL]"); + } + } + + public static void addItemToOreDictionary(final ItemStack stack, final String oreDictName) { + addItemToOreDictionary(stack, oreDictName, false); + } + + public static ItemStack getItemStackWithMeta(final boolean MOD, final String FQRN, final String itemName, + final int meta, final int itemstackSize) { + if (MOD) { + try { + Item em = null; + final Item em1 = getItemFromFQRN(FQRN); + + if (em1 != null) { + if (null == em) { + em = em1; + } + if (em != null) { + final ItemStack metaStack = new ItemStack(em, itemstackSize, meta); + return metaStack; + } + } + return null; + } catch (final NullPointerException e) { + Logger.ERROR(itemName + " not found. [NULL]"); + return null; + } + } + return null; + } + + public static ItemStack simpleMetaStack(final String FQRN, final int meta, final int itemstackSize) { + try { + Item em = null; + final Item em1 = getItemFromFQRN(FQRN); + // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null) { + if (null == em) { + em = em1; + } + if (em != null) { + final ItemStack metaStack = new ItemStack(em, itemstackSize, meta); + return metaStack; + } + } + return null; + } catch (final NullPointerException e) { + Logger.ERROR(FQRN + " not found. [NULL]"); + return 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; + } + return new ItemStack(item, size, meta); + } + + public static ItemStack simpleMetaStack(final Block block, final int meta, final int size) { + return simpleMetaStack(Item.getItemFromBlock(block), meta, size); + } + + public static ItemStack getCorrectStacktype(final String fqrn, final int stackSize) { + final String oreDict = "ore:"; + ItemStack temp; + if (fqrn.toLowerCase() + .contains(oreDict.toLowerCase())) { + final String sanitizedName = fqrn.replace(oreDict, ""); + temp = ItemUtils.getItemStackFromFQRN(sanitizedName, stackSize); + return temp; + } + final String[] fqrnSplit = fqrn.split(":"); + String temp1; + String temp2; + temp1 = fqrnSplit[1]; + if (fqrnSplit.length < 3) { + temp2 = "0"; + } else { + temp2 = fqrnSplit[2]; + } + temp = ItemUtils.getItemStackWithMeta(true, fqrn, temp1, Integer.parseInt(temp2), stackSize); + return temp; + } + + public static Item getItemFromFQRN(final String fqrn) // fqrn = fully qualified resource name + { + final String[] fqrnSplit = fqrn.split(":"); + return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); + } + + public static ItemStack getItemStackFromFQRN(final String fqrn, final int Size) // fqrn = fully qualified resource + // name + { + Logger.INFO("Trying to split string '" + fqrn + "'."); + final String[] fqrnSplit = fqrn.split(":"); + if (fqrnSplit.length < 2) { + return null; + } else { + if (fqrnSplit.length == 2) { + Logger.INFO("Mod: " + fqrnSplit[0] + ", Item: " + fqrnSplit[1]); + return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + } else if (fqrnSplit.length == 3 && fqrnSplit[2] != null && fqrnSplit[2].length() > 0) { + Logger.INFO("Mod: " + fqrnSplit[0] + ", Item: " + fqrnSplit[1] + ", Meta: " + fqrnSplit[2]); + ItemStack aStack = GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + int aMeta = Integer.parseInt(fqrnSplit[2]); + if (aStack != null && (aMeta >= 0 && aMeta <= Short.MAX_VALUE)) { + return ItemUtils.simpleMetaStack(aStack, aMeta, Size); + } else { + Logger.INFO("Could not find instance of Item: " + fqrnSplit[1]); + } + } + } + return null; + } + + public static ItemStack[] validItemsForOreDict(final String oredictName) { + final List<?> validNames = MaterialUtils.oreDictValuesForEntry(oredictName); + final ItemStack[] inputs = new ItemStack[validNames.size()]; + for (int i = 0; i < validNames.size(); i++) { + inputs[i] = (ItemStack) validNames.get(i); + } + return inputs; + } + + public static ItemStack getItemStackOfAmountFromOreDict(String oredictName, final int amount) { + String mTemp = oredictName; + + if (oredictName.contains("-") || oredictName.contains("_")) { + mTemp = Utils.sanitizeString(mTemp, new char[] { '-', '_' }); + } else { + mTemp = Utils.sanitizeString(mTemp); + } + + if (oredictName.contains("rod")) { + String s = "stick" + oredictName.substring(3); + oredictName = s; + } + + // Banned Materials and replacements for GT5.8 compat. + + if (oredictName.toLowerCase() + .contains("ingotclay")) { + return getSimpleStack(Items.clay_ball, amount); + } + + final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(mTemp); + if (!oreDictList.isEmpty()) { + final ItemStack returnValue = oreDictList.get(0) + .copy(); + returnValue.stackSize = amount; + return returnValue; + } + Logger.INFO("Failed to find `" + oredictName + "` in OD."); + return getErrorStack(amount, oredictName + " x" + amount); + // return getItemStackOfAmountFromOreDictNoBroken(mTemp, amount); + } + + public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, final int amount) { + if (CORE_Preloader.DEBUG_MODE) { + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(1)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(2)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(3)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(4)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(5)); + } + + try { + + if (oredictName.contains("-") || oredictName.contains("_")) { + oredictName = Utils.sanitizeString(oredictName, new char[] { '-', '_' }); + } else { + oredictName = Utils.sanitizeString(oredictName); + } + + // Adds a check to grab dusts using GT methodology if possible. + ItemStack returnValue = null; + if (oredictName.toLowerCase() + .contains("dust")) { + final String MaterialName = oredictName.toLowerCase() + .replace("dust", ""); + final Materials m = Materials.get(MaterialName); + if (m != null && m != Materials._NULL) { + returnValue = getGregtechDust(m, amount); + if (checkForInvalidItems(returnValue)) { + return returnValue; + } + } + } + if (returnValue == null) { + returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); + if (ItemUtils.checkForInvalidItems(returnValue)) { + return returnValue.copy(); + } + } + + Logger.RECIPE(oredictName + " was not valid."); + return null; + } catch (final Throwable t) { + return null; + } + } + + public static ItemStack getGregtechDust(final Materials material, final int amount) { + final ItemStack returnValue = GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L); + if (returnValue != null) { + if (ItemUtils.checkForInvalidItems(returnValue)) { + return returnValue.copy(); + } + } + Logger.WARNING(material + " was not valid."); + return null; + } + + // NullFormula + public static Item[] generateSpecialUseDusts(final String unlocalizedName, final String materialName, + final int Colour) { + return generateSpecialUseDusts(unlocalizedName, materialName, "NullFormula", Colour); + } + + public static Item[] generateSpecialUseDusts(final String unlocalizedName, final String materialName, + String mChemForm, final int Colour) { + GT_LanguageManager.addStringLocalization("gtplusplus.material." + materialName, materialName); + final Item[] output = { + 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]); + final ItemStack smallDust = ItemUtils.getSimpleStack(output[1]); + final ItemStack tinyDust = ItemUtils.getSimpleStack(output[2]); + + CORE.RA.addpackagerRecipe(ItemList.Schematic_Dust.get(0), smallDust, tinyDust, normalDust); + + if (ItemUtils.checkForInvalidItems(tinyDust) && ItemUtils.checkForInvalidItems(normalDust)) { + if (RecipeUtils.addShapedRecipe( + tinyDust, + tinyDust, + tinyDust, + tinyDust, + tinyDust, + tinyDust, + tinyDust, + tinyDust, + tinyDust, + normalDust)) { + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: " + materialName + " - Success"); + } else { + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: " + materialName + " - Failed"); + } + + if (RecipeUtils.addShapedRecipe( + normalDust, + null, + null, + null, + null, + null, + null, + null, + null, + ItemUtils.getSimpleStack(tinyDust, 9))) { + Logger.WARNING("9 Tiny dust from 1 Recipe: " + materialName + " - Success"); + } else { + Logger.WARNING("9 Tiny dust from 1 Recipe: " + materialName + " - Failed"); + } + } + + if (ItemUtils.checkForInvalidItems(smallDust) && ItemUtils.checkForInvalidItems(normalDust)) { + if (RecipeUtils.addShapedRecipe( + smallDust, + smallDust, + null, + smallDust, + smallDust, + null, + null, + null, + null, + normalDust)) { + Logger.WARNING("4 Small dust to 1 Dust Recipe: " + materialName + " - Success"); + } else { + Logger.WARNING("4 Small dust to 1 Dust Recipe: " + materialName + " - Failed"); + } + if (RecipeUtils.addShapedRecipe( + null, + normalDust, + null, + null, + null, + null, + null, + null, + null, + ItemUtils.getSimpleStack(smallDust, 4))) { + Logger.WARNING("4 Small dust from 1 Dust Recipe: " + materialName + " - Success"); + } else { + Logger.WARNING("4 Small dust from 1 Dust Recipe: " + materialName + " - Failed"); + } + } + + return output; + } + + 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.getUnlocalizedName(); + final String unlocalizedName = Utils.sanitizeString(materialName); + final int Colour = material.getRgbAsHex(); + final String aChemForm = material.vChemicalFormula; + final boolean isChemFormvalid = (aChemForm != null && aChemForm.length() > 0); + Item[] output = null; + if (onlyLargeDust == false) { + output = new Item[] { + new BaseItemDustUnique( + "itemDust" + unlocalizedName, + materialName, + isChemFormvalid ? aChemForm : "", + Colour, + "Dust"), + new BaseItemDustUnique( + "itemDustSmall" + unlocalizedName, + materialName, + isChemFormvalid ? aChemForm : "", + Colour, + "Small"), + new BaseItemDustUnique( + "itemDustTiny" + unlocalizedName, + materialName, + isChemFormvalid ? aChemForm : "", + Colour, + "Tiny") }; + } else { + output = new Item[] { new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, Colour, "Dust") }; + } + + new RecipeGen_DustGeneration(material, disableExtraRecipes); + + return output; + } + + public static boolean isRadioactive(final String materialName) { + int sRadiation = 0; + if (materialName.toLowerCase() + .contains("uranium")) { + sRadiation = 2; + } else if (materialName.toLowerCase() + .contains("plutonium")) { + sRadiation = 4; + } else if (materialName.toLowerCase() + .contains("thorium")) { + sRadiation = 1; + } + if (sRadiation >= 1) { + return true; + } + return false; + } + + public static int getRadioactivityLevel(final String materialName) { + int sRadiation = 0; + if (materialName.toLowerCase() + .contains("uranium")) { + sRadiation = 2; + } else if (materialName.toLowerCase() + .contains("plutonium")) { + sRadiation = 4; + } else if (materialName.toLowerCase() + .contains("thorium")) { + sRadiation = 1; + } + return sRadiation; + } + + public static String getArrayStackNames(final FluidStack[] aStack) { + String itemNames = "Fluid Array: "; + for (final FluidStack alph : aStack) { + if (alph != null) { + final String temp = itemNames; + itemNames = temp + ", " + alph.getLocalizedName() + " x" + alph.amount; + } else { + final String temp = itemNames; + itemNames = temp + ", " + "null" + " x" + "0"; + } + } + return itemNames; + } + + public static String getArrayStackNames(final ItemStack[] aStack) { + String itemNames = ""; + int aPos = 0; + for (final ItemStack alph : aStack) { + if (alph == null) { + continue; + } + if (alph != null) { + final String temp = itemNames; + itemNames = temp + (aPos > 0 ? ", " : "") + alph.getDisplayName() + " x" + alph.stackSize; + aPos++; + } + } + return itemNames; + } + + public static ItemStack getGregtechCircuit(final int Meta) { + return ItemUtils.getItemStackWithMeta(true, "gregtech:gt.integrated_circuit", "Gregtech Circuit", Meta, 0); + } + + private static final Map<Item, String> mModidCache = new HashMap<>(); + + private static String getModId(final Item item) { + if (mModidCache.containsKey(item)) { + return mModidCache.get(item); + } + String value = ""; + try { + final GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item); + if (id != null) { + final String modname = (id.modId == null ? id.name : id.modId); + value = ((id == null) || id.modId.equals("")) ? Minecraft.ID : modname; + } + } catch (final Throwable t) { + try { + final UniqueIdentifier t2 = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)); + if (t2 != null) { + final String modname = (t2.modId == null ? t2.name : t2.modId); + value = ((t2 == null) || t2.modId.equals("")) ? Minecraft.ID : modname; + } + } catch (final Throwable t3) { + t3.printStackTrace(); + value = "bad modid"; + } + } + if (!mModidCache.containsKey(item)) { + return mModidCache.put(item, value); + } + return value; + } + + public static String getModId(final ItemStack key) { + return getModId(key.getItem()); + } + + // Take 2 - GT/GT++ Dusts + public static ItemStack getGregtechDust(final String oredictName, final int amount) { + final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); + if (!oreDictList.isEmpty()) { + ItemStack returnvalue; + for (ItemStack itemStack : oreDictList) { + final String modid = getModId(itemStack.getItem()); + if (modid != null && (modid.equals(GregTech.ID) || modid.equals(GTPlusPlus.ID))) { + returnvalue = itemStack.copy(); + returnvalue.stackSize = amount; + return returnvalue; + } + } + } + return getNonTinkersDust(oredictName, amount); + } + + // Anything But Tinkers Dust + public static ItemStack getNonTinkersDust(final String oredictName, final int amount) { + final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); + if (!oreDictList.isEmpty()) { + ItemStack returnvalue; + for (ItemStack itemStack : oreDictList) { + final String modid = getModId(itemStack.getItem()); + if (modid != null && !modid.equals("tconstruct")) { + returnvalue = itemStack.copy(); + returnvalue.stackSize = amount; + return returnvalue; + } + } + } + // If only Tinkers dust exists, bow down and just use it. + return getItemStackOfAmountFromOreDictNoBroken(oredictName, amount); + } + + public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Material mMat, int mAmount) { + + String mName = Utils.sanitizeString(mMat.getLocalizedName()); + + String mItemName = mPrefix.name() + mName; + ItemStack gregstack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(mItemName, mAmount); + if (gregstack == null) { + return null; + } + return (gregstack); + } + + public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Materials mMat, int mAmount) { + if (mPrefix == OrePrefixes.rod) { + mPrefix = OrePrefixes.stick; + } + ItemStack aGtStack = GT_OreDictUnificator.get(mPrefix, mMat, mAmount); + if (aGtStack == null) { + Logger + .INFO("Failed to find `" + mPrefix + MaterialUtils.getMaterialName(mMat) + "` in OD. [Prefix Search]"); + return getErrorStack(mAmount, (mPrefix.toString() + MaterialUtils.getMaterialName(mMat) + " x" + mAmount)); + } else { + return aGtStack; + } + } + + public static ItemStack getErrorStack(int mAmount) { + return getErrorStack(mAmount, null); + } + + public static ItemStack getErrorStack(int mAmount, String aName) { + ItemStack g = getSimpleStack(ModItems.AAA_Broken, 1); + if (aName != null) { + NBTUtils.setBookTitle(g, EnumChatFormatting.RED + aName); + } + return g; + } + + public static ItemStack[] getStackOfAllOreDictGroup(String oredictname) { + final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictname); + if (!oreDictList.isEmpty()) { + final ItemStack[] returnValues = new ItemStack[oreDictList.size()]; + for (int i = 0; i < oreDictList.size(); i++) { + if (oreDictList.get(i) != null) { + returnValues[i] = oreDictList.get(i); + } + } + return returnValues.length > 0 ? returnValues : null; + } else { + return null; + } + } + + public static boolean registerFuel(ItemStack aBurnable, int burn) { + return CORE.burnables.add(new Pair<>(burn, aBurnable)); + } + + public static boolean checkForInvalidItems(ItemStack mInput) { + return checkForInvalidItems(new ItemStack[] { mInput }); + } + + public static boolean checkForInvalidItems(ItemStack[] mInput) { + return checkForInvalidItems(mInput, new ItemStack[] {}); + } + + /** + * + * @param mInputs + * @return {@link Boolean} - True if {@link ItemStack}[] only contains valid items. + */ + public static boolean checkForInvalidItems(ItemStack[] mInputs, ItemStack[] mOutputs) { + if (mInputs == null || mOutputs == null) { + return false; + } + + if (mInputs.length > 0) { + for (ItemStack stack : mInputs) { + if (stack != null) { + if (stack.getItem() != null) { + if (stack.getItem() == ModItems.AAA_Broken || stack.getItem() + .getClass() == ModItems.AAA_Broken.getClass()) { + return false; + } else if (stack.getItem() == ModItems.ZZZ_Empty || stack.getItem() + .getClass() == ModItems.ZZZ_Empty.getClass()) { + return false; + } else { + continue; + } + } else { + continue; + } + } else { + return false; + } + } + } + if (mOutputs.length > 0) { + for (ItemStack stack : mOutputs) { + if (stack != null) { + if (stack.getItem() != null) { + if (stack.getItem() == ModItems.AAA_Broken || stack.getItem() + .getClass() == ModItems.AAA_Broken.getClass()) { + return false; + } else if (stack.getItem() == ModItems.ZZZ_Empty || stack.getItem() + .getClass() == ModItems.ZZZ_Empty.getClass()) { + return false; + } else { + continue; + } + } else { + continue; + } + } else { + return false; + } + } + } + + 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) { + if (p[j] != null && (p[i] == null || GT_Utility.areStacksEqual(p[i], p[j]))) { + GT_Utility.moveStackFromSlotAToSlotB(aTemp, aTemp, j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + } + + return aTemp; + } + + public static String getFluidName(FluidStack aFluid) { + return aFluid != null ? aFluid.getFluid() + .getLocalizedName(aFluid) : "NULL"; + } + + public static String getItemName(ItemStack aStack) { + if (aStack == null) { + return "ERROR - Empty Stack"; + } + String aDisplay = null; + try { + aDisplay = ("" + StatCollector.translateToLocal( + aStack.getItem() + .getUnlocalizedNameInefficiently(aStack) + ".name")).trim(); + if (aStack.hasTagCompound()) { + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.hasKey("Name", 8)) { + aDisplay = nbttagcompound.getString("Name"); + } + } + } + } catch (Throwable ignored) { + + } + if (aDisplay == null || aDisplay.length() <= 0) { + aDisplay = aStack.getUnlocalizedName() + ":" + aStack.getItemDamage(); + } else { + aDisplay += " | Meta: " + aStack.getItemDamage(); + } + return aDisplay; + } + + public static String getUnlocalizedItemName(ItemStack aStack) { + if (aStack == null) { + return "ERROR.Empty.Stack"; + } + String aDisplay = null; + try { + aDisplay = (aStack.getUnlocalizedName()).trim(); + } catch (Throwable t) { + aDisplay = aStack.getItem() + .getUnlocalizedName(); + } + if (aDisplay == null || aDisplay.length() <= 0) { + aDisplay = aStack.getItem() + .getUnlocalizedNameInefficiently(aStack); + } + return aDisplay; + } + + public static boolean isItemGregtechTool(ItemStack aStack) { + if (aStack == null) { + return false; + } + final Item mItem = aStack.getItem(); + final Item aSkookum = ItemUtils.getItemFromFQRN("miscutils:gt.plusplus.metatool.01"); + final Class aSkookClass = aSkookum.getClass(); + if (aSkookClass.isInstance(mItem) || mItem instanceof GT_MetaGenerated_Tool_01 + || mItem instanceof MetaGeneratedGregtechTools + || mItem instanceof Gregtech_MetaTool + || mItem == aSkookum) { + 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 ItemStack[] cleanItemStackArray(ItemStack[] input) { + int aArraySize = input.length; + ItemStack[] aOutput = new ItemStack[aArraySize]; + AutoMap<ItemStack> aCleanedItems = new AutoMap<>(); + for (ItemStack checkStack : input) { + if (ItemUtils.checkForInvalidItems(checkStack)) { + aCleanedItems.put(checkStack); + } + } + for (int i = 0; i < aArraySize; i++) { + ItemStack aMappedStack = aCleanedItems.get(i); + if (aMappedStack != null) { + aOutput[i] = aMappedStack; + } + } + return aOutput; + } + + public static boolean doesOreDictHaveEntryFor(String 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) { + ItemStack aDepStack = aStack.copy(); + aDepStack.stackSize = (MathUtils.balance((aDepStack.stackSize - 1), 0, 64)); + if (aDepStack.stackSize > 0) { + return aDepStack; + } + } + return getNullStack(); + } + + public static boolean isControlCircuit(ItemStack aStack) { + if (aStack != null) { + Item aItem = aStack.getItem(); + if (aItem == CI.getNumberedBioCircuit(0) + .getItem() || aItem + == CI.getNumberedCircuit(0) + .getItem() + || aItem == CI.getNumberedAdvancedCircuit(0) + .getItem()) { + return true; + } + } + return false; + } + + public static boolean isCatalyst(ItemStack aStack) { + if (GT_Utility.areStacksEqual(aStack, GenericChem.mBlueCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mBrownCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mOrangeCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mPurpleCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mRedCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mYellowCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mPinkCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mFormaldehydeCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mSolidAcidCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mInfiniteMutationCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, AgriculturalChem.mGreenCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mPlatinumGroupCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mPlasticPolymerCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mRubberPolymerCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mAdhesionPromoterCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mTitaTungstenIndiumCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mRadioactivityCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mRareEarthGroupCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mSimpleNaquadahCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mAdvancedNaquadahCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mRawIntelligenceCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mUltimatePlasticCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mBiologicalIntelligenceCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.TemporalHarmonyCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mLimpidWaterCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mFlawlessWaterCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mParticleAccelerationCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mSynchrotronCapableCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mAlgagenicGrowthPromoterCatalyst, true)) { + return true; + } + + return false; + } + + public static boolean isMillingBall(ItemStack aStack) { + if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallAlumina, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallSoapstone, true)) { + return true; + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/LangUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/LangUtils.java new file mode 100644 index 0000000000..28d017d749 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/LangUtils.java @@ -0,0 +1,41 @@ +package gtPlusPlus.core.util.minecraft; + +import java.lang.reflect.Field; +import java.util.Map; +import java.util.Properties; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class LangUtils { + + @SuppressWarnings("unchecked") + public static void 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; + 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 ignored) { + + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java new file mode 100644 index 0000000000..881ccb3c41 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -0,0 +1,372 @@ +package gtPlusPlus.core.util.minecraft; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import gregtech.api.enums.Element; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.TypeCounter; +import gtPlusPlus.core.client.CustomTextureSet.TextureSets; +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.item.base.BaseItemComponent.ComponentTypes; +import gtPlusPlus.core.item.base.foil.BaseItemFoil; +import gtPlusPlus.core.item.base.wire.BaseItemFineWire; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.core.util.math.MathUtils; + +public class MaterialUtils { + + public static List<?> oreDictValuesForEntry(final String oredictName) { + List<?> oredictItemNames; + if (OreDictionary.doesOreNameExist(oredictName)) { + oredictItemNames = OreDictionary.getOres(oredictName); + return oredictItemNames; + } + return null; + } + + private static final Map<String, Material> mGeneratedMaterialMap = new HashMap<>(); + + public static Material generateMaterialFromGtENUM(final Materials material) { + return generateMaterialFromGtENUM(material, null, null); + } + + public static Material generateMaterialFromGtENUM(final Materials material, TextureSet aCustomTextures) { + return generateMaterialFromGtENUM(material, null, aCustomTextures); + } + + public static Material generateMaterialFromGtENUM(final Materials material, short[] customRGB) { + return generateMaterialFromGtENUM(material, customRGB, null); + } + + public static Material generateMaterialFromGtENUM(final Materials material, short[] customRGB, + TextureSet aCustomTextures) { + String aMaterialKey = getMaterialName(material).toLowerCase(); + if (mGeneratedMaterialMap.containsKey(aMaterialKey)) { + return mGeneratedMaterialMap.get(aMaterialKey); + } + + try { + String name = material.mName; + final short[] rgba = (customRGB == null ? material.mRGBa : customRGB); + final int melting = material.mMeltingPoint; + final int boiling = material.mBlastFurnaceTemp; + final long protons = material.getProtons(); + final long neutrons = material.getNeutrons(); + final boolean blastFurnace = material.mBlastFurnaceRequired; + int radioactivity = 0; + if (material.isRadioactive()) { + ItemStack aDustStack = ItemUtils.getOrePrefixStack(OrePrefixes.dust, material, 1); + radioactivity = aDustStack != null ? GT_Utility.getRadioactivityLevel(aDustStack) : 0; + if (radioactivity == 0) { + long aProtons = material.getProtons(); + radioactivity = (int) Math.min(Math.max((aProtons / 30), 1), 9); + } + } + Logger.MATERIALS("[Debug] Calculated Radiation level to be " + radioactivity + "."); + TextureSet iconSet = null; + if (aCustomTextures == null) { + if (material.isRadioactive()) { + iconSet = TextureSets.NUCLEAR.get(); + } else { + iconSet = material.mIconSet; + } + } else { + iconSet = aCustomTextures; + } + if (iconSet == null || iconSet.mSetName.toLowerCase() + .contains("fluid")) { + iconSet = TextureSet.SET_METALLIC; + } + Logger.MATERIALS("[Debug] Calculated Texture Set to be " + iconSet.mSetName + "."); + + final int durability = material.mDurability; + boolean mGenerateCell = false; + boolean mGenerateFluid = true; + MaterialState materialState; + String chemicalFormula = StringUtils.subscript(Utils.sanitizeString(material.mChemicalFormula)); + final Element element = material.mElement; + + // Weird Blacklist of Bad Chemical Strings + if (material.mElement == Element.Pb || material.mElement == Element.Na || material.mElement == Element.Ar) { + chemicalFormula = StringUtils.subscript(Utils.sanitizeString(material.mElement.name())); + } + + // Determine default state + Logger.MATERIALS("[Debug] Setting State of GT generated material. " + material.mDefaultLocalName); + if (material.getMolten(1) != null || material.getSolid(1) != null) { + materialState = MaterialState.SOLID; + Logger.MATERIALS("[Debug] Molten or Solid was not null."); + if (material.getMolten(1) == null && material.getSolid(1) != null) { + Logger.MATERIALS("[Debug] Molten is Null, Solid is not. Enabling cell generation."); + mGenerateCell = true; + } else if (material.getMolten(1) != null && material.getSolid(1) == null) { + Logger.MATERIALS("[Debug] Molten is not Null, Solid is null. Not enabling cell generation."); + // mGenerateCell = true; + } + Logger.MATERIALS("[Debug] State set as solid."); + } else if (material.getFluid(1) != null) { + Logger.MATERIALS("[Debug] State set as liquid."); + materialState = MaterialState.LIQUID; + } else if (material.getGas(1) != null) { + Logger.MATERIALS("[Debug] State set as gas."); + materialState = MaterialState.GAS; + } else { + Logger.MATERIALS( + "[Debug] State set as solid. This material has no alternative states, so for safety we wont generate anything."); + materialState = MaterialState.SOLID; + mGenerateFluid = false; + } + + if (name.toLowerCase() + .contains("infused")) { + final String tempname = name.substring(7); + name = "Infused " + tempname; + } + if (hasValidRGBA(rgba) || (element == Element.H) + || ((material == Materials.InfusedAir) || (material == Materials.InfusedFire) + || (material == Materials.InfusedEarth) + || (material == Materials.InfusedWater))) { + Material M = new Material( + name, + materialState, + iconSet, + durability, + rgba, + melting, + boiling, + protons, + neutrons, + blastFurnace, + chemicalFormula, + radioactivity, + mGenerateCell, + mGenerateFluid); + mGeneratedMaterialMap.put(aMaterialKey, M); + return M; + } else { + Logger.DEBUG_MATERIALS( + "Failed to generate GT++ material instance for " + material.mName + + " | Valid RGB? " + + (hasValidRGBA(rgba))); + } + } catch (Throwable t) { + Logger.DEBUG_MATERIALS("Failed to generate GT++ material instance for " + material.mName); + t.printStackTrace(); + } + return null; + } + + public static Material generateQuickMaterial(final String materialName, final MaterialState defaultState, + final short[] colour, final int sRadioactivity) { + String aMaterialKey = materialName.toLowerCase(); + if (mGeneratedMaterialMap.containsKey(aMaterialKey)) { + return mGeneratedMaterialMap.get(aMaterialKey); + } + + final Material temp = new Material( + materialName, + defaultState, + colour, + 1000, // melting + 3000, // boiling + 50, // Protons + 50, // Neutrons + false, + "", + sRadioactivity); + mGeneratedMaterialMap.put(aMaterialKey, temp); + return temp; + } + + public static boolean hasValidRGBA(final short[] rgba) { + if (rgba == null || rgba.length < 3 || rgba.length > 4) { + return false; + } + return true; + } + + public static int getTierOfMaterial(final double aMeltingPoint) { + return aMeltingPoint < 1000 ? 0 : (MathUtils.roundToClosestInt(aMeltingPoint / 1000f)); + } + + public static int getVoltageForTier(int aTier) { + // aTier += 1; - Probably some logic to this, idk. + + return switch (aTier) { + case 0 -> 16; + case 1 -> 30; + case 2 -> 120; + case 3 -> 480; + case 4 -> 1920; + case 5 -> 7680; + case 6 -> 30720; + case 7 -> 122880; + case 8 -> 491520; + case 9 -> 1966080; + case 10 -> 7864320; + case 11 -> 31457280; + case 12 -> 125829120; + case 13 -> 503316480; + case 14 -> 2013265920; + default -> Integer.MAX_VALUE; + }; + + } + + private static Materials getMaterialByName(String materialName) { + for (Materials m : Materials.values()) { + if (MaterialUtils.getMaterialName(m) + .toLowerCase() + .equals(materialName.toLowerCase())) { + return m; + } + } + return null; + } + + public static String getMaterialName(Materials mat) { + String mName = mat.mDefaultLocalName; + if (mName == null || mName.equals("")) { + mName = mat.mName; + } + return mName; + } + + public static TextureSet getMostCommonTextureSet(List<Material> list) { + TypeCounter<TextureSet> aCounter = new TypeCounter<>(TextureSet.class); + for (Material m : list) { + TextureSet t = m.getTextureSet(); + if (t == null) { + t = Materials.Gold.mIconSet; + } + if (t != null) { + aCounter.add(t, t.mSetName); + } + } + return aCounter.getResults(); + } + + public static Materials getMaterial(String aMaterialName, String aFallbackMaterialName) { + Materials g = getMaterial(aMaterialName); + if (g == null) { + g = getMaterial(aFallbackMaterialName); + } + if (g == null) { + Logger.INFO( + "Failed finding material '" + aMaterialName + + "' & fallback '" + + aFallbackMaterialName + + "', returning _NULL."); + CORE.crash(); + } + return g; + } + + public static Materials getMaterial(String aMaterialName) { + Materials m = Materials.get(aMaterialName); + if (m == Materials._NULL) { + m = getMaterialByName(aMaterialName); + } + if (m == null) { + Logger.INFO("Failed finding material '" + aMaterialName + "', returning _NULL."); + m = Materials._NULL; + } + return m; + } + + public static AutoMap<Material> getCompoundMaterialsRecursively(Material aMat) { + return getCompoundMaterialsRecursively_Speiger(aMat); + } + + public static AutoMap<Material> getCompoundMaterialsRecursively_Speiger(Material toSearch) { + AutoMap<Material> resultList = new AutoMap<>(); + if (toSearch.getComposites() + .isEmpty()) { + resultList.put(toSearch); + return resultList; + } + final int HARD_LIMIT = 1000; + + // Could be a Deque but i dont use the interface + // enough to use it as default. + LinkedList<Material> toCheck = new LinkedList<>(); + + toCheck.add(toSearch); + int processed = 0; + while (!toCheck.isEmpty() && processed < HARD_LIMIT) { + Material current = toCheck.remove(); + if (current.getComposites() + .isEmpty()) { + resultList.put(current); + } else { + for (MaterialStack entry : current.getComposites()) { + toCheck.add(entry.getStackMaterial()); + } + } + processed++; + } + return resultList; + } + + public static void generateComponentAndAssignToAMaterial(ComponentTypes aType, Material aMaterial) { + generateComponentAndAssignToAMaterial(aType, aMaterial, true); + } + + public static void generateComponentAndAssignToAMaterial(ComponentTypes aType, Material aMaterial, + boolean generateRecipes) { + Item aGC; + if (aType == ComponentTypes.FINEWIRE) { + aGC = new BaseItemFineWire(aMaterial); + } else if (aType == ComponentTypes.FOIL) { + aGC = new BaseItemFoil(aMaterial); + } else { + aGC = new BaseItemComponent(aMaterial, aType); + } + String aFormattedLangName = aType.getName(); + + if (!aFormattedLangName.startsWith(" ")) { + if (aFormattedLangName.contains("@")) { + String[] aSplit = aFormattedLangName.split("@"); + aFormattedLangName = aSplit[0] + " " + aMaterial.getLocalizedName() + " " + aSplit[1]; + } + } + + if (aFormattedLangName.equals(aType.getName())) { + aFormattedLangName = aMaterial.getLocalizedName() + aFormattedLangName; + } + + Logger.MATERIALS("[Lang] " + aGC.getUnlocalizedName() + ".name=" + aFormattedLangName); + aMaterial.registerComponentForMaterial(aType, ItemUtils.getSimpleStack(aGC)); + } + + public static void generateSpecialDustAndAssignToAMaterial(Material aMaterial, boolean generateMixerRecipes) { + Item[] aDusts = ItemUtils.generateSpecialUseDusts(aMaterial, false, !generateMixerRecipes); + if (aDusts.length > 0) { + aMaterial.registerComponentForMaterial(OrePrefixes.dust, ItemUtils.getSimpleStack(aDusts[0])); + aMaterial.registerComponentForMaterial(OrePrefixes.dustSmall, ItemUtils.getSimpleStack(aDusts[1])); + aMaterial.registerComponentForMaterial(OrePrefixes.dustTiny, ItemUtils.getSimpleStack(aDusts[2])); + } + } + + public static boolean isNullGregtechMaterial(Materials aGregtechMaterial) { + return aGregtechMaterial == Materials._NULL || aGregtechMaterial.equals(Materials._NULL) + || aGregtechMaterial.mName.equals(Materials._NULL.mName); + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java new file mode 100644 index 0000000000..3abc92b69e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java @@ -0,0 +1,133 @@ +package gtPlusPlus.core.util.minecraft; + +import java.util.HashMap; + +import gregtech.common.GT_Worldgen_GT_Ore_Layer; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class MiningUtils { + + public static int mMoonID = -99; + public static int mMarsID = -99; + public static int mCometsID = -99; + + public static void iterateAllOreTypes() { + HashMap<String, Integer> M = new HashMap<>(); + String aTextWorldGen; + if (MiningUtils.findAndMapOreTypesFromGT()) { + int mapKey = 0; + for (AutoMap<GT_Worldgen_GT_Ore_Layer> g : MiningUtils.mOreMaps) { + for (GT_Worldgen_GT_Ore_Layer h : g) { + + try { + aTextWorldGen = (String) ReflectionUtils + .getField(GT_Worldgen_GT_Ore_Layer.class, "aTextWorldgen") + .get(h); + } catch (IllegalArgumentException | IllegalAccessException e) { + aTextWorldGen = h.mWorldGenName; + } + + M.put(aTextWorldGen + h.mWorldGenName, mapKey); + Logger.INFO("Found Vein type: " + aTextWorldGen + h.mWorldGenName + " in map with key: " + mapKey); + } + mapKey++; + } + } + } + + public static AutoMap<GT_Worldgen_GT_Ore_Layer>[] mOreMaps = new AutoMap[7]; + private static final AutoMap<GT_Worldgen_GT_Ore_Layer> Ores_Overworld = new AutoMap<>(); + private static final AutoMap<GT_Worldgen_GT_Ore_Layer> Ores_Nether = new AutoMap<>(); + private static final AutoMap<GT_Worldgen_GT_Ore_Layer> Ores_End = new AutoMap<>(); + private static final AutoMap<GT_Worldgen_GT_Ore_Layer> Ores_Moon = new AutoMap<>(); + private static final AutoMap<GT_Worldgen_GT_Ore_Layer> Ores_Mars = new AutoMap<>(); + private static final AutoMap<GT_Worldgen_GT_Ore_Layer> Ores_Comets = new AutoMap<>(); + private static final AutoMap<GT_Worldgen_GT_Ore_Layer> Ores_Misc = new AutoMap<>(); + + public static boolean findAndMapOreTypesFromGT() { + // Gets Moon ID + + boolean aEndAsteroids; + try { + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore") != null + && mMoonID == -99) { + mMoonID = ReflectionUtils + .getField( + ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore"), + "idDimensionMoon") + .getInt(null); + } + } catch (IllegalArgumentException | IllegalAccessException ignored) {} + + // Gets Mars ID + try { + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars") != null + && mMarsID == -99) { + mMarsID = ReflectionUtils + .getField( + ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars"), + "dimensionIDMars") + .getInt(null); + } + } catch (IllegalArgumentException | IllegalAccessException ignored) {} + + // Get Comets ID + try { + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids") + != null && mCometsID == -99) { + mCometsID = ReflectionUtils + .getField( + ReflectionUtils + .getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids"), + "dimensionIDAsteroids") + .getInt(null); + } + } catch (IllegalArgumentException | IllegalAccessException ignored) {} + + // Clear Cache + Ores_Overworld.clear(); + Ores_Nether.clear(); + Ores_End.clear(); + Ores_Misc.clear(); + + for (GT_Worldgen_GT_Ore_Layer x : GT_Worldgen_GT_Ore_Layer.sList) { + if (x.mEnabled) { + + try { + aEndAsteroids = ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "mEndAsteroid") + .getBoolean(x); + } catch (IllegalArgumentException | IllegalAccessException e) { + aEndAsteroids = false; + } + + if (x.mOverworld) { + Ores_Overworld.put(x); + } + if (x.mNether) { + Ores_Nether.put(x); + } + if (x.mEnd || aEndAsteroids) { + Ores_End.put(x); + } + if (x.mOverworld || x.mNether || (x.mEnd || aEndAsteroids)) { + continue; + } + + Ores_Misc.put(x); + } else { + Ores_Comets.put(x); + } + } + + mOreMaps[0] = Ores_Overworld; + mOreMaps[1] = Ores_Nether; + mOreMaps[2] = Ores_End; + mOreMaps[3] = Ores_Moon; + mOreMaps[4] = Ores_Mars; + mOreMaps[5] = Ores_Comets; + mOreMaps[6] = Ores_Misc; + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java new file mode 100644 index 0000000000..4b0f15b81e --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java @@ -0,0 +1,164 @@ +package gtPlusPlus.core.util.minecraft; + +import static gtPlusPlus.core.item.ModItems.ZZZ_Empty; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +import gregtech.api.util.GT_Utility; + +public class NBTUtils { + + public static NBTTagCompound getNBT(ItemStack aStack) { + NBTTagCompound rNBT = aStack.getTagCompound(); + return ((rNBT == null) ? new NBTTagCompound() : rNBT); + } + + public static void setBookTitle(ItemStack aStack, String aTitle) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setString("title", aTitle); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static ItemStack[] readItemsFromNBT(ItemStack itemstack) { + NBTTagCompound tNBT = getNBT(itemstack); + final NBTTagList list = tNBT.getTagList("Items", 10); + ItemStack inventory[] = new ItemStack[list.tagCount()]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < list.tagCount())) { + if (ItemStack.loadItemStackFromNBT(data) == ItemUtils.getSimpleStack(ZZZ_Empty)) { + inventory[slot] = null; + } else { + inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + return inventory; + } + + public static ItemStack writeItemsToNBT(ItemStack itemstack, ItemStack[] stored) { + NBTTagCompound tNBT = getNBT(itemstack); + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < stored.length; i++) { + final ItemStack stack = stored[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } else { + final NBTTagCompound data = new NBTTagCompound(); + ItemStack nullstack = ItemUtils.getSimpleStack(ZZZ_Empty); + nullstack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + tNBT.setTag("Items", list); + itemstack.setTagCompound(tNBT); + return itemstack; + } + + public static ItemStack writeItemsToNBT(ItemStack itemstack, ItemStack[] stored, String customkey) { + NBTTagCompound tNBT = getNBT(itemstack); + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < stored.length; i++) { + final ItemStack stack = stored[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + tNBT.setTag(customkey, list); + itemstack.setTagCompound(tNBT); + return itemstack; + } + + public static void setBoolean(ItemStack aStack, String aTag, boolean aBoolean) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setBoolean(aTag, aBoolean); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static boolean getBoolean(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getBoolean(aTag); + } + + public static void setInteger(ItemStack aStack, String aTag, int aInt) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setInteger(aTag, aInt); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static int getInteger(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getInteger(aTag); + } + + public static void setLong(ItemStack aStack, String aTag, long aInt) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setLong(aTag, aInt); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static long getLong(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getLong(aTag); + } + + public static void setString(ItemStack aStack, String aTag, String aString) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setString(aTag, aString); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static String getString(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getString(aTag); + } + + public static boolean hasKey(ItemStack stack, String key) { + final NBTTagCompound itemData = getNBT(stack); + if (itemData.hasKey(key)) { + return true; + } + return false; + } + + public static boolean createIntegerTagCompound(ItemStack rStack, String tagName, String keyName, int keyValue) { + final NBTTagCompound tagMain = getNBT(rStack); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setInteger(keyName, keyValue); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static NBTTagCompound getTagCompound(ItemStack aStack, String tagName) { + NBTTagCompound aNBT = getNBT(aStack); + if (aNBT != null && hasKey(aStack, tagName)) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT; + } + } + return null; + } + + public static boolean hasTagCompound(ItemStack aStack) { + return aStack.hasTagCompound(); + } + + public static void createEmptyTagCompound(ItemStack aStack) { + if (!hasTagCompound(aStack)) { + NBTTagCompound aTag = new NBTTagCompound(); + aStack.setTagCompound(aTag); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/OreDictUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/OreDictUtils.java new file mode 100644 index 0000000000..0c8e971443 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/OreDictUtils.java @@ -0,0 +1,20 @@ +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 { + return b != null && !b.isEmpty(); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java new file mode 100644 index 0000000000..ba7353cba6 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java @@ -0,0 +1,206 @@ +package gtPlusPlus.core.util.minecraft; + +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.WeakHashMap; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class PlayerUtils { + + public static final Map<String, EntityPlayer> mCachedFakePlayers = new WeakHashMap<>(); + private static final Class mThaumcraftFakePlayer; + + static { + if (ReflectionUtils.doesClassExist("thaumcraft.common.lib.FakeThaumcraftPlayer")) { + mThaumcraftFakePlayer = ReflectionUtils.getClass("thaumcraft.common.lib.FakeThaumcraftPlayer"); + } else { + mThaumcraftFakePlayer = null; + } + } + + public static List<EntityPlayerMP> getOnlinePlayers() { + final List<EntityPlayerMP> onlinePlayers = MinecraftServer.getServer() + .getConfigurationManager().playerEntityList; + return onlinePlayers; + } + + public static void messagePlayer(final EntityPlayer P, final String S) { + gregtech.api.util.GT_Utility.sendChatToPlayer(P, S); + } + + public static void messagePlayer(final EntityPlayer P, final IChatComponent S) { + P.addChatComponentMessage(S); + } + + public static EntityPlayer getPlayer(final String name) { + try { + for (final EntityPlayer temp : getOnlinePlayers()) { + if (temp.getDisplayName() + .equalsIgnoreCase(name)) { + return temp; + } + } + } catch (final Throwable ignored) {} + return null; + } + + public static EntityPlayer getPlayerOnServerFromUUID(final UUID parUUID) { + if (parUUID == null) { + return null; + } + for (final EntityPlayerMP player : getOnlinePlayers()) { + if (player.getUniqueID() + .equals(parUUID)) { + return player; + } + } + return null; + } + + public static boolean isPlayerOP(final EntityPlayer player) { + if (player.canCommandSenderUseCommand(2, "")) { + return true; + } + return false; + } + + // Not Clientside + public static ItemStack getItemStackInPlayersHand(final World world, final String Name) { + final EntityPlayer thePlayer = getPlayer(Name); + ItemStack heldItem = null; + try { + heldItem = thePlayer.getHeldItem(); + } catch (final NullPointerException e) { + return null; + } + if (heldItem != null) { + return heldItem; + } + return null; + } + + @SideOnly(Side.CLIENT) + public static ItemStack getItemStackInPlayersHand() { + final Minecraft mc = Minecraft.getMinecraft(); + ItemStack heldItem; + try { + heldItem = mc.thePlayer.getHeldItem(); + } catch (final NullPointerException e) { + return null; + } + if (heldItem != null) { + return heldItem; + } + return null; + } + + public static ItemStack getItemStackInPlayersHand(final EntityPlayer player) { + ItemStack heldItem; + try { + heldItem = player.getHeldItem(); + } catch (final NullPointerException e) { + e.printStackTrace(); + return null; + } + if (heldItem != null) { + return heldItem; + } else { + if (Utils.isClient()) { + heldItem = player.getItemInUse(); + } else { + heldItem = player.getCurrentEquippedItem(); + } + } + return heldItem; + } + + public static final UUID getPlayersUUIDByName(final String aPlayerName) { + final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); + if (player != null) { + return player.getUniqueID(); + } + return null; + } + + public static void messageAllPlayers(String string) { + Utils.sendServerMessage(string); + } + + public static boolean isCreative(EntityPlayer aPlayer) { + return aPlayer.capabilities.isCreativeMode; + } + + public static boolean canTakeDamage(EntityPlayer aPlayer) { + return !aPlayer.capabilities.disableDamage; + } + + public static void cacheFakePlayer(EntityPlayer aPlayer) { + ChunkCoordinates aChunkLocation = aPlayer.getPlayerCoordinates(); + // Cache Fake Player + if (aPlayer instanceof FakePlayer + || (mThaumcraftFakePlayer != null && mThaumcraftFakePlayer.isInstance(aPlayer)) + || (aPlayer.getCommandSenderName() == null || aPlayer.getCommandSenderName() + .length() <= 0) + || (aPlayer.isEntityInvulnerable() && !aPlayer.canCommandSenderUseCommand(0, "") && (aChunkLocation == null) + || (aChunkLocation.posX == 0 && aChunkLocation.posY == 0 && aChunkLocation.posZ == 0))) { + mCachedFakePlayers.put( + aPlayer.getUniqueID() + .toString(), + aPlayer); + } + } + + public static boolean isCachedFakePlayer(String aUUID) { + return mCachedFakePlayers.containsKey(aUUID); + } + + public static boolean isRealPlayer(EntityLivingBase aEntity) { + if (aEntity instanceof EntityPlayer p) { + ChunkCoordinates aChunkLocation = p.getPlayerCoordinates(); + if (p instanceof FakePlayer) { + cacheFakePlayer(p); + return false; + } + if (mThaumcraftFakePlayer != null && mThaumcraftFakePlayer.isInstance(p)) { + cacheFakePlayer(p); + return false; + } + if (p.getCommandSenderName() == null) { + cacheFakePlayer(p); + return false; + } + if (p.getCommandSenderName() + .length() <= 0) { + cacheFakePlayer(p); + return false; + } + if (p.isEntityInvulnerable() && !p.canCommandSenderUseCommand(0, "") + && (aChunkLocation.posX == 0 && aChunkLocation.posY == 0 && aChunkLocation.posZ == 0)) { + cacheFakePlayer(p); + return false; + } + if (!isCachedFakePlayer( + p.getUniqueID() + .toString())) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java new file mode 100644 index 0000000000..ed2da4d7f7 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -0,0 +1,465 @@ +package gtPlusPlus.core.util.minecraft; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.ShapedRecipe; +import gtPlusPlus.core.handler.COMPAT_HANDLER; +import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; +import gtPlusPlus.core.handler.Recipes.RegistrationHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.data.ArrayUtils; + +public class RecipeUtils { + + public static int mInvalidID = 1; + + public static void recipeBuilder(final Object slot_1, final Object slot_2, final Object slot_3, final Object slot_4, + final Object slot_5, final Object slot_6, final Object slot_7, final Object slot_8, final Object slot_9, + ItemStack resultItem) { + + if (resultItem == null) { + Logger.RECIPE( + "[Fix] Found a recipe with an invalid output, yet had a valid inputs. Using Dummy output so recipe can be found.."); + resultItem = ItemUtils.getItemStackOfAmountFromOreDict("givemeabrokenitem", 1); + resultItem.setItemDamage(mInvalidID++); + RegistrationHandler.recipesFailed++; + + } else if ((slot_1 == null) && (slot_2 == null) + && (slot_3 == null) + && (slot_4 == null) + && (slot_5 == null) + && (slot_6 == null) + && (slot_7 == null) + && (slot_8 == null) + && (slot_9 == null)) { + Logger.RECIPE("[Fix] Found a recipe with 0 inputs, yet had a valid output."); + Logger.RECIPE( + "[Fix] Error found while adding a recipe for: " + resultItem != null ? resultItem.getDisplayName() + : "Bad Output Item" + " | Please report this issue on Github."); + RegistrationHandler.recipesFailed++; + return; + } + + Object[] o = new Object[] { slot_1, slot_2, slot_3, slot_4, slot_5, slot_6, slot_7, slot_8, slot_9 }; + + try { + int size = COMPAT_HANDLER.mRecipesToGenerate.size(); + COMPAT_HANDLER.mRecipesToGenerate.put(new InternalRecipeObject(o, resultItem, false)); + // Utils.LOG_WARNING("Success! Added a recipe for "+resultItem.getDisplayName()); + if (COMPAT_HANDLER.mRecipesToGenerate.size() > size) { + if (!COMPAT_HANDLER.areInitItemsLoaded) { + RegistrationHandler.recipesSuccess++; + } else { + LateRegistrationHandler.recipesSuccess++; + } + } + } catch (RuntimeException k) { + Logger.RECIPE( + "[Fix] Invalid Recipe detected for: " + resultItem != null ? resultItem.getUnlocalizedName() + : "INVALID OUTPUT ITEM"); + if (!COMPAT_HANDLER.areInitItemsLoaded) { + RegistrationHandler.recipesFailed++; + } else { + LateRegistrationHandler.recipesFailed++; + } + } + } + + public static void removeCraftingRecipe(Object x) { + if (null == x) { + return; + } + if (x instanceof String) { + final Item R = ItemUtils.getItemFromFQRN((String) x); + if (R != null) { + x = R; + } else { + return; + } + } + if ((x instanceof Item) || (x instanceof ItemStack)) { + if (x instanceof Item) { + final ItemStack r = new ItemStack((Item) x); + Logger.RECIPE("Removing Recipe for " + r.getUnlocalizedName()); + } else { + Logger.RECIPE("Removing Recipe for " + ((ItemStack) x).getUnlocalizedName()); + } + if (x instanceof ItemStack) { + final Item r = ((ItemStack) x).getItem(); + if (null != r) { + x = r; + } else { + Logger.RECIPE("Recipe removal failed - Tell Alkalus."); + return; + } + } + if (RecipeUtils.attemptRecipeRemoval((Item) x)) { + Logger.RECIPE("Recipe removal successful"); + return; + } + Logger.RECIPE("Recipe removal failed - Tell Alkalus."); + } + } + + private static boolean attemptRecipeRemoval(final Item I) { + Logger.RECIPE("Create list of recipes."); + final List<IRecipe> recipes = CraftingManager.getInstance() + .getRecipeList(); + final Iterator<IRecipe> items = recipes.iterator(); + Logger.RECIPE("Begin list iteration."); + while (items.hasNext()) { + final ItemStack is = items.next() + .getRecipeOutput(); + if ((is != null) && (is.getItem() == I)) { + items.remove(); + Logger.RECIPE("Remove a recipe with " + I.getUnlocalizedName() + " as output."); + continue; + } + } + Logger.RECIPE("All recipes should be gone?"); + if (!items.hasNext()) { + Logger.RECIPE("We iterated once, let's try again to double check."); + for (IRecipe recipe : recipes) { + final ItemStack is = recipe.getRecipeOutput(); + if ((is != null) && (is.getItem() == I)) { + items.remove(); + Logger.RECIPE("REMOVING MISSED RECIPE - RECHECK CONSTRUCTORS"); + return true; + } + } + Logger.RECIPE("Should be all gone now after double checking, so return true."); + return true; + } + Logger.RECIPE("Return false, because something went wrong."); + return false; + } + + public static boolean addShapedGregtechRecipe(final Object InputItem1, final Object InputItem2, + final Object InputItem3, final Object InputItem4, final Object InputItem5, final Object InputItem6, + final Object InputItem7, final Object InputItem8, final Object InputItem9, final ItemStack OutputItem) { + + Object[] o = { InputItem1, InputItem2, InputItem3, InputItem4, InputItem5, InputItem6, InputItem7, InputItem8, + InputItem9 }; + + if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { + CORE.crash( + "Load Phase " + gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE + + " should be " + + GTplusplus.INIT_PHASE.POST_INIT + + ". Unable to register recipe."); + } + + int size = COMPAT_HANDLER.mGtRecipesToGenerate.size(); + COMPAT_HANDLER.mGtRecipesToGenerate.put(new InternalRecipeObject(o, OutputItem, true)); + + if (COMPAT_HANDLER.mGtRecipesToGenerate.size() > size) { + if (!COMPAT_HANDLER.areInitItemsLoaded) { + RegistrationHandler.recipesSuccess++; + } else { + LateRegistrationHandler.recipesSuccess++; + } + return true; + } + return false; + } + + public static boolean addShapelessGregtechRecipe(final Object[] inputItems, final ItemStack OutputItem) { + // Catch Invalid Recipes + if (inputItems.length > 9 || inputItems.length < 1) { + if (OutputItem != null) { + Logger.RECIPE( + "[Fix] Invalid input array for shapeless recipe, which should output " + + OutputItem.getDisplayName()); + } + return false; + } + // let gregtech handle shapeless recipes. + if (GT_ModHandler.addShapelessCraftingRecipe(OutputItem, inputItems)) { + return true; + } + return false; + } + + public static boolean generateMortarRecipe(ItemStack aStack, ItemStack aOutput) { + return RecipeUtils + .addShapedGregtechRecipe(aStack, null, null, CI.craftingToolMortar, null, null, null, null, null, aOutput); + } + + public static class InternalRecipeObject implements RunnableWithInfo<String> { + + final ItemStack mOutput; + final ShapedOreRecipe mRecipe; + public final boolean isValid; + + public InternalRecipeObject(Object[] aInputs, ItemStack aOutput, boolean gtRecipe) { + Logger.RECIPE("==================================="); + mOutput = aOutput != null ? aOutput.copy() : null; + Object[] aFiltered = new Object[9]; + int aValid = 0; + for (Object o : aInputs) { + if (o instanceof ItemStack) { + aFiltered[aValid++] = o; + } else if (o instanceof Item) { + aFiltered[aValid++] = ItemUtils.getSimpleStack((Item) o); + } else if (o instanceof Block) { + aFiltered[aValid++] = ItemUtils.getSimpleStack((Block) o); + } else if (o instanceof String) { + aFiltered[aValid++] = o; + } else if (o == null) { + aFiltered[aValid++] = null; + } else { + Logger.RECIPE( + "Cleaned a " + o.getClass() + .getSimpleName() + " from recipe input."); + } + } + + int validCounter = 0, invalidCounter = 0; + for (Object p : aFiltered) { + if (p instanceof ItemStack) { + validCounter++; + } else if (p instanceof Item) { + validCounter++; + } else if (p instanceof Block) { + validCounter++; + } else if (p instanceof String) { + validCounter++; + } else if (p == null) { + validCounter++; + } else { + invalidCounter++; + } + } + + Logger.RECIPE("Using " + validCounter + " valid inputs and " + invalidCounter + " invalid inputs."); + ShapedRecipe r = new ShapedRecipe(aFiltered, mOutput); + if (r != null && r.mRecipe != null) { + isValid = true; + } else { + isValid = false; + } + mRecipe = r != null ? r.mRecipe : null; + } + + @Override + public void run() { + if (this.isValid) { + GameRegistry.addRecipe(mRecipe); + } else { + Logger.RECIPE( + "[Fix] Invalid shapped recipe outputting " + + (mOutput != null ? mOutput.getDisplayName() : "Bad Output Item")); + } + } + + @Override + public String getInfoData() { + if (mOutput != null && mOutput instanceof ItemStack) { + return mOutput.getDisplayName(); + } + return ""; + } + } + + public static boolean removeRecipeByOutput(ItemStack aOutput) { + return removeRecipeByOutput(aOutput, true, false, false); + } + + public static boolean removeRecipeByOutput(ItemStack aOutput, boolean aIgnoreNBT, + boolean aNotRemoveShapelessRecipes, boolean aOnlyRemoveNativeHandlers) { + if (aOutput == null) { + return false; + } else { + boolean rReturn = false; + ArrayList<IRecipe> tList = (ArrayList) CraftingManager.getInstance() + .getRecipeList(); + aOutput = GT_OreDictUnificator.get(aOutput); + int tList_sS = tList.size(); + + for (int i = 0; i < tList_sS; ++i) { + IRecipe tRecipe = (IRecipe) tList.get(i); + if (!aNotRemoveShapelessRecipes + || !(tRecipe instanceof ShapelessRecipes) && !(tRecipe instanceof ShapelessOreRecipe)) { + if (aOnlyRemoveNativeHandlers) { + if (!gregtech.api.util.GT_ModHandler.sNativeRecipeClasses.contains( + tRecipe.getClass() + .getName())) { + continue; + } + } else if (gregtech.api.util.GT_ModHandler.sSpecialRecipeClasses.contains( + tRecipe.getClass() + .getName())) { + continue; + } + + ItemStack tStack = tRecipe.getRecipeOutput(); + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tStack), aOutput, aIgnoreNBT)) { + tList.remove(i--); + tList_sS = tList.size(); + rReturn = true; + } + } + } + + return rReturn; + } + } + + public static void addSmeltingRecipe(ItemStack aStackInput, ItemStack aStackOutput, float aXpGained) { + + GameRegistry.addSmelting(aStackInput, aStackOutput, aXpGained); + } + + public static boolean addShapedRecipe(Object Input_1, Object Input_2, Object Input_3, Object Input_4, + Object Input_5, Object Input_6, Object Input_7, Object Input_8, Object Input_9, ItemStack aOutputStack) { + return addShapedRecipe( + new Object[] { Input_1, Input_2, Input_3, Input_4, Input_5, Input_6, Input_7, Input_8, Input_9 }, + aOutputStack); + } + + private static boolean addShapedRecipe(Object[] Inputs, ItemStack aOutputStack) { + Object[] Slots = new Object[9]; + + String aFullString = ""; + String aFullStringExpanded = "abcdefghi"; + + for (int i = 0; i < 9; i++) { + Object o = Inputs[i]; + + if (o instanceof ItemStack) { + Slots[i] = ItemUtils.getSimpleStack((ItemStack) o, 1); + aFullString += aFullStringExpanded.charAt(i); + } else if (o instanceof Item) { + Slots[i] = ItemUtils.getSimpleStack((Item) o, 1); + aFullString += aFullStringExpanded.charAt(i); + } else if (o instanceof Block) { + Slots[i] = ItemUtils.getSimpleStack((Block) o, 1); + aFullString += aFullStringExpanded.charAt(i); + } else if (o instanceof String) { + Slots[i] = o; + aFullString += aFullStringExpanded.charAt(i); + } else if (o instanceof ItemData aData) { + ItemStack aStackFromGT = ItemUtils.getOrePrefixStack(aData.mPrefix, aData.mMaterial.mMaterial, 1); + Slots[i] = aStackFromGT; + aFullString += aFullStringExpanded.charAt(i); + } else if (o == null) { + Slots[i] = null; + aFullString += " "; + } else { + Slots[i] = null; + Logger.INFO( + "Cleaned a " + o.getClass() + .getSimpleName() + " from recipe input."); + Logger.INFO("ERROR"); + CORE.crash("Bad Shaped Recipe."); + } + } + Logger.RECIPE("Using String: " + aFullString); + + String aRow1 = aFullString.substring(0, 3); + String aRow2 = aFullString.substring(3, 6); + String aRow3 = aFullString.substring(6, 9); + Logger.RECIPE("" + aRow1); + Logger.RECIPE("" + aRow2); + Logger.RECIPE("" + aRow3); + + String[] aStringData = new String[] { aRow1, aRow2, aRow3 }; + Object[] aDataObject = new Object[19]; + aDataObject[0] = aStringData; + int aIndex = 0; + + for (int u = 1; u < 20; u += 2) { + if (aIndex == 9) { + break; + } + if (aFullString.charAt(aIndex) != (' ')) { + aDataObject[u] = aFullString.charAt(aIndex); + aDataObject[u + 1] = Slots[aIndex]; + Logger.INFO( + "(" + aIndex + + ") " + + aFullString.charAt(aIndex) + + " | " + + (Slots[aIndex] instanceof ItemStack ? ItemUtils.getItemName((ItemStack) Slots[aIndex]) + : Slots[aIndex] instanceof String ? (String) Slots[aIndex] : "Unknown")); + } + aIndex++; + } + + Logger.RECIPE("Data Size: " + aDataObject.length); + aDataObject = ArrayUtils.removeNulls(aDataObject); + Logger.RECIPE("Clean Size: " + aDataObject.length); + Logger.RECIPE("ArrayData: " + Arrays.toString(aDataObject)); + + ShapedOreRecipe aRecipe = new ShapedOreRecipe(aOutputStack, aDataObject); + + int size = COMPAT_HANDLER.mRecipesToGenerate.size(); + COMPAT_HANDLER.mRecipesToGenerate.put(new InternalRecipeObject2(aRecipe)); + if (COMPAT_HANDLER.mRecipesToGenerate.size() > size) { + if (!COMPAT_HANDLER.areInitItemsLoaded) { + RegistrationHandler.recipesSuccess++; + } else { + LateRegistrationHandler.recipesSuccess++; + } + return true; + } + return false; + } + + public static class InternalRecipeObject2 implements RunnableWithInfo<String> { + + final ItemStack mOutput; + final ShapedOreRecipe mRecipe; + final boolean isValid; + + public InternalRecipeObject2(ShapedOreRecipe aRecipe) { + mRecipe = aRecipe; + mOutput = aRecipe.getRecipeOutput(); + if (mOutput != null) { + this.isValid = true; + } else { + this.isValid = false; + } + } + + @Override + public void run() { + if (this.isValid) { + GameRegistry.addRecipe(mRecipe); + } else { + Logger.INFO( + "[Fix] Invalid shapped recipe outputting " + mOutput != null ? mOutput.getDisplayName() + : "Bad Output Item"); + } + } + + @Override + public String getInfoData() { + if (mOutput != null) { + return mOutput.getDisplayName(); + } + return ""; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java new file mode 100644 index 0000000000..4e6e508c15 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java @@ -0,0 +1,147 @@ +package gtPlusPlus.core.util.minecraft.gregtech; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.fluids.FluidStack; + +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_Pollution; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.base.cell.BaseItemCell; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class PollutionUtils { + + public static AutoMap<FluidStack> mPollutionFluidStacks = new AutoMap<>(); + + public static boolean isPollutionEnabled() { + return GT_Mod.gregtechproxy.mPollution; + } + + public static boolean addPollution(IGregTechTileEntity te, int pollutionValue) { + if (GT_Mod.gregtechproxy.mPollution) { + GT_Pollution.addPollution(te, pollutionValue); + return true; + } + return false; + } + + public static void addPollution(IHasWorldObjectAndCoords aTileOfSomeSort, int pollutionValue) { + if (GT_Mod.gregtechproxy.mPollution) { + Chunk c = aTileOfSomeSort.getWorld() + .getChunkFromBlockCoords(aTileOfSomeSort.getXCoord(), aTileOfSomeSort.getZCoord()); + addPollution(c, pollutionValue); + } + } + + public static void addPollution(Chunk aChunk, int pollutionValue) { + if (GT_Mod.gregtechproxy.mPollution) { + GT_Pollution.addPollution(aChunk, pollutionValue); + } + } + + public static void removePollution(IGregTechTileEntity te, int pollutionValue) { + addPollution(te, -pollutionValue); + } + + public static void removePollution(Chunk aChunk, int pollutionValue) { + addPollution(aChunk, -pollutionValue); + } + + public static void nullifyPollution(IGregTechTileEntity te) { + if (te == null) { + return; + } + nullifyPollution((IHasWorldObjectAndCoords) te); + } + + public static void nullifyPollution(IHasWorldObjectAndCoords aTileOfSomeSort) { + if (aTileOfSomeSort == null) { + return; + } + Chunk c = aTileOfSomeSort.getWorld() + .getChunkFromBlockCoords(aTileOfSomeSort.getXCoord(), aTileOfSomeSort.getZCoord()); + nullifyPollution(c); + } + + public static void nullifyPollution(Chunk aChunk) { + if (GT_Mod.gregtechproxy.mPollution) { + if (aChunk == null) { + return; + } + int getCurrentPollution = getPollution(aChunk); + if (getCurrentPollution > 0) { + removePollution(aChunk, getCurrentPollution); + } + } + } + + public static int getPollution(IGregTechTileEntity te) { + return GT_Pollution.getPollution(te); + } + + public static int getPollution(Chunk te) { + return GT_Pollution.getPollution(te); + } + + public static void 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); + } + } + } else { + if (mPollutionFluidStacks.size() != 3) { + Logger.INFO("Unable to detect all 3 pollution fluids. Found: "); + Logger.INFO(ArrayUtils.toString(mPollutionFluidStacks)); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/recipe/GT_RecipeUtils.java b/src/main/java/gtPlusPlus/core/util/recipe/GT_RecipeUtils.java new file mode 100644 index 0000000000..c5498e4f59 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/recipe/GT_RecipeUtils.java @@ -0,0 +1,95 @@ +package gtPlusPlus.core.util.recipe; + +import static gtPlusPlus.core.slots.SlotIntegratedCircuit.isRegularProgrammableCircuit; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.apache.commons.lang3.ArrayUtils; + +import gnu.trove.map.hash.TCustomHashMap; +import gnu.trove.set.hash.TCustomHashSet; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.api.objects.Logger; + +public class GT_RecipeUtils { + + public static List<GT_Recipe> removeDuplicates(List<GT_Recipe> inputRecipes, String recipeMapName) { + TCustomHashSet<GT_Recipe> recipesHashSet = new TCustomHashSet<>(RecipeHashStrat.RecipeHashingStrategy); + ArrayList<GT_Recipe> recipeOutput = new ArrayList<>(); + TCustomHashMap<GT_Recipe, ItemStack> circuitMap = new TCustomHashMap<>(RecipeHashStrat.RecipeHashingStrategy); + int removedRecipeCount = 0; + + for (GT_Recipe recipeInput : inputRecipes) { + ItemStack savedCircuit = null; + // create a new input ItemStack array that does not contain programmable circuits if they were in the recipe + ArrayList<ItemStack> itemInputsWithoutProgrammableCircuit = new ArrayList<>(); + // iterate over the recipe input items and add them all to a new array without any programmable circuits + for (ItemStack itemStack : recipeInput.mInputs) { + if (itemStack == null) { + continue; + } + if (isRegularProgrammableCircuit(itemStack) == -1) { + itemInputsWithoutProgrammableCircuit.add(itemStack); + } else { + savedCircuit = itemStack; + } + } + GT_Recipe newRecipe = new GT_Recipe( + false, + itemInputsWithoutProgrammableCircuit.toArray(new ItemStack[0]), + recipeInput.mOutputs, + recipeInput.mSpecialItems, + recipeInput.mChances, + recipeInput.mFluidInputs, + recipeInput.mFluidOutputs, + recipeInput.mDuration, + recipeInput.mEUt, + recipeInput.mSpecialValue); + if (!recipesHashSet.contains(newRecipe)) { + // if the recipes customHashSet does not contain the new recipe then add it + recipesHashSet.add(newRecipe); + } else { + removedRecipeCount++; + } + if (savedCircuit != null) { + // if the current recipe has a circuit and the recipe (without circuits) is already in the + // circuit map then check make sure the circuit map saves the recipe with the smallest circuit + // damage value. This is to prevent a case where recipe load order would affect which duplicate + // recipes with multiple circuit values gets removed. + if (circuitMap.containsKey(newRecipe)) { + if (circuitMap.get(newRecipe) + .getItemDamage() > savedCircuit.getItemDamage()) { + circuitMap.put(newRecipe, savedCircuit); + } + } else { + // If the circuit map does not have the recipe in it yet then add it + circuitMap.put(newRecipe, savedCircuit); + } + } + } + // iterate over all recipes without duplicates and add them to the output. If the recipe had a programmable + // circuit in it then add it back with its damage value coming from the circuit map. + for (GT_Recipe filteredRecipe : recipesHashSet) { + // check to see if the recipe is in the circuit map + if (circuitMap.contains(filteredRecipe)) { + // add the circuit back + // update the item input array with the new input from + // ItemInputsWithoutProgrammableCircuit + circuit map circuit + filteredRecipe.mInputs = ArrayUtils.add(filteredRecipe.mInputs, circuitMap.get(filteredRecipe)); + } + // if the recipe was not in the circuit map then just add it the output as no updates to the item input + // needs to be made + recipeOutput.add(filteredRecipe); + } + // print results to log + Logger.INFO( + "Recipe Array duplication removal process completed for '" + recipeMapName + + "': '" + + removedRecipeCount + + "' removed."); + return recipeOutput; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/recipe/RecipeHashStrat.java b/src/main/java/gtPlusPlus/core/util/recipe/RecipeHashStrat.java new file mode 100644 index 0000000000..18323a4c8b --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/recipe/RecipeHashStrat.java @@ -0,0 +1,116 @@ +package gtPlusPlus.core.util.recipe; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.Objects; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import gnu.trove.strategy.HashingStrategy; +import gregtech.api.util.GT_Recipe; + +public class RecipeHashStrat { + + public static final HashingStrategy<GT_Recipe> RecipeHashingStrategy = new HashingStrategy<>() { + + @Override + public int computeHashCode(GT_Recipe recipe) { + return com.google.common.base.Objects.hashCode(recipe.mDuration, recipe.mEUt); + } + + @Override + public boolean equals(GT_Recipe recipe1, GT_Recipe recipe2) { + return areRecipesEqual(recipe1, recipe2); + } + }; + + public static boolean areRecipesEqual(GT_Recipe recipe1, GT_Recipe recipe2) { + // both item outputs use a copy to prevent interfering with chance based output orders + // sort all the arrays for recipe1 + RecipeHashStrat.sortItemStackArray(recipe1.mInputs); + ItemStack[] recipe1OutputCopy = recipe1.mOutputs.clone(); + RecipeHashStrat.sortItemStackArray(recipe1OutputCopy); + RecipeHashStrat.sortFluidStackArray(recipe1.mFluidInputs); + RecipeHashStrat.sortFluidStackArray(recipe1.mFluidOutputs); + // sort all the arrays for recipe2 + + RecipeHashStrat.sortItemStackArray(recipe2.mInputs); + ItemStack[] recipe2OutputCopy = recipe2.mOutputs.clone(); + RecipeHashStrat.sortItemStackArray(recipe2OutputCopy); + RecipeHashStrat.sortFluidStackArray(recipe2.mFluidInputs); + RecipeHashStrat.sortFluidStackArray(recipe2.mFluidOutputs); + + // checks if the recipe EUt, Duration, inputs and outputs for both items and fluids are equal + if (recipe1.mEUt != recipe2.mEUt) { + return false; + } + if (recipe1.mDuration != recipe2.mDuration) { + return false; + } + if (!areItemsStackArraysEqual(recipe1.mInputs, recipe2.mInputs)) { + return false; + } + if (!areItemsStackArraysEqual(recipe1OutputCopy, recipe2OutputCopy)) { + return false; + } + if (!areFluidStackArraysEqual(recipe1.mFluidInputs, recipe2.mFluidInputs)) { + return false; + } + if (!areFluidStackArraysEqual(recipe1.mFluidOutputs, recipe2.mFluidOutputs)) { + return false; + } + return true; + + } + + public static void sortItemStackArray(ItemStack[] itemStackArray) { + Arrays.sort( + itemStackArray, + Comparator.<ItemStack, Integer>comparing(itemStack -> Item.getIdFromItem(itemStack.getItem())) + .thenComparing(ItemStack::getItemDamage) + .thenComparing(itemStack -> itemStack.stackSize)); + } + + public static void sortFluidStackArray(FluidStack[] fluidStackArray) { + Arrays.sort( + fluidStackArray, + Comparator.comparing(FluidStack::getFluidID) + .thenComparing(fluidStack -> fluidStack.amount)); + } + + public static boolean areItemsStackArraysEqual(ItemStack[] array1, ItemStack[] array2) { + if (array1.length != array2.length) { + return false; + } + for (int i = 0; i < array1.length; i++) { + if (!Objects.equals(array1[i].getItem(), array2[i].getItem())) { + return false; + } + if (!Objects.equals(array1[i].getItemDamage(), array2[i].getItemDamage())) { + return false; + } + if (!Objects.equals(array1[i].stackSize, array2[i].stackSize)) { + return false; + } + } + return true; + } + + public static boolean areFluidStackArraysEqual(FluidStack[] array1, FluidStack[] array2) { + if (array1.length != array2.length) { + return false; + } + for (int i = 0; i < array1.length; i++) { + // check if the string representation of both FluidStacks are not equal + if (!Objects.equals(array1[i].getFluid(), array2[i].getFluid())) { + return false; + } + if (!Objects.equals(array1[i].amount, array2[i].amount)) { + return false; + } + } + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java b/src/main/java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java new file mode 100644 index 0000000000..807fba9238 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java @@ -0,0 +1,77 @@ +package gtPlusPlus.core.util.reflect; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; + +public final class AddGregtechRecipe { + + public static boolean importPyroRecipe(GT_Recipe aRecipe) { + + int aModifiedTime = (int) (aRecipe.mDuration * 0.8); + + if (aRecipe.mInputs == null || aRecipe.mFluidInputs == null + || aRecipe.mFluidOutputs == null + || aRecipe.mOutputs == null) { + return false; + } + if (aRecipe.mInputs.length > 2 || aRecipe.mFluidInputs.length > 1 + || aRecipe.mFluidOutputs.length > 1 + || aRecipe.mOutputs.length > 9) { + return false; + } else if (aRecipe.mInputs.length <= 0) { + return false; + } + + int aCircuitNumber = -1; + Item aCircuit = CI.getNumberedCircuit(1) + .getItem(); + boolean hasCircuit = false; + + for (ItemStack a : aRecipe.mInputs) { + if (a != null && a.getItem() == aCircuit) { + hasCircuit = true; + aCircuitNumber = a.getItemDamage(); + break; + } + } + + ItemStack aInputItem = null; + if (!hasCircuit || aCircuitNumber < 1) { + return false; + } + + for (ItemStack a : aRecipe.mInputs) { + if (a != null && a.getItem() != aCircuit) { + aInputItem = a; + break; + } + } + + return CORE.RA.addCokeOvenRecipe( + aCircuitNumber, + aInputItem, + aRecipe.mFluidInputs, + aRecipe.mFluidOutputs, + aRecipe.mOutputs, + aModifiedTime, + aRecipe.mEUt); + } + + @Deprecated + public static boolean addCokeAndPyrolyseRecipes(ItemStack input1, int circuitNumber, FluidStack inputFluid1, + ItemStack output1, FluidStack outputFluid1, int timeInSeconds, int euTick) { + // Seconds Conversion + int TIME = timeInSeconds * 20; + int TIMEPYRO = TIME + (TIME / 5); + // Even though it says coke and pyrolyse, ICO recipes are imported from pyrolyse by #importPyroRecipe + GT_Values.RA.addPyrolyseRecipe(input1, inputFluid1, circuitNumber, output1, outputFluid1, TIMEPYRO, euTick); + + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java new file mode 100644 index 0000000000..078cef6ea8 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -0,0 +1,727 @@ +package gtPlusPlus.core.util.reflect; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.apache.commons.lang3.ArrayUtils; + +import com.google.common.reflect.ClassPath; +import com.gtnewhorizon.gtnhlib.reflect.Fields; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.data.StringUtils; + +@SuppressWarnings({ "unchecked", "rawtypes" }) +public class ReflectionUtils { + + public static Map<String, Class<?>> mCachedClasses = new LinkedHashMap<>(); + public static Map<String, CachedMethod> mCachedMethods = new LinkedHashMap<>(); + public static Map<String, CachedField> mCachedFields = new LinkedHashMap<>(); + public static Map<String, CachedConstructor> mCachedConstructors = new LinkedHashMap<>(); + public static Map<Field, Fields.ClassFields.Field> mCachedFieldAccessors = new LinkedHashMap<>(); + + 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 Method METHOD; + + public CachedMethod(Method aMethod, boolean isStatic) { + METHOD = aMethod; + } + + public Method get() { + return METHOD; + } + + } + + private static class CachedField { + + private final Field FIELD; + + public CachedField(Field aField, boolean isStatic) { + FIELD = aField; + } + + public Field get() { + return FIELD; + } + + } + + private static Fields.ClassFields.Field cacheAccessor(Field f) { + return mCachedFieldAccessors.computeIfAbsent( + f, + (field) -> Fields.ofClass(field.getDeclaringClass()) + .getUntypedField(Fields.LookupType.DECLARED_IN_HIERARCHY, field.getName())); + } + + private static boolean cacheClass(Class<?> aClass) { + if (aClass == null) { + return false; + } + Class<?> y = mCachedClasses.get(aClass.getCanonicalName()); + if (y == null) { + mCachedClasses.put(aClass.getCanonicalName(), aClass); + return true; + } + return false; + } + + private static boolean cacheMethod(Class<?> aClass, Method aMethod) { + if (aMethod == null) { + return false; + } + boolean isStatic = Modifier.isStatic(aMethod.getModifiers()); + CachedMethod y = mCachedMethods + .get(aClass.getName() + "." + aMethod.getName() + "." + ArrayUtils.toString(aMethod.getParameterTypes())); + if (y == null) { + mCachedMethods.put( + aClass.getName() + "." + aMethod.getName() + "." + ArrayUtils.toString(aMethod.getParameterTypes()), + new CachedMethod(aMethod, isStatic)); + return true; + } + return false; + } + + private static boolean cacheField(Class<?> aClass, Field aField) { + if (aField == null) { + return false; + } + boolean isStatic = Modifier.isStatic(aField.getModifiers()); + CachedField y = mCachedFields.get(aClass.getName() + "." + aField.getName()); + if (y == null) { + mCachedFields.put(aClass.getName() + "." + aField.getName(), new CachedField(aField, isStatic)); + return true; + } + return false; + } + + private static void cacheConstructor(Class<?> aClass, Constructor<?> aConstructor) { + if (aConstructor == null) { + return; + } + mCachedConstructors.computeIfAbsent( + aClass.getName() + "." + ArrayUtils.toString(aConstructor.getParameterTypes()), + k -> new CachedConstructor(aConstructor)); + } + + /** + * 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) { + if (aClassCanonicalName == null || aClassCanonicalName.length() <= 0) { + return null; + } + Class<?> y = mCachedClasses.get(aClassCanonicalName); + if (y == null) { + y = getClass_Internal(aClassCanonicalName); + if (y != null) { + Logger.REFLECTION("Caching Class: " + aClassCanonicalName); + cacheClass(y); + } + } + return y; + } + + /** + * Returns a cached {@link Method} object. Wraps {@link #getMethod(Class, String, Class...)}. + * + * @param aObject - Object containing the Method. + * @param aMethodName - Method's name in {@link String} form. + * @param aTypes - Class Array of Types for {@link Method}'s constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Method getMethod(Object aObject, String aMethodName, Class[] aTypes) { + return getMethod(aObject.getClass(), aMethodName, aTypes); + } + + /** + * Returns a cached {@link Method} object. + * + * @param aClass - Class containing the Method. + * @param aMethodName - Method's name in {@link String} form. + * @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) { + if (aClass == null || aMethodName == null || aMethodName.length() <= 0) { + return null; + } + String aMethodKey = ArrayUtils.toString(aTypes); + // Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); + CachedMethod y = mCachedMethods.get(aClass.getName() + "." + aMethodName + "." + aMethodKey); + if (y == null) { + Method u = getMethod_Internal(aClass, aMethodName, aTypes); + if (u != null) { + Logger.REFLECTION("Caching Method: " + aMethodName + "." + aMethodKey); + cacheMethod(aClass, u); + return u; + } else { + return null; + } + } else { + return y.get(); + } + } + + /** + * Returns a cached {@link Field} object. + * + * @param aClass - Class containing the Method. + * @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) { + if (aClass == null || aFieldName == null || aFieldName.length() <= 0) { + return null; + } + CachedField y = mCachedFields.get(aClass.getName() + "." + aFieldName); + if (y == null) { + Field u; + try { + u = getField_Internal(aClass, aFieldName); + if (u != null) { + Logger.REFLECTION("Caching Field '" + aFieldName + "' from " + aClass.getName()); + cacheField(aClass, u); + return u; + } + } catch (NoSuchFieldException e) {} + return null; + + } else { + return y.get(); + } + } + + /** + * Returns a cached {@link Field} object. + * + * @param aInstance - {@link Object} to get the field instance from. + * @param aFieldName - Field name in {@link String} form. + * @return - Valid, non-final, {@link Field} object, or {@link null}. + */ + public static <T> T getField(final Object aInstance, final String aFieldName) { + try { + return (T) getField(aInstance.getClass(), aFieldName).get(aInstance); + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } + } + + /* + * Utility Functions + */ + + public static boolean doesClassExist(final String classname) { + return isClassPresent(classname); + } + + public static void makeFieldAccessible(final Field field) { + if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic( + field.getDeclaringClass() + .getModifiers())) { + field.setAccessible(true); + } + } + + public static void makeMethodAccessible(final Method field) { + if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic( + field.getDeclaringClass() + .getModifiers())) { + field.setAccessible(true); + } + } + + /** + * Get the method name for a depth in call stack. <br /> + * Utility function + * + * @param depth depth in the call stack (0 means current method, 1 means call method, ...) + * @return Method name + */ + public static String getMethodName(final int depth) { + final StackTraceElement[] ste = new Throwable().getStackTrace(); + // System. out.println(ste[ste.length-depth].getClassName()+"#"+ste[ste.length-depth].getMethodName()); + if (ste.length < depth) { + return "No valid stack."; + } + return ste[depth + 1].getMethodName(); + } + + /** + * + * @param aPackageName - The full {@link Package} name in {@link String} form. + * @return - {@link Boolean} object. True if loaded > 0 classes. + */ + public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { + ClassLoader classLoader = ReflectionUtils.class.getClassLoader(); + int loaded = 0; + try { + ClassPath path = ClassPath.from(classLoader); + for (ClassPath.ClassInfo info : path.getTopLevelClassesRecursive(aPackageName)) { + Class<?> clazz = Class.forName(info.getName(), true, classLoader); + if (clazz != null) { + loaded++; + Logger.INFO("Found " + clazz.getCanonicalName() + ". [" + loaded + "]"); + } + } + } catch (ClassNotFoundException | IOException e) { + + } + + return loaded > 0; + } + + public static void loadClass(String aClassName) { + try { + Class.forName(aClassName, true, ReflectionUtils.class.getClassLoader()); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { + Class<?> clazz; + if (object instanceof Class) { + clazz = (Class<?>) object; + } else { + clazz = object.getClass(); + } + while (clazz != null) { + try { + final Field field = getField(clazz, fieldName); + if (field != null) { + setFieldValue_Internal(object, field, fieldValue); + return true; + } + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("setField(" + object + ", " + fieldName + ") failed."); + clazz = clazz.getSuperclass(); + } catch (final Exception e) { + Logger.REFLECTION("setField(" + object + ", " + fieldName + ") failed."); + throw new IllegalStateException(e); + } + } + return false; + } + + public static boolean setField(final Object object, final Field field, final Object fieldValue) { + if (field == null) return false; + Class<?> clazz; + if (object instanceof Class) { + clazz = (Class<?>) object; + } else { + clazz = object.getClass(); + } + while (clazz != null) { + try { + final Field field2 = getField(clazz, field.getName()); + if (field2 != null) { + setFieldValue_Internal(object, field, fieldValue); + return true; + } + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("setField(" + object + ", " + field.getName() + ") failed."); + clazz = clazz.getSuperclass(); + } catch (final Exception e) { + Logger.REFLECTION("setField(" + object + ", " + field.getName() + ") failed."); + throw new IllegalStateException(e); + } + } + return false; + } + + /** + * Allows to change the state of an immutable instance. Huh?!? + */ + public static void setFinalFieldValue(Class<?> clazz, String fieldName, Object newValue) { + Field nameField = getField(clazz, fieldName); + try { + setFieldValue_Internal(clazz, nameField, newValue); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + public static void setByte(Object clazz, String fieldName, byte newValue) { + Field nameField = getField(clazz.getClass(), fieldName); + cacheAccessor(nameField).setValue(null, newValue); + } + + public static boolean invokeVoid(Object objectInstance, String methodName, Class[] parameters, Object[] values) { + if (objectInstance == null || methodName == null || parameters == null || values == null) { + return false; + } + Class<?> mLocalClass = (objectInstance instanceof Class ? (Class<?>) objectInstance + : objectInstance.getClass()); + Logger.REFLECTION( + "Trying to invoke " + methodName + " on an instance of " + mLocalClass.getCanonicalName() + "."); + try { + Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); + if (mInvokingMethod != null) { + Logger.REFLECTION(methodName + " was not null."); + mInvokingMethod.invoke(objectInstance, values); + Logger.REFLECTION("Successfully invoked " + methodName + "."); + return true; + } 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()); + } + + Logger.REFLECTION("Invoke failed or did something wrong."); + return false; + } + + /* + * Below Code block is used for determining generic types associated with type<E> + */ + + /* + * End of Generics Block + */ + + private static Field getField_Internal(final Class<?> clazz, final String fieldName) throws NoSuchFieldException { + try { + Logger.REFLECTION("Field: Internal Lookup: " + fieldName); + Field k = clazz.getDeclaredField(fieldName); + makeFieldAccessible(k); + return k; + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("Field: Internal Lookup Failed: " + fieldName); + final Class<?> superClass = clazz.getSuperclass(); + if (superClass == null) { + Logger.REFLECTION("Unable to find field '" + fieldName + "'"); + throw e; + } + Logger.REFLECTION("Method: Recursion Lookup: " + fieldName + " - Checking in " + superClass.getName()); + return getField_Internal(superClass, fieldName); + } + } + + /** + * if (isPresent("com.optionaldependency.DependencyClass")) || This block will never execute when the dependency is + * not present. There is therefore no more risk of code throwing NoClassDefFoundException. + */ + private static boolean isClassPresent(final String className) { + try { + Class.forName(className); + return true; + } catch (final Throwable ex) { + // Class or one of its dependencies is not present... + return false; + } + } + + private static Method getMethod_Internal(Class<?> aClass, String aMethodName, Class<?>... aTypes) { + Method m = null; + try { + Logger.REFLECTION("Method: Internal Lookup: " + aMethodName); + m = aClass.getDeclaredMethod(aMethodName, aTypes); + if (m != null) { + m.setAccessible(true); + } + } catch (Throwable t) { + Logger.REFLECTION("Method: Internal Lookup Failed: " + aMethodName); + try { + m = getMethodRecursively(aClass, aMethodName); + } catch (NoSuchMethodException e) { + Logger.REFLECTION("Unable to find method '" + aMethodName + "'"); + e.printStackTrace(); + dumpClassInfo(aClass); + } + } + 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); + } + } 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); + } + return c; + } catch (final NoSuchMethodException | IllegalArgumentException 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 { + Logger.REFLECTION("Method: Recursion Lookup: " + aMethodName); + Method k = clazz.getDeclaredMethod(aMethodName); + makeMethodAccessible(k); + return k; + } catch (final NoSuchMethodException e) { + final Class<?> superClass = clazz.getSuperclass(); + if (superClass == null || superClass == Object.class) { + throw e; + } + return getMethod_Internal(superClass, aMethodName); + } + } + + 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(); + Field[] fields = aClass.getDeclaredFields(); + Constructor[] consts = aClass.getDeclaredConstructors(); + + Logger.INFO("Dumping all Methods."); + for (Method method : methods) { + System.out + .println(method.getName() + " | " + StringUtils.getDataStringFromArray(method.getParameterTypes())); + } + Logger.INFO("Dumping all Fields."); + for (Field f : fields) { + System.out.println(f.getName()); + } + Logger.INFO("Dumping all Constructors."); + for (Constructor<?> c : consts) { + System.out.println( + c.getName() + " | " + + c.getParameterCount() + + " | " + + StringUtils.getDataStringFromArray(c.getParameterTypes())); + } + } + + private static Class<?> getNonPublicClass(final String className) { + Class<?> c = null; + try { + c = Class.forName(className); + } catch (final ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // full package name --------^^^^^^^^^^ + // or simpler without Class.forName: + // Class<package1.A> c = package1.A.class; + + if (null != c) { + // In our case we need to use + Constructor<?> constructor = null; + try { + constructor = c.getDeclaredConstructor(); + } catch (NoSuchMethodException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // note: getConstructor() can return only public constructors + // so we needed to search for any Declared constructor + + // now we need to make this constructor accessible + if (null != constructor) { + constructor.setAccessible(true); // ABRACADABRA! + + try { + final Object o = constructor.newInstance(); + return (Class<?>) o; + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return null; + } + + private static Class<?> getClass_Internal(String string) { + Class<?> aClass = null; + if (ReflectionUtils.doesClassExist(string)) { + try { + aClass = Class.forName(string); + } catch (ClassNotFoundException e) { + aClass = getNonPublicClass(string); + } + } + + 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); + } + if (aClassName != null && aClassName.length() > 0) { + Logger.REFLECTION("Trying to search '" + aClassName + "' for inner classes."); + Class<?> clazz = ReflectionUtils.getClass(aClassName); + if (clazz != null) { + 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; + } + } + } else { + return null; + } + } else { + return null; + } + } + return aClass; + } + + /** + * + * Set the value of a field reflectively. + */ + private static void setFieldValue_Internal(Object owner, Field field, Object value) throws Exception { + cacheAccessor(field).setValue(owner, value); + } + + public static boolean doesFieldExist(Class<?> clazz, String string) { + if (clazz != null) { + if (ReflectionUtils.getField(clazz, string) != null) { + return true; + } + } + return false; + } + + public static <T> T getFieldValue(Field field) { + return getFieldValue(field, null); + } + + public static <T> T getFieldValue(Field field, Object instance) { + try { + return (T) field.get(instance); + } catch (IllegalArgumentException | IllegalAccessException e) {} + return null; + } + + public static <T> T createNewInstanceFromConstructor(Constructor aConstructor, Object[] aArgs) { + T aInstance; + try { + aInstance = (T) aConstructor.newInstance(aArgs); + if (aInstance != null) { + return aInstance; + } + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + + public static Enum getEnum(Class<Enum> sgtbees, String name) { + if (sgtbees.isEnum()) { + Object[] aValues = sgtbees.getEnumConstants(); + for (Object o : aValues) { + if (o.toString() + .toLowerCase() + .equals(name.toLowerCase())) { + return (Enum) o; + } + } + } + return null; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/sys/KeyboardUtils.java b/src/main/java/gtPlusPlus/core/util/sys/KeyboardUtils.java new file mode 100644 index 0000000000..9c8b471ff6 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/util/sys/KeyboardUtils.java @@ -0,0 +1,37 @@ +package gtPlusPlus.core.util.sys; + +import net.minecraft.client.Minecraft; + +import org.lwjgl.input.Keyboard; + +public class KeyboardUtils { + + public static boolean isCtrlKeyDown() { + try { + if (!Keyboard.isCreated()) { + return false; + } + // prioritize CONTROL, but allow OPTION as well on Mac (note: GuiScreen's isCtrlKeyDown only checks for the + // OPTION key on Mac) + boolean isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) + || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); + if (!isCtrlKeyDown && Minecraft.isRunningOnMac) + isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LMETA) || Keyboard.isKeyDown(Keyboard.KEY_RMETA); + + return isCtrlKeyDown; + } catch (Throwable t) { + return false; + } + } + + public static boolean isShiftKeyDown() { + try { + if (!Keyboard.isCreated()) { + return false; + } + return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + } catch (Throwable t) { + return false; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/world/explosions/ExplosionHandler.java b/src/main/java/gtPlusPlus/core/world/explosions/ExplosionHandler.java new file mode 100644 index 0000000000..fdad398f6f --- /dev/null +++ b/src/main/java/gtPlusPlus/core/world/explosions/ExplosionHandler.java @@ -0,0 +1,31 @@ +package gtPlusPlus.core.world.explosions; + +import net.minecraft.entity.Entity; +import net.minecraft.world.World; + +public class ExplosionHandler { + + /** + * Creates an explosion. Args: entity, x, y, z, strength + */ + public MiningExplosion createExplosion(final World world, final Entity entityObj, final double x, final double y, + final double z, final float size, final boolean makesFlames, final boolean makesSmoke) { + return this.newExplosion(world, entityObj, x, y, z, size, makesFlames, makesSmoke); + } + + /** + * returns a new explosion. + */ + public MiningExplosion newExplosion(final World world, final Entity entityObj, final double x, final double y, + final double z, final float size, final boolean makesFlames, final boolean makesSmoke) { + final MiningExplosion explosion = new MiningExplosion(world, entityObj, x, y, z, size); + explosion.isFlaming = makesFlames; + explosion.isSmoking = makesSmoke; + if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(world, explosion)) { + return explosion; + } + explosion.doExplosionA(); + explosion.doExplosionB(true); + return explosion; + } +} diff --git a/src/main/java/gtPlusPlus/core/world/explosions/MiningExplosion.java b/src/main/java/gtPlusPlus/core/world/explosions/MiningExplosion.java new file mode 100644 index 0000000000..4d5473d349 --- /dev/null +++ b/src/main/java/gtPlusPlus/core/world/explosions/MiningExplosion.java @@ -0,0 +1,442 @@ +package gtPlusPlus.core.world.explosions; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.enchantment.EnchantmentProtection; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +import gregtech.api.objects.XSTR; +import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; +import gtPlusPlus.core.util.math.MathUtils; + +public class MiningExplosion extends Explosion { + + private final int field_77289_h = 16; + private final Random explosionRNG = new XSTR(); + private final World worldObj; + + private final Map<Entity, Vec3> field_77288_k = new HashMap<>(); + + public MiningExplosion(final World worldObj, final Entity entityObj, final double x, final double y, final double z, + final float size) { + super(worldObj, entityObj, x, y, z, size); + this.worldObj = worldObj; + this.exploder = entityObj; + this.explosionSize = size; + this.explosionX = x; + this.explosionY = y; + this.explosionZ = z; + } + + /** + * Does the first part of the explosion (destroy blocks) + */ + @SuppressWarnings("unchecked") + @Override + public void doExplosionA() { + final float f = this.explosionSize; + final HashSet<ChunkPosition> hashset = new HashSet<>(); + int i; + int j; + int k; + double d5; + double d6; + double d7; + + for (i = 0; i < this.field_77289_h; ++i) { + for (j = 0; j < this.field_77289_h; ++j) { + for (k = 0; k < this.field_77289_h; ++k) { + if ((i == 0) || (i == (this.field_77289_h - 1)) + || (j == 0) + || (j == (this.field_77289_h - 1)) + || (k == 0) + || (k == (this.field_77289_h - 1))) { + double d0 = ((i / (this.field_77289_h - 1.0F)) * 2.0F) - 1.0F; + double d1 = ((j / (this.field_77289_h - 1.0F)) * 2.0F) - 1.0F; + double d2 = ((k / (this.field_77289_h - 1.0F)) * 2.0F) - 1.0F; + final double d3 = Math.sqrt((d0 * d0) + (d1 * d1) + (d2 * d2)); + d0 /= d3; + d1 /= d3; + d2 /= d3; + float f1 = this.explosionSize * (0.7F + (this.worldObj.rand.nextFloat() * 0.6F)); + d5 = this.explosionX; + d6 = this.explosionY; + d7 = this.explosionZ; + + for (final float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) { + final int j1 = MathHelper.floor_double(d5); + final int k1 = MathHelper.floor_double(d6); + final int l1 = MathHelper.floor_double(d7); + final Block block = this.worldObj.getBlock(j1, k1, l1); + + if (block.getMaterial() != Material.air) { + final float f3 = this.exploder != null + ? this.exploder.func_145772_a(this, this.worldObj, j1, k1, l1, block) + : block.getExplosionResistance( + this.exploder, + this.worldObj, + j1, + k1, + l1, + this.explosionX, + this.explosionY, + this.explosionZ); + f1 -= (f3 + 0.3F) * f2; + } + + if ((f1 > 0.0F) && ((this.exploder == null) + || this.exploder.func_145774_a(this, this.worldObj, j1, k1, l1, block, f1))) { + hashset.add(new ChunkPosition(j1, k1, l1)); + } + + d5 += d0 * f2; + d6 += d1 * f2; + d7 += d2 * f2; + } + } + } + } + } + + this.affectedBlockPositions.addAll(hashset); + this.explosionSize *= 2.0F; + i = MathHelper.floor_double(this.explosionX - this.explosionSize - 1.0D); + j = MathHelper.floor_double(this.explosionX + this.explosionSize + 1.0D); + k = MathHelper.floor_double(this.explosionY - this.explosionSize - 1.0D); + final int i2 = MathHelper.floor_double(this.explosionY + this.explosionSize + 1.0D); + final int l = MathHelper.floor_double(this.explosionZ - this.explosionSize - 1.0D); + final int j2 = MathHelper.floor_double(this.explosionZ + this.explosionSize + 1.0D); + final List<Entity> list = this.worldObj + .getEntitiesWithinAABBExcludingEntity(this.exploder, AxisAlignedBB.getBoundingBox(i, k, l, j, i2, j2)); + net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.worldObj, this, list, this.explosionSize); + final Vec3 vec3 = Vec3.createVectorHelper(this.explosionX, this.explosionY, this.explosionZ); + + for (final Entity entity : list) { + final double d4 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) + / this.explosionSize; + + if (d4 <= 1.0D) { + d5 = entity.posX - this.explosionX; + d6 = (entity.posY + entity.getEyeHeight()) - this.explosionY; + d7 = entity.posZ - this.explosionZ; + final double d9 = MathHelper.sqrt_double((d5 * d5) + (d6 * d6) + (d7 * d7)); + + if (d9 != 0.0D) { + d5 /= d9; + d6 /= d9; + d7 /= d9; + final double d10 = this.worldObj.getBlockDensity(vec3, entity.boundingBox); + final double d11 = (1.0D - d4) * d10; + entity.attackEntityFrom( + DamageSource.setExplosionSource(this), + ((int) (((((d11 * d11) + d11) / 2.0D) * 8.0D * this.explosionSize) + 1.0D))); + final double d8 = EnchantmentProtection.func_92092_a(entity, d11); + entity.motionX += d5 * d8; + entity.motionY += d6 * d8; + entity.motionZ += d7 * d8; + + if (entity instanceof EntityPlayer) { + this.field_77288_k.put(entity, Vec3.createVectorHelper(d5 * d11, d6 * d11, d7 * d11)); + } + } + } + } + + this.explosionSize = f; + } + + /** + * Does the second part of the explosion (sound, particles, drop spawn) + */ + @Override + public void doExplosionB(final boolean p_77279_1_) { + this.worldObj.playSoundEffect( + this.explosionX, + this.explosionY, + this.explosionZ, + "random.explode", + 4.0F, + (1.0F + ((this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F)) * 0.7F); + + if ((this.explosionSize >= 2.0F) && this.isSmoking) { + this.worldObj + .spawnParticle("hugeexplosion", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "smoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "explode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else { + this.worldObj + .spawnParticle("largeexplode", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "smoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "explode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + + Iterator<ChunkPosition> iterator; + ChunkPosition chunkposition; + int i; + int j; + int k; + Block block; + + if (this.isSmoking) { + iterator = this.affectedBlockPositions.iterator(); + + while (iterator.hasNext()) { + chunkposition = iterator.next(); + i = chunkposition.chunkPosX; + j = chunkposition.chunkPosY; + k = chunkposition.chunkPosZ; + block = this.worldObj.getBlock(i, j, k); + + if (p_77279_1_) { + final double d0 = i + this.worldObj.rand.nextFloat(); + final double d1 = j + this.worldObj.rand.nextFloat(); + final double d2 = k + this.worldObj.rand.nextFloat(); + double d3 = d0 - this.explosionX; + double d4 = d1 - this.explosionY; + double d5 = d2 - this.explosionZ; + final double d6 = MathHelper.sqrt_double((d3 * d3) + (d4 * d4) + (d5 * d5)); + d3 /= d6; + d4 /= d6; + d5 /= d6; + double d7 = 0.5D / ((d6 / this.explosionSize) + 0.1D); + d7 *= (this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat()) + 0.3F; + d3 *= d7; + d4 *= d7; + d5 *= d7; + this.worldObj.spawnParticle( + "explode", + (d0 + (this.explosionX * 1.0D)) / 2.0D, + (d1 + (this.explosionY * 1.0D)) / 2.0D, + (d2 + (this.explosionZ * 1.0D)) / 2.0D, + d3, + d4, + d5); + this.worldObj.spawnParticle("smoke", d0, d1, d2, d3, d4, d5); + this.worldObj.spawnParticle( + "smoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "explode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + + if (block.getMaterial() != Material.air) { + if (block.canDropFromExplosion(this)) { + // world, x, y, z, world.getBlockMetadata(x, y, z), dropProb, 0 + block.dropBlockAsItemWithChance( + this.worldObj, + i, + j, + k, + this.worldObj.getBlockMetadata(i, j, k), + 1F, + 0); + } + + block.onBlockExploded(this.worldObj, i, j, k, this); + } + } + } + + if (this.isFlaming) { + iterator = this.affectedBlockPositions.iterator(); + + while (iterator.hasNext()) { + chunkposition = iterator.next(); + i = chunkposition.chunkPosX; + j = chunkposition.chunkPosY; + k = chunkposition.chunkPosZ; + block = this.worldObj.getBlock(i, j, k); + final Block block1 = this.worldObj.getBlock(i, j - 1, k); + + if ((block.getMaterial() == Material.air) && block1.func_149730_j() + && (this.explosionRNG.nextInt(3) == 0)) { + this.worldObj.setBlock(i, j, k, Blocks.fire); + } + } + } + } + + @Override + public Map<Entity, Vec3> func_77277_b() { + return this.field_77288_k; + } + + /** + * Returns either the entity that placed the explosive block, the entity that caused the explosion or null. + */ + @Override + public EntityLivingBase getExplosivePlacedBy() { + return this.exploder == null ? null + : (this.exploder instanceof EntityPrimedMiningExplosive + ? ((EntityPrimedMiningExplosive) this.exploder).getTntPlacedBy() + : (this.exploder instanceof EntityLivingBase ? (EntityLivingBase) this.exploder : null)); + } +} |