Search in sources :

Example 51 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method removeLoader.

@Override
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
    Location loaderLoc = chunkLoader.getLocation();
    World world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
    long tileEntityLong = LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
    TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
    if (tileEntityChunkLoader != null) {
        tileEntityChunkLoader.holograms.forEach(EntityHolograms_v1_12_R1::removeHologram);
        tileEntityChunkLoader.removed = true;
        world.tileEntityListTick.remove(tileEntityChunkLoader);
    }
    if (spawnParticle)
        world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
    for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
        Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
        chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
            NBTTagCompound nbtTagCompound = new NBTTagCompound();
            tileEntity.save(nbtTagCompound);
            nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
            try {
                compoundLoadMethod.invoke(tileEntity, nbtTagCompound);
            } catch (Throwable ex) {
                tileEntity.a(nbtTagCompound);
            }
        });
    }
}
Also used : ChunkLoader(com.bgsoftware.wildloaders.api.loaders.ChunkLoader) TileEntityMobSpawner(net.minecraft.server.v1_12_R1.TileEntityMobSpawner) Block(net.minecraft.server.v1_12_R1.Block) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) HashMap(java.util.HashMap) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) ArrayList(java.util.ArrayList) WChunkLoader(com.bgsoftware.wildloaders.loaders.WChunkLoader) TileEntity(net.minecraft.server.v1_12_R1.TileEntity) Chunk(net.minecraft.server.v1_12_R1.Chunk) World(net.minecraft.server.v1_12_R1.World) Location(org.bukkit.Location) NBTTagLong(net.minecraft.server.v1_12_R1.NBTTagLong) Map(java.util.Map) WildLoadersPlugin(com.bgsoftware.wildloaders.WildLoadersPlugin) ITileEntityChunkLoader(com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader) Method(java.lang.reflect.Method) Hologram(com.bgsoftware.wildloaders.api.holograms.Hologram) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) LongHash(org.bukkit.craftbukkit.v1_12_R1.util.LongHash) CraftChunk(org.bukkit.craftbukkit.v1_12_R1.CraftChunk) Collection(java.util.Collection) UUID(java.util.UUID) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) List(java.util.List) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) ITickable(net.minecraft.server.v1_12_R1.ITickable) ChunkLoaderNPC(com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC) Collections(java.util.Collections) ItemStack(net.minecraft.server.v1_12_R1.ItemStack) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) World(net.minecraft.server.v1_12_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) Chunk(net.minecraft.server.v1_12_R1.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_12_R1.CraftChunk) ITileEntityChunkLoader(com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader) TileEntityMobSpawner(net.minecraft.server.v1_12_R1.TileEntityMobSpawner) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_12_R1.CraftChunk) Location(org.bukkit.Location)

Example 52 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method getTag.

@Override
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    if (!tagCompound.hasKeyOfType(key, 8))
        return def;
    return tagCompound.getString(key);
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 53 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method getPlayerSkull.

@Override
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack itemStack, String texture) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound nbtTagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    NBTTagCompound skullOwner = nbtTagCompound.hasKey("SkullOwner") ? nbtTagCompound.getCompound("SkullOwner") : new NBTTagCompound();
    NBTTagCompound properties = new NBTTagCompound();
    NBTTagList textures = new NBTTagList();
    NBTTagCompound signature = new NBTTagCompound();
    signature.setString("Value", texture);
    textures.add(signature);
    properties.set("textures", textures);
    skullOwner.set("Properties", properties);
    skullOwner.setString("Id", UUID.randomUUID().toString());
    nbtTagCompound.set("SkullOwner", skullOwner);
    nmsItem.setTag(nbtTagCompound);
    return CraftItemStack.asBukkitCopy(nmsItem);
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 54 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method setTag.

@Override
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    tagCompound.set(key, new NBTTagString(value));
    nmsItem.setTag(tagCompound);
    return CraftItemStack.asBukkitCopy(nmsItem);
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 55 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method getTag.

@Override
public long getTag(org.bukkit.inventory.ItemStack itemStack, String key, long def) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    if (!tagCompound.hasKeyOfType(key, 4))
        return def;
    return tagCompound.getLong(key);
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Aggregations

NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)69 ItemStack (org.bukkit.inventory.ItemStack)60 Map (java.util.Map)41 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)39 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)38 ArrayList (java.util.ArrayList)37 ItemMeta (org.bukkit.inventory.meta.ItemMeta)35 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)33 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)30 ListTag (com.wasteofplastic.org.jnbt.ListTag)30 StringTag (com.wasteofplastic.org.jnbt.StringTag)30 Tag (com.wasteofplastic.org.jnbt.Tag)30 NBTTagCompound (net.minecraft.server.v1_16_R2.NBTTagCompound)24 Nullable (javax.annotation.Nullable)21 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)21 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)20 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)20 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)20 NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)19 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)18