geforkt von Mirrors/Paper
SPIGOT-2772, SPIGOT-2780: Improve empty ItemStack handling
Dieser Commit ist enthalten in:
Ursprung
129efc132a
Commit
162e961326
@ -1016,7 +1016,7 @@ public class CraftEventFactory {
|
||||
|
||||
public static EntityBreedEvent callEntityBreedEvent(EntityLiving child, EntityLiving mother, EntityLiving father, EntityLiving breeder, ItemStack bredWith, int experience) {
|
||||
org.bukkit.entity.LivingEntity breederEntity = (LivingEntity)(breeder == null ? null : breeder.getBukkitEntity());
|
||||
CraftItemStack bredWithStack = bredWith == null ? null : CraftItemStack.asCraftMirror(bredWith).clone();
|
||||
CraftItemStack bredWithStack = (bredWith.isEmpty()) ? null : CraftItemStack.asCraftMirror(bredWith).clone();
|
||||
|
||||
EntityBreedEvent event = new EntityBreedEvent((LivingEntity) child.getBukkitEntity(), (LivingEntity) mother.getBukkitEntity(), (LivingEntity) father.getBukkitEntity(), breederEntity, bredWithStack, experience);
|
||||
child.world.getServer().getPluginManager().callEvent(event);
|
||||
|
@ -46,7 +46,7 @@ public class CraftInventory implements Inventory {
|
||||
|
||||
public ItemStack getItem(int index) {
|
||||
net.minecraft.server.ItemStack item = getInventory().getItem(index);
|
||||
return item == null ? null : CraftItemStack.asCraftMirror(item);
|
||||
return CraftItemStack.asCraftMirror(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,7 +65,7 @@ public class CraftInventory implements Inventory {
|
||||
|
||||
int size = Math.min(items.length, mcItems.size());
|
||||
for (int i = 0; i < size; i++) {
|
||||
items[i] = (mcItems.get(i) == net.minecraft.server.ItemStack.a) ? null : CraftItemStack.asCraftMirror(mcItems.get(i));
|
||||
items[i] = CraftItemStack.asCraftMirror(mcItems.get(i));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
@ -28,19 +28,19 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor
|
||||
public ItemStack getItem(int slot) {
|
||||
if (slot < getIngredientsInventory().getSize()) {
|
||||
net.minecraft.server.ItemStack item = getIngredientsInventory().getItem(slot);
|
||||
return item == null ? null : CraftItemStack.asCraftMirror(item);
|
||||
return CraftItemStack.asCraftMirror(item);
|
||||
} else {
|
||||
net.minecraft.server.ItemStack item = getResultInventory().getItem(slot - getIngredientsInventory().getSize());
|
||||
return item == null ? null : CraftItemStack.asCraftMirror(item);
|
||||
return CraftItemStack.asCraftMirror(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(int index, ItemStack item) {
|
||||
if (index < getIngredientsInventory().getSize()) {
|
||||
getIngredientsInventory().setItem(index, (item == null ? null : CraftItemStack.asNMSCopy(item)));
|
||||
getIngredientsInventory().setItem(index, CraftItemStack.asNMSCopy(item));
|
||||
} else {
|
||||
getResultInventory().setItem((index - getIngredientsInventory().getSize()), (item == null ? null : CraftItemStack.asNMSCopy(item)));
|
||||
getResultInventory().setItem((index - getIngredientsInventory().getSize()), CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,19 +70,19 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
|
||||
public CraftItemStack getItem(int index) {
|
||||
if (index < getResultInventory().getSize()) {
|
||||
net.minecraft.server.ItemStack item = getResultInventory().getItem(index);
|
||||
return item == null ? null : CraftItemStack.asCraftMirror(item);
|
||||
return CraftItemStack.asCraftMirror(item);
|
||||
} else {
|
||||
net.minecraft.server.ItemStack item = getMatrixInventory().getItem(index - getResultInventory().getSize());
|
||||
return item == null ? null : CraftItemStack.asCraftMirror(item);
|
||||
return CraftItemStack.asCraftMirror(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(int index, ItemStack item) {
|
||||
if (index < getResultInventory().getSize()) {
|
||||
getResultInventory().setItem(index, (item == null ? null : CraftItemStack.asNMSCopy(item)));
|
||||
getResultInventory().setItem(index, CraftItemStack.asNMSCopy(item));
|
||||
} else {
|
||||
getMatrixInventory().setItem((index - getResultInventory().getSize()), (item == null ? null : CraftItemStack.asNMSCopy(item)));
|
||||
getMatrixInventory().setItem((index - getResultInventory().getSize()), CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,8 +99,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
|
||||
|
||||
public ItemStack getResult() {
|
||||
net.minecraft.server.ItemStack item = getResultInventory().getItem(0);
|
||||
if(item != null) return CraftItemStack.asCraftMirror(item);
|
||||
return null;
|
||||
return CraftItemStack.asCraftMirror(item);
|
||||
}
|
||||
|
||||
public void setMatrix(ItemStack[] contents) {
|
||||
|
@ -57,7 +57,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
* Copies the NMS stack to return as a strictly-Bukkit stack
|
||||
*/
|
||||
public static ItemStack asBukkitCopy(net.minecraft.server.ItemStack original) {
|
||||
if (original == net.minecraft.server.ItemStack.a) {
|
||||
if (original.isEmpty()) {
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(original.getItem()), original.getCount(), (short) original.getData());
|
||||
@ -68,7 +68,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
}
|
||||
|
||||
public static CraftItemStack asCraftMirror(net.minecraft.server.ItemStack original) {
|
||||
return new CraftItemStack(original);
|
||||
return (original.isEmpty()) ? null : new CraftItemStack(original);
|
||||
}
|
||||
|
||||
public static CraftItemStack asCraftCopy(ItemStack original) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren