diff --git a/build.gradle b/build.gradle index 0438b17..32f3629 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,7 @@ base { repositories { maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.architectury.dev/" } maven { url "https://maven.terraformersmc.com/releases/" } maven { url "https://pluto-mod-maven.web.app/maven" } maven { url = "https://maven.parchmentmc.org" } @@ -54,6 +55,8 @@ dependencies { modImplementation "ml.pluto7073:pdapi:${project.minecraft_version}+${project.pdapi_version}" modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" + + modApi "dev.architectury:architectury-fabric:10.1.20" // For REI } processResources { diff --git a/gradle.properties b/gradle.properties index b834c6a..03918ec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,21 +3,20 @@ org.gradle.jvmargs=-Xmx1G # Minecraft Stuff # check these on https://fabricmc.net/develop -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.10 -loader_version=0.15.11 -quilt_mappings=23 -parchment_version = 2023.09.03 +minecraft_version=1.20.2 +loader_version=0.16.5 +quilt_mappings=3 +parchment_version = 2023.12.10 # Mod Thingies -mod_version = 1.20.1+3.0 +mod_version = 1.20.2+3.0 maven_group = ml.pluto7073 archives_base_name = PlutosCoffeeMod-Fabric # Things I might be dependent on # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api -fabric_version=0.92.0+1.20.1 -cloth_version=11.1.118 -modmenu_version=7.1.0 +fabric_version=0.91.6+1.20.2 +cloth_version=12.0.119 +modmenu_version=8.0.1 pdapi_version=0.2.20 -rei_version=12.0.684 \ No newline at end of file +rei_version=13.1.773 \ No newline at end of file diff --git a/src/main/java/ml/pluto7073/plutoscoffee/blocks/EspressoMachineBlockEntity.java b/src/main/java/ml/pluto7073/plutoscoffee/blocks/EspressoMachineBlockEntity.java index badb6ad..a78d23e 100644 --- a/src/main/java/ml/pluto7073/plutoscoffee/blocks/EspressoMachineBlockEntity.java +++ b/src/main/java/ml/pluto7073/plutoscoffee/blocks/EspressoMachineBlockEntity.java @@ -33,11 +33,11 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.ContainerData; -import net.minecraft.world.inventory.RecipeHolder; +import net.minecraft.world.inventory.RecipeCraftingHolder; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BaseContainerBlockEntity; @@ -49,7 +49,7 @@ @SuppressWarnings("UnstableApiUsage") @MethodsReturnNonnullByDefault -public class EspressoMachineBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeHolder { +public class EspressoMachineBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeCraftingHolder { public static final FluidVariant WATER = FluidVariant.of(Fluids.WATER); @@ -95,7 +95,7 @@ public int get(int index) { case WATER_PROPERTY_INDEX -> (int) waterStorage.amount; case TOTAL_PULL_TIME_PROPERTY_INDEX -> { if (getItem(GROUNDS_SLOT_INDEX).isEmpty()) yield 400; - Optional recipe = matchGetter.getRecipeFor(EspressoMachineBlockEntity.this, level); + Optional recipe = matchGetter.getRecipeFor(EspressoMachineBlockEntity.this, level).map(RecipeHolder::value); if (recipe.isEmpty()) yield 400; yield recipe.get().pullTime; } @@ -158,7 +158,7 @@ public static void tick(Level level, BlockPos pos, BlockState state, EspressoMac if (blockEntity.inventory.get(GROUNDS_SLOT_INDEX).isEmpty()) { recipe = null; } else { - recipe = blockEntity.matchGetter.getRecipeFor(blockEntity, level).orElse(null); + recipe = blockEntity.matchGetter.getRecipeFor(blockEntity, level).map(RecipeHolder::value).orElse(null); } boolean canPull = canPull(blockEntity.inventory, recipe); @@ -360,16 +360,16 @@ protected AbstractContainerMenu createMenu(int syncId, Inventory inventory) { } @Override - public void setRecipeUsed(@Nullable Recipe recipe) { + public void setRecipeUsed(@Nullable RecipeHolder recipe) { if (recipe != null) { - ResourceLocation resourceLocation = recipe.getId(); + ResourceLocation resourceLocation = recipe.id(); this.recipesUsed.addTo(resourceLocation, 1); } } @Nullable - public Recipe getRecipeUsed() { + public RecipeHolder getRecipeUsed() { return null; } diff --git a/src/main/java/ml/pluto7073/plutoscoffee/coffee/MachineWaterSources.java b/src/main/java/ml/pluto7073/plutoscoffee/coffee/MachineWaterSources.java index 7530c2d..cbe51ba 100644 --- a/src/main/java/ml/pluto7073/plutoscoffee/coffee/MachineWaterSources.java +++ b/src/main/java/ml/pluto7073/plutoscoffee/coffee/MachineWaterSources.java @@ -1,12 +1,15 @@ package ml.pluto7073.plutoscoffee.coffee; import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.mojang.serialization.JsonOps; import ml.pluto7073.plutoscoffee.PlutosCoffee; import ml.pluto7073.plutoscoffee.network.s2c.SyncMachineWaterSourcesRegistryS2CPacket; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; import net.fabricmc.fabric.api.tag.convention.v1.ConventionalItemTags; +import net.minecraft.Util; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.packs.resources.Resource; @@ -92,7 +95,8 @@ public void onResourceManagerReload(ResourceManager resourceManager) { } private static MachineWaterSource fromJson(JsonObject data) { - Ingredient source = Ingredient.fromJson(GsonHelper.getAsJsonObject(data, "source")); + Ingredient source = + Util.getOrThrow(Ingredient.CODEC.parse(JsonOps.INSTANCE, GsonHelper.getAsJsonObject(data, "source")), JsonParseException::new); int water = GsonHelper.getAsInt(data, "water"); return new MachineWaterSource(source, water); } diff --git a/src/main/java/ml/pluto7073/plutoscoffee/compat/rei/display/PullingDisplay.java b/src/main/java/ml/pluto7073/plutoscoffee/compat/rei/display/PullingDisplay.java index 8b54fbb..b22c45e 100644 --- a/src/main/java/ml/pluto7073/plutoscoffee/compat/rei/display/PullingDisplay.java +++ b/src/main/java/ml/pluto7073/plutoscoffee/compat/rei/display/PullingDisplay.java @@ -9,6 +9,7 @@ import ml.pluto7073.plutoscoffee.recipe.PullingRecipe; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeHolder; import java.util.Collections; import java.util.List; @@ -19,17 +20,18 @@ public class PullingDisplay extends BasicDisplay { private final int groundsRequired; private final int pullTime; - public PullingDisplay(PullingRecipe recipe) { - this(List.of(EntryIngredients.ofIngredient(recipe.grounds), EntryIngredients.ofIngredient(recipe.base)), Collections.singletonList(EntryIngredients.of(recipe.getResultItem())), - recipe, recipe.groundsRequired, recipe.pullTime); + public PullingDisplay(RecipeHolder recipe) { + this(List.of(EntryIngredients.ofIngredient(recipe.value().grounds), EntryIngredients.ofIngredient(recipe.value().base)), + Collections.singletonList(EntryIngredients.of(recipe.value().getResultItem())), + recipe, recipe.value().groundsRequired, recipe.value().pullTime); } public PullingDisplay(List inputs, List outputs, CompoundTag tag) { this(inputs, outputs, RecipeManagerContext.getInstance().byId(tag, "location"), tag.getInt("groundsRequired"), tag.getInt("pullTime")); } - public PullingDisplay(List inputs, List outputs, Recipe recipe, int groundsRequired, int pullTime) { - super(inputs, outputs, Optional.ofNullable(recipe).map(Recipe::getId)); + public PullingDisplay(List inputs, List outputs, RecipeHolder recipe, int groundsRequired, int pullTime) { + super(inputs, outputs, Optional.ofNullable(recipe).map(RecipeHolder::id)); this.groundsRequired = groundsRequired; this.pullTime = pullTime; } diff --git a/src/main/java/ml/pluto7073/plutoscoffee/gui/CoffeeBrewerScreen.java b/src/main/java/ml/pluto7073/plutoscoffee/gui/CoffeeBrewerScreen.java index b168231..be77092 100644 --- a/src/main/java/ml/pluto7073/plutoscoffee/gui/CoffeeBrewerScreen.java +++ b/src/main/java/ml/pluto7073/plutoscoffee/gui/CoffeeBrewerScreen.java @@ -24,7 +24,7 @@ protected void init() { public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { int i = (this.width - this.imageWidth) / 2; int j = (this.height - this.imageHeight) / 2; - this.renderBackground(graphics); + this.renderBackground(graphics, mouseX, mouseY, delta); super.render(graphics, mouseX, mouseY, delta); this.renderTooltip(graphics, mouseX, mouseY); if (mouseX >= i + 60 && mouseX <= i + 78 && mouseY >= j + 44 && mouseY <= j + 48) { diff --git a/src/main/java/ml/pluto7073/plutoscoffee/gui/CoffeeGrindrScreen.java b/src/main/java/ml/pluto7073/plutoscoffee/gui/CoffeeGrindrScreen.java index 9e11803..0ce9920 100644 --- a/src/main/java/ml/pluto7073/plutoscoffee/gui/CoffeeGrindrScreen.java +++ b/src/main/java/ml/pluto7073/plutoscoffee/gui/CoffeeGrindrScreen.java @@ -19,7 +19,7 @@ protected void init() { @Override public void render(GuiGraphics context, int mouseX, int mouseY, float delta) { - this.renderBackground(context); + this.renderBackground(context, mouseX, mouseY, delta); super.render(context, mouseX, mouseY, delta); this.renderTooltip(context, mouseX, mouseY); } diff --git a/src/main/java/ml/pluto7073/plutoscoffee/gui/EspressoMachineScreen.java b/src/main/java/ml/pluto7073/plutoscoffee/gui/EspressoMachineScreen.java index d95baa7..93fe969 100644 --- a/src/main/java/ml/pluto7073/plutoscoffee/gui/EspressoMachineScreen.java +++ b/src/main/java/ml/pluto7073/plutoscoffee/gui/EspressoMachineScreen.java @@ -23,7 +23,7 @@ protected void init() { public void render(GuiGraphics context, int mouseX, int mouseY, float delta) { int i = (this.width - this.imageWidth) / 2; int j = (this.height - this.imageHeight) / 2; - this.renderBackground(context); + this.renderBackground(context, mouseX, mouseY, delta); super.render(context, mouseX, mouseY, delta); this.renderTooltip(context, mouseX, mouseY); if (mouseX >= i + 60 && mouseX <= i + 78 && mouseY >= j + 44 && mouseY <= j + 48) { diff --git a/src/main/java/ml/pluto7073/plutoscoffee/recipe/PullingRecipe.java b/src/main/java/ml/pluto7073/plutoscoffee/recipe/PullingRecipe.java index 51890a1..55926c5 100644 --- a/src/main/java/ml/pluto7073/plutoscoffee/recipe/PullingRecipe.java +++ b/src/main/java/ml/pluto7073/plutoscoffee/recipe/PullingRecipe.java @@ -1,6 +1,8 @@ package ml.pluto7073.plutoscoffee.recipe; import com.google.gson.JsonObject; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import ml.pluto7073.plutoscoffee.blocks.EspressoMachineBlockEntity; import ml.pluto7073.plutoscoffee.registry.ModRecipes; import net.minecraft.MethodsReturnNonnullByDefault; @@ -17,13 +19,11 @@ @MethodsReturnNonnullByDefault public class PullingRecipe implements Recipe { - private final ResourceLocation id; public final Ingredient grounds, base; public final int groundsRequired, pullTime; final ItemStack result; - public PullingRecipe(ResourceLocation id, Ingredient grounds, Ingredient base, int groundsRequired, int pullTime, ItemStack result) { - this.id = id; + public PullingRecipe(Ingredient grounds, Ingredient base, int groundsRequired, int pullTime, ItemStack result) { this.grounds = grounds; this.base = base; this.groundsRequired = groundsRequired; @@ -58,11 +58,6 @@ public ItemStack getResultItem() { return result.copy(); } - @Override - public ResourceLocation getId() { - return id; - } - @Override public NonNullList getIngredients() { return NonNullList.of(grounds, base); @@ -80,24 +75,27 @@ public RecipeType getType() { public static class Serializer implements RecipeSerializer { + private static final Codec CODEC = RecordCodecBuilder.create(instance -> + instance.group(Ingredient.CODEC.fieldOf("grounds").forGetter(recipe -> recipe.grounds), + Ingredient.CODEC.fieldOf("base").forGetter(recipe -> recipe.base), + Codec.INT.fieldOf("groundsRequired").forGetter(recipe -> recipe.groundsRequired), + Codec.INT.fieldOf("pullTime").orElse(400).forGetter(recipe -> recipe.pullTime), + ItemStack.CODEC.fieldOf("result").forGetter(recipe -> recipe.result)) + .apply(instance, PullingRecipe::new)); + @Override - public PullingRecipe fromJson(ResourceLocation id, JsonObject json) { - Ingredient grounds = Ingredient.fromJson(GsonHelper.getAsJsonObject(json, "grounds")); - Ingredient base = Ingredient.fromJson(GsonHelper.getAsJsonObject(json, "base")); - int groundsRequired = GsonHelper.getAsInt(json, "groundsRequired"); - int pullTime = GsonHelper.getAsInt(json, "pullTime", 400); - ItemStack result = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result")); - return new PullingRecipe(id, grounds, base, groundsRequired, pullTime, result); + public Codec codec() { + return CODEC; } @Override - public PullingRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) { + public PullingRecipe fromNetwork(FriendlyByteBuf buf) { Ingredient grounds = Ingredient.fromNetwork(buf); Ingredient base = Ingredient.fromNetwork(buf); int groundsCount = buf.readInt(); int pullTime = buf.readInt(); ItemStack result = buf.readItem(); - return new PullingRecipe(id, grounds, base, groundsCount, pullTime, result); + return new PullingRecipe(grounds, base, groundsCount, pullTime, result); } @Override diff --git a/src/main/java/ml/pluto7073/plutoscoffee/registry/ModVillagerProfessions.java b/src/main/java/ml/pluto7073/plutoscoffee/registry/ModVillagerProfessions.java index 6e92c5b..8d1ce40 100644 --- a/src/main/java/ml/pluto7073/plutoscoffee/registry/ModVillagerProfessions.java +++ b/src/main/java/ml/pluto7073/plutoscoffee/registry/ModVillagerProfessions.java @@ -49,10 +49,10 @@ public static void postInit() { new VillagerTrades.EmeraldForItems(ModItems.USED_COFFEE_GROUNDS, 26, 16, 2) }, 2, new VillagerTrades.ItemListing[]{ - new VillagerTrades.ItemsAndEmeraldsToItems(ModItems.LIGHT_ROAST_BEAN, 3, 2, ModItems.GROUND_LIGHT_ROAST, 12, 12, 5), - new VillagerTrades.ItemsAndEmeraldsToItems(ModItems.MEDIUM_ROAST_BEAN, 3, 2, ModItems.GROUND_MEDIUM_ROAST, 12, 12, 5), - new VillagerTrades.ItemsAndEmeraldsToItems(ModItems.DARK_ROAST_BEAN, 3, 2, ModItems.GROUND_DARK_ROAST, 12, 12, 5), - new VillagerTrades.ItemsAndEmeraldsToItems(ModItems.ESPRESSO_ROAST_BEAN, 3, 2, ModItems.GROUND_ESPRESSO_ROAST, 12, 12, 5) + new VillagerTrades.ItemsAndEmeraldsToItems(ModItems.LIGHT_ROAST_BEAN, 3, 2, ModItems.GROUND_LIGHT_ROAST, 12, 12, 5, 0.05F), + new VillagerTrades.ItemsAndEmeraldsToItems(ModItems.MEDIUM_ROAST_BEAN, 3, 2, ModItems.GROUND_MEDIUM_ROAST, 12, 12, 5, 0.05F), + new VillagerTrades.ItemsAndEmeraldsToItems(ModItems.DARK_ROAST_BEAN, 3, 2, ModItems.GROUND_DARK_ROAST, 12, 12, 5, 0.05F), + new VillagerTrades.ItemsAndEmeraldsToItems(ModItems.ESPRESSO_ROAST_BEAN, 3, 2, ModItems.GROUND_ESPRESSO_ROAST, 12, 12, 5, 0.05F) }, 3, new VillagerTrades.ItemListing[]{ new VillagerTrades.ItemsForEmeralds(CoffeeUtil.getBaseCoffee(CoffeeTypes.LIGHT_ROAST), 3, 1, 12, 10), @@ -66,7 +66,7 @@ public static void postInit() { new VillagerTrades.ItemsForEmeralds(CoffeeUtil.getWithAdditions(LatteItem.getStandardLatte(), "pdapi:glow_berries"), 7, 1, 12, 20), new VillagerTrades.ItemsForEmeralds(CoffeeUtil.getWithAdditions(LatteItem.getStandardLatte(), "pdapi:honey", "pdapi:sugar"), 5, 1, 12, 20), new VillagerTrades.ItemsForEmeralds(CoffeeUtil.getWithAdditions(LatteItem.getStandardLatte(), "plutoscoffee:mocha_syrup", "plutoscoffee:caramel"), 8, 1, 12, 20), - new VillagerTrades.ItemsAndEmeraldsToItems(ModItems.DARK_ROAST_BEAN, 16, 2, ModItems.DECAF_ROAST_BEAN, 16, 12, 20) + new VillagerTrades.ItemsAndEmeraldsToItems(ModItems.DARK_ROAST_BEAN, 16, 2, ModItems.DECAF_ROAST_BEAN, 16, 12, 20, 0.05F) }, 5, new VillagerTrades.ItemListing[]{ new VillagerTrades.ItemsForEmeralds(ModItems.COFFEE_BREWER, 24, 1, 12, 25), diff --git a/src/main/resources/data/plutoscoffee/recipes/blonde_espresso_shot.json b/src/main/resources/data/plutoscoffee/recipes/blonde_espresso_shot.json index fbc36dd..7392f01 100644 --- a/src/main/resources/data/plutoscoffee/recipes/blonde_espresso_shot.json +++ b/src/main/resources/data/plutoscoffee/recipes/blonde_espresso_shot.json @@ -9,7 +9,7 @@ "groundsRequired": 2, "pullTime": 400, "result": { - "item": "plutoscoffee:blonde_espresso_shot", - "count": 1 + "id": "plutoscoffee:blonde_espresso_shot", + "Count": 1 } } \ No newline at end of file diff --git a/src/main/resources/data/plutoscoffee/recipes/decaf_espresso_shot.json b/src/main/resources/data/plutoscoffee/recipes/decaf_espresso_shot.json index 87c13c2..e15249e 100644 --- a/src/main/resources/data/plutoscoffee/recipes/decaf_espresso_shot.json +++ b/src/main/resources/data/plutoscoffee/recipes/decaf_espresso_shot.json @@ -9,7 +9,7 @@ "groundsRequired": 2, "pullTime": 400, "result": { - "item": "plutoscoffee:decaf_espresso_shot", - "count": 1 + "id": "plutoscoffee:decaf_espresso_shot", + "Count": 1 } } \ No newline at end of file diff --git a/src/main/resources/data/plutoscoffee/recipes/espresso_shot.json b/src/main/resources/data/plutoscoffee/recipes/espresso_shot.json index 94c4b70..0f7d26f 100644 --- a/src/main/resources/data/plutoscoffee/recipes/espresso_shot.json +++ b/src/main/resources/data/plutoscoffee/recipes/espresso_shot.json @@ -9,7 +9,7 @@ "groundsRequired": 2, "pullTime": 400, "result": { - "item": "plutoscoffee:espresso_shot", - "count": 1 + "id": "plutoscoffee:espresso_shot", + "Count": 1 } } \ No newline at end of file