diff --git a/changelog.md b/changelog.md index be9c414..b9057e9 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +------------------------------------------------------ +Version 1.9.0 +------------------------------------------------------ +- Updated to MC 1.20.2 + ------------------------------------------------------ Version 1.8.0 ------------------------------------------------------ diff --git a/gradle.properties b/gradle.properties index dc04d5e..5552f76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx4G # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=1.20 -yarn_mappings=1.20+build.1 +minecraft_version=1.20.2-rc2 +yarn_mappings=1.20.2-rc2+build.1 loader_version=0.14.22 #Fabric api -fabric_version=0.83.0+1.20 +fabric_version=0.89.0+1.20.2 -elmendorf_version = 0.11.0 +elmendorf_version = 0.12.0 # Mod Properties -mod_version = 1.8.0 +mod_version = 1.9.0 maven_group = io.github.ladysnake archives_base_name = pal @@ -22,7 +22,7 @@ display_name = PlayerAbilityLib license_header = LGPL gpl_version = 3 curseforge_id = 359522 -curseforge_versions = 1.20; 1.20.1 +curseforge_versions = 1.20.2-Snapshot cf_requirements = fabric-api modrinth_id = DHQA06r4 release_type = release 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 331ba84..29cd4fe 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 @@ -29,7 +29,7 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtList; -import net.minecraft.network.encryption.PlayerPublicKey; +import net.minecraft.network.packet.c2s.common.SyncedClientOptions; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -58,7 +58,7 @@ public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile @Inject(method = "", at = @At("RETURN")) - private void init(MinecraftServer server, ServerWorld world, GameProfile profile, CallbackInfo ci) { + private void init(MinecraftServer server, ServerWorld world, GameProfile profile, SyncedClientOptions clientOptions, CallbackInfo ci) { PalInternals.populate(this, this.palAbilities); } @@ -94,7 +94,7 @@ private void copyAbilitiesAfterRespawn(ServerPlayerEntity oldPlayer, boolean ali } } - @Inject(method = "sendAbilitiesUpdate", at = @At(value = "NEW", target = "net/minecraft/network/packet/s2c/play/PlayerAbilitiesS2CPacket")) + @Inject(method = "sendAbilitiesUpdate", at = @At(value = "NEW", target = "(Lnet/minecraft/entity/player/PlayerAbilities;)Lnet/minecraft/network/packet/s2c/play/PlayerAbilitiesS2CPacket;")) private void checkAbilityConsistency(CallbackInfo ci) { for (PlayerAbility ability : this.listPalAbilities()) { AbilityTracker tracker = this.get(ability); diff --git a/src/testmod/java/io/github/ladysnake/paltest/FlightEffect.java b/src/testmod/java/io/github/ladysnake/paltest/FlightEffect.java index e6278f9..3b68f83 100644 --- a/src/testmod/java/io/github/ladysnake/paltest/FlightEffect.java +++ b/src/testmod/java/io/github/ladysnake/paltest/FlightEffect.java @@ -37,16 +37,14 @@ public FlightEffect(StatusEffectCategory statusEffectType, int color) { } @Override - public void onApplied(LivingEntity effected, AttributeContainer abstractEntityAttributeContainer, int amplifier) { - super.onApplied(effected, abstractEntityAttributeContainer, amplifier); + public void onApplied(LivingEntity effected, int amplifier) { + super.onApplied(effected, amplifier); if (effected instanceof ServerPlayerEntity sp) { Pal.grantAbility(sp, VanillaAbilities.ALLOW_FLYING, FLIGHT_POTION); } } - @Override - public void onRemoved(LivingEntity effected, AttributeContainer abstractEntityAttributeContainer, int amplifier) { - super.onRemoved(effected, abstractEntityAttributeContainer, amplifier); + public void onRemoved(LivingEntity effected) { if (effected instanceof ServerPlayerEntity sp) { Pal.revokeAbility(sp, VanillaAbilities.ALLOW_FLYING, FLIGHT_POTION); } diff --git a/src/testmod/java/io/github/ladysnake/paltest/PalTestSuite.java b/src/testmod/java/io/github/ladysnake/paltest/PalTestSuite.java index 6b33bd1..48f7a5e 100644 --- a/src/testmod/java/io/github/ladysnake/paltest/PalTestSuite.java +++ b/src/testmod/java/io/github/ladysnake/paltest/PalTestSuite.java @@ -22,6 +22,7 @@ import io.github.ladysnake.pal.Pal; import io.github.ladysnake.pal.VanillaAbilities; import net.fabricmc.fabric.api.gametest.v1.FabricGameTest; +import net.minecraft.network.packet.c2s.common.SyncedClientOptions; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.test.GameTest; import net.minecraft.test.GameTestException; @@ -54,6 +55,6 @@ private static void assertTrue(boolean b, String message) { } private ServerPlayerEntity createMockPlayer(TestContext ctx) { - return new ServerPlayerEntity(ctx.getWorld().getServer(), ctx.getWorld(), new GameProfile(UUID.randomUUID(), "test-mock-player")); + return new ServerPlayerEntity(ctx.getWorld().getServer(), ctx.getWorld(), new GameProfile(UUID.randomUUID(), "test-mock-player"), SyncedClientOptions.createDefault()); } } diff --git a/src/testmod/java/io/github/ladysnake/paltest/mixin/LivingEntityMixin.java b/src/testmod/java/io/github/ladysnake/paltest/mixin/LivingEntityMixin.java new file mode 100644 index 0000000..7b428da --- /dev/null +++ b/src/testmod/java/io/github/ladysnake/paltest/mixin/LivingEntityMixin.java @@ -0,0 +1,36 @@ +/* + * PlayerAbilityLib + * Copyright (C) 2019-2023 Ladysnake + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; If not, see . + */ +package io.github.ladysnake.paltest.mixin; + +import io.github.ladysnake.paltest.FlightEffect; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.effect.StatusEffectInstance; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(LivingEntity.class) +public class LivingEntityMixin { + @Inject(method = "onStatusEffectRemoved", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/effect/StatusEffect;onRemoved(Lnet/minecraft/entity/attribute/AttributeContainer;)V")) + private void callOnRemoved(StatusEffectInstance effect, CallbackInfo ci) { + if (effect.getEffectType() instanceof FlightEffect flightEffect) { + flightEffect.onRemoved((LivingEntity) (Object) this); + } + } +} diff --git a/src/testmod/resources/fabric.mod.json b/src/testmod/resources/fabric.mod.json index e1f5ff4..56d2aec 100644 --- a/src/testmod/resources/fabric.mod.json +++ b/src/testmod/resources/fabric.mod.json @@ -14,6 +14,9 @@ "issues": "https://github.com/Ladysnake/Pal/issues", "discord": "ladysnake.glitch.me/discord" }, + "mixins": [ + "mixins.paltest.common.json" + ], "environment": "*", "entrypoints": { "main": [ diff --git a/src/testmod/resources/mixins.paltest.common.json b/src/testmod/resources/mixins.paltest.common.json new file mode 100644 index 0000000..ae72447 --- /dev/null +++ b/src/testmod/resources/mixins.paltest.common.json @@ -0,0 +1,12 @@ +{ + "required": true, + "package": "io.github.ladysnake.paltest.mixin", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.7.11-SNAPSHOT", + "mixins": [ + "LivingEntityMixin" + ], + "injectors": { + "defaultRequire": 1 + } +}