Added EquipmentSetEvent and added fast smelting

This commit is contained in:
Aplosh 2023-05-22 04:56:29 +01:00
parent 6dd5f7a17c
commit 24f259830a
6 changed files with 283 additions and 218 deletions

View File

@ -30,6 +30,8 @@ dependencies {
api("com.googlecode.json-simple:json-simple:1.1.1") api("com.googlecode.json-simple:json-simple:1.1.1")
api("org.yaml:snakeyaml:1.30") api("org.yaml:snakeyaml:1.30")
api("net.md-5:bungeecord-chat:1.8-SNAPSHOT") api("net.md-5:bungeecord-chat:1.8-SNAPSHOT")
implementation("org.projectlombok:lombok:1.18.26")
implementation("org.projectlombok:lombok:1.18.26")
compileOnlyApi("net.sf.trove4j:trove4j:3.0.3") // provided by server compileOnlyApi("net.sf.trove4j:trove4j:3.0.3") // provided by server
// bundled with Minecraft, should be kept in sync // bundled with Minecraft, should be kept in sync

View File

@ -0,0 +1,51 @@
package org.bukkit.event.inventory;
import lombok.Setter;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
@Setter
public class EquipmentSetEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private final HumanEntity humanEntity;
private final int slot;
private final ItemStack previousItem;
private final ItemStack newItem;
public EquipmentSetEvent(HumanEntity entity, int slot, ItemStack previousItem, ItemStack newItem) {
this.humanEntity = entity;
this.slot = slot;
this.previousItem = previousItem;
this.newItem = newItem;
}
public static HandlerList getHandlerList() {
return handlers;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public HumanEntity getHumanEntity() {
return humanEntity;
}
public int getSlot() {
return slot;
}
public ItemStack getPreviousItem() {
return previousItem;
}
public ItemStack getNewItem() {
return newItem;
}
}

View File

@ -13,6 +13,7 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.inventory.EquipmentSetEvent;
import org.bukkit.event.player.PlayerBedEnterEvent; import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent; import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
@ -20,10 +21,7 @@ import org.bukkit.event.player.PlayerItemConsumeEvent;
import com.elevatemc.spigot.knockback.KnockbackProfile; import com.elevatemc.spigot.knockback.KnockbackProfile;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.Collection; import java.util.*;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
// CraftBukkit end // CraftBukkit end
public abstract class EntityHuman extends EntityLiving { public abstract class EntityHuman extends EntityLiving {
@ -1722,8 +1720,16 @@ public abstract class EntityHuman extends EntityLiving {
return this.inventory.getItemInHand(); return this.inventory.getItemInHand();
} }
@Override
public void setEquipment(int i, ItemStack itemstack) { public void setEquipment(int i, ItemStack itemstack) {
ItemStack previous = this.inventory.armor[i];
if (!Objects.equals(previous, itemstack)) {
if (previous != null && EquipmentSetEvent.getHandlerList().getRegisteredListeners().length != 0) {
previous = previous.cloneItemStack();
}
this.inventory.armor[i] = itemstack; this.inventory.armor[i] = itemstack;
Bukkit.getPluginManager().callEvent(new EquipmentSetEvent(this.getBukkitEntity(), i, CraftItemStack.asBukkitCopy(previous), CraftItemStack.asBukkitCopy(itemstack)));
}
} }
public abstract boolean isSpectator(); public abstract boolean isSpectator();

View File

@ -1,28 +1,25 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
// CraftBukkit start
import java.util.List;
import com.elevatemc.spigot.config.eSpigotConfig;
import org.bukkit.craftbukkit.entity.CraftHumanEntity; import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
// CraftBukkit end import org.bukkit.inventory.InventoryHolder;
import org.spigotmc.SpigotConfig;
public class PlayerInventory implements IInventory { public class PlayerInventory implements IInventory {
public ItemStack[] items = new ItemStack[36]; public ItemStack[] items = new ItemStack[36];
public ItemStack[] armor = new ItemStack[4]; public ItemStack[] armor = new ItemStack[4];
public int itemInHandIndex; public int itemInHandIndex;
public EntityHuman player; public EntityHuman player;
private ItemStack f; private ItemStack f;
public boolean e; public boolean e;
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private int maxStack = 64;
// CraftBukkit start - add fields and methods @Override
public List<HumanEntity> transaction = new java.util.ArrayList<>();
private int maxStack = MAX_STACK;
public ItemStack[] getContents() { public ItemStack[] getContents() {
return this.items; return this.items;
} }
@ -31,26 +28,30 @@ public class PlayerInventory implements IInventory {
return this.armor; return this.armor;
} }
@Override
public void onOpen(CraftHumanEntity who) { public void onOpen(CraftHumanEntity who) {
transaction.add(who); this.transaction.add(who);
} }
@Override
public void onClose(CraftHumanEntity who) { public void onClose(CraftHumanEntity who) {
transaction.remove(who); this.transaction.remove(who);
} }
@Override
public List<HumanEntity> getViewers() { public List<HumanEntity> getViewers() {
return transaction; return this.transaction;
} }
public org.bukkit.inventory.InventoryHolder getOwner() { @Override
public InventoryHolder getOwner() {
return this.player.getBukkitEntity(); return this.player.getBukkitEntity();
} }
@Override
public void setMaxStackSize(int size) { public void setMaxStackSize(int size) {
maxStack = size; this.maxStack = size;
} }
// CraftBukkit end
public PlayerInventory(EntityHuman entityhuman) { public PlayerInventory(EntityHuman entityhuman) {
this.player = entityhuman; this.player = entityhuman;
@ -65,61 +66,64 @@ public class PlayerInventory implements IInventory {
} }
private int c(Item item) { private int c(Item item) {
for (int i = 0; i < this.items.length; ++i) { int i = 0;
while (i < this.items.length) {
if (this.items[i] != null && this.items[i].getItem() == item) { if (this.items[i] != null && this.items[i].getItem() == item) {
return i; return i;
} }
++i;
} }
return -1; return -1;
} }
private int firstPartial(ItemStack itemstack) { private int firstPartial(ItemStack itemstack) {
for (int i = 0; i < this.items.length; ++i) { int i = 0;
while (i < this.items.length) {
if (this.items[i] != null && this.items[i].getItem() == itemstack.getItem() && this.items[i].isStackable() && this.items[i].count < this.items[i].getMaxStackSize() && this.items[i].count < this.getMaxStackSize() && (!this.items[i].usesData() || this.items[i].getData() == itemstack.getData()) && ItemStack.equals(this.items[i], itemstack)) { if (this.items[i] != null && this.items[i].getItem() == itemstack.getItem() && this.items[i].isStackable() && this.items[i].count < this.items[i].getMaxStackSize() && this.items[i].count < this.getMaxStackSize() && (!this.items[i].usesData() || this.items[i].getData() == itemstack.getData()) && ItemStack.equals(this.items[i], itemstack)) {
return i; return i;
} }
++i;
} }
return -1; return -1;
} }
// CraftBukkit start - Watch method above! :D
public int canHold(ItemStack itemstack) { public int canHold(ItemStack itemstack) {
int remains = itemstack.count; int remains = itemstack.count;
for (ItemStack item : this.items) { int i = 0;
if (item == null) return itemstack.count; while (i < this.items.length) {
if (this.items[i] == null) {
// Taken from firstPartial(ItemStack) return itemstack.count;
if (item != null && item.getItem() == itemstack.getItem() && item.isStackable() && item.count < item.getMaxStackSize() && item.count < this.getMaxStackSize() && (!item.usesData() || item.getData() == itemstack.getData()) && ItemStack.equals(item, itemstack)) {
remains -= (item.getMaxStackSize() < this.getMaxStackSize() ? item.getMaxStackSize() : this.getMaxStackSize()) - item.count;
} }
if (remains <= 0) return itemstack.count; if (this.items[i] != null && this.items[i].getItem() == itemstack.getItem() && this.items[i].isStackable() && this.items[i].count < this.items[i].getMaxStackSize() && this.items[i].count < this.getMaxStackSize() && (!this.items[i].usesData() || this.items[i].getData() == itemstack.getData()) && ItemStack.equals(this.items[i], itemstack)) {
remains -= (this.items[i].getMaxStackSize() < this.getMaxStackSize() ? this.items[i].getMaxStackSize() : this.getMaxStackSize()) - this.items[i].count;
}
if (remains <= 0) {
return itemstack.count;
}
++i;
} }
return itemstack.count - remains; return itemstack.count - remains;
} }
// CraftBukkit end
public int getFirstEmptySlotIndex() { public int getFirstEmptySlotIndex() {
for (int i = 0; i < this.items.length; ++i) { int i = 0;
while (i < this.items.length) {
if (this.items[i] == null) { if (this.items[i] == null) {
return i; return i;
} }
++i;
} }
return -1; return -1;
} }
public int a(Item item, int i, int j, NBTTagCompound nbttagcompound) { public int a(Item item, int i, int j, NBTTagCompound nbttagcompound) {
int k = 0;
int l;
ItemStack itemstack;
int i1; int i1;
ItemStack itemstack;
for (l = 0; l < this.items.length; ++l) { int k = 0;
int l = 0;
while (l < this.items.length) {
itemstack = this.items[l]; itemstack = this.items[l];
if (itemstack != null && (item == null || itemstack.getItem() == item) && (i <= -1 || itemstack.getData() == i) && (nbttagcompound == null || GameProfileSerializer.a(nbttagcompound, itemstack.getTag(), true))) { if (!(itemstack == null || item != null && itemstack.getItem() != item || i > -1 && itemstack.getData() != i || nbttagcompound != null && !GameProfileSerializer.a(nbttagcompound, itemstack.getTag(), true))) {
i1 = j <= 0 ? itemstack.count : Math.min(j - k, itemstack.count); i1 = j <= 0 ? itemstack.count : Math.min(j - k, itemstack.count);
k += i1; k += i1;
if (j != 0) { if (j != 0) {
@ -127,45 +131,41 @@ public class PlayerInventory implements IInventory {
if (this.items[l].count == 0) { if (this.items[l].count == 0) {
this.items[l] = null; this.items[l] = null;
} }
if (j > 0 && k >= j) { if (j > 0 && k >= j) {
return k; return k;
} }
} }
} }
++l;
} }
l = 0;
for (l = 0; l < this.armor.length; ++l) { while (l < this.armor.length) {
itemstack = this.armor[l]; itemstack = this.armor[l];
if (itemstack != null && (item == null || itemstack.getItem() == item) && (i <= -1 || itemstack.getData() == i) && (nbttagcompound == null || GameProfileSerializer.a(nbttagcompound, itemstack.getTag(), false))) { if (!(itemstack == null || item != null && itemstack.getItem() != item || i > -1 && itemstack.getData() != i || nbttagcompound != null && !GameProfileSerializer.a(nbttagcompound, itemstack.getTag(), false))) {
i1 = j <= 0 ? itemstack.count : Math.min(j - k, itemstack.count); i1 = j <= 0 ? itemstack.count : Math.min(j - k, itemstack.count);
k += i1; k += i1;
if (j != 0) { if (j != 0) {
this.armor[l].count -= i1; this.armor[l].count -= i1;
if (this.armor[l].count == 0) { if (this.armor[l].count == 0) {
this.armor[l] = null; this.player.setEquipment(k, null);
} }
if (j > 0 && k >= j) { if (j > 0 && k >= j) {
return k; return k;
} }
} }
} }
++l;
} }
if (this.f != null) { if (this.f != null) {
if (item != null && this.f.getItem() != item) { if (item != null && this.f.getItem() != item) {
return k; return k;
} }
if (i > -1 && this.f.getData() != i) { if (i > -1 && this.f.getData() != i) {
return k; return k;
} }
if (nbttagcompound != null && !GameProfileSerializer.a(nbttagcompound, this.f.getTag(), false)) { if (nbttagcompound != null && !GameProfileSerializer.a(nbttagcompound, this.f.getTag(), false)) {
return k; return k;
} }
l = j <= 0 ? this.f.count : Math.min(j - k, this.f.count); l = j <= 0 ? this.f.count : Math.min(j - k, this.f.count);
k += l; k += l;
if (j != 0) { if (j != 0) {
@ -173,13 +173,11 @@ public class PlayerInventory implements IInventory {
if (this.f.count == 0) { if (this.f.count == 0) {
this.f = null; this.f = null;
} }
if (j > 0 && k >= j) { if (j > 0 && k >= j) {
return k; return k;
} }
} }
} }
return k; return k;
} }
@ -187,109 +185,97 @@ public class PlayerInventory implements IInventory {
Item item = itemstack.getItem(); Item item = itemstack.getItem();
int i = itemstack.count; int i = itemstack.count;
int j = this.firstPartial(itemstack); int j = this.firstPartial(itemstack);
if (j < 0) { if (j < 0) {
j = this.getFirstEmptySlotIndex(); j = this.getFirstEmptySlotIndex();
} }
if (j < 0) { if (j < 0) {
return i; return i;
} else { }
if (this.items[j] == null) { if (this.items[j] == null) {
this.items[j] = new ItemStack(item, 0, itemstack.getData()); this.items[j] = new ItemStack(item, 0, itemstack.getData());
if (itemstack.hasTag()) { if (itemstack.hasTag()) {
this.items[j].setTag((NBTTagCompound) itemstack.getTag().clone()); this.items[j].setTag((NBTTagCompound) itemstack.getTag().clone());
} }
} }
int k = i; int k = i;
if (i > this.items[j].getMaxStackSize() - this.items[j].count) { if (i > this.items[j].getMaxStackSize() - this.items[j].count) {
k = this.items[j].getMaxStackSize() - this.items[j].count; k = this.items[j].getMaxStackSize() - this.items[j].count;
} }
if (k > this.getMaxStackSize() - this.items[j].count) { if (k > this.getMaxStackSize() - this.items[j].count) {
k = this.getMaxStackSize() - this.items[j].count; k = this.getMaxStackSize() - this.items[j].count;
} }
if (k == 0) { if (k == 0) {
return i; return i;
} else { }
i -= k;
this.items[j].count += k; this.items[j].count += k;
this.items[j].c = 5; this.items[j].c = 5;
return i; return i -= k;
}
}
} }
public void k() { public void k() {
for (int i = 0; i < this.items.length; ++i) { int i = 0;
while (i < this.items.length) {
if (this.items[i] != null) { if (this.items[i] != null) {
this.items[i].a(this.player.world, this.player, i, this.itemInHandIndex == i); this.items[i].a(this.player.world, this.player, i, this.itemInHandIndex == i);
} }
++i;
} }
} }
public boolean a(Item item) { public boolean a(Item item) {
int i = this.c(item); int i = this.c(item);
if (i < 0) { if (i < 0) {
return false; return false;
} else { }
if (--this.items[i].count <= 0) { if (--this.items[i].count <= 0) {
this.items[i] = null; this.items[i] = null;
} }
return true; return true;
} }
}
public boolean b(Item item) { public boolean b(Item item) {
int i = this.c(item); int i = this.c(item);
return i >= 0; return i >= 0;
} }
public boolean pickup(final ItemStack itemstack) { public boolean pickup(final ItemStack itemstack) {
if (itemstack != null && itemstack.count != 0 && itemstack.getItem() != null) { if (itemstack != null && itemstack.count != 0 && itemstack.getItem() != null) {
try {
int i; int i;
block10:
if (itemstack.g()) { {
block8:
{
block9:
{
if (!itemstack.g()) break block8;
i = this.getFirstEmptySlotIndex(); i = this.getFirstEmptySlotIndex();
if (i >= 0) { if (i < 0) break block9;
this.items[i] = ItemStack.b(itemstack); this.items[i] = ItemStack.b(itemstack);
this.items[i].c = 5; this.items[i].c = 5;
itemstack.count = 0; itemstack.count = 0;
return true; return true;
} else if (this.player.abilities.canInstantlyBuild) { }
if (this.player.abilities.canInstantlyBuild) {
itemstack.count = 0; itemstack.count = 0;
return true; return true;
} else { }
return false; return false;
} }
} else { try {
do { do {
i = itemstack.count; i = itemstack.count;
itemstack.count = this.e(itemstack); itemstack.count = this.e(itemstack);
} while (itemstack.count > 0 && itemstack.count < i); } while (itemstack.count > 0 && itemstack.count < i);
if (itemstack.count != i || !this.player.abilities.canInstantlyBuild) break block10;
if (itemstack.count == i && this.player.abilities.canInstantlyBuild) {
itemstack.count = 0; itemstack.count = 0;
return true; return true;
} else {
return itemstack.count < i;
}
}
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Adding item to inventory"); CrashReport crashreport = CrashReport.a(throwable, "Adding item to inventory");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Item being added"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Item being added");
crashreportsystemdetails.a("Item ID", Item.getId(itemstack.getItem())); crashreportsystemdetails.a("Item ID", Item.getId(itemstack.getItem()));
crashreportsystemdetails.a("Item data", itemstack.getData()); crashreportsystemdetails.a("Item data", itemstack.getData());
crashreportsystemdetails.a("Item name", new Callable() { crashreportsystemdetails.a("Item name", new Callable() {
public String a() throws Exception { public String a() throws Exception {
return itemstack.getName(); return itemstack.getName();
} }
@ -300,164 +286,169 @@ public class PlayerInventory implements IInventory {
}); });
throw new ReportedException(crashreport); throw new ReportedException(crashreport);
} }
} else { }
return itemstack.count < i;
}
return false; return false;
} }
}
@Override
public ItemStack splitStack(int i, int j) { public ItemStack splitStack(int i, int j) {
boolean settingArmor;
ItemStack[] aitemstack = this.items; ItemStack[] aitemstack = this.items;
boolean bl = settingArmor = i >= this.items.length;
if (i >= this.items.length) { if (i >= this.items.length) {
aitemstack = this.armor; aitemstack = this.armor;
i -= this.items.length; i -= this.items.length;
} }
if (aitemstack[i] != null) { if (aitemstack[i] != null) {
ItemStack itemstack;
if (aitemstack[i].count <= j) { if (aitemstack[i].count <= j) {
itemstack = aitemstack[i]; ItemStack itemstack = aitemstack[i];
aitemstack[i] = null; if (settingArmor) {
return itemstack; this.player.setEquipment(i, null);
} else { } else {
itemstack = aitemstack[i].cloneAndSubtract(j); aitemstack[i] = null;
}
return itemstack;
}
ItemStack itemstack = aitemstack[i].cloneAndSubtract(j);
if (aitemstack[i].count == 0) { if (aitemstack[i].count == 0) {
if (settingArmor) {
this.player.setEquipment(i, null);
} else {
aitemstack[i] = null; aitemstack[i] = null;
} }
}
return itemstack; return itemstack;
} }
} else {
return null; return null;
} }
}
@Override
public ItemStack splitWithoutUpdate(int i) { public ItemStack splitWithoutUpdate(int i) {
boolean settingArmor;
ItemStack[] aitemstack = this.items; ItemStack[] aitemstack = this.items;
boolean bl = settingArmor = i >= this.items.length;
if (i >= this.items.length) { if (i >= this.items.length) {
aitemstack = this.armor; aitemstack = this.armor;
i -= this.items.length; i -= this.items.length;
} }
if (aitemstack[i] != null) { if (aitemstack[i] != null) {
ItemStack itemstack = aitemstack[i]; ItemStack itemstack = aitemstack[i];
if (settingArmor) {
aitemstack[i] = null; this.player.setEquipment(i, null);
return itemstack;
} else { } else {
aitemstack[i] = null;
}
return itemstack;
}
return null; return null;
} }
}
@Override
public void setItem(int i, ItemStack itemstack) { public void setItem(int i, ItemStack itemstack) {
ItemStack[] aitemstack = this.items; ItemStack[] aitemstack = this.items;
if (i >= aitemstack.length) { if (i >= aitemstack.length) {
i -= aitemstack.length; this.player.setEquipment(i -= aitemstack.length, itemstack);
aitemstack = this.armor; } else {
}
aitemstack[i] = itemstack; aitemstack[i] = itemstack;
} }
}
public float a(Block block) { public float a(Block block) {
float f = 1.0F; float f = 1.0f;
if (this.items[this.itemInHandIndex] != null) { if (this.items[this.itemInHandIndex] != null) {
f *= this.items[this.itemInHandIndex].a(block); f *= this.items[this.itemInHandIndex].a(block);
} }
return f; return f;
} }
public NBTTagList a(NBTTagList nbttaglist) { public NBTTagList a(NBTTagList nbttaglist) {
int i;
NBTTagCompound nbttagcompound; NBTTagCompound nbttagcompound;
int i = 0;
for (i = 0; i < this.items.length; ++i) { while (i < this.items.length) {
if (this.items[i] != null) { if (this.items[i] != null) {
nbttagcompound = new NBTTagCompound(); nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte) i); nbttagcompound.setByte("Slot", (byte) i);
this.items[i].save(nbttagcompound); this.items[i].save(nbttagcompound);
nbttaglist.add(nbttagcompound); nbttaglist.add(nbttagcompound);
} }
++i;
} }
i = 0;
for (i = 0; i < this.armor.length; ++i) { while (i < this.armor.length) {
if (this.armor[i] != null) { if (this.armor[i] != null) {
nbttagcompound = new NBTTagCompound(); nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte) (i + 100)); nbttagcompound.setByte("Slot", (byte) (i + 100));
this.armor[i].save(nbttagcompound); this.armor[i].save(nbttagcompound);
nbttaglist.add(nbttagcompound); nbttaglist.add(nbttagcompound);
} }
++i;
} }
return nbttaglist; return nbttaglist;
} }
public void b(NBTTagList nbttaglist) { public void b(NBTTagList nbttaglist) {
this.items = new ItemStack[36]; this.items = new ItemStack[36];
this.armor = new ItemStack[4]; this.armor = new ItemStack[4];
int i = 0;
for (int i = 0; i < nbttaglist.size(); ++i) { while (i < nbttaglist.size()) {
NBTTagCompound nbttagcompound = nbttaglist.get(i); NBTTagCompound nbttagcompound = nbttaglist.get(i);
int j = nbttagcompound.getByte("Slot") & 255; int j = nbttagcompound.getByte("Slot") & 0xFF;
ItemStack itemstack = ItemStack.createStack(nbttagcompound); ItemStack itemstack = ItemStack.createStack(nbttagcompound);
if (itemstack != null) { if (itemstack != null) {
if (j >= 0 && j < this.items.length) { if (j >= 0 && j < this.items.length) {
this.items[j] = itemstack; this.items[j] = itemstack;
} }
if (j >= 100 && j < this.armor.length + 100) { if (j >= 100 && j < this.armor.length + 100) {
this.armor[j - 100] = itemstack; this.player.setEquipment(j - 100, itemstack);
} }
} }
++i;
}
} }
} @Override
public int getSize() { public int getSize() {
return this.items.length + 4; return this.items.length + 4;
} }
@Override
public ItemStack getItem(int i) { public ItemStack getItem(int i) {
ItemStack[] aitemstack = this.items; ItemStack[] aitemstack = this.items;
if (i >= aitemstack.length) { if (i >= aitemstack.length) {
i -= aitemstack.length; i -= aitemstack.length;
aitemstack = this.armor; aitemstack = this.armor;
} }
return aitemstack[i]; return aitemstack[i];
} }
@Override
public String getName() { public String getName() {
return "container.inventory"; return "container.inventory";
} }
@Override
public boolean hasCustomName() { public boolean hasCustomName() {
return false; return false;
} }
@Override
public IChatBaseComponent getScoreboardDisplayName() { public IChatBaseComponent getScoreboardDisplayName() {
return this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatMessage(this.getName(), new Object[0]); return this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatMessage(this.getName(), new Object[0]);
} }
@Override
public int getMaxStackSize() { public int getMaxStackSize() {
return maxStack; // CraftBukkit return this.maxStack;
} }
public boolean b(Block block) { public boolean b(Block block) {
if (block.getMaterial().isAlwaysDestroyable()) { if (block.getMaterial().isAlwaysDestroyable()) {
return true; return true;
} else {
ItemStack itemstack = this.getItem(this.itemInHandIndex);
return itemstack != null && itemstack.b(block);
} }
ItemStack itemstack = this.getItem(this.itemInHandIndex);
return itemstack != null ? itemstack.b(block) : false;
} }
public ItemStack e(int i) { public ItemStack e(int i) {
@ -466,54 +457,55 @@ public class PlayerInventory implements IInventory {
public int m() { public int m() {
int i = 0; int i = 0;
int j = 0;
for (ItemStack itemStack : this.armor) { while (j < this.armor.length) {
if (itemStack != null && itemStack.getItem() instanceof ItemArmor) { if (this.armor[j] != null && this.armor[j].getItem() instanceof ItemArmor) {
int k = ((ItemArmor) itemStack.getItem()).c; int k = ((ItemArmor) this.armor[j].getItem()).c;
i += k; i += k;
} }
++j;
} }
return i; return i;
} }
public void a(float f) { public void a(float f) {
f /= eSpigotConfig.reduceArmorDamage ? 8.0F : 4.0F; // MineHQ f /= 4.0F; // MineHQ
if (f < 1.0F) { if (f < 1.0F) {
f = 1.0F; f = 1.0F;
} }
for (int i = 0; i < this.armor.length; ++i) { int i = 0;
while (i < this.armor.length) {
if (this.armor[i] != null && this.armor[i].getItem() instanceof ItemArmor) { if (this.armor[i] != null && this.armor[i].getItem() instanceof ItemArmor) {
this.armor[i].damage((int) f, this.player); this.armor[i].damage((int) f, this.player);
if (this.armor[i].count == 0) { if (this.armor[i].count == 0) {
this.armor[i] = null; this.player.setEquipment(i, null);
} }
} }
++i;
} }
} }
public void n() { public void n() {
int i; int i = 0;
while (i < this.items.length) {
for (i = 0; i < this.items.length; ++i) {
if (this.items[i] != null) { if (this.items[i] != null) {
this.player.a(this.items[i], true, false); this.player.a(this.items[i], true, false);
this.items[i] = null; this.items[i] = null;
} }
++i;
} }
i = 0;
for (i = 0; i < this.armor.length; ++i) { while (i < this.armor.length) {
if (this.armor[i] != null) { if (this.armor[i] != null) {
this.player.a(this.armor[i], true, false); this.player.a(this.armor[i], true, false);
this.armor[i] = null; this.player.setEquipment(i, null);
}
++i;
} }
} }
} @Override
public void update() { public void update() {
this.e = true; this.e = true;
} }
@ -523,78 +515,87 @@ public class PlayerInventory implements IInventory {
} }
public ItemStack getCarried() { public ItemStack getCarried() {
// CraftBukkit start if (this.f != null && this.f.count <= 0) {
if (this.f != null && this.f.count == 0) {
this.setCarried(null); this.setCarried(null);
} }
// CraftBukkit end
return this.f; return this.f;
} }
@Override
public boolean a(EntityHuman entityhuman) { public boolean a(EntityHuman entityhuman) {
return !this.player.dead && entityhuman.h(this.player) <= 64.0D; return this.player.dead ? false : entityhuman.h(this.player) <= 64.0;
} }
public boolean c(ItemStack itemstack) { public boolean c(ItemStack itemstack) {
int i; int i = 0;
while (i < this.armor.length) {
for (i = 0; i < this.armor.length; ++i) {
if (this.armor[i] != null && this.armor[i].doMaterialsMatch(itemstack)) { if (this.armor[i] != null && this.armor[i].doMaterialsMatch(itemstack)) {
return true; return true;
} }
++i;
} }
i = 0;
for (i = 0; i < this.items.length; ++i) { while (i < this.items.length) {
if (this.items[i] != null && this.items[i].doMaterialsMatch(itemstack)) { if (this.items[i] != null && this.items[i].doMaterialsMatch(itemstack)) {
return true; return true;
} }
++i;
} }
return false; return false;
} }
public void startOpen(EntityHuman entityhuman) {} @Override
public void startOpen(EntityHuman entityhuman) {
}
public void closeContainer(EntityHuman entityhuman) {} @Override
public void closeContainer(EntityHuman entityhuman) {
}
@Override
public boolean b(int i, ItemStack itemstack) { public boolean b(int i, ItemStack itemstack) {
return true; return true;
} }
public void b(PlayerInventory playerinventory) { public void b(PlayerInventory playerinventory) {
int i; int i = 0;
while (i < this.items.length) {
for (i = 0; i < this.items.length; ++i) {
this.items[i] = ItemStack.b(playerinventory.items[i]); this.items[i] = ItemStack.b(playerinventory.items[i]);
++i;
} }
i = 0;
for (i = 0; i < this.armor.length; ++i) { while (i < this.armor.length) {
this.armor[i] = ItemStack.b(playerinventory.armor[i]); this.player.setEquipment(i, ItemStack.b(playerinventory.armor[i]));
++i;
} }
this.itemInHandIndex = playerinventory.itemInHandIndex; this.itemInHandIndex = playerinventory.itemInHandIndex;
} }
@Override
public int getProperty(int i) { public int getProperty(int i) {
return 0; return 0;
} }
public void b(int i, int j) {} @Override
public void b(int i, int j) {
}
@Override
public int g() { public int g() {
return 0; return 0;
} }
@Override
public void l() { public void l() {
int i; int i = 0;
while (i < this.items.length) {
for (i = 0; i < this.items.length; ++i) {
this.items[i] = null; this.items[i] = null;
++i;
} }
i = 0;
for (i = 0; i < this.armor.length; ++i) { while (i < this.armor.length) {
this.armor[i] = null; this.armor[i] = null;
} ++i;
}
} }
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent;
import org.bukkit.craftbukkit.entity.CraftHumanEntity; import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.spigotmc.SpigotConfig;
// CraftBukkit end // CraftBukkit end
public class TileEntityFurnace extends TileEntityContainer implements IUpdatePlayerListBox, IWorldInventory { public class TileEntityFurnace extends TileEntityContainer implements IUpdatePlayerListBox, IWorldInventory {
@ -186,9 +187,9 @@ public class TileEntityFurnace extends TileEntityContainer implements IUpdatePla
// CraftBukkit - moved from below // CraftBukkit - moved from below
if (this.isBurning() && this.canBurn()) { if (this.isBurning() && this.canBurn()) {
this.cookTime += elapsedTicks; this.cookTime += elapsedTicks * SpigotConfig.smeltingMultiplier;
if (this.cookTime >= this.cookTimeTotal) { if (this.cookTime >= this.cookTimeTotal) {
this.cookTime -= this.cookTimeTotal; // Paper this.cookTime = 0;
this.cookTimeTotal = this.a(this.items[0]); this.cookTimeTotal = this.a(this.items[0]);
this.burn(); this.burn();
flag1 = true; flag1 = true;

View File

@ -299,4 +299,8 @@ public class SpigotConfig
Bukkit.getLogger().info( "Debug logging is disabled" ); Bukkit.getLogger().info( "Debug logging is disabled" );
} }
} }
public static int smeltingMultiplier;
private static void smeltingMultiplier() { smeltingMultiplier = getInt("settings.smeltingMultipler", 1);}
} }