Skip to content

Commit

Permalink
Added salvaging recipes for tools and armor
Browse files Browse the repository at this point in the history
also made wooden mattocks and mining tools useable as fuel
  • Loading branch information
Shnupbups committed Oct 13, 2020
1 parent 83fc7c4 commit b473d23
Show file tree
Hide file tree
Showing 91 changed files with 3,069 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.github.chainmailstudios.astromine.datagen.generator.recipe.set;

import net.minecraft.advancement.criterion.ImpossibleCriterion;
import net.minecraft.data.server.recipe.CookingRecipeJsonFactory;
import net.minecraft.item.Item;
import net.minecraft.recipe.Ingredient;

import com.github.chainmailstudios.astromine.datagen.material.MaterialItemType;
import com.github.chainmailstudios.astromine.datagen.material.MaterialSet;
import me.shedaniel.cloth.api.datagen.v1.RecipeData;

import java.util.Arrays;
import java.util.Collection;

public class MultiBlastingSetRecipeGenerator extends MultiCookingSetRecipeGenerator {
public MultiBlastingSetRecipeGenerator(Collection<MaterialItemType> inputs, MaterialItemType output, int time, float experience) {
super(inputs, output, time, experience);
}

public MultiBlastingSetRecipeGenerator(Collection<MaterialItemType> inputs, MaterialItemType output, float experience) {
this(inputs, output, 100, experience);
}

public MultiBlastingSetRecipeGenerator(Collection<MaterialItemType> inputs, MaterialItemType output) {
this(inputs, output, 100, 0.1f);
}

@Override
public void generate(RecipeData recipes, MaterialSet set) {
Collection<Item> items = getInputs(set);
CookingRecipeJsonFactory
.createBlasting(
Ingredient.ofItems(items.toArray(new Item[0])),
set.getItem(output),
experience,
time)
.criterion("impossible", new ImpossibleCriterion.Conditions())
.offerTo(recipes, getRecipeId(set));
}

@Override
public String getRecipeName(MaterialSet set) {
return set.getItemIdPath(output) + "_from_blasting";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.github.chainmailstudios.astromine.datagen.generator.recipe.set;

import net.minecraft.item.Item;

import com.github.chainmailstudios.astromine.datagen.generator.recipe.set.base.CookingSetRecipeGenerator;
import com.github.chainmailstudios.astromine.datagen.material.MaterialItemType;
import com.github.chainmailstudios.astromine.datagen.material.MaterialSet;

import java.util.ArrayList;
import java.util.Collection;

public abstract class MultiCookingSetRecipeGenerator extends CookingSetRecipeGenerator {
private final Collection<MaterialItemType> inputs;

public MultiCookingSetRecipeGenerator(Collection<MaterialItemType> inputs, MaterialItemType output, int time, float experience) {
super(inputs.stream().findFirst().get(), output, time, experience);
this.inputs = inputs;
}

public Collection<MaterialItemType> getInputs() {
return inputs;
}

public Collection<Item> getInputs(MaterialSet set) {
ArrayList<Item> items = new ArrayList<>();
for(MaterialItemType type:getInputs()) {
if(shouldGenerate(set, type)) items.add(set.getItem(type));
}
return items;
}

@Override
public boolean shouldGenerate(MaterialSet set) {
boolean hasInput = false;
for(MaterialItemType type:getInputs()) {
if(set.hasType(type)) hasInput = true;
}
return hasInput && set.hasType(output);
}

public boolean shouldGenerate(MaterialSet set, MaterialItemType type) {
return set.hasType(output) && set.hasType(type) && !(set.isFromVanilla(type) && set.isFromVanilla(output));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.github.chainmailstudios.astromine.datagen.generator.recipe.set;

import net.minecraft.advancement.criterion.ImpossibleCriterion;
import net.minecraft.data.server.recipe.CookingRecipeJsonFactory;
import net.minecraft.item.Item;
import net.minecraft.recipe.Ingredient;

import com.github.chainmailstudios.astromine.datagen.material.MaterialItemType;
import com.github.chainmailstudios.astromine.datagen.material.MaterialSet;
import me.shedaniel.cloth.api.datagen.v1.RecipeData;

import java.util.Arrays;
import java.util.Collection;

public class MultiSmeltingSetRecipeGenerator extends MultiCookingSetRecipeGenerator {

public MultiSmeltingSetRecipeGenerator(Collection<MaterialItemType> inputs, MaterialItemType output, int time, float experience) {
super(inputs, output, time, experience);
}

public MultiSmeltingSetRecipeGenerator(Collection<MaterialItemType> inputs, MaterialItemType output, float experience) {
this(inputs, output, 200, experience);
}

public MultiSmeltingSetRecipeGenerator(Collection<MaterialItemType> inputs, MaterialItemType output) {
this(inputs, output, 200, 0.1f);
}

@Override
public void generate(RecipeData recipes, MaterialSet set) {
Collection<Item> items = getInputs(set);
CookingRecipeJsonFactory
.createSmelting(
Ingredient.ofItems(items.toArray(new Item[0])),
set.getItem(output),
experience,
time)
.criterion("impossible", new ImpossibleCriterion.Conditions())
.offerTo(recipes, getRecipeId(set));
}

@Override
public String getRecipeName(MaterialSet set) {
return set.getItemIdPath(output) + "_from_smelting";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.github.chainmailstudios.astromine.foundations.datagen.generators.recipe;

import com.github.chainmailstudios.astromine.datagen.generator.recipe.set.MultiBlastingSetRecipeGenerator;
import com.github.chainmailstudios.astromine.datagen.generator.recipe.set.MultiSmeltingSetRecipeGenerator;
import com.github.chainmailstudios.astromine.datagen.material.MaterialItemType;

import java.util.Arrays;
import java.util.List;

import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.AXE;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.BOOTS;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.CHESTPLATE;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.EXCAVATOR;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.HAMMER;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.HELMET;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.HOE;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.LEGGINGS;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.MATTOCK;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.MINING_TOOL;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.PICKAXE;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.SHOVEL;
import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.SWORD;

public class SalvageBlastingRecipeGenerator extends MultiBlastingSetRecipeGenerator {
public static final List<MaterialItemType> SALVAGEABLE = Arrays.asList(
PICKAXE, AXE, SHOVEL, SWORD, HOE,
HAMMER, EXCAVATOR, MINING_TOOL, MATTOCK,
HELMET, CHESTPLATE, LEGGINGS, BOOTS
);

public SalvageBlastingRecipeGenerator(MaterialItemType output) {
super(SALVAGEABLE, output);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.github.chainmailstudios.astromine.foundations.datagen.generators.recipe;

import com.github.chainmailstudios.astromine.datagen.generator.recipe.set.MultiSmeltingSetRecipeGenerator;
import com.github.chainmailstudios.astromine.datagen.material.MaterialItemType;

import static com.github.chainmailstudios.astromine.datagen.material.MaterialItemType.*;

import java.util.Arrays;
import java.util.List;

public class SalvageSmeltingRecipeGenerator extends MultiSmeltingSetRecipeGenerator {
public static final List<MaterialItemType> SALVAGEABLE = Arrays.asList(
PICKAXE, AXE, SHOVEL, SWORD, HOE,
HAMMER, EXCAVATOR, MINING_TOOL, MATTOCK,
HELMET, CHESTPLATE, LEGGINGS, BOOTS
);

public SalvageSmeltingRecipeGenerator(MaterialItemType output) {
super(SALVAGEABLE, output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import com.github.chainmailstudios.astromine.datagen.registry.AstromineRecipeGenerators;
import com.github.chainmailstudios.astromine.foundations.datagen.generators.recipe.AppleCraftingRecipeGenerator;
import com.github.chainmailstudios.astromine.foundations.datagen.generators.recipe.ArmorCraftingRecipeGenerators;
import com.github.chainmailstudios.astromine.foundations.datagen.generators.recipe.SalvageBlastingRecipeGenerator;
import com.github.chainmailstudios.astromine.foundations.datagen.generators.recipe.SalvageSmeltingRecipeGenerator;
import com.github.chainmailstudios.astromine.foundations.datagen.generators.recipe.ToolCraftingRecipeGenerators;
import com.github.chainmailstudios.astromine.foundations.datagen.generators.recipe.WrenchCraftingRecipeGenerator;
import com.github.chainmailstudios.astromine.foundations.registry.AstromineFoundationsBlocks;
Expand Down Expand Up @@ -139,6 +141,11 @@ public class AstromineFoundationsRecipeGenerators extends AstromineRecipeGenerat
public final RecipeGenerator BOOTS_SMITHING_FROM_INGOT = register(new SmithingSetRecipeGenerator(BOOTS, INGOT));
public final RecipeGenerator BOOTS_SMITHING_FROM_GEM = register(new SmithingSetRecipeGenerator(BOOTS, GEM));

public final RecipeGenerator SALVAGE_SMELTING_TO_NUGGET = register(new SalvageSmeltingRecipeGenerator(NUGGET));
public final RecipeGenerator SALVAGE_SMELTING_TO_FRAGMENT = register(new SalvageSmeltingRecipeGenerator(FRAGMENT));
public final RecipeGenerator SALVAGE_BLASTING_TO_NUGGET = register(new SalvageBlastingRecipeGenerator(NUGGET));
public final RecipeGenerator SALVAGE_BLASTING_TO_FRAGMENT = register(new SalvageBlastingRecipeGenerator(FRAGMENT));

public final RecipeGenerator WRENCH = register(new WrenchCraftingRecipeGenerator());

public final RecipeGenerator APPLE = register(new AppleCraftingRecipeGenerator());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"astromine:asterite_fragment_from_blasting"
]
},
"criteria": {
"impossible": {
"trigger": "minecraft:impossible"
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "astromine:asterite_fragment_from_blasting"
}
}
},
"requirements": [
[
"impossible",
"has_the_recipe"
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"astromine:asterite_fragment_from_smelting"
]
},
"criteria": {
"impossible": {
"trigger": "minecraft:impossible"
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "astromine:asterite_fragment_from_smelting"
}
}
},
"requirements": [
[
"impossible",
"has_the_recipe"
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"astromine:bronze_nugget_from_blasting"
]
},
"criteria": {
"impossible": {
"trigger": "minecraft:impossible"
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "astromine:bronze_nugget_from_blasting"
}
}
},
"requirements": [
[
"impossible",
"has_the_recipe"
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"astromine:bronze_nugget_from_smelting"
]
},
"criteria": {
"impossible": {
"trigger": "minecraft:impossible"
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "astromine:bronze_nugget_from_smelting"
}
}
},
"requirements": [
[
"impossible",
"has_the_recipe"
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"astromine:copper_nugget_from_blasting"
]
},
"criteria": {
"impossible": {
"trigger": "minecraft:impossible"
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "astromine:copper_nugget_from_blasting"
}
}
},
"requirements": [
[
"impossible",
"has_the_recipe"
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"astromine:copper_nugget_from_smelting"
]
},
"criteria": {
"impossible": {
"trigger": "minecraft:impossible"
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "astromine:copper_nugget_from_smelting"
}
}
},
"requirements": [
[
"impossible",
"has_the_recipe"
]
]
}
Loading

0 comments on commit b473d23

Please sign in to comment.