Files
Shiroha/shiroha-server/minecraft-patches/features/0015-Fix-dragon-part-desync.patch
T
Suisuroru 84f62ca34b
Shiroha CI / build (push) Canceled after 0s
Shiroha CI / Event File (push) Canceled after 0s
refactor entity portal speed fix patch
2026-08-15 16:14:13 +08:00

52 lines
3.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <mrhua269@gmail.com>
Date: Wed, 8 Jul 2026 21:23:24 +0800
Subject: [PATCH] Fix dragon part desync
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java
index aa53138b3670a8337b639472a6ab5ce46702ff76..6be786dcd9f02c0b59ca90453ddabff936d1cfdf 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java
@@ -93,6 +93,7 @@ public final class ServerEntityLookup extends EntityLookup {
if (entity instanceof ThrownEnderpearl enderpearl) {
this.addEnderPearl(CoordinateUtils.getChunkKey(enderpearl.chunkPosition()), enderpearl.getId()); // Folia - region threading
}
+ if (entity instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Shiroha - Fix dragon part desync
entity.registerScheduler(); // Paper - optimise Folia entity scheduler
}
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index f18f8e24442ceb418996a86bca20ae7c0700af8a..dee189bea3e90fd5dd503a2fe6b8a5c986589c62 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -4463,6 +4463,7 @@ public abstract class Entity
Entity copy = this.getType().create(destination, EntitySpawnReason.DIMENSION_TRAVEL);
copy.restoreFrom(this);
copy.transform(pos, yaw, pitch, velocity);
+ if (copy instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Shiroha - Fix dragon part desync
// vanilla code used to call remove _after_ copying, and some stuff is required to be after copy - so add hook here
// for example, clearing of inventory after switching dimensions
this.postRemoveAfterChangingDimensions();
diff --git a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
index ab921ab4b4cc860abd77744f2bd201013e136e51..226198ae04bf53528dbeb6a45f6cfb6f42342a36 100644
--- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
+++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
@@ -1011,4 +1011,16 @@ public class EnderDragon extends Mob implements Enemy {
return 500;
}
// Paper end - init expToDrop for already dying spawned dragon
+
+ // Shiroha start - Fix dragon part desync
+ public void syncDragonPartsAfterTeleportTransform() {
+ for (EnderDragonPart part : this.subEntities) {
+ this.tickPart(part,
+ Math.abs(part.getBoundingBox().maxX - part.getBoundingBox().minX),
+ Math.abs(part.getBoundingBox().maxY - part.getBoundingBox().minY),
+ Math.abs(part.getBoundingBox().maxZ - part.getBoundingBox().minZ)
+ ); // offset -> 0.0
+ }
+ }
+ // Shiroha end
}