Fix EntityCombustEvent cancellation cant fully prevent entities from being set on fire

This commit is contained in:
Denery 2022-10-31 14:20:52 +03:00
parent 7c7eff2c01
commit 5ca5bc3d6c
2 changed files with 58 additions and 54 deletions

View File

@ -536,13 +536,10 @@
}
public boolean isFree(double offsetX, double offsetY, double offsetZ) {
@@ -747,8 +1052,30 @@
@@ -750,6 +1055,28 @@
}
}
if (movement.y != vec3d1.y) {
block.updateEntityMovementAfterFallOn(this.level(), this);
+ }
+ }
+
+ // CraftBukkit start
+ if (this.horizontalCollision && this.getBukkitEntity() instanceof Vehicle) {
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
@ -561,23 +558,22 @@
+ if (!bl.getType().isAir()) {
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
}
}
+ }
+ }
+ // CraftBukkit end
+
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
Entity.MovementEmission entity_movementemission = this.getMovementEmission();
@@ -1131,8 +1458,22 @@
protected SoundEvent getSwimHighSpeedSplashSound() {
@@ -1133,6 +1460,20 @@
return SoundEvents.GENERIC_SPLASH;
+ }
+
}
+ // CraftBukkit start - Add delegate methods
+ public SoundEvent getSwimSound0() {
+ return this.getSwimSound();
}
+ }
+
+ public SoundEvent getSwimSplashSound0() {
+ return this.getSwimSplashSound();
+ }
@ -657,7 +653,7 @@
this.hasImpulse = true;
}
@@ -1858,9 +2224,21 @@
@@ -1858,8 +2224,20 @@
}
public boolean isPushable() {
@ -669,16 +665,15 @@
+ // Paper end - Climbing should not bypass cramming gamerule
return false;
}
+
+ // CraftBukkit start - collidable API
+ public boolean canCollideWithBukkit(Entity entity) {
+ return this.isPushable();
+ }
+ // CraftBukkit end
+
public void awardKillScore(Entity entityKilled, DamageSource damageSource) {
if (entityKilled instanceof ServerPlayer) {
CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer) entityKilled, this, damageSource);
@@ -1889,74 +2267,133 @@
}
@ -1285,7 +1280,7 @@
}
public int getTicksFrozen() {
@@ -2679,11 +3339,40 @@
@@ -2679,11 +3339,44 @@
public void thunderHit(ServerLevel world, LightningBolt lightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@ -1302,6 +1297,10 @@
+ pluginManager.callEvent(entityCombustEvent);
+ if (!entityCombustEvent.isCancelled()) {
+ this.igniteForSeconds(entityCombustEvent.getDuration(), false);
+ // Paper start - fix EntityCombustEvent cancellation
+ } else {
+ this.setRemainingFireTicks(this.remainingFireTicks - 1);
+ // Paper end - fix EntityCombustEvent cancellation
+ }
+ // CraftBukkit end
}
@ -1328,7 +1327,7 @@
}
public void onAboveBubbleCol(boolean drag) {
@@ -2713,7 +3402,7 @@
@@ -2713,7 +3406,7 @@
this.resetFallDistance();
}
@ -1337,7 +1336,7 @@
return true;
}
@@ -2818,7 +3507,7 @@
@@ -2818,7 +3511,7 @@
public String toString() {
String s = this.level() == null ? "~NULL~" : this.level().toString();
@ -1346,7 +1345,7 @@
}
public final boolean isInvulnerableToBase(DamageSource damageSource) {
@@ -2838,6 +3527,13 @@
@@ -2838,6 +3531,13 @@
}
public void restoreFrom(Entity original) {
@ -1360,7 +1359,7 @@
CompoundTag nbttagcompound = original.saveWithoutId(new CompoundTag());
nbttagcompound.remove("Dimension");
@@ -2850,8 +3546,57 @@
@@ -2850,8 +3550,57 @@
public Entity teleport(TeleportTransition teleportTarget) {
Level world = this.level();
@ -1418,7 +1417,7 @@
ServerLevel worldserver1 = teleportTarget.newLevel();
boolean flag = worldserver1.dimension() != worldserver.dimension();
@@ -2918,10 +3663,19 @@
@@ -2918,10 +3667,19 @@
gameprofilerfiller.pop();
return null;
} else {
@ -1439,7 +1438,7 @@
Iterator iterator1 = list1.iterator();
while (iterator1.hasNext()) {
@@ -2947,7 +3701,7 @@
@@ -2947,7 +3705,7 @@
}
private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) {
@ -1448,7 +1447,7 @@
Iterator iterator = this.getIndirectPassengers().iterator();
while (iterator.hasNext()) {
@@ -2995,9 +3749,17 @@
@@ -2995,22 +3753,45 @@
}
protected void removeAfterChangingDimensions() {
@ -1469,10 +1468,11 @@
}
}
@@ -3006,11 +3768,26 @@
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
}
public Vec3 getRelativePortalPosition(Direction.Axis portalAxis, BlockUtil.FoundRectangle portalRect) {
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
+ }
+
+ // CraftBukkit start
+ public CraftPortalEvent callPortalEvent(Entity entity, Location exit, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
@ -1484,9 +1484,9 @@
+ return null;
+ }
+ return new CraftPortalEvent(event);
+ }
}
+ // CraftBukkit end
+
public boolean canUsePortal(boolean allowVehicles) {
return (allowVehicles || !this.isPassenger()) && this.isAlive();
}
@ -1496,7 +1496,7 @@
if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) {
Iterator iterator = this.getPassengers().iterator();
@@ -3134,10 +3911,16 @@
@@ -3134,10 +3915,16 @@
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
}
@ -1516,7 +1516,7 @@
return entity != null;
}
@@ -3187,7 +3970,7 @@
@@ -3187,7 +3974,7 @@
/** @deprecated */
@Deprecated
protected void fixupDimensions() {
@ -1525,7 +1525,7 @@
EntityDimensions entitysize = this.getDimensions(entitypose);
this.dimensions = entitysize;
@@ -3196,7 +3979,7 @@
@@ -3196,7 +3983,7 @@
public void refreshDimensions() {
EntityDimensions entitysize = this.dimensions;
@ -1534,7 +1534,7 @@
EntityDimensions entitysize1 = this.getDimensions(entitypose);
this.dimensions = entitysize1;
@@ -3258,10 +4041,29 @@
@@ -3258,10 +4045,29 @@
}
public final void setBoundingBox(AABB boundingBox) {
@ -1566,7 +1566,7 @@
return this.getDimensions(pose).eyeHeight();
}
@@ -3335,7 +4137,7 @@
@@ -3335,7 +4141,7 @@
}
@Nullable
@ -1575,7 +1575,7 @@
return null;
}
@@ -3373,20 +4175,34 @@
@@ -3373,20 +4179,34 @@
}
private Stream<Entity> getIndirectPassengersStream() {
@ -1610,7 +1610,7 @@
return () -> {
return this.getIndirectPassengersStream().iterator();
};
@@ -3399,6 +4215,7 @@
@@ -3399,6 +4219,7 @@
}
public boolean hasExactlyOnePlayerPassenger() {
@ -1618,7 +1618,7 @@
return this.countPlayerPassengers() == 1;
}
@@ -3435,7 +4252,7 @@
@@ -3435,7 +4256,7 @@
}
public boolean isControlledByLocalInstance() {
@ -1627,7 +1627,7 @@
if (entityliving instanceof Player entityhuman) {
return entityhuman.isLocalPlayer();
@@ -3445,7 +4262,7 @@
@@ -3445,7 +4266,7 @@
}
public boolean isControlledByClient() {
@ -1636,7 +1636,7 @@
return entityliving != null && entityliving.isControlledByClient();
}
@@ -3463,7 +4280,7 @@
@@ -3463,7 +4284,7 @@
return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3);
}
@ -1645,7 +1645,7 @@
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
}
@@ -3489,8 +4306,37 @@
@@ -3489,8 +4310,37 @@
return 1;
}
@ -1684,7 +1684,7 @@
}
public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) {
@@ -3550,7 +4396,12 @@
@@ -3550,7 +4400,12 @@
vec3d = vec3d.add(vec3d1);
++k1;
@ -1697,7 +1697,7 @@
}
}
}
@@ -3613,7 +4464,7 @@
@@ -3613,7 +4468,7 @@
return new ClientboundAddEntityPacket(this, entityTrackerEntry);
}
@ -1706,7 +1706,7 @@
return this.type.getDimensions();
}
@@ -3714,7 +4565,39 @@
@@ -3714,7 +4569,39 @@
return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale);
}
@ -1746,7 +1746,7 @@
if (this.position.x != x || this.position.y != y || this.position.z != z) {
this.position = new Vec3(x, y, z);
int i = Mth.floor(x);
@@ -3732,6 +4615,12 @@
@@ -3732,6 +4619,12 @@
this.levelCallback.onMove();
}
@ -1759,7 +1759,7 @@
}
public void checkDespawn() {}
@@ -3818,8 +4707,16 @@
@@ -3818,8 +4711,16 @@
@Override
public final void setRemoved(Entity.RemovalReason reason) {
@ -1777,7 +1777,7 @@
}
if (this.removalReason.shouldDestroy()) {
@@ -3827,8 +4724,8 @@
@@ -3827,8 +4728,8 @@
}
this.getPassengers().forEach(Entity::stopRiding);
@ -1788,7 +1788,7 @@
}
public void unsetRemoved() {
@@ -3887,7 +4784,7 @@
@@ -3887,7 +4788,7 @@
}
public Vec3 getKnownMovement() {
@ -1797,7 +1797,7 @@
if (entityliving instanceof Player entityhuman) {
if (this.isAlive()) {
@@ -3962,4 +4859,14 @@
@@ -3962,4 +4863,14 @@
void accept(Entity entity, double x, double y, double z);
}

View File

@ -16,7 +16,7 @@
if (!entity.fireImmune()) {
if (entity.getRemainingFireTicks() < 0) {
entity.setRemainingFireTicks(entity.getRemainingFireTicks() + 1);
@@ -137,7 +139,14 @@
@@ -137,7 +139,18 @@
}
if (entity.getRemainingFireTicks() >= 0) {
@ -27,12 +27,16 @@
+
+ if (!event.isCancelled()) {
+ entity.igniteForSeconds(event.getDuration(), false);
+ // Paper start - fix EntityCombustEvent cancellation
+ } else {
+ entity.setRemainingFireTicks(entity.getRemainingFireTicks() - 1);
+ // Paper end - fix EntityCombustEvent cancellation
+ }
+ // CraftBukkit end
}
}
@@ -146,26 +155,26 @@
@@ -146,26 +159,26 @@
}
@Override
@ -66,7 +70,7 @@
}
@Override
@@ -213,4 +222,12 @@
@@ -213,4 +226,12 @@
}
}
}