@Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); if (newItem == null) { newItem = new ItemStack(Blocks.BEDROCK); } if (newItem.getTag() == null) { newItem.setTag(new NBTTagCompound()); } NBTTagCompound display = newItem.getTag().getCompound("display"); if (!newItem.getTag().hasKey("display")) { newItem.getTag().set("display", display); } NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore display.set("Lore", tagList); newItem.count = 0; setItemStack(newItem); }
/** Sets the spawner to the mob passed */ public static boolean setSpawnerEntityData(Block block, String key, Object obj) { if (block.getType() != Material.MOB_SPAWNER) return false; if (getVersion() == -1) return false; int v = getVersion(); if (v == 0) { net.minecraft.server.v1_8_R1.TileEntity te = ((org.bukkit.craftbukkit.v1_8_R1.CraftWorld) block.getWorld()) .getHandle() .getTileEntity( new net.minecraft.server.v1_8_R1.BlockPosition( block.getX(), block.getY(), block.getZ())); if (te instanceof net.minecraft.server.v1_8_R1.TileEntityMobSpawner) { net.minecraft.server.v1_8_R1.TileEntityMobSpawner tems = (net.minecraft.server.v1_8_R1.TileEntityMobSpawner) te; net.minecraft.server.v1_8_R1.NBTTagCompound c2 = new net.minecraft.server.v1_8_R1.NBTTagCompound(); tems.b(c2); net.minecraft.server.v1_8_R1.NBTTagCompound c = c2.getCompound("SpawnData"); if (c == null) c = new net.minecraft.server.v1_8_R1.NBTTagCompound(); if (obj instanceof Boolean) c.setBoolean(key, (boolean) obj); else if (obj instanceof Integer) c.setInt(key, (int) obj); else if (obj instanceof String) c.setString(key, (String) obj); else if (obj instanceof Byte) c.setByte(key, (byte) obj); else if (obj instanceof Float) c.setFloat(key, (float) obj); c2.set("SpawnData", c); tems.a(c2); } } else if (v == 1) { net.minecraft.server.v1_8_R2.TileEntity te = ((org.bukkit.craftbukkit.v1_8_R2.CraftWorld) block.getWorld()) .getHandle() .getTileEntity( new net.minecraft.server.v1_8_R2.BlockPosition( block.getX(), block.getY(), block.getZ())); if (te instanceof net.minecraft.server.v1_8_R2.TileEntityMobSpawner) { net.minecraft.server.v1_8_R2.TileEntityMobSpawner tems = (net.minecraft.server.v1_8_R2.TileEntityMobSpawner) te; net.minecraft.server.v1_8_R2.NBTTagCompound c2 = new net.minecraft.server.v1_8_R2.NBTTagCompound(); tems.b(c2); net.minecraft.server.v1_8_R2.NBTTagCompound c = c2.getCompound("SpawnData"); if (c == null) c = new net.minecraft.server.v1_8_R2.NBTTagCompound(); if (obj instanceof Boolean) c.setBoolean(key, (boolean) obj); else if (obj instanceof Integer) c.setInt(key, (int) obj); else if (obj instanceof String) c.setString(key, (String) obj); else if (obj instanceof Byte) c.setByte(key, (byte) obj); else if (obj instanceof Float) c.setFloat(key, (float) obj); c2.set("SpawnData", c); tems.a(c2); } } else if (v == 2) { net.minecraft.server.v1_8_R3.TileEntity te = ((org.bukkit.craftbukkit.v1_8_R3.CraftWorld) block.getWorld()) .getHandle() .getTileEntity( new net.minecraft.server.v1_8_R3.BlockPosition( block.getX(), block.getY(), block.getZ())); if (te instanceof net.minecraft.server.v1_8_R3.TileEntityMobSpawner) { net.minecraft.server.v1_8_R3.TileEntityMobSpawner tems = (net.minecraft.server.v1_8_R3.TileEntityMobSpawner) te; net.minecraft.server.v1_8_R3.NBTTagCompound c2 = new net.minecraft.server.v1_8_R3.NBTTagCompound(); tems.b(c2); net.minecraft.server.v1_8_R3.NBTTagCompound c = c2.getCompound("SpawnData"); if (c == null) c = new net.minecraft.server.v1_8_R3.NBTTagCompound(); if (obj instanceof Boolean) c.setBoolean(key, (boolean) obj); else if (obj instanceof Integer) c.setInt(key, (int) obj); else if (obj instanceof String) c.setString(key, (String) obj); else if (obj instanceof Byte) c.setByte(key, (byte) obj); else if (obj instanceof Float) c.setFloat(key, (float) obj); c2.set("SpawnData", c); tems.a(c2); } } else if (v == 3) { net.minecraft.server.v1_9_R1.TileEntity te = ((org.bukkit.craftbukkit.v1_9_R1.CraftWorld) block.getWorld()) .getHandle() .getTileEntity( new net.minecraft.server.v1_9_R1.BlockPosition( block.getX(), block.getY(), block.getZ())); if (te instanceof net.minecraft.server.v1_9_R1.TileEntityMobSpawner) { net.minecraft.server.v1_9_R1.TileEntityMobSpawner tems = (net.minecraft.server.v1_9_R1.TileEntityMobSpawner) te; net.minecraft.server.v1_9_R1.NBTTagCompound c2 = new net.minecraft.server.v1_9_R1.NBTTagCompound(); tems.save(c2); net.minecraft.server.v1_9_R1.NBTTagCompound c = c2.getCompound("SpawnData"); if (c == null) c = new net.minecraft.server.v1_9_R1.NBTTagCompound(); if (obj instanceof Boolean) c.setBoolean(key, (boolean) obj); else if (obj instanceof Integer) c.setInt(key, (int) obj); else if (obj instanceof String) c.setString(key, (String) obj); else if (obj instanceof Byte) c.setByte(key, (byte) obj); else if (obj instanceof Float) c.setFloat(key, (float) obj); c2.set("SpawnData", c); tems.a(c2); } } else if (v == 4) { net.minecraft.server.v1_9_R2.TileEntity te = ((org.bukkit.craftbukkit.v1_9_R2.CraftWorld) block.getWorld()) .getHandle() .getTileEntity( new net.minecraft.server.v1_9_R2.BlockPosition( block.getX(), block.getY(), block.getZ())); if (te instanceof net.minecraft.server.v1_9_R2.TileEntityMobSpawner) { net.minecraft.server.v1_9_R2.TileEntityMobSpawner tems = (net.minecraft.server.v1_9_R2.TileEntityMobSpawner) te; net.minecraft.server.v1_9_R2.NBTTagCompound c2 = new net.minecraft.server.v1_9_R2.NBTTagCompound(); tems.save(c2); net.minecraft.server.v1_9_R2.NBTTagCompound c = c2.getCompound("SpawnData"); if (c == null) c = new net.minecraft.server.v1_9_R2.NBTTagCompound(); if (obj instanceof Boolean) c.setBoolean(key, (boolean) obj); else if (obj instanceof Integer) c.setInt(key, (int) obj); else if (obj instanceof String) c.setString(key, (String) obj); else if (obj instanceof Byte) c.setByte(key, (byte) obj); else if (obj instanceof Float) c.setFloat(key, (float) obj); c2.set("SpawnData", c); tems.a(c2); } } else if (v == 5) { net.minecraft.server.v1_10_R1.TileEntity te = ((org.bukkit.craftbukkit.v1_10_R1.CraftWorld) block.getWorld()) .getHandle() .getTileEntity( new net.minecraft.server.v1_10_R1.BlockPosition( block.getX(), block.getY(), block.getZ())); if (te instanceof net.minecraft.server.v1_10_R1.TileEntityMobSpawner) { net.minecraft.server.v1_10_R1.TileEntityMobSpawner tems = (net.minecraft.server.v1_10_R1.TileEntityMobSpawner) te; net.minecraft.server.v1_10_R1.NBTTagCompound c2 = new net.minecraft.server.v1_10_R1.NBTTagCompound(); tems.save(c2); net.minecraft.server.v1_10_R1.NBTTagCompound c = c2.getCompound("SpawnData"); if (c == null) c = new net.minecraft.server.v1_10_R1.NBTTagCompound(); if (obj instanceof Boolean) c.setBoolean(key, (boolean) obj); else if (obj instanceof Integer) c.setInt(key, (int) obj); else if (obj instanceof String) c.setString(key, (String) obj); else if (obj instanceof Byte) c.setByte(key, (byte) obj); else if (obj instanceof Float) c.setFloat(key, (float) obj); c2.set("SpawnData", c); tems.a(c2); } } else return false; return true; }