Search in sources :

Example 1 with ICover

use of gregapi.cover.ICover in project gregtech6 by GregTech6.

the class GT_API method onModPostInit2.

@Override
public void onModPostInit2(FMLPostInitializationEvent aEvent) {
    if (MD.IC2.mLoaded) {
        PotionsGT.ID_RADIATION = ic2.api.info.Info.POTION_RADIATION.id;
    }
    if (MD.ENVM.mLoaded) {
        PotionsGT.ID_DEHYDRATION = enviromine.EnviroPotion.dehydration.id;
        PotionsGT.ID_FROSTBITE = enviromine.EnviroPotion.frostbite.id;
        PotionsGT.ID_HEATSTROKE = enviromine.EnviroPotion.heatstroke.id;
        PotionsGT.ID_HYPOTHERMIA = enviromine.EnviroPotion.hypothermia.id;
        PotionsGT.ID_INSANITY = enviromine.EnviroPotion.insanity.id;
    }
    if (MD.IE.mLoaded) {
        PotionsGT.ID_FLAMMABLE = blusunrize.immersiveengineering.common.util.IEPotions.flammable.id;
        PotionsGT.ID_SLIPPERY = blusunrize.immersiveengineering.common.util.IEPotions.slippery.id;
        PotionsGT.ID_CONDUCTIVE = blusunrize.immersiveengineering.common.util.IEPotions.conductive.id;
        PotionsGT.ID_STICKY = blusunrize.immersiveengineering.common.util.IEPotions.sticky.id;
    }
    EnergyCompat.checkAvailabilities();
    ToolCompat.checkAvailabilities();
    ST.checkAvailabilities();
    OUT.println(getModNameForLog() + ": If the Loading Bar somehow Freezes at this Point, then you definetly ran out of Memory or permgenspace, look at the other Logs to confirm it.");
    OreDictManager.INSTANCE.onPostLoad();
    ICover tCover = new CoverRedstoneTorch();
    CoverRegistry.put(ST.make(Blocks.redstone_torch, 1, 0), tCover);
    CoverRegistry.put(ST.make(Blocks.unlit_redstone_torch, 1, 0), tCover);
    CoverRegistry.put(ST.make(Items.repeater, 1, 0), new CoverRedstoneRepeater());
    OreDictPrefix.applyAllStackSizes();
    // Doesn't fucking work, the Chisel API is pure garbage...
    // if (MD.CHSL.mLoaded) {
    // if (MD.EtFu.mLoaded) {
    // FMLInterModComms.sendRuntimeMessage(GAPI, "ChiselAPI|Carving", "variation:add", "granite|" +MD.EtFu.mID+":stone|1");
    // FMLInterModComms.sendRuntimeMessage(GAPI, "ChiselAPI|Carving", "variation:add", "diorite|" +MD.EtFu.mID+":stone|3");
    // FMLInterModComms.sendRuntimeMessage(GAPI, "ChiselAPI|Carving", "variation:add", "andesite|"+MD.EtFu.mID+":stone|5");
    // }
    // if (MD.BOTA.mLoaded) {
    // FMLInterModComms.sendRuntimeMessage(GAPI, "ChiselAPI|Carving", "variation:add", "granite|" +MD.BOTA.mID+":stone|3");
    // FMLInterModComms.sendRuntimeMessage(GAPI, "ChiselAPI|Carving", "variation:add", "diorite|" +MD.BOTA.mID+":stone|2");
    // FMLInterModComms.sendRuntimeMessage(GAPI, "ChiselAPI|Carving", "variation:add", "andesite|"+MD.BOTA.mID+":stone|0");
    // }
    // if (MD.GT.mLoaded) {
    // FMLInterModComms.sendRuntimeMessage(GAPI, "ChiselAPI|Carving", "variation:add", "granite|" +MD.GT.mID+":gt.stone.granite|0");
    // FMLInterModComms.sendRuntimeMessage(GAPI, "ChiselAPI|Carving", "variation:add", "diorite|" +MD.GT.mID+":gt.stone.diorite|0");
    // FMLInterModComms.sendRuntimeMessage(GAPI, "ChiselAPI|Carving", "variation:add", "andesite|"+MD.GT.mID+":gt.stone.andesite|0");
    // }
    // }
    // Saving the Lang File.
    LanguageHandler.save();
    if (mPlayerLogger != null)
        new Thread(mPlayerLogger).start();
    for (ICompat tCompat : ICompat.COMPAT_CLASSES) try {
        tCompat.onPostLoad(aEvent);
    } catch (Throwable e) {
        e.printStackTrace(ERR);
    }
    for (OreDictMaterial tMaterial : OreDictMaterial.MATERIAL_ARRAY) if (tMaterial != null && !tMaterial.contains(TD.Properties.INVALID_MATERIAL)) {
        if (tMaterial.mID < 10000)
            MAT_LOG.print(" ");
        if (tMaterial.mID < 1000)
            MAT_LOG.print(" ");
        if (tMaterial.mID < 100)
            MAT_LOG.print(" ");
        if (tMaterial.mID < 10)
            MAT_LOG.print(" ");
        MAT_LOG.print(tMaterial.mID);
        MAT_LOG.print(": ");
        MAT_LOG.print(tMaterial.mNameInternal);
        MAT_LOG.println();
    }
}
Also used : ICompat(gregapi.compat.ICompat) OreDictMaterial(gregapi.oredict.OreDictMaterial) CoverRedstoneRepeater(gregapi.cover.covers.CoverRedstoneRepeater) CoverRedstoneTorch(gregapi.cover.covers.CoverRedstoneTorch) ICover(gregapi.cover.ICover)

Example 2 with ICover

use of gregapi.cover.ICover 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 ICover

use of gregapi.cover.ICover in project gregtech6 by GregTech6.

the class TileEntityBase06Covers method setCoverItem.

@Override
public boolean setCoverItem(byte aSide, ItemStack aStack, Entity aPlayer, boolean aForce, boolean aBlockUpdate) {
    if (SIDES_INVALID[aSide] || (!allowCovers(aSide) && aStack != null))
        return F;
    if (aStack == null && getCoverItem(aSide) == null)
        return F;
    if (mCovers == null)
        mCovers = CoverRegistry.coverdata(this, null);
    if (!aForce) {
        if (aStack == null) {
            if (mCovers.mBehaviours[aSide] != null && mCovers.mBehaviours[aSide].interceptCoverRemoval(aSide, mCovers, aPlayer))
                return !checkIfCoversEmptyAndDeleteIfNeeded();
        } else {
            if (mCovers.mBehaviours[aSide] != null)
                return !checkIfCoversEmptyAndDeleteIfNeeded();
            ICover tCover = CoverRegistry.get(aStack);
            if (tCover == null || tCover.interceptCoverPlacement(aSide, mCovers, aPlayer))
                return !checkIfCoversEmptyAndDeleteIfNeeded();
        }
    }
    if (mCovers.mBehaviours[aSide] != null)
        mCovers.mBehaviours[aSide].onCoverRemove(aSide, mCovers, aPlayer);
    mCovers.set(aSide, aStack);
    if (mCovers.mBehaviours[aSide] != null)
        mCovers.mBehaviours[aSide].onCoverPlaced(aSide, mCovers, aPlayer, aStack);
    if (aBlockUpdate)
        causeBlockUpdate();
    updateClientData();
    return checkIfCoversEmptyAndDeleteIfNeeded();
}
Also used : ICover(gregapi.cover.ICover)

Example 4 with ICover

use of gregapi.cover.ICover in project gregtech6 by GregTech6.

the class MultiItemRandom method addItem.

/**
 * This adds a Custom Item.
 * @param aID The Id of the assigned Item [0 - 32766]
 * @param aEnglish The Default Localised Name of the created Item
 * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip
 * @param aFoodBehavior The Food Value of this Item. Can be null aswell. Just a convenience thing.
 * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things.
 * @return An ItemStack containing the newly created Item.
 */
@SuppressWarnings("unchecked")
public final ItemStack addItem(int aID, String aEnglish, String aToolTip, Object... aRandomData) {
    if (aToolTip == null)
        aToolTip = "";
    if (mAllowedToAddItems && aID >= 0 && aID < 32767 && aID != W) {
        mLastID = (short) aID;
        ItemStack aStack = ST.make(this, 1, aID);
        if (UT.Code.stringValid(aEnglish)) {
            mEnabledItems.set(aID);
            mVisibleItems.set(aID);
            LH.add(getUnlocalizedName(aStack) + ".name", aEnglish);
            LH.add(getUnlocalizedName(aStack) + ".tooltip", aToolTip);
        }
        List<TC_AspectStack> tAspects = new ArrayListNoNulls<>();
        // Important Stuff to do first
        for (Object tRandomData : aRandomData) if (tRandomData instanceof TagData) {
            if (tRandomData == TD.Creative.HIDDEN) {
                mVisibleItems.set(aID, F);
                continue;
            }
            if (tRandomData == TD.Properties.AUTO_BLACKLIST) {
                OM.blacklist_(aStack);
                continue;
            }
        }
        // now check for the rest
        for (Object tRandomData : aRandomData) if (tRandomData != null) {
            boolean tUseOreDict = T;
            if (tRandomData instanceof ItemStackSet) {
                ((ItemStackSet<?>) tRandomData).add(aStack);
                continue;
            }
            if (tRandomData instanceof TagData) {
                continue;
            }
            if (tRandomData instanceof Number) {
                setBurnValue(aID, ((Number) tRandomData).intValue());
                continue;
            }
            if (tRandomData instanceof IFoodStat) {
                setFoodBehavior(aID, (IFoodStat) tRandomData);
                if (IL.IC2_Food_Can_Empty.exists() && IL.IC2_Food_Can_Filled.exists() && getContainerItem(aStack) == null) {
                    int tFoodValue = ((IFoodStat) tRandomData).getFoodLevel(this, aStack, null);
                    if (tFoodValue > 0)
                        RM.Canner.addRecipe2(T, 16, tFoodValue * 16, aStack, IL.IC2_Food_Can_Empty.get(tFoodValue), ((IFoodStat) tRandomData).isRotten(this, aStack, null) ? IL.IC2_Food_Can_Spoiled.get(tFoodValue, IL.IC2_Food_Can_Filled.get(tFoodValue)) : IL.IC2_Food_Can_Filled.get(tFoodValue));
                }
                tUseOreDict = F;
            }
            if (tRandomData instanceof ICover) {
                CoverRegistry.put(aStack, (ICover) tRandomData);
                tUseOreDict = F;
            }
            if (tRandomData instanceof IBehavior) {
                addItemBehavior(aID, (IBehavior<MultiItem>) tRandomData);
                tUseOreDict = F;
            }
            if (tRandomData instanceof IItemEnergy) {
                setElectricStats(aID, (IItemEnergy) tRandomData);
                tUseOreDict = F;
            }
            if (tRandomData instanceof IItemContainer) {
                ((IItemContainer) tRandomData).set(aStack);
                tUseOreDict = F;
            }
            if (tRandomData instanceof TC_AspectStack) {
                ((TC_AspectStack) tRandomData).addToAspectList(tAspects);
                continue;
            }
            if (tRandomData instanceof OreDictItemData) {
                if (((OreDictItemData) tRandomData).hasValidPrefixMaterialData()) {
                    OM.reg(aStack, tRandomData);
                    ItemStack tStack = ((OreDictItemData) tRandomData).getStack(1);
                    // Priority over autogenerated PrefixItems, but not over the hardcoded Compatibility Targets.
                    if (ST.invalid(tStack) || tStack.getItem() instanceof PrefixItem) {
                        OreDictManager.INSTANCE.setTarget_(((OreDictItemData) tRandomData).mPrefix, ((OreDictItemData) tRandomData).mMaterial.mMaterial, aStack);
                        continue;
                    }
                }
                OreDictManager.INSTANCE.addItemData_(aStack, (OreDictItemData) tRandomData);
                continue;
            }
            if (tRandomData instanceof FluidStack) {
                tRandomData = new FluidContainerData((FluidStack) tRandomData, ST.copy_(aStack), getContainerItem(aStack), T);
                // if (((FluidContainerData)tRandomData).emptyContainer != null)
                // RM.Canner.addRecipe1(T, 16, Math.max(((FluidContainerData)tRandomData).fluid.amount / 64, 16), ((FluidContainerData)tRandomData).emptyContainer, ((FluidContainerData)tRandomData).fluid, NF, ((FluidContainerData)tRandomData).filledContainer);
                // RM.Canner.addRecipe1(T, 16, Math.max(((FluidContainerData)tRandomData).fluid.amount / 64, 16), ((FluidContainerData)tRandomData).filledContainer, NF, ((FluidContainerData)tRandomData).fluid, ST.container(((FluidContainerData)tRandomData).filledContainer, F));
                FL.reg((FluidContainerData) tRandomData, T, F);
                continue;
            }
            if (tRandomData instanceof FluidContainerData) {
                // if (((FluidContainerData)tRandomData).emptyContainer != null)
                // RM.Canner.addRecipe1(T, 16, Math.max(((FluidContainerData)tRandomData).fluid.amount / 64, 16), ((FluidContainerData)tRandomData).emptyContainer, ((FluidContainerData)tRandomData).fluid, NF, ((FluidContainerData)tRandomData).filledContainer);
                // RM.Canner.addRecipe1(T, 16, Math.max(((FluidContainerData)tRandomData).fluid.amount / 64, 16), ((FluidContainerData)tRandomData).filledContainer, NF, ((FluidContainerData)tRandomData).fluid, ST.container(((FluidContainerData)tRandomData).filledContainer, F));
                FL.reg((FluidContainerData) tRandomData, T, F);
                continue;
            }
            if (tRandomData instanceof Runnable) {
                GAPI.mAfterPostInit.add((Runnable) tRandomData);
                tUseOreDict = F;
            }
            if (tUseOreDict) {
                OM.reg(tRandomData, aStack);
                continue;
            }
        }
        if (COMPAT_TC != null)
            COMPAT_TC.registerThaumcraftAspectsToItem(aStack, tAspects, F);
        return ST.update(ST.make(this, 1, aID));
    }
    return null;
}
Also used : IItemEnergy(gregapi.item.IItemEnergy) OreDictItemData(gregapi.oredict.OreDictItemData) FluidStack(net.minecraftforge.fluids.FluidStack) IFoodStat(gregapi.item.multiitem.food.IFoodStat) ItemStackSet(gregapi.code.ItemStackSet) IItemContainer(gregapi.code.IItemContainer) PrefixItem(gregapi.item.prefixitem.PrefixItem) FluidContainerData(net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData) ArrayListNoNulls(gregapi.code.ArrayListNoNulls) TC_AspectStack(gregapi.data.TC.TC_AspectStack) IBehavior(gregapi.item.multiitem.behaviors.IBehavior) ICover(gregapi.cover.ICover) TagData(gregapi.code.TagData) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ICover

use of gregapi.cover.ICover in project gregtech6 by GregTech6.

the class TileEntityBase06Covers method onToolClick.

@Override
public final long onToolClick(String aTool, long aRemainingDurability, long aQuality, Entity aPlayer, List<String> aChatReturn, IInventory aPlayerInventory, boolean aSneaking, ItemStack aStack, byte aSide, float aHitX, float aHitY, float aHitZ) {
    if (!allowInteraction(aPlayer))
        return 0;
    if (checkObstruction(aPlayer instanceof EntityPlayer ? (EntityPlayer) aPlayer : null, aSide, aHitX, aHitY, aHitZ))
        return 0;
    if (SIDES_VALID[aSide] && hasCovers()) {
        byte tSide = usePipePlacementMode(aSide) && mCovers.mIDs[aSide] == 0 ? UT.Code.getSideWrenching(aSide, aHitX, aHitY, aHitZ) : aSide;
        if (aTool.equals(TOOL_crowbar) && isServerSide()) {
            ItemStack tStack = getCoverItem(tSide);
            ICover tCover = mCovers.mBehaviours[tSide];
            if (tStack != null && setCoverItem(tSide, null, aPlayer, F, T)) {
                if (!(aPlayer instanceof EntityPlayer) || !UT.Inventories.addStackToPlayerInventory((EntityPlayer) aPlayer, tStack, F))
                    ST.place(worldObj, getOffsetX(aSide) + 0.5, getOffsetY(aSide) + 0.5, getOffsetZ(aSide) + 0.5, tStack);
                if (tCover != null)
                    tCover.onAfterCrowbar(this);
                return 10000;
            }
        }
        if (mCovers.mBehaviours[tSide] != null) {
            if (tSide != aSide) {
                long rDamage = onToolClick2(aTool, aRemainingDurability, aQuality, aPlayer, aChatReturn, aPlayerInventory, aSneaking, aStack, aSide, aHitX, aHitY, aHitZ);
                if (rDamage > 0)
                    return rDamage;
            }
            return mCovers.mBehaviours[tSide].onToolClick(tSide, mCovers, aTool, aRemainingDurability, aQuality, aPlayer, aChatReturn, aPlayerInventory, aSneaking, aStack, aSide, aHitX, aHitY, aHitZ);
        }
    }
    return onToolClick2(aTool, aRemainingDurability, aQuality, aPlayer, aChatReturn, aPlayerInventory, aSneaking, aStack, aSide, aHitX, aHitY, aHitZ);
}
Also used : ICover(gregapi.cover.ICover) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ICover (gregapi.cover.ICover)7 ItemStack (net.minecraft.item.ItemStack)3 ArrayListNoNulls (gregapi.code.ArrayListNoNulls)2 OreDictItemData (gregapi.oredict.OreDictItemData)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 IBlockBase (gregapi.block.IBlockBase)1 MultiTileEntityBlockInternal (gregapi.block.multitileentity.MultiTileEntityBlockInternal)1 IItemContainer (gregapi.code.IItemContainer)1 ItemStackSet (gregapi.code.ItemStackSet)1 TagData (gregapi.code.TagData)1 ICompat (gregapi.compat.ICompat)1 CoverRedstoneRepeater (gregapi.cover.covers.CoverRedstoneRepeater)1 CoverRedstoneTorch (gregapi.cover.covers.CoverRedstoneTorch)1 TC_AspectStack (gregapi.data.TC.TC_AspectStack)1 IItemEnergy (gregapi.item.IItemEnergy)1 ItemFluidDisplay (gregapi.item.ItemFluidDisplay)1 IBehavior (gregapi.item.multiitem.behaviors.IBehavior)1 IFoodStat (gregapi.item.multiitem.food.IFoodStat)1 PrefixItem (gregapi.item.prefixitem.PrefixItem)1