Search in sources :

Example 61 with Material

use of gregtech.api.unification.material.Material 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 62 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class BlockFrame method onTextureStitch.

@Override
@SideOnly(Side.CLIENT)
public void onTextureStitch(TextureStitchEvent.Pre event) {
    for (IBlockState state : this.getBlockState().getValidStates()) {
        Material material = state.getValue(variantProperty);
        event.getMap().registerSprite(MaterialIconType.frameGt.getBlockPath(material.getMaterialIconSet()));
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) PropertyMaterial(gregtech.common.blocks.properties.PropertyMaterial) Material(gregtech.api.unification.material.Material) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 63 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class MetaBlocks method createCompressedBlock.

private static void createCompressedBlock(Material[] materials, int index) {
    BlockCompressed block = new BlockCompressed(materials);
    block.setRegistryName("meta_block_compressed_" + index);
    for (Material material : materials) {
        COMPRESSED.put(material, block);
    }
}
Also used : Material(gregtech.api.unification.material.Material)

Example 64 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class MetaBlocks method createGeneratedBlock.

/**
 * Deterministically populates a category of MetaBlocks based on the unique registry ID of each qualifying Material.
 *
 * @param materialPredicate a filter for determining if a Material qualifies for generation in the category.
 * @param blockGenerator    a function which accepts a Materials set to pack into a MetaBlock, and the ordinal this
 *                          MetaBlock should have within its category.
 */
protected static void createGeneratedBlock(Predicate<Material> materialPredicate, BiConsumer<Material[], Integer> blockGenerator) {
    Map<Integer, Material[]> blocksToGenerate = new TreeMap<>();
    for (Material material : GregTechAPI.MATERIAL_REGISTRY) {
        if (materialPredicate.test(material)) {
            int id = material.getId();
            int metaBlockID = id / 16;
            int subBlockID = id % 16;
            if (!blocksToGenerate.containsKey(metaBlockID)) {
                Material[] materials = new Material[16];
                Arrays.fill(materials, Materials.NULL);
                blocksToGenerate.put(metaBlockID, materials);
            }
            blocksToGenerate.get(metaBlockID)[subBlockID] = material;
        }
    }
    blocksToGenerate.forEach((key, value) -> blockGenerator.accept(value, key));
}
Also used : Material(gregtech.api.unification.material.Material)

Example 65 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class BlockCompressed method getHarvestLevel.

@Override
public int getHarvestLevel(IBlockState state) {
    Material material = state.getValue(variantProperty);
    DustProperty prop = material.getProperty(PropertyKey.DUST);
    if (prop != null) {
        return material.getHarvestLevel();
    }
    return 0;
}
Also used : PropertyMaterial(gregtech.common.blocks.properties.PropertyMaterial) Material(gregtech.api.unification.material.Material) DustProperty(gregtech.api.unification.material.properties.DustProperty)

Aggregations

Material (gregtech.api.unification.material.Material)76 ItemStack (net.minecraft.item.ItemStack)31 UnificationEntry (gregtech.api.unification.stack.UnificationEntry)19 OrePrefix (gregtech.api.unification.ore.OrePrefix)13 MaterialStack (gregtech.api.unification.stack.MaterialStack)12 Nonnull (javax.annotation.Nonnull)10 PropertyKey (gregtech.api.unification.material.properties.PropertyKey)9 Block (net.minecraft.block.Block)8 IBlockState (net.minecraft.block.state.IBlockState)8 GTValues (gregtech.api.GTValues)7 Collectors (java.util.stream.Collectors)7 Nullable (javax.annotation.Nullable)7 Materials (gregtech.api.unification.material.Materials)6 DustProperty (gregtech.api.unification.material.properties.DustProperty)6 ToolProperty (gregtech.api.unification.material.properties.ToolProperty)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 GregTechAPI (gregtech.api.GregTechAPI)5 OreDictUnifier (gregtech.api.unification.OreDictUnifier)5 MarkerMaterial (gregtech.api.unification.material.MarkerMaterial)5 ItemMaterialInfo (gregtech.api.unification.stack.ItemMaterialInfo)5