[Change] Adopted new Recipe handling
This commit is contained in:
parent
7a972fc22f
commit
f6703dc8bf
2 changed files with 10 additions and 32 deletions
|
@ -26,8 +26,6 @@ import net.minecraft.world.level.Level;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCategory {
|
public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCategory {
|
||||||
|
@ -207,15 +205,9 @@ public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCateg
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void serializeRecipeData(JsonObject root) {
|
protected AlloyingRecipe createRecipe(ResourceLocation id) {
|
||||||
super.serializeRecipeData(root);
|
checkRecipe();
|
||||||
|
return new AlloyingRecipe(group, primaryInput, secondaryInput, output, experience, smeltTime);
|
||||||
if (experience != 0) {
|
|
||||||
root.addProperty("experience", experience);
|
|
||||||
}
|
|
||||||
if (experience != 350) {
|
|
||||||
root.addProperty("smelttime", smeltTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@ import net.minecraft.world.level.Level;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -338,21 +336,9 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void serializeRecipeData(JsonObject root) {
|
protected AnvilRecipe createRecipe(ResourceLocation id) {
|
||||||
super.serializeRecipeData(root);
|
checkRecipe();
|
||||||
|
return new AnvilRecipe(primaryInput, output, inputCount, toolLevel, anvilLevel, damage);
|
||||||
if (inputCount > 1) {
|
|
||||||
root.addProperty("inputCount", inputCount);
|
|
||||||
}
|
|
||||||
if (toolLevel != 1) {
|
|
||||||
root.addProperty("toolLevel", toolLevel);
|
|
||||||
}
|
|
||||||
if (anvilLevel != 1) {
|
|
||||||
root.addProperty("anvilLevel", anvilLevel);
|
|
||||||
}
|
|
||||||
if (damage != 1) {
|
|
||||||
root.addProperty("damage", damage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,10 +346,10 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
|
||||||
public static Codec<AnvilRecipe> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
public static Codec<AnvilRecipe> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||||
Ingredient.CODEC_NONEMPTY.fieldOf("input").forGetter(recipe -> recipe.input),
|
Ingredient.CODEC_NONEMPTY.fieldOf("input").forGetter(recipe -> recipe.input),
|
||||||
ItemUtil.CODEC_ITEM_STACK_WITH_NBT.fieldOf("result").forGetter(recipe -> recipe.output),
|
ItemUtil.CODEC_ITEM_STACK_WITH_NBT.fieldOf("result").forGetter(recipe -> recipe.output),
|
||||||
Codec.INT.fieldOf("inputCount").forGetter(recipe -> recipe.inputCount),
|
Codec.INT.optionalFieldOf("inputCount", 1).forGetter(recipe -> recipe.inputCount),
|
||||||
Codec.INT.fieldOf("toolLevel").forGetter(recipe -> recipe.toolLevel),
|
Codec.INT.optionalFieldOf("toolLevel", 1).forGetter(recipe -> recipe.toolLevel),
|
||||||
Codec.INT.fieldOf("anvilLevel").forGetter(recipe -> recipe.anvilLevel),
|
Codec.INT.optionalFieldOf("anvilLevel", 1).forGetter(recipe -> recipe.anvilLevel),
|
||||||
Codec.INT.fieldOf("damage").forGetter(recipe -> recipe.damage)
|
Codec.INT.optionalFieldOf("damage", 1).forGetter(recipe -> recipe.damage)
|
||||||
).apply(instance, AnvilRecipe::new));
|
).apply(instance, AnvilRecipe::new));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue