Created
January 29, 2014 04:45
-
-
Save anna-is-cute/8681976 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// h() is every tick | |
// Default Minecraft h() method | |
public void h() { | |
boolean flag = this.burnTime > 0; | |
boolean flag1 = false; | |
int elapsedTicks = MinecraftServer.currentTick - this.lastTick; | |
this.lastTick = MinecraftServer.currentTick; | |
if ((isBurning()) && (canBurn())) { | |
this.cookTime += elapsedTicks; | |
if (this.cookTime >= 200) { | |
this.cookTime %= 200; | |
burn(); | |
flag1 = true; | |
} | |
} else { | |
this.cookTime = 0; | |
} | |
if (this.burnTime > 0) { | |
this.burnTime -= elapsedTicks; | |
} | |
if (!this.world.isStatic) { | |
if ((this.burnTime <= 0) && (canBurn()) && (this.items[1] != null)) { | |
CraftItemStack fuel = CraftItemStack.asCraftMirror(this.items[1]); | |
FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), fuel, fuelTime(this.items[1])); | |
this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent); | |
if (furnaceBurnEvent.isCancelled()) { | |
return; | |
} | |
this.ticksForCurrentFuel = furnaceBurnEvent.getBurnTime(); | |
this.burnTime += this.ticksForCurrentFuel; | |
if ((this.burnTime > 0) && (furnaceBurnEvent.isBurning())) { | |
flag1 = true; | |
if (this.items[1] != null) { | |
this.items[1].count -= 1; | |
if (this.items[1].count == 0) { | |
Item item = this.items[1].getItem().t(); | |
this.items[1] = (item != null ? new ItemStack(item) : null); | |
} | |
} | |
} | |
} | |
if (flag != this.burnTime > 0) { | |
flag1 = true; | |
BlockFurnace.a(this.burnTime > 0, this.world, this.x, this.y, this.z); | |
} | |
} | |
if (flag1) | |
update(); | |
} | |
// My h() method | |
@Override | |
public void h() { | |
boolean isBurning = this.burnTime > 0; | |
boolean update = false; | |
int elapsedTicks = MinecraftServer.currentTick - this.lastTick; | |
this.lastTick = MinecraftServer.currentTick; | |
if (isBurning() && canBurn()) { | |
this.actualCookTime += elapsedTicks; | |
if (this.actualCookTime >= this.maxCookTime) { | |
if (this.maxCookTime == 0) this.maxCookTime = 150; | |
this.actualCookTime %= this.maxCookTime; | |
burn(); | |
update = true; | |
} | |
this.cookTime = (int) Math.ceil(((double) this.actualCookTime / (double) this.maxCookTime) * 200D); | |
} else { | |
this.actualCookTime = 0; | |
this.cookTime = 0; | |
} | |
if (this.burnTime > 0) this.burnTime -= elapsedTicks; | |
if (!this.world.isStatic) { | |
if (this.burnTime <= 0 && canBurn() && this.getItem(1) != null) { | |
CraftItemStack fuel = CraftItemStack.asCraftMirror(this.getItem(1)); | |
FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), fuel, fuelTime(this.getItem(1))); | |
this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent); | |
if (furnaceBurnEvent.isCancelled()) return; | |
this.ticksForCurrentFuel = furnaceBurnEvent.getBurnTime(); | |
this.burnTime += this.ticksForCurrentFuel; | |
if (this.burnTime > 0 && furnaceBurnEvent.isBurning()) { | |
update = true; | |
if (this.getItem(1) != null) { | |
this.getItem(1).count -= 1; | |
if (this.getItem(1).count == 0) { | |
Item item = this.getItem(1).getItem().t(); | |
this.setItem(1, item != null ? new ItemStack(item) : null); | |
} | |
} | |
} | |
} | |
if (isBurning != this.burnTime > 0) { | |
update = true; | |
BlockFurnace.a(this.burnTime > 0, this.world, this.x, this.y, this.z); | |
} | |
} | |
if (update) update(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment