Skip to content

Pack Making JSON Lights

DrprofLuigi edited this page Feb 27, 2022 · 11 revisions

One of the main things MTS does differently than any other mod is how it renders lights. Rather than messing with Minecraft lighting and causing lots of lighting updates and chunk re-draws, MTS instead opts for simple OpenGL blending, lighting, and some fancy textures. All of this is done automatically, with lighting configuration being determined from the data in the JSON file. Each light entry has the following parameters:

  • objectName – The name of the object in the model this light definition will act on.
  • emissive – If true, this light will be emissive and render a solid-color of light when on. If false, only the texture will light up. Does not affect rendering of blendableComponents.
  • covered – If true, this light will have a glass cover rendered over it. This cover will light-up with the light, so keep this in mind.
  • isBeam – If true, this light will be considered a beam and will do beam-blending. Useful for creating your own custom beam shapes.
  • isElectric – Causes the light to automatically dim relative to the electric power of the thing it is on. Should normally be true to prevent vehicles from having lights with dead batteries. This essentially multiplies the final brightness value of the brightnessAnimations.
  • color – A Color Value. This tells MTS what color this light should be. Required for emissive lights and lights with blendableComponents. This may be overriden by a brightnessAnimation that is a rotation type.
  • brightnessAnimations – A listing of animations for determining the light brightness (and potentially color).
  • Visibility transforms will turn the light on or off.
  • translation animations with the y-axis will add the variable value to the light brightness.
  • translation animations with the x-axis will multiply the light by the current light value.
  • translation animations with the z-axis will set the light brightness to that value, overriding any prior transform operations.
  • For all cases, the light brightness calculation starts at 0, so a set of animations that only multiply will just result in multiplying by 0 and a light that doesn't show up.
  • Leaving this blank or not having any active translation transforms will make for a light that is always on at 100% brightness, which you probably don't want.
  • Rotation transforms will set the color with the value corresponding to the XYZ parameters, overriding the color parameter. These values are from 0.0-1.0, which correspond to 0-255 for RGB. Note that the value of the variable for this operation will be multiplied by the value of the variable. This allows for gradual color changes. Also note that all rotation animation are added together to produce the final color, clamped to 1.0 for each axis, and support offsets. This allows for individual R, G, or B control via three rotation blocks. Or setting the R and G parameters with the first block, and then modifying the B parameter by the second block with only the B axis defined.
  • Inhibitor and activator transforms may be used as usual with these for advanced brightness logic.
  • blendableComponents – A listing of blendable components for this light. Used to allow for multiple flares or beams for a single light object.

Blendable Components

  • pos – The position at which the blendable component will be rendered at.
  • axis – The axis that defines the 'front' of the blendable component. This will be the 'normal' for the flare texture, or the direction of the beam.
  • flareHeight – The height of the flare to render.
  • flareWidth – The width of the flare to render.
  • beamDiameter – The diameter of the beam to render.
  • beamLength – The length of the beam to render.
Clone this wiki locally