Search in sources :

Example 1 with UpdateBlockEntityMessage

use of net.glowstone.net.message.play.game.UpdateBlockEntityMessage in project Glowstone by GlowstoneMC.

the class GlowPlayer method sendSignChange.

/**
 * Send a sign change, similar to {@link #sendSignChange(Location, String[])}, but using
 * complete TextMessages instead of strings.
 *
 * @param sign     the sign
 * @param location the location of the sign
 * @param lines    the new text on the sign or null to clear it
 * @throws IllegalArgumentException if location is null
 * @throws IllegalArgumentException if lines is non-null and has a length less than 4
 */
public void sendSignChange(SignEntity sign, Location location, TextMessage[] lines) throws IllegalArgumentException {
    checkNotNull(location, "location cannot be null");
    checkNotNull(lines, "lines cannot be null");
    checkArgument(lines.length == 4, "lines.length must equal 4");
    CompoundTag tag = new CompoundTag();
    sign.saveNbt(tag);
    afterBlockChanges.add(new UpdateBlockEntityMessage(location.getBlockX(), location.getBlockY(), location.getBlockZ(), GlowBlockEntity.SIGN.getValue(), tag));
}
Also used : UpdateBlockEntityMessage(net.glowstone.net.message.play.game.UpdateBlockEntityMessage) CompoundTag(net.glowstone.util.nbt.CompoundTag)

Example 2 with UpdateBlockEntityMessage

use of net.glowstone.net.message.play.game.UpdateBlockEntityMessage in project Glowstone by GlowstoneMC.

the class GlowPlayer method sendBlockEntityChange.

/**
 * Send a block entity change to the given location.
 *
 * @param location The location of the block entity.
 * @param type     The type of block entity being sent.
 * @param nbt      The NBT structure to send to the client.
 */
public void sendBlockEntityChange(Location location, GlowBlockEntity type, CompoundTag nbt) {
    checkNotNull(location, "Location cannot be null");
    checkNotNull(type, "Type cannot be null");
    checkNotNull(nbt, "NBT cannot be null");
    afterBlockChanges.add(new UpdateBlockEntityMessage(location.getBlockX(), location.getBlockY(), location.getBlockZ(), type.getValue(), nbt));
}
Also used : UpdateBlockEntityMessage(net.glowstone.net.message.play.game.UpdateBlockEntityMessage)

Example 3 with UpdateBlockEntityMessage

use of net.glowstone.net.message.play.game.UpdateBlockEntityMessage in project Glowstone by GlowstoneMC.

the class UpdateBlockEntityCodec method decode.

@Override
public UpdateBlockEntityMessage decode(ByteBuf buffer) throws IOException {
    BlockVector pos = GlowBufUtils.readBlockPosition(buffer);
    int action = buffer.readByte();
    CompoundTag nbt = GlowBufUtils.readCompound(buffer);
    return new UpdateBlockEntityMessage(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), action, nbt);
}
Also used : UpdateBlockEntityMessage(net.glowstone.net.message.play.game.UpdateBlockEntityMessage) BlockVector(org.bukkit.util.BlockVector) CompoundTag(net.glowstone.util.nbt.CompoundTag)

Aggregations

UpdateBlockEntityMessage (net.glowstone.net.message.play.game.UpdateBlockEntityMessage)3 CompoundTag (net.glowstone.util.nbt.CompoundTag)2 BlockVector (org.bukkit.util.BlockVector)1