use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutEntityMetadata in project LanternServer by LanternPowered.
the class PlayerEntityProtocol method sendHat.
private void sendHat(EntityProtocolUpdateContext context, TopHat hat) {
final LanternItemStack paneItem;
final LanternItemStack blockItem;
final Optional<DyeColor> dyeColor = hat.getDyeColor();
if (dyeColor.isPresent()) {
paneItem = new LanternItemStack(BlockTypes.CARPET);
paneItem.offer(Keys.DYE_COLOR, dyeColor.get());
blockItem = new LanternItemStack(BlockTypes.WOOL);
blockItem.offer(Keys.DYE_COLOR, dyeColor.get());
} else if (hat == TopHats.GOLD) {
paneItem = new LanternItemStack(BlockTypes.LIGHT_WEIGHTED_PRESSURE_PLATE);
blockItem = new LanternItemStack(BlockTypes.GOLD_BLOCK);
} else if (hat == TopHats.IRON) {
paneItem = new LanternItemStack(BlockTypes.HEAVY_WEIGHTED_PRESSURE_PLATE);
blockItem = new LanternItemStack(BlockTypes.IRON_BLOCK);
} else if (hat == TopHats.WOOD) {
paneItem = new LanternItemStack(BlockTypes.WOODEN_PRESSURE_PLATE);
blockItem = new LanternItemStack(BlockTypes.PLANKS);
} else if (hat == TopHats.STONE) {
paneItem = new LanternItemStack(BlockTypes.STONE_PRESSURE_PLATE);
blockItem = new LanternItemStack(BlockTypes.STONE);
} else if (hat == TopHats.SNOW) {
paneItem = new LanternItemStack(BlockTypes.SNOW_LAYER);
blockItem = new LanternItemStack(BlockTypes.SNOW);
} else {
throw new IllegalStateException();
}
byte flags = 0x20;
if (getEntity().get(Keys.GLOWING).get()) {
flags |= 0x40;
}
final ParameterList parameterList1 = new ByteBufParameterList(ByteBufferAllocator.unpooled());
parameterList1.add(EntityParameters.ArmorStand.FLAGS, (byte) (0x08 | 0x10));
parameterList1.add(EntityParameters.Base.FLAGS, flags);
final int id1 = this.passengerStack[10];
context.sendToAll(() -> new MessagePlayOutSpawnObject(id1, UUID.randomUUID(), 78, 0, getEntity().getPosition(), 0, 0, Vector3d.ZERO));
context.sendToAll(() -> new MessagePlayOutEntityMetadata(id1, parameterList1));
context.sendToAll(() -> new MessagePlayOutEntityEquipment(id1, 5, paneItem));
final ParameterList parameterList2 = new ByteBufParameterList(ByteBufferAllocator.unpooled());
parameterList2.add(EntityParameters.ArmorStand.FLAGS, (byte) (0x08 | 0x10 | 0x01));
parameterList2.add(EntityParameters.Base.FLAGS, flags);
final int id2 = this.passengerStack[11];
context.sendToAll(() -> new MessagePlayOutSpawnObject(id2, UUID.randomUUID(), 78, 0, getEntity().getPosition(), 0, 0, Vector3d.ZERO));
context.sendToAll(() -> new MessagePlayOutEntityMetadata(id2, parameterList2));
context.sendToAll(() -> new MessagePlayOutEntityEquipment(id2, 5, blockItem));
sendPassengers(context, 8, 10);
sendPassengers(context, 9, 11);
/*
final LanternItemStack boneItem = new LanternItemStack(ItemTypes.BONE);
float angleA = 250f;
float angleB = 250f;
for (int i = 12; i <= 14; i++) {
final ParameterList parameterList3 = new ByteBufParameterList(ByteBufferAllocator.unpooled());
parameterList3.add(EntityParameters.ArmorStand.FLAGS, (byte) (0x08 | 0x10 | 0x01 | 0x04));
parameterList3.add(EntityParameters.ArmorStand.LEFT_ARM_ROTATION, new Vector3f(50f, 360f - angleA, angleB));
parameterList3.add(EntityParameters.ArmorStand.RIGHT_ARM_ROTATION, new Vector3f(50f, angleA, 360f - angleB));
parameterList3.add(EntityParameters.Base.FLAGS, flags);
final int id3 = this.passengerStack[i];
context.sendToAll(() -> new MessagePlayOutSpawnObject(id3, UUID.randomUUID(), 78, 0,
getEntity().getPosition(), 0, 0, Vector3d.ZERO));
context.sendToAll(() -> new MessagePlayOutEntityMetadata(id3, parameterList3));
context.sendToAll(() -> new MessagePlayOutEntityEquipment(id3, 0, boneItem));
context.sendToAll(() -> new MessagePlayOutEntityEquipment(id3, 1, boneItem));
angleA -= 15f;
angleB -= 15f;
}
sendPassengers(context, 7, 9, 12, 13, 14);
*/
}
Aggregations