From 7e8d5d22b9c66f34bdc42d46ff6a07c149a4bc2b Mon Sep 17 00:00:00 2001 From: glisco Date: Wed, 4 Oct 2023 13:37:48 +0200 Subject: [PATCH] 1.20.2 --- build.gradle | 3 +- gradle.properties | 20 ++++++------- gradle/wrapper/gradle-wrapper.properties | 2 +- .../NumismaticOverhaul.java | 2 +- .../numismaticoverhaul/block/ShopBlock.java | 2 +- .../client/NumismaticOverhaulClient.java | 2 +- .../client/gui/CurrencyTooltipComponent.java | 6 +++- .../currency/MoneyBagLootEntry.java | 28 +++++++------------ .../mixin/TradeOfferInternalsMixin.java | 5 ++-- .../mixin/TradeOfferListMixin.java | 2 +- .../NumismaticVillagerTradesRegistry.java | 4 +-- .../json/adapters/SellSusStewAdapter.java | 5 +++- src/main/resources/fabric.mod.json | 4 +-- 13 files changed, 42 insertions(+), 43 deletions(-) diff --git a/build.gradle b/build.gradle index 18eaffe..37220c7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,7 @@ //file:noinspection GradlePackageVersionRange plugins { - id 'fabric-loom' version '1.1-SNAPSHOT' + id 'fabric-loom' version '1.4-SNAPSHOT' id 'maven-publish' - id 'io.github.juuxel.loom-quiltflower' version '1.7.3' } version = "${project.mod_version}+${project.minecraft_base_version}" diff --git a/gradle.properties b/gradle.properties index e2d8005..51e270a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_base_version=1.20 - minecraft_version=1.20 - yarn_mappings=1.20+build.1 - loader_version=0.14.21 + minecraft_base_version=1.20.2 + minecraft_version=1.20.2 + yarn_mappings=1.20.2+build.2 + loader_version=0.14.22 # Mod Properties mod_version=0.2.10 @@ -15,19 +15,19 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # check this on https://fabricmc.net/develop - fabric_version=0.83.0+1.20 + fabric_version=0.89.3+1.20.2 # https://github.com/OnyxStudios/Cardinal-Components-API/releases - cca_version=5.2.1 + cca_version=5.3.0 # https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-fabric/ - rei_version=12.0.622 + rei_version=13.0.666 # https://maven.wispforest.io/io/wispforest/owo-lib/ - owo_version=0.11.0+1.20 + owo_version=0.11.3+1.20.2 # https://www.curseforge.com/minecraft/mc-mods/modmenu/files - modmenu_version=7.0.0 + modmenu_version=8.0.0 # https://storage.googleapis.com/devan-maven/ - stacc_version=1.5.3-pre.1 + stacc_version=1.5.4-pre.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..db9a6b8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/glisco/numismaticoverhaul/NumismaticOverhaul.java b/src/main/java/com/glisco/numismaticoverhaul/NumismaticOverhaul.java index 68cfc80..5f77535 100644 --- a/src/main/java/com/glisco/numismaticoverhaul/NumismaticOverhaul.java +++ b/src/main/java/com/glisco/numismaticoverhaul/NumismaticOverhaul.java @@ -69,7 +69,7 @@ world, new BlockPos((int) pos.x, (int) pos.y, (int) pos.z), .75 public static final ScreenHandlerType PIGGY_BANK_SCREEN_HANDLER_TYPE = new ScreenHandlerType<>(PiggyBankScreenHandler::new, FeatureFlags.DEFAULT_ENABLED_FEATURES); public static final SoundEvent PIGGY_BANK_BREAK = SoundEvent.of(id("piggy_bank_break")); - public static final LootPoolEntryType MONEY_BAG_ENTRY = new LootPoolEntryType(new MoneyBagLootEntry.Serializer()); + public static final LootPoolEntryType MONEY_BAG_ENTRY = new LootPoolEntryType(MoneyBagLootEntry.CODEC); public static final TagKey> THE_BOURGEOISIE = TagKey.of(RegistryKeys.ENTITY_TYPE, id("the_bourgeoisie")); public static final TagKey VERY_HEAVY_BLOCKS = TagKey.of(RegistryKeys.BLOCK, id("very_heavy_blocks")); diff --git a/src/main/java/com/glisco/numismaticoverhaul/block/ShopBlock.java b/src/main/java/com/glisco/numismaticoverhaul/block/ShopBlock.java index 39ae991..bf6e81a 100644 --- a/src/main/java/com/glisco/numismaticoverhaul/block/ShopBlock.java +++ b/src/main/java/com/glisco/numismaticoverhaul/block/ShopBlock.java @@ -126,6 +126,6 @@ public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { @Nullable @Override public BlockEntityTicker getTicker(World world, BlockState state, BlockEntityType type) { - return checkType(type, NumismaticOverhaulBlocks.Entities.SHOP, ShopBlockEntity::tick); + return validateTicker(type, NumismaticOverhaulBlocks.Entities.SHOP, ShopBlockEntity::tick); } } diff --git a/src/main/java/com/glisco/numismaticoverhaul/client/NumismaticOverhaulClient.java b/src/main/java/com/glisco/numismaticoverhaul/client/NumismaticOverhaulClient.java index 78eb02b..329c2da 100644 --- a/src/main/java/com/glisco/numismaticoverhaul/client/NumismaticOverhaulClient.java +++ b/src/main/java/com/glisco/numismaticoverhaul/client/NumismaticOverhaulClient.java @@ -109,7 +109,7 @@ protected PurseLayerContainer(Sizing horizontalSizing, Sizing verticalSizing) { } @Override - protected void drawChildren(OwoUIDrawContext context, int mouseX, int mouseY, float partialTicks, float delta, List children) { + protected void drawChildren(OwoUIDrawContext context, int mouseX, int mouseY, float partialTicks, float delta, List children) { context.getMatrices().push(); context.getMatrices().translate(0, 0, 300); super.drawChildren(context, mouseX, mouseY, partialTicks, delta, children); diff --git a/src/main/java/com/glisco/numismaticoverhaul/client/gui/CurrencyTooltipComponent.java b/src/main/java/com/glisco/numismaticoverhaul/client/gui/CurrencyTooltipComponent.java index 724c668..fb78372 100644 --- a/src/main/java/com/glisco/numismaticoverhaul/client/gui/CurrencyTooltipComponent.java +++ b/src/main/java/com/glisco/numismaticoverhaul/client/gui/CurrencyTooltipComponent.java @@ -63,14 +63,18 @@ public void drawItems(TextRenderer textRenderer, int x, int y, DrawContext conte List originalCoins = data.original()[0] != -1 ? CurrencyConverter.getAsItemStackList(data.original()) : new ArrayList<>(); List coins = CurrencyConverter.getAsItemStackList(data.value()); + context.push().translate(0, 0, 50); + for (int i = 0; i < originalCoins.size(); i++) { - context.drawTexture(new Identifier("textures/gui/container/villager2.png"), x + (originalCoins.get(i).getCount() > 9 ? 14 : 11), y + 3, 0, 176, 9, 2, 512, 256); + context.drawGuiTexture(new Identifier("container/villager/discount_strikethrough"), x + (originalCoins.get(i).getCount() > 9 ? 14 : 11), y + 3, 9, 2); context.drawItemWithoutEntity(ItemOps.singleCopy(originalCoins.get(i)), x - 4, y - 5 + i * 10); } for (int i = 0; i < coins.size(); i++) { context.drawItemWithoutEntity(ItemOps.singleCopy(coins.get(i)), x - 4, y - 5 + i * 10 + (originalCoins.size() == 0 ? 0 : 10 + originalCoins.size() * 10)); } + + context.pop(); } private static Text createPlaceholder(int count) { diff --git a/src/main/java/com/glisco/numismaticoverhaul/currency/MoneyBagLootEntry.java b/src/main/java/com/glisco/numismaticoverhaul/currency/MoneyBagLootEntry.java index f6b9985..c88e60f 100644 --- a/src/main/java/com/glisco/numismaticoverhaul/currency/MoneyBagLootEntry.java +++ b/src/main/java/com/glisco/numismaticoverhaul/currency/MoneyBagLootEntry.java @@ -5,6 +5,8 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.item.ItemStack; import net.minecraft.loot.condition.LootCondition; import net.minecraft.loot.context.LootContext; @@ -12,16 +14,23 @@ import net.minecraft.loot.entry.LootPoolEntryType; import net.minecraft.loot.function.LootFunction; import net.minecraft.util.JsonHelper; +import net.minecraft.util.dynamic.Codecs; import net.minecraft.util.math.MathHelper; +import java.util.List; import java.util.function.Consumer; public class MoneyBagLootEntry extends LeafEntry { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + Codecs.createStrictOptionalFieldCodec(Codec.INT, "min", 0).forGetter(o -> o.min), + Codec.INT.fieldOf("max").forGetter(o -> o.max) + ).and(method_53290(instance)).apply(instance, MoneyBagLootEntry::new)); + private final int min; private final int max; - private MoneyBagLootEntry(int min, int max, int weight, int quality, LootCondition[] conditions, LootFunction[] functions) { + private MoneyBagLootEntry(int min, int max, int weight, int quality, List conditions, List functions) { super(weight, quality, conditions, functions); this.min = min; this.max = max; @@ -43,21 +52,4 @@ public static LeafEntry.Builder builder(int min, int max) { public LootPoolEntryType getType() { return NumismaticOverhaul.MONEY_BAG_ENTRY; } - - public static class Serializer extends LeafEntry.Serializer { - - @Override - public void addEntryFields(JsonObject jsonObject, MoneyBagLootEntry moneyBagLootEntry, JsonSerializationContext jsonSerializationContext) { - super.addEntryFields(jsonObject, moneyBagLootEntry, jsonSerializationContext); - jsonObject.addProperty("min", moneyBagLootEntry.min); - jsonObject.addProperty("max", moneyBagLootEntry.max); - } - - @Override - protected MoneyBagLootEntry fromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext, int i, int j, LootCondition[] lootConditions, LootFunction[] lootFunctions) { - final int mix = JsonHelper.getInt(jsonObject, "min", 0); - final int max = JsonHelper.getInt(jsonObject, "max"); - return new MoneyBagLootEntry(mix, max, i, j, lootConditions, lootFunctions); - } - } } diff --git a/src/main/java/com/glisco/numismaticoverhaul/mixin/TradeOfferInternalsMixin.java b/src/main/java/com/glisco/numismaticoverhaul/mixin/TradeOfferInternalsMixin.java index 431f302..ac835b0 100644 --- a/src/main/java/com/glisco/numismaticoverhaul/mixin/TradeOfferInternalsMixin.java +++ b/src/main/java/com/glisco/numismaticoverhaul/mixin/TradeOfferInternalsMixin.java @@ -2,6 +2,7 @@ import com.glisco.numismaticoverhaul.villagers.data.NumismaticVillagerTradesRegistry; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper; import net.fabricmc.fabric.impl.object.builder.TradeOfferInternals; import net.minecraft.village.TradeOffers; import net.minecraft.village.VillagerProfession; @@ -21,9 +22,9 @@ public class TradeOfferInternalsMixin { * @author glisco */ @Overwrite(remap = false) - public static synchronized void registerVillagerOffers(VillagerProfession profession, int level, Consumer> factory) { + public static synchronized void registerVillagerOffers(VillagerProfession profession, int level, TradeOfferHelper.VillagerOffersAdder factory) { final var factories = new ArrayList(); - factory.accept(factories); + factory.onRegister(factories, false); NumismaticVillagerTradesRegistry.registerFabricVillagerTrades(profession, level, factories); } diff --git a/src/main/java/com/glisco/numismaticoverhaul/mixin/TradeOfferListMixin.java b/src/main/java/com/glisco/numismaticoverhaul/mixin/TradeOfferListMixin.java index 2608628..2ef0b78 100644 --- a/src/main/java/com/glisco/numismaticoverhaul/mixin/TradeOfferListMixin.java +++ b/src/main/java/com/glisco/numismaticoverhaul/mixin/TradeOfferListMixin.java @@ -15,7 +15,7 @@ @Mixin(TradeOfferList.class) public class TradeOfferListMixin { - @Inject(method = "method_43715", at = @At(value = "INVOKE", ordinal = 4, target = "Lnet/minecraft/network/PacketByteBuf;writeInt(I)Lio/netty/buffer/ByteBuf;", shift = At.Shift.AFTER)) + @Inject(method = "method_43715", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeInt(I)Lnet/minecraft/network/PacketByteBuf;", ordinal = 4, shift = At.Shift.AFTER)) private static void writeReputation(PacketByteBuf buf, TradeOffer offer, CallbackInfo ci) { buf.writeVarInt(((NumismaticTradeOfferExtensions) offer).numismatic$getReputation()); } diff --git a/src/main/java/com/glisco/numismaticoverhaul/villagers/data/NumismaticVillagerTradesRegistry.java b/src/main/java/com/glisco/numismaticoverhaul/villagers/data/NumismaticVillagerTradesRegistry.java index b6bc828..92f6adf 100644 --- a/src/main/java/com/glisco/numismaticoverhaul/villagers/data/NumismaticVillagerTradesRegistry.java +++ b/src/main/java/com/glisco/numismaticoverhaul/villagers/data/NumismaticVillagerTradesRegistry.java @@ -29,7 +29,7 @@ public static void registerFabricWanderingTraderTrades(int level, List()).addAll(factories.stream().map(RemappingTradeWrapper::wrap).toList()); } - // -- NO datapack trades - this registry is cleared on reload-- + // -- NO datapack trades - this registry is cleared on reload -- public static void registerVillagerTrade(VillagerProfession profession, int level, TradeOffers.Factory trade) { getVillagerTradeList(TRADES_REGISTRY, profession, level).add(trade); @@ -55,7 +55,7 @@ public static void wrapModVillagers() { } private static List getVillagerTradeList(HashMap>> registry, VillagerProfession profession, int level) { - Int2ObjectOpenHashMap> villagerMap = getOrDefaultAndAdd(registry, profession, new Int2ObjectOpenHashMap<>()); + var villagerMap = getOrDefaultAndAdd(registry, profession, new Int2ObjectOpenHashMap<>()); return getOrDefaultAndAdd(villagerMap, level, new ArrayList<>()); } diff --git a/src/main/java/com/glisco/numismaticoverhaul/villagers/json/adapters/SellSusStewAdapter.java b/src/main/java/com/glisco/numismaticoverhaul/villagers/json/adapters/SellSusStewAdapter.java index 81c92aa..cdd5572 100644 --- a/src/main/java/com/glisco/numismaticoverhaul/villagers/json/adapters/SellSusStewAdapter.java +++ b/src/main/java/com/glisco/numismaticoverhaul/villagers/json/adapters/SellSusStewAdapter.java @@ -4,6 +4,7 @@ import com.glisco.numismaticoverhaul.villagers.exceptions.DeserializationException; import com.glisco.numismaticoverhaul.villagers.json.TradeJsonAdapter; import com.google.gson.JsonObject; +import net.minecraft.block.SuspiciousStewIngredient; import net.minecraft.entity.Entity; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.item.ItemStack; @@ -19,6 +20,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.List; + public class SellSusStewAdapter extends TradeJsonAdapter { @@ -57,7 +60,7 @@ public Factory(StatusEffect effect, int price, int duration, int experience, flo @Override public TradeOffer create(Entity entity, Random random) { ItemStack susStew = new ItemStack(Items.SUSPICIOUS_STEW, 1); - SuspiciousStewItem.addEffectToStew(susStew, this.effect, this.duration); + SuspiciousStewItem.addEffectsToStew(susStew, List.of(new SuspiciousStewIngredient.StewEffect(this.effect, this.duration))); return new TradeOffer(CurrencyHelper.getClosest(price), susStew, this.maxUses, this.experience, this.multiplier); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2448067..e63b0a4 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,10 +30,10 @@ "depends": { "fabricloader": ">=0.10.8", "fabric": "*", - "minecraft": ">=1.19.3", + "minecraft": ">=1.20.2", "cardinal-components-base": "*", "cardinal-components-entity": "*", - "owo": ">=0.9.2" + "owo": ">=0.11.3" }, "custom": { "cardinal-components": [