1212import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
1313import wearblackallday .dimthread .DimThread ;
1414
15- @ Mixin (Entity .class )
16- public abstract class EntityMixin {
17-
18- @ Shadow public abstract Entity moveToWorld (ServerWorld destination );
19-
20- @ Shadow @ Final public abstract boolean isRemoved ();
21-
22- @ Shadow private Entity .RemovalReason removalReason ;
15+ import org .slf4j .LoggerFactory ;
2316
24- private boolean duped = false ;
17+ @ Mixin (Entity .class )
18+ public abstract class EntityMixin implements Cloneable {
2519
2620 /**
2721 * Schedules moving entities between dimensions to the server thread. Once all
@@ -38,26 +32,21 @@ public void moveToWorld(ServerWorld destination, CallbackInfoReturnable<Entity>
3832 return ;
3933
4034 if (DimThread .owns (Thread .currentThread ())) {
41- destination .getServer ().execute (() -> this .moveToWorld (destination ));
35+ Entity snapshot = null ;
36+ try {
37+ snapshot = (Entity ) (this .clone ());
38+ } catch (CloneNotSupportedException e ) {
39+ throw new RuntimeException (e );
40+ }
41+ final Entity finalSnapshot = snapshot ;
42+ destination .getServer ().execute (
43+ () -> finalSnapshot .moveToWorld (destination )
44+ );
4245 ci .setReturnValue (null );
4346 }
4447 }
4548
46- /**
47- * If in the moveToWorld method removalReason is DISCARDED, then we assume its
48- * caused by a sand duplicator.
49- */
50- @ Redirect (method = "moveToWorld" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/Entity;isRemoved()Z" ))
51- public final boolean forceNotRemoved (Entity self ) {
52- Entity .RemovalReason reason = this .removalReason ;
53- if (
54- self instanceof FallingBlockEntity &&
55- reason == Entity .RemovalReason .DISCARDED &&
56- !duped
57- ) {
58- duped = true ;
59- return false ;
60- }
61- return self .isRemoved ();
49+ protected Object clone () throws CloneNotSupportedException {
50+ return super .clone ();
6251 }
6352}
0 commit comments