public void preInit(FMLPreInitializationEvent e) { MinecraftForge.EVENT_BUS.register(new ForgeEventHandlers()); McJtyLib.preInit(e); CommandHandler.registerCommands(); GeneralConfig.preInit(e); File directory = e.getModConfigurationDirectory(); mainConfig = new Configuration(new File(directory.getPath(), "needtobreathe.cfg")); Config.readConfig(mainConfig); // PacketHandler.registerMessages("meecreeps"); SimpleNetworkWrapper network = PacketHandler.registerMessages(NeedToBreathe.MODID, "needtobreathe"); NTBMessages.registerNetworkMessages(network); // Initialization of blocks and items typically goes here: // ModEntities.init(); ModItems.init(); ModBlocks.init(); }
public void preInit(FMLPreInitializationEvent e) { MinecraftForge.EVENT_BUS.register(new ForgeEventHandlers()); McJtyLib.preInit(e); CommandHandler.registerCommands(); MeeCreeps.api.registerFactories(); File directory = e.getModConfigurationDirectory(); config = new Configuration(new File(directory.getPath(), "meecreeps.cfg")); Config.readConfig(); SimpleNetworkWrapper network = mcjty.lib.network.PacketHandler.registerMessages(MeeCreeps.MODID, "meecreeps"); MeeCreepsMessages.registerMessages(network); // Initialization of blocks and items typically goes here: ModEntities.init(); }
public static <REQ extends IMessage, REPLY extends IMessage> void registerPacket(SimpleNetworkWrapper network, Class<REQ> requestMessageType, Class<? extends IMessageHandler<REQ, REPLY>> messageHandler, Side side) { String packetPackageName = requestMessageType.getPackage().getName(); Iterator<String> iterator = packetByteDiscriminators.keySet().iterator(); byte discriminator = -1; while(iterator.hasNext()) { String pack = iterator.next(); if(pack.contains(packetPackageName)) { packetByteDiscriminators.get(packetPackageName); } } if(discriminator == -1) { packetByteDiscriminators.put(packetPackageName, (byte) 0); } network.registerMessage(messageHandler, requestMessageType, packetByteDiscriminators.get(packetPackageName), side); }
public static void registerPackets(SimpleNetworkWrapper network) { network.registerMessage(PacketSetBlock.Handler.class, PacketSetBlock.class, 1, Side.SERVER); network.registerMessage(PacketSetISType.Handler.class, PacketSetISType.class, 2, Side.SERVER); network.registerMessage(PacketSetKeycardLevel.Handler.class, PacketSetKeycardLevel.class, 3, Side.SERVER); network.registerMessage(PacketUpdateLogger.Handler.class, PacketUpdateLogger.class, 4, Side.CLIENT); network.registerMessage(PacketCUpdateNBTTag.Handler.class, PacketCUpdateNBTTag.class, 5, Side.CLIENT); network.registerMessage(PacketSUpdateNBTTag.Handler.class, PacketSUpdateNBTTag.class, 6, Side.SERVER); network.registerMessage(PacketCPlaySoundAtPos.Handler.class, PacketCPlaySoundAtPos.class, 7, Side.CLIENT); network.registerMessage(PacketSetExplosiveState.Handler.class, PacketSetExplosiveState.class, 8, Side.SERVER); network.registerMessage(PacketGivePotionEffect.Handler.class, PacketGivePotionEffect.class, 9, Side.SERVER); network.registerMessage(PacketSSetOwner.Handler.class, PacketSSetOwner.class, 10, Side.SERVER); network.registerMessage(PacketSAddModules.Handler.class, PacketSAddModules.class, 11, Side.SERVER); network.registerMessage(PacketSSetPassword.Handler.class, PacketSSetPassword.class, 12, Side.SERVER); network.registerMessage(PacketSCheckPassword.Handler.class, PacketSCheckPassword.class, 13, Side.SERVER); network.registerMessage(PacketSSyncTENBTTag.Handler.class, PacketSSyncTENBTTag.class, 14, Side.SERVER); network.registerMessage(PacketSMountCamera.Handler.class, PacketSMountCamera.class, 15, Side.SERVER); network.registerMessage(PacketSSetCameraRotation.Handler.class, PacketSSetCameraRotation.class, 16, Side.SERVER); network.registerMessage(PacketCSetPlayerPositionAndRotation.Handler.class, PacketCSetPlayerPositionAndRotation.class, 17, Side.CLIENT); network.registerMessage(PacketSOpenGui.Handler.class, PacketSOpenGui.class, 18, Side.SERVER); network.registerMessage(PacketSToggleOption.Handler.class, PacketSToggleOption.class, 19, Side.SERVER); network.registerMessage(PacketCRequestTEOwnableUpdate.Handler.class, PacketCRequestTEOwnableUpdate.class, 20, Side.SERVER); network.registerMessage(PacketSUpdateTEOwnable.Handler.class, PacketSUpdateTEOwnable.class, 21, Side.CLIENT); network.registerMessage(PacketSUpdateSliderValue.Handler.class, PacketSUpdateSliderValue.class, 22, Side.SERVER); network.registerMessage(PacketSRemoveCameraTag.Handler.class, PacketSRemoveCameraTag.class, 23, Side.SERVER); }
public static void registerPackets(SimpleNetworkWrapper network) { network.registerMessage(PacketSetBlock.Handler.class, PacketSetBlock.class, 1, Side.SERVER); network.registerMessage(PacketSetISType.Handler.class, PacketSetISType.class, 2, Side.SERVER); network.registerMessage(PacketSetKeycardLevel.Handler.class, PacketSetKeycardLevel.class, 3, Side.SERVER); network.registerMessage(PacketUpdateLogger.Handler.class, PacketUpdateLogger.class, 4, Side.CLIENT); network.registerMessage(PacketCUpdateNBTTag.Handler.class, PacketCUpdateNBTTag.class, 5, Side.CLIENT); network.registerMessage(PacketSUpdateNBTTag.Handler.class, PacketSUpdateNBTTag.class, 6, Side.SERVER); network.registerMessage(PacketCPlaySoundAtPos.Handler.class, PacketCPlaySoundAtPos.class, 7, Side.CLIENT); network.registerMessage(PacketSetExplosiveState.Handler.class, PacketSetExplosiveState.class, 8, Side.SERVER); network.registerMessage(PacketGivePotionEffect.Handler.class, PacketGivePotionEffect.class, 9, Side.SERVER); network.registerMessage(PacketSSetOwner.Handler.class, PacketSSetOwner.class, 10, Side.SERVER); network.registerMessage(PacketSAddModules.Handler.class, PacketSAddModules.class, 11, Side.SERVER); network.registerMessage(PacketSSetPassword.Handler.class, PacketSSetPassword.class, 12, Side.SERVER); network.registerMessage(PacketSCheckPassword.Handler.class, PacketSCheckPassword.class, 13, Side.SERVER); network.registerMessage(PacketSSyncTENBTTag.Handler.class, PacketSSyncTENBTTag.class, 14, Side.SERVER); network.registerMessage(PacketSMountCamera.Handler.class, PacketSMountCamera.class, 15, Side.SERVER); network.registerMessage(PacketSSetCameraRotation.Handler.class, PacketSSetCameraRotation.class, 16, Side.SERVER); network.registerMessage(PacketCSetPlayerPositionAndRotation.Handler.class, PacketCSetPlayerPositionAndRotation.class, 17, Side.CLIENT); network.registerMessage(PacketSOpenGui.Handler.class, PacketSOpenGui.class, 18, Side.SERVER); network.registerMessage(PacketSToggleOption.Handler.class, PacketSToggleOption.class, 19, Side.SERVER); network.registerMessage(PacketSUpdateSliderValue.Handler.class, PacketSUpdateSliderValue.class, 20, Side.SERVER); network.registerMessage(PacketSRemoveCameraTag.Handler.class, PacketSRemoveCameraTag.class, 21, Side.SERVER); }
@SubscribeEvent public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) { if(event.player instanceof EntityPlayerMP) { ServerConfigMessage msg = new ServerConfigMessage(); msg.recipeVillagerSlabsIsRecovery = CommonProxy.recipeVillagerSlabsIsRecovery; SimpleNetworkWrapper netwrapper = CubicVillager.getProxy().simpleNetWrapper; netwrapper.sendTo(msg, (EntityPlayerMP)event.player); StringBuilder spawnedMessage = new StringBuilder(64); spawnedMessage.append("プレイヤー ") .append(((EntityPlayerMP)event.player).getName()) .append(" がワールドに参加しました。設定を送信しました。"); CubicVillager.LOG.info(spawnedMessage); } }
public static void registerNetworkMessages(SimpleNetworkWrapper net) { INSTANCE = net; // Server side // Client side net.registerMessage(PacketSendCleanAirToClient.Handler.class, PacketSendCleanAirToClient.class, PacketHandler.nextID(), Side.CLIENT); net.registerMessage(PacketIntegersFromServer.Handler.class, PacketIntegersFromServer.class, PacketHandler.nextID(), Side.CLIENT); net.registerMessage(PacketPoisonFromServer.Handler.class, PacketPoisonFromServer.class, PacketHandler.nextID(), Side.CLIENT); }
@Mod.EventHandler public void onPreInit(FMLPreInitializationEvent event) { Possessed.proxy.onPreInit(); Possessed.networkWrapper = new SimpleNetworkWrapper(Possessed.MODID); Possessed.networkWrapper.registerMessage(PossessMessage.Handler.class, PossessMessage.class, 0, Side.CLIENT); Possessed.networkWrapper.registerMessage(UpdatePossessedDataMessage.Handler.class, UpdatePossessedDataMessage.class, 1, Side.CLIENT); Possessed.networkWrapper.registerMessage(PossessClickEmptyMessage.Handler.class, PossessClickEmptyMessage.class, 2, Side.SERVER); Possessed.networkWrapper.registerMessage(PossessHurtMessage.Handler.class, PossessHurtMessage.class, 3, Side.CLIENT); Possessed.networkWrapper.registerMessage(SyncDataMessage.Handler.class, SyncDataMessage.class, 4, Side.CLIENT); Possessed.networkWrapper.registerMessage(StopPossessingMessage.Handler.class, StopPossessingMessage.class, 5, Side.SERVER); }
private final void setupNetwork(FMLPreInitializationEvent event) { SimpleNetworkWrapper modChannel = NetworkRegistry.INSTANCE.newSimpleChannel(ARKCraft.MODID); ARKCraft.modChannel = modChannel; int id = 0; // The handler (usually in the packet class), the packet class, unique // identifier, side to be handled modChannel.registerMessage(OpenPlayerCrafting.Handler.class, OpenPlayerCrafting.class, id++, Side.SERVER); modChannel.registerMessage(PlayerPoop.Handler.class, PlayerPoop.class, id++, Side.SERVER); modChannel.registerMessage(OpenAttachmentInventory.Handler.class, OpenAttachmentInventory.class, id++, Side.SERVER); modChannel.registerMessage(ReloadStarted.Handler.class, ReloadStarted.class, id++, Side.SERVER); modChannel.registerMessage(ReloadFinished.Handler.class, ReloadFinished.class, id++, Side.CLIENT); modChannel.registerMessage(MessageHover.class, MessageHover.class, id++, Side.CLIENT); modChannel.registerMessage(MessageHoverReq.class, MessageHoverReq.class, id++, Side.SERVER); modChannel.registerMessage(BurnerToggle.Handler.class, BurnerToggle.class, id++, Side.SERVER); modChannel.registerMessage(UpdateEngrams.Handler.class, UpdateEngrams.class, id++, Side.CLIENT); modChannel.registerMessage(ARKPlayerUpdateRequest.Handler.class, ARKPlayerUpdateRequest.class, id++, Side.SERVER); modChannel.registerMessage(ARKPlayerUpdate.Handler.class, ARKPlayerUpdate.class, id++, Side.CLIENT); modChannel.registerMessage(PlayerEngramCrafterUpdate.Handler.class, PlayerEngramCrafterUpdate.class, id++, Side.CLIENT); modChannel.registerMessage(ScrollGui.Handler.class, ScrollGui.class, id++, Side.SERVER); modChannel.registerMessage(ARKModeToggle.Handler.class, ARKModeToggle.class, id++, Side.SERVER); modChannel.registerMessage(GunFired.Handler.class, GunFired.class, id++, Side.SERVER); }
public static SimpleNetworkWrapper registerNetwork() { id = 0; net = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); net.registerMessage(MessageCustomClick.Handler.class, MessageCustomClick.class, id++, Side.SERVER); net.registerMessage(MessageRecipeSync.Handler.class, MessageRecipeSync.class, id++, Side.SERVER); net.registerMessage(MessageCraftingSync.Handler.class, MessageCraftingSync.class, id++, Side.CLIENT); net.registerMessage(MessageFilterUpdate.Handler.class, MessageFilterUpdate.class, id++, Side.CLIENT); net.registerMessage(MessageSecureSync.Handler.class, MessageSecureSync.class, id++, Side.CLIENT); net.registerMessage(MessageSecurePlayer.Handler.class, MessageSecurePlayer.class, id++, Side.SERVER); return net; }
public static <UTileEntity extends TileEntity & PartialUpdateHandler> void sendTileEntityUpdatePacket(UTileEntity tileEntity, String context, SimpleNetworkWrapper network, EntityPlayer player, Object... params) { if (!(player instanceof EntityPlayerMP)) throw new UnsupportedOperationException(); network.sendTo(PacketTileEntityData.packetEntityData(tileEntity, context, params), (EntityPlayerMP) player); }
public static void sendToPlayersWatchingChunk(World world, int chunkX, int chunkZ, SimpleNetworkWrapper network, IMessage message) { List<EntityPlayerMP> playersWatching = getPlayersWatchingChunk(world, chunkX, chunkZ); for (EntityPlayerMP playerMP : playersWatching) { network.sendTo(message, playerMP); } }
public static void sendEEPUpdatePacketToPlayer(Entity entity, String capabilityKey, EnumFacing facing, String context, SimpleNetworkWrapper network, EntityPlayer player, Object... params) { if (!(player instanceof EntityPlayerMP)) throw new UnsupportedOperationException(); network.sendTo(PacketEntityCapabilityData.packetEntityData(entity, capabilityKey, facing, context, params), (EntityPlayerMP) player); }
public static void sendEEPUpdatePacket(Entity entity, String capabilityKey, EnumFacing facing, String context, SimpleNetworkWrapper network, Object... params) { if (entity.world.isRemote) throw new UnsupportedOperationException(); for (EntityPlayer player : ((WorldServer) entity.world).getEntityTracker().getTrackingPlayers(entity)) sendEEPUpdatePacketToPlayer(entity, capabilityKey, facing, context, network, player, params); if (entity instanceof EntityPlayerMP) // Players don't 'track' themselves sendEEPUpdatePacketToPlayer(entity, capabilityKey, facing, context, network, (EntityPlayer) entity, params); }
public static <ETileEntity extends TileEntity & ClientEventHandler> void sendTileEntityEventPacket(ETileEntity tileEntity, String context, SimpleNetworkWrapper network, Object... params) { if (!(tileEntity.getWorld().isRemote)) throw new UnsupportedOperationException(); network.sendToServer(PacketTileEntityClientEvent.packetEntityData(tileEntity, context, params)); }
public static void registerMessages(SimpleNetworkWrapper net) { INSTANCE = net; registerMessages(); }
public static SimpleNetworkWrapper getInstance() { if (INSTANCE == null) { INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(ModGlobals.MODID); } return INSTANCE; }
public static SimpleNetworkWrapper getSimpleNetworkWrapper() { return network; }
public static SimpleNetworkWrapper getSnw() { return instance.snw; }
public static final SimpleNetworkWrapper getNetwork() { return network; }
public static SimpleNetworkWrapper getNetworkWrapper() { return Possessed.networkWrapper; }
public ConfigHandler(String modid, Logger log, SimpleNetworkWrapper network) { this.modid = modid; this.log = log; this.network = network; }
public static void init(@Nonnull final SimpleNetworkWrapper network) { network.registerMessage(StructurePacket.Handler.class, StructurePacket.class, 1, Side.CLIENT); StructureNetwork.network = network; }
public NetworkWrapper(String channelName) { network = new SimpleNetworkWrapper(channelName); handler = new AbstactPacketHandler(); }
public static SimpleNetworkWrapper get() { return DISPATCHER; }
public SimpleNetworkWrapper getNetChannel() { return netChannel; }
public static SimpleNetworkWrapper getChannel() { return CHANNEL; }
public static void createChatSyncForMod(String modid, SimpleNetworkWrapper wrapper){ if(INSTANCE.containsKey(modid)) return; wrapper.registerMessage(MessageHandler.class, ChatMessage.class, 1, Side.CLIENT); INSTANCE.put(modid, new ChatSync(wrapper)); }
@Override public SimpleNetworkWrapper get() { return INSTANCE; }
public static void register(SimpleNetworkWrapper network) { int packetID = 0; network.registerMessage(PacketOpenExtendedInventory.class, PacketOpenExtendedInventory.class, packetID++, Side.SERVER); network.registerMessage(PacketOpenNormalInventory.class, PacketOpenNormalInventory.class, packetID++, Side.SERVER); network.registerMessage(PacketSyncExtendedInventory.class, PacketSyncExtendedInventory.class, packetID++, Side.CLIENT); network.registerMessage(PacketSpellShiftLeft.class, PacketSpellShiftLeft.class, packetID++, Side.SERVER); network.registerMessage(PacketSpellShiftRight.class, PacketSpellShiftRight.class, packetID++, Side.SERVER); network.registerMessage(PacketParticleAtPosition.class, PacketParticleAtPosition.class, packetID++, Side.CLIENT); network.registerMessage(PacketSpellFromServer.class, PacketSpellFromServer.class, packetID++, Side.SERVER); network.registerMessage(PacketWandGui.class, PacketWandGui.class, packetID++, Side.SERVER); network.registerMessage(PacketMovePlayerColumn.class, PacketMovePlayerColumn.class, packetID++, Side.SERVER); network.registerMessage(PacketMovePlayerHotbar.class, PacketMovePlayerHotbar.class, packetID++, Side.SERVER); network.registerMessage(PacketWarpButton.class, PacketWarpButton.class, packetID++, Side.SERVER); network.registerMessage(PacketNewButton.class, PacketNewButton.class, packetID++, Side.SERVER); network.registerMessage(PacketDeleteWaypoint.class, PacketDeleteWaypoint.class, packetID++, Side.SERVER); network.registerMessage(PacketDepositPlayerToNearby.class, PacketDepositPlayerToNearby.class, packetID++, Side.SERVER); network.registerMessage(PacketDepositContainerToPlayer.class, PacketDepositContainerToPlayer.class, packetID++, Side.SERVER); network.registerMessage(PacketQuickStack.class, PacketQuickStack.class, packetID++, Side.SERVER); network.registerMessage(PacketRestockContainerToPlayer.class, PacketRestockContainerToPlayer.class, packetID++, Side.SERVER); network.registerMessage(PacketOpenFakeWorkbench.class, PacketOpenFakeWorkbench.class, packetID++, Side.SERVER); network.registerMessage(PacketSpellBuildSize.class, PacketSpellBuildSize.class, packetID++, Side.SERVER); network.registerMessage(PacketSyncPlayerData.class, PacketSyncPlayerData.class, packetID++, Side.CLIENT); packetID++;//removed packets from a refactor . KEEP THESE lines so packet ids dont mismatch packetID++; network.registerMessage(PacketSyncPlayerHealth.class, PacketSyncPlayerHealth.class, packetID++, Side.CLIENT); network.registerMessage(PacketTilePassword.class, PacketTilePassword.class, packetID++, Side.SERVER); network.registerMessage(PacketMoveBlock.class, PacketMoveBlock.class, packetID++, Side.SERVER); packetID++; network.registerMessage(PacketSwapBlock.class, PacketSwapBlock.class, packetID++, Side.SERVER); network.registerMessage(PacketRandomize.class, PacketRandomize.class, packetID++, Side.SERVER); network.registerMessage(PacketChestSack.class, PacketChestSack.class, packetID++, Side.SERVER); network.registerMessage(PacketTileRedstoneToggle.class, PacketTileRedstoneToggle.class, packetID++, Side.SERVER); network.registerMessage(PacketTileSizeToggle.class, PacketTileSizeToggle.class, packetID++, Side.SERVER); network.registerMessage(PacketTileIncrementField.class, PacketTileIncrementField.class, packetID++, Side.SERVER); packetID++; network.registerMessage(PacketTilePatternSwap.class, PacketTilePatternSwap.class, packetID++, Side.SERVER); packetID++; network.registerMessage(PacketTileVector.class, PacketTileVector.class, packetID++, Side.SERVER); network.registerMessage(PacketPlayerFalldamage.class, PacketPlayerFalldamage.class, packetID++, Side.SERVER); network.registerMessage(PacketSyncPlayerFlying.class, PacketSyncPlayerFlying.class, packetID++, Side.CLIENT); network.registerMessage(PacketSyncVillagerToClient.class, PacketSyncVillagerToClient.class, packetID++, Side.CLIENT); network.registerMessage(PacketSyncVillagerToServer.class, PacketSyncVillagerToServer.class, packetID++, Side.SERVER); network.registerMessage(PacketVillagerTrade.class, PacketVillagerTrade.class, packetID++, Side.SERVER); network.registerMessage(PacketSleepClient.class, PacketSleepClient.class, packetID++, Side.CLIENT); packetID++; network.registerMessage(PacketItemToggle.class, PacketItemToggle.class, packetID++, Side.SERVER); network.registerMessage(PacketTilePylon.class, PacketTilePylon.class, packetID++, Side.SERVER); network.registerMessage(PacketSound.class, PacketSound.class, packetID++, Side.CLIENT); network.registerMessage(PacketFluidSync.class, PacketFluidSync.class, packetID++, Side.CLIENT); network.registerMessage(PacketSwapPlayerHotbar.class, PacketSwapPlayerHotbar.class, packetID++, Side.SERVER); network.registerMessage(PacketTileFacingToggle.class, PacketTileFacingToggle.class, packetID++, Side.SERVER); network.registerMessage(PacketTileSetField.class, PacketTileSetField.class, packetID++, Side.SERVER); network.registerMessage(PacketTileFuelDisplay.class, PacketTileFuelDisplay.class, packetID++, Side.SERVER); network.registerMessage(PacketGuiShortOverride.class, PacketGuiShortOverride.class, packetID++, Side.CLIENT); network.registerMessage(PacketTileTextbox.class, PacketTileTextbox.class, packetID++, Side.SERVER); network.registerMessage(PacketScythe.class, PacketScythe.class, packetID++, Side.SERVER); }
public static SimpleNetworkWrapper getNetwork() { return network; }
public SimpleNetworkWrapper getNet() { return NETWORK; }
public PenguinNetwork(String name) { INSTANCE = new SimpleNetworkWrapper(name); handler = new PenguinPacketHandler(); }
public void registerPackets(SimpleNetworkWrapper network) { network.registerMessage(TPMachineConfiguration.Handler.class, TPMachineConfiguration.class, 1, Side.SERVER); network.registerMessage(TPAdvancedGuiAppData.Handler.class, TPAdvancedGuiAppData.class, 2, Side.SERVER); }