Skip to content

Commit

Permalink
Update to 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pluto7073 committed Oct 8, 2024
1 parent ce476be commit 1a180f3
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 55 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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 {
Expand Down
19 changes: 9 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
rei_version=13.1.773
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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<PullingRecipe> recipe = matchGetter.getRecipeFor(EspressoMachineBlockEntity.this, level);
Optional<PullingRecipe> recipe = matchGetter.getRecipeFor(EspressoMachineBlockEntity.this, level).map(RecipeHolder::value);
if (recipe.isEmpty()) yield 400;
yield recipe.get().pullTime;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<PullingRecipe> 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<EntryIngredient> inputs, List<EntryIngredient> outputs, CompoundTag tag) {
this(inputs, outputs, RecipeManagerContext.getInstance().byId(tag, "location"), tag.getInt("groundsRequired"), tag.getInt("pullTime"));
}

public PullingDisplay(List<EntryIngredient> inputs, List<EntryIngredient> outputs, Recipe<?> recipe, int groundsRequired, int pullTime) {
super(inputs, outputs, Optional.ofNullable(recipe).map(Recipe::getId));
public PullingDisplay(List<EntryIngredient> inputs, List<EntryIngredient> outputs, RecipeHolder<?> recipe, int groundsRequired, int pullTime) {
super(inputs, outputs, Optional.ofNullable(recipe).map(RecipeHolder::id));
this.groundsRequired = groundsRequired;
this.pullTime = pullTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
32 changes: 15 additions & 17 deletions src/main/java/ml/pluto7073/plutoscoffee/recipe/PullingRecipe.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,13 +19,11 @@
@MethodsReturnNonnullByDefault
public class PullingRecipe implements Recipe<Container> {

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;
Expand Down Expand Up @@ -58,11 +58,6 @@ public ItemStack getResultItem() {
return result.copy();
}

@Override
public ResourceLocation getId() {
return id;
}

@Override
public NonNullList<Ingredient> getIngredients() {
return NonNullList.of(grounds, base);
Expand All @@ -80,24 +75,27 @@ public RecipeType<?> getType() {

public static class Serializer implements RecipeSerializer<PullingRecipe> {

private static final Codec<PullingRecipe> 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<PullingRecipe> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"groundsRequired": 2,
"pullTime": 400,
"result": {
"item": "plutoscoffee:blonde_espresso_shot",
"count": 1
"id": "plutoscoffee:blonde_espresso_shot",
"Count": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"groundsRequired": 2,
"pullTime": 400,
"result": {
"item": "plutoscoffee:decaf_espresso_shot",
"count": 1
"id": "plutoscoffee:decaf_espresso_shot",
"Count": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"groundsRequired": 2,
"pullTime": 400,
"result": {
"item": "plutoscoffee:espresso_shot",
"count": 1
"id": "plutoscoffee:espresso_shot",
"Count": 1
}
}

0 comments on commit 1a180f3

Please sign in to comment.