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 bc6d611 commit 7331179
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 44 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "fabric-loom" version "1.7-SNAPSHOT"
id "fabric-loom" version "1.9-SNAPSHOT"
id "maven-publish"
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ maven_group = dev.yurisuika.raised
archives_base_name = raised

fabric_version = 0.97.1+1.20.4
loader_version = 0.16.7
loader_version = 0.16.9
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
48 changes: 23 additions & 25 deletions src/main/java/dev/yurisuika/raised/Raised.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,39 @@
import dev.yurisuika.raised.client.gui.screens.RaisedScreen;
import dev.yurisuika.raised.util.config.Config;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.network.chat.Component;

public class Raised implements ClientModInitializer {
public class Raised {

@Environment(EnvType.CLIENT)
public static void registerClientTickEvents() {
ClientTickEvents.END_CLIENT_TICK.register(minecraft -> {
while (RaisedOptions.options.consumeClick()) {
minecraft.setScreen(new RaisedScreen(Component.translatable("options.raised.title")));
}
});
}
public static class Client implements ClientModInitializer {

@Environment(EnvType.CLIENT)
public static void registerCommands() {
ClientCommandRegistrationCallback.EVENT.register(RaisedCommand::register);
}
public static void registerKeyMappings() {
KeyBindingHelper.registerKeyBinding(RaisedOptions.options);
}

@Environment(EnvType.CLIENT)
public static void registerKeyBindings() {
KeyBindingHelper.registerKeyBinding(RaisedOptions.options);
}
public static void registerInputEvents() {
ClientTickEvents.END_CLIENT_TICK.register(minecraft -> {
while (RaisedOptions.options.consumeClick()) {
minecraft.setScreen(new RaisedScreen(Component.translatable("options.raised.title")));
}
});
}

public static void registerCommands() {
ClientCommandRegistrationCallback.EVENT.register(RaisedCommand::register);
}

public void onInitializeClient() {
Config.loadConfig();

@Override
public void onInitializeClient() {
Config.loadConfig();
registerKeyMappings();
registerInputEvents();
registerCommands();
}

registerClientTickEvents();
registerCommands();
registerKeyBindings();
}

}
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
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"environment": "client",
"entrypoints": {
"client": [
"dev.yurisuika.raised.Raised"
"dev.yurisuika.raised.Raised\$Client"
]
},
"mixins": [
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/raised.accesswidener
Original file line number Diff line number Diff line change
@@ -1 +1 @@
accessWidener v1 named
accessWidener v2 named

0 comments on commit 7331179

Please sign in to comment.