diff --git a/resources/changelog/1.19.2-2.1.3.txt b/resources/changelog/1.19.2-2.1.3.txt new file mode 100644 index 00000000..0b4c1b1a --- /dev/null +++ b/resources/changelog/1.19.2-2.1.3.txt @@ -0,0 +1,6 @@ +As always, don't forget to backup your world before updating! +Requires CyclopsCore version 1.17.0 or higher. + +Fixes: +* Fix crash when IC2 is installed, Closes #254 + diff --git a/resources/changelog/1.19.2-2.1.4.txt b/resources/changelog/1.19.2-2.1.4.txt new file mode 100644 index 00000000..8b888a4c --- /dev/null +++ b/resources/changelog/1.19.2-2.1.4.txt @@ -0,0 +1,6 @@ +As always, don't forget to backup your world before updating! +Requires CyclopsCore version 1.17.0 or higher. + +Fixes: +* Fix step assist stacking on world rejoin, Closes #255 + diff --git a/resources/changelog/1.20.1-2.0.13.txt b/resources/changelog/1.20.1-2.0.13.txt new file mode 100644 index 00000000..91f18feb --- /dev/null +++ b/resources/changelog/1.20.1-2.0.13.txt @@ -0,0 +1,6 @@ +As always, don't forget to backup your world before updating! +Requires CyclopsCore version 1.18.4 or higher. + +Fixes: +* Fix crash when IC2 is installed, Closes #254 + diff --git a/resources/changelog/1.20.1-2.0.14.txt b/resources/changelog/1.20.1-2.0.14.txt new file mode 100644 index 00000000..dba15ba1 --- /dev/null +++ b/resources/changelog/1.20.1-2.0.14.txt @@ -0,0 +1,6 @@ +As always, don't forget to backup your world before updating! +Requires CyclopsCore version 1.18.4 or higher. + +Fixes: +* Fix step assist stacking on world rejoin, Closes #255 + diff --git a/src/main/java/org/cyclops/everlastingabilities/ability/AbilityTypeSpecialStepAssist.java b/src/main/java/org/cyclops/everlastingabilities/ability/AbilityTypeSpecialStepAssist.java index eda697ee..1a6ad3f4 100644 --- a/src/main/java/org/cyclops/everlastingabilities/ability/AbilityTypeSpecialStepAssist.java +++ b/src/main/java/org/cyclops/everlastingabilities/ability/AbilityTypeSpecialStepAssist.java @@ -38,6 +38,20 @@ public Codec codec() { return Objects.requireNonNull(RegistryEntries.ABILITYSERIALIZER_SPECIAL_STEP_ASSIST.get()); } + @Override + public void onTick(Player player, int level) { + super.onTick(player, level); + + // On world re-join, ensure the modifier is in place. + AttributeInstance attribute = player.getAttribute(NeoForgeMod.STEP_HEIGHT.value()); + if (attribute != null) { + AttributeModifier modifier = this.attributeModifiers.get(level); + if (!attribute.hasModifier(modifier)) { + attribute.addTransientModifier(modifier); + } + } + } + @Override public void onChangedLevel(Player player, int oldLevel, int newLevel) { AttributeInstance attribute = player.getAttribute(NeoForgeMod.STEP_HEIGHT.value()); @@ -46,7 +60,7 @@ public void onChangedLevel(Player player, int oldLevel, int newLevel) { attribute.removeModifier(this.attributeModifiers.get(oldLevel).getId()); } if (newLevel > 0) { - attribute.addPermanentModifier(this.attributeModifiers.get(newLevel)); + attribute.addTransientModifier(this.attributeModifiers.get(newLevel)); } } } diff --git a/src/main/java/org/cyclops/everlastingabilities/core/helper/WorldHelpers.java b/src/main/java/org/cyclops/everlastingabilities/core/helper/WorldHelpers.java index 4596bd49..10808e8f 100644 --- a/src/main/java/org/cyclops/everlastingabilities/core/helper/WorldHelpers.java +++ b/src/main/java/org/cyclops/everlastingabilities/core/helper/WorldHelpers.java @@ -4,6 +4,8 @@ import net.neoforged.fml.DistExecutor; import net.neoforged.neoforge.server.ServerLifecycleHooks; +import javax.annotation.Nullable; + /** * Helpers for world related logic. * TODO: use CyclopsCore's version in >1.19.2 @@ -15,6 +17,7 @@ public class WorldHelpers { /** * @return The registry access client-side server-side. */ + @Nullable public static RegistryAccess getRegistryAccess() { if (ServerLifecycleHooks.getCurrentServer() != null) { return ServerLifecycleHooks.getCurrentServer().registryAccess(); diff --git a/src/main/java/org/cyclops/everlastingabilities/core/helper/WorldHelpersClient.java b/src/main/java/org/cyclops/everlastingabilities/core/helper/WorldHelpersClient.java index 16841694..04f2914c 100644 --- a/src/main/java/org/cyclops/everlastingabilities/core/helper/WorldHelpersClient.java +++ b/src/main/java/org/cyclops/everlastingabilities/core/helper/WorldHelpersClient.java @@ -5,13 +5,19 @@ import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; +import javax.annotation.Nullable; + /** * @author rubensworks */ public class WorldHelpersClient { @OnlyIn(Dist.CLIENT) + @Nullable public static RegistryAccess getRegistryAccess() { + if (Minecraft.getInstance().level == null) { + return null; + } return Minecraft.getInstance().level.registryAccess(); }