SPIGOT-5830: Server crash when campfire lit via dispenser.

Also adds a missing call to BlockIgniteEvent for players igniting campfires with flint and steel.
This commit is contained in:
Parker Hawke 2020-06-25 19:01:18 -04:00 committed by md_5
parent 4b67fed7f6
commit 6abb4398b9
No known key found for this signature in database
GPG key ID: E8E901AC7C617C11
3 changed files with 19 additions and 1 deletions

View file

@ -5,7 +5,7 @@
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, entity).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, iprojectile).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end

View file

@ -1,5 +1,14 @@
--- a/net/minecraft/server/ItemFlintAndSteel.java
+++ b/net/minecraft/server/ItemFlintAndSteel.java
@@ -13,7 +13,7 @@
BlockPosition blockposition = itemactioncontext.getClickPosition();
IBlockData iblockdata = world.getType(blockposition);
- if (BlockCampfire.h(iblockdata)) {
+ if (BlockCampfire.h(iblockdata) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, entityhuman).isCancelled()) { // CraftBukkit
world.playSound(entityhuman, blockposition, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.RANDOM.nextFloat() * 0.4F + 0.8F);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true), 11);
if (entityhuman != null) {
@@ -27,6 +27,14 @@
BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace());

View file

@ -50,6 +50,7 @@ import net.minecraft.server.GeneratorAccess;
import net.minecraft.server.IBlockData;
import net.minecraft.server.IChatBaseComponent;
import net.minecraft.server.IInventory;
import net.minecraft.server.IProjectile;
import net.minecraft.server.ItemActionContext;
import net.minecraft.server.ItemStack;
import net.minecraft.server.Items;
@ -208,6 +209,7 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.projectiles.ProjectileSource;
public class CraftEventFactory {
public static final DamageSource MELTING = CraftDamageSource.copyOf(DamageSource.BURN);
@ -1213,6 +1215,13 @@ public class CraftEventFactory {
cause = IgniteCause.FLINT_AND_STEEL;
}
if (igniter instanceof IProjectile) {
Entity shooter = ((IProjectile) igniter).getShooter();
if (shooter != null) {
bukkitIgniter = shooter.getBukkitEntity();
}
}
BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), cause, bukkitIgniter);
world.getServer().getPluginManager().callEvent(event);
return event;