mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 00:30:25 +01:00
SPIGOT-4355: Improve cancelling VehicleEnterEvent
This commit is contained in:
parent
19d654bd5e
commit
3f5ca5f2a4
1 changed files with 25 additions and 11 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue