mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 08:38:45 +01:00
26 lines
1.6 KiB
Diff
26 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 ac846039c98ed297dcb913ef4a02d4ab259debd2..eaee840359e13914865433a78e683ce3c4196956 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
@@ -1928,9 +1928,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);
|
|
|