Skip to content

Commit

Permalink
Workaround for crossversion Component
Browse files Browse the repository at this point in the history
  • Loading branch information
PieKing1215 committed Jan 16, 2023
1 parent 7b0677e commit 4fe39a3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.vertex.PoseStack;
import me.pieking1215.invmove.module.CVComponent;
import me.pieking1215.invmove.module.Module;
import me.pieking1215.invmove.module.VanillaModule16;
import net.minecraft.client.KeyMapping;
Expand Down Expand Up @@ -66,6 +67,13 @@ public static void registerModule(Module module) {

public abstract MutableComponent translatableComponent(String key);
public abstract MutableComponent literalComponent(String text);
public MutableComponent fromCV(CVComponent c) {
if (c.translate) {
return translatableComponent(c.text);
} else {
return literalComponent(c.text);
}
}

public abstract boolean optionToggleCrouch();
public abstract void setOptionToggleCrouch(boolean toggleCrouch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static Screen setupCloth(Screen parent){
MOVEMENT.cfg.addTo(movement, eb, "config.invmove");

for (Module module : InvMove.instance().modules) {
SubCategoryBuilder cat = eb.startSubCategory(module.getTitle());
SubCategoryBuilder cat = eb.startSubCategory(InvMove.instance().fromCV(module.getTitle()));
module.getMovementConfig().addTo(cat, eb, "config.invmove." + module.getId() + "");
movement.addEntry(cat.build());
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public static Screen setupCloth(Screen parent){
BACKGROUND.cfg.addTo(background, eb, "config.invmove");

for (Module module : InvMove.instance().modules) {
SubCategoryBuilder cat = eb.startSubCategory(module.getTitle());
SubCategoryBuilder cat = eb.startSubCategory(InvMove.instance().fromCV(module.getTitle()));
module.getBackgroundConfig().addTo(cat, eb, "config.invmove." + module.getId() + "");
background.addEntry(cat.build());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package me.pieking1215.invmove.module;

public class CVComponent {
public boolean translate = false;
public String text;

public CVComponent(boolean translate, String text) {
this.translate = translate;
this.text = text;
}

public static CVComponent literal(String text) {
return new CVComponent(false, text);
}

public static CVComponent translated(String text) {
return new CVComponent(true, text);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package me.pieking1215.invmove.module;

import me.pieking1215.invmove.InvMove;
import me.pieking1215.invmove.module.config.ModuleConfig;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;

public interface Module {
@SuppressWarnings("SameReturnValue")
String getId();
default Component getTitle() {
return InvMove.instance().translatableComponent("key.invmove.module." + getId());
default CVComponent getTitle() {
return CVComponent.translated("key.invmove.module." + getId());
}
Movement shouldAllowMovement(Screen screen);
Background shouldHideBackground(Screen screen);
Expand Down

0 comments on commit 4fe39a3

Please sign in to comment.