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