Skip to content

Commit a912fcf

Browse files
committed
Attempt 2
1 parent 8c0cadf commit a912fcf

4 files changed

Lines changed: 20 additions & 31 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repositories {
2323

2424
dependencies {
2525
implementation "com.github.wearblackallday:JavaUtils:bd58640372"
26-
include"com.github.wearblackallday:JavaUtils:bd58640372"
26+
include "com.github.wearblackallday:JavaUtils:bd58640372"
2727

2828
// To change the versions see the gradle.properties file
2929
minecraft "com.mojang:minecraft:${project.minecraft_version}"

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G
33
# Fabric Properties
44
# check these on https://modmuss50.me/fabric.html
55
minecraft_version=1.18.2
6-
yarn_mappings=1.18.2+build.2
6+
yarn_mappings=1.18.2+build.3
77
loader_version=0.13.3
88
# Mod Properties
9-
mod_version=1.2.6-1.18.2-sand-duper-fix
9+
mod_version=1.2.6-1.18.2-sand-duper-fix.2
1010
maven_group=wearblackallday
1111
archives_base_name=DimThread
1212
# Dependencies
1313
# check this on https://modmuss50.me/fabric.html
14-
fabric_version=0.48.0+1.18.2
14+
fabric_version=0.51.1+1.18.2
1515
#fabric_game_rule_v1_version=1.0.9+e77d3ea6cb
1616

src/main/java/wearblackallday/dimthread/mixin/EntityMixin.java

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@
1212
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1313
import 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
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
accessWidener v1 named
2-
accessible class net/minecraft/server/world/ServerChunkManager$MainThreadExecutor
2+
accessible class net/minecraft/server/world/ServerChunkManager$MainThreadExecutor

0 commit comments

Comments
 (0)