diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CombiningFactoryBlockEntity.java b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CombiningFactoryBlockEntity.java index 285713d8..36dc981d 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CombiningFactoryBlockEntity.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CombiningFactoryBlockEntity.java @@ -7,7 +7,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.tonimatasdev.krystalcraft.blockentity.util.EnergyProcessingBlockEntity; @@ -69,20 +68,20 @@ public void tick() { } private boolean hasRecipe(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.COMBINING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.COMBINING.get(), this, level); if (match.isEmpty()) return false; - ItemStack resultItem = match.get().value().getResultItem(level.registryAccess()); + ItemStack resultItem = match.get().getResultItem(level.registryAccess()); return (resultItem.is(resultItem.getItem()) || resultItem.isEmpty()) && (resultItem.getCount() + getItem(RESULT_SLOT).getCount()) <= 64; } private void craft(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.COMBINING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.COMBINING.get(), this, level); if (match.isPresent()) { removeItem(INPUT1_SLOT, 1); removeItem(INPUT2_SLOT, 1); - ItemStack result = match.get().value().getResultItem(level.registryAccess()); + ItemStack result = match.get().getResultItem(level.registryAccess()); setItem(RESULT_SLOT, new ItemStack(result.getItem(), getItem(RESULT_SLOT).getCount() + result.getCount())); } } diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CombiningStationBlockEntity.java b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CombiningStationBlockEntity.java index 471f0e6f..c4da2057 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CombiningStationBlockEntity.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CombiningStationBlockEntity.java @@ -6,7 +6,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.tonimatasdev.krystalcraft.blockentity.util.BurnProcessingBlockEntity; @@ -66,20 +65,20 @@ public void tick() { } private boolean hasRecipe(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.COMBINING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.COMBINING.get(), this, level); if (match.isEmpty()) return false; - ItemStack resultItem = match.get().value().getResultItem(level.registryAccess()); + ItemStack resultItem = match.get().getResultItem(level.registryAccess()); return (resultItem.is(resultItem.getItem()) || resultItem.isEmpty()) && (resultItem.getCount() + getItem(RESULT_SLOT).getCount()) <= 64; } private void craft(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.COMBINING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.COMBINING.get(), this, level); if (match.isPresent()) { removeItem(INPUT1_SLOT, 1); removeItem(INPUT2_SLOT, 1); - ItemStack result = match.get().value().getResultItem(level.registryAccess()); + ItemStack result = match.get().getResultItem(level.registryAccess()); setItem(RESULT_SLOT, new ItemStack(result.getItem(), getItem(RESULT_SLOT).getCount() + result.getCount())); } } diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CrushingFactoryBlockEntity.java b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CrushingFactoryBlockEntity.java index 4613def6..05582a7f 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CrushingFactoryBlockEntity.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CrushingFactoryBlockEntity.java @@ -7,7 +7,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.tonimatasdev.krystalcraft.blockentity.util.EnergyProcessingBlockEntity; @@ -69,19 +68,19 @@ public void tick() { } private boolean hasRecipe(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.CRUSHING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.CRUSHING.get(), this, level); if (match.isEmpty()) return false; - ItemStack resultItem = match.get().value().getResultItem(level.registryAccess()); + ItemStack resultItem = match.get().getResultItem(level.registryAccess()); return (resultItem.is(resultItem.getItem()) || resultItem.isEmpty()) && (resultItem.getCount() + getItem(RESULT_SLOT).getCount()) <= 64; } private void craft(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.CRUSHING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.CRUSHING.get(), this, level); if (match.isPresent()) { removeItem(INPUT_SLOT, 1); - setItem(RESULT_SLOT, new ItemStack(match.get().value().getResultItem(level.registryAccess()).getItem(), getItem(RESULT_SLOT).getCount() + 1)); + setItem(RESULT_SLOT, new ItemStack(match.get().getResultItem(level.registryAccess()).getItem(), getItem(RESULT_SLOT).getCount() + 1)); } } } diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CrushingStationBlockEntity.java b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CrushingStationBlockEntity.java index 9b7a4e60..95e767bd 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CrushingStationBlockEntity.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CrushingStationBlockEntity.java @@ -6,7 +6,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.tonimatasdev.krystalcraft.blockentity.util.BurnProcessingBlockEntity; @@ -64,19 +63,19 @@ public void tick() { } private boolean hasRecipe(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.CRUSHING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.CRUSHING.get(), this, level); if (match.isEmpty()) return false; - ItemStack resultItem = match.get().value().getResultItem(level.registryAccess()); + ItemStack resultItem = match.get().getResultItem(level.registryAccess()); return (resultItem.is(resultItem.getItem()) || resultItem.isEmpty()) && (resultItem.getCount() + getItem(RESULT_SLOT).getCount()) <= 64; } private void craft(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.CRUSHING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.CRUSHING.get(), this, level); if (match.isPresent()) { removeItem(INPUT_SLOT, 1); - setItem(RESULT_SLOT, new ItemStack(match.get().value().getResultItem(level.registryAccess()).getItem(), getItem(RESULT_SLOT).getCount() + 1)); + setItem(RESULT_SLOT, new ItemStack(match.get().getResultItem(level.registryAccess()).getItem(), getItem(RESULT_SLOT).getCount() + 1)); } } } \ No newline at end of file diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CuttingFactoryBlockEntity.java b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CuttingFactoryBlockEntity.java index 071d5657..cfa981b3 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CuttingFactoryBlockEntity.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CuttingFactoryBlockEntity.java @@ -13,7 +13,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluids; @@ -101,19 +100,19 @@ public void tick() { } private boolean hasRecipe(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.CUTTING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.CUTTING.get(), this, level); if (match.isEmpty()) return false; - ItemStack resultItem = match.get().value().getResultItem(level.registryAccess()); + ItemStack resultItem = match.get().getResultItem(level.registryAccess()); return (resultItem.is(resultItem.getItem()) || (resultItem.isEmpty()) && (resultItem.getCount() + getItem(RESULT_SLOT).getCount()) <= 64); } private void craft(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.CUTTING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.CUTTING.get(), this, level); if (match.isPresent()) { removeItem(INPUT_SLOT, 1); - setItem(RESULT_SLOT, new ItemStack(match.get().value().getResultItem(level.registryAccess()).getItem(), getItem(RESULT_SLOT).getCount() + 1)); + setItem(RESULT_SLOT, new ItemStack(match.get().getResultItem(level.registryAccess()).getItem(), getItem(RESULT_SLOT).getCount() + 1)); } } } diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CuttingStationBlockEntity.java b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CuttingStationBlockEntity.java index 43e53c78..30b11e46 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CuttingStationBlockEntity.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/blockentity/CuttingStationBlockEntity.java @@ -12,7 +12,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluids; @@ -93,19 +92,19 @@ public void tick() { } private boolean hasRecipe(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.CUTTING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.CUTTING.get(), this, level); if (match.isEmpty()) return false; - ItemStack resultItem = match.get().value().getResultItem(level.registryAccess()); + ItemStack resultItem = match.get().getResultItem(level.registryAccess()); return (resultItem.is(resultItem.getItem()) || (resultItem.isEmpty()) && (resultItem.getCount() + getItem(RESULT_SLOT).getCount()) <= 64); } private void craft(Level level) { - Optional> match = level.getRecipeManager().getRecipeFor(ModRecipes.CUTTING.get(), this, level); + Optional match = level.getRecipeManager().getRecipeFor(ModRecipes.CUTTING.get(), this, level); if (match.isPresent()) { removeItem(INPUT_SLOT, 1); - setItem(RESULT_SLOT, new ItemStack(match.get().value().getResultItem(level.registryAccess()).getItem(), getItem(RESULT_SLOT).getCount() + 1)); + setItem(RESULT_SLOT, new ItemStack(match.get().getResultItem(level.registryAccess()).getItem(), getItem(RESULT_SLOT).getCount() + 1)); } } } \ No newline at end of file diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombiningFactoryScreen.java b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombiningFactoryScreen.java index 213fa9c4..32e3ade1 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombiningFactoryScreen.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombiningFactoryScreen.java @@ -37,7 +37,7 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float pPartialTick, in @Override public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { - renderBackground(guiGraphics, mouseX, mouseY, delta); + renderBackground(Objects.requireNonNull(guiGraphics)); super.render(guiGraphics, mouseX, mouseY, delta); renderTooltip(guiGraphics, mouseX, mouseY); diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombiningStationScreen.java b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombiningStationScreen.java index 0331553f..043a3e61 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombiningStationScreen.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombiningStationScreen.java @@ -37,7 +37,7 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float pPartialTick, in @Override public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { - renderBackground(guiGraphics, mouseX, mouseY, delta); + renderBackground(Objects.requireNonNull(guiGraphics)); super.render(guiGraphics, mouseX, mouseY, delta); renderTooltip(guiGraphics, mouseX, mouseY); } diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombustionGeneratorScreen.java b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombustionGeneratorScreen.java index 57362c95..3167ec40 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombustionGeneratorScreen.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CombustionGeneratorScreen.java @@ -37,7 +37,7 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float pPartialTick, in @Override public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { - renderBackground(guiGraphics, mouseX, mouseY, delta); + renderBackground(Objects.requireNonNull(guiGraphics)); super.render(guiGraphics, mouseX, mouseY, delta); renderTooltip(guiGraphics, mouseX, mouseY); diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CrushingFactoryScreen.java b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CrushingFactoryScreen.java index 64acfe04..1f3ea792 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CrushingFactoryScreen.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CrushingFactoryScreen.java @@ -37,7 +37,7 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float pPartialTick, in @Override public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { - renderBackground(guiGraphics, mouseX, mouseY, delta); + renderBackground(Objects.requireNonNull(guiGraphics)); super.render(guiGraphics, mouseX, mouseY, delta); renderTooltip(guiGraphics, mouseX, mouseY); diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CrushingStationScreen.java b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CrushingStationScreen.java index a1500936..e38941d0 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CrushingStationScreen.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CrushingStationScreen.java @@ -37,7 +37,7 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float pPartialTick, in @Override public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { - renderBackground(guiGraphics, mouseX, mouseY, delta); + renderBackground(Objects.requireNonNull(guiGraphics)); super.render(guiGraphics, mouseX, mouseY, delta); renderTooltip(guiGraphics, mouseX, mouseY); } diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CuttingFactoryScreen.java b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CuttingFactoryScreen.java index 4553ee1f..5375e8c8 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CuttingFactoryScreen.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CuttingFactoryScreen.java @@ -38,7 +38,7 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float pPartialTick, in @Override public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { - renderBackground(guiGraphics, mouseX, mouseY, delta); + renderBackground(Objects.requireNonNull(guiGraphics)); super.render(guiGraphics, mouseX, mouseY, delta); renderTooltip(guiGraphics, mouseX, mouseY); diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CuttingStationScreen.java b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CuttingStationScreen.java index c7abf3c9..ac0d65ba 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CuttingStationScreen.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/client/screen/CuttingStationScreen.java @@ -38,7 +38,7 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float pPartialTick, in @Override public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { - renderBackground(guiGraphics, mouseX, mouseY, delta); + renderBackground(Objects.requireNonNull(guiGraphics)); super.render(guiGraphics, mouseX, mouseY, delta); renderTooltip(guiGraphics, mouseX, mouseY); diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/compat/jei/JEIKrystalCraftModPlugin.java b/common/src/main/java/net/tonimatasdev/krystalcraft/compat/jei/JEIKrystalCraftModPlugin.java index 2fc331eb..16263067 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/compat/jei/JEIKrystalCraftModPlugin.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/compat/jei/JEIKrystalCraftModPlugin.java @@ -8,7 +8,6 @@ import mezz.jei.api.registration.IRecipeRegistration; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.RecipeManager; import net.tonimatasdev.krystalcraft.KrystalCraft; import net.tonimatasdev.krystalcraft.recipe.CombiningRecipe; @@ -18,7 +17,6 @@ import org.jetbrains.annotations.NotNull; import java.util.Objects; -import java.util.stream.Collectors; @JeiPlugin public class JEIKrystalCraftModPlugin implements IModPlugin { @@ -42,8 +40,8 @@ public void registerCategories(IRecipeCategoryRegistration registration) { public void registerRecipes(IRecipeRegistration registration) { RecipeManager manager = Objects.requireNonNull(Minecraft.getInstance().level).getRecipeManager(); - registration.addRecipes(CUTTING, manager.getAllRecipesFor(ModRecipes.CUTTING.get()).stream().map(RecipeHolder::value).collect(Collectors.toList())); - registration.addRecipes(CRUSHING, manager.getAllRecipesFor(ModRecipes.CRUSHING.get()).stream().map(RecipeHolder::value).collect(Collectors.toList())); - registration.addRecipes(COMBINING, manager.getAllRecipesFor(ModRecipes.COMBINING.get()).stream().map(RecipeHolder::value).collect(Collectors.toList())); + registration.addRecipes(CUTTING, manager.getAllRecipesFor(ModRecipes.CUTTING.get())); + registration.addRecipes(CRUSHING, manager.getAllRecipesFor(ModRecipes.CRUSHING.get())); + registration.addRecipes(COMBINING, manager.getAllRecipesFor(ModRecipes.COMBINING.get())); } } diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CombiningRecipe.java b/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CombiningRecipe.java index 239f2bc3..76b18c18 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CombiningRecipe.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CombiningRecipe.java @@ -17,10 +17,13 @@ import org.jetbrains.annotations.NotNull; public class CombiningRecipe implements Recipe { + + final ResourceLocation id; private final NonNullList inputs; private final ItemStack output; - public CombiningRecipe(NonNullList inputs, ItemStack output) { + public CombiningRecipe(ResourceLocation id, NonNullList inputs, ItemStack output) { + this.id = id; this.inputs = inputs; this.output = output; } @@ -51,6 +54,11 @@ public boolean canCraftInDimensions(int width, int height) { return this.output.copy(); } + @Override + public @NotNull ResourceLocation getId() { + return id; + } + @Override public @NotNull RecipeSerializer getSerializer() { return ModRecipeSerializers.COMBINING_SERIALIZER.get(); @@ -71,31 +79,31 @@ public boolean isSpecial() { return true; } - //public static class Serializer implements RecipeSerializer { TODO: Finish port - // @Override - // public @NotNull CombiningRecipe fromJson(ResourceLocation id, JsonObject json) { - // final var ingredients = RecipeUtils.deserializeIngredients(GsonHelper.getAsJsonArray(json, "ingredients")); - // if (ingredients.isEmpty()) { - // throw new JsonParseException("No ingredients for Combining"); - // } else if (ingredients.size() > 2) { - // throw new JsonParseException("Too many ingredients for Combining"); - // } else { - // return new CombiningRecipe(id, ingredients, ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result"))); - // } - // } -// - // @Override - // public @NotNull CombiningRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) { - // final var ingredients = NonNullList.withSize(buf.readVarInt(), Ingredient.EMPTY); - // ingredients.replaceAll(ignored -> Ingredient.fromNetwork(buf)); - // return new CombiningRecipe(id, ingredients, buf.readItem()); - // } -// - // @Override - // public void toNetwork(FriendlyByteBuf buf, CombiningRecipe recipe) { - // buf.writeVarInt(recipe.inputs.size()); - // recipe.inputs.forEach(entry -> entry.toNetwork(buf)); - // buf.writeItem(recipe.output); - // } - //} + public static class Serializer implements RecipeSerializer { + @Override + public @NotNull CombiningRecipe fromJson(ResourceLocation id, JsonObject json) { + final var ingredients = RecipeUtils.deserializeIngredients(GsonHelper.getAsJsonArray(json, "ingredients")); + if (ingredients.isEmpty()) { + throw new JsonParseException("No ingredients for Combining"); + } else if (ingredients.size() > 2) { + throw new JsonParseException("Too many ingredients for Combining"); + } else { + return new CombiningRecipe(id, ingredients, ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result"))); + } + } + + @Override + public @NotNull CombiningRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) { + final var ingredients = NonNullList.withSize(buf.readVarInt(), Ingredient.EMPTY); + ingredients.replaceAll(ignored -> Ingredient.fromNetwork(buf)); + return new CombiningRecipe(id, ingredients, buf.readItem()); + } + + @Override + public void toNetwork(FriendlyByteBuf buf, CombiningRecipe recipe) { + buf.writeVarInt(recipe.inputs.size()); + recipe.inputs.forEach(entry -> entry.toNetwork(buf)); + buf.writeItem(recipe.output); + } + } } \ No newline at end of file diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CrushingRecipe.java b/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CrushingRecipe.java index b9f3c297..c8aa5457 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CrushingRecipe.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CrushingRecipe.java @@ -17,10 +17,13 @@ import org.jetbrains.annotations.NotNull; public class CrushingRecipe implements Recipe { + + final ResourceLocation id; private final NonNullList inputs; private final ItemStack output; - public CrushingRecipe(NonNullList inputs, ItemStack output) { + public CrushingRecipe(ResourceLocation id, NonNullList inputs, ItemStack output) { + this.id = id; this.inputs = inputs; this.output = output; } @@ -49,6 +52,11 @@ public boolean canCraftInDimensions(int width, int height) { return this.output.copy(); } + @Override + public @NotNull ResourceLocation getId() { + return id; + } + @Override public @NotNull RecipeSerializer getSerializer() { return ModRecipeSerializers.CRUSHING_SERIALIZER.get(); @@ -69,31 +77,31 @@ public boolean isSpecial() { return true; } - //public static class Serializer implements RecipeSerializer { TODO: Finish port - // @Override - // public @NotNull CrushingRecipe fromJson(ResourceLocation id, JsonObject json) { - // final var ingredients = RecipeUtils.deserializeIngredients(GsonHelper.getAsJsonArray(json, "ingredients")); - // if (ingredients.isEmpty()) { - // throw new JsonParseException("No ingredients for Crushing"); - // } else if (ingredients.size() > 1) { - // throw new JsonParseException("Too many ingredients for Crushing"); - // } else { - // return new CrushingRecipe(id, ingredients, ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result"))); - // } - // } -// - // @Override - // public @NotNull CrushingRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) { - // final var ingredients = NonNullList.withSize(buf.readVarInt(), Ingredient.EMPTY); - // ingredients.replaceAll(ignored -> Ingredient.fromNetwork(buf)); - // return new CrushingRecipe(id, ingredients, buf.readItem()); - // } -// - // @Override - // public void toNetwork(FriendlyByteBuf buf, CrushingRecipe recipe) { - // buf.writeVarInt(recipe.inputs.size()); - // recipe.inputs.forEach(entry -> entry.toNetwork(buf)); - // buf.writeItem(recipe.output); - // } - //} + public static class Serializer implements RecipeSerializer { + @Override + public @NotNull CrushingRecipe fromJson(ResourceLocation id, JsonObject json) { + final var ingredients = RecipeUtils.deserializeIngredients(GsonHelper.getAsJsonArray(json, "ingredients")); + if (ingredients.isEmpty()) { + throw new JsonParseException("No ingredients for Crushing"); + } else if (ingredients.size() > 1) { + throw new JsonParseException("Too many ingredients for Crushing"); + } else { + return new CrushingRecipe(id, ingredients, ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result"))); + } + } + + @Override + public @NotNull CrushingRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) { + final var ingredients = NonNullList.withSize(buf.readVarInt(), Ingredient.EMPTY); + ingredients.replaceAll(ignored -> Ingredient.fromNetwork(buf)); + return new CrushingRecipe(id, ingredients, buf.readItem()); + } + + @Override + public void toNetwork(FriendlyByteBuf buf, CrushingRecipe recipe) { + buf.writeVarInt(recipe.inputs.size()); + recipe.inputs.forEach(entry -> entry.toNetwork(buf)); + buf.writeItem(recipe.output); + } + } } \ No newline at end of file diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CuttingRecipe.java b/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CuttingRecipe.java index 5fb595f4..a32e6070 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CuttingRecipe.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/recipe/CuttingRecipe.java @@ -17,10 +17,13 @@ import org.jetbrains.annotations.NotNull; public class CuttingRecipe implements Recipe { + + final ResourceLocation id; private final NonNullList inputs; private final ItemStack output; - public CuttingRecipe(NonNullList inputs, ItemStack output) { + public CuttingRecipe(ResourceLocation id, NonNullList inputs, ItemStack output) { + this.id = id; this.inputs = inputs; this.output = output; } @@ -49,6 +52,11 @@ public boolean canCraftInDimensions(int width, int height) { return this.output.copy(); } + @Override + public @NotNull ResourceLocation getId() { + return id; + } + @Override public @NotNull RecipeSerializer getSerializer() { return ModRecipeSerializers.CUTTING_SERIALIZER.get(); @@ -69,31 +77,31 @@ public boolean isSpecial() { return true; } - //public static class Serializer implements RecipeSerializer { TODO: Finish port - // @Override - // public @NotNull CuttingRecipe fromJson(ResourceLocation id, JsonObject json) { - // final var ingredients = RecipeUtils.deserializeIngredients(GsonHelper.getAsJsonArray(json, "ingredients")); - // if (ingredients.isEmpty()) { - // throw new JsonParseException("No ingredients for Cutting"); - // } else if (ingredients.size() > 1) { - // throw new JsonParseException("Too many ingredients for Cutting"); - // } else { - // return new CuttingRecipe(id, ingredients, ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result"))); - // } - // } -// - // @Override - // public @NotNull CuttingRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) { - // final var ingredients = NonNullList.withSize(buf.readVarInt(), Ingredient.EMPTY); - // ingredients.replaceAll(ignored -> Ingredient.fromNetwork(buf)); - // return new CuttingRecipe(id, ingredients, buf.readItem()); - // } -// - // @Override - // public void toNetwork(FriendlyByteBuf buf, CuttingRecipe recipe) { - // buf.writeVarInt(recipe.inputs.size()); - // recipe.inputs.forEach(entry -> entry.toNetwork(buf)); - // buf.writeItem(recipe.output); - // } - //} + public static class Serializer implements RecipeSerializer { + @Override + public @NotNull CuttingRecipe fromJson(ResourceLocation id, JsonObject json) { + final var ingredients = RecipeUtils.deserializeIngredients(GsonHelper.getAsJsonArray(json, "ingredients")); + if (ingredients.isEmpty()) { + throw new JsonParseException("No ingredients for Cutting"); + } else if (ingredients.size() > 1) { + throw new JsonParseException("Too many ingredients for Cutting"); + } else { + return new CuttingRecipe(id, ingredients, ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result"))); + } + } + + @Override + public @NotNull CuttingRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) { + final var ingredients = NonNullList.withSize(buf.readVarInt(), Ingredient.EMPTY); + ingredients.replaceAll(ignored -> Ingredient.fromNetwork(buf)); + return new CuttingRecipe(id, ingredients, buf.readItem()); + } + + @Override + public void toNetwork(FriendlyByteBuf buf, CuttingRecipe recipe) { + buf.writeVarInt(recipe.inputs.size()); + recipe.inputs.forEach(entry -> entry.toNetwork(buf)); + buf.writeItem(recipe.output); + } + } } \ No newline at end of file diff --git a/common/src/main/java/net/tonimatasdev/krystalcraft/registry/ModRecipeSerializers.java b/common/src/main/java/net/tonimatasdev/krystalcraft/registry/ModRecipeSerializers.java index f6842db2..29fb768f 100644 --- a/common/src/main/java/net/tonimatasdev/krystalcraft/registry/ModRecipeSerializers.java +++ b/common/src/main/java/net/tonimatasdev/krystalcraft/registry/ModRecipeSerializers.java @@ -16,10 +16,9 @@ public class ModRecipeSerializers { public static final MythRegistry> RECIPE_SERIALIZERS = MythRegistries.create(BuiltInRegistries.RECIPE_SERIALIZER, KrystalCraft.MOD_ID); - // TODO: Finish port - public static final RegistryEntry> CUTTING_SERIALIZER = create("cutting", /*CuttingRecipe.Serializer::new*/ null); - public static final RegistryEntry> CRUSHING_SERIALIZER = create("crushing", /*CrushingRecipe.Serializer::new*/ null); - public static final RegistryEntry> COMBINING_SERIALIZER = create("combining", /*CombiningRecipe.Serializer::new*/ null); + public static final RegistryEntry> CUTTING_SERIALIZER = create("cutting", CuttingRecipe.Serializer::new); + public static final RegistryEntry> CRUSHING_SERIALIZER = create("crushing", CrushingRecipe.Serializer::new); + public static final RegistryEntry> COMBINING_SERIALIZER = create("combining", CombiningRecipe.Serializer::new); private static > RegistryEntry> create(String name, Supplier> serializer) { return RECIPE_SERIALIZERS.register(name, serializer); diff --git a/fabric/src/main/resources/data/krystalcraft/recipes/combining_factory.json b/fabric/src/main/resources/data/krystalcraft/recipes/combining_factory.json index a325ee73..e9330d80 100644 --- a/fabric/src/main/resources/data/krystalcraft/recipes/combining_factory.json +++ b/fabric/src/main/resources/data/krystalcraft/recipes/combining_factory.json @@ -7,7 +7,7 @@ "tag": "c:iron_ingots" }, "1": { - "tag": "c:iron_blocks" + "item": "minecraft:iron_block" }, "2": { "item": "krystalcraft:combining_station" diff --git a/fabric/src/main/resources/data/krystalcraft/recipes/combustion_generator.json b/fabric/src/main/resources/data/krystalcraft/recipes/combustion_generator.json index a51061fa..9420deb9 100644 --- a/fabric/src/main/resources/data/krystalcraft/recipes/combustion_generator.json +++ b/fabric/src/main/resources/data/krystalcraft/recipes/combustion_generator.json @@ -7,7 +7,7 @@ "tag": "c:iron_ingots" }, "1": { - "tag": "c:iron_blocks" + "item": "minecraft:iron_block" }, "2": { "item": "minecraft:furnace" diff --git a/fabric/src/main/resources/data/krystalcraft/recipes/crushing_factory.json b/fabric/src/main/resources/data/krystalcraft/recipes/crushing_factory.json index 6c1ae716..5dbab5b1 100644 --- a/fabric/src/main/resources/data/krystalcraft/recipes/crushing_factory.json +++ b/fabric/src/main/resources/data/krystalcraft/recipes/crushing_factory.json @@ -7,7 +7,7 @@ "tag": "c:iron_ingots" }, "1": { - "tag": "c:iron_blocks" + "item": "minecraft:iron_block" }, "2": { "item": "krystalcraft:crushing_station" diff --git a/fabric/src/main/resources/data/krystalcraft/recipes/crushing_station.json b/fabric/src/main/resources/data/krystalcraft/recipes/crushing_station.json index 408dde56..067a4ad2 100644 --- a/fabric/src/main/resources/data/krystalcraft/recipes/crushing_station.json +++ b/fabric/src/main/resources/data/krystalcraft/recipes/crushing_station.json @@ -7,13 +7,13 @@ "item": "minecraft:stick" }, "1": { - "tag": "forge:cobblestone" + "item": "minecraft:cobblestone" }, "2": { - "tag": "forge:ingots/iron" + "tag": "c:iron_ingots" }, "3": { - "tag": "forge:storage_blocks/iron" + "item": "minecraft:iron_block" } }, "pattern": [ diff --git a/fabric/src/main/resources/data/krystalcraft/recipes/cutting_factory.json b/fabric/src/main/resources/data/krystalcraft/recipes/cutting_factory.json index 8f136ace..078d99f9 100644 --- a/fabric/src/main/resources/data/krystalcraft/recipes/cutting_factory.json +++ b/fabric/src/main/resources/data/krystalcraft/recipes/cutting_factory.json @@ -7,7 +7,7 @@ "tag": "c:iron_ingots" }, "1": { - "tag": "c:iron_blocks" + "item": "minecraft:iron_block" }, "2": { "item": "krystalcraft:cutting_station" diff --git a/fabric/src/main/resources/data/krystalcraft/recipes/cutting_station.json b/fabric/src/main/resources/data/krystalcraft/recipes/cutting_station.json index ec771b42..4ea08382 100644 --- a/fabric/src/main/resources/data/krystalcraft/recipes/cutting_station.json +++ b/fabric/src/main/resources/data/krystalcraft/recipes/cutting_station.json @@ -7,16 +7,16 @@ "item": "minecraft:stick" }, "1": { - "tag": "forge:cobblestone" + "item": "minecraft:cobblestone" }, "2": { "item": "minecraft:bucket" }, "3": { - "tag": "forge:raw_materials/diamond" + "tag": "krystalcraft:raw_diamond_ores" }, "4": { - "tag": "forge:ingots/iron" + "tag": "c:iron_ingots" } }, "pattern": [ diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 4678462b..d5a97123 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -15,7 +15,6 @@ architectury { val minecraftVersion: String by extra val forgeVersion: String by extra val forgeLoaderRange: String by extra -val botariumVersion: String by extra val modVersion: String by extra val jeiVersion: String by extra @@ -27,10 +26,10 @@ configurations["runtimeClasspath"].extendsFrom(common) configurations["developmentForge"].extendsFrom(common) dependencies { - forge("net.minecraftforge:forge:$forgeVersion") + forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion") - modCompileOnly("mezz.jei:jei-${minecraftVersion}-forge-api:${jeiVersion}") - modLocalRuntime("mezz.jei:jei-${minecraftVersion}-forge:${jeiVersion}") { isTransitive = false } + modCompileOnly("mezz.jei:jei-$minecraftVersion-forge-api:$jeiVersion") + modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false } modApi(files("../libs/MythLib-forge-1.0.0.jar")) diff --git a/gradle.properties b/gradle.properties index 41c2953b..82305eed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,17 +4,17 @@ org.gradle.jvmargs=-Xmx3G modVersion=0.0.4.2 # Dependencies -reiVersion=12.0.634 -jeiVersion=16.0.0.28 +reiVersion=12.0.684 +jeiVersion=15.2.0.27 # Minecraft Properties -minecraftVersion=1.20.2 +minecraftVersion=1.20.1 # Fabric Properties -fabricLoaderVersion=0.14.24 +fabricLoaderVersion=0.15.1 fabricLoaderRange=>=0.14.0 fabricApiVersion=0.90.7 # Forge Properties -forgeVersion=1.20.2-48.0.33 -forgeLoaderRange=[48,) \ No newline at end of file +forgeVersion=47.2.17 +forgeLoaderRange=[47,) \ No newline at end of file diff --git a/libs/MythLib-common-1.0.0.jar b/libs/MythLib-common-1.0.0.jar index 71acf36c..51b72838 100644 Binary files a/libs/MythLib-common-1.0.0.jar and b/libs/MythLib-common-1.0.0.jar differ diff --git a/libs/MythLib-fabric-1.0.0.jar b/libs/MythLib-fabric-1.0.0.jar index 36481718..0d2a1f07 100644 Binary files a/libs/MythLib-fabric-1.0.0.jar and b/libs/MythLib-fabric-1.0.0.jar differ diff --git a/libs/MythLib-forge-1.0.0.jar b/libs/MythLib-forge-1.0.0.jar index 73f8460d..251a3604 100644 Binary files a/libs/MythLib-forge-1.0.0.jar and b/libs/MythLib-forge-1.0.0.jar differ