Search in sources :

Example 6 with Material

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

the class MaterialMetaItem method getItemStackDisplayName.

@Override
@SideOnly(Side.CLIENT)
public String getItemStackDisplayName(ItemStack itemStack) {
    if (itemStack.getItemDamage() < metaItemOffset) {
        if (!generatedItems.contains((short) itemStack.getItemDamage())) {
            return "";
        }
        Material material = Material.MATERIAL_REGISTRY.getObjectById(itemStack.getItemDamage() % 1000);
        OrePrefix prefix = orePrefixes[itemStack.getItemDamage() / 1000];
        return prefix.getLocalNameForItem(material);
    }
    return super.getItemStackDisplayName(itemStack);
}
Also used : OrePrefix(gregtech.api.unification.ore.OrePrefix) Material(gregtech.api.unification.material.type.Material) MarkerMaterial(gregtech.api.unification.material.type.MarkerMaterial) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 7 with Material

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

the class MaterialMetaItem method registerModels.

@Override
@SideOnly(Side.CLIENT)
public void registerModels() {
    for (short metaItem : generatedItems) {
        OrePrefix prefix = this.orePrefixes[metaItem / 1000];
        Material material = Material.MATERIAL_REGISTRY.getObjectById(metaItem % 1000);
        ModelBakery.registerItemVariants(this, prefix.materialIconType.getItemModelPath(material.materialIconSet));
    }
    int orePrefixAmount = (int) Arrays.stream(this.orePrefixes).filter(Objects::nonNull).count();
    ModelLoader.setCustomMeshDefinition(this, stack -> {
        if (stack.getMetadata() < orePrefixAmount * 1000) {
            OrePrefix prefix = this.orePrefixes[stack.getMetadata() / 1000];
            Material material = Material.MATERIAL_REGISTRY.getObjectById(stack.getMetadata() % 1000);
            return new ModelResourceLocation(prefix.materialIconType.getItemModelPath(material.materialIconSet), "inventory");
        }
        return new ModelResourceLocation("builtin/missing", "missing");
    });
}
Also used : OrePrefix(gregtech.api.unification.ore.OrePrefix) Objects(java.util.Objects) Material(gregtech.api.unification.material.type.Material) MarkerMaterial(gregtech.api.unification.material.type.MarkerMaterial) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with Material

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

the class MaterialMetaItem method onUpdate.

@Override
public void onUpdate(ItemStack itemStack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
    if (itemStack.getItemDamage() < metaItemOffset && generatedItems.contains((short) itemStack.getItemDamage()) && entityIn instanceof EntityLivingBase) {
        EntityLivingBase entity = (EntityLivingBase) entityIn;
        Material material = Material.MATERIAL_REGISTRY.getObjectById(itemStack.getItemDamage() % 1000);
        OrePrefix prefix = orePrefixes[itemStack.getItemDamage() / 1000];
        if (prefix.heatDamage > 0.0 && GTUtility.isWearingFullHeatHazmat(entity) && worldIn.getTotalWorldTime() % 20 == 0) {
            entity.attackEntityFrom(DamageSources.getHeatDamage(), prefix.heatDamage);
        } else if (prefix.heatDamage < 0.0 && GTUtility.isWearingFullFrostHazmat(entity) && worldIn.getTotalWorldTime() % 20 == 0) {
            entity.attackEntityFrom(DamageSources.getFrostDamage(), -prefix.heatDamage);
        }
        if (prefix.name().contains("Dense")) {
            entity.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 100, 1));
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) OrePrefix(gregtech.api.unification.ore.OrePrefix) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Material(gregtech.api.unification.material.type.Material) MarkerMaterial(gregtech.api.unification.material.type.MarkerMaterial)

Example 9 with Material

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

the class ToolMetaItem method getPrimaryMaterial.

@Nullable
public static SolidMaterial getPrimaryMaterial(ItemStack itemStack) {
    NBTTagCompound statsTag = itemStack.getSubCompound("GT.ToolStats");
    if (statsTag == null || !statsTag.hasKey("GT.ToolPrimaryMaterial", Constants.NBT.TAG_STRING))
        return null;
    Material material = Material.MATERIAL_REGISTRY.getObject(statsTag.getString("GT.ToolPrimaryMaterial"));
    if (material instanceof SolidMaterial) {
        return (SolidMaterial) material;
    }
    return null;
}
Also used : SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) Material(gregtech.api.unification.material.type.Material) Nullable(javax.annotation.Nullable)

Example 10 with Material

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

the class ToolMetaItem method getHandleMaterial.

@Nullable
public static SolidMaterial getHandleMaterial(ItemStack itemStack) {
    NBTTagCompound statsTag = itemStack.getSubCompound("GT.ToolStats");
    if (statsTag == null || !statsTag.hasKey("GT.ToolHandleMaterial", Constants.NBT.TAG_STRING))
        return null;
    Material material = Material.MATERIAL_REGISTRY.getObject(statsTag.getString("GT.ToolHandleMaterial"));
    if (material instanceof SolidMaterial) {
        return (SolidMaterial) material;
    }
    return null;
}
Also used : SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) Material(gregtech.api.unification.material.type.Material) Nullable(javax.annotation.Nullable)

Aggregations

Material (gregtech.api.unification.material.type.Material)17 OrePrefix (gregtech.api.unification.ore.OrePrefix)11 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 DustMaterial (gregtech.api.unification.material.type.DustMaterial)5 MarkerMaterial (gregtech.api.unification.material.type.MarkerMaterial)5 java.util (java.util)4 Nullable (javax.annotation.Nullable)4 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)4 ItemStack (net.minecraft.item.ItemStack)4 GregTechAPI (gregtech.api.GregTechAPI)3 Materials (gregtech.api.unification.material.Materials)3 SolidMaterial (gregtech.api.unification.material.type.SolidMaterial)3 SimpleItemStack (gregtech.api.unification.stack.SimpleItemStack)3 IBlockState (net.minecraft.block.state.IBlockState)3 CaseFormat (com.google.common.base.CaseFormat)2 Joiner (com.google.common.base.Joiner)2 ImmutableList (com.google.common.collect.ImmutableList)2 Streams (com.google.common.collect.Streams)2 M (gregtech.api.GTValues.M)2 BlockMachine (gregtech.api.block.machines.BlockMachine)2