mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-10 04:41:42 +01:00
SPIGOT-4030: Improve CraftItemStack.hasItemMeta
This commit is contained in:
parent
1526726b57
commit
8c9dea83c3
@ -553,7 +553,7 @@ public final class CraftItemStack extends ItemStack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasItemMeta() {
|
public boolean hasItemMeta() {
|
||||||
return hasItemMeta(handle);
|
return hasItemMeta(handle) && !CraftItemFactory.instance().equals(getItemMeta(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean hasItemMeta(net.minecraft.server.ItemStack item) {
|
static boolean hasItemMeta(net.minecraft.server.ItemStack item) {
|
||||||
|
@ -11,6 +11,7 @@ import net.minecraft.server.ITileEntity;
|
|||||||
import net.minecraft.server.Item;
|
import net.minecraft.server.Item;
|
||||||
import net.minecraft.server.ItemBlock;
|
import net.minecraft.server.ItemBlock;
|
||||||
import net.minecraft.server.ItemBlockWallable;
|
import net.minecraft.server.ItemBlockWallable;
|
||||||
|
import net.minecraft.server.NBTTagInt;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@ -140,6 +141,20 @@ public class ItemMetaTest extends AbstractTestingBase {
|
|||||||
assertThat(bukkit, is((ItemStack) craft));
|
assertThat(bukkit, is((ItemStack) craft));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTaggedButNotMeta() {
|
||||||
|
CraftItemStack craft = CraftItemStack.asCraftCopy(new ItemStack(Material.SHEARS));
|
||||||
|
craft.handle.setDamage(0);
|
||||||
|
|
||||||
|
assertThat("Should have NBT tag", CraftItemStack.hasItemMeta(craft.handle), is(true));
|
||||||
|
assertThat("NBT Tag should contain Damage", craft.handle.getTag().get("Damage"), instanceOf(NBTTagInt.class));
|
||||||
|
assertThat("But we should not have meta", craft.hasItemMeta(), is(false));
|
||||||
|
|
||||||
|
ItemStack pureBukkit = new ItemStack(Material.SHEARS);
|
||||||
|
assertThat("Bukkit and craft stacks should be similar", craft.isSimilar(pureBukkit), is(true));
|
||||||
|
assertThat("Bukkit and craft stacks should be equal", craft.equals(pureBukkit), is(true));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBlockStateMeta() {
|
public void testBlockStateMeta() {
|
||||||
List<Block> queue = new ArrayList<>();
|
List<Block> queue = new ArrayList<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user