Search in sources :

Example 1 with SyncGearCraftingItemsPacket

use of net.silentchaos512.gear.network.SyncGearCraftingItemsPacket 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));
}
Also used : Player(net.minecraft.world.entity.player.Player) ServerPlayer(net.minecraft.server.level.ServerPlayer) SyncGearCraftingItemsPacket(net.silentchaos512.gear.network.SyncGearCraftingItemsPacket) ServerPlayer(net.minecraft.server.level.ServerPlayer) SyncMaterialCraftingItemsPacket(net.silentchaos512.gear.network.SyncMaterialCraftingItemsPacket) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

ServerPlayer (net.minecraft.server.level.ServerPlayer)1 Player (net.minecraft.world.entity.player.Player)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1 SyncGearCraftingItemsPacket (net.silentchaos512.gear.network.SyncGearCraftingItemsPacket)1 SyncMaterialCraftingItemsPacket (net.silentchaos512.gear.network.SyncMaterialCraftingItemsPacket)1