An example of the Ultralight HTML renderer in Minecraft Forge 1.8.9 A few general modding tips are also included
demo.mp4
- Rendering HTML
- Mouse input
- Keyboard input
- Java/JavaScript interop (implementation not shown)
This example can be run out of the box. Simply
- Clone this repo
- Run the gradle task
runClient
- Join a world, any world
- Press right shift to open the demo GUI
-
Step 1
Place your audio file underassets/<modID>/sounds
in .ogg format -
Step 2
Register your file in sounds.json with the following format
"whatever.name":{
"category": "master",
"sounds":[
{
"name":"<modID>:my_sound","stream":false
}
]
}
The above will look for the file my_sound.ogg
under assets/<modID>/sounds/
and make it accessible by whatever.name
The category is trivial.
Step 3
Play your sound file using the accessible name
Minecraft.getMinecraft().thePlayer.playSound("<modID>:whatever.name", volume, pitch);
- You can play vanilla minecraft sounds with example above. Simply replace
<modID>
withminecraft
. A complete list of vanilla sounds can be found here - It's good practice to name audio files using snake case
Your image can be anywhere under assets/<modID>
. Reference that image relatively in the code like so
public static final ResourceLocation myImage = new ResourceLocation(MODID, path);
The above will look for an image at assets/<modID>/path
.
Drawing can then be done with the convenient RenderUtils class.
RenderUtils.drawTexture(resourceLocation, x, y, width, height, rgbaCombined);
If you are drawing without a gui active (aka directly to the screen), make sure to fix your x & y coordinates using the ScaledResolution class
build
Builds the mod into a usable jar file under build/libsrunClient
Runs the mod in minecraft on the fly