fix up the examplemod for new FML and add a couple of extra bits.
This commit is contained in:
parent
a171cf3efe
commit
c83b13d45c
4 changed files with 97 additions and 31 deletions
|
@ -1,31 +1,56 @@
|
||||||
package com.example.examplemod;
|
package com.example.examplemod;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||||
|
import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@Mod(modid = ExampleMod.MODID, name = ExampleMod.NAME, version = ExampleMod.VERSION)
|
// The value here should match an entry in the META-INF/mods.toml file
|
||||||
|
@Mod("examplemod")
|
||||||
public class ExampleMod
|
public class ExampleMod
|
||||||
{
|
{
|
||||||
public static final String MODID = "examplemod";
|
// Directly reference a log4j logger.
|
||||||
public static final String NAME = "Example Mod";
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
public static final String VERSION = "1.0";
|
|
||||||
|
|
||||||
private static Logger logger;
|
public ExampleMod() {
|
||||||
|
// Register the preInit method for modloading
|
||||||
|
FMLModLoadingContext.get().getModEventBus().addListener(this::preInit);
|
||||||
|
// Register the init method for modloading
|
||||||
|
FMLModLoadingContext.get().getModEventBus().addListener(this::init);
|
||||||
|
|
||||||
@EventHandler
|
// Register ourselves for server, registry and other game events we are interested in
|
||||||
public void preInit(FMLPreInitializationEvent event)
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
{
|
|
||||||
logger = event.getModLog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
private void preInit(final FMLPreInitializationEvent event)
|
||||||
public void init(FMLInitializationEvent event)
|
{
|
||||||
|
// some preinit code
|
||||||
|
LOGGER.info("HELLO FROM PREINIT");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(final FMLInitializationEvent event)
|
||||||
{
|
{
|
||||||
// some example code
|
// some example code
|
||||||
logger.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
|
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
|
||||||
|
// register a new block here
|
||||||
|
LOGGER.info("HELLO from Register Block");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onServerStarting(FMLServerStartingEvent event) {
|
||||||
|
// do something when the server starts
|
||||||
|
LOGGER.info("HELLO from server starting");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
57
src/main/resources/META-INF/mods.toml
Normal file
57
src/main/resources/META-INF/mods.toml
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
||||||
|
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
||||||
|
# The overall format is standard TOML format, v0.5.0.
|
||||||
|
# Note that there are a couple of TOML lists in this file.
|
||||||
|
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||||
|
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||||
|
modLoader="javafml" #mandatory
|
||||||
|
# A version range to match for said mod loader - for regular FML @Mod it will be the minecraft version (without the 1.)
|
||||||
|
loaderVersion="[13,)" #mandatory
|
||||||
|
# A URL to query for updates for this mod. See the JSON update specification <here>
|
||||||
|
updateJSONURL="http://myurl.me/" #optional
|
||||||
|
# A URL to refer people to when problems occur with this mod
|
||||||
|
issueTrackerURL="http://my.issue.tracker/" #optional
|
||||||
|
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||||
|
displayURL="http://example.com/" #optional
|
||||||
|
# A file name (in the root of the mod JAR) containing a logo for display
|
||||||
|
logoFile="examplemod.png" #optional
|
||||||
|
# A text field displayed in the mod UI
|
||||||
|
credits="Thanks for this example mod goes to Java" #optional
|
||||||
|
# A text field displayed in the mod UI
|
||||||
|
authors="Love, Cheese and small house plants" #optional
|
||||||
|
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||||
|
[[mods]] #mandatory
|
||||||
|
# The modid of the mod
|
||||||
|
modId="examplemod" #mandatory
|
||||||
|
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||||
|
version="1.0" #mandatory
|
||||||
|
# A display name for the mod
|
||||||
|
displayName="Example Mod" #mandatory
|
||||||
|
# The description text for the mod (multi line!) (#mandatory)
|
||||||
|
description='''
|
||||||
|
This is a long form description of the mod. You can write whatever you want here
|
||||||
|
|
||||||
|
Have some lorem ipsum.
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis lacinia magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sagittis luctus odio eu tempus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque volutpat ligula eget lacus auctor sagittis. In hac habitasse platea dictumst. Nunc gravida elit vitae sem vehicula efficitur. Donec mattis ipsum et arcu lobortis, eleifend sagittis sem rutrum. Cras pharetra quam eget posuere fermentum. Sed id tincidunt justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||||
|
[[dependencies.examplemod]] #optional
|
||||||
|
# the modid of the dependency
|
||||||
|
modId="forge" #mandatory
|
||||||
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
|
mandatory=true #mandatory
|
||||||
|
# The version range of the dependency
|
||||||
|
versionRange="[14.23.2.0,)" #mandatory
|
||||||
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||||
|
ordering="NONE"
|
||||||
|
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||||
|
side="BOTH"
|
||||||
|
# Here's another dependency
|
||||||
|
[[dependencies.examplemod]]
|
||||||
|
modId="minecraft"
|
||||||
|
mandatory=true
|
||||||
|
versionRange="[1.13]"
|
||||||
|
ordering="NONE"
|
||||||
|
side="BOTH"
|
|
@ -1,16 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"modid": "examplemod",
|
|
||||||
"name": "Example Mod",
|
|
||||||
"description": "Example placeholder mod.",
|
|
||||||
"version": "${version}",
|
|
||||||
"mcversion": "${mcversion}",
|
|
||||||
"url": "",
|
|
||||||
"updateUrl": "",
|
|
||||||
"authorList": ["ExampleDude"],
|
|
||||||
"credits": "The Forge and FML guys, for making this example",
|
|
||||||
"logoFile": "",
|
|
||||||
"screenshots": [],
|
|
||||||
"dependencies": []
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"pack": {
|
"pack": {
|
||||||
"description": "examplemod resources",
|
"description": "examplemod resources",
|
||||||
"pack_format": 3,
|
"pack_format": 4,
|
||||||
"_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)."
|
"_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue