0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-25 13:56:14 +00:00
craftbukkit/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch
2024-10-23 02:15:00 +11:00

74 lines
3.1 KiB
Diff

--- a/net/minecraft/world/level/block/BlockFireAbstract.java
+++ b/net/minecraft/world/level/block/BlockFireAbstract.java
@@ -20,6 +20,10 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+// CraftBukkit start
+import net.minecraft.world.item.context.ItemActionContext;
+// CraftBukkit end
+
public abstract class BlockFireAbstract extends Block {
private static final int SECONDS_ON_FIRE = 8;
@@ -137,7 +141,14 @@
}
if (entity.getRemainingFireTicks() >= 0) {
- entity.igniteForSeconds(8.0F);
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition), entity.getBukkitEntity(), 8.0F);
+ world.getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ entity.igniteForSeconds(event.getDuration(), false);
+ }
+ // CraftBukkit end
}
}
@@ -146,26 +157,26 @@
}
@Override
- protected void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {
+ protected void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag, ItemActionContext context) { // CraftBukkit - context
if (!iblockdata1.is(iblockdata.getBlock())) {
if (inPortalDimension(world)) {
Optional<BlockPortalShape> optional = BlockPortalShape.findEmptyPortalShape(world, blockposition, EnumDirection.EnumAxis.X);
if (optional.isPresent()) {
- ((BlockPortalShape) optional.get()).createPortalBlocks(world);
+ ((BlockPortalShape) optional.get()).createPortalBlocks(world, (context == null) ? null : context.getPlayer()); // CraftBukkit - player
return;
}
}
if (!iblockdata.canSurvive(world, blockposition)) {
- world.removeBlock(blockposition, false);
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
}
}
}
private static boolean inPortalDimension(World world) {
- return world.dimension() == World.OVERWORLD || world.dimension() == World.NETHER;
+ return world.getTypeKey() == net.minecraft.world.level.dimension.WorldDimension.OVERWORLD || world.getTypeKey() == net.minecraft.world.level.dimension.WorldDimension.NETHER; // CraftBukkit - getTypeKey()
}
@Override
@@ -213,4 +224,12 @@
}
}
}
+
+ // CraftBukkit start
+ protected void fireExtinguished(net.minecraft.world.level.GeneratorAccess world, BlockPosition position) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ world.removeBlock(position, false);
+ }
+ }
+ // CraftBukkit end
}