SPIGOT-7613: Don't respect mobGriefing gamerule in World#createExplosion() without source entity

By: 2008Choco <hawkeboyz2@hotmail.com>
This commit is contained in:
CraftBukkit/Spigot
2024-04-17 19:13:29 +10:00
parent f127f9030d
commit e6730f6daf
2 changed files with 34 additions and 4 deletions

View File

@@ -703,7 +703,16 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) {
return !world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? net.minecraft.world.level.World.a.MOB : net.minecraft.world.level.World.a.NONE).wasCanceled;
net.minecraft.world.level.World.a explosionType;
if (!breakBlocks) {
explosionType = net.minecraft.world.level.World.a.NONE; // Don't break blocks
} else if (source == null) {
explosionType = net.minecraft.world.level.World.a.STANDARD; // Break blocks, don't decay drops
} else {
explosionType = net.minecraft.world.level.World.a.MOB; // Respect mobGriefing gamerule
}
return !world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, explosionType).wasCanceled;
}
@Override