diff --git a/changelog.md b/changelog.md index 86e19c1..783deae 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,7 @@ ------------------------------------------------------ Version 1.3.0 ------------------------------------------------------ -- Updated to 21w10a +- Updated to 21w18a ------------------------------------------------------ Version 1.2.1 diff --git a/gradle.properties b/gradle.properties index 2c1f056..711635b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=21w10a -yarn_mappings=21w10a+build.2 -loader_version=0.11.2 +minecraft_version=21w18a +yarn_mappings=21w18a+build.3 +loader_version=0.11.3 #Fabric api -fabric_version=0.32.1+1.17 +fabric_version=0.34.2+1.17 # Mod Properties -mod_version = 1.3.0-nightly.21w10a +mod_version = 1.3.0-nightly.21w18a maven_group = io.github.ladysnake archives_base_name = Pal diff --git a/src/main/java/io/github/ladysnake/pal/AbilityTracker.java b/src/main/java/io/github/ladysnake/pal/AbilityTracker.java index 5ecd8e5..6776fcf 100644 --- a/src/main/java/io/github/ladysnake/pal/AbilityTracker.java +++ b/src/main/java/io/github/ladysnake/pal/AbilityTracker.java @@ -17,7 +17,7 @@ */ package io.github.ladysnake.pal; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import org.jetbrains.annotations.Contract; /** @@ -87,7 +87,7 @@ public interface AbilityTracker { * @param tag the tag to write to */ @Contract(mutates = "param") - void save(CompoundTag tag); + void save(NbtCompound tag); /** * Loads a serialized form of an {@code AbilityTracker} from {@code tag} into this object. @@ -95,5 +95,5 @@ public interface AbilityTracker { * @param tag the tag to read from */ @Contract(mutates = "this") - void load(CompoundTag tag); + void load(NbtCompound tag); } diff --git a/src/main/java/io/github/ladysnake/pal/Pal.java b/src/main/java/io/github/ladysnake/pal/Pal.java index 06b0fab..14038cd 100644 --- a/src/main/java/io/github/ladysnake/pal/Pal.java +++ b/src/main/java/io/github/ladysnake/pal/Pal.java @@ -17,6 +17,7 @@ */ package io.github.ladysnake.pal; +import com.google.common.base.Suppliers; import io.github.ladysnake.pal.impl.PalInternals; import net.fabricmc.api.ModInitializer; import net.minecraft.entity.player.PlayerEntity; @@ -26,6 +27,7 @@ import java.util.Objects; import java.util.function.BiFunction; +import java.util.function.Supplier; /** * Player Ability Lib's main class. Provides static methods to interact with player abilities. @@ -172,8 +174,8 @@ public static boolean isAbilityRegistered(@Nullable Identifier abilityId) { * @return a lazy supplier for a player ability registered with the given {@code abilityId} * @throws NullPointerException if {@code abilityId} is null */ - public static Lazy provideRegisteredAbility(Identifier abilityId) { - return new Lazy<>(() -> Objects.requireNonNull(PalInternals.getAbility(abilityId), abilityId + " has not been registered")); + public static Supplier provideRegisteredAbility(Identifier abilityId) { + return Suppliers.memoize(() -> Objects.requireNonNull(PalInternals.getAbility(abilityId), abilityId + " has not been registered")); } @Override diff --git a/src/main/java/io/github/ladysnake/pal/SimpleAbilityTracker.java b/src/main/java/io/github/ladysnake/pal/SimpleAbilityTracker.java index a095326..8edf06e 100644 --- a/src/main/java/io/github/ladysnake/pal/SimpleAbilityTracker.java +++ b/src/main/java/io/github/ladysnake/pal/SimpleAbilityTracker.java @@ -20,9 +20,9 @@ import io.github.ladysnake.pal.impl.VanillaAbilityTracker; import net.fabricmc.fabric.api.util.NbtType; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.StringTag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtString; import net.minecraft.util.Identifier; import java.util.HashSet; @@ -99,17 +99,17 @@ protected boolean shouldBeEnabled() { } @Override - public void save(CompoundTag tag) { - ListTag list = new ListTag(); + public void save(NbtCompound tag) { + NbtList list = new NbtList(); for (AbilitySource abilitySource : this.abilitySources) { - list.add(StringTag.of(abilitySource.getId().toString())); + list.add(NbtString.of(abilitySource.getId().toString())); } tag.put("ability_sources", list); } @Override - public void load(CompoundTag tag) { - ListTag list = tag.getList("ability_sources", NbtType.STRING); + public void load(NbtCompound tag) { + NbtList list = tag.getList("ability_sources", NbtType.STRING); for (int i = 0; i < list.size(); i++) { Identifier sourceId = Identifier.tryParse(list.getString(i)); if (sourceId != null) { diff --git a/src/main/java/io/github/ladysnake/pal/impl/mixin/ServerPlayerEntityMixin.java b/src/main/java/io/github/ladysnake/pal/impl/mixin/ServerPlayerEntityMixin.java index e6496fe..fe32958 100644 --- a/src/main/java/io/github/ladysnake/pal/impl/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/io/github/ladysnake/pal/impl/mixin/ServerPlayerEntityMixin.java @@ -26,12 +26,11 @@ import io.github.ladysnake.pal.impl.VanillaAbilityTracker; import net.fabricmc.fabric.api.util.NbtType; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; +import net.minecraft.nbt.NbtList; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.network.ServerPlayerInteractionManager; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; @@ -93,10 +92,10 @@ private void checkAbilityConsistency(CallbackInfo ci) { } @Inject(method = "writeCustomDataToNbt", at = @At("RETURN")) - private void writeAbilitiesToTag(CompoundTag tag, CallbackInfo ci) { - ListTag list = new ListTag(); + private void writeAbilitiesToTag(NbtCompound tag, CallbackInfo ci) { + NbtList list = new NbtList(); for (Map.Entry entry : this.palAbilities.entrySet()) { - CompoundTag abilityTag = new CompoundTag(); + NbtCompound abilityTag = new NbtCompound(); abilityTag.putString("ability_id", entry.getKey().getId().toString()); entry.getValue().save(abilityTag); list.add(abilityTag); @@ -106,11 +105,11 @@ private void writeAbilitiesToTag(CompoundTag tag, CallbackInfo ci) { @Inject( method = "readCustomDataFromNbt", - at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;readCustomDataFromNbt(Lnet/minecraft/nbt/CompoundTag;)V", shift = At.Shift.AFTER) + at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;readCustomDataFromNbt(Lnet/minecraft/nbt/NbtCompound;)V", shift = At.Shift.AFTER) ) - private void readAbilitiesFromTag(CompoundTag tag, CallbackInfo ci) { - for (Tag t : tag.getList("playerabilitylib:abilities", NbtType.COMPOUND)) { - CompoundTag abilityTag = ((CompoundTag) t); + private void readAbilitiesFromTag(NbtCompound tag, CallbackInfo ci) { + for (NbtElement t : tag.getList("playerabilitylib:abilities", NbtType.COMPOUND)) { + NbtCompound abilityTag = ((NbtCompound) t); if (abilityTag.contains("ability_id")) { Identifier abilityId = Identifier.tryParse(abilityTag.getString("ability_id")); if (abilityId != null) {