Difference between revisions of "Codebase"

From Electrical Age
Jump to: navigation, search
(Created page with "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...")
 
Line 11: Line 11:
 
== Code ==
 
== Code ==
  
In <code>/src/main/java/</code>, 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 <code>mods/eln/</code>; there, you will find:
+
In <code>/src/main/java/</code>, 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 <code>mods/eln/</code>; there, you will find all of the following content.
 +
 
 +
=== Components and Simulation ===
  
 
* <code>Eln.java</code>: The main mod file. It is ''absolutely enormous'' as of this writing, and we are sorry. This is where all the blocks, items, recipes, etc. get registered. If you're going to add a ''completely new'' block, item, recipe, etc., you will have to add it somewhere in this file.
 
* <code>Eln.java</code>: The main mod file. It is ''absolutely enormous'' as of this writing, and we are sorry. This is where all the blocks, items, recipes, etc. get registered. If you're going to add a ''completely new'' block, item, recipe, etc., you will have to add it somewhere in this file.
 +
* <code>sim/</code>: The Big Bad itself. The [[Simulator]] is responsible for running all the [[Process]]es in various orders, and solving all the circuits made out of [[Node]]s in the world, once per tick.
 +
* <code>node/</code>: This is where all the [[Node]] base classes live, including <code>NodeBase</code>, <code>NodeBlock</code>, and so forth. The base classes for [[SixNode]] and [[TransparentNode]] also live here.
 +
* <code>sixnode/</code>: This is where all the realized (derived from) [[SixNode]] content lives, like the [[Signal Processor]], the [[Sensor]]s, all of the [[Cable]]s, [[Switch]]es, [[Relay]]s, etc.
 +
* <code>transparentnode/</code>: This is where ''almost all'' the realized [[TransparentNode]] content lives, like the [[Thermal Dissipator]]s, [[Solar Panel]]s, [[Capacitor]]s and [[Inductor]]s, all of the [[Machine]]s, [[Battery|Batteries]], the [[Wind turbine|wind]], [[Water turbine|water]], and [[Heat turbine]]s, and so forth.
 +
* <code>gridnode/</code>: Code for the [[Powerline example|T1]] and T2 electrical [[Grid]]s (the latter is undocumented as of this writing), such as the [[Grid Transformer]].
 +
* <code>mechanical/</code>: Code for the [[Simple gas turbine control|mechanical (shaft) networks]], including the [[Steam turbine|steam]] and [[Gas turbine]] (but not the other ones above), the [[Generator]], the [[Motor]], and so forth.
 +
* <code>simplenode/</code>: Pretty much just the [[Electrical Age to other energy exporter]].
 +
 +
=== Minecraft Interaction ===
 +
 +
* <code>item/</code>: Plenty of the items which have no in-world representation, like [[Machine Booster]]s, [[Alloy Dust]], the [[X-Ray Scanner]], the [[Light Bulb]]s, and so forth.
 +
* <code>entity/</code>: Really, only the [[Replicator]] mob.
 +
* <code>fluid/</code>: Interacts with Forge's fluid API. Mostly used by the [[Steam turbine|steam]] and [[Gas turbine]]s, but also the [[Fluid Heat Furnace]].
 +
* <code>generic/</code>: 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.''
 +
* <code>packets/</code>: Network packet encoder/decoders sent over the wire.
 +
* <code>server/</code>: Various serverside things, like the <code>ConsoleListener</code> which interprets chat commands, and <code>PlayerManager</code> and <code>PlayerMetadata</code>, which handle the "wrench" key functionality.
 +
* <code>client/</code>: Various clientside things, including <code>FrameTime</code> which updates rendered objects' animations in accordance with the ''real time'' clock, and the event listener which handles the "wrench" key presses.
 +
* <code>sound/</code>: Utilities for playing sound, continuously or per event, in various ways.
 +
* <code>gui/</code>: Various classes to help with rendering the clientside interfaces.
 +
 +
=== Supporting Code ===
 +
 +
* <code>fsm/</code>: Finite State Machines, for long, state-oriented processes, like the [[Turret]] or [[Transporter]].
 +
* <code>ghost/</code>: Handles "ghost" blocks with no rendering that bound the larger objects (entities, really), like the [[Utility pole]]s, [[Grid Transformer]], and so forth.
 +
* <code>cable/</code>: Only the ''rendering'' of cables (which is quite complex); the actual cable itself is a [[SixNode]].
 +
* <code>misc/</code>: Tons of utility classes, the <code>WindProcess</code> for the [[Wind turbine]]s, 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 <code>Eln.java</code>, 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 <code>/src/main/resources/</code>, one finds two files: <code>mcmod.info</code> (which declares some important high-level info about the mod, like its name, requirements, authors, logo, etc.), and <code>assets/eln/</code>, which contains the following content:
 +
 +
* <code>logo.png</code>: Wow, that looks [https://raw.githubusercontent.com/Electrical-Age/ElectricalAge/develop/src/main/resources/assets/eln/logo.png kinda nice].
 +
* <code>model/</code>, <code>model-to-be-integrated/</code>: All of the [[Models]] that get rendered as tile entities. The two directories are separated because [[Obj3D|Obj3DFolder]] loads ''every'' file which ends in a <code>.obj</code> extension under <code>model/</code>. See [[Modelling]] for more information.
 +
* <code>sprites/</code>: 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:
 +
** <code>sprites/gui/</code>: 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.
 +
* <code>sounds.json</code>, <code>sounds/</code>: The former is a [https://minecraft.gamepedia.com/Sounds.json 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 <code>sounds.json</code>. See [[Sounds]].
 +
* <code>lang/</code>: [[Translation]] files.
 +
* <code>textures/</code>: Image files mostly intended to be displayed in inventory slots, with occasional exception:
 +
** <code>textures/armor/</code>: One exception; these are UV-mapped textures for the [[Ecoal]] and [[Copper Armor]].
 +
** <code>textures/entity/</code>: The other exception; UV-mapped textures for the [[Replicator]] (and, presumably, other mobs).
 +
** <code>textures/voltages/</code>: 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.
 +
** <code>textures/items/</code>, <code>textures/blocks/</code>: 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.
 +
** <code>textures/wire.png</code>: Another weird exception, this is the cable texture used for [[Grid]] links. (Arguably better placed in <code>sprites/</code>...)

Revision as of 21:07, 10 February 2019

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/...)