Search in sources :

Example 1 with net.minecraft.server.v1_9_R2

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

the class EntityHelper_v1_9_R2 method unhideEntity.

@Override
public void unhideEntity(Player player, Entity entity) {
    // Use Bukkit API for Player entities
    if (entity instanceof Player) {
        player.showPlayer((Player) entity);
        return;
    }
    CraftPlayer craftPlayer = (CraftPlayer) player;
    EntityPlayer entityPlayer = craftPlayer.getHandle();
    UUID playerUUID = player.getUniqueId();
    if (entityPlayer.playerConnection != null && !craftPlayer.equals(entity) && hiddenEntities.containsKey(playerUUID)) {
        Set hidden = hiddenEntities.get(playerUUID);
        UUID entityUUID = entity.getUniqueId();
        if (hidden.contains(entityUUID)) {
            hidden.remove(entityUUID);
            EntityTracker tracker = ((WorldServer) craftPlayer.getHandle().world).tracker;
            net.minecraft.server.v1_9_R2.Entity other = ((CraftEntity) entity).getHandle();
            EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId());
            if (entry != null && !entry.trackedPlayers.contains(entityPlayer)) {
                entry.updatePlayer(entityPlayer);
            }
        }
    }
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) HashSet(java.util.HashSet) Set(java.util.Set) net.minecraft.server.v1_9_R2(net.minecraft.server.v1_9_R2) CompoundTag_v1_9_R2(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_9_R2) CraftEntity(org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) UUID(java.util.UUID)

Example 2 with net.minecraft.server.v1_9_R2

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

the class EntityHelper_v1_9_R2 method walkTo.

@Override
public void walkTo(final Entity entity, Location location, double speed, final Runnable callback) {
    if (entity == null || location == null) {
        return;
    }
    net.minecraft.server.v1_9_R2.Entity nmsEntityEntity = ((CraftEntity) entity).getHandle();
    if (!(nmsEntityEntity instanceof EntityInsentient)) {
        return;
    }
    final EntityInsentient nmsEntity = (EntityInsentient) nmsEntityEntity;
    final NavigationAbstract entityNavigation = nmsEntity.getNavigation();
    final PathEntity path;
    final boolean aiDisabled = isAIDisabled(entity);
    if (aiDisabled) {
        toggleAI(entity, true);
        nmsEntity.onGround = true;
    }
    path = entityNavigation.a(location.getX(), location.getY(), location.getZ());
    if (path != null) {
        entityNavigation.a(path, 1D);
        entityNavigation.a(2D);
        final double oldSpeed = nmsEntity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).b();
        nmsEntity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(speed);
        new BukkitRunnable() {

            @Override
            public void run() {
                if (entityNavigation.n() || path.b()) {
                    if (callback != null) {
                        callback.run();
                    }
                    nmsEntity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(oldSpeed);
                    if (aiDisabled) {
                        toggleAI(entity, false);
                    }
                    cancel();
                }
            }
        }.runTaskTimer(NMSHandler.getJavaPlugin(), 1, 1);
    } else //if (!Utilities.checkLocation(location, entity.getLocation(), 20)) {
    // TODO: generate waypoints to the target location?
    {
        entity.teleport(location);
    }
}
Also used : net.minecraft.server.v1_9_R2(net.minecraft.server.v1_9_R2) CompoundTag_v1_9_R2(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_9_R2) CraftEntity(org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Example 3 with net.minecraft.server.v1_9_R2

use of net.minecraft.server.v1_9_R2 in project acidisland 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_9_R2.ItemStack cis = CraftItemStack.asNMSCopy(itemStack);
    te.a(cis.getItem(), cis.getData());
    te.update();
}
Also used : BlockPosition(net.minecraft.server.v1_9_R2.BlockPosition) TileEntityFlowerPot(net.minecraft.server.v1_9_R2.TileEntityFlowerPot) CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld) Location(org.bukkit.Location)

Example 4 with net.minecraft.server.v1_9_R2

use of net.minecraft.server.v1_9_R2 in project acidisland by tastybento.

the class NMSHandler method getSpawnEgg.

/**
 * Get spawn egg
 * @param type
 * @param amount
 * @return
 */
@SuppressWarnings("deprecation")
public ItemStack getSpawnEgg(EntityType type, int amount) {
    ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
    net.minecraft.server.v1_9_R2.ItemStack stack = CraftItemStack.asNMSCopy(item);
    NBTTagCompound tagCompound = stack.getTag();
    if (tagCompound == null) {
        tagCompound = new NBTTagCompound();
    }
    NBTTagCompound id = new NBTTagCompound();
    id.setString("id", type.getName());
    tagCompound.set("EntityTag", id);
    stack.setTag(tagCompound);
    return CraftItemStack.asBukkitCopy(stack);
}
Also used : NBTTagCompound(net.minecraft.server.v1_9_R2.NBTTagCompound) ItemStack(org.bukkit.inventory.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack)

Example 5 with net.minecraft.server.v1_9_R2

use of net.minecraft.server.v1_9_R2 in project acidisland by tastybento.

the class NMSHandler method setBlockSuperFast.

@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_9_R2.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_9_R2.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_9_R2.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_9_R2.IBlockData) BlockPosition(net.minecraft.server.v1_9_R2.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld)

Aggregations

CompoundTag_v1_9_R2 (net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_9_R2)6 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)6 net.minecraft.server.v1_9_R2 (net.minecraft.server.v1_9_R2)4 CraftEntity (org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity)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 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 BlockPosition (net.minecraft.server.v1_9_R2.BlockPosition)2 NBTTagString (net.minecraft.server.v1_9_R2.NBTTagString)2 Location (org.bukkit.Location)2 CraftWorld (org.bukkit.craftbukkit.v1_9_R2.CraftWorld)2 CraftPlayer (org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)2 CraftItemStack (org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack)2 ItemStack (org.bukkit.inventory.ItemStack)2 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)2