mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 00:50:41 +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);
|
this.world.addEntity(entityitem);
|
||||||
return 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;
|
Entity entity = this.vehicle;
|
||||||
|
|
||||||
this.vehicle = null;
|
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) {
|
if (entity.getVehicle() != this) {
|
||||||
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
|
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
|
||||||
} else {
|
} else {
|
||||||
|
@ -452,15 +463,18 @@
|
||||||
+ CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
+ CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
||||||
+ Entity n = craftn == null ? null : craftn.getHandle();
|
+ Entity n = craftn == null ? null : craftn.getHandle();
|
||||||
+ if (event.isCancelled() || n != orig) {
|
+ if (event.isCancelled() || n != orig) {
|
||||||
+ return;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) {
|
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) {
|
||||||
this.passengers.add(0, entity);
|
this.passengers.add(0, entity);
|
||||||
} else {
|
} else {
|
||||||
@@ -1697,13 +1983,30 @@
|
@@ -1695,15 +1981,33 @@
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
+ return true; // CraftBukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
- protected void removePassenger(Entity entity) {
|
- protected void removePassenger(Entity entity) {
|
||||||
|
@ -491,7 +505,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean q(Entity entity) {
|
protected boolean q(Entity entity) {
|
||||||
@@ -1800,6 +2103,13 @@
|
@@ -1800,6 +2104,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSwimming(boolean flag) {
|
public void setSwimming(boolean flag) {
|
||||||
|
@ -505,7 +519,7 @@
|
||||||
this.setFlag(4, flag);
|
this.setFlag(4, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1860,16 +2170,53 @@
|
@@ -1860,16 +2171,53 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAirTicks(int i) {
|
public void setAirTicks(int i) {
|
||||||
|
@ -562,7 +576,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void j(boolean flag) {
|
public void j(boolean flag) {
|
||||||
@@ -2036,19 +2383,72 @@
|
@@ -2036,19 +2384,72 @@
|
||||||
if (!this.world.isClientSide && !this.dead) {
|
if (!this.world.isClientSide && !this.dead) {
|
||||||
this.world.methodProfiler.a("changeDimension");
|
this.world.methodProfiler.a("changeDimension");
|
||||||
MinecraftServer minecraftserver = this.bK();
|
MinecraftServer minecraftserver = this.bK();
|
||||||
|
@ -638,7 +652,7 @@
|
||||||
BlockPosition blockposition;
|
BlockPosition blockposition;
|
||||||
|
|
||||||
if (dimensionmanager == DimensionManager.THE_END) {
|
if (dimensionmanager == DimensionManager.THE_END) {
|
||||||
@@ -2077,12 +2477,18 @@
|
@@ -2077,12 +2478,18 @@
|
||||||
blockposition = new BlockPosition(this);
|
blockposition = new BlockPosition(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,7 +672,7 @@
|
||||||
if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) {
|
if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) {
|
||||||
BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
|
BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
|
||||||
|
|
||||||
@@ -2090,6 +2496,7 @@
|
@@ -2090,6 +2497,7 @@
|
||||||
} else {
|
} else {
|
||||||
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
|
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
|
||||||
}
|
}
|
||||||
|
@ -666,7 +680,7 @@
|
||||||
|
|
||||||
boolean flag = entity.attachedToPlayer;
|
boolean flag = entity.attachedToPlayer;
|
||||||
|
|
||||||
@@ -2097,13 +2504,21 @@
|
@@ -2097,13 +2505,21 @@
|
||||||
worldserver1.addEntity(entity);
|
worldserver1.addEntity(entity);
|
||||||
entity.attachedToPlayer = flag;
|
entity.attachedToPlayer = flag;
|
||||||
worldserver1.entityJoinedWorld(entity, false);
|
worldserver1.entityJoinedWorld(entity, false);
|
||||||
|
@ -689,7 +703,7 @@
|
||||||
return entity;
|
return entity;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -2243,7 +2658,26 @@
|
@@ -2243,7 +2659,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(AxisAlignedBB axisalignedbb) {
|
public void a(AxisAlignedBB axisalignedbb) {
|
||||||
|
|
Loading…
Reference in a new issue