Thursday, 24 October 2013

Server-side Class Linkage Map

The diagram below shows the cross-references between the most important Server-side vanilla classes. For example:

EntityPlayerMP.playerNetServerHandler contains a NetServerHandler
Entity.worldObj refers to WorldServer
WorldServer.playerEntities contains a collection of EntityPlayers
 The map can be used to find a way to access the particular Class you need, starting with the Class(es) your code has been provided with.
NB - there are several ways of getting to EntityPlayerMP depending on which ones you want:
  1. To get all players on the server, use ServerConfigurationManager.playerEntityList()
  2. To get all players within range of a particular chunk, start from PlayerManager()
  3. For the player corresponding to a particular NetServerHandler, use .playerEntity
  4. For all players within range of a particular Entity, start from EntityTracker.
  5. For all players in a particular dimension, use worldServer.playerEntities, where you get worldServer using MinecraftServer.getServer().worldServerForDimension or DimensionManager.getWorld()
 MinecraftServer is designed as a Singleton (there is only ever one instance of the Class). It can be accessed by MinecraftServer.getServer().
Server-side Class Linkage Map for reference between the major vanilla Classes. Fields which are public are designated by solid arrows; private fields are in curly brackets and have dotted arrows. MinecraftServer is accessible using .getServer()