Hi. I realized, that a lot of people have issues figuring out the constructors of the packets, or most of the people use fields, to set these variables, instead of doing it in 1 line. This is not a straight copy from the protocol reference, some things are different than what it is in bukkit or spigot. Note: x, y and z coordinates can be changed to blockPositions in spigot 1.8, be careful packets (Move your mouse to reveal the content) packets (open) packets (close) PacketPlayOutAbilities - PlayerAbilities playerAbilities Note: PlayerAbilities is a nms class, wich contains the main server information about a the player (canFly, isOp, etc.)PacketPlayOutBed - EntityHuman player, int x, int y, int z PacketPlayOutBlockAction - BlockPosition position, byte byte1, byte byte2 Note: Used for note blocks, pistons and chests byte1 and byte2 do different things between different blocks, more herePacketPlayOutBlockBreakAnimation - int entityId, int x, int y, int, z, int breakStage breakStage can be 1-7 and -1, -1 is the original, 1 is the first animation phase, 7 is the last onePacketPlayOutBlockChange - World (nms version) world, int x, y, z Note: x, y and z changed to BlockPosition in spigot 1.8PacketPlayOutChat - IChatBaseComponent message, byte type Note: type can be 0, 1 and 2, 2 is only supported inspigot 1.8 and up 0 - chat; 1 - system message; 2 - actionbarPacketPlayOutCloseWindow - int windowId Note: This represents, when a window is forced to get closed (e.g. destroying a sign)PacketPlayOutCollect - int entityId, int itemEntityID Note: This doesn't include setting the item in the inventory, nor removing the itemPacketPlayOutAttachEntity - int leash, Entity atachedEntity, Entity vehicle Note: leash can be either 0 or 1. 0 is not leashed attach (horses, riding pigs), 1 is for leashed attach (you caught a zombie with a leash(good for you))PacketPlayOutEntity - int entityId PacketPlayOutEntityDestroy - int[] entityIds PacketPlayOutEntityEffect - int entityId, MobEffect mobEffect PacketPlayOutEntityEquipment - int entityId, int slot, ItemStack itemStack PacketPlayOutEntityHeadRotation - int entityId, byte deltaAngle PacketPlayOutEntityLook - int entityId, byte newAngle Note: The different between this and headRotation, is that this sets the mobs head to the set value, but the headRotation adds the rotation to the current onePacketPlayOutEntityStatus - int entityId, byte status Note: Status can differ from 1 to 23, can be different between mobs. More herePacketPlayOutEntityTeleport - int entityId, int x, int y, int z, byte yaw, byte pitch, boolean onGround PacketPlayOutEntityVelocity - int entityId, int x, int y, int z PacketPlayOutSpawnEntityExperienceOrb - World (nms version) world, int x, int y, int z, int amount Note: amount sets the amount, of what the experience orb holds. It doesn't spawn more than one.PacketPlayOutSpawnEntityLiving - int entityId Note: The entity only shows up for the player, who received the packet.PacketPlayOutSpawnEntityPainting - EntityPainting entityPainting PacketPlayOutSpawnEntityWeather - Entity entity Note: As far as I know, this only usable for lightning. There is no other entity spawning in different weather cases.PacketPlayOutRemoveEntityEffect PacketPlayOutNamedEntitySpawn PacketPlayOutAnimation - Entity entity, int animationType Note: animationType can differ between 0 and 5. More herePacketPlayOutExperience - float percent, int level, int totalExperience Note: percent is a float between 0 and 1, 0 is empty, 1 is full, 0.5 is half-full, etc.PacketPlayOutExplosion - double x, double y, double z, float radius, List<byte>, float dX, float dY, float dZ Note: the List<byte> contains the records (aka. affected blocks), it must be divisible by three, it contains x, y and z coordinates the List<byte> changed to List<BlockPositions> in spigot 1.8 radius is currently unused by the clientPacketPlayOutGameStateChange - int reason, float value Note: reason can differ between 0 and 10. More here value depends on reasonPacketPlayOutHeldItemSlot - int slot PacketPlayOutKickDisconnect - IChatBaseComponent message Note: Doesn't kick out anybody, only displays the "player has been kicked" message in the chatPacketPlayOutMap - int id, byte scale, Collection<MapIcon> icons, PacketPlayOutNamedSoundEffect -String soundName, double x, double y, double z, float volume, float pitch Note: all sound names can be found here 1 is the 100% volume, but can be more than that 63 is the 100% pitch, and again, can be higherPacketPlayOutOpenSignEditor - double x, double y, double z Note: x, y and z variables are changed to BlockPosition in Spigot 1.8PacketPlayOutOpenWindow - int windowId, int windowType, String title, int slotCount, boolean flag, (int entityId) Note: entityId is optional, e.g. horseInventory The constructor changed in spigot 1.8 to int windowId, String type, IChatBaseComponent titlePacketPlayOutPlayerInfo - EnumPlayerInfoAction action, EntityPlayer... players Note: action can be: ADD_PLAYER UPDATE_GAME_MODE UPDATE_LATENCY UPDATE_DISPLAY_NAME REMOVE_PLAYERPacketPlayOutPosition - double x, double y, double z, float yaw, float pitch, boolean onGround Note: yaw and pitch are in degrees in counter-clockwise order The constructor changed in spigot 1.8 to double x, double y, double z, float yaw, float pitch, Set<EnumPlayerTeleportFlag> flags flags can contain the followings: X(0) Y(1) Z(2) Y_ROT(3) X_ROT(4)it contains, wich movement type/direction did the player.PacketPlayOutRespawn - int Dimension, EnumDifficulty difficulty, WordType worldType, EnumGamemode gamemode Note: Dimension can be -1 (Nether), 0 (Overworld) and 1 (End) gamemode can be SURVIVAL(0) CREATIVE(1) ADVENTURE(2) SPECTATOR(3) (only available in Spigot 1.8)difficulty can be PEACEFUL(0) EASY(1) NORMAL(2) HARD(3)PacketPlayOutScoreboardDisplayObjective - int place, ScoreboardObjective objective Note: place can be 0 (list), 1 (sidebar), 2 (below name)PacketPlayOutScoreboardObjective - ScoreboardObjective objective, int value PacketPlayOutScoreboardScore - ScoreboardScore score, int value Note: You don't need the value in Spigot 1.8 ScoreboardScore can be changed to String scoreName Then you need the value in Spigot too. Keep in mindPacketPlayOutScoreboardTeam - ScoreboardTeam team, int playerCount Note: You can send the player's names in a Collection<String> playernames, then the constructor is ScoreboardTeam team, Collection<String> playerNames, int playerCountPacketPlayOutSetSlot - int windowId, int slot, ItemStack item PacketPlayOutSpawnPosition - int x, int y, int z Note: x, y and z changed to BlockPosition in Spigot 1.8PacketPlayOutStatistic - Map (collection) statistics Note: the constructor changed in Spigot 1.8 to Map<Statistic, Integer> statisticsthe map contains the name of the statistic with the corresponding value with it (String. Integer), you can find all of the statistic names here PacketPlayOutTabComplete - String[] values Note: values contains the possible outcomes of the tab completion, the last packet overrides the one beforePacketPlayOutTitle - EnumTitleAction action, IChatBaseComponent message Note: action can be TITLE SUBTITLE TIMES CLEAR RESETThis is only available in Spigot 1.8 or upPacketPlayOutTransaction - int windowId, short actionNumber, boolean isAccepted PacketPlayOutUpdateAttributes - int entityId, Collection attributes Note: Spigot requires a Collection<AttributeInstance> instead of normal CollectionPacketPlayOutUpdateHealth - float health, int foodlevel, float saturation Note: health can vary from 0 to 20 foodlevel can vary from 0 to 20 saturation can vary between 0 and 5PacketPlayOutUpdateSign - int x, int y, int z, String[] text Note: in Spigot 1.8, the constructor changed to World world, BlockPosition position, IChatBaseComponent[] textPacketPlayOutUpdateTime - long worldAge, long timeOfDay, boolean flag Note: worldAge cannot be changed via commands if timeOfDay is -1, then the sun will sto at it's current positionPacketPlayOutWindowData - int windowId, int property, int value Note: property and value can vary between different window types. More here.PacketPlayOutWindowItems - int windowId, List items Note: in Spigot, the items list need to be like List<ItemStack> itemsPakcetPlayOutWolrdBorder - WorldBorder border, EnumWorldBorderAction action Note: This is only available in Spigot 1.8 and up action can be SET_SIZE LERP_SIZE SET_CENTER INITIALIZE SET_WARNING_TIME SET_WARNING_BLOCKSPacketPlayOutWorldParticles - String name, boolean visiblity, float x, float y, float z, float offsetX, float offsetY, float offsetZ, float data, int count, int.. data Note: name changed to EnumParticle in Spigot 1.8 if visiblity is true, the particle distance changes to 65535 (16 bit variable max value) the offsets are the maximum value the particles can differ from the set position data can mean the particles color, or e.g. the block break particles' state count is how much particle will be played, every off them gets a different offset I know what you're thinking. Yes, I had a lot of free time. Post any suggestions below.
I first wanted to add them, but then realized, that you don't have any method of sending those pacjets
Yeah. You can certainly utilize the classes to listen in on incoming packets, but you have no reason to construct them. Maybe there's some really specific case where you'd want to make incoming packets, but honestly I can't imagine when that would be necessary.
@Mrs. bwfctower I know at least one reason: Forcing a player out of the respawn screen. (The client command packet).
@mcdorli The playerConnection is a packet listener (afaik). And all packet-received methods are currently named "a". So PlayerConnection#a(Inpacket) (like this)
@mcdorli That is usefull but unfortunately due to the unstable "nature" of the contents of the NMS package, they tend to change throughout different versions... If you check the constructors of 1.7.X and 1.8.X for the same packets, they are different, For example: PacketPlayOutBed in 1.7.R2 has this constructor: Code: public PacketPlayOutBed(EntityHuman paramEntityHuman, int paramInt1, int paramInt2, int paramInt3) and the same packet in 1.8.R3 has this constructor: Code: public PacketPlayOutBed(EntityHuman ☃, BlockPosition ☃) (and the default constructor \wo parameters) So if you used reflection to make it version independed and it is using either constructor, it wont work cross versions. Variables on the other hand seem to be a litle less likely to change form what i have noticed but still it is the same concept there as well. What i like to do in such cases, is to perform a search for the field i want to manipulate that looks it up depending on it's type. So if a class contains an int i want to change, i will loop through all declared fields of this class and look for the filed of type int. Once found i can change it. The down side of that method is that some times new fields are added and some are removed. in such cases i include a bit of safety in the algorythm so if two int's exist in the class it wont work. The above method can also work with methods (thus constructors as well) Anyway this thread is indeed helpfull! There is no clear documentation for packets :/
If you look closely, I mentioned many times, that x,y and z integer positions mostly changed to blockPositions in spigot 1.8.
@mcdorli Well i am generalising it a bit to other fields/methods as well and recomend a possible way of bypassing it if needed
Sticky fingers, eh? And you might want to refer to wiki.vg for the windowIDs. (as they can be quite confusing )
Small typo on PacketPlayOutRespawn. WordType should be WorldType. Otherwise, a fantastic and helpful list.