Skip to content

Commit

Permalink
Code cleanup. Prefix mixins like good modders
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Apr 18, 2022
1 parent 79750db commit 643a06a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
Expand Up @@ -4,4 +4,5 @@ public class Constants {

public static final String MOD_ID = "tipthescales";
public static final String MOD_NAME = "Tip The Scales";

}
Expand Up @@ -6,9 +6,12 @@
import net.minecraft.network.chat.TranslatableComponent;

public class ScaleHelper {

public static int guiScale;

public static Component genericValueLabel(Option option, Component args) {
return new TranslatableComponent("options.generic_value", ((OptionAccessor)option).getCaption(), args);

return new TranslatableComponent("options.generic_value", ((OptionAccessor) option).tipTheScales$getCaption(), args);
}

}
Expand Up @@ -24,18 +24,18 @@ public MixinVideoSettingsScreen(Screen param0, Options param1, Component param2)
}

@Inject(method = "init", at = @At("HEAD"))
public void init(CallbackInfo ci) {
public void tipTheScales$init(CallbackInfo ci) {

Option[] options = VideoSettingsScreenAccessor.getOPTIONS();
Option[] options = VideoSettingsScreenAccessor.tipTheScales$getOPTIONS();
for(int i = 0; i < options.length; i++) {
Option option = options[i];
if(option.equals(Option.GUI_SCALE)) {

CycleOption<Integer> cycleOption = (CycleOption<Integer>) option;
OptionAccessor accessOption = (OptionAccessor) cycleOption;

String captionKey = accessOption.getCaption().getContents();
if(accessOption.getCaption() instanceof TranslatableComponent transComp) {
String captionKey = accessOption.tipTheScales$getCaption().getContents();
if(accessOption.tipTheScales$getCaption() instanceof TranslatableComponent transComp) {
captionKey = transComp.getKey();
}

Expand All @@ -55,18 +55,18 @@ public void init(CallbackInfo ci) {
}

@Inject(method = "mouseClicked", at = @At(value = "HEAD"))
public void mouseClickedHead(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) {
public void tipTheScales$mouseClickedHead(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) {

ScaleHelper.guiScale = this.options.guiScale;
}


@Redirect(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;resizeDisplay()V"))
public void mouseClickedResize(Minecraft instance) {}
public void tipTheScales$mouseClickedResize(Minecraft instance) {}


@Inject(method = "mouseReleased", at = @At(value = "HEAD"))
public void mouseReleasedHead(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) {
public void tipTheScales$mouseReleasedHead(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) {

if(this.options.guiScale != ScaleHelper.guiScale) {
this.minecraft.resizeDisplay();
Expand All @@ -75,7 +75,7 @@ public void mouseReleasedHead(double mouseX, double mouseY, int button, Callback
}

@Redirect(method = "mouseReleased", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;resizeDisplay()V"))
public void mouseReleasedResize(Minecraft instance) {}
public void tipTheScales$mouseReleasedResize(Minecraft instance) {}


}
Expand Up @@ -8,7 +8,7 @@
@Mixin(Option.class)
public interface OptionAccessor {

@Accessor
Component getCaption();
@Accessor("caption")
Component tipTheScales$getCaption();

}
Expand Up @@ -8,8 +8,8 @@
@Mixin(VideoSettingsScreen.class)
public interface VideoSettingsScreenAccessor {

@Accessor
static Option[] getOPTIONS() {
@Accessor("OPTIONS")
static Option[] tipTheScales$getOPTIONS() {

throw new UnsupportedOperationException();
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -14,7 +14,7 @@ fabricLoaderVersion=0.13.3

# Mod options
modName=TipTheScales
modAuthor=Jaredlll08
modAuthor=Jared
modId=tipthescales
modAvatar=https://media.forgecdn.net/avatars/131/501/636467873539016713.png
curseProjectId=282313
Expand Down

0 comments on commit 643a06a

Please sign in to comment.