Package com.sk89q.jnbt

Examples of com.sk89q.jnbt.CompoundTagBuilder


            if (hasTilePosition) {
                Vector tilePosition = new Vector(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ"));
                Vector newTilePosition = transform.apply(tilePosition.subtract(from)).add(to);

                CompoundTagBuilder builder = tag.createBuilder()
                        .putInt("TileX", newTilePosition.getBlockX())
                        .putInt("TileY", newTilePosition.getBlockY())
                        .putInt("TileZ", newTilePosition.getBlockZ());

                if (hasDirection || hasLegacyDirection) {
                    int d = hasDirection ? tag.asInt("Direction") : MCDirections.fromLegacyHanging((byte) tag.asInt("Dir"));
                    Direction direction = MCDirections.fromHanging(d);

                    if (direction != null) {
                        Vector vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector.ZERO)).normalize();
                        Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL);

                        builder.putByte("Direction", (byte) MCDirections.toHanging(newDirection));
                        builder.putByte("Dir", MCDirections.toLegacyHanging(MCDirections.toHanging(newDirection)));
                    }
                }

                return new BaseEntity(state.getTypeId(), builder.build());
            }
        }

        return state;
    }
View Full Code Here

TOP

Related Classes of com.sk89q.jnbt.CompoundTagBuilder

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.