/** * Returns this block change's absolute Location in a given World. * * @param world World for the location * @return This block change's absolute Location */ public Location getLocation(World world) { return new Location(world, getAbsoluteX(), getY(), getAbsoluteZ()); }
public static EquivalentConverter<MultiBlockChangeInfo[]> getArrayConverter(final ChunkCoordIntPair chunk) { return new EquivalentConverter<MultiBlockChangeInfo[]>() { private final EquivalentConverter<MultiBlockChangeInfo> converter = MultiBlockChangeInfo.getConverter(chunk);
/** * Sets this block change's y coordinate * * @param y New y coordinate */ public void setY(int y) { setLocation(getX(), y, getZ()); }
/** * Sets this block change's relative z coordinate. * * @param z New z coordinate */ public void setZ(int z) { setLocation(getX(), getY(), z); }
/** * Sets this block change's absolute x coordinate. * * @param x New x coordinate */ public void setX(int x) { setLocation(x, getY(), getZ()); }
public MultiBlockChangeInfo(Location location, WrappedBlockData data) { this.data = data; this.chunk = new ChunkCoordIntPair(location.getBlockX() >> 4, location.getBlockZ() >> 4); this.setLocation(location); }
/** * Gets this block change's absolute x coordinate. * * @return Absolute X coordinate */ public int getAbsoluteX() { return (chunk.getChunkX() << 4) + getX(); }
/** * Gets this block change's absolute z coordinate. * * @return Absolute Z coordinate */ public int getAbsoluteZ() { return (chunk.getChunkZ() << 4) + getZ(); }
/** * Retrieves a read/write structure for MultiBlockChangeInfo arrays in Minecraft 1.8. * <p> * This modifier will automatically marshal between MultiBlockChangeInfo and the * internal Minecraft MultiBlockChangeInfo. * @return A modifier for BlockData fields. */ public StructureModifier<MultiBlockChangeInfo[]> getMultiBlockChangeInfoArrays() { ChunkCoordIntPair chunk = getChunkCoordIntPairs().read(0); // Convert to and from our wrapper return structureModifier.withType( MinecraftReflection.getMultiBlockChangeInfoArrayClass(), MultiBlockChangeInfo.getArrayConverter(chunk)); }
@Override public MultiBlockChangeInfo getSpecific(Object generic) { StructureModifier<Object> modifier = new StructureModifier<>(generic.getClass(), null, false).withTarget(generic); StructureModifier<Short> shorts = modifier.withType(short.class); short location = shorts.read(0); StructureModifier<WrappedBlockData> dataModifier = modifier.withType(MinecraftReflection.getIBlockDataClass(), BukkitConverters.getWrappedBlockDataConverter()); WrappedBlockData data = dataModifier.read(0); return new MultiBlockChangeInfo(location, data, chunk); }
/** * Sets this block change's absolute Location. * * @param location This block change's new location */ public void setLocation(Location location) { setLocation(location.getBlockX(), location.getBlockY(), location.getBlockZ()); }