use of gregtech.api.unification.material.type.SolidMaterial in project GregTech by GregTechCE.
the class ToolMetaItem method onCreated.
@Override
public void onCreated(ItemStack stack, World world, EntityPlayer player) {
T metaToolValueItem = getItem(stack);
if (metaToolValueItem != null) {
IToolStats toolStats = metaToolValueItem.getToolStats();
toolStats.onToolCrafted(stack, player);
ArrayList<EnchantmentData> enchantments = new ArrayList<>(toolStats.getEnchantments(stack));
SolidMaterial material = getPrimaryMaterial(stack);
if (material == null) {
return;
}
for (EnchantmentData enchantmentData : material.toolEnchantments) {
Optional<EnchantmentData> sameEnchantment = enchantments.stream().filter(it -> it.enchantment == enchantmentData.enchantment).findAny();
if (sameEnchantment.isPresent()) {
enchantments.remove(sameEnchantment.get());
int level = Math.min(enchantmentData.level + sameEnchantment.get().level, enchantmentData.enchantment.getMaxLevel());
enchantments.add(new EnchantmentData(enchantmentData.enchantment, level));
} else {
enchantments.add(enchantmentData);
}
}
for (EnchantmentData enchantmentData : enchantments) {
stack.addEnchantment(enchantmentData.enchantment, enchantmentData.level);
}
}
}
use of gregtech.api.unification.material.type.SolidMaterial in project GregTech by GregTechCE.
the class ProcessingCrushed method registerOre.
/*public static void register() {
ProcessingCrushed processing = new ProcessingCrushed();
OrePrefix.clump.addProcessingHandler(processing);
OrePrefix.shard.addProcessingHandler(processing);
OrePrefix.crushed.addProcessingHandler(processing);
OrePrefix.dirtyGravel.addProcessingHandler(processing);
}*/
public void registerOre(UnificationEntry entry, String modName, SimpleItemStack simpleStack) {
ItemStack stack = simpleStack.asItemStack();
if (entry.material instanceof SolidMaterial) {
SolidMaterial material = (SolidMaterial) entry.material;
ItemStack impureDustStack = OreDictUnifier.get(OrePrefix.dustImpure, material);
ItemStack dustStack = OreDictUnifier.get(OrePrefix.dust, material);
DustMaterial byproductMaterial = GTUtility.selectItemInList(0, material, material.oreByProducts, DustMaterial.class);
// fallback for dirtyGravel, shard & clump
if (impureDustStack.isEmpty()) {
impureDustStack = dustStack;
}
RecipeMap.HAMMER_RECIPES.recipeBuilder().inputs(stack).outputs(impureDustStack).duration(10).EUt(16).buildAndRegister();
RecipeMap.MACERATOR_RECIPES.recipeBuilder().inputs(stack).outputs(impureDustStack).duration(100).EUt(24).chancedOutput(OreDictUnifier.get(OrePrefix.dust, byproductMaterial), 1000);
RecipeMap.ORE_WASHER_RECIPES.recipeBuilder().inputs(stack).fluidInputs(ModHandler.getWater(1000)).outputs(OreDictUnifier.get(entry.orePrefix == OrePrefix.crushed ? OrePrefix.crushedPurified : OrePrefix.dustPure, material), OreDictUnifier.get(OrePrefix.dustTiny, byproductMaterial), OreDictUnifier.get(OrePrefix.dust, Materials.Stone)).buildAndRegister();
RecipeMap.THERMAL_CENTRIFUGE_RECIPES.recipeBuilder().inputs(stack).duration((int) entry.material.getMass() * 20).outputs(OreDictUnifier.get(entry.orePrefix == OrePrefix.crushed ? OrePrefix.crushedCentrifuged : OrePrefix.dust, entry.material), OreDictUnifier.get(OrePrefix.dustTiny, byproductMaterial), OreDictUnifier.get(OrePrefix.dust, Materials.Stone)).buildAndRegister();
if (material.washedIn != null) {
DustMaterial washingByproduct = GTUtility.selectItemInList(3, material, material.oreByProducts, DustMaterial.class);
RecipeMap.CHEMICAL_BATH_RECIPES.recipeBuilder().inputs(stack).fluidInputs(material.washedIn.getFluid(1000)).outputs(OreDictUnifier.get(entry.orePrefix == OrePrefix.crushed ? OrePrefix.crushedPurified : OrePrefix.dustPure, entry.material)).chancedOutput(OreDictUnifier.get(OrePrefix.dust, washingByproduct), 7000).chancedOutput(OreDictUnifier.get(OrePrefix.dust, Materials.Stone), 4000).duration(800).EUt(8).buildAndRegister();
}
}
}
use of gregtech.api.unification.material.type.SolidMaterial in project GregTech by GregTechCE.
the class ProcessingCrushedCentrifuged method registerOre.
public void registerOre(UnificationEntry entry, String modName, SimpleItemStack itemStack) {
if (entry.material instanceof SolidMaterial) {
ItemStack stack = itemStack.asItemStack();
SolidMaterial solidMaterial = (SolidMaterial) entry.material;
ItemStack dustStack = OreDictUnifier.get(OrePrefix.dust, solidMaterial);
ItemStack byproductStack = OreDictUnifier.get(OrePrefix.dust, GTUtility.selectItemInList(2, solidMaterial, solidMaterial.oreByProducts, DustMaterial.class), 1);
RecipeMap.HAMMER_RECIPES.recipeBuilder().inputs(stack).outputs(dustStack).duration(10).EUt(16).buildAndRegister();
RecipeMap.MACERATOR_RECIPES.recipeBuilder().inputs(stack).outputs(dustStack).chancedOutput(byproductStack, 1000).buildAndRegister();
}
}
use of gregtech.api.unification.material.type.SolidMaterial in project GregTech by GregTechCE.
the class ProcessingCrushedPurified method registerOre.
// public static void register() {
// OrePrefix.crushedPurified.addProcessingHandler(new ProcessingCrushedPurified());
// }
// @Override
public void registerOre(UnificationEntry entry, String modName, SimpleItemStack itemStack) {
if (entry.material instanceof SolidMaterial) {
ItemStack crushedPurifiedStack = itemStack.asItemStack();
SolidMaterial solidMaterial = (SolidMaterial) entry.material;
ItemStack crushedCentrifugedStack = OreDictUnifier.get(OrePrefix.crushedCentrifuged, solidMaterial);
ItemStack dustStack = OreDictUnifier.get(OrePrefix.dust, solidMaterial);
ItemStack byproductStack = OreDictUnifier.get(OrePrefix.dustTiny, GTUtility.selectItemInList(1, solidMaterial, solidMaterial.oreByProducts, DustMaterial.class));
if (!crushedCentrifugedStack.isEmpty()) {
RecipeMap.THERMAL_CENTRIFUGE_RECIPES.recipeBuilder().inputs(crushedPurifiedStack).outputs(crushedCentrifugedStack, byproductStack).duration((int) (entry.material.getMass() * 20)).EUt(60).buildAndRegister();
} else {
RecipeMap.THERMAL_CENTRIFUGE_RECIPES.recipeBuilder().inputs(crushedPurifiedStack).outputs(dustStack, byproductStack).duration((int) (entry.material.getMass() * 20)).EUt(60).buildAndRegister();
}
if (entry.material instanceof GemMaterial) {
ItemStack exquisiteStack = OreDictUnifier.get(OrePrefix.gemExquisite, entry.material);
ItemStack flawlessStack = OreDictUnifier.get(OrePrefix.gemFlawless, entry.material);
ItemStack gemStack = OreDictUnifier.get(OrePrefix.gem, entry.material);
ItemStack flawedStack = OreDictUnifier.get(OrePrefix.gemFlawed, entry.material);
ItemStack chippedStack = OreDictUnifier.get(OrePrefix.gemChipped, entry.material);
if (entry.material.hasFlag(GemMaterial.MatFlags.HIGH_SIFTER_OUTPUT)) {
RecipeMap.SIFTER_RECIPES.recipeBuilder().inputs(crushedPurifiedStack).chancedOutput(exquisiteStack, 300).chancedOutput(flawlessStack, 1200).chancedOutput(gemStack, 4500).chancedOutput(flawedStack, 1400).chancedOutput(chippedStack, 2800).chancedOutput(dustStack, 3500).duration(800).EUt(16).buildAndRegister();
} else {
RecipeMap.SIFTER_RECIPES.recipeBuilder().inputs(crushedPurifiedStack).chancedOutput(exquisiteStack, 100).chancedOutput(flawlessStack, 400).chancedOutput(gemStack, 1500).chancedOutput(flawedStack, 2000).chancedOutput(chippedStack, 4000).chancedOutput(dustStack, 5000).duration(800).EUt(16).buildAndRegister();
}
}
}
}
use of gregtech.api.unification.material.type.SolidMaterial in project GregTech by GregTechCE.
the class ProcessingPure method registerOre.
public void registerOre(UnificationEntry entry, String modName, SimpleItemStack simpleStack) {
if (entry.material instanceof SolidMaterial) {
SolidMaterial material = (SolidMaterial) entry.material;
ItemStack stack = simpleStack.asItemStack();
DustMaterial byproductMaterial = GTUtility.selectItemInList(1, material, material.oreByProducts, DustMaterial.class);
ItemStack pureDustStack = OreDictUnifier.get(OrePrefix.dustPure, material);
if (pureDustStack.isEmpty()) {
// fallback for reduced & cleanGravel
pureDustStack = OreDictUnifier.get(OrePrefix.dust, material);
}
RecipeMap.HAMMER_RECIPES.recipeBuilder().inputs(stack).outputs(OreDictUnifier.get(OrePrefix.dustPure, material)).duration(10).EUt(16).buildAndRegister();
RecipeMap.MACERATOR_RECIPES.recipeBuilder().inputs(stack).outputs(pureDustStack).chancedOutput(OreDictUnifier.get(OrePrefix.dust, byproductMaterial), 1000).buildAndRegister();
}
}
Aggregations