From 2b7ae2001ed8f49d2de8f88ef306426af60c279b Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 4 May 2020 01:32:46 +0100 Subject: $ Fixed handling of Giant Eggs. $ Fixed obscure crash caused by Dingos. $ Fixed handling of Spawn Eggs and entities registered to the global list. $ Potentially fixed NEI not working correctly for GT++ recipe maps. --- .../gtPlusPlus/core/item/general/ItemGiantEgg.java | 351 ++++++++++++--------- .../item/general/spawn/ItemCustomSpawnEgg.java | 285 +++++++++++++++++ 2 files changed, 489 insertions(+), 147 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java (limited to 'src/Java/gtPlusPlus/core/item/general') diff --git a/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java b/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java index d98b27d163..b3338bb681 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java @@ -4,176 +4,223 @@ import static gtPlusPlus.core.lib.CORE.RANDOM; import java.util.List; -import gregtech.api.enums.ItemList; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.entity.item.ItemEntityGiantEgg; -import gtPlusPlus.core.item.base.BaseItemBurnable; +import gtPlusPlus.core.item.base.BaseItemTickable; +import gtPlusPlus.core.item.general.spawn.ItemCustomSpawnEgg; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; -import net.minecraft.creativetab.CreativeTabs; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; -import net.minecraft.util.StatCollector; import net.minecraft.world.World; -public class ItemGiantEgg extends BaseItemBurnable { +public class ItemGiantEgg extends BaseItemTickable { - public ItemGiantEgg(String unlocalizedName, String displayName, CreativeTabs creativeTab, int stackSize, int maxDmg, - String description, String oredictName, int burnTime, int meta) { - super(unlocalizedName, displayName, creativeTab, stackSize, maxDmg, description, oredictName, burnTime, meta); - this.setMaxStackSize(1); - } + private static ItemStack turnsIntoItem; + private static ItemStack mCorrectEgg; + private static ItemStack mCorrectStemCells; - @Override - public String getItemStackDisplayName(ItemStack aStack) { - String localName = super.getItemStackDisplayName(aStack); - nbtWork(aStack); - int size = 1; - if (NBTUtils.hasKey(aStack, "size")){ - size = NBTUtils.getInteger(aStack, "size"); - return ""+size+" "+localName; - } - return "?? "+localName; + public void registerFuel(int burn){ + CORE.burnables.add(new Pair(burn, ItemUtils.getSimpleStack(this, 1))); } - private static ItemStack mCorrectEgg; - private static ItemStack mCorrectStemCells; + public final void registerOrdictionary(String name){ + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(this), name); + } - @Override - public void onUpdate(ItemStack aStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + public ItemGiantEgg() { + this(Utils.rgbtoHexValue(255, 255, 255), Short.MAX_VALUE * Byte.MAX_VALUE, new String[] {"I had best try disassemble this.. for science!"}); + } - if (world.isRemote) { - super.onUpdate(aStack, world, entityHolding, p_77663_4_, p_77663_5_); - return; - } - try { - boolean player = (entityHolding != null && entityHolding instanceof EntityPlayer); + private ItemGiantEgg(int colour, int maxTicks, String[] desc1) { + super(true, false, "itemBigEgg", colour, maxTicks, desc1); + setTextureName(CORE.MODID + ":itemBigEgg"); + this.setMaxStackSize(1); + registerFuel(5000); + registerOrdictionary("fuelLargeChickenEgg"); + } + + public static void postInit(ItemGiantEgg aGiantEggItem) { + ItemGiantEgg.turnsIntoItem = getSpawnEggStack(); + //new DecayableRecipe(aGiantEggItem.maxTicks, getSimpleStack(aGiantEggItem), ItemUtils.getSimpleStack(ItemGiantEgg.turnsIntoItem, 1)); + } - if (player) { - NBTUtils.setBoolean(aStack, "playerHeld", true); - } - else { - NBTUtils.setBoolean(aStack, "playerHeld", false); - } - - nbtWork(aStack); - - int age = NBTUtils.hasKey(aStack, "mAge") ? NBTUtils.getInteger(aStack, "mAge") : 0; - if (player) { - NBTUtils.setInteger(aStack, "mAge", age+1); - - //Set the correct egg for future hatches - if (mCorrectEgg == null) { - if (NBTUtils.hasKey(aStack, "mAge") && NBTUtils.hasKey(aStack, "mEggAge")) { - if (NBTUtils.getInteger(aStack, "mAge") >= NBTUtils.getInteger(aStack, "mEggAge")) { - for (int g=0;g<128;g++) { - ItemStack mSpawn = ItemUtils.simpleMetaStack(Items.spawn_egg, g, 1); - if (mSpawn != null) { - String s = ("" + StatCollector.translateToLocal(mSpawn.getUnlocalizedName() + ".name")).trim(); - String s1 = EntityList.getStringFromID(mSpawn.getItemDamage()); - if (s1 != null){ - s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name"); - if (s1.equalsIgnoreCase("bigChickenFriendly")) { - mCorrectEgg = mSpawn; - break; - } - } - } - } + private static ItemStack getSpawnEggStack() { + //Set the correct egg for future hatches + if (mCorrectEgg == null) { + /*for (int g=0;g= NBTUtils.getInteger(aStack, "mEggAge")) { - if (MathUtils.randInt(0, 1000) >= 990) { - if (NBTUtils.hasKey(aStack, "size")) { - if ((NBTUtils.getInteger(aStack, "size")+1) >= MathUtils.randInt(0, 9)) { - ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((mCorrectEgg)); - ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); - } - else { - ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); - } - } - } - } - } + private static ItemStack getStemCellStack() { + if (mCorrectStemCells == null) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 28) { + ItemStack xl = ItemUtils.getValueOfItemList("Circuit_Chip_Stemcell", 1, ItemUtils.getSimpleStack(Items.egg, 2)); + if (xl != null) { + mCorrectStemCells = xl.copy(); } } + else { + mCorrectStemCells = ItemUtils.getSimpleStack(Items.egg, 2); + } } - catch (Throwable t) { - t.printStackTrace(); - } + return mCorrectStemCells; + } - super.onUpdate(aStack, world, entityHolding, p_77663_4_, p_77663_5_); + protected int getMaxTicks(ItemStack aStack) { + if (aStack != null && aStack.hasTagCompound() && aStack.getTagCompound().hasKey("mEggAge")) { + return NBTUtils.getInteger(aStack, "mEggAge"); + } + return maxTicks; } @Override - public void onCreated(ItemStack p_77622_1_, World p_77622_2_, EntityPlayer p_77622_3_) { - super.onCreated(p_77622_1_, p_77622_2_, p_77622_3_); + public void registerIcons(final IIconRegister i) { + this.mIcon[0] = i.registerIcon(CORE.MODID + ":" + "itemBigEgg"); } - public void nbtWork(ItemStack aStack) { - if (NBTUtils.hasKey(aStack, "playerHeld")) { - boolean player = NBTUtils.getBoolean(aStack, "playerHeld"); - if (player && !NBTUtils.hasKey(aStack, "size")) { - NBTUtils.setInteger(aStack, "size", MathUtils.randInt(1, 8)); + + @Override + protected boolean createNBT(World world, ItemStack aStack){ + + if (aStack.getTagCompound() != null && aStack.getTagCompound().hasKey("size")) { + return false; + } + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(1)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(2)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(3)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(4)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(5)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(6)); + //Logger.INFO("Creating Egg NBT."); + boolean aSuper = super.createNBT(world, aStack); + int size = MathUtils.randInt(1, 8); + NBTUtils.setInteger(aStack, "size", size); + NBTUtils.setInteger(aStack, "mEggAge", ((MathUtils.randInt(8000, 16000)*size))); + ItemStack aStemCells = getStemCellStack(); + if (aStemCells != null) { + int mSize = NBTUtils.getInteger(aStack, "size"); + float mSizeMod = (MathUtils.randInt(-5, 5)/5); + mSize += mSizeMod; + mSize = Math.max(mSize, 1); + ItemStack eggYolks[] = new ItemStack[mSize]; + for (int u=0;u 0) { + NBTUtils.setInteger(aStack, "mExpected", mexpected); + NBTUtils.writeItemsToGtCraftingComponents(aStack, new ItemStack[]{ ItemUtils.getSimpleStack(aStemCells, mexpected)}, true); + } + } + return aSuper; + + } - if (player && NBTUtils.getTagCompound(aStack, "GT.CraftingComponents") == null) { - if (mCorrectStemCells == null) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 28) { - - ItemList xl = ItemUtils.getValueOfItemList("Circuit_Chip_Stemcell", ItemList.Circuit_Elite); - if (xl != null && xl.hasBeenSet()) { - mCorrectStemCells = xl.get(1); - } - } - else { - mCorrectStemCells = ItemUtils.getSimpleStack(Items.egg, 2); - } - } - if (mCorrectStemCells != null) { - int mSize = NBTUtils.getInteger(aStack, "size"); - float mSizeMod = (MathUtils.randInt(-5, 5)/10); - mSize += mSizeMod; - mSize = Math.max(mSize, 1); - ItemStack eggYolks[] = new ItemStack[mSize]; - for (int u=0;u= 990) { + if (NBTUtils.hasKey(iStack, "size")) { + if ((NBTUtils.getInteger(iStack, "size")+1) >= MathUtils.randInt(0, 9)) { + ItemStack replacement = ItemUtils.getSimpleStack(getHatchResult(), 1); + if (replacement == null) { + + } + //Logger.INFO("Replacing "+iStack.getDisplayName()+" with "+replacement.getDisplayName()+"."); + final ItemStack tempTransform = replacement.copy(); + if (iStack.stackSize > 1){ + int u = iStack.stackSize; + tempTransform.stackSize = u; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + for (int l=0;l 0) { - NBTUtils.setInteger(aStack, "mExpected", mexpected); - } - - NBTUtils.writeItemsToGtCraftingComponents(aStack, eggYolks, true); } } - if (player && NBTUtils.getTagCompound(aStack, "GT.CraftingComponents") != null) { + } + } - } - } + public ItemStack getHatchResult() { + return turnsIntoItem; } + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String localName = super.getItemStackDisplayName(aStack); + /*if (aStack.getTagCompound() == null){ + createNBT(null, aStack); + Logger.INFO("Egg has no NBT, creating (getDisplayName)"); + }*/ + int size = 1; + if (NBTUtils.hasKey(aStack, "size")){ + size = NBTUtils.getInteger(aStack, "size"); + return ""+size+" "+localName; + } + return "?? "+localName; + } + + @Override public boolean hasCustomEntity(ItemStack stack) { return true; @@ -181,11 +228,8 @@ public class ItemGiantEgg extends BaseItemBurnable { @Override public Entity createEntity(World world, Entity location, ItemStack itemstack) { - if (location instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) location; - if (itemstack == null) { return null; } @@ -217,27 +261,40 @@ public class ItemGiantEgg extends BaseItemBurnable { @Override public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { int size = 0; - if (NBTUtils.hasKey(stack, "size")){ - size = NBTUtils.getInteger(stack, "size"); - } - int age = 0; - if (NBTUtils.hasKey(stack, "mAge")){ - age = NBTUtils.getInteger(stack, "mAge"); - } - int life = 0; - if (NBTUtils.hasKey(stack, "mEggAge")){ - life = NBTUtils.getInteger(stack, "mEggAge"); - } + long age = 0; + long life = 0; int expected = 0; - if (NBTUtils.hasKey(stack, "mExpected")){ - expected = NBTUtils.getInteger(stack, "mExpected"); + if (this.descriptionString.length > 0) { + list.add(EnumChatFormatting.GRAY+this.descriptionString[0]); } - list.add("Egg Size: "+size+" ounces"); - list.add("Expected Stem Cells: "+expected); - list.add("Age: "+(age/20)+"s"+" / "+(life/20)+"s"); + if (NBTUtils.hasKey(stack, "size")){ + size = NBTUtils.getInteger(stack, "size"); + if (size > 0 && NBTUtils.hasKey(stack, "TickableItem")){ + NBTTagCompound aNBT = stack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + age = aNBT.getLong("Tick"); + } + } + } + if (NBTUtils.hasKey(stack, "mEggAge")){ + life = NBTUtils.getInteger(stack, "mEggAge"); + } + if (NBTUtils.hasKey(stack, "mExpected")){ + expected = NBTUtils.getInteger(stack, "mExpected"); + } + } + String aSize = size > 0 ? ""+size : "??"; + String aExpected = expected > 0 ? ""+expected : "??"; + String aAge = age > 0 ? ""+(age/20) : "??"; + String aLife = life > 0 ? ""+(life/20) : "??"; + list.add("Egg Size: "+aSize+" ounces"); + list.add("Expected Stem Cells: "+aExpected); + list.add("Age: "+aAge+"s"+" / "+aLife+"s"); list.add("Larger eggs take longer to hatch,"); - list.add("but have a better chance of hatching."); - super.addInformation(stack, aPlayer, list, bool); + list.add("but have a better chance of hatching."); + } } diff --git a/src/Java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java b/src/Java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java new file mode 100644 index 0000000000..727b933fa7 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java @@ -0,0 +1,285 @@ +package gtPlusPlus.core.item.general.spawn; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +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.*; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.*; +import net.minecraft.util.*; +import net.minecraft.world.World; + +public class ItemCustomSpawnEgg extends ItemMonsterPlacer { + + private static final HashMap mIconMap = new HashMap(); + private static int mTotalMetaItems = 0; + + private static final HashMap mMaxStackSizeMap = new HashMap(); + private static final HashMap mRarityMap = new HashMap(); + private static final HashMap> mOreDictNames = new HashMap>(); + + private static final HashMap mColourBaseMap = new HashMap(); + private static final HashMap mColourSpotsMap = new HashMap(); + private static final HashMap mEntityNameMap = new HashMap(); + private static final HashMap mEntityFullNameMap = new HashMap(); + + private static final HashMap mReverseEntityMap = new HashMap(); + + protected EntityLiving entityToSpawn = null; + + public static ItemStack getSpawnEggForEntityname(String aEntityName, int aSize) { + return ItemUtils.simpleMetaStack(ModItems.itemCustomSpawnEgg, mReverseEntityMap.get(aEntityName), aSize); + } + + public static void registerEntityForSpawnEgg(final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, int aSecondaryColor) { + registerEntityForSpawnEgg(aMetaID, parEntityToSpawnName, aPrimaryColor, aSecondaryColor, EnumRarity.common, new ArrayList()); + } + + public static void registerEntityForSpawnEgg(final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, int aSecondaryColor, EnumRarity aRarity, final ArrayList 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 static void registerEggsToOreDict() { + for (int aMetaID = 0; aMetaID < mTotalMetaItems; aMetaID++) { + ArrayList aOreDictNames = mOreDictNames.get(aMetaID); + if (aOreDictNames != null && !aOreDictNames.isEmpty()) { + ItemStack aFoodStack = ItemUtils.simpleMetaStack(ModItems.itemCustomSpawnEgg, aMetaID, 1 + ); + for (String aOreName : aOreDictNames) { + ItemUtils.addItemToOreDictionary(aFoodStack, aOreName); + } + } + } + } + + 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 "Spawn " + mEntityNameMap.get(par1ItemStack.getItemDamage()); + } + + + @Override + public void registerIcons(final IIconRegister u) { + mIconMap.put(0, u.registerIcon(CORE.MODID + ":" + "spawn_egg")); + mIconMap.put(1, u.registerIcon(CORE.MODID + ":" + "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, CORE.MODID + "." + parEntityToSpawnName); + } +} -- cgit From 59c6a1bf700132d0f5b7da49f59b05ac8b9f2894 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 27 May 2020 18:33:53 +0100 Subject: + Added recipe for pine saplings. + Added tier info into Chemical Plant NEI handler. + Added custom NEI handlers for Dehydration and Reactor Fuel Processing Plant recipes. % Adjusted output of Fluorite ore production recipes. % Finished Work on Chemical Plant user manual. $ Added another safety catch to the VFC GUI. --- .../gui/machine/GUI_VolumetricFlaskSetter.java | 13 +- src/Java/gtPlusPlus/core/handler/BookHandler.java | 256 ++++-- .../core/item/general/books/ItemBaseBook.java | 8 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 33 +- src/Java/gtPlusPlus/core/util/Utils.java | 12 +- src/Java/gtPlusPlus/nei/GT_NEI_Dehydrator.java | 864 +++++++++++++++++++++ src/Java/gtPlusPlus/nei/GT_NEI_FluidReactor.java | 29 +- src/Java/gtPlusPlus/nei/GT_NEI_RFPP.java | 460 +++++++++++ src/Java/gtPlusPlus/nei/NEI_GT_Config.java | 6 + .../chemplant/GregtechMTE_ChemicalPlant.java | 24 +- 10 files changed, 1611 insertions(+), 94 deletions(-) create mode 100644 src/Java/gtPlusPlus/nei/GT_NEI_Dehydrator.java create mode 100644 src/Java/gtPlusPlus/nei/GT_NEI_RFPP.java (limited to 'src/Java/gtPlusPlus/core/item/general') diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java index b0c1e8b6ff..0257e51d0c 100644 --- a/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java @@ -33,9 +33,11 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { 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); mText.setMaxStringLength(5); + mText.setEnableBackgroundDrawing(true); mText.setText("0"); mText.setFocused(true); } @@ -83,7 +85,10 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { @Override public void onGuiClosed() { mIsOpen = false; + mText.setEnabled(false); + mText.setVisible(false); super.onGuiClosed(); + Keyboard.enableRepeatEvents(false); } public void updateScreen(){ @@ -120,8 +125,10 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { } protected void mouseClicked(int x, int y, int btn) { - super.mouseClicked(x, y, btn); - this.mText.mouseClicked(x, y, btn); + if (mIsOpen) { + super.mouseClicked(x, y, btn); + this.mText.mouseClicked(x, y, btn); + } } @@ -141,7 +148,7 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { 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 diff --git a/src/Java/gtPlusPlus/core/handler/BookHandler.java b/src/Java/gtPlusPlus/core/handler/BookHandler.java index 57d371905f..13c57677a0 100644 --- a/src/Java/gtPlusPlus/core/handler/BookHandler.java +++ b/src/Java/gtPlusPlus/core/handler/BookHandler.java @@ -3,6 +3,8 @@ package gtPlusPlus.core.handler; import java.util.HashMap; import java.util.Map; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.recipe.common.CI; @@ -57,45 +59,45 @@ public class BookHandler { "Power Storage & You [Version 0.64]", "Alkalus", new String[] { - //Page 1 - "So, when it comes to power storage you relaly have three seperate options:\n"+ - " \n"+ - "Battery Buffers,\n"+ - "Energy Buffers,\n"+ - "The Power Sub-Station\n", - //Page 2 - "Battery Buffer\n" + - " \n" + - "Is rather portable. Allowing you to throw set one up and insert batteries where ever you may need."+"\n"+ - "They output 1A for each battery stored inside, upto a maximum of 16A.", - //Page 3 - "Energy Buffer\n" + - " \n" + - "Is a more optimal choice for storage in your base. Once placed down, they cannot be moved without losing all stored power."+"\n"+ - "Energy Buffers can output 4A from the output side, however accept 16A as input.", - //Page 4 - "The Power Sub-Station"+ - " \n"+ - "Is used for storing Insane amounts of power later game."+"\n"+ - "Consumes 2% of the average voltage of all energy type hatches every tick."+"\n", - //Page 5 - "Allows Insertation/Removal of power from the rear face of the controller, swap with a screwdriver."+"\n"+ - "Variable Height Structure, between 4-16Y. Inserted Redox Cells dictate max energy tier of structure."+"\n", - //Page 6 - "Redox Cells cannot be placed into the Top or Bottom layer and only take up 3xhx3 internally."+"\n"+ - "Different Tier cells CANNOT be mixed together."+"\n", - //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."+"\n"+ - "Currently the GUI will NOT display anything at all until the structure forms, this is a known bug."+"\n", - //Page 8 - "Valid Hatches:\n"+ - "Energy Hatch,\n"+ - "Dynamo Hatch,\n"+ - "Charging Bus,\n"+ - "Discharging Bus,\n"+ - "Dynamo Buffer,\n"+ - "Multi-Amp Dynamo Hatch.\n\n\n"+ - "Structure MUST contain at least one energy input and one energy output hatch." + //Page 1 + "So, when it comes to power storage you relaly have three seperate options:\n"+ + " \n"+ + "Battery Buffers,\n"+ + "Energy Buffers,\n"+ + "The Power Sub-Station\n", + //Page 2 + "Battery Buffer\n" + + " \n" + + "Is rather portable. Allowing you to throw set one up and insert batteries where ever you may need."+"\n"+ + "They output 1A for each battery stored inside, upto a maximum of 16A.", + //Page 3 + "Energy Buffer\n" + + " \n" + + "Is a more optimal choice for storage in your base. Once placed down, they cannot be moved without losing all stored power."+"\n"+ + "Energy Buffers can output 4A from the output side, however accept 16A as input.", + //Page 4 + "The Power Sub-Station"+ + " \n"+ + "Is used for storing Insane amounts of power later game."+"\n"+ + "Consumes 2% of the average voltage of all energy type hatches every tick."+"\n", + //Page 5 + "Allows Insertation/Removal of power from the rear face of the controller, swap with a screwdriver."+"\n"+ + "Variable Height Structure, between 4-16Y. Inserted Redox Cells dictate max energy tier of structure."+"\n", + //Page 6 + "Redox Cells cannot be placed into the Top or Bottom layer and only take up 3xhx3 internally."+"\n"+ + "Different Tier cells CANNOT be mixed together."+"\n", + //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."+"\n"+ + "Currently the GUI will NOT display anything at all until the structure forms, this is a known bug."+"\n", + //Page 8 + "Valid Hatches:\n"+ + "Energy Hatch,\n"+ + "Dynamo Hatch,\n"+ + "Charging Bus,\n"+ + "Discharging Bus,\n"+ + "Dynamo Buffer,\n"+ + "Multi-Amp Dynamo Hatch.\n\n\n"+ + "Structure MUST contain at least one energy input and one energy output hatch." }); //Test Novel @@ -103,7 +105,7 @@ public class BookHandler { "Manual_Modular_Bauble", "How to: Modular Baubles", "Alkalus", new String[] { "Concept: This idea came from wanting flexibility. \n" + - "First step, Build a Modularity table to begin customisation of your Bauble. \n" + "First step, Build a Modularity table to begin customisation of your Bauble. \n" + " After this has been constructed, you can now combine the upgrades listed within this book to improve the baubles level/100.", "Defence:\n" + "Can be upgraded by combining metal plates with the bauble. \n" @@ -128,7 +130,7 @@ public class BookHandler { "[Fluid Work] Mode B - 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 C - 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[] { @@ -178,20 +180,167 @@ public class BookHandler { "Processing Plant"+ "----------------------\n"+ "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[] { - "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 A - 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 B - 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 C - 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.", + + // 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" + "\n" + + "Machine Casings = Hatch tier" + "\n" + + "Higher tier coils More Speed" + "\n" + + "T1 50% , T2 100% , T3 150%, etc" + "\n", + + "Higher tier pipe casings boost parallel"+ "\n" + + "and reduce catalyst consumption" + "\n" + + "+2 parallel per tier, 20% extra chance of"+ "\n" + + "not damaging catalyst per tier" + "\n", + + + // Machine Casings + "Valid Solid Machine Casings:" + "\n" + + "0 - Strong Bronze" + "\n" + + "1 - Solid Steel" + "\n" + + "2 - Sturdy Aluminium" + "\n" + + "3 - Clean Stainless Steel" + "\n" + + "4 - Stable Titanium" + "\n" + + "5 - Robust Tungstensteel" + "\n" + + "6 - Vigorous Laurenium" + "\n" + + "7 - 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:" + "\n" + "\n" + + "1 - Bronze" + "\n" + + "2 - Steel" + "\n" + + "3 - Titanium" + "\n" + + "4 - Tungstensteel", + + //Coils + "Valid Coils:" + "\n" + "\n" + + "1 - Cupronickel" + "\n" + + "2 - Kanthal" + "\n" + + "3 - Nichrome" + "\n" + + "4 - Tungstensteel" + "\n" + + "5 - HSS-G" + "\n" + + "6 - Naquadah" + "\n" + + "7 - Naquadah Alloy", + + // Requirements + "Multiblock Requirements:" + "\n" + "\n" + + "27x Coils" + "\n" + + "18x Pipe Casings" + "\n" + + "57x Tiered Machine Casings" + "\n" + + "80+ Solid Casings", + + // Construction Guide + "Construction Guide Pt1:" + "\n" + "\n" + + "Controller is placed on a middle casing in the bottom layer" + "\n" + + "Hatches can only be placed on the bottom layer edges", + + "Construction Guide Pt2:" + "\n" + "\n" + + "7x7x7 Hollow frame of solid casings" + "\n" + + "5x1x5 layer of solid casings (fills in top layer)" + "\n" + + "5x1x5 layer of machine casings (fills in bottom layer)", + + "Construction Guide Pt3:" + "\n" + + "In the central 3x5x3:" + "\n" + + "3x1x3 layer of Coils, surrounded by ring of Machine Casings" + "\n" + + "3x1x3 layer of Pipe Casings" + "\n" + + "3x1x3 layer of Coils" + "\n" + + "3x1x3 layer of Pipe Casings" + "\n" + + "3x1x3 layer of Coils, surrounded by ring of Machine Casings", + + // Construction Guide Info + "Information:" + "\n" + "\n" + + "A = Air" + "\n" + + "X = Solid Casing" + "\n" + + "M = Machine Casing" + "\n" + + "P = Pipe Casing" + "\n" + + "C = Coil Casing", + + "Layer 1:" + "\n" + "\n" + + "XXXXXXX" + "\n" + + "XMMMMMX" + "\n" + + "XMMMMMX" + "\n" + + "XMMMMMX" + "\n" + + "XMMMMMX" + "\n" + + "XMMMMMX" + "\n" + + "XXXXXXX", + + "Layer 2:" + "\n" + "\n" + + "AAAAAAA" + "\n" + + "AMMMMMA" + "\n" + + "AMCCCMA" + "\n" + + "AMCCCMA" + "\n" + + "AMCCCMA" + "\n" + + "AMMMMMA" + "\n" + + "AAAAAAA", + + "Layer 3:" + "\n" + "\n" + + "AAAAAAA" + "\n" + + "AAAAAAA" + "\n" + + "AAPPPAA" + "\n" + + "AAPPPAA" + "\n" + + "AAPPPAA" + "\n" + + "AAAAAAA" + "\n" + + "AAAAAAA", + + "Layer 4:" + "\n" + "\n" + + "AAAAAAA" + "\n" + + "AAAAAAA" + "\n" + + "AACCCAA" + "\n" + + "AACCCAA" + "\n" + + "AACCCAA" + "\n" + + "AAAAAAA" + "\n" + + "AAAAAAA", + + "Layer 5:" + "\n" + "\n" + + "AAAAAAA" + "\n" + + "AAAAAAA" + "\n" + + "AAPPPAA" + "\n" + + "AAPPPAA" + "\n" + + "AAPPPAA" + "\n" + + "AAAAAAA" + "\n" + + "AAAAAAA", + + "Layer 6:" + "\n" + "\n" + + "AAAAAAA" + "\n" + + "AMMMMMA" + "\n" + + "AMCCCMA" + "\n" + + "AMCCCMA" + "\n" + + "AMCCCMA" + "\n" + + "AMMMMMA" + "\n" + + "AAAAAAA", + + "Layer 7:" + "\n" + "\n" + + "XXXXXXX" + "\n" + + "XXXXXXX" + "\n" + + "XXXXXXX" + "\n" + + "XXXXXXX" + "\n" + + "XXXXXXX" + "\n" + + "XXXXXXX" + "\n" + + "XXXXXXX", }); - + } @@ -218,6 +367,13 @@ public class BookHandler { 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 "+aPages[i]); GT_Log.err.println(new StringBuilder().append("WARNING: String for written Book too long! -> ") .append(aPages[i]).toString()); } } else { + Logger.INFO("WARNING: Too much Pages for written Book! -> "+aTitle); GT_Log.err.println(new StringBuilder().append("WARNING: Too much Pages for written Book! -> ") .append(aTitle).toString()); break; } } tNBTList.appendTag(new NBTTagString(new StringBuilder().append("Credits to ").append(aAuthor) - .append(" for writing this Book. This was Book Nr. ").append(sBookCount) + .append(" for writing this Book. This was Book Nr. ").append(aID) .append(" at its creation. Gotta get 'em all!").toString())); tNBT.setTag("pages", tNBTList); rStack.setTagCompound(tNBT); diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_Dehydrator.java b/src/Java/gtPlusPlus/nei/GT_NEI_Dehydrator.java new file mode 100644 index 0000000000..8a7d4fae64 --- /dev/null +++ b/src/Java/gtPlusPlus/nei/GT_NEI_Dehydrator.java @@ -0,0 +1,864 @@ +package gtPlusPlus.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.common.event.FMLInterModComms; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerInputHandler; +import codechicken.nei.guihook.IContainerTooltipHandler; +import codechicken.nei.recipe.*; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_NEI_Dehydrator +extends TemplateRecipeHandler { + public static final int sOffsetX = 5; + public static final int sOffsetY = 11; + + static { + GuiContainerManager.addInputHandler(new GT_RectHandler()); + GuiContainerManager.addTooltipHandler(new GT_RectHandler()); + } + + protected final GT_Recipe_Map mRecipeMap; + + public GT_NEI_Dehydrator() { + this.mRecipeMap = GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes; + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), this.getOverlayIdentifier(), new Object[0])); + if (!NEI_GT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtechplusplus@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + public static void drawText(final int aX, final int aY, final String aString, final int aColor) { + Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GT_NEI_Dehydrator(); + } + + @Override + public void loadCraftingRecipes(final String outputId, final Object... results) { + if (outputId.equals(this.getOverlayIdentifier())) { + for (final GT_Recipe tRecipe : this.mRecipeMap.mRecipeList) { + if (!tRecipe.mHidden) { + this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(final ItemStack aResult) { + final ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + final ArrayList tResults = new ArrayList(); + tResults.add(aResult); + tResults.add(GT_OreDictUnificator.get(true, aResult)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (final OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + final FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); + if (tFluid != null) { + tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (final FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tResults.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (final GT_Recipe tRecipe : this.mRecipeMap.mRecipeList) { + if (!tRecipe.mHidden) { + final CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (final ItemStack tStack : tResults) { + if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + } + + @Override + public void loadUsageRecipes(final ItemStack aInput) { + final ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + + final ArrayList tInputs = new ArrayList(); + tInputs.add(aInput); + tInputs.add(GT_OreDictUnificator.get(false, aInput)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (final OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + final FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); + if (tFluid != null) { + tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (final FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tInputs.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (final GT_Recipe tRecipe : this.mRecipeMap.mRecipeList) { + if (!tRecipe.mHidden) { + final CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (final ItemStack tStack : tInputs) { + if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + } + + @Override + public String getOverlayIdentifier() { + return this.mRecipeMap.mNEIName; + } + + @Override + public void drawBackground(final int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 78); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public String getRecipeName() { + return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + } + + @Override + public String getGuiTexture() { + // return "gregtech:textures/gui/" + this.mRecipeMap.mUnlocalizedName + ".png"; + return this.mRecipeMap.mNEIGUIPath; + } + + @Override + public List handleItemTooltip(final GuiRecipe gui, final ItemStack aStack, final List currenttip, final int aRecipeIndex) { + final TemplateRecipeHandler.CachedRecipe tObject = this.arecipes.get(aRecipeIndex); + if ((tObject instanceof CachedDefaultRecipe)) { + final CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; + for (final PositionedStack tStack : tRecipe.mOutputs) { + if (aStack == tStack.item) { + if ((!(tStack instanceof FixedPositionedStack)) || (((FixedPositionedStack) tStack).mChance <= 0) || (((FixedPositionedStack) tStack).mChance == 10000)) { + break; + } + currenttip.add("Chance: " + (((FixedPositionedStack) tStack).mChance / 100) + "." + ((((FixedPositionedStack) tStack).mChance % 100) < 10 ? "0" + (((FixedPositionedStack) tStack).mChance % 100) : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + break; + } + } + for (final PositionedStack tStack : tRecipe.mInputs) { + if (aStack == tStack.item) { + if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || + (tStack.item.stackSize != 0)) { + break; + } + currenttip.add("Does not get consumed in the process"); + break; + } + } + } + return currenttip; + } + + @Override + public void drawExtras(final int aRecipeIndex) { + final int tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + final int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + if (tEUt != 0) { + drawText(10, 73, "Total: " + (tDuration * tEUt) + " EU", -16777216); + drawText(10, 83, "Usage: " + tEUt + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 93, "Voltage: " + (tEUt / this.mRecipeMap.mAmperage) + " EU", -16777216); + drawText(10, 103, "Amperage: " + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, "Voltage: unspecified", -16777216); + drawText(10, 103, "Amperage: unspecified", -16777216); + } + } + if (tDuration > 0) { + drawText(10, 113, "Time: " + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + " secs", -16777216); + } + if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + } + } + + public static class GT_RectHandler + implements IContainerInputHandler, IContainerTooltipHandler { + @Override + public boolean mouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + if (this.canHandle(gui)) { + if (button == 0) { + return this.transferRect(gui, false); + } + if (button == 1) { + return this.transferRect(gui, true); + } + } + return false; + } + + @Override + public boolean lastKeyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + public boolean canHandle(final GuiContainer gui) { + return (((gui instanceof GT_GUIContainer_BasicMachine)) && (GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI)) /*|| ((gui instanceof GT_GUIContainer_FusionReactor)) && (GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI))*/); + } + + @Override + public List handleTooltip(final GuiContainer gui, final int mousex, final int mousey, final List currenttip) { + if ((this.canHandle(gui)) && (currenttip.isEmpty())) { + if ((gui instanceof GT_GUIContainer_BasicMachine) && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } /*else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + }*/ + + } + return currenttip; + } + + private boolean transferRect(final GuiContainer gui, final boolean usage) { + if (gui instanceof GT_GUIContainer_BasicMachine) { + return (this.canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0])); + } /*else if (gui instanceof GT_GUIContainer_FusionReactor) { + return (canHandle(gui)) && (new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0])); + }*/ + return false; + } + + @Override + public List handleItemDisplayName(final GuiContainer gui, final ItemStack itemstack, final List currenttip) { + return currenttip; + } + + @Override + public List handleItemTooltip(final GuiContainer gui, final ItemStack itemstack, final int mousex, final int mousey, final List currenttip) { + return currenttip; + } + + @Override + public boolean keyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + @Override + public void onKeyTyped(final GuiContainer gui, final char keyChar, final int keyID) { + } + + @Override + public void onMouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public void onMouseUp(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public boolean mouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + return false; + } + + @Override + public void onMouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + } + + @Override + public void onMouseDragged(final GuiContainer gui, final int mousex, final int mousey, final int button, final long heldTime) { + } + } + + public class FixedPositionedStack + extends PositionedStack { + public final int mChance; + public boolean permutated = false; + + public FixedPositionedStack(final Object object, final int x, final int y) { + this(object, x, y, 0); + } + + public FixedPositionedStack(final Object object, final int x, final int y, final int aChance) { + super(object, x, y, true); + this.mChance = aChance; + } + + @Override + public void generatePermutations() { + if (this.permutated) { + return; + } + final ArrayList tDisplayStacks = new ArrayList(); + for (final ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + final List permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (final Iterator i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = i$.next(); + } + } else { + final ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = (tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + this.setPermutationToRender(0); + } + } + + public class CachedDefaultRecipe + extends TemplateRecipeHandler.CachedRecipe { + public final GT_Recipe mRecipe; + public final List mOutputs = new ArrayList(); + public final List mInputs = new ArrayList(); + + public CachedDefaultRecipe(final GT_Recipe aRecipe) { + super(); + this.mRecipe = aRecipe; + + int tStartIndex = 0; + switch (GT_NEI_Dehydrator.this.mRecipeMap.mUsualInputCount) { + case 0: + break; + case 1: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 2: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 3: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 4: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 5: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 6: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 7: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + break; + case 8: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 32)); + } + tStartIndex++; + break; + default: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 32)); + } + tStartIndex++; + } + if (aRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + switch (GT_NEI_Dehydrator.this.mRecipeMap.mUsualOutputCount) { + case 0: + break; + case 1: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 2: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 3: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 4: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 5: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 6: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 7: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 8: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + default: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + } + + + //New fluid display behaviour when 3 fluid inputs are detected. (Basically a mix of the code below for outputs an the code above for 9 input slots.) + if (aRecipe.mFluidInputs.length > 2) { + if ((aRecipe.mFluidInputs[0] != null) && (aRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[0], true), 12, 5)); + } + if ((aRecipe.mFluidInputs[1] != null) && (aRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[1], true), 30, 5)); + } + if ((aRecipe.mFluidInputs.length > 2) && (aRecipe.mFluidInputs[2] != null) && (aRecipe.mFluidInputs[2].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[2], true), 48, 5)); + } + if ((aRecipe.mFluidInputs.length > 3) && (aRecipe.mFluidInputs[3] != null) && (aRecipe.mFluidInputs[3].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[3], true), 12, 23)); + } + if ((aRecipe.mFluidInputs.length > 4) && (aRecipe.mFluidInputs[4] != null) && (aRecipe.mFluidInputs[4].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[4], true), 30, 23)); + } + if ((aRecipe.mFluidInputs.length > 5) && (aRecipe.mFluidInputs[5] != null) && (aRecipe.mFluidInputs[5].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[5], true), 48, 23)); + } + if ((aRecipe.mFluidInputs.length > 6) && (aRecipe.mFluidInputs[6] != null) && (aRecipe.mFluidInputs[6].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[6], true), 12, 41)); + } + if ((aRecipe.mFluidInputs.length > 7) && (aRecipe.mFluidInputs[7] != null) && (aRecipe.mFluidInputs[7].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[7], true), 30, 41)); + } + if ((aRecipe.mFluidInputs.length > 8) && (aRecipe.mFluidInputs[8] != null) && (aRecipe.mFluidInputs[8].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[8], true), 48, 41)); + } + } + //Returns to old behaviour if fluid inputs < 3 + else if ((aRecipe.mFluidInputs.length > 0) && (aRecipe.mFluidInputs[0] != null) && (aRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[0], true), 48, 52)); + if ((aRecipe.mFluidInputs.length == 2) && (aRecipe.mFluidInputs[1] != null) && (aRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[1], true), 30, 52)); + } + } + + if (aRecipe.mFluidOutputs.length > 1) { + if ((aRecipe.mFluidOutputs[0] != null) && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 102, 5)); + } + if ((aRecipe.mFluidOutputs[1] != null) && (aRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[1], true), 120, 5)); + } + if ((aRecipe.mFluidOutputs.length > 2) && (aRecipe.mFluidOutputs[2] != null) && (aRecipe.mFluidOutputs[2].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[2], true), 138, 5)); + } + if ((aRecipe.mFluidOutputs.length > 3) && (aRecipe.mFluidOutputs[3] != null) && (aRecipe.mFluidOutputs[3].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[3], true), 102, 23)); + } + if ((aRecipe.mFluidOutputs.length > 4) && (aRecipe.mFluidOutputs[4] != null) && (aRecipe.mFluidOutputs[4].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[4], true), 120, 23)); + } + if ((aRecipe.mFluidOutputs.length > 5) && (aRecipe.mFluidOutputs[5] != null) && (aRecipe.mFluidOutputs[5].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[5], true), 138, 23)); + } + if ((aRecipe.mFluidOutputs.length > 6) && (aRecipe.mFluidOutputs[6] != null) && (aRecipe.mFluidOutputs[6].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[6], true), 102, 41)); + } + if ((aRecipe.mFluidOutputs.length > 7) && (aRecipe.mFluidOutputs[7] != null) && (aRecipe.mFluidOutputs[7].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[7], true), 120, 41)); + } + if ((aRecipe.mFluidOutputs.length > 8) && (aRecipe.mFluidOutputs[8] != null) && (aRecipe.mFluidOutputs[8].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[8], true), 138, 41)); + } + } else if ((aRecipe.mFluidOutputs.length > 0) && (aRecipe.mFluidOutputs[0] != null) && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 102, 5)); + } + } + + @Override + public List getIngredients() { + return this.getCycledIngredients(GT_NEI_Dehydrator.this.cycleticks / 10, this.mInputs); + } + + @Override + public PositionedStack getResult() { + return null; + } + + @Override + public List getOtherStacks() { + return this.mOutputs; + } + } +} diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_FluidReactor.java b/src/Java/gtPlusPlus/nei/GT_NEI_FluidReactor.java index 57e6e1a899..213d022478 100644 --- a/src/Java/gtPlusPlus/nei/GT_NEI_FluidReactor.java +++ b/src/Java/gtPlusPlus/nei/GT_NEI_FluidReactor.java @@ -242,7 +242,34 @@ extends TemplateRecipeHandler { drawText(10, 103, "Time: " + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + " secs", -16777216); } if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { - drawText(10, 113, this.mRecipeMap.mNEISpecialValuePre + (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + int aTier = (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue); + String aTierMaterial = " - "; + if (aTier <= 0) { + aTierMaterial += "Bronze"; + } + else if (aTier == 1) { + aTierMaterial += "Steel"; + } + else if (aTier == 2) { + aTierMaterial += "Aluminium"; + } + else if (aTier == 3) { + aTierMaterial += "Stainless Steel"; + } + else if (aTier == 4) { + aTierMaterial += "Titanium"; + } + else if (aTier == 5) { + aTierMaterial += "Tungsten Steel"; + } + else if (aTier == 6) { + aTierMaterial += "Laurenium"; + } + else if (aTier == 7) { + aTierMaterial += "Botmium"; + } + + drawText(10, 113, this.mRecipeMap.mNEISpecialValuePre + (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + aTierMaterial, -16777216); } } diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_RFPP.java b/src/Java/gtPlusPlus/nei/GT_NEI_RFPP.java new file mode 100644 index 0000000000..c91d2bb47a --- /dev/null +++ b/src/Java/gtPlusPlus/nei/GT_NEI_RFPP.java @@ -0,0 +1,460 @@ +package gtPlusPlus.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.*; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerInputHandler; +import codechicken.nei.guihook.IContainerTooltipHandler; +import codechicken.nei.recipe.*; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_NEI_RFPP +extends TemplateRecipeHandler { + public static final int sOffsetX = 5; + public static final int sOffsetY = 11; + + static { + GuiContainerManager.addInputHandler(new GT_RectHandler()); + GuiContainerManager.addTooltipHandler(new GT_RectHandler()); + } + + protected CustomRecipeMap mRecipeMap; + + public GT_NEI_RFPP() { + this.mRecipeMap = CustomRecipeMap.sFissionFuelProcessing; + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), this.getRecipeMapName(), new Object[0])); + if (!NEI_GT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtechplusplus@" + this.getRecipeName() + "@" + this.getRecipeMapName()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + public List getSortedRecipes() { + List result = new ArrayList(this.mRecipeMap.mRecipeList); + Collections.sort(result); + return result; + } + + public static void drawText(final int aX, final int aY, final String aString, final int aColor) { + Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GT_NEI_RFPP(); + } + + @Override + public void loadCraftingRecipes(final String outputId, final Object... results) { + if (outputId.equals(getRecipeMapName())) { + for (GTPP_Recipe tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(final ItemStack aResult) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + ArrayList tResults = new ArrayList(); + tResults.add(aResult); + tResults.add(GT_OreDictUnificator.get(true, aResult)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); + if (tFluid != null) { + tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tResults.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (GTPP_Recipe tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (ItemStack tStack : tResults) { + if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + //CachedDefaultRecipe tNEIRecipe; + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + + ArrayList tInputs = new ArrayList(); + tInputs.add(aInput); + tInputs.add(GT_OreDictUnificator.get(false, aInput)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); + if (tFluid != null) { + tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tInputs.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (GTPP_Recipe tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (ItemStack tStack : tInputs) { + if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + //CachedDefaultRecipe tNEIRecipe; + } + + public String getRecipeMapName() { + return this.mRecipeMap.mNEIName; + } + + @Override + public String getOverlayIdentifier() { + return this.mRecipeMap.mNEIName; + } + + @Override + public void drawBackground(final int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 78); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public String getRecipeName() { + return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + } + + @Override + public String getGuiTexture() { + return this.mRecipeMap.mNEIGUIPath; + } + + @Override + public List handleItemTooltip(final GuiRecipe gui, final ItemStack aStack, final List currenttip, final int aRecipeIndex) { + final TemplateRecipeHandler.CachedRecipe tObject = this.arecipes.get(aRecipeIndex); + if ((tObject instanceof CachedDefaultRecipe)) { + final CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; + for (final PositionedStack tStack : tRecipe.mOutputs) { + if (aStack == tStack.item) { + if ((!(tStack instanceof FixedPositionedStack)) || (((FixedPositionedStack) tStack).mChance <= 0) || (((FixedPositionedStack) tStack).mChance == 10000)) { + break; + } + currenttip.add("Chance: " + (((FixedPositionedStack) tStack).mChance / 100) + "." + ((((FixedPositionedStack) tStack).mChance % 100) < 10 ? "0" + (((FixedPositionedStack) tStack).mChance % 100) : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + break; + } + } + for (final PositionedStack tStack : tRecipe.mInputs) { + if (GT_Utility.areStacksEqual(aStack, tStack.item)) { + if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || + (tStack.item.stackSize != 0)) { + break; + } + if (ItemUtils.isControlCircuit(aStack)) { + currenttip.add("Does not get consumed in the process"); + } + break; + } + } + } + return currenttip; + } + + @Override + public void drawExtras(final int aRecipeIndex) { + final long tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + final int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + if (tEUt != 0) { + drawText(10, 73, "Total: " + (long) (tDuration * tEUt) + " EU", -16777216); + //drawText(10, 83, "Usage: " + tEUt + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 83, "Voltage: " + (tEUt / this.mRecipeMap.mAmperage) + " EU/t", -16777216); + drawText(10, 93, "Amperage: " + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, "Voltage: unspecified", -16777216); + drawText(10, 103, "Amperage: unspecified", -16777216); + } + } + if (tDuration > 0) { + drawText(10, 103, "Time: " + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + " secs", -16777216); + } + //if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + //drawText(10, 113, this.mRecipeMap.mNEISpecialValuePre + (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + //} + } + + public static class GT_RectHandler + implements IContainerInputHandler, IContainerTooltipHandler { + @Override + public boolean mouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + if (this.canHandle(gui)) { + if (button == 0) { + return this.transferRect(gui, false); + } + if (button == 1) { + return this.transferRect(gui, true); + } + } + return false; + } + + @Override + public boolean lastKeyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + public boolean canHandle(final GuiContainer gui) { + return (((gui instanceof GT_GUIContainer_BasicMachine)) && (GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI)) /*|| ((gui instanceof GT_GUIContainer_FusionReactor)) && (GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI))*/); + } + + @Override + public List handleTooltip(final GuiContainer gui, final int mousex, final int mousey, final List currenttip) { + if ((this.canHandle(gui)) && (currenttip.isEmpty())) { + if ((gui instanceof GT_GUIContainer_BasicMachine) && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } /*else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + }*/ + + } + return currenttip; + } + + private boolean transferRect(final GuiContainer gui, final boolean usage) { + if (gui instanceof GT_GUIContainer_BasicMachine) { + return (this.canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0])); + } /*else if (gui instanceof GT_GUIContainer_FusionReactor) { + return (canHandle(gui)) && (new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0])); + }*/ + return false; + } + + @Override + public List handleItemDisplayName(final GuiContainer gui, final ItemStack itemstack, final List currenttip) { + return currenttip; + } + + @Override + public List handleItemTooltip(final GuiContainer gui, final ItemStack itemstack, final int mousex, final int mousey, final List currenttip) { + return currenttip; + } + + @Override + public boolean keyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + @Override + public void onKeyTyped(final GuiContainer gui, final char keyChar, final int keyID) { + } + + @Override + public void onMouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public void onMouseUp(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public boolean mouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + return false; + } + + @Override + public void onMouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + } + + @Override + public void onMouseDragged(final GuiContainer gui, final int mousex, final int mousey, final int button, final long heldTime) { + } + } + + public class FixedPositionedStack + extends PositionedStack { + public final int mChance; + public boolean permutated = false; + + public FixedPositionedStack(final Object object, final int x, final int y) { + this(object, x, y, 0); + } + + public FixedPositionedStack(final Object object, final int x, final int y, final int aChance) { + super(object, x, y, true); + this.mChance = aChance; + } + + @Override + public void generatePermutations() { + if (this.permutated) { + return; + } + final ArrayList tDisplayStacks = new ArrayList(); + for (final ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + final List permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (final Iterator i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = i$.next(); + } + } else { + final ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = (tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + this.setPermutationToRender(0); + } + } + + public class CachedDefaultRecipe + extends TemplateRecipeHandler.CachedRecipe { + public final GT_Recipe mRecipe; + public final List mOutputs = new ArrayList(); + public final List mInputs = new ArrayList(); + + public CachedDefaultRecipe(final GT_Recipe aRecipe) { + super(); + this.mRecipe = aRecipe; + + int tStartIndex = 0; + + + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + + if (aRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + + //Four Output Slots + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + + if ((aRecipe.mFluidInputs.length > 0) && (aRecipe.mFluidInputs[0] != null) && (aRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[0], true), 30, 52)); + if ((aRecipe.mFluidInputs.length > 1) && (aRecipe.mFluidInputs[1] != null) && (aRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[1], true), 48, 52)); + } + } + + if (aRecipe.mFluidOutputs.length > 0) { + if ((aRecipe.mFluidOutputs[0] != null) && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 102, 52)); + } + if ((aRecipe.mFluidOutputs.length > 1) && (aRecipe.mFluidOutputs[1] != null) && (aRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[1], true), 120, 52)); + } + } + } + + @Override + public List getIngredients() { + return this.getCycledIngredients(GT_NEI_RFPP.this.cycleticks / 10, this.mInputs); + } + + @Override + public PositionedStack getResult() { + return null; + } + + @Override + public List getOtherStacks() { + return this.mOutputs; + } + } +} diff --git a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java index 40826168d2..e89ec9a13b 100644 --- a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java +++ b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java @@ -19,9 +19,11 @@ implements IConfigureNEI { @Override public synchronized void loadConfig() { + mUniqueRecipeMapHandling.add(CustomRecipeMap.sFissionFuelProcessing.mUnlocalizedName); mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sChemicalPlantRecipes.mUnlocalizedName); mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sOreMillRecipes.mUnlocalizedName); mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sFlotationCellRecipes.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sChemicalDehydratorRecipes.mUnlocalizedName); mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sVacuumFurnaceRecipes.mUnlocalizedName); // Custom Recipe Maps @@ -78,6 +80,10 @@ implements IConfigureNEI { new GT_NEI_FlotationCell(); Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe.GTPP_Recipe_Map.sVacuumFurnaceRecipes.mNEIName); new GT_NEI_VacFurnace(); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.mNEIName); + new GT_NEI_Dehydrator(); + Logger.INFO("NEI Registration: Registering NEI handler for "+CustomRecipeMap.sFissionFuelProcessing.mNEIName); + new GT_NEI_RFPP(); Logger.INFO("NEI Registration: Registering NEI handler for "+DecayableRecipeHandler.mNEIName); API.registerRecipeHandler(new DecayableRecipeHandler()); API.registerUsageHandler(new DecayableRecipeHandler()); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index 0883647c3d..4b1acf6494 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -108,28 +108,8 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return new String[] { "Controller Block for the Chemical Plant", "Heavy Industry, now right at your doorstep!", - "Solid Casings dictate Chemical Plant tier", - "Machine Casings dictate Hatch tier", - "Higher tier coils speed up the machine", - "CuNi 50% , FeAlCr 100% , Ni4Cr 150% , ...", - "Higher tier pipe casings boost parallel and reduce catalyst consumption", - "+2 parallel per tier, 20% extra chance of not damaging catalyst per tier", - "27x Coils", - "18x Pipe Casings", - "57x Tiered Machine Casings", - "80+ Solid Casings", - "Construction Guide:", - "Controller is placed on a middle casing in the bottom layer", - "Hatches can only be placed on the bottom layer edges", - "7x7x7 Hollow frame of solid casings", - "5x1x5 layer of solid casings (fills in top layer)", - "5x1x5 layer of machine casings (fills in bottom layer)", - "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", + "Please read to user manual for more information on construction & usage", + TAG_HIDE_MAINT }; } -- cgit From 132faf38b856454007e97f4a8837133f496c64e3 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 29 May 2020 21:23:28 +0100 Subject: + Added low tier basic turbines for Pollution Scrubbers. + Added capability for Scrubbers to be automated. --- src/Java/gtPlusPlus/core/item/ModItems.java | 57 ++---- .../item/general/ItemBasicScrubberTurbine.java | 147 +++++++++++++++ .../core/slots/SlotPollutionScrubber.java | 66 +++++++ .../api/gui/basic/CONTAINER_PollutionCleaner.java | 207 ++++++++------------- .../api/gui/basic/GUI_PollutionCleaner.java | 16 +- .../GregtechMetaAtmosphericReconditioner.java | 49 ++++- src/resources/assets/miscutils/lang/en_US.lang | 7 +- .../miscutils/textures/items/itemBasicTurbine.png | Bin 0 -> 475 bytes 8 files changed, 356 insertions(+), 193 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java create mode 100644 src/Java/gtPlusPlus/core/slots/SlotPollutionScrubber.java create mode 100644 src/resources/assets/miscutils/textures/items/itemBasicTurbine.png (limited to 'src/Java/gtPlusPlus/core/item/general') diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 963d6203cc..1e0b779bac 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -4,21 +4,15 @@ import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; import static gtPlusPlus.core.lib.CORE.LOAD_ALL_CONTENT; import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.util.GT_OreDictUnificator; -import gregtech.common.items.GT_VolumetricFlask; 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.BaseEuItem; -import gtPlusPlus.core.item.base.BaseItemBackpack; +import gtPlusPlus.core.item.base.*; 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.foil.BaseItemFoil; import gtPlusPlus.core.item.base.foods.BaseItemFood; import gtPlusPlus.core.item.base.foods.BaseItemHotFood; @@ -29,34 +23,12 @@ import gtPlusPlus.core.item.base.misc.BaseItemMisc; import gtPlusPlus.core.item.base.misc.BaseItemMisc.MiscTypes; import gtPlusPlus.core.item.base.plates.BaseItemPlate; import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; -import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; -import gtPlusPlus.core.item.bauble.HealthBoostBauble; -import gtPlusPlus.core.item.bauble.ModularBauble; -import gtPlusPlus.core.item.bauble.MonsterKillerBaseBauble; -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.bauble.*; +import gtPlusPlus.core.item.chemistry.*; import gtPlusPlus.core.item.crafting.ItemDummyResearch; import gtPlusPlus.core.item.effects.RarityUncommon; import gtPlusPlus.core.item.food.BaseItemMetaFood; -import gtPlusPlus.core.item.general.BaseItemGrindle; -import gtPlusPlus.core.item.general.BufferCore; -import gtPlusPlus.core.item.general.ItemAirFilter; -import gtPlusPlus.core.item.general.ItemAreaClear; -import gtPlusPlus.core.item.general.ItemBasicFirestarter; -import gtPlusPlus.core.item.general.ItemBlueprint; -import gtPlusPlus.core.item.general.ItemControlCore; -import gtPlusPlus.core.item.general.ItemEmpty; -import gtPlusPlus.core.item.general.ItemGemShards; -import gtPlusPlus.core.item.general.ItemGenericToken; -import gtPlusPlus.core.item.general.ItemGiantEgg; -import gtPlusPlus.core.item.general.ItemHalfCompleteCasings; -import gtPlusPlus.core.item.general.ItemLavaFilter; +import gtPlusPlus.core.item.general.*; import gtPlusPlus.core.item.general.books.ItemBaseBook; import gtPlusPlus.core.item.general.capture.ItemEntityCatcher; import gtPlusPlus.core.item.general.chassis.ItemBoilerChassis; @@ -74,20 +46,12 @@ import gtPlusPlus.core.item.tool.misc.SandstoneHammer; import gtPlusPlus.core.item.tool.misc.box.AutoLunchBox; import gtPlusPlus.core.item.tool.misc.box.MagicToolBag; import gtPlusPlus.core.item.tool.misc.box.UniversalToolBox; -import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; -import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase; -import gtPlusPlus.core.item.tool.staballoy.StaballoyAxe; -import gtPlusPlus.core.item.tool.staballoy.StaballoyPickaxe; +import gtPlusPlus.core.item.tool.staballoy.*; import gtPlusPlus.core.item.wearable.WearableLoader; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.material.ALLOY; -import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.material.MISC_MATERIALS; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.material.MaterialGenerator; -import gtPlusPlus.core.material.NONMATERIAL; +import gtPlusPlus.core.material.*; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.material.nuclear.NUCLIDE; import gtPlusPlus.core.recipe.common.CI; @@ -106,11 +70,8 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; +import net.minecraft.item.*; import net.minecraft.item.Item.ToolMaterial; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fluids.Fluid; @@ -300,6 +261,7 @@ public final class ModItems { public static Item itemSugarCoke; public static Item itemCircuitLFTR; + public static Item itemBasicTurbine; public static Item itemDebugAreaClear; @@ -757,6 +719,9 @@ public final class ModItems { //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. diff --git a/src/Java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java b/src/Java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java new file mode 100644 index 0000000000..bd8159eb01 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java @@ -0,0 +1,147 @@ +package gtPlusPlus.core.item.general; +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; + +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 gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +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(CORE.MODID + ":" + "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 < 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 "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); + } + 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 2500; + } + if (aMeta == 1) { + return 5000; + } + } + 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; + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/slots/SlotPollutionScrubber.java b/src/Java/gtPlusPlus/core/slots/SlotPollutionScrubber.java new file mode 100644 index 0000000000..6dd3745d09 --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotPollutionScrubber.java @@ -0,0 +1,66 @@ +package gtPlusPlus.core.slots; + +import java.util.HashMap; + +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.item.general.ItemAirFilter; +import gtPlusPlus.core.item.general.ItemBasicScrubberTurbine; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotPollutionScrubber extends Slot { + + private final int mType; + private final int mTier; + + private static HashMap mConveyorMap = new HashMap(); + + static { + for (int i=0; i<(CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? 9 : 5); i++) { + mConveyorMap.put(i, CI.getConveyor(i, 1)); + } + } + + public SlotPollutionScrubber(final int aType, final int aTier, final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + mType = aType; + mTier = aTier; + } + + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(this, itemstack); + } + + public static synchronized boolean isItemValidForSlot(final SlotPollutionScrubber aSlot, final ItemStack itemstack) { + if (aSlot.mType == 0) { + if (itemstack.getItem() instanceof ItemBasicScrubberTurbine) { + return true; + } + if (itemstack.getItem() instanceof GT_MetaGenerated_Tool && itemstack.getItemDamage() >= 170 && itemstack.getItemDamage() <= 179){ + return true; + } + } + else if (aSlot.mType == 1) { + if (itemstack.getItem() instanceof ItemAirFilter) { + return true; + } + } + else if (aSlot.mType == 2) { + ItemStack aConveyorStack = mConveyorMap.get(aSlot.mTier); + if (GT_Utility.areStacksEqual(itemstack, aConveyorStack, true)) { + return true; + } + } + return false; + } + + @Override + public int getSlotStackLimit() { + return 1; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java index e3365935aa..79d1033bd0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java @@ -14,6 +14,8 @@ import net.minecraft.item.ItemStack; import gregtech.api.gui.*; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.slots.SlotPollutionScrubber; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaAtmosphericReconditioner; /** @@ -23,132 +25,81 @@ import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaA */ public class CONTAINER_PollutionCleaner extends GT_Container_BasicTank { - public boolean mFluidTransfer = false, mItemTransfer = false, mStuttering = false; - public int mReduction = 0; - - public CONTAINER_PollutionCleaner(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 26, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 107, 63)); - - int tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getInputSlot(); - - switch (((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mInputSlotCount) { - case 2: //Pollution Scrubber - //Add 2 Item Slots - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 107, 25)); - break; - default: - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 43)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 43)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 43)); - break; - } - - tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getOutputSlot(); - - switch (((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mOutputItems.length) { - case 0: - break; - default: - break; - } - - addSlotToContainer(new Slot(mTileEntity, 1, 80, 63)); - addSlotToContainer(new Slot(mTileEntity, 3, 125, 63)); - //addSlotToContainer(new GT_Slot_Render(mTileEntity, tStartIndex++, 53, 63)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - switch (aSlotIndex) { - case 0: - if (mTileEntity.getMetaTileEntity() == null) return null; - ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mFluidTransfer = !((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mFluidTransfer; - return null; - case 1: - if (mTileEntity.getMetaTileEntity() == null) return null; - ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mItemTransfer = !((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mItemTransfer; - return null; - default: - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; - - mFluidTransfer = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mFluidTransfer; - mItemTransfer = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mItemTransfer; - mStuttering = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mStuttering; - mReduction = ((GregtechMetaAtmosphericReconditioner) mTileEntity.getMetaTileEntity()).mPollutionReduction; - - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 102, mFluidTransfer ? 1 : 0); - var1.sendProgressBarUpdate(this, 103, mItemTransfer ? 1 : 0); - var1.sendProgressBarUpdate(this, 104, mStuttering ? 1 : 0); - var1.sendProgressBarUpdate(this, 105, mReduction); - } - } - - @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: - mFluidTransfer = (par2 != 0); - break; - case 103: - mItemTransfer = (par2 != 0); - break; - case 104: - mStuttering = (par2 != 0); - break; - case 105: - mReduction = (par2); - break; - } - } - - @Override - public int getSlotStartIndex() { - return 3; - } - - @Override - public int getShiftClickStartIndex() { - return 3; - } - - @Override - public int getSlotCount() { - return getShiftClickSlotCount() + ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mOutputItems.length + 2; - } - - @Override - public int getShiftClickSlotCount() { - return ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mInputSlotCount; - } + public boolean mFluidTransfer = false, mItemTransfer = false, mStuttering = false; + public int mReduction = 0; + + public CONTAINER_PollutionCleaner(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + + int tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getInputSlot(); + int aTier = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mTier; + + + //Add 2 Item Slots + addSlotToContainer(new SlotPollutionScrubber(0, aTier, mTileEntity, tStartIndex++, 53, 25)); + addSlotToContainer(new SlotPollutionScrubber(1, aTier, mTileEntity, tStartIndex++, 107, 25)); + // Upgrade Slot + addSlotToContainer(new SlotPollutionScrubber(2, aTier, mTileEntity, tStartIndex++, 125, 63)); + + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + Logger.INFO("Clicked on slot "+aSlotIndex); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + + mReduction = ((GregtechMetaAtmosphericReconditioner) mTileEntity.getMetaTileEntity()).mPollutionReduction; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 105, mReduction); + } + } + + @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 105: + mReduction = (par2); + break; + } + } + + @Override + public int getSlotStartIndex() { + return 0; + } + + @Override + public int getShiftClickStartIndex() { + return 0; + } + + @Override + public int getSlotCount() { + return getShiftClickSlotCount(); + } + + @Override + public int getShiftClickSlotCount() { + return 3; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java index 2c1601cee2..7a9417eeb6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java @@ -3,16 +3,10 @@ package gtPlusPlus.xmod.gregtech.api.gui.basic; import java.util.ArrayList; import java.util.List; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ControlCore; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaAtmosphericReconditioner; +import net.minecraft.entity.player.InventoryPlayer; public class GUI_PollutionCleaner extends GT_GUIContainerMetaTile_Machine { public final String mName; @@ -48,13 +42,7 @@ public class GUI_PollutionCleaner extends GT_GUIContainerMetaTile_Machine { final int x3 = x2 - xStart; final int y3 = y2 - yStart + 5; final List list = new ArrayList(); - if (y3 >= 67 && y3 <= 84) { - if (x3 >= 7 && x3 <= 24) { - list.add("Fluid Auto-Output"); - } - if (x3 >= 25 && x3 <= 42) { - list.add("Item Auto-Output"); - } + if (y3 >= 67 && y3 <= 84) { if (x3 >= 77 && x3 <= 95) { //Do Dumb shit CONTAINER_PollutionCleaner aContainerCast = (CONTAINER_PollutionCleaner) this.mContainer; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index 04d37e8c1e..89997d7be8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -21,6 +21,7 @@ import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.item.general.ItemAirFilter; +import gtPlusPlus.core.item.general.ItemBasicScrubberTurbine; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; @@ -90,7 +91,8 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi "Can be configured with a soldering iron to change modes", "Low Efficiency: Removes half pollution, Turbine takes 50% dmg", "High Efficiency: Removes full pollution, Turbine takes 100% dmg", - "Turbine Rotor will not break in LE mode", + "Turbine Rotor will not break in LE mode", + "Insert an equal tier Conveyor Module to enable automation" }; if (!mPollutionEnabled) { String[] B = new String[] { @@ -367,6 +369,9 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi public boolean hasRotor(ItemStack rotorStack){ if(rotorStack != null){ + if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { + return true; + } if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool && rotorStack.getItemDamage() >= 170 && rotorStack.getItemDamage() <= 179){ return true; } @@ -392,6 +397,25 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi } } + if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { + long currentUse = ItemBasicScrubberTurbine.getFilterDamage(rotorStack); + //Remove broken Filter + if (rotorStack.getItemDamage() == 0 && currentUse >= 2500-10){ + this.mInventory[this.SLOT_FILTER] = null; + return false; + } + else if (rotorStack.getItemDamage() == 1 && currentUse >= 5000-10){ + this.mInventory[this.SLOT_FILTER] = null; + return false; + } + else { + //Do Damage + ItemAirFilter.setFilterDamage(rotorStack, currentUse+10); + Logger.WARNING("Rotor Damage: "+currentUse); + return true; + } + } + if(mInventory[SLOT_ROTOR].getItem() instanceof GT_MetaGenerated_Tool_01 && ((GT_MetaGenerated_Tool) mInventory[SLOT_ROTOR].getItem()).getToolStats(mInventory[SLOT_ROTOR]).getSpeedMultiplier()>0 && GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[SLOT_ROTOR]).mToolSpeed>0 ) { @@ -646,10 +670,27 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi @Override public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - if (aIndex == 4){ - return false; + Logger.INFO("Trying to Insert into "+aIndex); + if (aIndex == 5) { + if (aStack.getItem() instanceof ItemAirFilter) { + return true; + } } - return super.canInsertItem(aIndex, aStack, aSide); + if (aIndex == 4 || aIndex == 6){ + if (aIndex == 4) { + if (this.mInventory[5] != null) { + Logger.INFO("Found conveyor, can automate turbines."); + if (aStack.getItem() instanceof ItemBasicScrubberTurbine) { + return true; + } + if (aStack.getItem() instanceof GT_MetaGenerated_Tool && aStack.getItemDamage() >= 170 && aStack.getItemDamage() <= 179){ + return true; + } + } + } + } + //return super.canInsertItem(aIndex, aStack, aSide); + return false; } @Override diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index 2d79aa5cba..ac1d849dc2 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -3229,4 +3229,9 @@ item.itemRotorBotmium.name=Botmium Rotor item.itemGearBotmium.name=Botmium Gear item.itemCellBotmium.name=Botmium Cell tile.Block of Botmium.name=Block of Botmium -tile.Botmium Frame Box.name=Botmium Frame Box \ No newline at end of file +tile.Botmium Frame Box.name=Botmium Frame Box + +//Added 29/05/20 +item.itemBasicTurbine.name=Basic Turbine +item.itemBasicTurbine_0.name=Basic Iron Turbine +item.itemBasicTurbine_1.name=Basic Bronze Turbine \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/items/itemBasicTurbine.png b/src/resources/assets/miscutils/textures/items/itemBasicTurbine.png new file mode 100644 index 0000000000..62de905fb9 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/itemBasicTurbine.png differ -- cgit