use of net.silentchaos512.gear.network.SyncMaterialCraftingItemsPacket in project Silent-Gear by SilentChaos512.
the class SyncMaterialCraftingItemsPacket method decode.
public static SyncMaterialCraftingItemsPacket decode(FriendlyByteBuf buffer) {
SyncMaterialCraftingItemsPacket packet = new SyncMaterialCraftingItemsPacket();
int count = buffer.readVarInt();
for (int i = 0; i < count; ++i) {
packet.craftingItems.put(buffer.readResourceLocation(), Ingredient.fromNetwork(buffer));
}
int subCount = buffer.readVarInt();
for (int i = 0; i < subCount; ++i) {
Map<PartType, Ingredient> map = new HashMap<>();
ResourceLocation id = buffer.readResourceLocation();
int mapCount = buffer.readByte();
for (int j = 0; j < mapCount; ++j) {
PartType type = PartType.get(buffer.readResourceLocation());
Ingredient ingredient = Ingredient.fromNetwork(buffer);
map.put(type, ingredient);
}
packet.partSubs.put(id, map);
}
return packet;
}
use of net.silentchaos512.gear.network.SyncMaterialCraftingItemsPacket in project Silent-Gear by SilentChaos512.
the class ServerEvents method onPlayerJoinServer.
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onPlayerJoinServer(PlayerEvent.PlayerLoggedInEvent event) {
Player player = event.getPlayer();
if (!(player instanceof ServerPlayer))
return;
ServerPlayer playerMP = (ServerPlayer) player;
// Send crafting items packets to correct for registry changes
SilentGear.LOGGER.debug("Sending materials crafting item correction packet");
Network.channel.sendTo(new SyncMaterialCraftingItemsPacket(MaterialManager.getValues()), playerMP.connection.connection, NetworkDirection.PLAY_TO_CLIENT);
SilentGear.LOGGER.debug("Sending parts crafting item correction packet");
Network.channel.sendTo(new SyncGearCraftingItemsPacket(), playerMP.connection.connection, NetworkDirection.PLAY_TO_CLIENT);
TraitManager.getErrorMessages(playerMP).forEach(text -> playerMP.sendMessage(text, Util.NIL_UUID));
MaterialManager.getErrorMessages(playerMP).forEach(text -> playerMP.sendMessage(text, Util.NIL_UUID));
PartManager.getErrorMessages(playerMP).forEach(text -> playerMP.sendMessage(text, Util.NIL_UUID));
}
Aggregations