From 5c2585068b57952ccb63300b75c2b85cdf190ec5 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 28 Jul 2018 10:10:17 +1000 Subject: [PATCH] SPIGOT-1588: Fix cancelling mount related events --- nms-patches/Entity.patch | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index b8a4a8878a..7bc62fd1aa 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -449,6 +449,15 @@ EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); entityitem.n(); +@@ -1678,7 +1963,7 @@ + Entity entity = this.ax; + + this.ax = null; +- entity.p(this); ++ if (!entity.p(this)) this.ax = entity; // CraftBukkit + } + + } @@ -1687,6 +1972,24 @@ if (entity.getVehicle() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); @@ -474,7 +483,12 @@ if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) { this.passengers.add(0, entity); } else { -@@ -1700,6 +2003,22 @@ +@@ -1696,13 +1999,30 @@ + } + } + +- protected void p(Entity entity) { ++ protected boolean p(Entity entity) { // CraftBukkit if (entity.getVehicle() == this) { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { @@ -490,14 +504,18 @@ + CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle(); + Entity n = craftn == null ? null : craftn.getHandle(); + if (event.isCancelled() || n != orig) { -+ return; ++ return false; + } + } + // CraftBukkit end this.passengers.remove(entity); entity.k = 60; } -@@ -1799,6 +2118,13 @@ ++ return true; // CraftBukkit + } + + protected boolean q(Entity entity) { +@@ -1799,6 +2119,13 @@ } public void setSwimming(boolean flag) { @@ -511,7 +529,7 @@ this.setFlag(4, flag); } -@@ -1859,14 +2185,49 @@ +@@ -1859,14 +2186,49 @@ } public void setAirTicks(int i) { @@ -564,7 +582,7 @@ } } -@@ -2035,19 +2396,76 @@ +@@ -2035,19 +2397,76 @@ if (!this.world.isClientSide && !this.dead) { this.world.methodProfiler.a("changeDimension"); MinecraftServer minecraftserver = this.bK(); @@ -644,7 +662,7 @@ BlockPosition blockposition; if (i == 1) { -@@ -2076,12 +2494,18 @@ +@@ -2076,12 +2495,18 @@ blockposition = new BlockPosition(this); } @@ -664,7 +682,7 @@ if (j == 1 && i == 1) { BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn()); -@@ -2089,6 +2513,7 @@ +@@ -2089,6 +2514,7 @@ } else { entity.setPositionRotation(blockposition, entity.yaw, entity.pitch); } @@ -672,7 +690,7 @@ boolean flag = entity.attachedToPlayer; -@@ -2096,13 +2521,21 @@ +@@ -2096,13 +2522,21 @@ worldserver1.addEntity(entity); entity.attachedToPlayer = flag; worldserver1.entityJoinedWorld(entity, false); @@ -695,7 +713,7 @@ return entity; } else { return null; -@@ -2242,7 +2675,26 @@ +@@ -2242,7 +2676,26 @@ } public void a(AxisAlignedBB axisalignedbb) {