Package net.minecraft.server.v1_7_R4

Examples of net.minecraft.server.v1_7_R4.DataWatcher


        PacketPlayOutUpdateHealth healthPacket = getHealthPacket(health, food, food_saturation);
        PacketHelper.sendPacket(player, healthPacket);
    }

    public static void showExperience(Player player, float experience, int level) {
        PacketPlayOutExperience experiencePacket = getExperiencePacket(experience, level);
        PacketHelper.sendPacket(player, experiencePacket);
    }
View Full Code Here


        PacketPlayOutExperience experiencePacket = getExperiencePacket(experience, level);
        PacketHelper.sendPacket(player, experiencePacket);
    }

    public static void resetExperience(Player player) {
        PacketPlayOutExperience experiencePacket = getExperiencePacket(player.getExp(), player.getLevel());
        PacketHelper.sendPacket(player, experiencePacket);
    }
View Full Code Here

    }

    @Override
    public void handlePacket(Object packet, Player destination) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
        if (packet instanceof PacketPlayOutNamedEntitySpawn) {
            final PacketPlayOutNamedEntitySpawn p = (PacketPlayOutNamedEntitySpawn) packet;
            final GameProfile profile = (GameProfile) this.gameProfileField.get(p);
            final String oldName = profile.getName();
            final UUID oldID = profile.getId();
            final TagInfo newName = this.handler.getNameForPacket20(oldID, this.entityIDField.getInt(p), oldName, destination);
            if (newName != null && !newName.getName().equals(oldName)) {
View Full Code Here

    }

    private static final Map<UUID, Integer> slotChanged = new HashMap<UUID, Integer>();

    public static PacketPlayOutSetSlot getSlotPacket(UUID player, int nmsSlot, ItemStack item) {
        PacketPlayOutSetSlot slotPacket = new PacketPlayOutSetSlot();
        try{
            slot_inventoryId.set(slotPacket, 0);
            slotChanged.put(player, nmsSlot);
            slot_slotId.set(slotPacket, nmsSlot);
            slot_item.set(slotPacket, CraftItemStack.asNMSCopy(item));
View Full Code Here

        else
            item = item.clone();
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(message);
        item.setItemMeta(meta);
        PacketPlayOutSetSlot slotPacket = getSlotPacket(player.getUniqueId(),
                player.getInventory().getHeldItemSlot() + 36, item);
        PacketHelper.sendPacket(player, slotPacket);
    }
View Full Code Here

    public static void resetItem(Player player) {
        if (player == null) return;
        UUID uuid = player.getUniqueId();
        if (slotChanged.containsKey(uuid)) {
            PacketPlayOutSetSlot slotPacket = getSlotPacket(uuid, slotChanged.get(uuid), player.getItemInHand());
            PacketHelper.sendPacket(player, slotPacket);
            slotChanged.remove(uuid);
        }
    }
View Full Code Here

    }

    //Accessing packets
    @SuppressWarnings("deprecation")
    public static PacketPlayOutSpawnEntityLiving getMobPacket(String text, Location loc, int health) {
        PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
        try {
            spawn_entityId.set(mobPacket, ENTITY_ID);
            spawn_entityType.set(mobPacket, (byte) EntityType.ENDER_DRAGON.getTypeId());
            spawn_locationX.set(mobPacket, (int) Math.floor(loc.getBlockX() * 32.0D));
            spawn_locationY.set(mobPacket, -256 * 32);
 
View Full Code Here

        return watcher;
    }

    //Other methods
    public static void displayTextBar(String text, final Player player, int health) {
        PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(text, player.getLocation(), health);
        PacketHelper.sendPacket(player, mobPacket);
        hasHealthBar.put(player.getName(), true);
    }
View Full Code Here

            hasHealthBar.put(player.getName(), false);
        }
    }

    public static void displayLoadingBar(final String text, final String completeText, final Player player, final int healthAdd, final long delay, final boolean loadUp) {
        PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(text, player.getLocation(), 200);
        PacketHelper.sendPacket(player, mobPacket);
        hasHealthBar.put(player.getName(), true);
        new BukkitRunnable() {
            int health = (loadUp ? 0 : 300);

            @Override
            public void run() {
                if ((loadUp ? health < 300 : health > 0)) {
                    DataWatcher watcher = getWatcher(text, health);
                    PacketPlayOutEntityMetadata metaPacket = getMetadataPacket(watcher);
                    PacketHelper.sendPacket(player, metaPacket);
                    if (loadUp) {
                        health += healthAdd;
                    } else {
                        health -= healthAdd;
                    }
                } else {
                    DataWatcher watcher = getWatcher(text, (loadUp ? 300 : 0));
                    PacketPlayOutEntityMetadata metaPacket = getMetadataPacket(watcher);
                    PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
                    PacketHelper.sendPacket(player, metaPacket);
                    PacketHelper.sendPacket(player, destroyEntityPacket);
                    hasHealthBar.put(player.getName(), false);
//Complete text
                    PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(completeText, player.getLocation(), 200);
                    PacketHelper.sendPacket(player, mobPacket);
                    hasHealthBar.put(player.getName(), true);
                    DataWatcher watcher2 = getWatcher(completeText, 300);
                    PacketPlayOutEntityMetadata metaPacket2 = getMetadataPacket(watcher2);
                    PacketHelper.sendPacket(player, metaPacket2);
View Full Code Here

        }
        return experiencePacket;
    }

    public static PacketPlayOutUpdateHealth getHealthPacket(float health, int food, float food_saturation) {
        PacketPlayOutUpdateHealth healthPacket = new PacketPlayOutUpdateHealth();
        try {
            health_health.set(healthPacket, health);
            health_food.set(healthPacket, food);
            health_saturation.set(healthPacket, food_saturation);
View Full Code Here

TOP

Related Classes of net.minecraft.server.v1_7_R4.DataWatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.