Search in sources :

Example 1 with ArrayListNoNulls

use of gregapi.code.ArrayListNoNulls in project gregtech6 by GregTech6.

the class GT_API_Proxy method onWorldTick.

@SubscribeEvent
public void onWorldTick(WorldTickEvent aEvent) {
    if (aEvent.side.isServer() && aEvent.phase == Phase.END) {
        ArrayListNoNulls<EntityXPOrb> tOrbs = (XP_ORB_COMBINING && SERVER_TIME % 40 == 31 ? new ArrayListNoNulls<EntityXPOrb>(128) : null);
        for (int i = 0; i < aEvent.world.loadedEntityList.size(); i++) {
            Entity aEntity = (Entity) aEvent.world.loadedEntityList.get(i);
            if (aEntity == null || aEntity.isDead)
                continue;
            if (aEntity instanceof EntityXPOrb) {
                if (tOrbs != null)
                    tOrbs.add((EntityXPOrb) aEntity);
            } else if (aEntity instanceof EntityItem) {
                ItemStack aStack = ((EntityItem) aEntity).getEntityItem();
                if (ST.valid(aStack)) {
                    ItemStack rStack = ST.copy(aStack);
                    boolean tBreak = F, tFireProof = F;
                    // TODO make a case for Armor too whenever I decide to even add Armor.
                    if (rStack.getItem() instanceof MultiItemTool) {
                        if (MultiItemTool.getPrimaryMaterial(aStack).contains(TD.Properties.UNBURNABLE))
                            tFireProof = T;
                        if (MultiItemTool.getSecondaryMaterial(aStack).contains(TD.Properties.UNBURNABLE))
                            tFireProof = T;
                    }
                    OreDictItemData aData = OM.anydata_(rStack);
                    if (aData != null) {
                        if (aData.hasValidPrefixData())
                            for (IOreDictListenerItem tListener : aData.mPrefix.mListenersItem) {
                                rStack = tListener.onTickWorld(aData.mPrefix, aData.mMaterial.mMaterial, rStack, (EntityItem) aEntity);
                                if (!ST.equal(rStack, aStack) || rStack.stackSize != aStack.stackSize) {
                                    tBreak = T;
                                    break;
                                }
                            }
                        if (!tBreak && aData.hasValidMaterialData())
                            for (OreDictMaterialStack tMaterial : aData.getAllMaterialStacks()) {
                                if (tBreak)
                                    break;
                                if (tMaterial.mMaterial.contains(TD.Properties.UNBURNABLE))
                                    tFireProof = T;
                                for (IOreDictListenerItem tListener : tMaterial.mMaterial.mListenersItem) {
                                    rStack = tListener.onTickWorld(aData.mPrefix, tMaterial.mMaterial, rStack, (EntityItem) aEntity);
                                    if (!ST.equal(rStack, aStack) || rStack.stackSize != aStack.stackSize) {
                                        tBreak = T;
                                        break;
                                    }
                                }
                            }
                    }
                    if (rStack == null || rStack.stackSize <= 0) {
                        ((EntityItem) aEntity).setEntityItemStack(NI);
                        ((EntityItem) aEntity).setDead();
                    } else if (!ST.equal(rStack, aStack) || rStack.stackSize != aStack.stackSize) {
                        ((EntityItem) aEntity).setEntityItemStack(rStack);
                        ((EntityItem) aEntity).delayBeforeCanPickup = 40;
                    }
                    if (!aEntity.isDead && aEntity.isBurning() && (tBreak || (tFireProof && !MD.MC.owns(rStack)))) {
                        UT.Reflection.setField(EntityItem.class, aEntity, "health", 250, F);
                        UT.Reflection.setField(EntityItem.class, aEntity, "field_70291_e", 250, F);
                        aEntity.extinguish();
                    }
                }
            } else if (aEntity instanceof EntityLivingBase) {
                if (ENTITY_CRAMMING > 0 && SERVER_TIME % 50 == 0 && !(aEntity instanceof EntityPlayer) && ((EntityLivingBase) aEntity).canBePushed() && ((EntityLivingBase) aEntity).getHealth() > 0) {
                    List<?> tList = aEntity.worldObj.getEntitiesWithinAABBExcludingEntity(aEntity, aEntity.boundingBox.expand(0.2, 0.0, 0.2));
                    Class<? extends Entity> tClass = aEntity.getClass();
                    int aEntityCount = 1;
                    if (tList != null)
                        for (int j = 0; j < tList.size(); j++) if (tList.get(j) != null && tList.get(j).getClass() == tClass)
                            aEntityCount++;
                    if (aEntityCount > ENTITY_CRAMMING)
                        aEntity.attackEntityFrom(DamageSource.inWall, (aEntityCount - ENTITY_CRAMMING) * TFC_DAMAGE_MULTIPLIER);
                }
            }
        }
        if (tOrbs != null && tOrbs.size() > 32)
            for (EntityXPOrb aOrb : tOrbs) {
                if (aOrb.xpValue >= Short.MAX_VALUE)
                    continue;
                if (aOrb.xpValue <= 0) {
                    aOrb.xpValue = 0;
                    aOrb.setDead();
                    continue;
                }
                for (EntityXPOrb tOrb : tOrbs) if (aOrb != tOrb && !tOrb.isDead && tOrb.xpValue > 0 && tOrb.xpValue < Short.MAX_VALUE && aOrb.getDistanceSqToEntity(tOrb) <= 3) {
                    aOrb.xpOrbAge = Math.min(aOrb.xpOrbAge, tOrb.xpOrbAge);
                    if (aOrb.xpValue + tOrb.xpValue > Short.MAX_VALUE) {
                        tOrb.xpValue -= (Short.MAX_VALUE - aOrb.xpValue);
                        aOrb.xpValue = Short.MAX_VALUE;
                        break;
                    }
                    aOrb.xpValue += tOrb.xpValue;
                    tOrb.xpValue = 0;
                    tOrb.setDead();
                    break;
                }
            }
        if (SERVER_TIME % 20 == 1) {
            checkSaveLocation(aEvent.world.getSaveHandler().getWorldDirectory(), T);
            for (int i = 0; i < aEvent.world.loadedTileEntityList.size(); i++) {
                TileEntity aTileEntity = (TileEntity) aEvent.world.loadedTileEntityList.get(i);
                if (aTileEntity instanceof ITileEntityNeedsSaving)
                    WD.mark(aTileEntity);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PrefixBlockTileEntity(gregapi.block.prefixblock.PrefixBlockTileEntity) Entity(net.minecraft.entity.Entity) OreDictItemData(gregapi.oredict.OreDictItemData) OreDictMaterialStack(gregapi.oredict.OreDictMaterialStack) PacketDeathPoint(gregapi.network.packets.PacketDeathPoint) ArrayListNoNulls(gregapi.code.ArrayListNoNulls) TileEntity(net.minecraft.tileentity.TileEntity) PrefixBlockTileEntity(gregapi.block.prefixblock.PrefixBlockTileEntity) MultiItemTool(gregapi.item.multiitem.MultiItemTool) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityItem(net.minecraft.entity.item.EntityItem) IOreDictListenerItem(gregapi.oredict.listeners.IOreDictListenerItem) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 2 with ArrayListNoNulls

use of gregapi.code.ArrayListNoNulls in project gregtech6 by GregTech6.

the class GT_API_Proxy_Client method onItemTooltip.

@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent aEvent) {
    if (Abstract_Mod.sFinalized < Abstract_Mod.sModCountUsingGTAPI || ST.invalid(aEvent.itemStack))
        return;
    if (!DISPLAY_TEMP_TOOLTIP) {
        DISPLAY_TEMP_TOOLTIP = T;
        return;
    }
    try {
        if (UT.NBT.getNBT(aEvent.itemStack).getBoolean("gt.err.oredict.output")) {
            aEvent.toolTip.clear();
            aEvent.toolTip.add(0, LH.Chat.BLINKING_RED + "A Recipe used an OreDict Item as Output directly, without copying it before!");
            aEvent.toolTip.add(1, LH.Chat.BLINKING_RED + "This is a typical CallByReference/CallByValue Error of the Modder doing it.");
            aEvent.toolTip.add(2, LH.Chat.BLINKING_RED + "Please check all Recipes outputting this Item, and report the Recipes to their Owner.");
            aEvent.toolTip.add(3, LH.Chat.BLINKING_RED + "The Owner of the RECIPE, NOT the Owner of the Item!");
            return;
        }
        String aRegName = ST.regName(aEvent.itemStack);
        if (aRegName == null) {
            aEvent.toolTip.set(0, LH.Chat.BLINKING_RED + "ERROR: THIS ITEM HAS NOT BEEN REGISTERED!!!");
            aRegName = "ERROR: THIS ITEM HAS NOT BEEN REGISTERED!!!";
        }
        short aMeta = ST.meta_(aEvent.itemStack);
        byte aBlockMeta = UT.Code.bind4(aMeta);
        Block aBlock = ST.block(aEvent.itemStack);
        Item aItem = ST.item(aEvent.itemStack);
        if (aEvent.itemStack.getTagCompound() == null) {
            if (aBlock == Blocks.dirt && aBlockMeta == 1) {
                aEvent.toolTip.set(0, aEvent.toolTip.get(0).replaceAll("Dirt", "Coarse Dirt"));
            }
            if (MD.RC.mLoaded && "Railcraft:part.plate".equalsIgnoreCase(aRegName)) {
                switch(aMeta) {
                    case 0:
                        aEvent.toolTip.set(0, LH.Chat.WHITE + LH.get("oredict.plateIron.name"));
                        break;
                    case 1:
                        aEvent.toolTip.set(0, LH.Chat.WHITE + LH.get("oredict.plateSteel.name"));
                        break;
                    case 2:
                        aEvent.toolTip.set(0, LH.Chat.WHITE + LH.get("oredict.plateTinAlloy.name"));
                        break;
                    case 3:
                        aEvent.toolTip.set(0, LH.Chat.WHITE + LH.get("oredict.plateCopper.name"));
                        break;
                    case 4:
                        aEvent.toolTip.set(0, LH.Chat.WHITE + LH.get("oredict.plateLead.name"));
                        break;
                }
            }
        }
        if (MD.Mek.owns(aRegName)) {
            aEvent.toolTip.set(0, aEvent.toolTip.get(0).replaceAll("Osmium", MT.Ge.mNameLocal));
        }
        if (ItemsGT.RECIPE_REMOVED_USE_TRASH_BIN_INSTEAD.contains(aEvent.itemStack, T)) {
            aEvent.toolTip.add(LH.Chat.BLINKING_RED + "Recipe has been removed in favour of the GregTech Ender Garbage Bin");
        }
        ICover tCover = CoverRegistry.get(aEvent.itemStack);
        if (tCover != null)
            tCover.addToolTips(aEvent.toolTip, aEvent.itemStack, aEvent.showAdvancedItemTooltips);
        if (aBlock != NB) {
            if (IL.TC_Warded_Glass.equal(aEvent.itemStack, F, T)) {
                aEvent.toolTip.add(LH.getToolTipBlastResistance(aBlock, 999));
            } else if (ItemsGT.SHOW_RESISTANCE.contains(aEvent.itemStack, T)) {
                if (IL.ICBM_Concrete.block() == aBlock) {
                    switch(aMeta) {
                        default:
                            aEvent.toolTip.add(LH.getToolTipBlastResistance(aBlock, 30));
                            break;
                        case 1:
                            aEvent.toolTip.add(LH.getToolTipBlastResistance(aBlock, 38));
                            break;
                        case 2:
                            aEvent.toolTip.add(LH.getToolTipBlastResistance(aBlock, 48));
                            break;
                    }
                } else {
                    aEvent.toolTip.add(LH.getToolTipBlastResistance(aBlock, aBlock.getExplosionResistance(null)));
                }
                aEvent.toolTip.add(LH.getToolTipHarvest(aBlock.getMaterial(), aBlock.getHarvestTool(aBlockMeta), aBlock.getHarvestLevel(aBlockMeta)));
            }
            if (BlocksGT.openableCrowbar.contains(aBlock)) {
                aEvent.toolTip.add(LH.Chat.DGRAY + LH.get(LH.TOOL_TO_OPEN_CROWBAR));
            }
        }
        if (BooksGT.BOOK_REGISTER.containsKey(aEvent.itemStack, T)) {
            aEvent.toolTip.add(LH.Chat.DGRAY + LH.get(LH.TOOLTIP_SHELFABLE));
        }
        if (Sandwiches.INGREDIENTS.containsKey(aEvent.itemStack, T)) {
            aEvent.toolTip.add(LH.Chat.DGRAY + LH.get(LH.TOOLTIP_SANDWICHABLE));
        }
        if (aItem.isBeaconPayment(aEvent.itemStack)) {
            aEvent.toolTip.add(LH.Chat.DGRAY + LH.get(LH.TOOLTIP_BEACON_PAYMENT));
        }
        OreDictItemData tData = OM.anydata_(aEvent.itemStack);
        if (!(aItem instanceof ItemFluidDisplay) && SHOW_INTERNAL_NAMES) {
            if (tData != null && tData.hasValidPrefixMaterialData()) {
                if (tData.mBlackListed) {
                    if (ST.isGT(aItem))
                        aEvent.toolTip.add(LH.Chat.ORANGE + tData.toString());
                    else
                        aEvent.toolTip.add(LH.Chat.DCYAN + aRegName + LH.Chat.WHITE + " - " + LH.Chat.CYAN + aMeta + LH.Chat.WHITE + " - " + LH.Chat.ORANGE + tData.toString());
                } else {
                    if (ST.isGT(aItem))
                        aEvent.toolTip.add(LH.Chat.GREEN + tData.toString());
                    else
                        aEvent.toolTip.add(LH.Chat.DCYAN + aRegName + LH.Chat.WHITE + " - " + LH.Chat.CYAN + aMeta + LH.Chat.WHITE + " - " + LH.Chat.GREEN + tData.toString());
                }
            } else {
                if (!ST.isGT(aItem))
                    aEvent.toolTip.add(LH.Chat.DCYAN + aRegName + LH.Chat.WHITE + " - " + LH.Chat.CYAN + aMeta);
            }
        }
        if (tData != null) {
            if (tData.hasValidPrefixData()) {
                for (IOreDictListenerItem tListener : tData.mPrefix.mListenersItem) {
                    String tToolTip = tListener.getListenerToolTip(tData.mPrefix, tData.mMaterial.mMaterial, aEvent.itemStack);
                    if (tToolTip != null)
                        aEvent.toolTip.add(tToolTip);
                }
            } else {
                if (IL.RC_Firestone_Refined.equal(aEvent.itemStack, T, T))
                    aEvent.toolTip.add(LH.Chat.CYAN + "Works in Burning Boxes (" + (800 * EU_PER_LAVA) + " HU per Lava Block)");
                else if (IL.RC_Firestone_Cracked.equal(aEvent.itemStack, T, T))
                    aEvent.toolTip.add(LH.Chat.CYAN + "Works in Burning Boxes (" + (600 * EU_PER_LAVA) + " HU per Lava Block)");
                else if (IL.TF_Pick_Giant.equal(aEvent.itemStack, T, T))
                    aEvent.toolTip.add(LH.Chat.CYAN + "Can be repaired with Knightmetal Ingots on the Anvil");
                else if (IL.TF_Sword_Giant.equal(aEvent.itemStack, T, T))
                    aEvent.toolTip.add(LH.Chat.CYAN + "Can be repaired with Ironwood Ingots on the Anvil");
                else if (IL.TF_Lamp_of_Cinders.equal(aEvent.itemStack, T, T))
                    aEvent.toolTip.add(LH.Chat.CYAN + "Can be used as a Lighter for GT6 things and TNT");
            }
            if (tData.hasValidMaterialData()) {
                boolean tUnburnable = F;
                for (OreDictMaterialStack tMaterial : tData.getAllMaterialStacks()) {
                    if (tMaterial.mMaterial.contains(TD.Properties.UNBURNABLE))
                        tUnburnable = T;
                    for (IOreDictListenerItem tListener : tMaterial.mMaterial.mListenersItem) {
                        String tToolTip = tListener.getListenerToolTip(tData.mPrefix, tData.mMaterial.mMaterial, aEvent.itemStack);
                        if (tToolTip != null)
                            aEvent.toolTip.add(tToolTip);
                    }
                }
                if (tData.mMaterial.mMaterial.mToolTypes > 0 && (tData.mPrefix != null || (aEvent.itemStack.getMaxStackSize() > 1 && tData.mByProducts.length == 0 && tData.mMaterial.mAmount <= U))) {
                    aEvent.toolTip.add(LH.Chat.BLUE + "Q: " + tData.mMaterial.mMaterial.mToolQuality + " - S: " + tData.mMaterial.mMaterial.mToolSpeed + " - D: " + tData.mMaterial.mMaterial.mToolDurability);
                }
                if (SHOW_CHEM_FORMULAS && UT.Code.stringValid(tData.mMaterial.mMaterial.mTooltipChemical) && (tData.mPrefix == null ? tData.mByProducts.length == 0 : tData.mPrefix.contains(TD.Prefix.TOOLTIP_MATERIAL))) {
                    aEvent.toolTip.add(LH.Chat.YELLOW + tData.mMaterial.mMaterial.mTooltipChemical);
                }
                if (tData.mMaterial.mMaterial == MT.Nikolite) {
                    aEvent.toolTip.set(0, aEvent.toolTip.get(0).replaceAll("(Teslatite|Electrotine)", MT.Nikolite.mNameLocal));
                }
                if (tData.mMaterial.mMaterial == MT.Ge) {
                    aEvent.toolTip.set(0, aEvent.toolTip.get(0).replaceAll("Osmium", MT.Ge.mNameLocal));
                }
                if (tData.hasValidPrefixData()) {
                    if (tData.mPrefix == OP.dustTiny && ANY.Blaze.mToThis.contains(tData.mMaterial.mMaterial)) {
                        aEvent.toolTip.set(0, aEvent.toolTip.get(0).replaceAll(tData.mMaterial.mMaterial.mNameLocal, OP.dustTiny.mMaterialPre + tData.mMaterial.mMaterial.mNameLocal));
                    }
                    if (tData.mPrefix.contains(TD.Prefix.NEEDS_SHARPENING))
                        aEvent.toolTip.add(LH.Chat.CYAN + LH.get(LH.TOOLTIP_NEEDS_SHARPENING));
                    if (tData.mPrefix.contains(TD.Prefix.NEEDS_HANDLE))
                        aEvent.toolTip.add(LH.Chat.CYAN + LH.get(LH.TOOLTIP_NEEDS_HANDLE) + LH.Chat.WHITE + tData.mMaterial.mMaterial.mHandleMaterial.getLocal());
                    ArrayListNoNulls<Integer> tShapelessAmounts = new ArrayListNoNulls<>();
                    for (AdvancedCrafting1ToY tHandler : tData.mPrefix.mShapelessManagersSingle) if (tHandler.hasOutputFor(tData.mMaterial.mMaterial))
                        tShapelessAmounts.add(1);
                    for (AdvancedCraftingXToY tHandler : tData.mPrefix.mShapelessManagers) if (tHandler.hasOutputFor(tData.mMaterial.mMaterial))
                        tShapelessAmounts.add(tHandler.mInputCount);
                    if (!tShapelessAmounts.isEmpty()) {
                        Collections.sort(tShapelessAmounts);
                        aEvent.toolTip.add(LH.Chat.CYAN + LH.get(LH.TOOLTIP_SHAPELESS_CRAFT) + LH.Chat.WHITE + tShapelessAmounts);
                    }
                    if (tData.mPrefix.contains(TD.Prefix.TOOLTIP_ENCHANTS)) {
                        if (!tData.mMaterial.mMaterial.mEnchantmentTools.isEmpty()) {
                            if (!tData.mPrefix.contains(TD.Prefix.AMMO_ALIKE)) {
                                if (tData.mMaterial.mMaterial.mEnchantmentTools.size() <= 5) {
                                    aEvent.toolTip.add(LH.Chat.PURPLE + LH.get(LH.TOOLTIP_POSSIBLE_TOOL_ENCHANTS));
                                    for (ObjectStack<Enchantment> tEnchantment : tData.mMaterial.mMaterial.mEnchantmentTools) {
                                        if (tEnchantment.mObject == Enchantment.fortune) {
                                            aEvent.toolTip.add(LH.Chat.PINK + Enchantment.fortune.getTranslatedName((int) tEnchantment.mAmount) + " / " + Enchantment.looting.getTranslatedName((int) tEnchantment.mAmount));
                                        } else if (tEnchantment.mObject == Enchantment.knockback) {
                                            aEvent.toolTip.add(LH.Chat.PINK + Enchantment.knockback.getTranslatedName((int) tEnchantment.mAmount) + " / " + Enchantment.punch.getTranslatedName((int) tEnchantment.mAmount));
                                        } else if (tEnchantment.mObject == Enchantment.fireAspect) {
                                            if (tEnchantment.mAmount >= 3)
                                                aEvent.toolTip.add(LH.Chat.PINK + Enchantment.fireAspect.getTranslatedName((int) tEnchantment.mAmount) + " / " + Enchantment.flame.getTranslatedName((int) tEnchantment.mAmount) + " / Auto Smelt I");
                                            else
                                                aEvent.toolTip.add(LH.Chat.PINK + Enchantment.fireAspect.getTranslatedName((int) tEnchantment.mAmount) + " / " + Enchantment.flame.getTranslatedName((int) tEnchantment.mAmount));
                                        } else {
                                            aEvent.toolTip.add(LH.Chat.PINK + tEnchantment.mObject.getTranslatedName((int) tEnchantment.mAmount));
                                        }
                                    }
                                } else {
                                    aEvent.toolTip.add(LH.Chat.PURPLE + LH.get(LH.TOOLTIP_TOO_MANY_TOOL_ENCHANTS));
                                }
                            }
                        }
                        if (MD.BTL.mLoaded && tData.mMaterial.mMaterial.contains(TD.Properties.BETWEENLANDS)) {
                            aEvent.toolTip.add(LH.Chat.GREEN + LH.get(LH.TOOLTIP_BETWEENLANDS_RESISTANCE));
                        }
                        if (!tData.mPrefix.containsAny(TD.Prefix.TOOL_HEAD, TD.Prefix.WEAPON_ALIKE, TD.Prefix.AMMO_ALIKE, TD.Prefix.TOOL_ALIKE)) {
                            if (!tData.mMaterial.mMaterial.mEnchantmentArmors.isEmpty()) {
                                if (tData.mMaterial.mMaterial.mEnchantmentArmors.size() <= 3) {
                                    aEvent.toolTip.add(LH.Chat.PURPLE + LH.get(LH.TOOLTIP_POSSIBLE_ARMOR_ENCHANTS));
                                    for (ObjectStack<Enchantment> tEnchantment : tData.mMaterial.mMaterial.mEnchantmentArmors) {
                                        aEvent.toolTip.add(LH.Chat.PINK + tEnchantment.mObject.getTranslatedName((int) tEnchantment.mAmount));
                                    }
                                } else {
                                    aEvent.toolTip.add(LH.Chat.PURPLE + LH.get(LH.TOOLTIP_TOO_MANY_ARMOR_ENCHANTS));
                                }
                            }
                            if ((IL.TF_Mazestone.exists() || IL.TF_Mazehedge.exists()) && tData.mMaterial.mMaterial.contains(TD.Properties.MAZEBREAKER)) {
                                aEvent.toolTip.add(LH.Chat.PINK + LH.get(LH.TOOLTIP_TWILIGHT_MAZE_BREAKING));
                            }
                        }
                    }
                    if (aBlock == NB || !(aBlock instanceof MultiTileEntityBlockInternal || aBlock instanceof IBlockBase)) {
                        if (tData.mMaterial.mMaterial.contains(TD.Properties.FLAMMABLE)) {
                            if (tData.mMaterial.mMaterial.contains(TD.Properties.EXPLOSIVE)) {
                                aEvent.toolTip.add(LH.Chat.RED + LH.get(LH.TOOLTIP_FLAMMABLE_AND_EXPLOSIVE));
                            } else {
                                aEvent.toolTip.add(LH.Chat.RED + LH.get(LH.TOOLTIP_FLAMMABLE));
                            }
                        } else if (tData.mMaterial.mMaterial.contains(TD.Properties.EXPLOSIVE)) {
                            aEvent.toolTip.add(LH.Chat.RED + LH.get(LH.TOOLTIP_EXPLOSIVE));
                        }
                    }
                }
                if (tUnburnable && !MD.MC.owns(aRegName))
                    aEvent.toolTip.add(LH.Chat.GREEN + LH.get(LH.TOOLTIP_UNBURNABLE));
            }
            if (aEvent.showAdvancedItemTooltips) {
                boolean temp = T;
                for (OreDictMaterialStack tMaterial : tData.getAllMaterialStacks()) if (tMaterial.mAmount != 0 && !tMaterial.mMaterial.contains(TD.Properties.DONT_SHOW_THIS_COMPONENT)) {
                    if (temp) {
                        aEvent.toolTip.add(LH.Chat.DCYAN + LH.get(LH.TOOLTIP_CONTAINED_MATERIALS));
                        temp = F;
                    }
                    StringBuilder tString = new StringBuilder(128);
                    double aWeight = tMaterial.weight();
                    long tWeight = ((long) (aWeight * 1000)) % 1000;
                    tString.append(LH.Chat.WHITE).append(UT.Code.displayUnits(tMaterial.mAmount)).append(" ");
                    tString.append(LH.Chat.YELLOW).append(tMaterial.mMaterial.getLocal());
                    tString.append(LH.Chat.WHITE).append(" (");
                    tString.append(LH.Chat.CYAN).append("M: ");
                    tString.append(LH.Chat.WHITE).append(tMaterial.mMaterial.mMeltingPoint);
                    tString.append(LH.Chat.RED).append("K ");
                    tString.append(LH.Chat.CYAN).append(" B: ");
                    tString.append(LH.Chat.WHITE).append(tMaterial.mMaterial.mBoilingPoint);
                    tString.append(LH.Chat.RED).append("K ");
                    tString.append(LH.Chat.CYAN).append(" W: ");
                    tString.append(LH.Chat.WHITE).append((long) aWeight).append(".").append(tWeight < 1 ? "000" : tWeight < 10 ? "00" + tWeight : tWeight < 100 ? "0" + tWeight : tWeight);
                    tString.append(LH.Chat.YELLOW).append("kg");
                    tString.append(LH.Chat.WHITE).append(")");
                    aEvent.toolTip.add(tString.toString());
                }
            } else {
                aEvent.toolTip.add(LH.Chat.DGRAY + "Enable F3+H Mode for Info about contained Materials.");
            }
            if (ST.isGT(aItem) && tData.hasValidPrefixMaterialData()) {
                if (tData.mMaterial.mMaterial.mOriginalMod == null) {
                    aEvent.toolTip.add(LH.Chat.BLUE + "Material from an Unknown Mod");
                } else if (tData.mMaterial.mMaterial.mOriginalMod == MD.MC) {
                    aEvent.toolTip.add(LH.Chat.BLUE + "Vanilla Material");
                } else if (tData.mMaterial.mMaterial.mOriginalMod == MD.GAPI) {
                    if (tData.mMaterial.mMaterial.mID > 0 && tData.mMaterial.mMaterial.mID < 8000) {
                        aEvent.toolTip.add(LH.Chat.BLUE + "Material from the Periodic Table of Elements");
                    } else {
                        aEvent.toolTip.add(LH.Chat.BLUE + "Random Material handled by Greg API");
                    }
                } else {
                    aEvent.toolTip.add(LH.Chat.BLUE + "Material from " + tData.mMaterial.mMaterial.mOriginalMod.mName);
                }
            }
        }
        // Remove all Nulls and fix eventual Formatting mistakes.
        for (int i = 1, j = aEvent.toolTip.size(); i < j; i++) {
            String tTooltip = aEvent.toolTip.get(i);
            if (tTooltip == null) {
                aEvent.toolTip.remove(i--);
                j--;
            } else
                aEvent.toolTip.set(i, tTooltip + LH.Chat.RESET_TOOLTIP);
        }
    } catch (Throwable e) {
        e.printStackTrace(ERR);
    }
}
Also used : AdvancedCrafting1ToY(gregapi.recipes.AdvancedCrafting1ToY) OreDictItemData(gregapi.oredict.OreDictItemData) MultiTileEntityBlockInternal(gregapi.block.multitileentity.MultiTileEntityBlockInternal) OreDictMaterialStack(gregapi.oredict.OreDictMaterialStack) IBlockBase(gregapi.block.IBlockBase) ArrayListNoNulls(gregapi.code.ArrayListNoNulls) AdvancedCraftingXToY(gregapi.recipes.AdvancedCraftingXToY) Item(net.minecraft.item.Item) IOreDictListenerItem(gregapi.oredict.listeners.IOreDictListenerItem) ICover(gregapi.cover.ICover) Block(net.minecraft.block.Block) RenderFallingBlock(net.minecraft.client.renderer.entity.RenderFallingBlock) ItemFluidDisplay(gregapi.item.ItemFluidDisplay) Enchantment(net.minecraft.enchantment.Enchantment) IOreDictListenerItem(gregapi.oredict.listeners.IOreDictListenerItem) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with ArrayListNoNulls

use of gregapi.code.ArrayListNoNulls in project gregtech6 by GregTech6.

the class GT_API_Proxy_Client method onClientTickEvent.

@SubscribeEvent
public void onClientTickEvent(ClientTickEvent aEvent) {
    if (aEvent.phase == Phase.END) {
        if (CLIENT_TIME == 10) {
            // Initializing the Fake Furnace Recipe Map
            if (FL.XP.exists())
                for (Object tObject : FurnaceRecipes.smelting().getSmeltingList().keySet()) if (tObject instanceof ItemStack) {
                    RM.Furnace.addFakeRecipe(F, RM.Furnace.findRecipe(null, null, F, Long.MAX_VALUE, NI, ZL_FS, ST.array((ItemStack) tObject)));
                }
            // Now for hiding stuff from NEI that should have never been there in the first place.
            if (!SHOW_MICROBLOCKS && NEI)
                for (Item aItem : new Item[] { ST.item(MD.FMB, "microblock"), ST.item(MD.ExU, "microblocks"), ST.item(MD.ExS, "microblocks"), ST.item(MD.AE, "item.ItemFacade") }) if (aItem != null) {
                    ST.hide(aItem);
                    List<ItemStack> tList = new ArrayListNoNulls<>();
                    aItem.getSubItems(aItem, CreativeTabs.tabAllSearch, tList);
                    for (ItemStack tStack : tList) ST.hide(tStack);
                }
        }
        switch((int) (CLIENT_TIME % 10)) {
            case 0:
                LH.Chat.RAINBOW_FAST = LH.Chat.RED;
                LH.Chat.BLINKING_CYAN = LH.Chat.CYAN;
                LH.Chat.BLINKING_RED = LH.Chat.RED;
                LH.Chat.BLINKING_ORANGE = LH.Chat.ORANGE;
                break;
            case 1:
                LH.Chat.RAINBOW_FAST = LH.Chat.ORANGE;
                break;
            case 2:
                LH.Chat.RAINBOW_FAST = LH.Chat.YELLOW;
                break;
            case 3:
                LH.Chat.RAINBOW_FAST = LH.Chat.GREEN;
                break;
            case 4:
                LH.Chat.RAINBOW_FAST = LH.Chat.CYAN;
                break;
            case 5:
                LH.Chat.RAINBOW_FAST = LH.Chat.DCYAN;
                LH.Chat.BLINKING_CYAN = LH.Chat.WHITE;
                LH.Chat.BLINKING_RED = LH.Chat.WHITE;
                LH.Chat.BLINKING_ORANGE = LH.Chat.YELLOW;
                break;
            case 6:
                LH.Chat.RAINBOW_FAST = LH.Chat.DBLUE;
                break;
            case 7:
                LH.Chat.RAINBOW_FAST = LH.Chat.BLUE;
                break;
            case 8:
                LH.Chat.RAINBOW_FAST = LH.Chat.PURPLE;
                break;
            case 9:
                LH.Chat.RAINBOW_FAST = LH.Chat.PINK;
                break;
        }
        switch((int) (CLIENT_TIME % 50)) {
            case 0:
                LH.Chat.RAINBOW = LH.Chat.RED;
                LH.Chat.BLINKING_GRAY = LH.Chat.GRAY;
                break;
            case 5:
                LH.Chat.RAINBOW = LH.Chat.ORANGE;
                break;
            case 10:
                LH.Chat.RAINBOW = LH.Chat.YELLOW;
                break;
            case 15:
                LH.Chat.RAINBOW = LH.Chat.GREEN;
                break;
            case 20:
                LH.Chat.RAINBOW = LH.Chat.CYAN;
                break;
            case 25:
                LH.Chat.RAINBOW = LH.Chat.DCYAN;
                LH.Chat.BLINKING_GRAY = LH.Chat.DGRAY;
                break;
            case 30:
                LH.Chat.RAINBOW = LH.Chat.DBLUE;
                break;
            case 35:
                LH.Chat.RAINBOW = LH.Chat.BLUE;
                break;
            case 40:
                LH.Chat.RAINBOW = LH.Chat.PURPLE;
                break;
            case 45:
                LH.Chat.RAINBOW = LH.Chat.PINK;
                break;
        }
        switch((int) (CLIENT_TIME % 250)) {
            case 0:
                LH.Chat.RAINBOW_SLOW = LH.Chat.RED;
                break;
            case 25:
                LH.Chat.RAINBOW_SLOW = LH.Chat.ORANGE;
                break;
            case 50:
                LH.Chat.RAINBOW_SLOW = LH.Chat.YELLOW;
                break;
            case 75:
                LH.Chat.RAINBOW_SLOW = LH.Chat.GREEN;
                break;
            case 100:
                LH.Chat.RAINBOW_SLOW = LH.Chat.CYAN;
                break;
            case 125:
                LH.Chat.RAINBOW_SLOW = LH.Chat.DCYAN;
                break;
            case 150:
                LH.Chat.RAINBOW_SLOW = LH.Chat.DBLUE;
                break;
            case 175:
                LH.Chat.RAINBOW_SLOW = LH.Chat.BLUE;
                break;
            case 200:
                LH.Chat.RAINBOW_SLOW = LH.Chat.PURPLE;
                break;
            case 225:
                LH.Chat.RAINBOW_SLOW = LH.Chat.PINK;
                break;
        }
        int tDirection = (CLIENT_TIME % 100 < 50 ? +1 : -1);
        for (short[] tArray : sPosR) tArray[0] = UT.Code.bind8(tArray[0] + tDirection);
        for (short[] tArray : sPosG) tArray[1] = UT.Code.bind8(tArray[1] + tDirection);
        for (short[] tArray : sPosB) tArray[2] = UT.Code.bind8(tArray[2] + tDirection);
        for (short[] tArray : sPosA) tArray[3] = UT.Code.bind8(tArray[3] + tDirection);
        for (short[] tArray : sNegR) tArray[0] = UT.Code.bind8(tArray[0] - tDirection);
        for (short[] tArray : sNegG) tArray[1] = UT.Code.bind8(tArray[1] - tDirection);
        for (short[] tArray : sNegB) tArray[2] = UT.Code.bind8(tArray[2] - tDirection);
        for (short[] tArray : sNegA) tArray[3] = UT.Code.bind8(tArray[3] - tDirection);
        boolean tNR = UT.Code.inside(0, 99, (CLIENT_TIME / 2) % 300), tNG = UT.Code.inside(50, 149, (CLIENT_TIME / 2) % 300), tNB = UT.Code.inside(100, 199, (CLIENT_TIME / 2) % 300), tPR = UT.Code.inside(100, 199, (CLIENT_TIME / 2) % 300), tPG = UT.Code.inside(150, 249, (CLIENT_TIME / 2) % 300), tPB = UT.Code.inside(200, 299, (CLIENT_TIME / 2) % 300);
        for (short[] tArray : sRainbow) {
            if (tPR)
                tArray[0] = UT.Code.bind8(tArray[0] + 1);
            if (tPG)
                tArray[1] = UT.Code.bind8(tArray[1] + 1);
            if (tPB)
                tArray[2] = UT.Code.bind8(tArray[2] + 1);
            if (tNR)
                tArray[0] = UT.Code.bind8(tArray[0] - 1);
            if (tNG)
                tArray[1] = UT.Code.bind8(tArray[1] - 1);
            if (tNB)
                tArray[2] = UT.Code.bind8(tArray[2] - 1);
        }
        tNR = UT.Code.inside(0, 9, (CLIENT_TIME / 2) % 30);
        tNG = UT.Code.inside(5, 14, (CLIENT_TIME / 2) % 30);
        tNB = UT.Code.inside(10, 19, (CLIENT_TIME / 2) % 30);
        tPR = UT.Code.inside(10, 19, (CLIENT_TIME / 2) % 30);
        tPG = UT.Code.inside(15, 24, (CLIENT_TIME / 2) % 30);
        tPB = UT.Code.inside(20, 29, (CLIENT_TIME / 2) % 30);
        for (short[] tArray : sRainbowFast) {
            if (tPR)
                tArray[0] = UT.Code.bind8(tArray[0] + 10);
            if (tPG)
                tArray[1] = UT.Code.bind8(tArray[1] + 10);
            if (tPB)
                tArray[2] = UT.Code.bind8(tArray[2] + 10);
            if (tNR)
                tArray[0] = UT.Code.bind8(tArray[0] - 10);
            if (tNG)
                tArray[1] = UT.Code.bind8(tArray[1] - 10);
            if (tNB)
                tArray[2] = UT.Code.bind8(tArray[2] - 10);
        }
        CLIENT_TIME++;
    }
}
Also used : Item(net.minecraft.item.Item) IOreDictListenerItem(gregapi.oredict.listeners.IOreDictListenerItem) ItemStack(net.minecraft.item.ItemStack) ArrayListNoNulls(gregapi.code.ArrayListNoNulls) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with ArrayListNoNulls

use of gregapi.code.ArrayListNoNulls in project gregtech6 by GregTech6.

the class MultiTileEntityItemInternal method getOreDictItemData.

@Override
public OreDictItemData getOreDictItemData(ItemStack aStack) {
    List<OreDictItemData> rList = new ArrayListNoNulls<>(F, OM.data(aStack));
    MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry.getNewTileEntityContainer(aStack);
    // Yes I keep Covers a special case, less chances for fuck ups.
    if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof ITileEntityCoverable) {
        CoverData tCoverData = ((ITileEntityCoverable) tTileEntityContainer.mTileEntity).getCoverData();
        if (tCoverData != null)
            for (byte tSide : ALL_SIDES_VALID) rList.add(OM.anydata(tCoverData.getCoverItem(tSide)));
    }
    // Same for foamed Blocks.
    if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof ITileEntityFoamable && ((ITileEntityFoamable) tTileEntityContainer.mTileEntity).hasFoam(SIDE_ANY)) {
        rList.add(new OreDictItemData(MT.ConstructionFoam, U));
        if (((ITileEntityFoamable) tTileEntityContainer.mTileEntity).ownedFoam(SIDE_ANY))
            rList.add(new OreDictItemData(MT.Pd, U4));
    }
    // General case for Custom additional OreDictItemData.
    if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IMTE_GetOreDictItemData) {
        rList = ((IMTE_GetOreDictItemData) tTileEntityContainer.mTileEntity).getOreDictItemData(rList);
    }
    return rList.isEmpty() ? null : rList.size() > 1 ? new OreDictItemData(rList) : rList.get(0);
}
Also used : ITileEntityCoverable(gregapi.cover.ITileEntityCoverable) OreDictItemData(gregapi.oredict.OreDictItemData) CoverData(gregapi.cover.CoverData) ITileEntityFoamable(gregapi.tileentity.ITileEntityFoamable) ArrayListNoNulls(gregapi.code.ArrayListNoNulls) IItemNoGTOverride(gregapi.item.IItemNoGTOverride)

Example 5 with ArrayListNoNulls

use of gregapi.code.ArrayListNoNulls in project gregtech6 by GregTech6.

the class Loader_Recipes_Replace method run.

@SuppressWarnings("rawtypes")
@Override
public void run() {
    OUT.println("GT_Mod: Replacing Vanilla alike Recipes.");
    NON_REPLACEABLE.add(ST.make(ToolsGT.sMetaTool, 1, W));
    NON_REPLACEABLE.add(ST.make(Items.bow, 1, W));
    NON_REPLACEABLE.add(ST.make(Items.fishing_rod, 1, W));
    NON_REPLACEABLE.add(IL.IC2_ForgeHammer.getWithMeta(1, W));
    NON_REPLACEABLE.add(IL.IC2_WireCutter.getWithMeta(1, W));
    NON_REPLACEABLE.add(ST.mkic("painter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("blackPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("redPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("greenPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("brownPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("bluePainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("purplePainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("cyanPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("lightGreyPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("darkGreyPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("pinkPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("limePainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("yellowPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("cloudPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("magentaPainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("orangePainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("whitePainter", 1, W));
    NON_REPLACEABLE.add(ST.mkic("cfPack", 1, W));
    NON_REPLACEABLE.add(ST.mkic("jetpack", 1, W));
    NON_REPLACEABLE.add(ST.mkic("treetap", 1, W));
    NON_REPLACEABLE.add(ST.mkic("weedEx", 1, W));
    NON_REPLACEABLE.add(ST.mkic("staticBoots", 1, W));
    NON_REPLACEABLE.add(ST.mkic("compositeArmor", 1, W));
    NON_REPLACEABLE.add(ST.mkic("hazmatHelmet", 1, W));
    NON_REPLACEABLE.add(ST.mkic("hazmatChestplate", 1, W));
    NON_REPLACEABLE.add(ST.mkic("hazmatLeggings", 1, W));
    NON_REPLACEABLE.add(ST.mkic("hazmatBoots", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.RC, "part.turbine.disk", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.RC, "part.turbine.blade", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.RC, "part.turbine.rotor", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.RC, "borehead.diamond", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.RC, "borehead.steel", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.RC, "borehead.iron", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.TF, "item.plateNaga", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.TF, "item.legsNaga", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.TF, "item.arcticHelm", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.TF, "item.arcticPlate", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.TF, "item.arcticLegs", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.TF, "item.arcticBoots", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.TF, "item.yetiHelm", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.TF, "item.yetiPlate", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.TF, "item.yetiLegs", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.TF, "item.yetiBoots", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.AE, "item.ToolCertusQuartzCuttingKnife", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.AE, "item.ToolNetherQuartzCuttingKnife", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.FR, "apiaristHelmet", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.FR, "apiaristChest", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.FR, "apiaristLegs", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.FR, "apiaristBoots", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.FR, "frameUntreated", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.FR, "frameImpregnated", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.FR, "frameProven", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.FR, "waxCast", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.GC, "item.sensorGlasses", 1, W));
    NON_REPLACEABLE.add(ST.make(MD.NC, "ItemToolThermometer", 1, W));
    List<ItemStack> tStickList = OreDictionary.getOres(OD.stickWood.toString());
    HashSetNoNulls<Object> tAlreadyScannedItems = new HashSetNoNulls<>();
    ArrayListNoNulls<RecipeReplacement> tList = new ArrayListNoNulls<>();
    List<IRecipe> tRecipeList = CR.list();
    boolean tUseProgressBar = UT.LoadingBar.start("Looking up Recipes", tRecipeList.size());
    for (int l = 0; l < tRecipeList.size(); l++) {
        IRecipe tRecipe = tRecipeList.get(l);
        if (tUseProgressBar)
            UT.LoadingBar.step("");
        ItemStack aOutput = tRecipe.getRecipeOutput();
        if (ST.invalid(aOutput))
            continue;
        if (aOutput.stackSize != 1)
            continue;
        if (aOutput.getMaxDamage() <= 0)
            continue;
        if (aOutput.getMaxStackSize() != 1)
            continue;
        if (tRecipe instanceof ShapelessRecipes)
            continue;
        if (tRecipe instanceof ShapelessOreRecipe)
            continue;
        if (tRecipe instanceof ICraftingRecipeGT)
            continue;
        if (ST.block(aOutput) != NB)
            continue;
        if (COMPAT_IC2 != null && COMPAT_IC2.isReactorItem(aOutput))
            continue;
        if (COMPAT_EU_ITEM != null && COMPAT_EU_ITEM.is(aOutput))
            continue;
        if (NON_REPLACEABLE.contains(aOutput, T))
            continue;
        if (sNonReplaceableNames.contains(aOutput.getUnlocalizedName()))
            continue;
        Object[] tRecipeInputs = null;
        if (tRecipe instanceof ShapedOreRecipe) {
            tRecipeInputs = ((ShapedOreRecipe) tRecipe).getInput();
        } else if (tRecipe instanceof ShapedRecipes) {
            tRecipeInputs = ((ShapedRecipes) tRecipe).recipeItems;
        } else if (MD.IC2.mLoaded && tRecipe instanceof ic2.core.AdvRecipe) {
            tRecipeInputs = ((ic2.core.AdvRecipe) tRecipe).input;
        }
        if (tRecipeInputs == null || tRecipeInputs.length <= 0)
            continue;
        OreDictPrefix tPrefix = null;
        OreDictMaterial tMat = null, tRod = null;
        boolean temp = T;
        tAlreadyScannedItems.clear();
        for (int i = 0; i < tRecipeInputs.length; i++) {
            Object tObject = tRecipeInputs[i];
            if (!tAlreadyScannedItems.add(tObject))
                continue;
            OreDictItemData tData = null;
            if (tObject instanceof ItemStack) {
                if (IL.Stick.equal(tObject, T, T)) {
                    tRod = ANY.Wood;
                    continue;
                }
                tData = OM.anyassociation((ItemStack) tObject);
            } else if (MD.IC2.mLoaded && tObject instanceof ic2.api.recipe.RecipeInputItemStack) {
                if (IL.Stick.equal(((ic2.api.recipe.RecipeInputItemStack) tObject).input, T, T)) {
                    tRod = ANY.Wood;
                    continue;
                }
                tData = OM.anyassociation(((ic2.api.recipe.RecipeInputItemStack) tObject).input);
            } else if (MD.IC2.mLoaded && tObject instanceof ic2.api.recipe.RecipeInputOreDict) {
                if (OD.stickWood.toString().equals(((ic2.api.recipe.RecipeInputOreDict) tObject).input)) {
                    tRod = ANY.Wood;
                    continue;
                }
                if (OD.stickAnyWood.toString().equals(((ic2.api.recipe.RecipeInputOreDict) tObject).input)) {
                    tRod = ANY.Wood;
                    continue;
                }
                tData = OM.data(((ic2.api.recipe.RecipeInputOreDict) tObject).input);
            } else if (tObject instanceof List) {
                if (tStickList == tObject) {
                    tRod = ANY.Wood;
                    continue;
                }
                switch(((List) tObject).size()) {
                    case 0:
                        temp = F;
                        break;
                    case 1:
                        if (((List) tObject).get(0) instanceof ItemStack) {
                            tData = OM.anyassociation((ItemStack) (((List) tObject).get(0)));
                        } else {
                            temp = F;
                        }
                        break;
                    default:
                        for (Object tContent : ((List) tObject)) if (tContent instanceof ItemStack) {
                            if (tData == null) {
                                tData = OM.anyassociation((ItemStack) tContent);
                                if (tData == null || !tData.hasValidPrefixMaterialData()) {
                                    temp = F;
                                    break;
                                }
                            } else {
                                OreDictItemData tAssociation = OM.anyassociation((ItemStack) tContent);
                                if (tAssociation == null || tAssociation.mPrefix != tData.mPrefix || tAssociation.mMaterial.mMaterial != tData.mMaterial.mMaterial) {
                                    temp = F;
                                    break;
                                }
                            }
                        } else {
                            temp = F;
                            break;
                        }
                        break;
                }
                if (!temp)
                    break;
            } else {
                temp = F;
                break;
            }
            if (tData == null) {
                temp = F;
                break;
            }
            if (tData.mPrefix == OP.stick) {
                if (tRod != null && tRod != tData.mMaterial.mMaterial) {
                    temp = F;
                    break;
                }
                tRod = tData.mMaterial.mMaterial;
            } else {
                if (tMat != null && tMat != tData.mMaterial.mMaterial) {
                    temp = F;
                    break;
                }
                if (tData.mPrefix != OP.ingot && tData.mPrefix != OP.gem) {
                    temp = F;
                    break;
                }
                tMat = tData.mMaterial.mMaterial;
                tPrefix = tData.mPrefix;
            }
        }
        if (temp)
            tList.add(new RecipeReplacement(tRecipe, tPrefix, tMat, tRod));
    }
    if (tUseProgressBar)
        UT.LoadingBar.finish();
    tUseProgressBar = UT.LoadingBar.start("Replacing Recipes", tList.size());
    for (RecipeReplacement aRecipe : tList) {
        if (tUseProgressBar)
            UT.LoadingBar.step(aRecipe.mMat);
        if (aRecipe.mPrefix == null || aRecipe.mMat == null)
            continue;
        ItemStack tMat = aRecipe.mPrefix.mat(aRecipe.mMat, 1);
        if (tMat == null)
            continue;
        INGT.func_150996_a(tMat.getItem());
        INGT.stackSize = 1;
        ST.meta_(INGT, ST.meta_(tMat));
        RecipeReplacer[] tReplacer = sRecipesMat;
        if (aRecipe.mRod != null) {
            ItemStack tRod = (aRecipe.mRod == ANY.Wood ? IL.Stick.get(1) : OP.stick.mat(aRecipe.mRod, 1));
            if (tRod == null)
                continue;
            STCK.func_150996_a(tRod.getItem());
            STCK.stackSize = 1;
            ST.meta_(STCK, ST.meta_(tRod));
            tReplacer = sRecipesRod;
        }
        for (RecipeReplacer aReplacer : tReplacer) {
            ItemStack tCrafted = getRecipeOutput(aRecipe.mRecipe, aReplacer.mRecipe);
            if (tCrafted == null)
                continue;
            int tMatCount = 0, tRodCount = 0;
            for (ItemStack tStack : aReplacer.mRecipe) if (tStack == INGT)
                tMatCount++;
            else if (tStack == STCK)
                tRodCount++;
            OM.dat2(tCrafted, aRecipe.mMat, aRecipe.mPrefix.mAmount * tMatCount, OM.stack(aRecipe.mRod, OP.stick.mAmount * tRodCount));
            if (aRecipe.mPrefix != OP.ingot)
                continue;
            ItemStack tPlate = OP.plate.mat(aRecipe.mMat, 1);
            if (tPlate == null || aReplacer.mShape == null || aReplacer.mShape.length <= 0)
                continue;
            if (!ConfigsGT.RECIPES.get(ConfigCategories.Recipes.recipereplacements, aRecipe.mMat + "." + aReplacer.mName, T))
                continue;
            if (!tRecipeList.remove(aRecipe.mRecipe))
                continue;
            Object tNamePlate = OreDictionary.getOres(OP.plate.dat(aRecipe.mMat).toString()).isEmpty() ? OP.ingot.dat(aRecipe.mMat) : OP.plate.dat(aRecipe.mMat), tNameCurve = OreDictionary.getOres(OP.plateCurved.dat(aRecipe.mMat).toString()).isEmpty() ? tNamePlate : OP.plateCurved.dat(aRecipe.mMat);
            switch(aReplacer.mShape.length) {
                case 1:
                    CR.shaped(tCrafted, CR.DEF, new Object[] { aReplacer.mShape[0], PLT.charAt(0), tNamePlate, CRV.charAt(0), tNameCurve, ROD.charAt(0), OP.stick.dat(aRecipe.mRod == null ? aRecipe.mMat : aRecipe.mRod), NGT.charAt(0), OP.ingot.dat(aRecipe.mMat) });
                    break;
                case 2:
                    CR.shaped(tCrafted, CR.DEF, new Object[] { aReplacer.mShape[0], aReplacer.mShape[1], PLT.charAt(0), tNamePlate, CRV.charAt(0), tNameCurve, ROD.charAt(0), OP.stick.dat(aRecipe.mRod == null ? aRecipe.mMat : aRecipe.mRod), NGT.charAt(0), OP.ingot.dat(aRecipe.mMat) });
                    break;
                default:
                    CR.shaped(tCrafted, CR.DEF, new Object[] { aReplacer.mShape[0], aReplacer.mShape[1], aReplacer.mShape[2], PLT.charAt(0), tNamePlate, CRV.charAt(0), tNameCurve, ROD.charAt(0), OP.stick.dat(aRecipe.mRod == null ? aRecipe.mMat : aRecipe.mRod), NGT.charAt(0), OP.ingot.dat(aRecipe.mMat) });
                    break;
            }
        }
    }
    if (tUseProgressBar)
        UT.LoadingBar.finish();
}
Also used : ShapedRecipes(net.minecraft.item.crafting.ShapedRecipes) OreDictItemData(gregapi.oredict.OreDictItemData) ICraftingRecipeGT(gregapi.recipes.ICraftingRecipeGT) ShapelessOreRecipe(net.minecraftforge.oredict.ShapelessOreRecipe) List(java.util.List) ShapelessRecipes(net.minecraft.item.crafting.ShapelessRecipes) OreDictMaterial(gregapi.oredict.OreDictMaterial) IRecipe(net.minecraft.item.crafting.IRecipe) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) ArrayListNoNulls(gregapi.code.ArrayListNoNulls) HashSetNoNulls(gregapi.code.HashSetNoNulls) OreDictPrefix(gregapi.oredict.OreDictPrefix) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ArrayListNoNulls (gregapi.code.ArrayListNoNulls)54 ItemStack (net.minecraft.item.ItemStack)33 OreDictItemData (gregapi.oredict.OreDictItemData)12 OreDictMaterial (gregapi.oredict.OreDictMaterial)11 Recipe (gregapi.recipes.Recipe)10 OreDictMaterialStack (gregapi.oredict.OreDictMaterialStack)9 Block (net.minecraft.block.Block)9 HashSetNoNulls (gregapi.code.HashSetNoNulls)7 TileEntity (net.minecraft.tileentity.TileEntity)7 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)6 OreDictPrefix (gregapi.oredict.OreDictPrefix)6 List (java.util.List)6 ChunkCoordinates (net.minecraft.util.ChunkCoordinates)6 FluidStack (net.minecraftforge.fluids.FluidStack)6 MultiTileEntityRegistry (gregapi.block.multitileentity.MultiTileEntityRegistry)5 ItemStackContainer (gregapi.code.ItemStackContainer)5 FluidContainerData (net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData)5 IOreDictConfigurationComponent (gregapi.oredict.configurations.IOreDictConfigurationComponent)4 DelegatorTileEntity (gregapi.tileentity.delegate.DelegatorTileEntity)4 ShapelessOreRecipe (net.minecraftforge.oredict.ShapelessOreRecipe)4