geforkt von Mirrors/Paper
be13705177
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing CraftBukkit Changes: 6b8cd9a7 SPIGOT-6207: forcibly drop the items of a converted zombie villager
240 Zeilen
13 KiB
Diff
240 Zeilen
13 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: lukas81298 <lukas81298@gmail.com>
|
|
Date: Sun, 13 Dec 2020 13:42:55 +0100
|
|
Subject: [PATCH] do not create unnecessary copies of passenger list
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMount.java b/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMount.java
|
|
index edc6fff87c4abad2c123b1a46d6e5b792602b3be..5e739b26b6b5490b2c7651d3e9ff8649e776137e 100644
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMount.java
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMount.java
|
|
@@ -15,7 +15,7 @@ public class PacketPlayOutMount implements Packet<PacketListenerPlayOut> {
|
|
|
|
public PacketPlayOutMount(Entity entity) {
|
|
this.a = entity.getId();
|
|
- List<Entity> list = entity.getPassengers();
|
|
+ List<Entity> list = entity.passengers; // Paper - do not create a copy of the list
|
|
|
|
this.b = new int[list.size()];
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
|
|
index 58dd349adf2bc9bac6569464ef7a7aec81729e79..1df8fb8cb3fcf8201e1c5fa8ca13f7a9c632c379 100644
|
|
--- a/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
|
|
+++ b/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
|
|
@@ -103,10 +103,10 @@ public class EntityTrackerEntry {
|
|
|
|
public final void tick() { this.a(); } // Paper - OBFHELPER
|
|
public void a() {
|
|
- List<Entity> list = this.tracker.getPassengers();
|
|
+ List<Entity> list = this.tracker.passengers; // Paper - do not copy list
|
|
|
|
if (!list.equals(this.p)) {
|
|
- this.p = list;
|
|
+ this.p = com.google.common.collect.ImmutableList.copyOf(list); // Paper - only copy list if something has changed
|
|
this.broadcastIncludingSelf(new PacketPlayOutMount(this.tracker)); // CraftBukkit
|
|
}
|
|
|
|
@@ -376,7 +376,7 @@ public class EntityTrackerEntry {
|
|
}
|
|
}
|
|
|
|
- if (!this.tracker.getPassengers().isEmpty()) {
|
|
+ if (!this.tracker.passengers.isEmpty()) { // Paper - do not create copy of list
|
|
consumer.accept(new PacketPlayOutMount(this.tracker));
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
index b47cd2a8fb4920531d80acfcfe40f8211fedc9ae..300884804bf9ac3fba7c30a04d8adf52e3dd2e3e 100644
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
@@ -2307,7 +2307,7 @@ Sections go from 0..16. Now whenever a section is not empty, it can potentially
|
|
list.add(entity);
|
|
}
|
|
|
|
- if (!entity.getPassengers().isEmpty()) {
|
|
+ if (!entity.passengers.isEmpty()) { // Paper - do not copy list
|
|
list1.add(entity);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 7abeeefeb579a43bc9ee85fd4150afacfb11c802..429f0591c6a55f6c5d08a0755f7d39da676468bc 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -2230,7 +2230,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
}
|
|
|
|
protected boolean q(Entity entity) {
|
|
- return this.getPassengers().size() < 1;
|
|
+ return this.passengers.size() < 1; // Paper - do not copy list
|
|
}
|
|
|
|
public final float getCollisionBorderSize() { return bg(); } // Paper - OBFHELPER
|
|
@@ -2326,7 +2326,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
}
|
|
|
|
public boolean isVehicle() {
|
|
- return !this.getPassengers().isEmpty();
|
|
+ return !this.passengers.isEmpty(); // Paper - do not copy list
|
|
}
|
|
|
|
public boolean bt() {
|
|
@@ -3138,7 +3138,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
}
|
|
|
|
public boolean w(Entity entity) {
|
|
- Iterator iterator = this.getPassengers().iterator();
|
|
+ Iterator iterator = this.passengers.iterator(); // Paper - do not copy list
|
|
|
|
Entity entity1;
|
|
|
|
@@ -3154,7 +3154,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
}
|
|
|
|
public boolean a(Class<? extends Entity> oclass) {
|
|
- Iterator iterator = this.getPassengers().iterator();
|
|
+ Iterator iterator = this.passengers.iterator(); // Paper - do not copy list
|
|
|
|
Entity entity;
|
|
|
|
@@ -3171,7 +3171,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
|
|
public Collection<Entity> getAllPassengers() {
|
|
Set<Entity> set = Sets.newHashSet();
|
|
- Iterator iterator = this.getPassengers().iterator();
|
|
+ Iterator iterator = this.passengers.iterator(); // Paper - do not copy list
|
|
|
|
while (iterator.hasNext()) {
|
|
Entity entity = (Entity) iterator.next();
|
|
@@ -3197,7 +3197,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
private void a(boolean flag, Set<Entity> set) {
|
|
Entity entity;
|
|
|
|
- for (Iterator iterator = this.getPassengers().iterator(); iterator.hasNext(); entity.a(flag, set)) {
|
|
+ for (Iterator iterator = this.passengers.iterator(); iterator.hasNext(); entity.a(flag, set)) { // Paper - do not copy list
|
|
entity = (Entity) iterator.next();
|
|
if (!flag || EntityPlayer.class.isAssignableFrom(entity.getClass())) {
|
|
set.add(entity);
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java
|
|
index ec51a5532576ce25465bacf61c716ddaffca514e..d285f5aa66fa81a2f56920c05afb4506cb82fa54 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java
|
|
@@ -52,7 +52,7 @@ public class PathfinderGoalTame extends PathfinderGoal {
|
|
@Override
|
|
public void e() {
|
|
if (!this.entity.isTamed() && this.entity.getRandom().nextInt(50) == 0) {
|
|
- Entity entity = (Entity) this.entity.getPassengers().get(0);
|
|
+ Entity entity = this.entity.passengers.isEmpty() ? null : this.entity.passengers.get(0); // Paper - do not copy list, fixed array out of bounds exception as well
|
|
|
|
if (entity == null) {
|
|
return;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/EntityPig.java b/src/main/java/net/minecraft/world/entity/animal/EntityPig.java
|
|
index d6e1697f64e60f2a567288c604a1690159955f37..676ca381a5e111fc15f319e73504e4e60dbf0d2b 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/EntityPig.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/EntityPig.java
|
|
@@ -86,7 +86,7 @@ public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable {
|
|
@Nullable
|
|
@Override
|
|
public Entity getRidingPassenger() {
|
|
- return this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
|
|
+ return this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java b/src/main/java/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
|
|
index d678e3164ecdb7f0c600597bcb39d1054dfbc4b2..1e41c45af6dbcf097d7d6104e63db637f199301a 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
|
|
@@ -972,7 +972,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInven
|
|
@Nullable
|
|
@Override
|
|
public Entity getRidingPassenger() {
|
|
- return this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
|
|
+ return this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list
|
|
}
|
|
|
|
@Nullable
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityRavager.java b/src/main/java/net/minecraft/world/entity/monster/EntityRavager.java
|
|
index 7781386da593a1c4f3ad7e7e8761767dda7cb66c..16d5cae64887b82e67eeb61ccb714e6125ff0c09 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EntityRavager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityRavager.java
|
|
@@ -134,7 +134,7 @@ public class EntityRavager extends EntityRaider {
|
|
@Nullable
|
|
@Override
|
|
public Entity getRidingPassenger() {
|
|
- return this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
|
|
+ return this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java
|
|
index 069076d3c7165440217a7632b089ab2aa0fbdb1d..5e2c13bd6e52ffe182ef034e05ba6fe1cb301005 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java
|
|
@@ -317,7 +317,7 @@ public class EntityBoat extends Entity {
|
|
super.tick();
|
|
this.r();
|
|
if (this.cs()) {
|
|
- if (this.getPassengers().isEmpty() || !(this.getPassengers().get(0) instanceof EntityHuman)) {
|
|
+ if (this.passengers.isEmpty() || !(this.passengers.get(0) instanceof EntityHuman)) { // Paper - do not copy list
|
|
this.a(false, false);
|
|
}
|
|
|
|
@@ -380,7 +380,7 @@ public class EntityBoat extends Entity {
|
|
Entity entity = (Entity) list.get(j);
|
|
|
|
if (!entity.w(this)) {
|
|
- if (flag && this.getPassengers().size() < 2 && !entity.isPassenger() && entity.getWidth() < this.getWidth() && entity instanceof EntityLiving && !(entity instanceof EntityWaterAnimal) && !(entity instanceof EntityHuman)) {
|
|
+ if (flag && this.passengers.size() < 2 && !entity.isPassenger() && entity.getWidth() < this.getWidth() && entity instanceof EntityLiving && !(entity instanceof EntityWaterAnimal) && !(entity instanceof EntityHuman)) { // Paper - do not copy passenger list
|
|
entity.startRiding(this);
|
|
} else {
|
|
this.collide(entity);
|
|
@@ -727,8 +727,8 @@ public class EntityBoat extends Entity {
|
|
float f = 0.0F;
|
|
float f1 = (float) ((this.dead ? 0.009999999776482582D : this.bc()) + entity.bb());
|
|
|
|
- if (this.getPassengers().size() > 1) {
|
|
- int i = this.getPassengers().indexOf(entity);
|
|
+ if (this.passengers.size() > 1) { // Paper - do not copy list
|
|
+ int i = this.passengers.indexOf(entity); // Paper - do not copy list
|
|
|
|
if (i == 0) {
|
|
f = 0.2F;
|
|
@@ -747,7 +747,7 @@ public class EntityBoat extends Entity {
|
|
entity.yaw += this.ak;
|
|
entity.setHeadRotation(entity.getHeadRotation() + this.ak);
|
|
this.a(entity);
|
|
- if (entity instanceof EntityAnimal && this.getPassengers().size() > 1) {
|
|
+ if (entity instanceof EntityAnimal && this.passengers.size() > 1) { // Paper - do not copy list
|
|
int j = entity.getId() % 2 == 0 ? 90 : 270;
|
|
|
|
entity.n(((EntityAnimal) entity).aA + (float) j);
|
|
@@ -907,13 +907,13 @@ public class EntityBoat extends Entity {
|
|
|
|
@Override
|
|
protected boolean q(Entity entity) {
|
|
- return this.getPassengers().size() < 2 && !this.a((Tag) TagsFluid.WATER);
|
|
+ return this.passengers.size() < 2 && !this.a((Tag) TagsFluid.WATER); // Paper - do not copy list
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public Entity getRidingPassenger() {
|
|
- List<Entity> list = this.getPassengers();
|
|
+ List<Entity> list = this.passengers; // Paper - do not copy list
|
|
|
|
return list.isEmpty() ? null : (Entity) list.get(0);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java b/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
|
index 57821301ef031995e6044a17b46c70a693322455..75a88ab5d5b0fdb98ea8d61bb6b82049b21101f3 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
|
@@ -561,7 +561,7 @@ public abstract class EntityMinecartAbstract extends Entity {
|
|
|
|
vec3d1 = new Vec3D(d8 * d4 / d6, vec3d1.y, d8 * d5 / d6);
|
|
this.setMot(vec3d1);
|
|
- Entity entity = this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
|
|
+ Entity entity = this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
Vec3D vec3d2 = entity.getMot();
|