diff options
author | md_5 <git@md-5.net> | 2018-09-09 09:32:11 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-09-09 09:32:11 +1000 |
commit | 3f5ca5f2a41a7cdb38255668c73c3776482e6474 (patch) | |
tree | e5674ab38ae1d3ca06791fd60f65471791cefaf6 | |
parent | 19d654bd5ee46d9827153c91b71dd806d7268085 (diff) | |
download | craftbukkit-3f5ca5f2a41a7cdb38255668c73c3776482e6474.tar craftbukkit-3f5ca5f2a41a7cdb38255668c73c3776482e6474.tar.gz craftbukkit-3f5ca5f2a41a7cdb38255668c73c3776482e6474.tar.lz craftbukkit-3f5ca5f2a41a7cdb38255668c73c3776482e6474.tar.xz craftbukkit-3f5ca5f2a41a7cdb38255668c73c3776482e6474.zip |
SPIGOT-4355: Improve cancelling VehicleEnterEvent
-rw-r--r-- | nms-patches/Entity.patch | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index 0d91d11b..d9384b8a 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -425,7 +425,16 @@ this.world.addEntity(entityitem); return entityitem; } -@@ -1679,7 +1947,7 @@ +@@ -1658,7 +1926,7 @@ + } + + this.vehicle = entity; +- this.vehicle.o(this); ++ if (!this.vehicle.o(this)) this.vehicle = null; // CraftBukkit + return true; + } + } +@@ -1679,15 +1947,33 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -434,7 +443,9 @@ } } -@@ -1688,6 +1956,24 @@ + +- protected void o(Entity entity) { ++ protected boolean o(Entity entity) { // CraftBukkit if (entity.getVehicle() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); } else { @@ -452,15 +463,18 @@ + CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle(); + Entity n = craftn == null ? null : craftn.getHandle(); + if (event.isCancelled() || n != orig) { -+ return; ++ return false; + } + } + // CraftBukkit end if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) { this.passengers.add(0, entity); } else { -@@ -1697,13 +1983,30 @@ +@@ -1695,15 +1981,33 @@ + } + } ++ return true; // CraftBukkit } - protected void removePassenger(Entity entity) { @@ -491,7 +505,7 @@ } protected boolean q(Entity entity) { -@@ -1800,6 +2103,13 @@ +@@ -1800,6 +2104,13 @@ } public void setSwimming(boolean flag) { @@ -505,7 +519,7 @@ this.setFlag(4, flag); } -@@ -1860,16 +2170,53 @@ +@@ -1860,16 +2171,53 @@ } public void setAirTicks(int i) { @@ -562,7 +576,7 @@ } public void j(boolean flag) { -@@ -2036,19 +2383,72 @@ +@@ -2036,19 +2384,72 @@ if (!this.world.isClientSide && !this.dead) { this.world.methodProfiler.a("changeDimension"); MinecraftServer minecraftserver = this.bK(); @@ -638,7 +652,7 @@ BlockPosition blockposition; if (dimensionmanager == DimensionManager.THE_END) { -@@ -2077,12 +2477,18 @@ +@@ -2077,12 +2478,18 @@ blockposition = new BlockPosition(this); } @@ -658,7 +672,7 @@ if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) { BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn()); -@@ -2090,6 +2496,7 @@ +@@ -2090,6 +2497,7 @@ } else { entity.setPositionRotation(blockposition, entity.yaw, entity.pitch); } @@ -666,7 +680,7 @@ boolean flag = entity.attachedToPlayer; -@@ -2097,13 +2504,21 @@ +@@ -2097,13 +2505,21 @@ worldserver1.addEntity(entity); entity.attachedToPlayer = flag; worldserver1.entityJoinedWorld(entity, false); @@ -689,7 +703,7 @@ return entity; } else { return null; -@@ -2243,7 +2658,26 @@ +@@ -2243,7 +2659,26 @@ } public void a(AxisAlignedBB axisalignedbb) { |