From 96fb8c6c3a05dd1c465865e6a5da7dbaad6ea40c Mon Sep 17 00:00:00 2001 From: Pyrofab Date: Fri, 12 Nov 2021 11:17:27 +0100 Subject: [PATCH] Update to 1.18-pre1 --- gradle.properties | 10 +++++----- .../ladysnake/paltest/AbilityToggleItem.java | 11 ++++++----- .../io/github/ladysnake/paltest/FlightEffect.java | 14 +++++++------- .../java/io/github/ladysnake/paltest/PalTest.java | 4 ++-- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/gradle.properties b/gradle.properties index 138847e..a506b7c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,11 +3,11 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=1.17.1 -yarn_mappings=1.17.1+build.10 +minecraft_version=1.18-pre1 +yarn_mappings=1.18-pre1+build.3 loader_version=0.12.5 #Fabric api -fabric_version=0.42.1+1.17 +fabric_version=0.42.2+1.18 # Mod Properties mod_version = 1.4.0 @@ -20,7 +20,7 @@ display_name = PlayerAbilityLib license_header = LGPL gpl_version = 3 curseforge_id = 359522 -curseforge_versions = 1.17; 1.17.1 +curseforge_versions = 1.18-Snapshot; 1.18 cf_requirements = fabric-api release_type = release -changelog_url = https://github.com/Ladysnake/PlayerAbilityLib/blob/1.17/changelog.md +changelog_url = https://github.com/Ladysnake/PlayerAbilityLib/blob/1.18/changelog.md diff --git a/src/testmod/java/io/github/ladysnake/paltest/AbilityToggleItem.java b/src/testmod/java/io/github/ladysnake/paltest/AbilityToggleItem.java index db0e185..b0400ac 100644 --- a/src/testmod/java/io/github/ladysnake/paltest/AbilityToggleItem.java +++ b/src/testmod/java/io/github/ladysnake/paltest/AbilityToggleItem.java @@ -23,6 +23,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.LiteralText; import net.minecraft.util.Formatting; import net.minecraft.util.Hand; @@ -45,16 +46,16 @@ public AbilityToggleItem(Settings settings, PlayerAbility abilityId, Identifier @Override public TypedActionResult use(World world, PlayerEntity user, Hand hand) { - if (!world.isClient) { - if (abilitySource.grants(user, this.ability)) { // check whether the source is granting the ability - abilitySource.revokeFrom(user, this.ability); // if it is, revoke it + if (user instanceof ServerPlayerEntity sp) { + if (abilitySource.grants(sp, this.ability)) { // check whether the source is granting the ability + abilitySource.revokeFrom(sp, this.ability); // if it is, revoke it } else { - abilitySource.grantTo(user, this.ability); // otherwise, grant it + abilitySource.grantTo(sp, this.ability); // otherwise, grant it } // Feedback message user.sendMessage(new LiteralText("") .append(new LiteralText(abilitySource.getId().toString()).styled(s -> s.withColor(Formatting.YELLOW))) - .append(abilitySource.grants(user, this.ability) ? new LiteralText(" added").styled(s -> s.withColor(Formatting.GREEN)) : new LiteralText(" removed").styled(s -> s.withColor(Formatting.RED))) + .append(abilitySource.grants(sp, this.ability) ? new LiteralText(" added").styled(s -> s.withColor(Formatting.GREEN)) : new LiteralText(" removed").styled(s -> s.withColor(Formatting.RED))) .append(" (") .append(new LiteralText(this.ability.getId().toString()).styled(s -> s.withColor(Formatting.YELLOW))) .append(" is ") diff --git a/src/testmod/java/io/github/ladysnake/paltest/FlightEffect.java b/src/testmod/java/io/github/ladysnake/paltest/FlightEffect.java index 86c6250..8a378c0 100644 --- a/src/testmod/java/io/github/ladysnake/paltest/FlightEffect.java +++ b/src/testmod/java/io/github/ladysnake/paltest/FlightEffect.java @@ -23,8 +23,8 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.AttributeContainer; import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectType; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.effect.StatusEffectCategory; +import net.minecraft.server.network.ServerPlayerEntity; /** * A status effect that gives creative flight to players @@ -32,23 +32,23 @@ public class FlightEffect extends StatusEffect { public static final AbilitySource FLIGHT_POTION = Pal.getAbilitySource(PalTest.id("potion_flight")); - public FlightEffect(StatusEffectType statusEffectType, int color) { + public FlightEffect(StatusEffectCategory statusEffectType, int color) { super(statusEffectType, color); } @Override public void onApplied(LivingEntity effected, AttributeContainer abstractEntityAttributeContainer, int amplifier) { super.onApplied(effected, abstractEntityAttributeContainer, amplifier); - if (effected instanceof PlayerEntity) { - Pal.grantAbility((PlayerEntity) effected, VanillaAbilities.ALLOW_FLYING, FLIGHT_POTION); + 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); - if (effected instanceof PlayerEntity) { - Pal.revokeAbility((PlayerEntity) effected, VanillaAbilities.ALLOW_FLYING, FLIGHT_POTION); + if (effected instanceof ServerPlayerEntity sp) { + Pal.revokeAbility(sp, VanillaAbilities.ALLOW_FLYING, FLIGHT_POTION); } } } diff --git a/src/testmod/java/io/github/ladysnake/paltest/PalTest.java b/src/testmod/java/io/github/ladysnake/paltest/PalTest.java index 507ed0b..db6aebc 100644 --- a/src/testmod/java/io/github/ladysnake/paltest/PalTest.java +++ b/src/testmod/java/io/github/ladysnake/paltest/PalTest.java @@ -23,7 +23,7 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.effect.StatusEffectType; +import net.minecraft.entity.effect.StatusEffectCategory; import net.minecraft.item.ArmorItem; import net.minecraft.item.ArmorMaterials; import net.minecraft.item.Item; @@ -45,7 +45,7 @@ public void onInitialize() { Registry.register(Registry.ITEM, id("bad_charm"), new BadFlightItem(new Item.Settings())); Registry.register(Registry.ITEM, id("flight_charm"), new AbilityToggleItem(new Item.Settings(), VanillaAbilities.ALLOW_FLYING, id("charm_flight"))); Registry.register(Registry.ITEM, id("kryptonite"), new AbilityToggleItem(new Item.Settings(), PalTestAbilities.LIMIT_FLIGHT, id("kryptonite"))); - Registry.register(Registry.STATUS_EFFECT, id("flight"), new FlightEffect(StatusEffectType.BENEFICIAL, 0xFFFFFF)); + Registry.register(Registry.STATUS_EFFECT, id("flight"), new FlightEffect(StatusEffectCategory.BENEFICIAL, 0xFFFFFF)); } private void registerWaxWings() {