mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 11:25:55 +03:00
190 lines
7.7 KiB
Diff
190 lines
7.7 KiB
Diff
--- ../src-base/minecraft/net/minecraft/tileentity/TileEntityFurnace.java
|
|
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityFurnace.java
|
|
@@ -23,6 +23,7 @@
|
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.nbt.NBTTagList;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.util.EnumFacing;
|
|
import net.minecraft.util.ITickable;
|
|
import net.minecraft.util.datafix.DataFixer;
|
|
@@ -31,9 +32,48 @@
|
|
import net.minecraft.util.math.MathHelper;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
+import luohuayu.CatServer.tileentity.CBTileEntityLockable;
|
|
+import java.util.List;
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
+import org.bukkit.entity.HumanEntity;
|
|
|
|
-public class TileEntityFurnace extends TileEntityLockable implements ITickable, ISidedInventory
|
|
+//CraftBukkit start
|
|
+import java.util.List;
|
|
+
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
+import org.bukkit.entity.HumanEntity;
|
|
+import org.bukkit.event.inventory.FurnaceBurnEvent;
|
|
+import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
+// CraftBukkit end
|
|
+
|
|
+public class TileEntityFurnace extends CBTileEntityLockable implements ITickable, ISidedInventory
|
|
{
|
|
+ // CraftBukkit start - add fields and methods
|
|
+ private int lastTick = MinecraftServer.currentTick;
|
|
+ private int maxStack = MAX_STACK;
|
|
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
+
|
|
+ public ItemStack[] getContents() {
|
|
+ return this.furnaceItemStacks;
|
|
+ }
|
|
+
|
|
+ public void onOpen(CraftHumanEntity who) {
|
|
+ transaction.add(who);
|
|
+ }
|
|
+
|
|
+ public void onClose(CraftHumanEntity who) {
|
|
+ transaction.remove(who);
|
|
+ }
|
|
+
|
|
+ public List<HumanEntity> getViewers() {
|
|
+ return transaction;
|
|
+ }
|
|
+
|
|
+ public void setMaxStackSize(int size) {
|
|
+ maxStack = size;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
private static final int[] SLOTS_TOP = new int[] {0};
|
|
private static final int[] SLOTS_BOTTOM = new int[] {2, 1};
|
|
private static final int[] SLOTS_SIDES = new int[] {1};
|
|
@@ -180,25 +220,53 @@
|
|
|
|
public void update()
|
|
{
|
|
- boolean flag = this.isBurning();
|
|
+ boolean flag = (this.getBlockType() == Blocks.LIT_FURNACE); // CraftBukkit - SPIGOT-844 - Check if furnace block is lit using the block instead of burn time
|
|
boolean flag1 = false;
|
|
|
|
+ // CraftBukkit start - Use wall time instead of ticks for cooking
|
|
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
|
+ this.lastTick = MinecraftServer.currentTick;
|
|
+
|
|
+ // CraftBukkit - moved from below - edited for wall time
|
|
+ if (this.isBurning() && this.canSmelt()) {
|
|
+ this.cookTime += elapsedTicks;
|
|
+ if (this.cookTime >= this.totalCookTime) {
|
|
+ this.cookTime = 0;
|
|
+ this.totalCookTime = this.getCookTime(this.furnaceItemStacks[0]);
|
|
+ this.smeltItem();
|
|
+ flag1 = true;
|
|
+ }
|
|
+ } else {
|
|
+ this.cookTime = 0;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
if (this.isBurning())
|
|
{
|
|
- --this.furnaceBurnTime;
|
|
+ this.furnaceBurnTime -= elapsedTicks; // CraftBukkit - use elapsedTicks in place of constant
|
|
}
|
|
|
|
if (!this.worldObj.isRemote)
|
|
{
|
|
if (this.isBurning() || this.furnaceItemStacks[1] != null && this.furnaceItemStacks[0] != null)
|
|
{
|
|
- if (!this.isBurning() && this.canSmelt())
|
|
+ // CraftBukkit start - Handle multiple elapsed ticks
|
|
+ if (this.furnaceBurnTime <= 0 && this.canSmelt()) // CraftBukkit - == to <=
|
|
{
|
|
- this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
|
|
- this.currentItemBurnTime = this.furnaceBurnTime;
|
|
+ CraftItemStack fuel = CraftItemStack.asCraftMirror(this.furnaceItemStacks[1]);
|
|
|
|
- if (this.isBurning())
|
|
- {
|
|
+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.worldObj.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), fuel, getItemBurnTime(this.furnaceItemStacks[1]));
|
|
+ this.worldObj.getServer().getPluginManager().callEvent(furnaceBurnEvent);
|
|
+
|
|
+ if (furnaceBurnEvent.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ this.currentItemBurnTime = furnaceBurnEvent.getBurnTime();
|
|
+ this.furnaceBurnTime += this.currentItemBurnTime;
|
|
+
|
|
+ if (this.furnaceBurnTime > 0 && furnaceBurnEvent.isBurning()) {
|
|
+ // CraftBukkit end
|
|
flag1 = true;
|
|
|
|
if (this.furnaceItemStacks[1] != null)
|
|
@@ -213,6 +281,7 @@
|
|
}
|
|
}
|
|
|
|
+ /* CraftBukkit start - Moved up
|
|
if (this.isBurning() && this.canSmelt())
|
|
{
|
|
++this.cookTime;
|
|
@@ -229,16 +298,19 @@
|
|
{
|
|
this.cookTime = 0;
|
|
}
|
|
+ */
|
|
}
|
|
else if (!this.isBurning() && this.cookTime > 0)
|
|
{
|
|
this.cookTime = MathHelper.clamp_int(this.cookTime - 2, 0, this.totalCookTime);
|
|
}
|
|
+
|
|
|
|
if (flag != this.isBurning())
|
|
{
|
|
flag1 = true;
|
|
BlockFurnace.setState(this.isBurning(), this.worldObj, this.pos);
|
|
+ this.updateContainingBlockInfo(); // CraftBukkit - Invalidate tile entity's cached block type
|
|
}
|
|
}
|
|
|
|
@@ -276,14 +348,33 @@
|
|
{
|
|
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]);
|
|
|
|
- if (this.furnaceItemStacks[2] == null)
|
|
- {
|
|
- this.furnaceItemStacks[2] = itemstack.copy();
|
|
+ // CraftBukkit start - fire FurnaceSmeltEvent
|
|
+ CraftItemStack source = CraftItemStack.asCraftMirror(this.furnaceItemStacks[0]);
|
|
+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack);
|
|
+
|
|
+ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.worldObj.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), source, result);
|
|
+ this.worldObj.getServer().getPluginManager().callEvent(furnaceSmeltEvent);
|
|
+
|
|
+ if (furnaceSmeltEvent.isCancelled()) {
|
|
+ return;
|
|
}
|
|
- else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem())
|
|
- {
|
|
- this.furnaceItemStacks[2].stackSize += itemstack.stackSize; // Forge BugFix: Results may have multiple items
|
|
+
|
|
+ result = furnaceSmeltEvent.getResult();
|
|
+ itemstack = CraftItemStack.asNMSCopy(result);
|
|
+
|
|
+ if (itemstack != null) {
|
|
+ if (this.furnaceItemStacks[2] == null)
|
|
+ {
|
|
+ this.furnaceItemStacks[2] = itemstack;
|
|
+ }
|
|
+ else if (CraftItemStack.asCraftMirror(this.furnaceItemStacks[2]).isSimilar(result))
|
|
+ {
|
|
+ this.furnaceItemStacks[2].stackSize += itemstack.stackSize; // Forge BugFix: Results may have multiple items
|
|
+ } else {
|
|
+ return;
|
|
+ }
|
|
}
|
|
+ // CraftBukkit end
|
|
|
|
if (this.furnaceItemStacks[0].getItem() == Item.getItemFromBlock(Blocks.SPONGE) && this.furnaceItemStacks[0].getMetadata() == 1 && this.furnaceItemStacks[1] != null && this.furnaceItemStacks[1].getItem() == Items.BUCKET)
|
|
{
|