Search in sources :

Example 1 with IOreDictListenerItem

use of gregapi.oredict.listeners.IOreDictListenerItem 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 IOreDictListenerItem

use of gregapi.oredict.listeners.IOreDictListenerItem 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)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 ArrayListNoNulls (gregapi.code.ArrayListNoNulls)2 OreDictItemData (gregapi.oredict.OreDictItemData)2 OreDictMaterialStack (gregapi.oredict.OreDictMaterialStack)2 IOreDictListenerItem (gregapi.oredict.listeners.IOreDictListenerItem)2 IBlockBase (gregapi.block.IBlockBase)1 MultiTileEntityBlockInternal (gregapi.block.multitileentity.MultiTileEntityBlockInternal)1 PrefixBlockTileEntity (gregapi.block.prefixblock.PrefixBlockTileEntity)1 ICover (gregapi.cover.ICover)1 ItemFluidDisplay (gregapi.item.ItemFluidDisplay)1 MultiItemTool (gregapi.item.multiitem.MultiItemTool)1 PacketDeathPoint (gregapi.network.packets.PacketDeathPoint)1 AdvancedCrafting1ToY (gregapi.recipes.AdvancedCrafting1ToY)1 AdvancedCraftingXToY (gregapi.recipes.AdvancedCraftingXToY)1 Block (net.minecraft.block.Block)1 RenderFallingBlock (net.minecraft.client.renderer.entity.RenderFallingBlock)1 Enchantment (net.minecraft.enchantment.Enchantment)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityItem (net.minecraft.entity.item.EntityItem)1