diff --git a/gradle.properties b/gradle.properties index eb2b8296..6173cb7f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,15 +8,15 @@ mod_version=4.4.2 java_version=17 # Fabric Properties # see https://fabricmc.net/develop/ -minecraft_version=1.20.2 -compatible_minecraft_versions=1.20.2 +minecraft_version=1.20.4 +compatible_minecraft_versions=>=1.20.3 <=1.20.4 loader_version=0.15.11 # Fabric Api -fabric_version=0.91.6+1.20.2 +fabric_version=0.97.1+1.20.4 # see https://maven.parchmentmc.org/org/parchmentmc/data -parchment_mappings=1.20.2:2023.12.10 +parchment_mappings=1.20.4:2024.04.14 # see https://masa.dy.fi/maven/carpet/fabric-carpet/ -carpet_core_version=1.20.2-1.4.119+v230928 +carpet_core_version=1.20.3-1.4.128+v231205 # see https://linkie.shedaniel.me/dependencies -cloth_config_version=12.0.119 -modmenu_version=8.0.1 +cloth_config_version=13.0.121 +modmenu_version=9.0.0 diff --git a/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/AllayVexTrigger.java b/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/AllayVexTrigger.java index aecb4bb5..bdd3fb5a 100644 --- a/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/AllayVexTrigger.java +++ b/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/AllayVexTrigger.java @@ -1,54 +1,45 @@ package com.jsorrell.carpetskyadditions.advancements.criterion; -import com.google.gson.JsonObject; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import java.util.Optional; import net.minecraft.advancements.critereon.*; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.ExtraCodecs; import net.minecraft.world.entity.animal.allay.Allay; import net.minecraft.world.entity.monster.Vex; import net.minecraft.world.level.storage.loot.LootContext; -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") public class AllayVexTrigger extends SimpleCriterionTrigger { + @Override + public Codec codec() { + return TriggerInstance.CODEC; + } + public void trigger(ServerPlayer player, Vex vex, Allay allay) { LootContext vexLootContext = EntityPredicate.createContext(player, vex); LootContext allayLootContext = EntityPredicate.createContext(player, allay); trigger(player, triggerInstance -> triggerInstance.matches(vexLootContext, allayLootContext)); } - @Override - public TriggerInstance createInstance( - JsonObject json, Optional player, DeserializationContext context) { - Optional vexPredicate = EntityPredicate.fromJson(json, "vex", context); - Optional allayPredicate = EntityPredicate.fromJson(json, "allay", context); - return new TriggerInstance(player, vexPredicate, allayPredicate); - } - - public static class TriggerInstance extends AbstractCriterionTriggerInstance { - private final Optional vex; - private final Optional allay; - - public TriggerInstance( - Optional player, - Optional vex, - Optional allay) { - super(player); - this.vex = vex; - this.allay = allay; - } + public record TriggerInstance( + Optional player, + Optional vex, + Optional allay) + implements SimpleInstance { + + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + ExtraCodecs.strictOptionalField(EntityPredicate.ADVANCEMENT_CODEC, "player") + .forGetter(TriggerInstance::player), + ExtraCodecs.strictOptionalField(EntityPredicate.ADVANCEMENT_CODEC, "vex") + .forGetter(TriggerInstance::vex), + ExtraCodecs.strictOptionalField(EntityPredicate.ADVANCEMENT_CODEC, "allay") + .forGetter(TriggerInstance::allay)) + .apply(instance, TriggerInstance::new)); public boolean matches(LootContext vexContext, LootContext allayContext) { return (vex.isEmpty() || vex.get().matches(vexContext)) && (allay.isEmpty() || allay.get().matches(allayContext)); } - - @Override - public JsonObject serializeToJson() { - JsonObject jsonObject = super.serializeToJson(); - - vex.ifPresent(v -> jsonObject.add("vex", v.toJson())); - allay.ifPresent(a -> jsonObject.add("allay", a.toJson())); - return jsonObject; - } } } diff --git a/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/ConvertSpiderTrigger.java b/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/ConvertSpiderTrigger.java index 2cf3705b..b9df65e1 100644 --- a/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/ConvertSpiderTrigger.java +++ b/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/ConvertSpiderTrigger.java @@ -1,53 +1,44 @@ package com.jsorrell.carpetskyadditions.advancements.criterion; -import com.google.gson.JsonObject; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import java.util.Optional; import net.minecraft.advancements.critereon.*; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.ExtraCodecs; import net.minecraft.world.entity.monster.CaveSpider; import net.minecraft.world.entity.monster.Spider; import net.minecraft.world.level.storage.loot.LootContext; -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") public class ConvertSpiderTrigger extends SimpleCriterionTrigger { + @Override + public Codec codec() { + return TriggerInstance.CODEC; + } + public void trigger(ServerPlayer player, Spider spider, CaveSpider caveSpider) { LootContext spiderLootContext = EntityPredicate.createContext(player, spider); LootContext caveSpiderLootContext = EntityPredicate.createContext(player, caveSpider); trigger(player, triggerInstance -> triggerInstance.matches(spiderLootContext, caveSpiderLootContext)); } - @Override - public TriggerInstance createInstance( - JsonObject json, Optional player, DeserializationContext context) { - Optional spiderPredicate = EntityPredicate.fromJson(json, "spider", context); - Optional caveSpiderPredicate = EntityPredicate.fromJson(json, "cave_spider", context); - return new TriggerInstance(player, spiderPredicate, caveSpiderPredicate); - } - - public static class TriggerInstance extends AbstractCriterionTriggerInstance { - private final Optional spider; - private final Optional caveSpider; - - public TriggerInstance( - Optional player, - Optional spider, - Optional caveSpider) { - super(player); - this.spider = spider; - this.caveSpider = caveSpider; - } + public record TriggerInstance( + Optional player, + Optional spider, + Optional caveSpider) + implements SimpleInstance { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + ExtraCodecs.strictOptionalField(EntityPredicate.ADVANCEMENT_CODEC, "player") + .forGetter(TriggerInstance::player), + ExtraCodecs.strictOptionalField(EntityPredicate.ADVANCEMENT_CODEC, "spider") + .forGetter(TriggerInstance::spider), + ExtraCodecs.strictOptionalField(EntityPredicate.ADVANCEMENT_CODEC, "cave_spider") + .forGetter(TriggerInstance::caveSpider)) + .apply(instance, TriggerInstance::new)); public boolean matches(LootContext spiderContext, LootContext caveSpiderContext) { return (spider.isEmpty() || spider.get().matches(spiderContext)) && (caveSpider.isEmpty() || caveSpider.get().matches(caveSpiderContext)); } - - @Override - public JsonObject serializeToJson() { - JsonObject jsonObject = super.serializeToJson(); - spider.ifPresent(s -> jsonObject.add("spider", s.toJson())); - caveSpider.ifPresent(cs -> jsonObject.add("cave_spider", cs.toJson())); - return jsonObject; - } } } diff --git a/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/SkyAdditionsCriteriaTriggers.java b/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/SkyAdditionsCriteriaTriggers.java index a7d8f420..9efa1416 100644 --- a/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/SkyAdditionsCriteriaTriggers.java +++ b/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/SkyAdditionsCriteriaTriggers.java @@ -1,10 +1,10 @@ package com.jsorrell.carpetskyadditions.advancements.criterion; -import com.jsorrell.carpetskyadditions.mixin.CriteriaTriggersAccessor; import com.jsorrell.carpetskyadditions.util.SkyAdditionsResourceLocation; import net.minecraft.advancements.CriterionTrigger; import net.minecraft.advancements.critereon.PlayerTrigger; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; public class SkyAdditionsCriteriaTriggers { public static final PlayerTrigger GENERATE_GEODE = register("generate_geode", new PlayerTrigger()); @@ -12,13 +12,7 @@ public class SkyAdditionsCriteriaTriggers { public static final AllayVexTrigger ALLAY_VEX = register("allay_vex", new AllayVexTrigger()); private static > T register(String name, T trigger) { - ResourceLocation resourceLocation = new SkyAdditionsResourceLocation(name); - - if (CriteriaTriggersAccessor.getCriteria().putIfAbsent(resourceLocation, trigger) != null) { - throw new IllegalArgumentException("Duplicate criterion id " + resourceLocation); - } else { - return trigger; - } + return Registry.register(BuiltInRegistries.TRIGGER_TYPES, new SkyAdditionsResourceLocation(name), trigger); } public static void bootstrap() {} diff --git a/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/SkyAdditionsEntityPredicate.java b/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/SkyAdditionsEntityPredicate.java index 4e178fe0..c19d2c51 100644 --- a/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/SkyAdditionsEntityPredicate.java +++ b/src/main/java/com/jsorrell/carpetskyadditions/advancements/criterion/SkyAdditionsEntityPredicate.java @@ -10,8 +10,9 @@ public record SkyAdditionsEntityPredicate( Optional location, Optional steppingOnLocation) { - public static final Codec CODEC = - ExtraCodecs.recursive(codec -> RecordCodecBuilder.create(instance -> instance.group( + public static final Codec CODEC = ExtraCodecs.recursive( + "SkyAdditionsEntityPredicate", + codec -> RecordCodecBuilder.create(instance -> instance.group( ExtraCodecs.strictOptionalField(SkyAdditionsLocationPredicate.CODEC, "location") .forGetter(SkyAdditionsEntityPredicate::location), ExtraCodecs.strictOptionalField(SkyAdditionsLocationPredicate.CODEC, "stepping_on") diff --git a/src/main/java/com/jsorrell/carpetskyadditions/mixin/CriteriaTriggersAccessor.java b/src/main/java/com/jsorrell/carpetskyadditions/mixin/CriteriaTriggersAccessor.java deleted file mode 100644 index 3081ba1e..00000000 --- a/src/main/java/com/jsorrell/carpetskyadditions/mixin/CriteriaTriggersAccessor.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.jsorrell.carpetskyadditions.mixin; - -import com.google.common.collect.BiMap; -import net.minecraft.advancements.CriteriaTriggers; -import net.minecraft.advancements.CriterionTrigger; -import net.minecraft.resources.ResourceLocation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(CriteriaTriggers.class) -public interface CriteriaTriggersAccessor { - @Accessor("CRITERIA") - static BiMap> getCriteria() { - throw new AssertionError(); - } -} diff --git a/src/main/java/com/jsorrell/carpetskyadditions/mixin/DataFixersMixin.java b/src/main/java/com/jsorrell/carpetskyadditions/mixin/DataFixersMixin.java index f0dacc13..2e789d8a 100644 --- a/src/main/java/com/jsorrell/carpetskyadditions/mixin/DataFixersMixin.java +++ b/src/main/java/com/jsorrell/carpetskyadditions/mixin/DataFixersMixin.java @@ -21,7 +21,7 @@ public abstract class DataFixersMixin { value = "INVOKE", target = "Lcom/mojang/datafixers/DataFixerBuilder;addSchema(ILjava/util/function/BiFunction;)Lcom/mojang/datafixers/schemas/Schema;", - ordinal = 149, + ordinal = 150, remap = false)) private static void addSkyBlockGeneratorNameFix(DataFixerBuilder builder, CallbackInfo ci) { Schema schema3079 = builder.addSchema(3079, V3079::new); @@ -35,7 +35,7 @@ private static void addSkyBlockGeneratorNameFix(DataFixerBuilder builder, Callba value = "INVOKE", target = "Lcom/mojang/datafixers/DataFixerBuilder;addSchema(ILjava/util/function/BiFunction;)Lcom/mojang/datafixers/schemas/Schema;", - ordinal = 159, + ordinal = 160, remap = false)) private static void addSkyBlockGeneratorNameFix2(DataFixerBuilder builder, CallbackInfo ci) { Schema schema3106 = builder.addSchema(3106, V3106::new); diff --git a/src/main/java/com/jsorrell/carpetskyadditions/mixin/WorldGenSettingsHeightAndBiomeFixMixin.java b/src/main/java/com/jsorrell/carpetskyadditions/mixin/WorldGenSettingsHeightAndBiomeFixMixin.java index dbec2866..8c5489eb 100644 --- a/src/main/java/com/jsorrell/carpetskyadditions/mixin/WorldGenSettingsHeightAndBiomeFixMixin.java +++ b/src/main/java/com/jsorrell/carpetskyadditions/mixin/WorldGenSettingsHeightAndBiomeFixMixin.java @@ -8,7 +8,7 @@ @Mixin(WorldGenSettingsHeightAndBiomeFix.class) public class WorldGenSettingsHeightAndBiomeFixMixin { @Redirect( - method = "method_38834(ZZLcom/mojang/serialization/Dynamic;)Lcom/mojang/serialization/Dynamic;", + method = "method_54971(ZZLcom/mojang/serialization/Dynamic;)Lcom/mojang/serialization/Dynamic;", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z")) private static boolean datafixSkyBlock(String s1, Object s2) { return s1.equals(s2) || "minecraft:skyblock".equals(s2); diff --git a/src/main/resources/carpetskyadditions.mixins.json b/src/main/resources/carpetskyadditions.mixins.json index e15ae7d5..40ca5e89 100644 --- a/src/main/resources/carpetskyadditions.mixins.json +++ b/src/main/resources/carpetskyadditions.mixins.json @@ -10,7 +10,6 @@ "BlocksMixin", "CamelMixin", "ChunkGeneratorAccessor", - "CriteriaTriggersAccessor", "DataFixersMixin", "DispensePotionBehaviorMixin", "DolphinMixin", diff --git a/src/main/resources/resourcepacks/skyblock/pack.mcmeta b/src/main/resources/resourcepacks/skyblock/pack.mcmeta index 7b36ffed..43f7c7ff 100644 --- a/src/main/resources/resourcepacks/skyblock/pack.mcmeta +++ b/src/main/resources/resourcepacks/skyblock/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 18, + "pack_format": 26, "description": "Accompanying datapack to the Carpet Sky Additions mod" } } diff --git a/src/main/resources/resourcepacks/skyblock_acacia/pack.mcmeta b/src/main/resources/resourcepacks/skyblock_acacia/pack.mcmeta index d159efb8..8bb0e929 100644 --- a/src/main/resources/resourcepacks/skyblock_acacia/pack.mcmeta +++ b/src/main/resources/resourcepacks/skyblock_acacia/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 18, + "pack_format": 26, "description": "Acacia start - Also enable SkyBlock datapack" } } diff --git a/translations-pack/pack.mcmeta b/translations-pack/pack.mcmeta index 53e5e2cf..0d07f136 100644 --- a/translations-pack/pack.mcmeta +++ b/translations-pack/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 18, + "pack_format": 22, "description": "Translations for the accompanying datapack to the Carpet Sky Additions mod" } }