@Override public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) { try {URL version = new URL("https://raw.github.com/DrEinsteinium/WikiLink/master/version.txt"); BufferedReader in = new BufferedReader(new InputStreamReader(version.openStream())); String line; String wholeString = ""; while((line = in.readLine()) != null) wholeString += " "+line; if(!wholeString.contains(Reference.VER_MODHASH)) netHandler.getPlayer().addChatMessage("\u00A76[\u00A7aWikiLink\u00A76]\u00A7c WikiLink is out of date for your Minecraft version. Please update at www.catacombs.co for the latest version."); in.close(); } catch (Exception e) { e.printStackTrace(); netHandler.getPlayer().addChatMessage("\u00A76[\u00A7aWikiLink\u00A76]\u00A74 There was a problem while checking the version of WikiLink. Please report this at \u00A79www.catacombs.co/contact-me/"); } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { try { if (packet.channel.equals(CHANNEL_GRAVE_UPGRADE)) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { if (Minecraft.getMinecraft().currentScreen instanceof GraveUpgradeGui) { ((GraveUpgradeGui) (Minecraft.getMinecraft().currentScreen)).updateInfoFromPacket(NetworkHelper.byteArrayToNBT(packet.data)); } } else { MiscHelper.setPersistentDataTag((EntityPlayer) player, BSConstants.NBT_PLAYER_GRAVE_DATA, NetworkHelper.byteArrayToNBT(packet.data)); } } } catch (Exception e) { e.printStackTrace(); } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if (player instanceof EntityPlayerMP) { EntityPlayerMP playerMP = (EntityPlayerMP) player; RemoteKey rk = new RemoteKey(packet); Map<String, Boolean> playerKeyMap; if (!playerKeys.containsKey(playerMP.username)) { playerKeyMap = new HashMap<String, Boolean>(); playerKeys.put(playerMP.username, playerKeyMap); } else { playerKeyMap = playerKeys.get(playerMP.username); } playerKeyMap.put(rk.getName(), rk.isDown()); } }
public static void handlePacket( BillundPacket packet, Player player ) { switch( packet.packetType ) { case BillundPacket.OrderSet: { EntityPlayer entity = (EntityPlayer)player; World world = entity.worldObj; int set = packet.dataInt[0]; int cost = BillundSet.get( set ).getCost(); if( removeEmeralds( entity, cost ) ) { Random r = new Random(); world.spawnEntityInWorld( new EntityAirDrop( world, Math.floor( entity.posX - 8 + r.nextInt(16) ) + 0.5f, Math.min( world.getHeight(), 255 ) - r.nextInt(32) - 0.5f, Math.floor( entity.posZ - 8 + r.nextInt(16) ) + 0.5f, set ) ); } break; } } }
private void handleStats(Packet250CustomPayload packet, Player player, DataInputStream inputStream){ FCraftJobCore props = FCraftJobCore.get((EntityPlayer) player); float[] newStats = new float[4]; try { for(int i=0;i<4;i++){ newStats[i] = inputStream.readFloat(); } props.setStats(newStats[0], newStats[1], newStats[2], newStats[3]); props.setLevelUpPoints(inputStream.readInt()); props.setLevel(inputStream.readInt()); props.setMaxExperience(inputStream.readInt()); props.setCurrentMateria(inputStream.readInt()); } catch (IOException e) { e.printStackTrace(); } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { EntityPlayer sender = (EntityPlayer) player; if (packet.channel.equals(Resources.PACKET_CHANNEL)) { DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data)); int id = -1; try { id = data.readInt(); } catch (IOException e) { e.printStackTrace(); } } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if (packet.channel.equals(Resources.PACKET_CHANNEL)) { DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data)); try { int id = -1; id = data.readInt(); EntityPlayer p = (EntityPlayer) player; } catch (IOException e) { e.printStackTrace(); } } }
@Override public void onPacketData(INetworkManager network, int packetID, DataInputStream data, Player player) { try { switch (packetID) { case PacketIds.HABITAT_BIOME_POINTER: PacketCoordinates packetC = new PacketCoordinates(); packetC.readData(data); Proxies.common.setBiomeFinderCoordinates(null, packetC.getCoordinates()); break; case PacketIds.GENOME_TRACKER_UPDATE: PacketNBT packetN = new PacketNBT(); packetN.readData(data); onGenomeTrackerUpdate((EntityPlayer) player, packetN); break; case PacketIds.IMPRINT_SELECTION_GET: onImprintSelectionGet((EntityPlayer) player); break; } } catch (Exception ex) { ex.printStackTrace(); } }
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer me, int par6, float par7, float par8, float par9) { if(!me.isSneaking()){ int meta = world.getBlockMetadata(x, y, z); TileEntity tile = world.getBlockTileEntity(x, y, z); if(meta == 0 && tile != null && tile instanceof TileDualFurnace){ PacketDispatcher.sendPacketToPlayer(tile.getDescriptionPacket(), (Player)me); me.openGui(MineTechPlus.instance, GuiIds.GUI_DUALFURNACE, world, x, y, z); return true; } if(meta == 1 && tile != null && tile instanceof TileSuperContainer){ me.openGui(MineTechPlus.instance, GuiIds.GUI_SUPER_CONTAINER, world, x, y, z); return true; } } return false; }
private void handleClientPacket(Packet250CustomPayload packet, Player player) { if(Reference.DEBUG)System.out.println("Client Packet Received"); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(packet.data)); try { int packetId = dis.readInt(); if(Reference.DEBUG)System.out.println("Handling packet with id:"+packetId); if(packetId == 1){ } if(packetId == 2){ // Idea refining /*int x = dis.readInt(); int y = dis.readInt(); int z = dis.readInt(); int d = dis.readInt(); int c = dis.readInt(); World w = DimensionManager.getWorld(d); TileEntity tile = w.getBlockTileEntity(x, y, z); if(tile instanceof TileWorkstation) ((TileWorkstation) tile).cooldown = c;*/ } }catch(Exception e){ e.printStackTrace(); } }
@Override public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) { try { if (UpdateCheck.isUpdateAvailable()) { netHandler.getPlayer().sendChatToPlayer(ChatMessageComponent.createFromText("["+EnumChatFormatting.GOLD +"SkullForge"+EnumChatFormatting.RESET+"] An Update is available for this mod. Check http://goo.gl/ya0VpP for more info. (Your Version: "+EnumChatFormatting.AQUA+SkullForge.version+EnumChatFormatting.RESET+")")); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); netHandler.getPlayer().sendChatToPlayer(ChatMessageComponent.createFromText("["+EnumChatFormatting.GOLD +"SkullForge"+EnumChatFormatting.RESET+"]"+EnumChatFormatting.RED+" Unable to contact the Update Server!")); } //Uncomment for testing purposes only kthxbye :D //netHandler.getPlayer().sendChatToPlayer(ChatMessageComponent.createFromText("["+EnumChatFormatting.GOLD +"SkullForge"+EnumChatFormatting.RESET+"] Version "+EnumChatFormatting.AQUA+SkullForge.version+EnumChatFormatting.RESET+" loaded!")); }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { try{ NBTTagCompound packetTag = CompressedStreamTools.readCompressed(new ByteArrayInputStream(packet.data)); if(packetTag.getName().equalsIgnoreCase("favourite")){ handleFavouritePacket(packetTag);return; } if(packetTag.getName().equalsIgnoreCase("notify")){ handleNotifyPacket(packetTag);return; } }catch(Exception e){ throw new RuntimeException(e); } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { ByteArrayDataInput dat = ByteStreams.newDataInput(packet.data); byte packetID = dat.readByte(); switch(packetID) { case 0: handleSkillUpdate(dat); break; case 1: handleAllSkillsUpdate(dat); break; case 2: handleSkillAllUpdate(dat); break; } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player playerEntity) { DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); int packetSender; try { packetSender = inputStream.readInt(); } catch (IOException e) { e.printStackTrace(); return; } if (playerEntity instanceof EntityPlayer) { EntityPlayer player = ((EntityPlayer)playerEntity); if (packetSender==1) { //Jetpack updateJetpack(packet, player); } else if (packetSender==2) { //ExplosionRing updateExplosionRing(packet, player); } } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player p) { final DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data)); final int packetType = PacketUtil.readPacketID(data); EntityPlayer player = (EntityPlayer) p; if (packetType == 0) { final Class<?>[] decodeAs = { Integer.class, Integer.class, Integer.class }; final Object[] packetReadout = PacketUtil.readPacketData(data, decodeAs); int entityID = 0; Entity entity = null; switch ((Integer) packetReadout[1]) { case 0: entityID = (Integer) packetReadout[2]; entity = player.worldObj.getEntityByID(entityID); } } }
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { int packetID = -1; try { ByteArrayInputStream array = new ByteArrayInputStream( packet.data ); DataInputStream stream = new DataInputStream( array ); packetID = stream.readByte(); SLPMod.proxy.handlePacket( packetID, stream, (EntityPlayer) player ); stream.close(); } catch ( Exception e ) { System.err.println( "Error while processing PP Packet #" + packetID + " !" ); e.printStackTrace(); } }
@Override public void onPacketData(INetworkManager network, Packet250CustomPayload packet, Player player) { Utils.log("ClientPacketHandler: Side is " + FMLCommonHandler.instance().getSide()); Utils.log("ClientPacketHandler: Packet Recieved"); DataInputStream stream = new DataInputStream(new ByteArrayInputStream(packet.data)); // Read the first int to determine packet type try { this.packetType = stream.readInt(); } catch (Exception ex) { ex.printStackTrace(); } /* * each packet type needs to implement an if and then whatever other * read functions it needs complete with try/catch blocks */ if (this.packetType == 0) { // GuiExpBook button pressed // Nothing happens here I think ahh } Utils.log("ClientPacketHandler: Press 1 complete!"); if (this.packetType == 1) { // Unimplemented, yay! :D } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { try { DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); byte packetType; try { packetType = inputStream.readByte(); switch (packetType) { case PACKET_KEY_PRESS: handlePacketKeyPress(packet, (EntityPlayer) player, inputStream); break; default: LogHelper.log(Level.SEVERE, "Unhandled packet exception for packet id " + packetType); } } finally { inputStream.close(); } } catch (IOException e) { e.printStackTrace(); } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { final String channel = packet.channel; final boolean isServer = CCTags.proxy.isServer(); try { SubHandler h = handlers.get(channel); Preconditions.checkNotNull(h, "Invalid channel: %s", channel); if (h.checkSide(isServer)) { DataInput input = ByteStreams.newDataInput(packet.data); h.handle(manager, player, input); } else Log.warning("Message on channel %s from player %s sent into wrong direction", channel, player); } catch (Exception e) { if (isServer) Log.severe(e, "Invalid message from player %s on channel %s", player, channel); else Log.severe(e, "Invalid message from server on channel %s", channel); } }
@Override public void doSpellCasterEffect(EntityPlayer caster) { caster.worldObj.playSoundAtEntity(caster, "mob.enderdragon.wings", 1.0F, 1.0F); if (caster.onGround) { caster.motionY += 1.0D; } caster.fallDistance = 0; caster.capabilities.allowFlying = true; caster.capabilities.isFlying = true; SpellboundCore.getInstance().addActiveSpellToEntity(caster, this, 20); PacketDispatcher.sendPacketToPlayer(PacketHandler.createFlightPacket(true), (Player) caster); }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if(packet.channel.equals(CHANNEL_NAME)) { try { ByteArrayInputStream byteStream = new ByteArrayInputStream(packet.data); DataInputStream dataStream = new DataInputStream(byteStream); byte msgType = dataStream.readByte(); switch(msgType) { case CARVING_ACTION: handleCarvingAction(dataStream, player); break; case CARVING_DATA: handleCarvingData(dataStream, player); break; } } catch(Throwable tt) { tt.printStackTrace(); } } }
private void switchItems(Packet250CustomPayload packet, Player playerEntity) { if(packet.data != null) { DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); int selection; int currentItem; try { selection = inputStream.readInt(); currentItem = inputStream.readInt(); } catch (IOException e) { e.printStackTrace(); return; } EntityPlayerMP player = (EntityPlayerMP) playerEntity; InventoryPlayer inv = player.inventory; ItemStack toSwitch = inv.mainInventory[selection]; //stores the selected item ItemStack hotbarItem = inv.mainInventory[currentItem]; //stores the item from the hotbar inv.mainInventory[currentItem] = toSwitch; //move the item from the inventory to the hotbar inv.mainInventory[selection] = hotbarItem; //move the hotbar item to the inventory } }
/** * {@inheritDoc} */ @Override public void onPacketData(final INetworkManager manager, final Packet250CustomPayload packet, final Player player) { if (packet.channel.equals(VoiceChat.MOD_ID)) { try { // Creates the packet. final ByteArrayInputStream bis = new ByteArrayInputStream( packet.data); final DataInputStream dis = new DataInputStream(bis); final Command c = Command.values()[dis.readInt()]; final PacketCommandBase p = c.newInstance(); p.read(dis); p.execute(); } catch (final Exception e) { FMLLog.log(VoiceChat.MOD_ID, Level.SEVERE, e, "Could not read the packet"); } } }
public void removePlayer(Player player) { if (player1 == (EntityPlayer) player) { player1 = player2; player2 = null; playerCount--; pos2 = -1; } else if (player2 == (EntityPlayer) player) { player2 = null; playerCount--; pos2 = -1; } if (playerCount < 0) playerCount = 0; if (playerCount == 1) ((EntityPlayerMP) player1).playerNetServerHandler.sendPacketToPlayer(PacketCreator.createStringPacket(EnumPackets.RegisterTrader, "")); }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if (packet.channel.equals("UCTS_TileEntity")) { handleTEPacket(manager, packet, player); } else if (packet.channel.equals("UCTS_Buttons")) { handleButtonsPacket(manager, packet, player); } else if (packet.channel.equals("UCTS_TE_Request")){ handleTERequest(manager, packet, player); } }
private void handleTEPacket(INetworkManager manager, Packet250CustomPayload packet, Player player) { // Packet always server-to-player. EntityPlayer entityPlayer = (EntityPlayer) player; World world = entityPlayer.worldObj; if (!world.isRemote) { Minecraft.getMinecraft().getLogAgent() .logWarning("UniversalCoins: TileEntity packet received by server."); } int coinSum, x = 0, y = 0, z = 0, dimension; boolean bypass; DataInputStream stream = new DataInputStream(new ByteArrayInputStream( packet.data)); try { coinSum = stream.readInt(); x = stream.readInt(); y = stream.readInt(); z = stream.readInt(); dimension = stream.readInt(); bypass = stream.readBoolean(); } catch (Exception ex) { ex.printStackTrace(); return; } if (world.getWorldInfo().getVanillaDimension() != dimension) { return; } TileEntity tEntity = world.getBlockTileEntity(x, y, z); if (tEntity != null && tEntity instanceof UCTileEntity) { UCTileEntity ucTileEntity = (UCTileEntity) tEntity; ucTileEntity.coinSum = coinSum; ucTileEntity.bypassActive = bypass; ucTileEntity.onInventoryChanged(); } }
private void handleTERequest(INetworkManager manager, Packet250CustomPayload packet, Player player) { // Packet always player-to-server EntityPlayer entityPlayer = (EntityPlayer) player; World world = entityPlayer.worldObj; if (world.isRemote) { Minecraft.getMinecraft().getLogAgent() .logWarning("UniversalCoins: TE Request packet received by client."); } int x = 0, y = 0, z = 0, dimension; DataInputStream stream = new DataInputStream(new ByteArrayInputStream( packet.data)); try { x = stream.readInt(); y = stream.readInt(); z = stream.readInt(); dimension = stream.readInt(); } catch (Exception ex) { ex.printStackTrace(); return; } if (world.getWorldInfo().getVanillaDimension() != dimension) { return; } TileEntity tEntity = world.getBlockTileEntity(x, y, z); if (tEntity != null && tEntity instanceof UCTileEntity) { UCTileEntity ucTileEntity = (UCTileEntity) tEntity; ucTileEntity.dispatchPackage(); } }
/** * 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); } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { switch (packet.data[0]) { case 0: EntityPlayerMP playerMP = (EntityPlayerMP) player; playerMP.openGui(RecipeIGE.instance, 0, playerMP.worldObj, 0, 0, 0); break; } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload _packet, Player player) { try { BillundPacket packet = BillundPacket.parse( _packet.data ); Billund.handlePacket( packet, player ); } catch( Exception e ) { // Something failed, ignore it //e.printStackTrace(); } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); byte packetType; try { packetType = inputStream.readByte(); } catch (IOException e) { e.printStackTrace(); return; } if(packet.channel.equals("GenericClass")){ switch(packetType) { case EXTENDED_PROPERTIES: handleClass(packet, player, inputStream); break; case OPEN_SERVER_GUI: handleOpenServerGui(packet, (EntityPlayer) player, inputStream); break; case EXTENDED_SPEC: handleSpec(packet, player, inputStream); break; case EXTENDED_WEAPONS: handleWeapon(packet, player, inputStream); break; case EXTENDED_STATS: handleStats(packet, player, inputStream); break; case EXTENDED_CHAIN: handleChain(packet, player, inputStream); break; default: System.out.println("[PACKET][WARNING] Unknown packet type " + packetType); } } }
private void handleClass(Packet250CustomPayload packet, Player player, DataInputStream inputStream){ FCraftJobCore props = FCraftJobCore.get((EntityPlayer) player); try { props.setJob(inputStream.readInt()); } catch (IOException e) { e.printStackTrace(); } }
private void handleChain(Packet250CustomPayload packet, Player player, DataInputStream inputStream){ FCraftJobCore props = FCraftJobCore.get((EntityPlayer) player); try { props.setChainLevel(inputStream.readInt()); props.setLastEntityKilled(IOUtils.toString(inputStream)); } catch (IOException e) { e.printStackTrace(); } }
private void handleWeapon(Packet250CustomPayload packet, Player player, DataInputStream inputStream){ FCraftJobCore props = FCraftJobCore.get((EntityPlayer) player); try { ItemStack itemstack = packet.readItemStack(inputStream); if (itemstack != null) { itemstack.setTagCompound(itemstack.getTagCompound()); } } catch (IOException e) { e.printStackTrace(); } }
private void handleSpec(Packet250CustomPayload packet, Player player, DataInputStream inputStream){ FCraftJobCore props = FCraftJobCore.get((EntityPlayer) player); try { props.setSpec(inputStream.readInt()); } catch (IOException e) { e.printStackTrace(); } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if(packet.channel.equals("RediscoveredMod")){ handlePacket(packet); } }
@Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if(tickData[0] instanceof Player && tickData[1] instanceof World) { Player player = (Player) tickData[0]; World w = (World) tickData[1]; // FysiksFun.tickPlayer(player, w); } }
@Deprecated public static void serverSendPacket(NetServerHandler handler, Packet packet) { if (handler != null) { PacketDispatcher.sendPacketToPlayer(packet, (Player)handler.getPlayer()); } }