mirror of
https://github.com/PaperMC/Paper.git
synced 2024-08-20 11:22:56 +02:00
27 lines
1.6 KiB
Diff
27 lines
1.6 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||
|
Date: Mon, 27 Apr 2020 00:04:16 -0700
|
||
|
Subject: [PATCH] Reduce allocation of Vec3D by entity tracker
|
||
|
|
||
|
|
||
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||
|
index 16cce0feeca7d6f9f67100a07b824930adabcc72..926e4a8ea6e5afc6ad683761a5d8c4006cdec5ee 100644
|
||
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||
|
@@ -1929,9 +1929,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||
|
public void updatePlayer(ServerPlayer player) {
|
||
|
org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot
|
||
|
if (player != this.entity) {
|
||
|
- Vec3 vec3d = player.position().subtract(this.entity.position());
|
||
|
+ // Paper start - remove allocation of Vec3D here
|
||
|
+ // Vec3 vec3d = player.position().subtract(this.entity.position());
|
||
|
+ double vec3d_dx = player.getX() - this.entity.getX();
|
||
|
+ double vec3d_dz = player.getZ() - this.entity.getZ();
|
||
|
+ // Paper end - remove allocation of Vec3D here
|
||
|
double d0 = (double) Math.min(this.getEffectiveRange(), (ChunkMap.this.viewDistance - 1) * 16);
|
||
|
- double d1 = vec3d.x * vec3d.x + vec3d.z * vec3d.z;
|
||
|
+ double d1 = vec3d_dx * vec3d_dx + vec3d_dz * vec3d_dz; // Paper
|
||
|
double d2 = d0 * d0;
|
||
|
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player);
|
||
|
|