Skip to content

Commit

Permalink
Update for 1.20.3/1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jsorrell committed Jul 25, 2024
1 parent 151f940 commit cada0dd
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 102 deletions.
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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<AllayVexTrigger.TriggerInstance> {
@Override
public Codec<TriggerInstance> 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<ContextAwarePredicate> player, DeserializationContext context) {
Optional<ContextAwarePredicate> vexPredicate = EntityPredicate.fromJson(json, "vex", context);
Optional<ContextAwarePredicate> allayPredicate = EntityPredicate.fromJson(json, "allay", context);
return new TriggerInstance(player, vexPredicate, allayPredicate);
}

public static class TriggerInstance extends AbstractCriterionTriggerInstance {
private final Optional<ContextAwarePredicate> vex;
private final Optional<ContextAwarePredicate> allay;

public TriggerInstance(
Optional<ContextAwarePredicate> player,
Optional<ContextAwarePredicate> vex,
Optional<ContextAwarePredicate> allay) {
super(player);
this.vex = vex;
this.allay = allay;
}
public record TriggerInstance(
Optional<ContextAwarePredicate> player,
Optional<ContextAwarePredicate> vex,
Optional<ContextAwarePredicate> allay)
implements SimpleInstance {

public static final Codec<TriggerInstance> 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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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<ConvertSpiderTrigger.TriggerInstance> {
@Override
public Codec<TriggerInstance> 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<ContextAwarePredicate> player, DeserializationContext context) {
Optional<ContextAwarePredicate> spiderPredicate = EntityPredicate.fromJson(json, "spider", context);
Optional<ContextAwarePredicate> caveSpiderPredicate = EntityPredicate.fromJson(json, "cave_spider", context);
return new TriggerInstance(player, spiderPredicate, caveSpiderPredicate);
}

public static class TriggerInstance extends AbstractCriterionTriggerInstance {
private final Optional<ContextAwarePredicate> spider;
private final Optional<ContextAwarePredicate> caveSpider;

public TriggerInstance(
Optional<ContextAwarePredicate> player,
Optional<ContextAwarePredicate> spider,
Optional<ContextAwarePredicate> caveSpider) {
super(player);
this.spider = spider;
this.caveSpider = caveSpider;
}
public record TriggerInstance(
Optional<ContextAwarePredicate> player,
Optional<ContextAwarePredicate> spider,
Optional<ContextAwarePredicate> caveSpider)
implements SimpleInstance {
public static final Codec<TriggerInstance> 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;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
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());
public static final ConvertSpiderTrigger CONVERT_SPIDER = register("convert_spider", new ConvertSpiderTrigger());
public static final AllayVexTrigger ALLAY_VEX = register("allay_vex", new AllayVexTrigger());

private static <T extends CriterionTrigger<?>> 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() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

public record SkyAdditionsEntityPredicate(
Optional<SkyAdditionsLocationPredicate> location, Optional<SkyAdditionsLocationPredicate> steppingOnLocation) {
public static final Codec<SkyAdditionsEntityPredicate> CODEC =
ExtraCodecs.recursive(codec -> RecordCodecBuilder.create(instance -> instance.group(
public static final Codec<SkyAdditionsEntityPredicate> CODEC = ExtraCodecs.recursive(
"SkyAdditionsEntityPredicate",
codec -> RecordCodecBuilder.create(instance -> instance.group(
ExtraCodecs.strictOptionalField(SkyAdditionsLocationPredicate.CODEC, "location")
.forGetter(SkyAdditionsEntityPredicate::location),
ExtraCodecs.strictOptionalField(SkyAdditionsLocationPredicate.CODEC, "stepping_on")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/carpetskyadditions.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"BlocksMixin",
"CamelMixin",
"ChunkGeneratorAccessor",
"CriteriaTriggersAccessor",
"DataFixersMixin",
"DispensePotionBehaviorMixin",
"DolphinMixin",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/resourcepacks/skyblock/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"pack_format": 18,
"pack_format": 26,
"description": "Accompanying datapack to the Carpet Sky Additions mod"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"pack_format": 18,
"pack_format": 26,
"description": "Acacia start - Also enable SkyBlock datapack"
}
}
2 changes: 1 addition & 1 deletion translations-pack/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"pack_format": 18,
"pack_format": 22,
"description": "Translations for the accompanying datapack to the Carpet Sky Additions mod"
}
}

0 comments on commit cada0dd

Please sign in to comment.