13
0
geforkt von Mirrors/Paper

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

Also adds a missing call to BlockIgniteEvent for players igniting campfires with flint and steel.

By: Parker Hawke <hawkeboyz2@hotmail.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2020-06-25 19:01:18 -04:00
Ursprung 61ff27fa00
Commit 6ccde4e6fd
3 geänderte Dateien mit 19 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,7 @@
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
+ // CraftBukkit start + // 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; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end

Datei anzeigen

@ -1,5 +1,14 @@
--- a/net/minecraft/server/ItemFlintAndSteel.java --- a/net/minecraft/server/ItemFlintAndSteel.java
+++ b/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 @@ @@ -27,6 +27,14 @@
BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace()); BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace());

Datei anzeigen

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