Ejemplo n.º 1
0
 public void encode(
     PlayerUpdateMessage message, GameFrameBuilder builder, GameFrameBuilder blockBuilder) {
   encodeDescriptor(message, builder, blockBuilder);
   if (isBlockUpdatedRequired()) {
     int flags = 0;
     for (PlayerBlock block : blocks.values()) flags |= block.getFlag();
     if (flags > 0xFF) {
       flags |= 0x10;
       blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, flags);
     } else {
       blockBuilder.put(DataType.BYTE, flags);
     }
     encodeBlock(message, blockBuilder, ChatPlayerBlock.class);
     encodeBlock(message, blockBuilder, HitOnePlayerBlock.class);
     encodeBlock(message, blockBuilder, AnimationPlayerBlock.class);
     encodeBlock(message, blockBuilder, AppearancePlayerBlock.class);
     encodeBlock(message, blockBuilder, TurnToMobPlayerBlock.class);
     encodeBlock(message, blockBuilder, ForceMovementPlayerBlock.class);
     encodeBlock(message, blockBuilder, ForceChatPlayerBlock.class);
     encodeBlock(message, blockBuilder, HitTwoPlayerBlock.class);
     // encodeBlock(message, blockBuilder, ???.class); //0x800
     encodeBlock(message, blockBuilder, SpotAnimationPlayerBlock.class);
     encodeBlock(message, blockBuilder, TurnToPositionPlayerBlock.class);
   }
 }
Ejemplo n.º 2
0
 private void encodeBlock(
     PlayerUpdateMessage message, GameFrameBuilder builder, Class<? extends PlayerBlock> type) {
   PlayerBlock block = blocks.get(type);
   if (block != null) {
     block.encode(message, builder);
   }
 }
Ejemplo n.º 3
0
 private void addBlock(PlayerBlock block) {
   blocks.put(block.getClass(), block);
 }