summaryrefslogtreecommitdiff
path: root/src/main/java/co
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/co')
-rw-r--r--src/main/java/co/fantabos/bscv/BoSCoVicino.java23
-rw-r--r--src/main/java/co/fantabos/bscv/Command.java17
-rw-r--r--src/main/java/co/fantabos/bscv/Fullbright.java27
-rw-r--r--src/main/java/co/fantabos/bscv/Mod.java37
4 files changed, 95 insertions, 9 deletions
diff --git a/src/main/java/co/fantabos/bscv/BoSCoVicino.java b/src/main/java/co/fantabos/bscv/BoSCoVicino.java
index e3555a5..afb5029 100644
--- a/src/main/java/co/fantabos/bscv/BoSCoVicino.java
+++ b/src/main/java/co/fantabos/bscv/BoSCoVicino.java
@@ -1,12 +1,15 @@
-package com.example.examplemod;
+package co.fantabos.bscv;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
+import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
+import net.minecraftforge.fml.ModLoadingContext;
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.FMLCommonSetupEvent;
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
@Mod("bscv")
-public class BoSCoVicino
-{
+public class BoSCoVicino {
// Directly reference a log4j logger.
private static final Logger LOGGER = LogManager.getLogger();
+ public static Minecraft minecraft;
+
public BoSCoVicino() {
// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
@@ -35,12 +39,15 @@ public class BoSCoVicino
// Register the doClientStuff method for modloading
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
MinecraftForge.EVENT_BUS.register(this);
}
- private void setup(final FMLCommonSetupEvent event)
- {
+ private void setup(final FMLCommonSetupEvent event) {
// some preinit code
LOGGER.info("HELLO FROM PREINIT");
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
@@ -51,14 +58,12 @@ public class BoSCoVicino
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
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
LOGGER.info("Got IMC {}", event.getIMCStream().
map(m->m.getMessageSupplier().get()).
diff --git a/src/main/java/co/fantabos/bscv/Command.java b/src/main/java/co/fantabos/bscv/Command.java
new file mode 100644
index 0000000..496a48c
--- /dev/null
+++ b/src/main/java/co/fantabos/bscv/Command.java
@@ -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();
+ }
+}
diff --git a/src/main/java/co/fantabos/bscv/Fullbright.java b/src/main/java/co/fantabos/bscv/Fullbright.java
new file mode 100644
index 0000000..7b0b222
--- /dev/null
+++ b/src/main/java/co/fantabos/bscv/Fullbright.java
@@ -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));
+ }
+ }
+}
diff --git a/src/main/java/co/fantabos/bscv/Mod.java b/src/main/java/co/fantabos/bscv/Mod.java
new file mode 100644
index 0000000..ddf1f65
--- /dev/null
+++ b/src/main/java/co/fantabos/bscv/Mod.java
@@ -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);
+ }
+}