mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 07:48:53 +01:00
SPIGOT-4370: Remove vehicle if its passenger spawn event was cancelled
This commit is contained in:
parent
1cead6280f
commit
bf1c82731c
1 changed files with 29 additions and 40 deletions
|
@ -296,7 +296,7 @@
|
|||
if (k(blockposition)) {
|
||||
return Blocks.VOID_AIR.getBlockData();
|
||||
} else {
|
||||
@@ -649,6 +854,42 @@
|
||||
@@ -649,6 +854,49 @@
|
||||
}
|
||||
|
||||
public boolean addEntity(Entity entity) {
|
||||
|
@ -331,6 +331,13 @@
|
|||
+ }
|
||||
+
|
||||
+ if (event != null && (event.isCancelled() || entity.dead)) {
|
||||
+ Entity vehicle = entity.getVehicle();
|
||||
+ if (vehicle != null) {
|
||||
+ vehicle.dead = true;
|
||||
+ }
|
||||
+ for (Entity passenger : entity.bQ()) {
|
||||
+ passenger.dead = true;
|
||||
+ }
|
||||
+ entity.dead = true;
|
||||
+ return false;
|
||||
+ }
|
||||
|
@ -339,7 +346,7 @@
|
|||
int i = MathHelper.floor(entity.locX / 16.0D);
|
||||
int j = MathHelper.floor(entity.locZ / 16.0D);
|
||||
boolean flag = entity.attachedToPlayer;
|
||||
@@ -679,6 +920,7 @@
|
||||
@@ -679,6 +927,7 @@
|
||||
((IWorldAccess) this.v.get(i)).a(entity);
|
||||
}
|
||||
|
||||
|
@ -347,7 +354,7 @@
|
|||
}
|
||||
|
||||
protected void c(Entity entity) {
|
||||
@@ -686,6 +928,7 @@
|
||||
@@ -686,6 +935,7 @@
|
||||
((IWorldAccess) this.v.get(i)).b(entity);
|
||||
}
|
||||
|
||||
|
@ -355,7 +362,7 @@
|
|||
}
|
||||
|
||||
public void kill(Entity entity) {
|
||||
@@ -721,7 +964,15 @@
|
||||
@@ -721,7 +971,15 @@
|
||||
this.getChunkAt(i, j).b(entity);
|
||||
}
|
||||
|
||||
|
@ -372,7 +379,7 @@
|
|||
this.c(entity);
|
||||
}
|
||||
|
||||
@@ -756,6 +1007,11 @@
|
||||
@@ -756,6 +1014,11 @@
|
||||
|
||||
for (i = 0; i < this.k.size(); ++i) {
|
||||
entity = (Entity) this.k.get(i);
|
||||
|
@ -384,7 +391,7 @@
|
|||
|
||||
try {
|
||||
++entity.ticksLived;
|
||||
@@ -804,8 +1060,10 @@
|
||||
@@ -804,8 +1067,10 @@
|
||||
CrashReportSystemDetails crashreportsystemdetails1;
|
||||
CrashReport crashreport1;
|
||||
|
||||
|
@ -397,7 +404,7 @@
|
|||
Entity entity1 = entity.getVehicle();
|
||||
|
||||
if (entity1 != null) {
|
||||
@@ -838,7 +1096,7 @@
|
||||
@@ -838,7 +1103,7 @@
|
||||
this.getChunkAt(j, l).b(entity);
|
||||
}
|
||||
|
||||
|
@ -406,7 +413,7 @@
|
|||
this.c(entity);
|
||||
}
|
||||
|
||||
@@ -893,9 +1151,11 @@
|
||||
@@ -893,9 +1158,11 @@
|
||||
TileEntity tileentity1 = (TileEntity) this.c.get(i1);
|
||||
|
||||
if (!tileentity1.x()) {
|
||||
|
@ -418,7 +425,7 @@
|
|||
|
||||
if (this.isLoaded(tileentity1.getPosition())) {
|
||||
Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
|
||||
@@ -903,6 +1163,12 @@
|
||||
@@ -903,6 +1170,12 @@
|
||||
|
||||
chunk.a(tileentity1.getPosition(), tileentity1);
|
||||
this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
|
||||
|
@ -431,7 +438,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -956,15 +1222,13 @@
|
||||
@@ -956,15 +1229,13 @@
|
||||
int i;
|
||||
int j;
|
||||
|
||||
|
@ -453,7 +460,7 @@
|
|||
|
||||
entity.N = entity.locX;
|
||||
entity.O = entity.locY;
|
||||
@@ -980,6 +1244,7 @@
|
||||
@@ -980,6 +1251,7 @@
|
||||
return IRegistry.ENTITY_TYPE.getKey(entity.P()).toString();
|
||||
});
|
||||
entity.tick();
|
||||
|
@ -461,7 +468,7 @@
|
|||
this.methodProfiler.e();
|
||||
}
|
||||
}
|
||||
@@ -1310,11 +1575,18 @@
|
||||
@@ -1310,11 +1582,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -480,7 +487,7 @@
|
|||
TileEntity tileentity = null;
|
||||
|
||||
if (this.J) {
|
||||
@@ -1349,6 +1621,14 @@
|
||||
@@ -1349,6 +1628,14 @@
|
||||
public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
|
||||
if (!k(blockposition)) {
|
||||
if (tileentity != null && !tileentity.x()) {
|
||||
|
@ -495,7 +502,7 @@
|
|||
if (this.J) {
|
||||
tileentity.setPosition(blockposition);
|
||||
Iterator iterator = this.c.iterator();
|
||||
@@ -1509,6 +1789,14 @@
|
||||
@@ -1509,6 +1796,14 @@
|
||||
}
|
||||
|
||||
this.p = MathHelper.a(this.p, 0.0F, 1.0F);
|
||||
|
@ -510,7 +517,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -1594,7 +1882,10 @@
|
||||
@@ -1594,7 +1889,10 @@
|
||||
}
|
||||
|
||||
public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
|
||||
|
@ -522,7 +529,7 @@
|
|||
return false;
|
||||
} else {
|
||||
int i = 0;
|
||||
@@ -1737,7 +2028,7 @@
|
||||
@@ -1737,7 +2035,7 @@
|
||||
}
|
||||
|
||||
public Stream<VoxelShape> a(@Nullable Entity entity, VoxelShape voxelshape, VoxelShape voxelshape1, Set<Entity> set) {
|
||||
|
@ -531,7 +538,7 @@
|
|||
|
||||
return entity == null ? stream : Stream.concat(stream, this.a(entity, voxelshape, set));
|
||||
}
|
||||
@@ -1767,7 +2058,7 @@
|
||||
@@ -1767,7 +2065,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
|
@ -540,7 +547,7 @@
|
|||
arraylist.add(entity);
|
||||
}
|
||||
}
|
||||
@@ -1782,7 +2073,7 @@
|
||||
@@ -1782,7 +2080,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
|
@ -549,7 +556,7 @@
|
|||
arraylist.add(entity);
|
||||
}
|
||||
}
|
||||
@@ -1831,7 +2122,7 @@
|
||||
@@ -1831,7 +2129,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -558,25 +565,7 @@
|
|||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1852,8 +2143,16 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
+ // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs
|
||||
+ if (entity instanceof EntityInsentient) {
|
||||
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
|
||||
+ if (entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- if (!(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) {
|
||||
+ if (true || !(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) {
|
||||
+ // CraftBukkit end
|
||||
if (oclass.isAssignableFrom(entity.getClass())) {
|
||||
++j;
|
||||
}
|
||||
@@ -1972,6 +2271,11 @@
|
||||
@@ -1972,6 +2270,11 @@
|
||||
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
|
||||
|
@ -588,7 +577,7 @@
|
|||
|
||||
if (predicate.test(entityhuman1)) {
|
||||
double d5 = entityhuman1.d(d0, d1, d2);
|
||||
@@ -2164,6 +2468,16 @@
|
||||
@@ -2164,6 +2467,16 @@
|
||||
|
||||
public void everyoneSleeping() {}
|
||||
|
||||
|
@ -605,7 +594,7 @@
|
|||
public float g(float f) {
|
||||
return (this.q + (this.r - this.q) * f) * this.i(f);
|
||||
}
|
||||
@@ -2325,7 +2639,7 @@
|
||||
@@ -2325,7 +2638,7 @@
|
||||
int l = j * 16 + 8 - blockposition.getZ();
|
||||
boolean flag = true;
|
||||
|
||||
|
|
Loading…
Reference in a new issue