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);
}
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");
});
}
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));
}
}
}
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;
}
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;
}
Aggregations