use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class OreRecipeHandler method processCrushedPurified.
public static void processCrushedPurified(OrePrefix purifiedPrefix, Material material, OreProperty property) {
ItemStack crushedCentrifugedStack = OreDictUnifier.get(OrePrefix.crushedCentrifuged, material);
ItemStack dustStack = OreDictUnifier.get(OrePrefix.dustPure, material);
Material byproductMaterial = GTUtility.selectItemInList(1, material, property.getOreByProducts(), Material.class);
ItemStack byproductStack = OreDictUnifier.get(OrePrefix.dust, byproductMaterial);
RecipeMaps.FORGE_HAMMER_RECIPES.recipeBuilder().input(purifiedPrefix, material).outputs(dustStack).duration(10).EUt(16).buildAndRegister();
RecipeMaps.MACERATOR_RECIPES.recipeBuilder().input(purifiedPrefix, material).outputs(dustStack).chancedOutput(byproductStack, 1400, 850).duration(400).buildAndRegister();
ModHandler.addShapelessRecipe(String.format("purified_ore_to_dust_%s", material), dustStack, 'h', new UnificationEntry(purifiedPrefix, material));
if (!crushedCentrifugedStack.isEmpty()) {
RecipeMaps.THERMAL_CENTRIFUGE_RECIPES.recipeBuilder().input(purifiedPrefix, material).outputs(crushedCentrifugedStack, OreDictUnifier.get(OrePrefix.dustTiny, byproductMaterial, 3)).buildAndRegister();
}
if (material.hasProperty(PropertyKey.GEM)) {
ItemStack exquisiteStack = OreDictUnifier.get(OrePrefix.gemExquisite, material);
ItemStack flawlessStack = OreDictUnifier.get(OrePrefix.gemFlawless, material);
ItemStack gemStack = OreDictUnifier.get(OrePrefix.gem, material);
ItemStack flawedStack = OreDictUnifier.get(OrePrefix.gemFlawed, material);
ItemStack chippedStack = OreDictUnifier.get(OrePrefix.gemChipped, material);
if (material.hasFlag(HIGH_SIFTER_OUTPUT)) {
RecipeBuilder<SimpleRecipeBuilder> builder = RecipeMaps.SIFTER_RECIPES.recipeBuilder().input(purifiedPrefix, material).chancedOutput(exquisiteStack, 500, 150).chancedOutput(flawlessStack, 1500, 200).chancedOutput(gemStack, 5000, 1000).chancedOutput(dustStack, 2500, 500).duration(400).EUt(16);
if (!flawedStack.isEmpty())
builder.chancedOutput(flawedStack, 2000, 500);
if (!chippedStack.isEmpty())
builder.chancedOutput(chippedStack, 3000, 350);
builder.buildAndRegister();
} else {
RecipeBuilder<SimpleRecipeBuilder> builder = RecipeMaps.SIFTER_RECIPES.recipeBuilder().input(purifiedPrefix, material).chancedOutput(exquisiteStack, 300, 100).chancedOutput(flawlessStack, 1000, 150).chancedOutput(gemStack, 3500, 500).chancedOutput(dustStack, 5000, 750).duration(400).EUt(16);
if (!flawedStack.isEmpty())
builder.chancedOutput(flawedStack, 2500, 300);
if (!exquisiteStack.isEmpty())
builder.chancedOutput(chippedStack, 3500, 400);
builder.buildAndRegister();
}
}
processMetalSmelting(purifiedPrefix, material, property);
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class ToolMetaItem method getHarvestLevel.
public int getHarvestLevel(ItemStack itemStack) {
T metaToolValueItem = getItem(itemStack);
if (metaToolValueItem != null) {
NBTTagCompound toolTag = getToolStatsTag(itemStack);
Material toolMaterial = getToolMaterial(itemStack);
IToolStats toolStats = metaToolValueItem.getToolStats();
int harvestLevel = 0;
if (toolTag != null && toolTag.hasKey("HarvestLevel")) {
harvestLevel = toolTag.getInteger("HarvestLevel");
} else if (toolMaterial != null) {
DustProperty prop = toolMaterial.getProperty(PropertyKey.DUST);
if (prop != null)
harvestLevel = prop.getHarvestLevel();
else
return 0;
}
int baseHarvestLevel = toolStats.getBaseQuality(itemStack);
return baseHarvestLevel + harvestLevel;
}
return 0;
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class ToolMetaItem method getItemStackDisplayName.
@Nonnull
@Override
public String getItemStackDisplayName(ItemStack stack) {
if (stack.getItemDamage() >= metaItemOffset) {
T item = getItem(stack);
if (item == null) {
return "invalid item";
}
Material primaryMaterial = getToolMaterial(stack);
String materialName = primaryMaterial == null ? "" : String.valueOf(primaryMaterial.getLocalizedName());
return LocalizationUtils.format("metaitem." + item.unlocalizedName + ".name", materialName);
}
return super.getItemStackDisplayName(stack);
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class ToolMetaItem method getMaxItemDamage.
@Override
public int getMaxItemDamage(ItemStack itemStack) {
T metaToolValueItem = getItem(itemStack);
if (metaToolValueItem != null) {
NBTTagCompound toolTag = getToolStatsTag(itemStack);
Material toolMaterial = getToolMaterial(itemStack);
IToolStats toolStats = metaToolValueItem.getToolStats();
int materialDurability = 0;
if (toolTag != null && toolTag.hasKey("MaxDurability")) {
materialDurability = toolTag.getInteger("MaxDurability");
} else if (toolMaterial != null) {
ToolProperty prop = toolMaterial.getProperty(PropertyKey.TOOL);
if (prop != null)
materialDurability = prop.getToolDurability();
else
return 0;
}
float multiplier = toolStats.getMaxDurabilityMultiplier(itemStack);
return (int) (materialDurability * multiplier);
}
return 0;
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class ToolMetaItemListener method onAnvilChange.
@SubscribeEvent
public static void onAnvilChange(AnvilUpdateEvent event) {
ItemStack firstStack = event.getLeft();
ItemStack secondStack = event.getRight();
if (!firstStack.isEmpty() && !secondStack.isEmpty() && firstStack.getItem() instanceof ToolMetaItem) {
ToolMetaItem<?> toolMetaItem = (ToolMetaItem<?>) firstStack.getItem();
MetaToolValueItem toolValueItem = toolMetaItem.getItem(firstStack);
if (toolValueItem == null) {
return;
}
Material toolMaterial = ToolMetaItem.getToolMaterial(firstStack);
OrePrefix solidPrefix = getSolidPrefix(toolMaterial);
UnificationEntry unificationEntry = OreDictUnifier.getUnificationEntry(secondStack);
double toolDamage = toolMetaItem.getItemDamage(firstStack) / (toolMetaItem.getMaxItemDamage(firstStack) * 1.0);
double materialForFullRepair = toolValueItem.getAmountOfMaterialToRepair(firstStack);
int durabilityPerUnit = (int) Math.ceil(toolMetaItem.getMaxItemDamage(firstStack) / materialForFullRepair);
int materialUnitsRequired = Math.min(secondStack.getCount(), (int) Math.ceil(toolDamage * materialForFullRepair));
int repairCost = (MathHelper.clamp(toolMaterial.getHarvestLevel(), 2, 3) - 1) * materialUnitsRequired;
if (toolDamage > 0.0 && materialUnitsRequired > 0 && unificationEntry != null && unificationEntry.material == toolMaterial && unificationEntry.orePrefix == solidPrefix) {
int durabilityToRegain = durabilityPerUnit * materialUnitsRequired;
ItemStack resultStack = firstStack.copy();
toolMetaItem.regainItemDurability(resultStack, durabilityToRegain);
event.setMaterialCost(materialUnitsRequired);
event.setCost(repairCost);
event.setOutput(resultStack);
}
}
}
Aggregations