craftbukkit/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch

73 lines
3.1 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/level/block/BlockFireAbstract.java
+++ b/net/minecraft/world/level/block/BlockFireAbstract.java
2025-03-26 03:05:00 +11:00
@@ -22,6 +22,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;
2025-03-26 03:05:00 +11:00
@@ -147,33 +151,40 @@
2024-10-23 02:15:00 +11:00
}
if (entity.getRemainingFireTicks() >= 0) {
2024-06-14 01:05:00 +10:00
- entity.igniteForSeconds(8.0F);
2020-06-25 10:00:00 +10:00
+ // CraftBukkit start
2025-03-26 03:05:00 +11:00
+ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(entity.getBukkitEntity().getLocation().getBlock(), entity.getBukkitEntity(), 8.0F); // PAIL - TODO
+ entity.level().getCraftServer().getPluginManager().callEvent(event);
2020-06-25 10:00:00 +10:00
+
+ if (!event.isCancelled()) {
2024-04-24 01:15:00 +10:00
+ entity.igniteForSeconds(event.getDuration(), false);
2020-06-25 10:00:00 +10:00
+ }
+ // CraftBukkit end
}
2022-06-08 02:00:00 +10:00
}
2020-06-25 10:00:00 +10:00
}
@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()) {
2024-10-23 02:15:00 +11:00
- ((BlockPortalShape) optional.get()).createPortalBlocks(world);
+ ((BlockPortalShape) optional.get()).createPortalBlocks(world, (context == null) ? null : context.getPlayer()); // CraftBukkit - player
return;
}
2020-08-12 07:00:00 +10:00
}
2020-06-25 10:00:00 +10:00
2021-11-22 09:00:00 +11:00
if (!iblockdata.canSurvive(world, blockposition)) {
- world.removeBlock(blockposition, false);
2020-08-12 07:00:00 +10:00
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
2020-06-25 10:00:00 +10:00
}
2020-08-12 07:00:00 +10:00
}
}
2021-11-22 09:00:00 +11:00
private static boolean inPortalDimension(World world) {
- return world.dimension() == World.OVERWORLD || world.dimension() == World.NETHER;
2021-11-23 18:39:43 +11:00
+ return world.getTypeKey() == net.minecraft.world.level.dimension.WorldDimension.OVERWORLD || world.getTypeKey() == net.minecraft.world.level.dimension.WorldDimension.NETHER; // CraftBukkit - getTypeKey()
2020-08-12 07:00:00 +10:00
}
@Override
2025-03-26 03:05:00 +11:00
@@ -217,4 +228,12 @@
2021-01-16 12:00:00 +11:00
}
2020-08-12 07:00:00 +10:00
}
2020-06-25 10:00:00 +10:00
}
+
+ // CraftBukkit start
2021-11-22 09:00:00 +11:00
+ 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);
2020-06-25 10:00:00 +10:00
+ }
+ }
+ // CraftBukkit end
}