use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class UpdateItemsMessageEncoder method encode.
@Override
public GamePacket encode(UpdateItemsMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(206, PacketType.VARIABLE_SHORT);
Item[] items = message.getItems();
builder.put(DataType.SHORT, message.getInterfaceId());
builder.put(DataType.SHORT, items.length);
for (Item item : items) {
int id = item == null ? -1 : item.getId();
int amount = item == null ? 0 : item.getAmount();
builder.put(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD, id + 1);
if (amount > 254) {
builder.put(DataType.BYTE, DataTransformation.NEGATE, 255);
builder.put(DataType.INT, DataOrder.LITTLE, amount);
} else {
builder.put(DataType.BYTE, DataTransformation.NEGATE, amount);
}
}
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class SendProjectileMessageEncoder method encode.
@Override
public GamePacket encode(SendProjectileMessage message) {
Projectile projectile = message.getProjectile();
Position source = projectile.getPosition();
Position destination = projectile.getDestination();
GamePacketBuilder builder = new GamePacketBuilder(181);
builder.put(DataType.BYTE, message.getPositionOffset());
builder.put(DataType.BYTE, destination.getX() - source.getX());
builder.put(DataType.BYTE, destination.getY() - source.getY());
builder.put(DataType.SHORT, projectile.getTarget());
builder.put(DataType.SHORT, projectile.getGraphic());
builder.put(DataType.BYTE, projectile.getStartHeight());
builder.put(DataType.BYTE, projectile.getEndHeight());
builder.put(DataType.SHORT, projectile.getDelay());
builder.put(DataType.SHORT, projectile.getLifetime());
builder.put(DataType.BYTE, projectile.getPitch());
builder.put(DataType.BYTE, projectile.getOffset());
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class SetWidgetTextMessageEncoder method encode.
@Override
public GamePacket encode(SetWidgetTextMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(232, PacketType.VARIABLE_SHORT);
builder.put(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD, message.getInterfaceId());
builder.putString(message.getText());
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class SwitchTabInterfaceMessageEncoder method encode.
@Override
public GamePacket encode(SwitchTabInterfaceMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(10);
builder.put(DataType.BYTE, DataTransformation.SUBTRACT, message.getTabId());
builder.put(DataType.SHORT, DataTransformation.ADD, message.getInterfaceId());
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class UpdateRunEnergyMessageEncoder method encode.
@Override
public GamePacket encode(UpdateRunEnergyMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(125);
builder.put(DataType.BYTE, message.getEnergy());
return builder.toGamePacket();
}
Aggregations