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