Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-1.20-lts' into master-1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jun 21, 2024
2 parents a93b719 + aebed08 commit 5ca2ae0
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 1 deletion.
6 changes: 6 additions & 0 deletions resources/changelog/1.19.2-2.1.3.txt
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions resources/changelog/1.19.2-2.1.4.txt
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions resources/changelog/1.20.1-2.0.13.txt
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions resources/changelog/1.20.1-2.0.14.txt
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ public Codec<? extends IAbilityType> 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());
Expand All @@ -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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 5ca2ae0

Please sign in to comment.