Search in sources :

Example 1 with World

use of net.minecraft.server.v1_9_R2.World 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 World

use of net.minecraft.server.v1_9_R2.World in project SpaciousLib by anhcraft.

the class Title_1_9_R2 method sendSubTitle.

@Override
public void sendSubTitle(World world, String text) {
    for (Player player : world.getPlayers()) {
        PacketPlayOutTitle title = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', text) + "\"}"));
        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
    }
}
Also used : PacketPlayOutTitle(net.minecraft.server.v1_9_R2.PacketPlayOutTitle) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)

Example 3 with World

use of net.minecraft.server.v1_9_R2.World in project MyPet by xXKeyleXx.

the class EntityRegistry method createMinecraftEntity.

@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
    EntityMyPet petEntity = null;
    Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
    World world = ((CraftWorld) bukkitWorld).getHandle();
    try {
        Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
        Object obj = ctor.newInstance(world, pet);
        if (obj instanceof EntityMyPet) {
            petEntity = (EntityMyPet) obj;
        }
    } catch (Exception e) {
        MyPetApi.getLogger().info(ChatColor.RED + entityClass.getName() + " is no valid MyPet(Entity)!");
        e.printStackTrace();
    }
    return petEntity;
}
Also used : World(net.minecraft.server.v1_8_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld)

Example 4 with World

use of net.minecraft.server.v1_9_R2.World in project MyPet by xXKeyleXx.

the class EntityRegistry method createMinecraftEntity.

@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
    EntityMyPet petEntity = null;
    Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
    World world = ((CraftWorld) bukkitWorld).getHandle();
    try {
        Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
        Object obj = ctor.newInstance(world, pet);
        if (obj instanceof EntityMyPet) {
            petEntity = (EntityMyPet) obj;
        }
    } catch (Exception e) {
        MyPetApi.getLogger().info(ChatColor.RED + entityClass.getName() + " is no valid MyPet(Entity)!");
        e.printStackTrace();
    }
    return petEntity;
}
Also used : CraftWorld(org.bukkit.craftbukkit.v1_8_R2.CraftWorld) World(net.minecraft.server.v1_8_R2.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R2.CraftWorld)

Example 5 with World

use of net.minecraft.server.v1_9_R2.World in project MyPet by xXKeyleXx.

the class EntityRegistry method createMinecraftEntity.

@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
    EntityMyPet petEntity = null;
    Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
    World world = ((CraftWorld) bukkitWorld).getHandle();
    try {
        Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
        Object obj = ctor.newInstance(world, pet);
        if (obj instanceof EntityMyPet) {
            petEntity = (EntityMyPet) obj;
        }
    } catch (Exception e) {
        MyPetApi.getLogger().info(ChatColor.RED + entityClass.getName() + " is no valid MyPet(Entity)!");
        e.printStackTrace();
    }
    return petEntity;
}
Also used : World(net.minecraft.server.v1_9_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_9_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_9_R1.CraftWorld)

Aggregations

CraftPlayer (org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)7 Player (org.bukkit.entity.Player)5 PacketPlayOutTitle (net.minecraft.server.v1_9_R2.PacketPlayOutTitle)4 CraftWorld (org.bukkit.craftbukkit.v1_9_R2.CraftWorld)4 UUID (java.util.UUID)3 BlockPosition (net.minecraft.server.v1_9_R2.BlockPosition)3 HashSet (java.util.HashSet)2 Set (java.util.Set)2 CompoundTag_v1_9_R2 (net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_9_R2)2 World (net.minecraft.server.v1_7_R4.World)2 net.minecraft.server.v1_9_R2 (net.minecraft.server.v1_9_R2)2 IBlockData (net.minecraft.server.v1_9_R2.IBlockData)2 CraftEntity (org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity)2 GameProfile (com.mojang.authlib.GameProfile)1 Property (com.mojang.authlib.properties.Property)1 BigInteger (java.math.BigInteger)1 MessageDigest (java.security.MessageDigest)1 CraftFakePlayer_v1_9_R2 (net.aufdemrand.denizen.nms.impl.entities.CraftFakePlayer_v1_9_R2)1 EntityFakePlayer_v1_9_R2 (net.aufdemrand.denizen.nms.impl.entities.EntityFakePlayer_v1_9_R2)1 PlayerProfile (net.aufdemrand.denizen.nms.util.PlayerProfile)1