use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class RecyclingRecipes method registerRecyclingRecipes.
public static void registerRecyclingRecipes(ItemStack input, List<MaterialStack> components, boolean ignoreArcSmelting, @Nullable OrePrefix prefix) {
// Gather the valid Materials for use in recycling recipes.
// - Filter out Materials that cannot create a Dust
// - Filter out Materials that do not equate to at least 1 Nugget worth of Material.
// - Sort Materials on a descending material amount
List<MaterialStack> materials = components.stream().filter(stack -> stack.material.hasProperty(PropertyKey.DUST)).filter(stack -> stack.amount >= M / 9).sorted(Comparator.comparingLong(ms -> -ms.amount)).collect(Collectors.toList());
// Exit if no Materials matching the above requirements exist.
if (materials.isEmpty())
return;
// Calculate the voltage multiplier based on if a Material has a Blast Property
int voltageMultiplier = calculateVoltageMultiplier(components);
if (prefix != OrePrefix.dust) {
registerMaceratorRecycling(input, components, voltageMultiplier);
}
if (prefix != null) {
registerExtractorRecycling(input, components, voltageMultiplier, prefix);
}
if (ignoreArcSmelting)
return;
if (components.size() == 1) {
Material m = components.get(0).material;
// skip non-ingot materials
if (!m.hasProperty(PropertyKey.INGOT)) {
return;
}
// Skip Ingot -> Ingot Arc Recipes
if (OreDictUnifier.getPrefix(input) == OrePrefix.ingot && m.getProperty(PropertyKey.INGOT).getArcSmeltInto() == m) {
return;
}
}
registerArcRecycling(input, components, prefix);
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class RecyclingRecipes method finalizeOutputs.
private static List<ItemStack> finalizeOutputs(List<MaterialStack> materials, int maxOutputs, Function<MaterialStack, ItemStack> toItemStackMapper) {
// Map of ItemStack, Long to properly sort by the true material amount for outputs
List<Tuple<ItemStack, MaterialStack>> outputs = new ArrayList<>();
for (MaterialStack ms : materials) {
ItemStack stack = toItemStackMapper.apply(ms);
if (stack == ItemStack.EMPTY)
continue;
if (stack.getCount() > 64) {
UnificationEntry entry = OreDictUnifier.getUnificationEntry(stack);
if (entry != null) {
// should always be true
OrePrefix prefix = entry.orePrefix;
// so simply split the stacks and continue.
if (prefix == OrePrefix.block || prefix == OrePrefix.dust) {
splitStacks(outputs, stack, entry);
} else {
// Attempt to split and to shrink the stack, and choose the option that creates the
// "larger" single stack, in terms of raw material amount.
List<Tuple<ItemStack, MaterialStack>> split = new ArrayList<>();
List<Tuple<ItemStack, MaterialStack>> shrink = new ArrayList<>();
splitStacks(split, stack, entry);
shrinkStacks(shrink, stack, entry);
if (split.get(0).getSecond().amount > shrink.get(0).getSecond().amount) {
outputs.addAll(split);
} else
outputs.addAll(shrink);
}
}
} else
outputs.add(new Tuple<>(stack, ms));
}
// Sort the List by total material amount descending.
outputs.sort(Comparator.comparingLong(e -> -e.getSecond().amount));
// Sort "duplicate" outputs to the end.
// For example, if there are blocks of Steel and nuggets of Steel, and the nuggets
// are preventing some other output from occupying one of the final slots of the machine,
// cut the nuggets out to favor the newer item instead of having 2 slots occupied by Steel.
//
// There is probably a better way to do this.
Map<MaterialStack, ItemStack> temp = new HashMap<>();
for (Tuple<ItemStack, MaterialStack> t : outputs) {
boolean isInMap = false;
for (MaterialStack ms : temp.keySet()) {
if (ms.material == t.getSecond().material) {
isInMap = true;
break;
}
}
if (!isInMap)
temp.put(t.getSecond(), t.getFirst());
}
temp.putAll(outputs.stream().filter(t -> !temp.containsKey(t.getSecond())).collect(Collectors.toMap(Tuple::getSecond, Tuple::getFirst)));
// Filter Ash to the very end of the list, after all others
List<ItemStack> ashStacks = temp.entrySet().stream().filter(e -> isAshMaterial(e.getKey())).sorted(Comparator.comparingLong(e -> -e.getKey().amount)).map(Entry::getValue).collect(Collectors.toList());
List<ItemStack> returnValues = temp.entrySet().stream().sorted(Comparator.comparingLong(e -> -e.getKey().amount)).filter(e -> !isAshMaterial(e.getKey())).limit(maxOutputs).map(Entry::getValue).collect(Collectors.toList());
for (int i = 0; i < ashStacks.size() && returnValues.size() < maxOutputs; i++) {
returnValues.add(ashStacks.get(i));
}
return returnValues;
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class BrewingRecipes method init.
public static void init() {
for (Material material : new Material[] { Talc, Soapstone, Redstone }) {
BREWING_RECIPES.recipeBuilder().input(dust, material).fluidInputs(Oil.getFluid(1000)).fluidOutputs(Lubricant.getFluid(1000)).duration(128).EUt(4).buildAndRegister();
BREWING_RECIPES.recipeBuilder().input(dust, material).fluidInputs(Creosote.getFluid(1000)).fluidOutputs(Lubricant.getFluid(1000)).duration(128).EUt(4).buildAndRegister();
BREWING_RECIPES.recipeBuilder().input(dust, material).fluidInputs(SeedOil.getFluid(1000)).fluidOutputs(Lubricant.getFluid(1000)).duration(128).EUt(4).buildAndRegister();
}
// Biomass
BREWING_RECIPES.recipeBuilder().duration(800).EUt(3).input("treeSapling", 1).fluidInputs(Water.getFluid(100)).fluidOutputs(Biomass.getFluid(100)).buildAndRegister();
BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Items.POTATO)).fluidInputs(Water.getFluid(20)).fluidOutputs(Biomass.getFluid(20)).buildAndRegister();
BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Items.CARROT)).fluidInputs(Water.getFluid(20)).fluidOutputs(Biomass.getFluid(20)).buildAndRegister();
BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Blocks.CACTUS)).fluidInputs(Water.getFluid(20)).fluidOutputs(Biomass.getFluid(20)).buildAndRegister();
BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Items.REEDS)).fluidInputs(Water.getFluid(20)).fluidOutputs(Biomass.getFluid(20)).buildAndRegister();
BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Blocks.BROWN_MUSHROOM)).fluidInputs(Water.getFluid(20)).fluidOutputs(Biomass.getFluid(20)).buildAndRegister();
BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Blocks.RED_MUSHROOM)).fluidInputs(Water.getFluid(20)).fluidOutputs(Biomass.getFluid(20)).buildAndRegister();
BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Items.BEETROOT)).fluidInputs(Water.getFluid(20)).fluidOutputs(Biomass.getFluid(20)).buildAndRegister();
BREWING_RECIPES.recipeBuilder().EUt(4).duration(128).input(BIO_CHAFF).fluidInputs(Water.getFluid(750)).fluidOutputs(Biomass.getFluid(750)).buildAndRegister();
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class ToolRecipeHandler method registerSoftHammerRecipes.
private static void registerSoftHammerRecipes() {
Material[] softHammerMaterials = new Material[] { Materials.Wood, Materials.Rubber, Materials.Polyethylene, Materials.Polytetrafluoroethylene, Materials.Polybenzimidazole };
for (int i = 0; i < softHammerMaterials.length; i++) {
Material material = softHammerMaterials[i];
ItemStack itemStack = MetaItems.SOFT_HAMMER.getStackForm();
if (ModHandler.isMaterialWood(material)) {
MetaItems.SOFT_HAMMER.setToolData(itemStack, material, 48, 1, 4.0f, 1.0f);
ModHandler.addMirroredShapedRecipe(String.format("soft_hammer_%s", material), itemStack, "XX ", "XXS", "XX ", 'X', new UnificationEntry(OrePrefix.plank, material), 'S', new UnificationEntry(OrePrefix.stick, Materials.Wood));
} else {
MetaItems.SOFT_HAMMER.setToolData(itemStack, material, 128 * (1 << i), 1, 4.0f, 1.0f);
ModHandler.addMirroredShapedRecipe(String.format("soft_hammer_%s", material), itemStack, "XX ", "XXS", "XX ", 'X', new UnificationEntry(OrePrefix.ingot, material), 'S', new UnificationEntry(OrePrefix.stick, Materials.Wood));
}
}
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class ToolRecipeHandler method processSimpleToolHead.
public static void processSimpleToolHead(OrePrefix toolPrefix, Material material, MetaToolValueItem toolItem, boolean mirrored, Object... recipe) {
Material handleMaterial = Materials.Wood;
ModHandler.addShapelessRecipe(String.format("%s_%s_%s", toolPrefix.name(), material, handleMaterial), toolItem.getStackForm(material), new UnificationEntry(toolPrefix, material), new UnificationEntry(OrePrefix.stick, handleMaterial));
if (material.hasProperty(PropertyKey.INGOT) && material.hasFlag(GENERATE_PLATE)) {
addSimpleToolRecipe(toolPrefix, material, toolItem, new UnificationEntry(OrePrefix.plate, material), new UnificationEntry(OrePrefix.ingot, material), mirrored, recipe);
} else if (material.hasProperty(GEM)) {
addSimpleToolRecipe(toolPrefix, material, toolItem, new UnificationEntry(OrePrefix.gem, material), new UnificationEntry(OrePrefix.gem, material), mirrored, recipe);
}
}
Aggregations