Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blacklist irregular entities from desync fix #369

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ public interface IPrevMotion
double getPrevMotionZ();

void setPrevMotionZ(double prevMotionZ);

/**
* Checks if this entity has ever called super.onUpdate(). This should adequately determine if it should be ignored by the desync fix.
* @return true if the implementing class calls super.onUpdate()
*/
boolean hasSuperUpdate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public static void initBlacklistedEntityEntries()

public static boolean isBlacklisted(Entity entity)
{
return blacklistedEntityEntries.contains(EntityRegistry.getEntry(entity.getClass()));
return blacklistedEntityEntries.contains(EntityRegistry.getEntry(entity.getClass())) || !(((IPrevMotion) entity).hasSuperUpdate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ public class UTEntityMixin implements IPrevMotion
private double prevMotionY;
@Unique
private double prevMotionZ;
@Unique
private boolean universalTweaks$superUpdate = false;

@Inject(method = "onUpdate", at = @At("HEAD"))
public void utOnUpdate(CallbackInfo info)
{
if (UTEntityDesync.isBlacklisted(((Entity) (Object) this))) return;
if (!universalTweaks$superUpdate) universalTweaks$superUpdate = true;
prevMotionX = motionX;
prevMotionY = motionY;
prevMotionZ = motionZ;
Expand Down Expand Up @@ -72,4 +75,10 @@ public void setPrevMotionZ(double prevMotionZ)
{
this.prevMotionZ = prevMotionZ;
}

@Override
public boolean hasSuperUpdate()
{
return universalTweaks$superUpdate;
}
}
Loading