small logic and javadoc changes
@@ -19,7 +19,7 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
/**
- * Lets entities get sent to the client even though they're not in range of a PlayerEntity
+ * Lets entities get sent to the client even though they're not in range of a player
*/
@Mixin(ChunkMap.TrackedEntity.class)
public abstract class TrackedEntityMixin {
@@ -34,7 +34,7 @@ public abstract class TrackedEntityMixin {
private boolean shouldBeSent = false;
/**
- * Checks if this entity is in range of a Camera that is currently being viewed, and stores the result in the field shouldBeSent
+ * Checks if this entity is in range of a camera that is currently being viewed, and stores the result in the field shouldBeSent
*/
@Inject(method = "updatePlayer", at = @At(value = "INVOKE_ASSIGN", target = "Ljava/lang/Math;min(II)I"), locals = LocalCapture.CAPTURE_FAILSOFT)
private void onUpdatePlayer(ServerPlayer player, CallbackInfo callback, Vec3 unused, int viewDistance) {
@@ -52,10 +52,9 @@ public abstract class TrackedEntityMixin {
*/
@ModifyVariable(method = "updatePlayer", name = "flag", at = @At(value = "JUMP", opcode = Opcodes.IFEQ, shift = At.Shift.BEFORE))
public boolean modifyFlag(boolean original) {
- if (entity instanceof SecurityCamera) {
- return true;
- }
+ boolean shouldBeSent = this.shouldBeSent;
- return original || shouldBeSent;
+ this.shouldBeSent = false;
+ return entity instanceof SecurityCamera || original || shouldBeSent;
}
}
