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

52 lines
2.8 KiB
Diff

--- a/net/minecraft/world/level/block/entity/TileEntityCampfire.java
+++ b/net/minecraft/world/level/block/entity/TileEntityCampfire.java
@@ -31,6 +31,14 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockCookEvent;
+import org.bukkit.event.block.CampfireStartEvent;
+import org.bukkit.inventory.CampfireRecipe;
+// CraftBukkit end
+
public class TileEntityCampfire extends TileEntity implements Clearable {
private static final int BURN_COOL_SPEED = 2;
@@ -63,6 +71,20 @@
}).orElse(itemstack);
if (itemstack1.isItemEnabled(worldserver.enabledFeatures())) {
+ // CraftBukkit start - fire BlockCookEvent
+ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
+
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(worldserver, blockposition), source, result);
+ worldserver.getCraftServer().getPluginManager().callEvent(blockCookEvent);
+
+ if (blockCookEvent.isCancelled()) {
+ return;
+ }
+
+ result = blockCookEvent.getResult();
+ itemstack1 = CraftItemStack.asNMSCopy(result);
+ // CraftBukkit end
InventoryUtils.dropItemStack(worldserver, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
tileentitycampfire.items.set(i, ItemStack.EMPTY);
worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
@@ -177,7 +199,11 @@
return false;
}
- this.cookingTime[i] = ((RecipeCampfire) ((RecipeHolder) optional.get()).value()).cookingTime();
+ // CraftBukkit start
+ CampfireStartEvent event = new CampfireStartEvent(CraftBlock.at(this.level,this.worldPosition), CraftItemStack.asCraftMirror(itemstack), (CampfireRecipe) optional.get().toBukkitRecipe());
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.cookingTime[i] = event.getTotalCookTime(); // i -> event.getTotalCookTime()
+ // CraftBukkit end
this.cookingProgress[i] = 0;
this.items.set(i, itemstack.consumeAndReturn(1, entityliving));
worldserver.gameEvent((Holder) GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entityliving, this.getBlockState()));