mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 18:27:17 +01:00
data improvements
By: Tahg <tahgtahv@gmail.com>
This commit is contained in:
parent
35a5504f20
commit
b7fd3933e4
3 changed files with 11 additions and 6 deletions
|
@ -687,7 +687,7 @@ public class CraftWorld implements World {
|
|||
} else if (Egg.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityEgg(world, x, y, z);
|
||||
} else if (FallingSand.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityFallingSand(world, x, y, z, 0);
|
||||
entity = new EntityFallingSand(world, x, y, z, 0, 0);
|
||||
} else if (Fireball.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityFireball(world);
|
||||
((EntityFireball) entity).setPositionRotation(x, y, z, yaw, pitch);
|
||||
|
|
|
@ -199,12 +199,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
|||
|
||||
public int firstPartial(ItemStack item) {
|
||||
ItemStack[] inventory = getContents();
|
||||
ItemStack filteredItem = new CraftItemStack(item);
|
||||
if (item == null) {
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
ItemStack cItem = inventory[i];
|
||||
if (cItem != null && cItem.getTypeId() == item.getTypeId() && cItem.getAmount() < cItem.getMaxStackSize() && cItem.getDurability() == item.getDurability()) {
|
||||
if (cItem != null && cItem.getTypeId() == filteredItem.getTypeId() && cItem.getAmount() < cItem.getMaxStackSize() && cItem.getDurability() == filteredItem.getDurability()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,15 @@ public class CraftItemStack extends ItemStack {
|
|||
super(
|
||||
item != null ? item.id: 0,
|
||||
item != null ? item.count : 0,
|
||||
(short)(item != null ? item.damage : 0)
|
||||
(short)(item != null ? item.getData() : 0)
|
||||
);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public CraftItemStack(ItemStack item) {
|
||||
this(item.getTypeId(), item.getAmount(), item.getDurability());
|
||||
}
|
||||
|
||||
/* 'Overwritten' constructors from ItemStack, yay for Java sucking */
|
||||
public CraftItemStack(final int type) {
|
||||
this(type, 0);
|
||||
|
@ -105,15 +109,15 @@ public class CraftItemStack extends ItemStack {
|
|||
// Ignore damage if item is null
|
||||
if (item != null) {
|
||||
super.setDurability(durability);
|
||||
item.damage = durability;
|
||||
item.b(durability);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability() {
|
||||
if (item != null) {
|
||||
super.setDurability((short) item.damage); // sync, needed?
|
||||
return (short) item.damage;
|
||||
super.setDurability((short) item.getData()); // sync, needed?
|
||||
return (short) item.getData();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue