Search in sources :

Example 1 with MetaPrefixItem

use of gregtech.api.items.materialitem.MetaPrefixItem in project GregTech by GregTechCEu.

the class CommandRecipeCheck method prettyPrintItemStack.

public String prettyPrintItemStack(ItemStack stack) {
    if (stack.getItem() instanceof MetaItem) {
        MetaItem<?> metaItem = (MetaItem<?>) stack.getItem();
        MetaValueItem metaValueItem = metaItem.getItem(stack);
        if (metaValueItem == null) {
            if (metaItem instanceof MetaPrefixItem) {
                Material material = ((MetaPrefixItem) metaItem).getMaterial(stack);
                OrePrefix orePrefix = ((MetaPrefixItem) metaItem).getOrePrefix();
                return "(MetaItem) OrePrefix: " + orePrefix.name + ", Material: " + material + " * " + stack.getCount();
            }
        } else {
            if (MetaItems.INTEGRATED_CIRCUIT.isItemEqual(stack)) {
                return "Config circuit #" + IntCircuitIngredient.getCircuitConfiguration(stack);
            }
            return "(MetaItem) " + metaValueItem.unlocalizedName + " * " + stack.getCount();
        }
    } else if (stack.getItem() instanceof MachineItemBlock) {
        MetaTileEntity mte = MachineItemBlock.getMetaTileEntity(stack);
        if (mte != null) {
            String id = mte.metaTileEntityId.toString();
            if (mte.metaTileEntityId.getNamespace().equals("gregtech"))
                id = mte.metaTileEntityId.getPath();
            return "(MetaTileEntity) " + id + " * " + stack.getCount();
        }
    } else {
        Block block = Block.getBlockFromItem(stack.getItem());
        String id = null;
        if (block instanceof BlockCompressed) {
            id = "block" + ((BlockCompressed) block).getGtMaterial(stack.getMetadata()).toCamelCaseString();
        } else if (block instanceof BlockFrame) {
            id = "frame" + ((BlockFrame) block).getGtMaterial(stack.getMetadata()).toCamelCaseString();
        } else if (block instanceof BlockMaterialPipe) {
            id = ((BlockMaterialPipe<?, ?, ?>) block).getPrefix().name + ((BlockMaterialPipe<?, ?, ?>) block).getItemMaterial(stack).toCamelCaseString();
        }
        if (id != null) {
            return "(MetaBlock) " + id + " * " + stack.getCount();
        }
    }
    // noinspection ConstantConditions
    return stack.getItem().getRegistryName().toString() + " * " + stack.getCount() + " (Meta " + stack.getItemDamage() + ")";
}
Also used : MetaValueItem(gregtech.api.items.metaitem.MetaItem.MetaValueItem) MetaItem(gregtech.api.items.metaitem.MetaItem) BlockCompressed(gregtech.common.blocks.BlockCompressed) OrePrefix(gregtech.api.unification.ore.OrePrefix) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) Material(gregtech.api.unification.material.Material) BlockMaterialPipe(gregtech.api.pipenet.block.material.BlockMaterialPipe) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) Block(net.minecraft.block.Block) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) MetaPrefixItem(gregtech.api.items.materialitem.MetaPrefixItem) BlockFrame(gregtech.common.blocks.BlockFrame)

Example 2 with MetaPrefixItem

use of gregtech.api.items.materialitem.MetaPrefixItem in project GregTech by GregTechCEu.

the class MetaItems method init.

public static void init() {
    MetaItem1 first = new MetaItem1();
    first.setRegistryName("meta_item_1");
    MetaTool tool = new MetaTool();
    tool.setRegistryName("meta_tool");
    CT_OREDICT_ITEM = new MetaOreDictItem((short) 0);
    CT_OREDICT_ITEM.setRegistryName("meta_oredict_item_ct");
    MetaArmor armor = new MetaArmor();
    armor.setRegistryName("gt_armor");
    for (OrePrefix prefix : orePrefixes) {
        String regName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, prefix.name());
        MetaPrefixItem metaOrePrefix = new MetaPrefixItem(prefix);
        metaOrePrefix.setRegistryName(String.format("meta_%s", regName));
    }
}
Also used : MetaArmor(gregtech.common.items.armor.MetaArmor) OrePrefix(gregtech.api.unification.ore.OrePrefix) MetaPrefixItem(gregtech.api.items.materialitem.MetaPrefixItem) MetaOreDictItem(gregtech.api.items.metaitem.MetaOreDictItem)

Aggregations

MetaPrefixItem (gregtech.api.items.materialitem.MetaPrefixItem)2 OrePrefix (gregtech.api.unification.ore.OrePrefix)2 MachineItemBlock (gregtech.api.block.machines.MachineItemBlock)1 MetaItem (gregtech.api.items.metaitem.MetaItem)1 MetaValueItem (gregtech.api.items.metaitem.MetaItem.MetaValueItem)1 MetaOreDictItem (gregtech.api.items.metaitem.MetaOreDictItem)1 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)1 BlockMaterialPipe (gregtech.api.pipenet.block.material.BlockMaterialPipe)1 Material (gregtech.api.unification.material.Material)1 BlockCompressed (gregtech.common.blocks.BlockCompressed)1 BlockFrame (gregtech.common.blocks.BlockFrame)1 MetaArmor (gregtech.common.items.armor.MetaArmor)1 Block (net.minecraft.block.Block)1