use of com.wuest.prefab.proxy.messages.ConfigSyncMessage in project MC-Prefab by Brian-Wuest.
the class ModEventHandler method onPlayerLoginEvent.
/**
* This event occurs when a player logs in. This is used to send server configuration to the client.
* @param event The event object.
*/
@SubscribeEvent
public static void onPlayerLoginEvent(PlayerLoggedInEvent event) {
if (!event.player.world.isRemote) {
NBTTagCompound tag = Prefab.proxy.proxyConfiguration.ToNBTTagCompound();
Prefab.network.sendTo(new ConfigSyncMessage(tag), (EntityPlayerMP) event.player);
System.out.println("Sent config to '" + event.player.getDisplayNameString() + ".'");
}
}
use of com.wuest.prefab.proxy.messages.ConfigSyncMessage in project MC-Prefab by Brian-Wuest.
the class ModEventHandler method onPlayerLoginEvent.
/**
* This event occurs when a player logs in. This is used to send server configuration to the client.
*
* @param event The event object.
*/
@SubscribeEvent
public static void onPlayerLoginEvent(PlayerLoggedInEvent event) {
if (!event.getPlayer().level.isClientSide) {
CompoundTag tag = CommonProxy.proxyConfiguration.serverConfiguration.ToNBTTagCompound();
Prefab.network.sendTo(new ConfigSyncMessage(tag), ((ServerPlayer) event.getPlayer()).connection.connection, NetworkDirection.PLAY_TO_CLIENT);
Prefab.LOGGER.info("Sent config to '" + event.getPlayer().getDisplayName().getString() + "'.");
}
}
use of com.wuest.prefab.proxy.messages.ConfigSyncMessage in project MC-Prefab by Brian-Wuest.
the class ModRegistry method RegisterMessages.
/**
* This is where the mod messages are registered.
*/
public static void RegisterMessages() {
AtomicInteger index = new AtomicInteger();
Prefab.network.messageBuilder(ConfigSyncMessage.class, index.getAndIncrement()).encoder(ConfigSyncMessage::encode).decoder(ConfigSyncMessage::decode).consumer(ConfigSyncHandler::handle).add();
Prefab.network.messageBuilder(PlayerEntityTagMessage.class, index.getAndIncrement()).encoder(PlayerEntityTagMessage::encode).decoder(PlayerEntityTagMessage::decode).consumer(PlayerEntityHandler::handle).add();
Prefab.network.messageBuilder(StructureTagMessage.class, index.getAndIncrement()).encoder(StructureTagMessage::encode).decoder(StructureTagMessage::decode).consumer(StructureHandler::handle).add();
Prefab.network.messageBuilder(StructureScannerActionMessage.class, index.getAndIncrement()).encoder(StructureScannerActionMessage::encode).decoder(StructureScannerActionMessage::decode).consumer(StructureScannerActionHandler::handle).add();
Prefab.network.messageBuilder(StructureScannerSyncMessage.class, index.getAndIncrement()).encoder(StructureScannerSyncMessage::encode).decoder(StructureScannerSyncMessage::decode).consumer(StructureScannerSyncHandler::handle).add();
}
Aggregations