|
| 1 | +import { Tab, Tabs } from 'nextra-theme-docs' |
| 2 | + |
| 3 | +# Cosmetic Module |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +## Integration |
| 8 | + |
| 9 | +### Sample Code |
| 10 | +Explore each integration by cycling through each tab to find the best fit for your requirements and needs. |
| 11 | + |
| 12 | +<Tabs items={['Apollo API', 'apollo-protos library', 'Manual JSON Object Construction']}> |
| 13 | + |
| 14 | +<Tab> |
| 15 | + |
| 16 | +**Equip cosmetics on an NPC** |
| 17 | + |
| 18 | +```java |
| 19 | +public void equipNpcCosmeticsExample(int entityId, UUID npcUuid, List<Integer> cosmeticIds) { |
| 20 | + this.cosmeticModule.equipNpcCosmetics(Recipients.ofEveryone(), new ApolloEntity(entityId, npcUuid), cosmeticIds); |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +**Unequip cosmetics from an NPC** |
| 25 | + |
| 26 | +```java |
| 27 | +public void unequipNpcCosmeticsExample(int entityId, UUID npcUuid, List<Integer> cosmeticIds) { |
| 28 | + this.cosmeticModule.unequipNpcCosmetics(Recipients.ofEveryone(), new ApolloEntity(entityId, npcUuid), cosmeticIds); |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +**Reset all cosmetics on an NPC** |
| 33 | + |
| 34 | +```java |
| 35 | +public void resetNpcCosmeticsExample(int entityId, UUID npcUuid) { |
| 36 | + this.cosmeticModule.resetNpcCosmetics(Recipients.ofEveryone(), new ApolloEntity(entityId, npcUuid)); |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +</Tab> |
| 41 | + |
| 42 | +<Tab> |
| 43 | + |
| 44 | +**Equip cosmetics on an NPC** |
| 45 | + |
| 46 | +```java |
| 47 | +public void equipNpcCosmeticsExample(int entityId, UUID npcUuid, List<Integer> cosmeticIds) { |
| 48 | + EquipNpcCosmeticsMessage message = EquipNpcCosmeticsMessage.newBuilder() |
| 49 | + .setEntityId(ProtobufUtil.createEntityIdProto(entityId, npcUuid)) |
| 50 | + .addAllCosmeticIds(cosmeticIds) |
| 51 | + .build(); |
| 52 | + |
| 53 | + ProtobufPacketUtil.broadcastPacket(message); |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +**Unequip cosmetics from an NPC** |
| 58 | + |
| 59 | +```java |
| 60 | +public void unequipNpcCosmeticsExample(int entityId, UUID npcUuid, List<Integer> cosmeticIds) { |
| 61 | + UnequipNpcCosmeticsMessage message = UnequipNpcCosmeticsMessage.newBuilder() |
| 62 | + .setEntityId(ProtobufUtil.createEntityIdProto(entityId, npcUuid)) |
| 63 | + .addAllCosmeticIds(cosmeticIds) |
| 64 | + .build(); |
| 65 | + |
| 66 | + ProtobufPacketUtil.broadcastPacket(message); |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +**Reset all cosmetics on an NPC** |
| 71 | + |
| 72 | +```java |
| 73 | +public void resetNpcCosmeticsExample(int entityId, UUID npcUuid) { |
| 74 | + ResetNpcCosmeticsMessage message = ResetNpcCosmeticsMessage.newBuilder() |
| 75 | + .setEntityId(ProtobufUtil.createEntityIdProto(entityId, npcUuid)) |
| 76 | + .build(); |
| 77 | + |
| 78 | + ProtobufPacketUtil.broadcastPacket(message); |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +</Tab> |
| 83 | + |
| 84 | +<Tab> |
| 85 | + |
| 86 | +**Equip cosmetics on an NPC** |
| 87 | + |
| 88 | +```java |
| 89 | +public void equipNpcCosmeticsExample(int entityId, UUID npcUuid, List<Integer> cosmeticIds) { |
| 90 | + JsonArray cosmeticIdsArray = new JsonArray(); |
| 91 | + cosmeticIds.forEach(cosmeticIdsArray::add); |
| 92 | + |
| 93 | + JsonObject message = new JsonObject(); |
| 94 | + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cosmetic.v1.EquipNpcCosmeticsMessage"); |
| 95 | + message.add("entity_id", JsonUtil.createEntityIdObject(entityId, npcUuid)); |
| 96 | + message.add("cosmetic_ids", cosmeticIdsArray); |
| 97 | + |
| 98 | + JsonPacketUtil.broadcastPacket(message); |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +**Unequip cosmetics from an NPC** |
| 103 | + |
| 104 | +```java |
| 105 | +public void unequipNpcCosmeticsExample(int entityId, UUID npcUuid, List<Integer> cosmeticIds) { |
| 106 | + JsonArray cosmeticIdsArray = new JsonArray(); |
| 107 | + cosmeticIds.forEach(cosmeticIdsArray::add); |
| 108 | + |
| 109 | + JsonObject message = new JsonObject(); |
| 110 | + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cosmetic.v1.UnequipNpcCosmeticsMessage"); |
| 111 | + message.add("entity_id", JsonUtil.createEntityIdObject(entityId, npcUuid)); |
| 112 | + message.add("cosmetic_ids", cosmeticIdsArray); |
| 113 | + |
| 114 | + JsonPacketUtil.broadcastPacket(message); |
| 115 | +} |
| 116 | +``` |
| 117 | + |
| 118 | +**Reset all cosmetics on an NPC** |
| 119 | + |
| 120 | +```java |
| 121 | +public void resetNpcCosmeticsExample(int entityId, UUID npcUuid) { |
| 122 | + JsonObject message = new JsonObject(); |
| 123 | + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cosmetic.v1.ResetNpcCosmeticsMessage"); |
| 124 | + message.add("entity_id", JsonUtil.createEntityIdObject(entityId, npcUuid)); |
| 125 | + |
| 126 | + JsonPacketUtil.broadcastPacket(message); |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +</Tab> |
| 131 | + |
| 132 | +</Tabs> |
0 commit comments