Commits
md_5 authored 24c5e68c5fe
41 41 | + } |
42 42 | + |
43 43 | + public void setMaxStackSize(int size) { |
44 44 | + maxStack = size; |
45 45 | + } |
46 46 | + // CraftBukkit end |
47 47 | + |
48 48 | public TileEntityFurnace() { |
49 49 | super(TileEntityTypes.FURNACE); |
50 50 | this.items = NonNullList.a(3, ItemStack.a); |
51 - | |
52 - | } |
53 - | |
54 - | public void tick() { |
55 - | - boolean flag = this.isBurning(); |
56 - | + boolean flag = this.getBlock().get(BlockFurnace.LIT); // CraftBukkit - SPIGOT-844 - Check if furnace block is lit using the block instead of burn time |
57 - | boolean flag1 = false; |
58 - | |
59 - | if (this.isBurning()) { |
60 51 | |
61 52 | IRecipe irecipe = this.world.getCraftingManager().b(this, this.world); |
62 53 | |
63 54 | if (!this.isBurning() && this.canBurn(irecipe)) { |
64 55 | - this.burnTime = fuelTime(itemstack); |
65 56 | + // CraftBukkit start |
66 57 | + CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack); |
67 58 | + |
68 59 | + FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(this.world, this.position), fuel, fuelTime(itemstack)); |
69 60 | + this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent); |
73 64 | + } |
74 65 | + |
75 66 | + this.burnTime = furnaceBurnEvent.getBurnTime(); |
76 67 | this.ticksForCurrentFuel = this.burnTime; |
77 68 | - if (this.isBurning()) { |
78 69 | + if (this.isBurning() && furnaceBurnEvent.isBurning()) { |
79 70 | + // CraftBukkit end |
80 71 | flag1 = true; |
81 72 | if (!itemstack.isEmpty()) { |
82 73 | Item item = itemstack.getItem(); |
83 - | |
84 - | if (flag != this.isBurning()) { |
85 - | flag1 = true; |
86 - | this.world.setTypeAndData(this.position, (IBlockData) this.world.getType(this.position).set(BlockFurnace.LIT, this.isBurning()), 3); |
87 - | + this.invalidateBlockCache(); // CraftBukkit - Invalidate tile entity's cached block type |
88 - | } |
89 - | } |
90 - | |
91 - | |
74 + | |
92 75 | } |
93 76 | |
94 77 | private int s() { |
95 78 | - FurnaceRecipe furnacerecipe = (FurnaceRecipe) this.world.getCraftingManager().b(this, this.world); |
96 79 | + FurnaceRecipe furnacerecipe = (this.hasWorld()) ? (FurnaceRecipe) this.world.getCraftingManager().b(this, this.world) : null; // CraftBukkit - SPIGOT-4302 |
97 80 | |
98 81 | return furnacerecipe != null ? furnacerecipe.h() : 200; |
99 82 | } |
100 - | |
83 + | |
101 84 | ItemStack itemstack1 = irecipe.d(); |
102 85 | ItemStack itemstack2 = (ItemStack) this.items.get(2); |
103 86 | |
104 87 | + // CraftBukkit start - fire FurnaceSmeltEvent |
105 88 | + CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); |
106 89 | + org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); |
107 90 | + |
108 91 | + FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), source, result); |
109 92 | + this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent); |
110 93 | + |