From 3a190a56b456ffeff67659133bfd45f86b0e1a54 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sat, 1 Jun 2024 13:33:21 -0400 Subject: [PATCH 1/2] Add optional fix for modern ender dragon having broken movement compared to 1.13 --- .../EnderDragonMixin.java | 22 +++++++++++++++++++ .../core/config/ModernFixEarlyConfig.java | 1 + .../assets/modernfix/lang/en_us.json | 3 ++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/restore_old_dragon_movement/EnderDragonMixin.java diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/restore_old_dragon_movement/EnderDragonMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/restore_old_dragon_movement/EnderDragonMixin.java new file mode 100644 index 00000000..69560eb5 --- /dev/null +++ b/common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/restore_old_dragon_movement/EnderDragonMixin.java @@ -0,0 +1,22 @@ +package org.embeddedt.modernfix.common.mixin.bugfix.restore_old_dragon_movement; + +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.Slice; + +@Mixin(EnderDragon.class) +public class EnderDragonMixin { + /** + * @author embeddedt (regression identified by Jukitsu in MC-272431) + * @reason Revert dragon vertical movement behavior to how it worked in 1.13 and older. Note: this patches techniques + * that rely on the predictable vertical descent like one-cycling. + */ + @ModifyArg(method = "aiStep", + slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/boss/enderdragon/phases/DragonPhaseInstance;getFlyTargetLocation()Lnet/minecraft/world/phys/Vec3;")), + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;add(DDD)Lnet/minecraft/world/phys/Vec3;", ordinal = 0), index = 1) + private double fixVerticalVelocityScale(double y) { + return y * 10; + } +} diff --git a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java index 5a18501c..54680c8d 100644 --- a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java +++ b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java @@ -170,6 +170,7 @@ public class ModernFixEarlyConfig { .put("mixin.perf.reuse_datapacks", false) .put("mixin.feature.direct_stack_trace", false) .put("mixin.feature.stalled_chunk_load_detection", false) + .put("mixin.bugfix.restore_old_dragon_movement", false) .put("mixin.perf.clear_mixin_classinfo", false) .put("mixin.bugfix.packet_leak", false) .put("mixin.perf.deduplicate_location", false) diff --git a/common/src/main/resources/assets/modernfix/lang/en_us.json b/common/src/main/resources/assets/modernfix/lang/en_us.json index a2f242d8..aa23867f 100644 --- a/common/src/main/resources/assets/modernfix/lang/en_us.json +++ b/common/src/main/resources/assets/modernfix/lang/en_us.json @@ -131,5 +131,6 @@ "modernfix.option.mixin.feature.stalled_chunk_load_detection": "This option may help to detect the cause of chunkloading freezes. However, leaving it enabled may cause slightly worse performance.", "modernfix.option.mixin.perf.fix_loop_spin_waiting": "Fixes Minecraft's built-in wait function consuming excessive amounts of CPU resources.", "modernfix.option.mixin.perf.forge_cap_retrieval": "Small micro-optimization that makes retrieving custom entity data slightly more efficient on Forge.", - "modernfix.option.mixin.perf.forge_registry_lambda": "Fixes oversights in Forge that lead to excessive allocation in hot registry methods." + "modernfix.option.mixin.perf.forge_registry_lambda": "Fixes oversights in Forge that lead to excessive allocation in hot registry methods.", + "modernfix.option.mixin.bugfix.restore_old_dragon_movement": "Fixes MC-272431, which tracks the ender dragon being unable to dive to the portal as it did in 1.13 and older. This causes the dragon to fly quite a bit differently from what modern players are used to and also patches out one-cycling, so it's not enabled by default. Thanks to Jukitsu for identifying the regression in the vanilla code." } From 5d7813bf3e251ea044bd63f66451c7a0ed4ceb6f Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sat, 1 Jun 2024 13:37:50 -0400 Subject: [PATCH 2/2] Fix watchdog crash on server start --- .../java/org/embeddedt/modernfix/world/IntegratedWatchdog.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/src/main/java/org/embeddedt/modernfix/world/IntegratedWatchdog.java b/common/src/main/java/org/embeddedt/modernfix/world/IntegratedWatchdog.java index cfa52d7e..cfb4a0de 100644 --- a/common/src/main/java/org/embeddedt/modernfix/world/IntegratedWatchdog.java +++ b/common/src/main/java/org/embeddedt/modernfix/world/IntegratedWatchdog.java @@ -37,6 +37,9 @@ public class IntegratedWatchdog extends Thread { if(!lastTickStart.isPresent()) { return; } + if(lastTickStart.getAsLong() < 0) { + continue; + } long curTime = Util.getMillis(); long delta = curTime - lastTickStart.getAsLong(); if(delta > MAX_TICK_DELTA) {