WIP: Ender Ore generation
This commit is contained in:
parent
d272597e87
commit
ad0834b25f
10 changed files with 90 additions and 18 deletions
|
@ -33,10 +33,10 @@ public class AlloyingRecipe implements Recipe<Inventory> {
|
|||
protected final int smeltTime;
|
||||
|
||||
|
||||
public AlloyingRecipe(Identifier id, Ingredient primaryInput, Ingredient secondaryInput,
|
||||
public AlloyingRecipe(Identifier id, String group, Ingredient primaryInput, Ingredient secondaryInput,
|
||||
ItemStack output, float experience, int smeltTime) {
|
||||
|
||||
this.group = String.format("%s:%s", GROUP, id.getPath());
|
||||
this.group = group;
|
||||
this.id = id;
|
||||
this.primaryInput = primaryInput;
|
||||
this.secondaryInput = secondaryInput;
|
||||
|
@ -113,6 +113,7 @@ public class AlloyingRecipe implements Recipe<Inventory> {
|
|||
|
||||
public static Builder create(String id) {
|
||||
INSTANCE.id = BetterEnd.getResId(id);
|
||||
INSTANCE.group = String.format("%s:%s", GROUP, id);
|
||||
INSTANCE.primaryInput = null;
|
||||
INSTANCE.secondaryInput = null;
|
||||
INSTANCE.output = null;
|
||||
|
@ -126,11 +127,17 @@ public class AlloyingRecipe implements Recipe<Inventory> {
|
|||
private Ingredient primaryInput;
|
||||
private Ingredient secondaryInput;
|
||||
private ItemStack output;
|
||||
private String group;
|
||||
private float experience;
|
||||
private int smeltTime;
|
||||
|
||||
private Builder() {}
|
||||
|
||||
public Builder setGroup(String group) {
|
||||
this.group = group;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPrimaryInput(ItemConvertible... inputs) {
|
||||
this.primaryInput = Ingredient.ofItems(inputs);
|
||||
return this;
|
||||
|
@ -192,7 +199,7 @@ public class AlloyingRecipe implements Recipe<Inventory> {
|
|||
} else if(output == null) {
|
||||
throw new IllegalArgumentException("Output can't be null!");
|
||||
}
|
||||
EndRecipeManager.addRecipe(AlloyingRecipe.TYPE, new AlloyingRecipe(id, primaryInput, secondaryInput, output, experience, smeltTime));
|
||||
EndRecipeManager.addRecipe(AlloyingRecipe.TYPE, new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public class AlloyingRecipeSerializer implements RecipeSerializer<AlloyingRecipe
|
|||
Ingredient primaryInput = Ingredient.fromJson(ingredients.get(0));
|
||||
Ingredient secondaryInput = Ingredient.fromJson(ingredients.get(1));
|
||||
String rusultStr = JsonHelper.getString(json, "result");
|
||||
String group = JsonHelper.getString(json, "group", "");
|
||||
Identifier resultId = new Identifier(rusultStr);
|
||||
ItemStack output = new ItemStack(Registry.ITEM.getOrEmpty(resultId).orElseThrow(() -> {
|
||||
return new IllegalStateException("Item: " + rusultStr + " does not exist");
|
||||
|
@ -26,22 +27,24 @@ public class AlloyingRecipeSerializer implements RecipeSerializer<AlloyingRecipe
|
|||
float experience = JsonHelper.getFloat(json, "experience", 0.0F);
|
||||
int smeltTime = JsonHelper.getInt(json, "smelttime", 350);
|
||||
|
||||
return new AlloyingRecipe(id, primaryInput, secondaryInput, output, experience, smeltTime);
|
||||
return new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlloyingRecipe read(Identifier id, PacketByteBuf packetBuffer) {
|
||||
String group = packetBuffer.readString();
|
||||
Ingredient primaryInput = Ingredient.fromPacket(packetBuffer);
|
||||
Ingredient secondaryInput = Ingredient.fromPacket(packetBuffer);
|
||||
ItemStack output = packetBuffer.readItemStack();
|
||||
float experience = packetBuffer.readFloat();
|
||||
int smeltTime = packetBuffer.readVarInt();
|
||||
|
||||
return new AlloyingRecipe(id, primaryInput, secondaryInput, output, experience, smeltTime);
|
||||
return new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketByteBuf packetBuffer, AlloyingRecipe recipe) {
|
||||
packetBuffer.writeString(recipe.group);
|
||||
recipe.primaryInput.write(packetBuffer);
|
||||
recipe.secondaryInput.write(packetBuffer);
|
||||
packetBuffer.writeItemStack(recipe.output);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue