Search in sources :

Example 1 with DoubleTag

use of com.sk89q.jnbt.DoubleTag in project FastAsyncWorldEdit by IntellectualSites.

the class MutableEntityChange method create.

public void create(UndoContext context) {
    Map<String, Tag> map = tag.getValue();
    Tag posTag = map.get("Pos");
    if (posTag == null) {
        LOGGER.warn("Missing pos tag: {}", tag);
        return;
    }
    List<DoubleTag> pos = (List<DoubleTag>) posTag.getValue();
    double x = pos.get(0).getValue();
    double y = pos.get(1).getValue();
    double z = pos.get(2).getValue();
    Extent extent = context.getExtent();
    Location location = new Location(extent, x, y, z, 0, 0);
    String id = tag.getString("Id");
    EntityType type = EntityTypes.parse(id);
    BaseEntity entity = new BaseEntity(type, tag);
    context.getExtent().createEntity(location, entity);
}
Also used : EntityType(com.sk89q.worldedit.world.entity.EntityType) Extent(com.sk89q.worldedit.extent.Extent) BaseEntity(com.sk89q.worldedit.entity.BaseEntity) List(java.util.List) DoubleTag(com.sk89q.jnbt.DoubleTag) CompoundTag(com.sk89q.jnbt.CompoundTag) Tag(com.sk89q.jnbt.Tag) LongTag(com.sk89q.jnbt.LongTag) DoubleTag(com.sk89q.jnbt.DoubleTag) Location(com.sk89q.worldedit.util.Location)

Example 2 with DoubleTag

use of com.sk89q.jnbt.DoubleTag in project FastAsyncWorldEdit by IntellectualSites.

the class ClipboardWriter method writeVector.

// FAWE start
default Tag writeVector(Vector3 vector) {
    List<DoubleTag> list = new ArrayList<>();
    list.add(new DoubleTag(vector.getX()));
    list.add(new DoubleTag(vector.getY()));
    list.add(new DoubleTag(vector.getZ()));
    return new ListTag(DoubleTag.class, list);
}
Also used : ArrayList(java.util.ArrayList) DoubleTag(com.sk89q.jnbt.DoubleTag) ListTag(com.sk89q.jnbt.ListTag)

Example 3 with DoubleTag

use of com.sk89q.jnbt.DoubleTag in project FastAsyncWorldEdit by IntellectualSites.

the class MutableEntityChange method delete.

@SuppressWarnings({ "unchecked" })
public void delete(UndoContext context) {
    Map<String, Tag> map = tag.getValue();
    long most;
    long least;
    if (map.containsKey("UUIDMost")) {
        most = ((LongTag) map.get("UUIDMost")).getValue();
        least = ((LongTag) map.get("UUIDLeast")).getValue();
    } else if (map.containsKey("PersistentIDMSB")) {
        most = ((LongTag) map.get("PersistentIDMSB")).getValue();
        least = ((LongTag) map.get("PersistentIDLSB")).getValue();
    } else {
        LOGGER.info("Skipping entity without uuid.");
        return;
    }
    List<DoubleTag> pos = (List<DoubleTag>) map.get("Pos").getValue();
    int x = MathMan.roundInt(pos.get(0).getValue());
    int y = MathMan.roundInt(pos.get(1).getValue());
    int z = MathMan.roundInt(pos.get(2).getValue());
    UUID uuid = new UUID(most, least);
    context.getExtent().removeEntity(x, y, z, uuid);
}
Also used : List(java.util.List) DoubleTag(com.sk89q.jnbt.DoubleTag) CompoundTag(com.sk89q.jnbt.CompoundTag) Tag(com.sk89q.jnbt.Tag) LongTag(com.sk89q.jnbt.LongTag) DoubleTag(com.sk89q.jnbt.DoubleTag) UUID(java.util.UUID) LongTag(com.sk89q.jnbt.LongTag)

Aggregations

DoubleTag (com.sk89q.jnbt.DoubleTag)3 CompoundTag (com.sk89q.jnbt.CompoundTag)2 LongTag (com.sk89q.jnbt.LongTag)2 Tag (com.sk89q.jnbt.Tag)2 List (java.util.List)2 ListTag (com.sk89q.jnbt.ListTag)1 BaseEntity (com.sk89q.worldedit.entity.BaseEntity)1 Extent (com.sk89q.worldedit.extent.Extent)1 Location (com.sk89q.worldedit.util.Location)1 EntityType (com.sk89q.worldedit.world.entity.EntityType)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1