summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorEvilSeph <evilseph@unaligned.org>2011-06-19 21:47:17 -0400
committerEvilSeph <evilseph@unaligned.org>2011-06-20 00:15:32 -0400
commit918f488d233bc602b97eb51bd5f59a9c91c4624b (patch)
tree33ab832862810e8c0b1a85a0d91bd7fe190f0156 /src/main/java
parent6cf0fc4a7bfbb78f87a596404b269b92dca5af6b (diff)
downloadcraftbukkit-918f488d233bc602b97eb51bd5f59a9c91c4624b.tar
craftbukkit-918f488d233bc602b97eb51bd5f59a9c91c4624b.tar.gz
craftbukkit-918f488d233bc602b97eb51bd5f59a9c91c4624b.tar.lz
craftbukkit-918f488d233bc602b97eb51bd5f59a9c91c4624b.tar.xz
craftbukkit-918f488d233bc602b97eb51bd5f59a9c91c4624b.zip
Added Furnace smelt and burn events.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/net/minecraft/server/TileEntityFurnace.java40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
index 65d23e58..63d1f76a 100644
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
+++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java
@@ -1,5 +1,13 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.inventory.FurnaceBurnEvent;
+import org.bukkit.event.inventory.FurnaceSmeltEvent;
+// CraftBukkit end
+
public class TileEntityFurnace extends TileEntity implements IInventory {
private ItemStack[] items = new ItemStack[3];
@@ -119,7 +127,18 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
if (!this.world.isStatic) {
// CraftBukkit start -- handle multiple elapsed ticks
- if (this.burnTime <= 0 && this.h()) { // CraftBukkit == to <=
+ if (this.burnTime <= 0 && this.h() && this.items[1] != null) { // CraftBukkit == to <=
+ CraftServer cserver = this.world.getServer();
+ CraftWorld cworld = this.world.getWorld();
+ CraftItemStack fuel = new CraftItemStack(this.items[1]);
+
+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(cworld.getBlockAt(this.e, this.f, this.g), fuel, this.a(this.items[1]));
+ cserver.getPluginManager().callEvent(furnaceBurnEvent);
+
+ if (furnaceBurnEvent.isCancelled()) {
+ return;
+ }
+
this.b = this.a(this.items[1]);
this.burnTime += this.b;
// CraftBukkit end
@@ -173,8 +192,25 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
if (this.h()) {
ItemStack itemstack = FurnaceRecipes.a().a(this.items[0].getItem().id);
+ // CraftBukkit start
+ CraftServer cserver = this.world.getServer();
+ CraftWorld cworld = this.world.getWorld();
+ CraftItemStack source = new CraftItemStack(this.items[0]);
+ CraftItemStack result = new CraftItemStack(itemstack.j());
+
+ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(cworld.getBlockAt(this.e, this.f, this.g), source, result);
+ cserver.getPluginManager().callEvent(furnaceSmeltEvent);
+
+ if (furnaceSmeltEvent.isCancelled()) {
+ return;
+ }
+
+ org.bukkit.inventory.ItemStack oldResult = furnaceSmeltEvent.getResult();
+ ItemStack newResult = new ItemStack(oldResult.getTypeId(), oldResult.getAmount(), oldResult.getDurability());
+ itemstack = newResult;
+ // CraftBukkit end
if (this.items[2] == null) {
- this.items[2] = itemstack.j();
+ this.items[2] = itemstack;
} else if (this.items[2].id == itemstack.id) {
// CraftBukkit start - compare damage too
if (this.items[2].damage == itemstack.damage) {