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 9fcec6c commit 2825446
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 43 deletions.
64 changes: 35 additions & 29 deletions src/main/java/dev/yurisuika/raised/Raised.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,55 @@
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
import net.neoforged.neoforge.common.NeoForge;

@Mod("raised")
public class Raised {

@Mod.EventBusSubscriber(modid = "raised", value = Dist.CLIENT)
public static class ClientNeoForgeEvents {
@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 registerGuiEvents(FMLClientSetupEvent event) {
NeoForge.EVENT_BUS.register(new RaisedGui.Hotbar());
NeoForge.EVENT_BUS.register(new RaisedGui.Chat());
NeoForge.EVENT_BUS.register(new RaisedGui.Bossbar());
NeoForge.EVENT_BUS.register(new RaisedGui.Sidebar());
NeoForge.EVENT_BUS.register(new RaisedGui.Effects());
NeoForge.EVENT_BUS.register(new RaisedGui.Players());
NeoForge.EVENT_BUS.register(new RaisedGui.Other());
}

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

@SubscribeEvent
public static void clientSetup(FMLClientSetupEvent event) {
NeoForge.EVENT_BUS.register(new RaisedGui.Hotbar());
NeoForge.EVENT_BUS.register(new RaisedGui.Chat());
NeoForge.EVENT_BUS.register(new RaisedGui.Bossbar());
NeoForge.EVENT_BUS.register(new RaisedGui.Sidebar());
NeoForge.EVENT_BUS.register(new RaisedGui.Effects());
NeoForge.EVENT_BUS.register(new RaisedGui.Players());
NeoForge.EVENT_BUS.register(new RaisedGui.Other());
}

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

}

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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 @@ -43,7 +42,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 @@ -57,7 +57,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 @@ -155,7 +154,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 @@ -331,12 +329,10 @@ public static ResourceLocation getSignal(float percent) {
return resourceLocation;
}

@Override
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
renderTransparentBackground(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 2825446

Please sign in to comment.