feat: initial base mod plus some scaffolding
a basic fullbright is there with no way to toggle it
This commit is contained in:
parent
b6f64fef25
commit
84ec30f4c1
4 changed files with 95 additions and 9 deletions
|
@ -1,12 +1,15 @@
|
||||||
package com.example.examplemod;
|
package co.fantabos.bscv;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.InterModComms;
|
import net.minecraftforge.fml.InterModComms;
|
||||||
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.config.ModConfig.Type;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||||
|
@ -20,11 +23,12 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
// The value here should match an entry in the META-INF/mods.toml file
|
// The value here should match an entry in the META-INF/mods.toml file
|
||||||
@Mod("bscv")
|
@Mod("bscv")
|
||||||
public class BoSCoVicino
|
public class BoSCoVicino {
|
||||||
{
|
|
||||||
// Directly reference a log4j logger.
|
// Directly reference a log4j logger.
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
|
public static Minecraft minecraft;
|
||||||
|
|
||||||
public BoSCoVicino() {
|
public BoSCoVicino() {
|
||||||
// Register the setup method for modloading
|
// Register the setup method for modloading
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||||
|
@ -35,12 +39,15 @@ public class BoSCoVicino
|
||||||
// Register the doClientStuff method for modloading
|
// Register the doClientStuff method for modloading
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
|
||||||
|
|
||||||
|
ModLoadingContext.get().registerConfig(Type.CLIENT, Configuration.SPEC, "bscv.toml");
|
||||||
|
|
||||||
|
BoSCoVicino.minecraft = Minecraft.getInstance();
|
||||||
|
|
||||||
// Register ourselves for server and other game events we are interested in
|
// Register ourselves for server and other game events we are interested in
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup(final FMLCommonSetupEvent event)
|
private void setup(final FMLCommonSetupEvent event) {
|
||||||
{
|
|
||||||
// some preinit code
|
// some preinit code
|
||||||
LOGGER.info("HELLO FROM PREINIT");
|
LOGGER.info("HELLO FROM PREINIT");
|
||||||
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
|
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
|
||||||
|
@ -51,14 +58,12 @@ public class BoSCoVicino
|
||||||
LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().options);
|
LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().options);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enqueueIMC(final InterModEnqueueEvent event)
|
private void enqueueIMC(final InterModEnqueueEvent event) {
|
||||||
{
|
|
||||||
// some example code to dispatch IMC to another mod
|
// some example code to dispatch IMC to another mod
|
||||||
InterModComms.sendTo("bscv", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
|
InterModComms.sendTo("bscv", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processIMC(final InterModProcessEvent event)
|
private void processIMC(final InterModProcessEvent event) {
|
||||||
{
|
|
||||||
// some example code to receive and process InterModComms from other mods
|
// some example code to receive and process InterModComms from other mods
|
||||||
LOGGER.info("Got IMC {}", event.getIMCStream().
|
LOGGER.info("Got IMC {}", event.getIMCStream().
|
||||||
map(m->m.getMessageSupplier().get()).
|
map(m->m.getMessageSupplier().get()).
|
||||||
|
|
17
src/main/java/co/fantabos/bscv/Command.java
Normal file
17
src/main/java/co/fantabos/bscv/Command.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package co.fantabos.bscv;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
|
||||||
|
import net.minecraft.command.CommandSource;
|
||||||
|
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
|
public class Command {
|
||||||
|
|
||||||
|
// TODO automate registering commands
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onRegisterCommandEvent(RegisterCommandsEvent event) {
|
||||||
|
CommandDispatcher<CommandSource> dispatcher = event.getDispatcher();
|
||||||
|
}
|
||||||
|
}
|
27
src/main/java/co/fantabos/bscv/Fullbright.java
Normal file
27
src/main/java/co/fantabos/bscv/Fullbright.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package co.fantabos.bscv;
|
||||||
|
|
||||||
|
import net.minecraft.potion.Effect;
|
||||||
|
import net.minecraft.potion.EffectInstance;
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
import net.minecraftforge.event.TickEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
|
public class Fullbright extends Mod {
|
||||||
|
|
||||||
|
private final ForgeConfigSpec.ConfigValue<String> mode;
|
||||||
|
|
||||||
|
public Fullbright(ForgeConfigSpec.Builder builder) {
|
||||||
|
super("Fullbright", Group.VISION, builder);
|
||||||
|
|
||||||
|
this.mode = builder.comment("either potion or gamma").define("mode", "potion");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onTick(TickEvent.ClientTickEvent event) {
|
||||||
|
if (BoSCoVicino.minecraft == null) return;
|
||||||
|
if (BoSCoVicino.minecraft.player == null) return;
|
||||||
|
if (this.mode.get().equals("potion")) {
|
||||||
|
BoSCoVicino.minecraft.player.addEffect(new EffectInstance(Effect.byId(16), 5204));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
src/main/java/co/fantabos/bscv/Mod.java
Normal file
37
src/main/java/co/fantabos/bscv/Mod.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package co.fantabos.bscv;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
|
public abstract class Mod {
|
||||||
|
public enum Group {
|
||||||
|
CORE,
|
||||||
|
BUILD,
|
||||||
|
DEFENSE,
|
||||||
|
VISION,
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String name;
|
||||||
|
public final Group group;
|
||||||
|
public final ForgeConfigSpec.ConfigValue<Boolean> enabled;
|
||||||
|
|
||||||
|
Mod(String name, Group group, ForgeConfigSpec.Builder builder) {
|
||||||
|
this.name = name;
|
||||||
|
this.group = group;
|
||||||
|
|
||||||
|
builder.push(this.name.toLowerCase());
|
||||||
|
this.enabled = builder
|
||||||
|
.comment(String.format("Enable %s", this.name))
|
||||||
|
.define(this.name.toLowerCase(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enable() {
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
this.enabled.set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disable() {
|
||||||
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
|
this.enabled.set(false);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue