/** * Checks timeouts and processes all pending read packets. */ public void processReadPackets() { int i = 2500; while (i-- >= 0 && !this.readPacketCache.isEmpty()) { Packet packet = readPacketCache.poll(); packet.processPacket(this.myNetHandler); } if (this.readPacketCache.size() > i) { this.field_98214_c.logWarning("Memory connection overburdened; after processing 2500 packets, we still have " + this.readPacketCache.size() + " to go!"); } if (this.shuttingDown && this.readPacketCache.isEmpty()) { this.myNetHandler.handleErrorMessage(this.shutdownReason, this.field_74439_g); FMLNetworkHandler.onConnectionClosed(this, this.myNetHandler.getPlayer()); } }
public void handleLogin(Packet1Login par1Packet1Login) { this.mc.playerController = new PlayerControllerMP(this.mc, this); this.mc.statFileWriter.readStat(StatList.joinMultiplayerStat, 1); this.worldClient = new WorldClient(this, new WorldSettings(0L, par1Packet1Login.gameType, false, par1Packet1Login.hardcoreMode, par1Packet1Login.terrainType), par1Packet1Login.dimension, par1Packet1Login.difficultySetting, this.mc.mcProfiler, this.mc.getLogAgent()); this.worldClient.isRemote = true; this.mc.loadWorld(this.worldClient); this.mc.thePlayer.dimension = par1Packet1Login.dimension; this.mc.displayGuiScreen(new GuiDownloadTerrain(this)); this.mc.thePlayer.entityId = par1Packet1Login.clientEntityId; this.currentServerMaxPlayers = par1Packet1Login.maxPlayers; this.mc.playerController.setGameType(par1Packet1Login.gameType); FMLNetworkHandler.onConnectionEstablishedToServer(this, netManager, par1Packet1Login); this.mc.gameSettings.sendSettingsToServer(); this.netManager.addToSendQueue(new Packet250CustomPayload("MC|Brand", ClientBrandRetriever.getClientModName().getBytes(Charsets.UTF_8))); }
/** * Called upon block activation (right click on the block.) */ @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if(!world.isRemote){ if(world.getBlockMetadata(x, y, z) % 4 == 0 && !world.isBlockSolidOnSide(x, y + 1, z, DOWN)) FMLNetworkHandler.openGui(player, StorageCraft.instance, 0, world, x, y, z); else if(world.getBlockMetadata(x, y, z) % 4 == 1 && !world.isBlockSolidOnSide(x, y + 1, z, DOWN)) FMLNetworkHandler.openGui(player, StorageCraft.instance, 1, world, x, y, z); else if(world.getBlockMetadata(x, y, z) % 4 == 2 && !world.isBlockSolidOnSide(x, y + 1, z, DOWN)) FMLNetworkHandler.openGui(player, StorageCraft.instance, 2, world, x, y, z); else if (world.getBlockMetadata(x, y, z) % 4 == 3 && !world.isBlockSolidOnSide(x, y + 1, z, DOWN)) FMLNetworkHandler.openGui(player, StorageCraft.instance, 3, world, x, y, z); } return true; }
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { // We want the GUI opening to be handled on the serverside if (!world.isRemote) { /* * Play to open GUI on, Mod instance, ID of the GUI, world of the * player/world to open GUI, xyz coords of the block to open the GUI * on */ FMLNetworkHandler.openGui(player, IceCraft.instance, Ids.refrigerator_gui, world, x, y, z); } // We want the GUI to open regardless whether it is the client or server return true; }
/** * For catching interactions with the Undertaker */ @ForgeSubscribe public void interactEvent(EntityInteractEvent event) { if (event.target instanceof EntityVillager && ((EntityVillager) event.target).getProfession() == BurialServices.getConfig().villagerID) { if (FMLCommonHandler.instance().getSide().isServer()) { PacketDispatcher.sendPacketToPlayer(NetworkHelper.makeNBTPacket(BSConstants.CHANNEL_GRAVE_UPGRADE, MiscHelper.getPersistentDataTag(event.entityPlayer, BSConstants.NBT_PLAYER_GRAVE_DATA)), (Player) event.entityPlayer); } event.setCanceled(MinecraftServer.getServer().isSinglePlayer()); FMLNetworkHandler.openGui(event.entityPlayer, BurialServices.instance, GuiHandler.undertakerID, event.entityPlayer.worldObj, 0, 0, 0); } }
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){ if(!world.isRemote){ FMLNetworkHandler.openGui(player, RunesAndSilver.instance, RunesAndSilver.guiIdSilverFurnace, world, x, y, z); } return true; }
/** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { if(!world.isRemote) { FMLNetworkHandler.openGui(entityplayer, mod_Rediscovered.instance, mod_Rediscovered.guiIDLockedChest, world, x, y, z); } return true; }
@Subscribe public void constructMod(FMLConstructionEvent event) { try { ModClassLoader modClassLoader = event.getModClassLoader(); modClassLoader.addFile(modSource); EnumSet<TickType> ticks = EnumSet.noneOf(TickType.class); this.gameTickHandler = new BaseModTicker(ticks, false); this.guiTickHandler = new BaseModTicker(ticks.clone(), true); Class<? extends BaseModProxy> modClazz = (Class<? extends BaseModProxy>) modClassLoader.loadBaseModClass(modClazzName); configureMod(modClazz, event.getASMHarvestedData()); isNetworkMod = FMLNetworkHandler.instance().registerNetworkMod(this, modClazz, event.getASMHarvestedData()); ModLoaderNetworkHandler dummyHandler = null; if (!isNetworkMod) { FMLLog.fine("Injecting dummy network mod handler for BaseMod %s", getModId()); dummyHandler = new ModLoaderNetworkHandler(this); FMLNetworkHandler.instance().registerNetworkMod(dummyHandler); } Constructor<? extends BaseModProxy> ctor = modClazz.getConstructor(); ctor.setAccessible(true); mod = modClazz.newInstance(); if (dummyHandler != null) { dummyHandler.setBaseMod(mod); } ProxyInjector.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide(), new ILanguageAdapter.JavaAdapter()); } catch (Exception e) { controller.errorOccurred(this, e); Throwables.propagateIfPossible(e); } }
@Subscribe public void modConstruction(FMLConstructionEvent evt) { FMLLog.info("Registering Forge Packet Handler"); try { FMLNetworkHandler.instance().registerNetworkMod(new ForgeNetworkHandler(this)); FMLLog.info("Succeeded registering Forge Packet Handler"); } catch (Exception e) { FMLLog.log(Level.SEVERE, e, "Failed to register packet handler for Forge"); } }
/** * Checks timeouts and processes all pending read packets. */ public void processReadPackets() { if (this.sendQueueByteLength > 2097152) { this.networkShutdown("disconnect.overflow", new Object[0]); } if (this.readPackets.isEmpty()) { if (this.field_74490_x++ == 1200) { this.networkShutdown("disconnect.timeout", new Object[0]); } } else { this.field_74490_x = 0; } int i = 1000; while (i-- >= 0) { Packet packet = (Packet)this.readPackets.poll(); if (packet != null && !this.theNetHandler.isConnectionClosed()) { packet.processPacket(this.theNetHandler); } } this.wakeThreads(); if (this.isTerminating && this.readPackets.isEmpty()) { this.theNetHandler.handleErrorMessage(this.terminationReason, this.shutdownDescription); FMLNetworkHandler.onConnectionClosed(this, this.theNetHandler.getPlayer()); } }
@Override /** * Contains logic for handling packets containing arbitrary unique item data. Currently this is only for maps. */ public void handleMapData(Packet131MapData par1Packet131MapData) { FMLNetworkHandler.handlePacket131Packet(this, par1Packet131MapData); }
public NetClientHandler(Minecraft par1Minecraft, String par2Str, int par3) throws IOException { this.mc = par1Minecraft; Socket socket = new Socket(InetAddress.getByName(par2Str), par3); this.netManager = new TcpConnection(par1Minecraft.getLogAgent(), socket, "Client", this); FMLNetworkHandler.onClientConnectionToRemoteServer(this, par2Str, par3, this.netManager); }
public NetClientHandler(Minecraft par1Minecraft, String par2Str, int par3, GuiScreen par4GuiScreen) throws IOException { this.mc = par1Minecraft; this.field_98183_l = par4GuiScreen; Socket socket = new Socket(InetAddress.getByName(par2Str), par3); this.netManager = new TcpConnection(par1Minecraft.getLogAgent(), socket, "Client", this); FMLNetworkHandler.onClientConnectionToRemoteServer(this, par2Str, par3, this.netManager); }
public NetClientHandler(Minecraft par1Minecraft, IntegratedServer par2IntegratedServer) throws IOException { this.mc = par1Minecraft; this.netManager = new MemoryConnection(par1Minecraft.getLogAgent(), this); par2IntegratedServer.getServerListeningThread().func_71754_a((MemoryConnection)this.netManager, par1Minecraft.getSession().getUsername()); FMLNetworkHandler.onClientConnectionToIntegratedServer(this, par2IntegratedServer, this.netManager); }
public void quitWithPacket(Packet par1Packet) { if (!this.disconnected) { this.netManager.addToSendQueue(par1Packet); this.netManager.serverShutdown(); FMLNetworkHandler.onConnectionClosed(this.netManager, this.getPlayer()); } }
public void handleChat(Packet3Chat par1Packet3Chat) { par1Packet3Chat = FMLNetworkHandler.handleChatMessage(this, par1Packet3Chat); if (par1Packet3Chat == null) { return; } ClientChatReceivedEvent event = new ClientChatReceivedEvent(par1Packet3Chat.message); if (!MinecraftForge.EVENT_BUS.post(event) && event.message != null) { this.mc.ingameGUI.getChatGUI().printChatMessage(ChatMessageComponent.createFromJson(event.message).toStringWithFormatting(true)); } }
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float a, float b, float c) { if (!world.isRemote){ FMLNetworkHandler.openGui(player, KingdomKeys.instance, 0, world, x, y, z); } return true; }
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { FMLNetworkHandler.openGui(player, TechnicalWizardry.instance, GuiIds.ItemInserter, world, x, y, z); } return true; }
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { FMLNetworkHandler.openGui(player, TechnicalWizardry.instance, GuiIds.PlayerLinkedBlock, world, x, y, z); } return true; }
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { FMLNetworkHandler.openGui(player, TechnicalWizardry.instance, GuiIds.Forge, world, x, y, z); } return true; }
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { FMLNetworkHandler.openGui(player, TechnicalWizardry.instance, GuiIds.Buffer, world, x, y, z); } return true; }
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { FMLNetworkHandler.openGui(player, TechnicalWizardry.instance, GuiIds.VacuumChest, world, x, y, z); } return true; }
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { FMLNetworkHandler.openGui(player, TechnicalWizardry.instance, GuiIds.SpecificItemInserter, world, x, y, z); } return true; }
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { FMLNetworkHandler.openGui(player, TechnicalWizardry.instance, GuiIds.ItemMover, world, x, y, z); } return true; }