Skip to content

Commit 392fca3

Browse files
authored
Merge pull request #369 from jchung01/desync-fix-compat
Blacklist irregular entities from desync fix
2 parents b284201 + ea6f375 commit 392fca3

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/desync/IPrevMotion.java

+6
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ public interface IPrevMotion
1414
double getPrevMotionZ();
1515

1616
void setPrevMotionZ(double prevMotionZ);
17+
18+
/**
19+
* Checks if this entity has ever called super.onUpdate(). This should adequately determine if it should be ignored by the desync fix.
20+
* @return true if the implementing class calls super.onUpdate()
21+
*/
22+
boolean hasSuperUpdate();
1723
}

src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/desync/UTEntityDesync.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public static void initBlacklistedEntityEntries()
3636

3737
public static boolean isBlacklisted(Entity entity)
3838
{
39-
return blacklistedEntityEntries.contains(EntityRegistry.getEntry(entity.getClass()));
39+
return blacklistedEntityEntries.contains(EntityRegistry.getEntry(entity.getClass())) || !(((IPrevMotion) entity).hasSuperUpdate());
4040
}
4141
}

src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/desync/mixin/UTEntityMixin.java

+9
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ public class UTEntityMixin implements IPrevMotion
2727
private double prevMotionY;
2828
@Unique
2929
private double prevMotionZ;
30+
@Unique
31+
private boolean universalTweaks$superUpdate = false;
3032

3133
@Inject(method = "onUpdate", at = @At("HEAD"))
3234
public void utOnUpdate(CallbackInfo info)
3335
{
3436
if (UTEntityDesync.isBlacklisted(((Entity) (Object) this))) return;
37+
if (!universalTweaks$superUpdate) universalTweaks$superUpdate = true;
3538
prevMotionX = motionX;
3639
prevMotionY = motionY;
3740
prevMotionZ = motionZ;
@@ -72,4 +75,10 @@ public void setPrevMotionZ(double prevMotionZ)
7275
{
7376
this.prevMotionZ = prevMotionZ;
7477
}
78+
79+
@Override
80+
public boolean hasSuperUpdate()
81+
{
82+
return universalTweaks$superUpdate;
83+
}
7584
}

0 commit comments

Comments
 (0)