WIP: infusion
This commit is contained in:
parent
a1593730f1
commit
163b2881ba
8 changed files with 38 additions and 16 deletions
|
@ -217,16 +217,37 @@ public class InfusionRecipe implements Recipe<InfusionRitual> {
|
|||
public InfusionRecipe fromTag(CompoundTag tag) {
|
||||
Identifier id = new Identifier(tag.getString("id"));
|
||||
InfusionRecipe recipe = new InfusionRecipe(id);
|
||||
|
||||
CompoundSerializer<Ingredient> inputSerializer = this.toSerializer(recipe.input);
|
||||
recipe.input = inputSerializer.fromTag(tag.getCompound("input"));
|
||||
recipe.output = ItemStack.fromTag(tag.getCompound("output"));
|
||||
recipe.time = tag.getInt("time");
|
||||
CompoundTag catalysts = tag.getCompound("catalysts");
|
||||
for(int i = 0; i < recipe.catalysts.length; i++) {
|
||||
String key = Integer.toString(i);
|
||||
CompoundSerializer<Ingredient> cataSerializer = this.toSerializer(recipe.catalysts[i]);
|
||||
recipe.catalysts[i] = cataSerializer.fromTag(catalysts.getCompound(key));
|
||||
}
|
||||
return recipe;
|
||||
}
|
||||
|
||||
public CompoundTag toTag(InfusionRecipe recipe, CompoundTag tag) {
|
||||
CompoundSerializer<?> inputSerializer = CompoundSerializer.class.cast(recipe.input);
|
||||
CompoundSerializer<?> inputSerializer = this.toSerializer(recipe.input);
|
||||
tag.put("input", inputSerializer.toTag(new CompoundTag()));
|
||||
tag.put("output", recipe.output.toTag(new CompoundTag()));
|
||||
|
||||
tag.putInt("time", recipe.time);
|
||||
CompoundTag catalysts = new CompoundTag();
|
||||
for(int i = 0; i < recipe.catalysts.length; i++) {
|
||||
String key = Integer.toString(i);
|
||||
CompoundSerializer<?> cataSerializer = this.toSerializer(recipe.catalysts[i]);
|
||||
catalysts.put(key, cataSerializer.toTag(new CompoundTag()));
|
||||
}
|
||||
tag.put("catalysts", catalysts);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private CompoundSerializer<Ingredient> toSerializer(Ingredient ingredient) {
|
||||
return CompoundSerializer.class.cast(ingredient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue