Search in sources :

Example 51 with Material

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

the class MetaPrefixItem method onEntityItemUpdate.

@Override
public boolean onEntityItemUpdate(EntityItem itemEntity) {
    int damage = itemEntity.getItem().getMetadata();
    if (itemEntity.getEntityWorld().isRemote)
        return false;
    Material material = GregTechAPI.MATERIAL_REGISTRY.getObjectById(damage);
    if (!purifyMap.containsKey(this.prefix))
        return false;
    BlockPos blockPos = new BlockPos(itemEntity);
    IBlockState blockState = itemEntity.getEntityWorld().getBlockState(blockPos);
    if (!(blockState.getBlock() instanceof BlockCauldron))
        return false;
    int waterLevel = blockState.getValue(BlockCauldron.LEVEL);
    if (waterLevel == 0)
        return false;
    itemEntity.getEntityWorld().setBlockState(blockPos, blockState.withProperty(BlockCauldron.LEVEL, waterLevel - 1));
    ItemStack replacementStack = OreDictUnifier.get(purifyMap.get(prefix), material, itemEntity.getItem().getCount());
    itemEntity.setItem(replacementStack);
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockCauldron(net.minecraft.block.BlockCauldron) Material(gregtech.api.unification.material.Material) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 52 with Material

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

the class MetaPrefixItem method registerOreDict.

public void registerOreDict() {
    for (short metaItem : metaItems.keySet()) {
        Material material = GregTechAPI.MATERIAL_REGISTRY.getObjectById(metaItem);
        ItemStack item = new ItemStack(this, 1, metaItem);
        OreDictUnifier.registerOre(item, prefix, material);
        registerSpecialOreDict(item, material, prefix);
    }
}
Also used : Material(gregtech.api.unification.material.Material) ItemStack(net.minecraft.item.ItemStack)

Example 53 with Material

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

the class ToolMetaItem method getToolAttackDamage.

public float getToolAttackDamage(ItemStack itemStack) {
    T metaToolValueItem = getItem(itemStack);
    if (metaToolValueItem != null) {
        NBTTagCompound toolTag = getToolStatsTag(itemStack);
        Material toolMaterial = getToolMaterial(itemStack);
        IToolStats toolStats = metaToolValueItem.getToolStats();
        float attackDamage = 0;
        if (toolTag != null && toolTag.hasKey("AttackDamage")) {
            attackDamage = toolTag.getFloat("AttackDamage");
        } else if (toolTag != null && toolTag.hasKey("HarvestLevel")) {
            attackDamage = toolTag.getInteger("HarvestLevel");
        } else if (toolMaterial != null) {
            ToolProperty prop = toolMaterial.getProperty(PropertyKey.TOOL);
            if (prop != null)
                attackDamage = prop.getToolAttackDamage();
            else
                return 0;
        }
        float baseAttackDamage = toolStats.getBaseDamage(itemStack);
        return baseAttackDamage + attackDamage;
    }
    return 0;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Material(gregtech.api.unification.material.Material) ToolProperty(gregtech.api.unification.material.properties.ToolProperty)

Example 54 with Material

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

the class ToolMetaItem method getToolDigSpeed.

public float getToolDigSpeed(ItemStack itemStack) {
    T metaToolValueItem = getItem(itemStack);
    if (metaToolValueItem != null) {
        NBTTagCompound toolTag = getToolStatsTag(itemStack);
        Material toolMaterial = getToolMaterial(itemStack);
        IToolStats toolStats = metaToolValueItem.getToolStats();
        float toolSpeed = 0;
        if (toolTag != null && toolTag.hasKey("DigSpeed")) {
            toolSpeed = toolTag.getFloat("DigSpeed");
        } else if (toolMaterial != null) {
            ToolProperty prop = toolMaterial.getProperty(PropertyKey.TOOL);
            if (prop != null)
                toolSpeed = prop.getToolSpeed();
            else
                return 0;
        }
        float multiplier = toolStats.getDigSpeedMultiplier(itemStack);
        return toolSpeed * multiplier;
    }
    return 0;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Material(gregtech.api.unification.material.Material) ToolProperty(gregtech.api.unification.material.properties.ToolProperty)

Example 55 with Material

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

the class ToolMetaItem method getToolMaterial.

public static Material getToolMaterial(ItemStack itemStack) {
    NBTTagCompound statsTag = getToolStatsTag(itemStack);
    if (statsTag == null) {
        return Materials.Neutronium;
    }
    String toolMaterialName;
    if (statsTag.hasKey("Material")) {
        toolMaterialName = statsTag.getString("Material");
    } else if (statsTag.hasKey("PrimaryMaterial")) {
        toolMaterialName = statsTag.getString("PrimaryMaterial");
    } else {
        return Materials.Neutronium;
    }
    Material material = GregTechAPI.MATERIAL_REGISTRY.getObject(toolMaterialName);
    if (material != null) {
        return material;
    }
    return Materials.Neutronium;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Material(gregtech.api.unification.material.Material)

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