Skip to content

Commit

Permalink
reorganize registration
Browse files Browse the repository at this point in the history
  • Loading branch information
yurisuika committed Dec 27, 2024
1 parent 027c5a0 commit 6580313
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 38 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs = -Xmx3G
loom.platform = forge

minecraft_version = 1.21.3
parchment_version = 2024.07.28
parchment_version = 2024.11.10

mod_id = raised
mod_author = yurisuika
Expand Down
49 changes: 26 additions & 23 deletions src/main/java/dev/yurisuika/raised/Raised.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,47 @@
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.RegisterClientCommandsEvent;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod("raised")
public class Raised {

@Mod.EventBusSubscriber(modid = "raised", value = Dist.CLIENT)
public static class ClientForgeEvents {
@Mod("raised")
public static class Client {

@SubscribeEvent
public static void keyInput(InputEvent.Key event) {
while (RaisedOptions.options.consumeClick()) {
Minecraft.getInstance().setScreen(new RaisedScreen(Component.translatable("options.raised.title")));
@Mod.EventBusSubscriber(modid = "raised", bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public static class GameEvents {

@SubscribeEvent
public static void registerInputEvents(InputEvent.Key event) {
while (RaisedOptions.options.consumeClick()) {
Minecraft.getInstance().setScreen(new RaisedScreen(Component.translatable("options.raised.title")));
}
}

@SubscribeEvent
public static void registerCommands(RegisterClientCommandsEvent event) {
RaisedCommand.register(event.getDispatcher(), event.getBuildContext());
}
}

@SubscribeEvent
public static void registerClientCommands(RegisterClientCommandsEvent event) {
RaisedCommand.register(event.getDispatcher(), event.getBuildContext());
}

}
@Mod.EventBusSubscriber(modid = "raised", bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class ModEvents {

@Mod.EventBusSubscriber(modid = "raised", bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class ClientModBusEvents {
@SubscribeEvent
public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
event.register(RaisedOptions.options);
}

@SubscribeEvent
public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
event.register(RaisedOptions.options);
}

}

public Raised() {
Config.loadConfig();
public Client() {
Config.loadConfig();
}

MinecraftForge.EVENT_BUS.register(this);
}

public Raised() {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public boolean isToggled() {
return toggled;
}

@Override
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
if (texture != null) {
RenderSystem.disableDepthTest();
Expand All @@ -44,7 +43,6 @@ public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float
}
}

@Override
public void renderString(GuiGraphics guiGraphics, Font font, int color) {}

public static class Builder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public RaisedScreen(Component title) {
super(title);
}

@Override
public void init() {
title = new StringWidget(Component.translatable("options.raised.title"), font);
page = new StringWidget(Component.translatable(element.getKey()), font);
Expand Down Expand Up @@ -157,7 +156,6 @@ public void setIconToggleButton(IconToggleButton widget) {
widget.active = !widget.toggled;
}

@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
super.render(guiGraphics, mouseX, mouseY, partialTick);

Expand Down Expand Up @@ -329,13 +327,11 @@ public static ResourceLocation getSignal(float percent) {
return resourceLocation;
}

@Override
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
renderBlurredBackground();
renderMenuBackground(guiGraphics);
}

@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
super.keyPressed(keyCode, scanCode, modifiers);
if (RaisedOptions.options.matches(keyCode, scanCode)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public int getId() {
return id;
}

@Override
public String getKey() {
return key;
}
Expand All @@ -45,7 +44,6 @@ public static Element byId(int id) {
return VALUES[Mth.abs(id % VALUES.length)];
}

@Override
public String getSerializedName() {
return name().toLowerCase();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public int getId() {
return id;
}

@Override
public String getKey() {
return key;
}
Expand All @@ -49,7 +48,6 @@ public static Position byId(int id) {
return VALUES[Mth.abs(id % VALUES.length)];
}

@Override
public String getSerializedName() {
return name().toLowerCase();
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/dev/yurisuika/raised/util/properties/Sync.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public int getId() {
return id;
}

@Override
public String getKey() {
return key;
}
Expand All @@ -46,7 +45,6 @@ public static Sync byId(int id) {
return VALUES[Mth.abs(id % VALUES.length)];
}

@Override
public String getSerializedName() {
return name().toLowerCase();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public int getId() {
return id;
}

@Override
public String getKey() {
return key;
}
Expand All @@ -41,7 +40,6 @@ public static Texture byId(int id) {
return VALUES[Mth.abs(id % VALUES.length)];
}

@Override
public String getSerializedName() {
return name().toLowerCase();
}
Expand Down

0 comments on commit 6580313

Please sign in to comment.