Search in sources :

Example 16 with net.minecraft.server.v1_16_R2

use of net.minecraft.server.v1_16_R2 in project TheAPI by TheDevTec.

the class v1_16_R2 method getBlock.

@Override
public Object getBlock(Object chunk, int x, int y, int z) {
    net.minecraft.server.v1_16_R2.Chunk c = (net.minecraft.server.v1_16_R2.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null)
        return Blocks.AIR.getBlockData();
    return sc.getBlocks().a(x & 15, y & 15, z & 15);
}
Also used : Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_16_R2.CraftChunk) ChunkSection(net.minecraft.server.v1_16_R2.ChunkSection)

Example 17 with net.minecraft.server.v1_16_R2

use of net.minecraft.server.v1_16_R2 in project TheAPI by TheDevTec.

the class v1_16_R2 method updateLightAt.

@Override
public void updateLightAt(Object chunk, int x, int y, int z) {
    net.minecraft.server.v1_16_R2.Chunk c = (net.minecraft.server.v1_16_R2.Chunk) chunk;
    c.world.getChunkProvider().getLightEngine().a(new BlockPosition(x, y, z));
}
Also used : BlockPosition(net.minecraft.server.v1_16_R2.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_16_R2.CraftChunk)

Example 18 with net.minecraft.server.v1_16_R2

use of net.minecraft.server.v1_16_R2 in project TheAPI by TheDevTec.

the class v1_16_R2 method openAnvilGUI.

@Override
public void openAnvilGUI(Player player, Object con, String title, ItemStack[] items) {
    ContainerAnvil container = (ContainerAnvil) con;
    EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
    int id = container.windowId;
    net.minecraft.server.v1_16_R2.ItemStack[] nmsItems = new net.minecraft.server.v1_16_R2.ItemStack[items.length];
    for (int i = 0; i < items.length; ++i) {
        ItemStack is = items[i];
        if (is == null || is.getType() == Material.AIR)
            continue;
        net.minecraft.server.v1_16_R2.ItemStack item = null;
        container.setItem(i, item = (net.minecraft.server.v1_16_R2.ItemStack) asNMSItem(is));
        nmsItems[i] = item;
    }
    BukkitLoader.getPacketHandler().send(player, packetOpenWindow(id, "minecraft:anvil", 0, title));
    int i = 0;
    for (net.minecraft.server.v1_16_R2.ItemStack o : nmsItems) BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, i++, o));
    nmsPlayer.activeContainer.transferTo((Container) container, (CraftPlayer) player);
    nmsPlayer.activeContainer = (Container) container;
    ((Container) container).addSlotListener(nmsPlayer);
    container.checkReachable = false;
}
Also used : Container(net.minecraft.server.v1_16_R2.Container) CraftContainer(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftContainer) ContainerAnvil(net.minecraft.server.v1_16_R2.ContainerAnvil) EntityPlayer(net.minecraft.server.v1_16_R2.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer) CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack)

Example 19 with net.minecraft.server.v1_16_R2

use of net.minecraft.server.v1_16_R2 in project SilkSpawners by timbru31.

the class NMSHandler method setNBTEntityID.

@Override
public ItemStack setNBTEntityID(final ItemStack item, final String entity) {
    if (item == null || StringUtils.isBlank(entity)) {
        Bukkit.getLogger().warning("[SilkSpawners] Skipping invalid spawner to set NBT data on.");
        return null;
    }
    String prefixedEntity;
    if (!entity.startsWith("minecraft:")) {
        prefixedEntity = "minecraft:" + entity;
    } else {
        prefixedEntity = entity;
    }
    net.minecraft.server.v1_16_R2.ItemStack itemStack = null;
    final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    NBTTagCompound tag = itemStack.getOrCreateTag();
    // Check for SilkSpawners key
    if (!tag.hasKey("SilkSpawners")) {
        tag.set("SilkSpawners", new NBTTagCompound());
    }
    tag.getCompound("SilkSpawners").setString("entity", entity);
    // Check for Vanilla keys
    if (!tag.hasKey("BlockEntityTag")) {
        tag.set("BlockEntityTag", new NBTTagCompound());
    }
    tag = tag.getCompound("BlockEntityTag");
    // EntityId - Deprecated in 1.9
    tag.setString("EntityId", entity);
    tag.setString("id", TileEntityTypes.a(TileEntityTypes.MOB_SPAWNER).getKey());
    // SpawnData
    if (!tag.hasKey("SpawnData")) {
        tag.set("SpawnData", new NBTTagCompound());
    }
    tag.getCompound("SpawnData").setString("id", prefixedEntity);
    if (!tag.hasKey("SpawnPotentials")) {
        tag.set("SpawnPotentials", new NBTTagCompound());
    }
    // SpawnEgg data
    if (!tag.hasKey("EntityTag")) {
        tag.set("EntityTag", new NBTTagCompound());
    }
    tag.getCompound("EntityTag").setString("id", prefixedEntity);
    return CraftItemStack.asCraftMirror(itemStack);
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound)

Example 20 with net.minecraft.server.v1_16_R2

use of net.minecraft.server.v1_16_R2 in project SilkSpawners by timbru31.

the class NMSHandler method getVanillaNBTEntityID.

@Override
@Nullable
public String getVanillaNBTEntityID(final ItemStack item) {
    net.minecraft.server.v1_16_R2.ItemStack itemStack = null;
    final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    NBTTagCompound tag = itemStack.getTag();
    if (tag == null || !tag.hasKey("BlockEntityTag")) {
        return null;
    }
    tag = tag.getCompound("BlockEntityTag");
    if (tag.hasKey("EntityId")) {
        return tag.getString("EntityId");
    } else if (tag.hasKey("SpawnData") && tag.getCompound("SpawnData").hasKey("id")) {
        return tag.getCompound("SpawnData").getString("id");
    } else if (tag.hasKey("SpawnPotentials") && !tag.getList("SpawnPotentials", 8).isEmpty()) {
        return tag.getList("SpawnPotentials", 8).getCompound(0).getCompound("Entity").getString("id");
    } else {
        return null;
    }
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound) Nullable(javax.annotation.Nullable)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack)11 NBTTagCompound (net.minecraft.server.v1_16_R2.NBTTagCompound)9 ItemStack (org.bukkit.inventory.ItemStack)7 CraftChunk (org.bukkit.craftbukkit.v1_16_R2.CraftChunk)4 Container (net.minecraft.server.v1_16_R2.Container)3 EntityPlayer (net.minecraft.server.v1_16_R2.EntityPlayer)3 Chunk (org.bukkit.Chunk)3 CraftPlayer (org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer)3 CraftContainer (org.bukkit.craftbukkit.v1_16_R2.inventory.CraftContainer)3 PacketContainer (com.comphenix.protocol.events.PacketContainer)2 Pair (com.mojang.datafixers.util.Pair)2 ArrayList (java.util.ArrayList)2 Nullable (javax.annotation.Nullable)2 net.minecraft.server.v1_16_R2 (net.minecraft.server.v1_16_R2)2 BlockPosition (net.minecraft.server.v1_16_R2.BlockPosition)2 ChunkSection (net.minecraft.server.v1_16_R2.ChunkSection)2 ContainerAnvil (net.minecraft.server.v1_16_R2.ContainerAnvil)2 EnumItemSlot (net.minecraft.server.v1_16_R2.EnumItemSlot)2 PacketPlayOutEntityEquipment (net.minecraft.server.v1_16_R2.PacketPlayOutEntityEquipment)2 Material (org.bukkit.Material)2