Skip to content

Per-Player Blocks

Send ServerSetBlock packets directly to a player’s packet handler to show fake blocks without modifying the world.

Use PlayerRef.getPacketHandler().write() to send packets to specific players:

PlayerRef player = ...; // get from event or command
Packet packet = ...; // the packet to send
player.getPacketHandler().write(packet);

Sets a single block for the receiving player. Packet ID: 140

FieldTypeDescription
xint (4 bytes LE)World X coordinate
yint (4 bytes LE)World Y coordinate
zint (4 bytes LE)World Z coordinate
blockIdint (4 bytes LE)Block type index from asset map
fillershort (2 bytes LE)For multi-block structures, use 0 for simple blocks
rotationbyteRotation index 0-23

Block IDs are runtime indices from the block type asset map:

import com.hypixel.hytale.server.world.block.BlockType;
// get block ID by name
int stoneId = BlockType.getAssetMap().getIndex("Stone");
int airId = BlockType.getAssetMap().getIndex("Air");
int glassId = BlockType.getAssetMap().getIndex("Glass");
import com.hypixel.hytale.server.world.block.BlockType;
import com.hypixel.hytale.server.core.network.packet.server.ServerSetBlock;
public void sendFakeBlock(PlayerRef player, int x, int y, int z, String blockName) {
int blockId = BlockType.getAssetMap().getIndex(blockName);
ServerSetBlock packet = new ServerSetBlock(
x, y, z, // position
blockId, // block type
(short) 0, // filler (0 for simple blocks)
(byte) 0 // no rotation
);
player.getPacketHandler().write(packet);
}
// usage
sendFakeBlock(player, 100, 64, 200, "Diamond");

Sets multiple blocks in one packet. More efficient for bulk changes. Packet ID: 141

import com.hypixel.hytale.server.core.network.packet.server.ServerSetBlocks;
public void sendFakeBlocks(PlayerRef player, List<BlockChange> changes) {
ServerSetBlocks packet = new ServerSetBlocks(changes);
player.getPacketHandler().write(packet);
}

Show a temporary barrier only to one player:

public void showBarrier(PlayerRef player, int x, int y, int z, int width, int height) {
int barrierBlock = BlockType.getAssetMap().getIndex("Barrier");
for (int dx = 0; dx < width; dx++) {
for (int dy = 0; dy < height; dy++) {
ServerSetBlock packet = new ServerSetBlock(
x + dx, y + dy, z,
barrierBlock, (short) 0, (byte) 0
);
player.getPacketHandler().write(packet);
}
}
}

To “remove” fake blocks, send the actual world block data:

public void resetBlock(PlayerRef player, World world, int x, int y, int z) {
BlockState realBlock = world.getBlockState(x, y, z);
int blockId = BlockType.getAssetMap().getIndex(realBlock.getType().getIdentifier());
ServerSetBlock packet = new ServerSetBlock(
x, y, z,
blockId,
(short) 0,
realBlock.getRotation()
);
player.getPacketHandler().write(packet);
}
  • Chunk reloads: When a player reloads chunks (moving far away and back), fake blocks are lost
  • Block updates: Real block changes in the same position will overwrite fake blocks
  • Interactions: Players cannot interact with fake blocks (they’re client-side only)
  • Performance: Sending many individual packets can be slow; use ServerSetBlocks for bulk changes