SPIGOT-5562: Entering a boat triggers VehicleExitEvent

This patch prevents entities from riding a vehicle they're already riding on.
When trying to enter a boat the client will send up to two packets for each hand
causing the server to think they should enter the boat twice, despite the first
interaction being sufficient.
This commit is contained in:
SydMontague 2020-06-25 10:00:00 +10:00 committed by md_5
parent 7ea3c040bc
commit 847ad16eed
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -384,7 +384,13 @@
this.world.addEntity(entityitem);
return entityitem;
}
@@ -1559,7 +1801,7 @@
@@ -1554,12 +1796,13 @@
return false;
} else {
if (this.isPassenger()) {
+ if (this.vehicle == entity) return true; // CraftBukkit - SPIGOT-5562: already riding
this.stopRiding();
}
this.setPose(EntityPose.STANDING);
this.vehicle = entity;
@ -393,7 +399,7 @@
return true;
}
}
@@ -1584,7 +1826,7 @@
@@ -1584,7 +1827,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@ -402,7 +408,7 @@
}
}
@@ -1593,10 +1835,31 @@
@@ -1593,10 +1836,31 @@
this.bb();
}
@ -435,7 +441,7 @@
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) {
this.passengers.add(0, entity);
} else {
@@ -1604,15 +1867,33 @@
@@ -1604,15 +1868,33 @@
}
}
@ -470,7 +476,7 @@
}
protected boolean q(Entity entity) {
@@ -1665,7 +1946,13 @@
@@ -1665,7 +1947,13 @@
this.world.getMethodProfiler().enter("portal");
this.portalTicks = i;
this.portalCooldown = this.getDefaultPortalCooldown();
@ -485,7 +491,7 @@
this.world.getMethodProfiler().exit();
}
@@ -1765,6 +2052,13 @@
@@ -1765,6 +2053,13 @@
}
public void setSwimming(boolean flag) {
@ -499,7 +505,7 @@
this.setFlag(4, flag);
}
@@ -1825,16 +2119,56 @@
@@ -1825,16 +2120,56 @@
}
public void setAirTicks(int i) {
@ -559,7 +565,7 @@
}
public void k(boolean flag) {
@@ -1986,18 +2320,45 @@
@@ -1986,18 +2321,45 @@
@Nullable
public Entity a(WorldServer worldserver) {
@ -609,7 +615,7 @@
} else {
double d0 = this.locX();
double d1 = this.locZ();
@@ -2023,7 +2384,16 @@
@@ -2023,7 +2385,16 @@
Vec3D vec3d1 = this.getPortalOffset();
blockposition = new BlockPosition(d0, this.locY(), d1);
@ -627,7 +633,7 @@
if (shapedetector_shape == null) {
return null;
@@ -2033,6 +2403,11 @@
@@ -2033,6 +2404,11 @@
vec3d = shapedetector_shape.velocity;
f = (float) shapedetector_shape.yaw;
}
@ -639,7 +645,7 @@
this.world.getMethodProfiler().exitEnter("reloading");
Entity entity = this.getEntityType().a((World) worldserver);
@@ -2043,8 +2418,16 @@
@@ -2043,8 +2419,16 @@
entity.setMot(vec3d);
worldserver.addEntityTeleport(entity);
if (worldserver.getDimensionKey() == World.THE_END) {
@ -657,7 +663,7 @@
}
this.bJ();
@@ -2253,7 +2636,26 @@
@@ -2253,7 +2637,26 @@
}
public void a(AxisAlignedBB axisalignedbb) {