Per-Player Blocks
Send ServerSetBlock packets directly to a player’s packet handler to show fake blocks without modifying the world.
Sending Packets to Players
Section titled “Sending Packets to Players”Use PlayerRef.getPacketHandler().write() to send packets to specific players:
PlayerRef player = ...; // get from event or commandPacket packet = ...; // the packet to send
player.getPacketHandler().write(packet);ServerSetBlock Packet
Section titled “ServerSetBlock Packet”Sets a single block for the receiving player. Packet ID: 140
Structure
Section titled “Structure”| Field | Type | Description |
|---|---|---|
| x | int (4 bytes LE) | World X coordinate |
| y | int (4 bytes LE) | World Y coordinate |
| z | int (4 bytes LE) | World Z coordinate |
| blockId | int (4 bytes LE) | Block type index from asset map |
| filler | short (2 bytes LE) | For multi-block structures, use 0 for simple blocks |
| rotation | byte | Rotation index 0-23 |
Getting Block IDs
Section titled “Getting Block IDs”Block IDs are runtime indices from the block type asset map:
import com.hypixel.hytale.server.world.block.BlockType;
// get block ID by nameint stoneId = BlockType.getAssetMap().getIndex("Stone");int airId = BlockType.getAssetMap().getIndex("Air");int glassId = BlockType.getAssetMap().getIndex("Glass");Example: Send Fake Block
Section titled “Example: Send Fake Block”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);}
// usagesendFakeBlock(player, 100, 64, 200, "Diamond");ServerSetBlocks Packet
Section titled “ServerSetBlocks Packet”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);}Practical Examples
Section titled “Practical Examples”Fake Wall (Barrier)
Section titled “Fake Wall (Barrier)”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); } }}Resetting to Real Blocks
Section titled “Resetting to Real Blocks”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);}Limitations
Section titled “Limitations”- 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
ServerSetBlocksfor bulk changes