mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-15 17:05:09 +01:00
stonecutter: cleaner versioned code
This commit is contained in:
@@ -112,7 +112,6 @@ public class MidnightLib {
|
|||||||
|
|
||||||
|
|
||||||
/*? if neoforge {*/
|
/*? if neoforge {*/
|
||||||
|
|
||||||
/*public static List<LiteralArgumentBuilder<CommandSourceStack>> commands = new ArrayList<>();
|
/*public static List<LiteralArgumentBuilder<CommandSourceStack>> commands = new ArrayList<>();
|
||||||
|
|
||||||
public MidnightLib() {
|
public MidnightLib() {
|
||||||
|
|||||||
@@ -7,22 +7,17 @@ public class MidnightLibConfig extends MidnightConfig {
|
|||||||
//? if fabric {
|
//? if fabric {
|
||||||
@Entry public static ConfigButton config_screen_list = PlatformFunctions.isModLoaded("modmenu") ? ConfigButton.MODMENU : ConfigButton.TRUE;
|
@Entry public static ConfigButton config_screen_list = PlatformFunctions.isModLoaded("modmenu") ? ConfigButton.MODMENU : ConfigButton.TRUE;
|
||||||
|
|
||||||
public enum ConfigButton {
|
|
||||||
TRUE, FALSE, MODMENU
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean shouldShowButton() {
|
public static boolean shouldShowButton() {
|
||||||
return config_screen_list.equals(ConfigButton.TRUE) || (config_screen_list.equals(ConfigButton.MODMENU) && !PlatformFunctions.isModLoaded("modmenu"));
|
return config_screen_list.equals(ConfigButton.TRUE) || (config_screen_list.equals(ConfigButton.MODMENU) && !PlatformFunctions.isModLoaded("modmenu"));
|
||||||
}
|
}
|
||||||
//?} else {
|
//?} else {
|
||||||
/*@Entry public static ConfigButton config_screen_list = ConfigButton.FALSE;
|
/*@Entry public static ConfigButton config_screen_list = ConfigButton.FALSE;
|
||||||
|
|
||||||
public enum ConfigButton {
|
|
||||||
TRUE, FALSE
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean shouldShowButton() {
|
public static boolean shouldShowButton() {
|
||||||
return config_screen_list.equals(ConfigButton.TRUE);
|
return config_screen_list.equals(ConfigButton.TRUE);
|
||||||
}
|
}
|
||||||
*///?}
|
*///?}
|
||||||
|
public enum ConfigButton {
|
||||||
|
TRUE, FALSE /*? if fabric {*/, MODMENU /*?}*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
//? if >= 1.21.9 {
|
//? if >= 1.21.9 {
|
||||||
import net.minecraft.client.input.MouseButtonEvent;
|
import net.minecraft.client.input.MouseButtonEvent;
|
||||||
//?}
|
//?}
|
||||||
|
|
||||||
public class ButtonEntry extends ContainerObjectSelectionList.Entry<ButtonEntry> {
|
public class ButtonEntry extends ContainerObjectSelectionList.Entry<ButtonEntry> {
|
||||||
@@ -37,13 +37,7 @@ public class ButtonEntry extends ContainerObjectSelectionList.Entry<ButtonEntry>
|
|||||||
int scaledWidth = Minecraft.getInstance().getWindow().getGuiScaledWidth();
|
int scaledWidth = Minecraft.getInstance().getWindow().getGuiScaledWidth();
|
||||||
|
|
||||||
if (text != null && (!text.getString().contains("spacer") || !buttons.isEmpty())) {
|
if (text != null && (!text.getString().contains("spacer") || !buttons.isEmpty())) {
|
||||||
title = new MultiLineTextWidget(12, 0,
|
title = new MultiLineTextWidget(12, 0, text.copy(), textRenderer).setCentered(centered);
|
||||||
//? if >= 1.21 {
|
|
||||||
Component.translationArg(text)
|
|
||||||
//?} else {
|
|
||||||
/*text.copy()
|
|
||||||
*///?}
|
|
||||||
, textRenderer).setCentered(centered);
|
|
||||||
if (info != null)
|
if (info != null)
|
||||||
title.setTooltip(info.getTooltip(false));
|
title.setTooltip(info.getTooltip(false));
|
||||||
title.setMaxWidth(!buttons.isEmpty() ? buttons.get(buttons.size() > 2 ? buttons.size() - 1 : 0).getX() - 16 : scaledWidth - 24);
|
title.setMaxWidth(!buttons.isEmpty() ? buttons.get(buttons.size() > 2 ? buttons.size() - 1 : 0).getX() - 16 : scaledWidth - 24);
|
||||||
@@ -70,13 +64,8 @@ public class ButtonEntry extends ContainerObjectSelectionList.Entry<ButtonEntry>
|
|||||||
Optional.ofNullable(this.buttons.get(0)).ifPresent(widget -> {
|
Optional.ofNullable(this.buttons.get(0)).ifPresent(widget -> {
|
||||||
int idMode = this.info.entry.idMode();
|
int idMode = this.info.entry.idMode();
|
||||||
if (idMode != -1) context.renderItem(idMode == 0 ?
|
if (idMode != -1) context.renderItem(idMode == 0 ?
|
||||||
//? if >= 1.21.4 {
|
BuiltInRegistries.ITEM./*? if >= 1.21.4 {*/ getValue /*?} else {*/ /*get*/ /*?}*/(ResourceLocation.tryParse(this.info.tempValue)).getDefaultInstance()
|
||||||
BuiltInRegistries.ITEM.getValue(ResourceLocation.tryParse(this.info.tempValue)).getDefaultInstance()
|
: BuiltInRegistries.BLOCK./*? if >= 1.21.4 {*/ getValue /*?} else {*/ /*get*/ /*?}*/(ResourceLocation.tryParse(this.info.tempValue)).asItem().getDefaultInstance(),
|
||||||
: BuiltInRegistries.BLOCK.getValue(ResourceLocation.tryParse(this.info.tempValue)).asItem().getDefaultInstance(),
|
|
||||||
//?} else {
|
|
||||||
/*BuiltInRegistries.ITEM.get(ResourceLocation.tryParse(this.info.tempValue)).getDefaultInstance()
|
|
||||||
: BuiltInRegistries.BLOCK.get(ResourceLocation.tryParse(this.info.tempValue)).asItem().getDefaultInstance(),
|
|
||||||
*///?}
|
|
||||||
widget.getX() + widget.getWidth() - 18, y + 2);
|
widget.getX() + widget.getWidth() - 18, y + 2);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,13 +130,7 @@ public abstract class MidnightConfig {
|
|||||||
info.function = (BiFunction<EditBox, Button, Predicate<String>>) (t, b) -> s -> {
|
info.function = (BiFunction<EditBox, Button, Predicate<String>>) (t, b) -> s -> {
|
||||||
s = s.trim();
|
s = s.trim();
|
||||||
if (!(s.isEmpty() || !isNumber || pattern.matcher(s).matches()) ||
|
if (!(s.isEmpty() || !isNumber || pattern.matcher(s).matches()) ||
|
||||||
(info.dataType == ResourceLocation.class && ResourceLocation.read(s)
|
(info.dataType == ResourceLocation.class && ResourceLocation.read(s)./*? if >= 1.21 {*/isError() /*?} else {*/ /*error().isPresent()*/ /*?}*/)) return false;
|
||||||
//? if >= 1.21 {
|
|
||||||
.isError()
|
|
||||||
//?} else {
|
|
||||||
/*.error().isPresent()
|
|
||||||
*///?}
|
|
||||||
)) return false;
|
|
||||||
|
|
||||||
Number value = 0; boolean inLimits = false; info.error = null;
|
Number value = 0; boolean inLimits = false; info.error = null;
|
||||||
if (!(isNumber && s.isEmpty()) && !s.equals("-") && !s.equals(".")) {
|
if (!(isNumber && s.isEmpty()) && !s.equals("-") && !s.equals(".")) {
|
||||||
|
|||||||
@@ -18,19 +18,11 @@ public class MidnightConfigListWidget extends ContainerObjectSelectionList<Butto
|
|||||||
public boolean renderHeaderSeparator = true;
|
public boolean renderHeaderSeparator = true;
|
||||||
|
|
||||||
public MidnightConfigListWidget(Minecraft client, int width, int height, int y, int itemHeight) {
|
public MidnightConfigListWidget(Minecraft client, int width, int height, int y, int itemHeight) {
|
||||||
//? if >= 1.21 {
|
super(client, width, height, y, /*? if < 1.21 {*/ /*height + y,*/ /*?}*/ itemHeight);
|
||||||
super(client, width, height, y, itemHeight);
|
|
||||||
//?} else {
|
|
||||||
/*super(client, width, height, y, height + y, itemHeight);
|
|
||||||
*///?}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//? if >= 1.21.4 {
|
public int /*? if >= 1.21.4 {*/ scrollBarX() /*?} else {*/ /*getScrollbarPosition()*/ /*?}*/ {
|
||||||
public int scrollBarX() {
|
|
||||||
//?} else {
|
|
||||||
/*public int getScrollbarPosition() {
|
|
||||||
*///?}
|
|
||||||
return this.width - 7;
|
return this.width - 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import net.minecraft.client.input.KeyEvent;
|
|||||||
//?}
|
//?}
|
||||||
|
|
||||||
//? if >=1.21 {
|
//? if >=1.21 {
|
||||||
import net.minecraft.client.gui.components.SpriteIconButton;
|
import net.minecraft.client.gui.components.SpriteIconButton;
|
||||||
//?}
|
//?}
|
||||||
|
|
||||||
public class MidnightConfigScreen extends Screen {
|
public class MidnightConfigScreen extends Screen {
|
||||||
@@ -79,7 +79,7 @@ public class MidnightConfigScreen extends Screen {
|
|||||||
updateList();
|
updateList();
|
||||||
list.setScrollAmount(0);
|
list.setScrollAmount(0);
|
||||||
}
|
}
|
||||||
scrollProgress = /*? < 1.21.4 {*/ /*list.getScrollAmount() *//*?} else {*/ list.scrollAmount() /*?}*/;
|
scrollProgress = /*? if < 1.21.4 {*/ /*list.getScrollAmount() *//*?} else {*/ list.scrollAmount() /*?}*/;
|
||||||
for (EntryInfo info : MidnightConfig.entries.values())
|
for (EntryInfo info : MidnightConfig.entries.values())
|
||||||
if (Objects.equals(modid, info.modid)) info.updateFieldValue();
|
if (Objects.equals(modid, info.modid)) info.updateFieldValue();
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
|||||||
Reference in New Issue
Block a user