Search in sources :

Example 1 with ListTag

use of net.aufdemrand.denizen.nms.util.jnbt.ListTag in project Denizen-For-Bukkit by DenizenScript.

the class ImprovedOfflinePlayer method setLocation.

public void setLocation(Location location) {
    World w = location.getWorld();
    UUID uuid = w.getUID();
    List<DoubleTag> position = new ArrayList<DoubleTag>();
    position.add(new DoubleTag(location.getX()));
    position.add(new DoubleTag(location.getY()));
    position.add(new DoubleTag(location.getZ()));
    List<FloatTag> rotation = new ArrayList<FloatTag>();
    rotation.add(new FloatTag(location.getYaw()));
    rotation.add(new FloatTag(location.getPitch()));
    this.compound = this.compound.createBuilder().putLong("WorldUUIDMost", uuid.getMostSignificantBits()).putLong("WorldUUIDLeast", uuid.getLeastSignificantBits()).putInt("Dimension", w.getEnvironment().ordinal()).put("Pos", new ListTag(DoubleTag.class, position)).put("Rotation", new ListTag(FloatTag.class, rotation)).build();
    if (this.autosave) {
        savePlayerData();
    }
}
Also used : FloatTag(net.aufdemrand.denizen.nms.util.jnbt.FloatTag) ArrayList(java.util.ArrayList) World(org.bukkit.World) UUID(java.util.UUID) DoubleTag(net.aufdemrand.denizen.nms.util.jnbt.DoubleTag) ListTag(net.aufdemrand.denizen.nms.util.jnbt.ListTag)

Example 2 with ListTag

use of net.aufdemrand.denizen.nms.util.jnbt.ListTag in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelper_v1_10_R1 method showBannerUpdate.

@Override
public void showBannerUpdate(Player player, Location location, DyeColor base, List<Pattern> patterns) {
    List<CompoundTag> nbtPatterns = new ArrayList<CompoundTag>();
    for (Pattern pattern : patterns) {
        nbtPatterns.add(NMSHandler.getInstance().createCompoundTag(new HashMap<String, Tag>()).createBuilder().putInt("Color", pattern.getColor().getDyeData()).putString("Pattern", pattern.getPattern().getIdentifier()).build());
    }
    CompoundTag compoundTag = NMSHandler.getInstance().getBlockHelper().getNbtData(location.getBlock()).createBuilder().putInt("Base", base.getDyeData()).put("Patterns", new ListTag(CompoundTag.class, nbtPatterns)).build();
    showTileEntityData(player, location, 3, compoundTag);
}
Also used : Pattern(org.bukkit.block.banner.Pattern) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListTag(net.aufdemrand.denizen.nms.util.jnbt.ListTag) CompoundTag(net.aufdemrand.denizen.nms.util.jnbt.CompoundTag)

Example 3 with ListTag

use of net.aufdemrand.denizen.nms.util.jnbt.ListTag in project Denizen-For-Bukkit by DenizenScript.

the class ImprovedOfflinePlayer method setVelocity.

public void setVelocity(Vector vector) {
    List<DoubleTag> motion = new ArrayList<DoubleTag>();
    motion.add(new DoubleTag(vector.getX()));
    motion.add(new DoubleTag(vector.getY()));
    motion.add(new DoubleTag(vector.getZ()));
    this.compound = compound.createBuilder().put("Motion", new ListTag(DoubleTag.class, motion)).build();
    if (this.autosave) {
        savePlayerData();
    }
}
Also used : ArrayList(java.util.ArrayList) DoubleTag(net.aufdemrand.denizen.nms.util.jnbt.DoubleTag) ListTag(net.aufdemrand.denizen.nms.util.jnbt.ListTag)

Example 4 with ListTag

use of net.aufdemrand.denizen.nms.util.jnbt.ListTag in project Denizen-For-Bukkit by DenizenScript.

the class ImprovedOfflinePlayer method getLocation.

public Location getLocation() {
    ListTag position = this.compound.getListTag("Pos");
    ListTag rotation = this.compound.getListTag("Rotation");
    return new Location(Bukkit.getWorld(new UUID(this.compound.getLong("WorldUUIDMost"), this.compound.getLong("WorldUUIDLeast"))), position.getDouble(0), position.getDouble(1), position.getDouble(2), rotation.getFloat(0), rotation.getFloat(1));
}
Also used : UUID(java.util.UUID) ListTag(net.aufdemrand.denizen.nms.util.jnbt.ListTag) Location(org.bukkit.Location)

Example 5 with ListTag

use of net.aufdemrand.denizen.nms.util.jnbt.ListTag in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelper_v1_8_R3 method showBannerUpdate.

@Override
public void showBannerUpdate(Player player, Location location, DyeColor base, List<Pattern> patterns) {
    List<CompoundTag> nbtPatterns = new ArrayList<CompoundTag>();
    for (Pattern pattern : patterns) {
        nbtPatterns.add(NMSHandler.getInstance().createCompoundTag(new HashMap<String, Tag>()).createBuilder().putInt("Color", pattern.getColor().getDyeData()).putString("Pattern", pattern.getPattern().getIdentifier()).build());
    }
    CompoundTag compoundTag = NMSHandler.getInstance().getBlockHelper().getNbtData(location.getBlock()).createBuilder().putInt("Base", base.getDyeData()).put("Patterns", new ListTag(CompoundTag.class, nbtPatterns)).build();
    showTileEntityData(player, location, 3, compoundTag);
}
Also used : Pattern(org.bukkit.block.banner.Pattern) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListTag(net.aufdemrand.denizen.nms.util.jnbt.ListTag) CompoundTag(net.aufdemrand.denizen.nms.util.jnbt.CompoundTag)

Aggregations

ListTag (net.aufdemrand.denizen.nms.util.jnbt.ListTag)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)4 CompoundTag (net.aufdemrand.denizen.nms.util.jnbt.CompoundTag)4 Pattern (org.bukkit.block.banner.Pattern)4 UUID (java.util.UUID)2 DoubleTag (net.aufdemrand.denizen.nms.util.jnbt.DoubleTag)2 FloatTag (net.aufdemrand.denizen.nms.util.jnbt.FloatTag)1 Location (org.bukkit.Location)1 World (org.bukkit.World)1