Codebase

From Electrical Age
Revision as of 21:07, 10 February 2019 by Grissess (talk | contribs)

Jump to: navigation, search

First, if you haven't read it yet, see Developing for how to make your own local copy of a project. If you're just browsing the source, read on.

For the remainder of this document, I'll be using the forward slash (/) as the path separator, as it is on most UNIX-like operating systems. This should be equally valid on Windows, despite its normal path separator being the backslash (\). If you're on Windows, take note that some of the paths you see may appear different as a result. Similarly, the "absolute paths" (starting with /) will be relative to the repository root--wherever you cloned that, or are viewing it. Finally, if a path ends with a slash, it means that it's a directory.

Code and Assets

Everything of this sort lives in /src/main/. When building, you may find some siblings in /src/, like api/ or test/ appear--you can safely ignore these.

Under /src/main/, you will find two directories, java/ and resources/. The former is the code, and the latter is the assets.

Code

In /src/main/java/, you may find a few directories, many of which are APIs linked to by ELN, such as ComputerCraft and OpenComputers APIs. The main content lives in mods/eln/; there, you will find all of the following content.

Components and Simulation

Minecraft Interaction

  • item/: Plenty of the items which have no in-world representation, like Machine Boosters, Alloy Dust, the X-Ray Scanner, the Light Bulbs, and so forth.
  • entity/: Really, only the Replicator mob.
  • fluid/: Interacts with Forge's fluid API. Mostly used by the steam and Gas turbines, but also the Fluid Heat Furnace.
  • generic/: The Generic Proxy System used by ELN. In essence, this encodes a large number of different items and blocks in the Minecraft world by using damage values as identifiers, preventing the exhaustion of Block and Item IDs. This system will probably be supplanted in the upcoming 1.10 port with BlockState.
  • packets/: Network packet encoder/decoders sent over the wire.
  • server/: Various serverside things, like the ConsoleListener which interprets chat commands, and PlayerManager and PlayerMetadata, which handle the "wrench" key functionality.
  • client/: Various clientside things, including FrameTime which updates rendered objects' animations in accordance with the real time clock, and the event listener which handles the "wrench" key presses.
  • sound/: Utilities for playing sound, continuously or per event, in various ways.
  • gui/: Various classes to help with rendering the clientside interfaces.

Supporting Code

  • fsm/: Finite State Machines, for long, state-oriented processes, like the Turret or Transporter.
  • ghost/: Handles "ghost" blocks with no rendering that bound the larger objects (entities, really), like the Utility poles, Grid Transformer, and so forth.
  • cable/: Only the rendering of cables (which is quite complex); the actual cable itself is a SixNode.
  • misc/: Tons of utility classes, the WindProcess for the Wind turbines, some of the code for the network protocol, the famous Cordoonate, LRDU, and Direction classes, and other dragons of all shapes and sizes.

Everything Else

Do note that there's some blatantly dead code hanging around in the base; if it's not referenced in Eln.java, it's probably not in the game.

And, of course, beware of all the scary things hiding in the dark corners of the codebase. You may, of course, run into them, and may even need to use them, but warning has been given--people who are 100% aware of how everything works together are few and far between.

Assets

Back out in /src/main/resources/, one finds two files: mcmod.info (which declares some important high-level info about the mod, like its name, requirements, authors, logo, etc.), and assets/eln/, which contains the following content:

  • logo.png: Wow, that looks kinda nice.
  • model/, model-to-be-integrated/: All of the Models that get rendered as tile entities. The two directories are separated because Obj3DFolder loads every file which ends in a .obj extension under model/. See Modelling for more information.
  • sprites/: Various textures used within the game engine, such as masks for cable textures, and a couple atlas textures of unknown use. Notably, however, it contains a subdirectory:
    • sprites/gui/: Contains the interfaces for various machines; nominally 256x256 pixel PNGs with transparency, you'll also notice (in some) "off-screen" areas that contain, e.g., the animated arrow in the case of the furnace. Many of the active elements, such as buttons and inventory slots, are missing from these backgrounds--and added by the Gui and Container classes.
  • sounds.json, sounds/: The former is a sounds.json file, as would be loaded by a resource pack, and defines all the sounds loaded by the mod. The latter directory is the root of the search for the sounds named in sounds.json. See Sounds.
  • lang/: Translation files.
  • textures/: Image files mostly intended to be displayed in inventory slots, with occasional exception:
    • textures/armor/: One exception; these are UV-mapped textures for the Ecoal and Copper Armor.
    • textures/entity/: The other exception; UV-mapped textures for the Replicator (and, presumably, other mobs).
    • textures/voltages/: Backgrounds for the various "voltage levels" or tiers; this is what contributes the background color to some inventory slots. Many of these are PNGs with translucency throughout.
    • textures/items/, textures/blocks/: Item and block textures, as seen in inventories. The filenames correspond to the string names given to the Generic Proxy System constructors, lowercase and with spaces removed.
    • textures/wire.png: Another weird exception, this is the cable texture used for Grid links. (Arguably better placed in sprites/...)