Search in sources :

Example 11 with net.minecraft.server.v1_8_R3

use of net.minecraft.server.v1_8_R3 in project NoCheatPlus by NoCheatPlus.

the class BlockCacheSpigotCB1_8_R3 method fetchBounds.

@Override
public double[] fetchBounds(final int x, final int y, final int z) {
    @SuppressWarnings("deprecation") final int id = getType(x, y, z).getId();
    final net.minecraft.server.v1_8_R3.Block block = net.minecraft.server.v1_8_R3.Block.getById(id);
    if (block == null) {
        // TODO: Convention for null bounds -> full ?
        return null;
    }
    block.updateShape(world, new BlockPosition(x, y, z));
    // minX, minY, minZ, maxX, maxY, maxZ
    return new double[] { block.B(), block.D(), block.F(), block.C(), block.E(), block.G() };
}
Also used : BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition)

Example 12 with net.minecraft.server.v1_8_R3

use of net.minecraft.server.v1_8_R3 in project askyblock by tastybento.

the class NMSHandler method setBook.

@Override
public ItemStack setBook(Tag item) {
    ItemStack chestItem = new ItemStack(Material.WRITTEN_BOOK);
    // Bukkit.getLogger().info(item.toString());
    if (((CompoundTag) item).getValue().containsKey("tag")) {
        Map<String, Tag> contents = (Map<String, Tag>) ((CompoundTag) item).getValue().get("tag").getValue();
        // BookMeta bookMeta = (BookMeta) chestItem.getItemMeta();
        String author = "";
        if (contents.containsKey("author")) {
            author = ((StringTag) contents.get("author")).getValue();
        }
        // Bukkit.getLogger().info("Author: " + author);
        // bookMeta.setAuthor(author);
        String title = "";
        if (contents.containsKey("title")) {
            title = ((StringTag) contents.get("title")).getValue();
        }
        // Bukkit.getLogger().info("Title: " + title);
        // bookMeta.setTitle(title);
        List<String> lore = new ArrayList<String>();
        if (contents.containsKey("display")) {
            Map<String, Tag> display = (Map<String, Tag>) (contents.get("display")).getValue();
            List<Tag> loreTag = ((ListTag) display.get("Lore")).getValue();
            for (Tag s : loreTag) {
                lore.add(((StringTag) s).getValue());
            }
        }
        // Bukkit.getLogger().info("Lore: " + lore);
        net.minecraft.server.v1_8_R3.ItemStack stack = CraftItemStack.asNMSCopy(chestItem);
        // Pages
        // Create the NMS Stack's NBT (item data)
        NBTTagCompound tag = new NBTTagCompound();
        // Set the book's title
        tag.setString("title", title);
        tag.setString("author", author);
        if (contents.containsKey("pages")) {
            NBTTagList pages = new NBTTagList();
            List<Tag> pagesTag = ((ListTag) contents.get("pages")).getValue();
            for (Tag s : pagesTag) {
                pages.add(new NBTTagString(((StringTag) s).getValue()));
            }
            // Add the pages to the tag
            tag.set("pages", pages);
        }
        // Apply the tag to the item
        stack.setTag(tag);
        chestItem = CraftItemStack.asCraftMirror(stack);
        ItemMeta bookMeta = (ItemMeta) chestItem.getItemMeta();
        bookMeta.setLore(lore);
        chestItem.setItemMeta(bookMeta);
    }
    return chestItem;
}
Also used : StringTag(com.wasteofplastic.org.jnbt.StringTag) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) NBTTagString(net.minecraft.server.v1_8_R3.NBTTagString) ListTag(com.wasteofplastic.org.jnbt.ListTag) NBTTagList(net.minecraft.server.v1_8_R3.NBTTagList) NBTTagString(net.minecraft.server.v1_8_R3.NBTTagString) StringTag(com.wasteofplastic.org.jnbt.StringTag) CompoundTag(com.wasteofplastic.org.jnbt.CompoundTag) Tag(com.wasteofplastic.org.jnbt.Tag) ListTag(com.wasteofplastic.org.jnbt.ListTag) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) Map(java.util.Map) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 13 with net.minecraft.server.v1_8_R3

use of net.minecraft.server.v1_8_R3 in project askyblock by tastybento.

the class NMSHandler method setBlockSuperFast.

@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_8_R3.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_8_R3.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
    int combined = blockId + (data << 12);
    IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getByCombinedId(combined);
    if (applyPhysics) {
        w.setTypeAndData(bp, ibd, 3);
    } else {
        w.setTypeAndData(bp, ibd, 2);
    }
    chunk.a(bp, ibd);
}
Also used : IBlockData(net.minecraft.server.v1_8_R3.IBlockData) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 14 with net.minecraft.server.v1_8_R3

use of net.minecraft.server.v1_8_R3 in project Denizen-For-Bukkit by DenizenScript.

the class EntityHelper_v1_8_R3 method hideEntity.

@Override
public void hideEntity(Player player, Entity entity, boolean keepInTabList) {
    // Use Bukkit API for Player entities
    if (entity instanceof Player) {
        player.hidePlayer((Player) entity);
        return;
    }
    CraftPlayer craftPlayer = (CraftPlayer) player;
    EntityPlayer entityPlayer = craftPlayer.getHandle();
    UUID playerUUID = player.getUniqueId();
    if (entityPlayer.playerConnection != null && !craftPlayer.equals(entity)) {
        if (!hiddenEntities.containsKey(playerUUID)) {
            hiddenEntities.put(playerUUID, new HashSet<UUID>());
        }
        Set hidden = hiddenEntities.get(playerUUID);
        UUID entityUUID = entity.getUniqueId();
        if (!hidden.contains(entityUUID)) {
            hidden.add(entityUUID);
            EntityTracker tracker = ((WorldServer) craftPlayer.getHandle().world).tracker;
            net.minecraft.server.v1_8_R3.Entity other = ((CraftEntity) entity).getHandle();
            EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId());
            if (entry != null) {
                entry.clear(entityPlayer);
            }
        }
    }
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) HashSet(java.util.HashSet) Set(java.util.Set) CraftEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) UUID(java.util.UUID) CompoundTag_v1_8_R3(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3) net.minecraft.server.v1_8_R3(net.minecraft.server.v1_8_R3)

Example 15 with net.minecraft.server.v1_8_R3

use of net.minecraft.server.v1_8_R3 in project askyblock by tastybento.

the class NMSHandler method setFlowerPotBlock.

/* (non-Javadoc)
     * @see com.wasteofplastic.askyblock.nms.NMSAbstraction#setBlock(org.bukkit.block.Block, org.bukkit.inventory.ItemStack)
     * Credis: Mister_Frans (THANK YOU VERY MUCH !)
     */
@Override
public void setFlowerPotBlock(Block block, ItemStack itemStack) {
    Location loc = block.getLocation();
    CraftWorld cw = (CraftWorld) block.getWorld();
    BlockPosition bp = new BlockPosition(loc.getX(), loc.getY(), loc.getZ());
    TileEntityFlowerPot te = (TileEntityFlowerPot) cw.getHandle().getTileEntity(bp);
    // Bukkit.getLogger().info("Debug: flowerpot materialdata = " + (new ItemStack(potItem, 1,(short) potItemData).toString()));
    net.minecraft.server.v1_8_R3.ItemStack cis = CraftItemStack.asNMSCopy(itemStack);
    te.a(cis.getItem(), cis.getData());
    te.update();
}
Also used : BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) TileEntityFlowerPot(net.minecraft.server.v1_8_R3.TileEntityFlowerPot) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) Location(org.bukkit.Location)

Aggregations

CraftEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity)7 CompoundTag_v1_8_R3 (net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3)6 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)5 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)5 net.minecraft.server.v1_8_R3 (net.minecraft.server.v1_8_R3)4 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)4 UUID (java.util.UUID)3 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)2 ListTag (com.wasteofplastic.org.jnbt.ListTag)2 StringTag (com.wasteofplastic.org.jnbt.StringTag)2 Tag (com.wasteofplastic.org.jnbt.Tag)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 AxisAlignedBB (net.minecraft.server.v1_8_R3.AxisAlignedBB)2 IBlockData (net.minecraft.server.v1_8_R3.IBlockData)2 NBTTagList (net.minecraft.server.v1_8_R3.NBTTagList)2 NBTTagString (net.minecraft.server.v1_8_R3.NBTTagString)2 TileEntityFlowerPot (net.minecraft.server.v1_8_R3.TileEntityFlowerPot)2