Search in sources :

Example 41 with CompoundTag

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

the class AbstractChangeSet method add.

public void add(int x, int y, int z, BaseBlock from, BaseBlock to) {
    try {
        if (from.hasNbtData()) {
            CompoundTag nbt = from.getNbtData();
            assert nbt != null;
            addTileRemove(MainUtil.setPosition(nbt, x, y, z));
        }
        if (to.hasNbtData()) {
            CompoundTag nbt = to.getNbtData();
            assert nbt != null;
            addTileCreate(MainUtil.setPosition(nbt, x, y, z));
        }
        int combinedFrom = from.getOrdinal();
        int combinedTo = to.getOrdinal();
        add(x, y, z, combinedFrom, combinedTo);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : CompoundTag(com.sk89q.jnbt.CompoundTag) IOException(java.io.IOException)

Example 42 with CompoundTag

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

the class CompressedCompoundTag method decompress.

private void decompress() {
    try (NBTInputStream nbtIn = new NBTInputStream(adapt(in))) {
        in = null;
        CompoundTag tag = (CompoundTag) nbtIn.readTag();
        Map<String, Tag> value = tag.getValue();
        Map<String, Tag> raw = super.getValue();
        raw.putAll(value);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : NBTInputStream(com.sk89q.jnbt.NBTInputStream) CompoundTag(com.sk89q.jnbt.CompoundTag) Tag(com.sk89q.jnbt.Tag) IOException(java.io.IOException) CompoundTag(com.sk89q.jnbt.CompoundTag)

Example 43 with CompoundTag

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

the class DefaultBlockParser method validate.

// FAWE Start
private <T extends BlockStateHolder> T validate(ParserContext context, T holder) {
    if (context.isRestricted()) {
        Actor actor = context.requireActor();
        if (!actor.hasPermission("worldedit.anyblock") && worldEdit.getConfiguration().checkDisallowedBlocks(holder)) {
            throw new DisallowedUsageException(Caption.of("worldedit.error.disallowed-block", TextComponent.of(String.valueOf(holder))));
        }
        CompoundTag nbt = holder.getNbtData();
        if (nbt != null) {
            if (!actor.hasPermission("worldedit.anyblock.nbt")) {
                throw new DisallowedUsageException(Caption.of("fawe.error.nbt.forbidden", TextComponent.of("worldedit.anyblock.nbt")));
            }
        }
    }
    return holder;
}
Also used : DisallowedUsageException(com.sk89q.worldedit.extension.input.DisallowedUsageException) Actor(com.sk89q.worldedit.extension.platform.Actor) CompoundTag(com.sk89q.jnbt.CompoundTag)

Example 44 with CompoundTag

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

the class CharFilterBlock method getFullBlock.

@Override
public final BaseBlock getFullBlock() {
    final BlockState state = getBlock();
    final BlockMaterial material = state.getMaterial();
    if (material.hasContainer()) {
        final CompoundTag tag = get.getTile(x, y + yy, z);
        return state.toBaseBlock(tag);
    }
    return state.toBaseBlock();
}
Also used : BlockState(com.sk89q.worldedit.world.block.BlockState) BlockMaterial(com.sk89q.worldedit.world.registry.BlockMaterial) CompoundTag(com.sk89q.jnbt.CompoundTag)

Example 45 with CompoundTag

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

the class CharFilterBlock method setFullBlock.

@Override
public void setFullBlock(BaseBlock block) {
    delegate.set(this, block.getOrdinalChar());
    final CompoundTag nbt = block.getNbtData();
    if (nbt != null) {
        // TODO optimize check via ImmutableBaseBlock
        set.setTile(x, yy + y, z, nbt);
    }
}
Also used : CompoundTag(com.sk89q.jnbt.CompoundTag)

Aggregations

CompoundTag (com.sk89q.jnbt.CompoundTag)69 Tag (com.sk89q.jnbt.Tag)38 StringTag (com.sk89q.jnbt.StringTag)26 HashMap (java.util.HashMap)25 IntTag (com.sk89q.jnbt.IntTag)24 ListTag (com.sk89q.jnbt.ListTag)21 ShortTag (com.sk89q.jnbt.ShortTag)16 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)16 ByteArrayTag (com.sk89q.jnbt.ByteArrayTag)14 IntArrayTag (com.sk89q.jnbt.IntArrayTag)14 IOException (java.io.IOException)14 Map (java.util.Map)13 BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)11 NamedTag (com.sk89q.jnbt.NamedTag)9 Location (com.sk89q.worldedit.util.Location)9 BlockState (com.sk89q.worldedit.world.block.BlockState)9 BaseEntity (com.sk89q.worldedit.entity.BaseEntity)8 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)6 Region (com.sk89q.worldedit.regions.Region)6 ArrayList (java.util.ArrayList)6