Compare commits
13 Commits
aea8559831
...
architectu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ba128f322 | ||
|
|
cf58bd3637 | ||
|
|
61e9ca96fa | ||
|
|
b963764afe | ||
|
|
fefbaa1947 | ||
|
|
9602736335 | ||
|
|
30d213b92c | ||
|
|
b61b2cdf12 | ||
|
|
bcde119f23 | ||
|
|
b08e38ae11 | ||
|
|
a4d801ddf7 | ||
|
|
fd858bd468 | ||
|
|
02374253fd |
@@ -20,7 +20,7 @@ subprojects {
|
||||
// The following line declares the yarn mappings you may select this one as well.
|
||||
mappings loom.layered {
|
||||
it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2")
|
||||
// it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
|
||||
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ allprojects {
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
options.release = 17
|
||||
options.release = 21
|
||||
}
|
||||
ext {
|
||||
releaseChangelog = {
|
||||
|
||||
@@ -1,30 +1,52 @@
|
||||
package eu.midnightdust.core.mixin;
|
||||
|
||||
import eu.midnightdust.core.config.MidnightLibConfig;
|
||||
import eu.midnightdust.core.screen.MidnightConfigOverviewScreen;
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import eu.midnightdust.lib.util.screen.TexturedOverlayButtonWidget;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.option.OptionsScreen;
|
||||
import net.minecraft.client.gui.widget.TextIconButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ThreePartsLayoutWidget;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static eu.midnightdust.core.MidnightLib.MOD_ID;
|
||||
import static eu.midnightdust.core.config.MidnightLibConfig.shouldShowButton;
|
||||
|
||||
@Mixin(OptionsScreen.class)
|
||||
public class MixinOptionsScreen extends Screen {
|
||||
private static final Identifier MIDNIGHTLIB_ICON_TEXTURE = new Identifier("midnightlib","textures/gui/midnightlib_button.png");
|
||||
protected MixinOptionsScreen(Text title) {
|
||||
super(title);
|
||||
public abstract class MixinOptionsScreen extends Screen {
|
||||
@Shadow @Final private ThreePartsLayoutWidget layout;
|
||||
@Unique TextIconButtonWidget midnightlib$button = TextIconButtonWidget.builder(Text.translatable("midnightlib.overview.title"), (
|
||||
buttonWidget) -> Objects.requireNonNull(client).setScreen(new MidnightConfigOverviewScreen(this)), true)
|
||||
.texture(Identifier.of(MOD_ID,"icon/"+MOD_ID), 16, 16).dimension(20, 20).build();
|
||||
|
||||
private MixinOptionsScreen(Text title) {super(title);}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "init")
|
||||
public void midnightlib$onInit(CallbackInfo ci) {
|
||||
if (shouldShowButton()) {
|
||||
this.midnightlib$setButtonPos();
|
||||
this.addDrawableChild(midnightlib$button);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"),method = "init")
|
||||
private void midnightlib$init(CallbackInfo ci) {
|
||||
if (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.TRUE) || (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.MODMENU) && !PlatformFunctions.isModLoaded("modmenu")))
|
||||
this.addDrawableChild(new TexturedOverlayButtonWidget(this.width / 2 + 158, this.height / 6 - 12, 20, 20, 0, 0, 20, MIDNIGHTLIB_ICON_TEXTURE, 32, 64, (buttonWidget) -> Objects.requireNonNull(client).setScreen(new MidnightConfigOverviewScreen(this)), Text.translatable("midnightlib.overview.title")));
|
||||
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "initTabNavigation")
|
||||
public void midnightlib$onResize(CallbackInfo ci) {
|
||||
if (shouldShowButton()) this.midnightlib$setButtonPos();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Unique
|
||||
public void midnightlib$setButtonPos() {
|
||||
midnightlib$button.setPosition(layout.getWidth() / 2 + 158, layout.getY() + layout.getFooterHeight() - 4);
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,18 @@ import eu.midnightdust.core.MidnightLib;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.Selectable;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.*;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
import net.minecraft.text.*;
|
||||
import java.util.*;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static eu.midnightdust.lib.config.MidnightConfig.MidnightConfigListWidget;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class MidnightConfigOverviewScreen extends Screen {
|
||||
@@ -23,64 +25,26 @@ public class MidnightConfigOverviewScreen extends Screen {
|
||||
this.parent = parent;
|
||||
}
|
||||
private final Screen parent;
|
||||
private MidnightOverviewListWidget list;
|
||||
private MidnightConfigListWidget list;
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> Objects.requireNonNull(client).setScreen(parent)).dimensions(this.width / 2 - 100, this.height - 28, 200, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> Objects.requireNonNull(client).setScreen(parent)).dimensions(this.width / 2 - 100, this.height - 26, 200, 20).build());
|
||||
|
||||
this.list = new MidnightOverviewListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
|
||||
if (this.client != null && this.client.world != null) this.list.setRenderBackground(false);
|
||||
this.addSelectableChild(this.list);
|
||||
this.addSelectableChild(this.list = new MidnightConfigListWidget(this.client, this.width, this.height - 57, 24, 25));
|
||||
List<String> sortedMods = new ArrayList<>(MidnightConfig.configClass.keySet());
|
||||
Collections.sort(sortedMods);
|
||||
sortedMods.forEach((modid) -> {
|
||||
if (!MidnightLib.hiddenMods.contains(modid)) {
|
||||
list.addButton(ButtonWidget.builder(Text.translatable(modid +".midnightconfig.title"), (button) ->
|
||||
Objects.requireNonNull(client).setScreen(MidnightConfig.getScreen(this,modid))).dimensions(this.width / 2 - 125, this.height - 28, 250, 20).build());
|
||||
}
|
||||
});
|
||||
list.addButton(List.of(ButtonWidget.builder(Text.translatable(modid +".midnightconfig.title"), (button) ->
|
||||
Objects.requireNonNull(client).setScreen(MidnightConfig.getScreen(this, modid))).dimensions(this.width / 2 - 125, this.height - 28, 250, 20).build()), null, null);
|
||||
}});
|
||||
super.init();
|
||||
}
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(context);
|
||||
this.list.render(context, mouseX, mouseY, delta);
|
||||
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 15, 0xFFFFFF);
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
}
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class MidnightOverviewListWidget extends ElementListWidget<OverviewButtonEntry> {
|
||||
TextRenderer textRenderer;
|
||||
|
||||
public MidnightOverviewListWidget(MinecraftClient minecraftClient, int i, int j, int k, int l, int m) {
|
||||
super(minecraftClient, i, j, k, l, m);
|
||||
this.centerListVertically = false;
|
||||
textRenderer = minecraftClient.textRenderer;
|
||||
}
|
||||
@Override
|
||||
public int getScrollbarPositionX() {return this.width-7;}
|
||||
|
||||
public void addButton(ClickableWidget button) {
|
||||
this.addEntry(OverviewButtonEntry.create(button));
|
||||
}
|
||||
@Override
|
||||
public int getRowWidth() { return 400; }
|
||||
}
|
||||
public static class OverviewButtonEntry extends ElementListWidget.Entry<OverviewButtonEntry> {
|
||||
private final ClickableWidget button;
|
||||
private final List<ClickableWidget> buttonList = new ArrayList<>();
|
||||
|
||||
private OverviewButtonEntry(ClickableWidget button) {
|
||||
this.button = button;
|
||||
this.buttonList.add(button);
|
||||
}
|
||||
public static OverviewButtonEntry create(ClickableWidget button) {return new OverviewButtonEntry(button);}
|
||||
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
||||
button.setY(y);
|
||||
button.render(context, mouseX, mouseY, tickDelta);
|
||||
}
|
||||
public List<? extends Element> children() {return buttonList;}
|
||||
public List<? extends Selectable> selectableChildren() {return buttonList;}
|
||||
this.list.render(context, mouseX, mouseY, delta);
|
||||
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 10, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package eu.midnightdust.lib.config;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.*; import com.google.gson.stream.*;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer;
|
||||
@@ -32,26 +31,6 @@ import java.util.regex.Pattern;
|
||||
|
||||
import static net.minecraft.client.MinecraftClient.IS_SYSTEM_MAC;
|
||||
|
||||
|
||||
/* FIXME:
|
||||
* hi martin :wave:
|
||||
* before anythinge else:
|
||||
* DON'T ANNOY YOURSELF WITH THIS
|
||||
* BACKPORT UNLESS YOU REALLY DON'T HAVE
|
||||
* ANYTHING BETTER TO DO!!!!!
|
||||
* i don't wish to waste your time in any capacity,
|
||||
* and this backport is going to be a *huge* mess,
|
||||
* as you surely know
|
||||
* so please!! take it easy!
|
||||
* much love <3
|
||||
* .
|
||||
* this being your codebase, i'm guessing
|
||||
* (moreso hoping) you'll know what's in need
|
||||
* of fixing given the rendering changes between
|
||||
* 1.20 & 1.21
|
||||
* gave it my best shot but... got completely lost.
|
||||
*/
|
||||
|
||||
/** MidnightConfig by Martin "Motschen" Prokoph
|
||||
* Single class config library - feel free to copy!
|
||||
* Based on <a href="https://github.com/Minenash/TinyConfig">...</a>
|
||||
@@ -118,10 +97,8 @@ public abstract class MidnightConfig {
|
||||
if (!condition.requiredModId().isEmpty() && !PlatformFunctions.isModLoaded(condition.requiredModId()))
|
||||
this.conditionsMet = false;
|
||||
String requiredOption = condition.requiredOption().contains(":") ? condition.requiredOption() : (this.modid + ":" + condition.requiredOption());
|
||||
if (entries.get(requiredOption) != null) {
|
||||
EntryInfo info = entries.get(requiredOption);
|
||||
if (entries.get(requiredOption) instanceof EntryInfo info)
|
||||
this.conditionsMet &= List.of(condition.requiredValue()).contains(info.tempValue);
|
||||
}
|
||||
if (!this.conditionsMet) break;
|
||||
}
|
||||
if (prevConditionState != this.conditionsMet) reloadScreen = true;
|
||||
@@ -218,7 +195,8 @@ public abstract class MidnightConfig {
|
||||
info.function = (BiFunction<TextFieldWidget, ButtonWidget, Predicate<String>>) (t, b) -> s -> {
|
||||
s = s.trim();
|
||||
if (!(s.isEmpty() || !isNumber || pattern.matcher(s).matches()) ||
|
||||
(info.dataType == Identifier.class && Identifier.validate(s).equals(DataResult.success(new Identifier(s))))) return false; // inline substitution for "isError"
|
||||
(info.dataType == Identifier.class && Identifier.validate(s).isError())) return false;
|
||||
|
||||
Number value = 0; boolean inLimits = false; info.error = null;
|
||||
if (!(isNumber && s.isEmpty()) && !s.equals("-") && !s.equals(".")) {
|
||||
try { value = f.apply(s); } catch(NumberFormatException e){ return false; }
|
||||
@@ -322,10 +300,8 @@ public abstract class MidnightConfig {
|
||||
if (this.list != null) {
|
||||
for (ButtonEntry entry : this.list.children()) {
|
||||
if (entry.buttons != null && entry.buttons.size() > 1 && entry.info.field != null) {
|
||||
if (entry.buttons.get(0) != null) {
|
||||
ClickableWidget widget = entry.buttons.get(0);
|
||||
if (entry.buttons.get(0) instanceof ClickableWidget widget)
|
||||
if (widget.isFocused() || widget.isHovered()) widget.setTooltip(entry.info.getTooltip(true));
|
||||
}
|
||||
if (entry.buttons.get(1) instanceof ButtonWidget button)
|
||||
button.active = !Objects.equals(String.valueOf(entry.info.value), String.valueOf(entry.info.defaultValue)) && entry.info.conditionsMet;
|
||||
}}}}
|
||||
@@ -357,7 +333,7 @@ public abstract class MidnightConfig {
|
||||
Objects.requireNonNull(client).setScreen(parent);
|
||||
}).dimensions(this.width / 2 + 4, this.height - 26, 150, 20).build());
|
||||
|
||||
this.list = new MidnightConfigListWidget(this.client, this.width, this.height, this.height - 57, 24, 25);
|
||||
this.list = new MidnightConfigListWidget(this.client, this.width, this.height - 57, 24, 25);
|
||||
this.addSelectableChild(this.list); fillList();
|
||||
if (tabs.size() > 1) list.renderHeaderSeparator = false;
|
||||
}
|
||||
@@ -377,11 +353,11 @@ public abstract class MidnightConfig {
|
||||
}
|
||||
if (info.modid.equals(modid) && (info.tab == null || info.tab == tabManager.getCurrentTab())) {
|
||||
Text name = Objects.requireNonNullElseGet(info.name, () -> Text.translatable(translationPrefix + info.fieldName));
|
||||
IconButtonWidget resetButton = IconButtonWidget.builder(Text.translatable("controls.reset"), Identifier.of("midnightlib","icon/reset"), (button -> {
|
||||
TextIconButtonWidget resetButton = TextIconButtonWidget.builder(Text.translatable("controls.reset"), (button -> {
|
||||
info.value = info.defaultValue; info.listIndex = 0;
|
||||
info.tempValue = info.toTemporaryValue();
|
||||
updateList();
|
||||
}) ).build();
|
||||
}), true).texture(Identifier.of("midnightlib","icon/reset"), 12, 12).dimension(20, 20).build();
|
||||
resetButton.setPosition(width - 205 + 150 + 25, 0);
|
||||
|
||||
if (info.function != null) {
|
||||
@@ -429,7 +405,7 @@ public abstract class MidnightConfig {
|
||||
} catch (Exception ignored) {}
|
||||
info.actionButton = colorButton;
|
||||
} else if (e.selectionMode() > -1) {
|
||||
ButtonWidget explorerButton = IconButtonWidget.builder(Text.empty(), Identifier.of("midnightlib", "icon/explorer"),
|
||||
ButtonWidget explorerButton = TextIconButtonWidget.builder(Text.empty(),
|
||||
button -> new Thread(() -> {
|
||||
JFileChooser fileChooser = new JFileChooser(info.tempValue);
|
||||
fileChooser.setFileSelectionMode(e.selectionMode()); fileChooser.setDialogType(e.fileChooserType());
|
||||
@@ -441,8 +417,8 @@ public abstract class MidnightConfig {
|
||||
info.setValue(fileChooser.getSelectedFile().getAbsolutePath());
|
||||
updateList();
|
||||
}
|
||||
}).start()
|
||||
).build();
|
||||
}).start(), true
|
||||
).texture(Identifier.of("midnightlib", "icon/explorer"), 12, 12).dimension(20, 20).build();
|
||||
explorerButton.setPosition(width - 185, 0);
|
||||
info.actionButton = explorerButton;
|
||||
}
|
||||
@@ -473,10 +449,9 @@ public abstract class MidnightConfig {
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class MidnightConfigListWidget extends ElementListWidget<ButtonEntry> {
|
||||
public boolean renderHeaderSeparator = true;
|
||||
public MidnightConfigListWidget(MinecraftClient client, int width, int height, int yStart, int y, int itemHeight) { super(client, width, height, yStart, y, itemHeight); }
|
||||
@Override public int getScrollbarPositionX() { return this.width -7; }
|
||||
public MidnightConfigListWidget(MinecraftClient client, int width, int height, int y, int itemHeight) { super(client, width, height, y, itemHeight); }
|
||||
@Override public int getScrollbarX() { return this.width -7; }
|
||||
|
||||
/*
|
||||
@Override
|
||||
protected void drawHeaderAndFooterSeparators(DrawContext context) {
|
||||
if (renderHeaderSeparator) super.drawHeaderAndFooterSeparators(context);
|
||||
@@ -484,7 +459,6 @@ public abstract class MidnightConfig {
|
||||
context.drawTexture(this.client.world == null ? Screen.FOOTER_SEPARATOR_TEXTURE : Screen.INWORLD_FOOTER_SEPARATOR_TEXTURE, this.getX(), this.getBottom(), 0.0F, 0.0F, this.getWidth(), 2, 32, 2);
|
||||
RenderSystem.disableBlend(); }
|
||||
}
|
||||
*/
|
||||
public void addButton(List<ClickableWidget> buttons, Text text, EntryInfo info) { this.addEntry(new ButtonEntry(buttons, text, info)); }
|
||||
public void clear() { this.clearEntries(); }
|
||||
@Override public int getRowWidth() { return 10000; }
|
||||
@@ -517,8 +491,7 @@ public abstract class MidnightConfig {
|
||||
boolean tooltipVisible = mouseX >= title.getX() && mouseX < title.getWidth() + title.getX() && mouseY >= title.getY() && mouseY < title.getHeight() + title.getY();
|
||||
if (tooltipVisible && title.getTooltip() != null) context.drawOrderedTooltip(textRenderer, title.getTooltip().getLines(MinecraftClient.getInstance()), mouseX, mouseY);
|
||||
|
||||
if (info.entry != null && !this.buttons.isEmpty() && this.buttons.get(0) != null) {
|
||||
ClickableWidget widget = this.buttons.get(0);
|
||||
if (info.entry != null && !this.buttons.isEmpty() && this.buttons.getFirst() instanceof ClickableWidget widget) {
|
||||
int idMode = this.info.entry.idMode();
|
||||
if (idMode != -1) context.drawItem(idMode == 0 ? Registries.ITEM.get(Identifier.tryParse(this.info.tempValue)).getDefaultStack() : Registries.BLOCK.get(Identifier.tryParse(this.info.tempValue)).asItem().getDefaultStack(), widget.getX() + widget.getWidth() - 18, y + 2);
|
||||
}
|
||||
@@ -528,7 +501,7 @@ public abstract class MidnightConfig {
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (this.info != null && this.info.comment != null && !this.info.comment.url().isBlank())
|
||||
ConfirmLinkScreen.open(this.info.comment.url(), MinecraftClient.getInstance().currentScreen, true);
|
||||
ConfirmLinkScreen.open(MinecraftClient.getInstance().currentScreen, this.info.comment.url(), true);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package eu.midnightdust.lib.util.screen;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.widget.TexturedButtonWidget;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class TexturedOverlayButtonWidget extends TexturedButtonWidget {
|
||||
|
||||
public TexturedOverlayButtonWidget(int x, int y, int width, int height, int u, int v, Identifier texture, PressAction pressAction) {
|
||||
super(x, y, width, height, u, v, texture, pressAction);
|
||||
}
|
||||
|
||||
public TexturedOverlayButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, Identifier texture, PressAction pressAction) {
|
||||
super(x, y, width, height, u, v, hoveredVOffset, texture, pressAction);
|
||||
}
|
||||
|
||||
public TexturedOverlayButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, Identifier texture, int textureWidth, int textureHeight, PressAction pressAction) {
|
||||
super(x, y, width, height, u, v, hoveredVOffset, texture, textureWidth, textureHeight, pressAction);
|
||||
}
|
||||
|
||||
public TexturedOverlayButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, Identifier texture, int textureWidth, int textureHeight, PressAction pressAction, Text text) {
|
||||
super(x, y, width, height, u, v, hoveredVOffset, texture, textureWidth, textureHeight, pressAction, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
int i = 66;
|
||||
if (!this.isNarratable()) {
|
||||
i += hoveredVOffset * 2;
|
||||
} else if (this.isSelected()) {
|
||||
i += hoveredVOffset;
|
||||
}
|
||||
context.drawNineSlicedTexture(WIDGETS_TEXTURE, this.getX(), this.getY(), this.width, this.height, 4, 200, 20, 0, i);
|
||||
super.renderButton(context, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 960 B |
|
Before Width: | Height: | Size: 136 B After Width: | Height: | Size: 136 B |
|
After Width: | Height: | Size: 136 B |
|
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 114 B |
@@ -1,12 +1 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "eu.midnightdust.core.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"MixinOptionsScreen"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
{"required": true,"minVersion": "0.8","package": "eu.midnightdust.core.mixin","compatibilityLevel": "JAVA_17","client": ["MixinOptionsScreen"],"injectors": {"defaultRequire": 1}}
|
||||
@@ -65,7 +65,7 @@ components.java {
|
||||
}
|
||||
}
|
||||
|
||||
/*unifiedPublishing {
|
||||
unifiedPublishing {
|
||||
project {
|
||||
displayName = "MidnightLib $rootProject.version - Fabric $project.minecraft_version"
|
||||
releaseType = "$project.release_type"
|
||||
@@ -85,7 +85,7 @@ components.java {
|
||||
curseforge {
|
||||
token = CURSEFORGE_TOKEN
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 17", project.minecraft_version
|
||||
gameVersions.addAll "Java 21", project.minecraft_version
|
||||
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
|
||||
}
|
||||
}
|
||||
@@ -101,4 +101,4 @@ components.java {
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -36,7 +36,7 @@
|
||||
},
|
||||
"depends": {
|
||||
"fabric-resource-loader-v0": "*",
|
||||
"minecraft": ">=1.20"
|
||||
"minecraft": ">=1.21"
|
||||
},
|
||||
|
||||
"mixins": [
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
org.gradle.jvmargs=-Xmx4096M
|
||||
|
||||
minecraft_version=1.20.1
|
||||
supported_versions=1.20
|
||||
yarn_mappings=1.20.1+build.10
|
||||
enabled_platforms=fabric
|
||||
minecraft_version=1.21.1
|
||||
supported_versions=1.21
|
||||
yarn_mappings=1.21.1+build.3
|
||||
enabled_platforms=fabric,neoforge
|
||||
|
||||
archives_base_name=midnightlib
|
||||
mod_version=1.7.5
|
||||
maven_group=eu.midnightdust
|
||||
# release_type=release
|
||||
# curseforge_id=488090
|
||||
# modrinth_id=codAaoxh
|
||||
release_type=release
|
||||
curseforge_id=488090
|
||||
modrinth_id=codAaoxh
|
||||
|
||||
fabric_loader_version=0.16.14
|
||||
fabric_api_version=0.92.6+1.20.1
|
||||
fabric_api_version=0.116.4+1.21.1
|
||||
|
||||
mod_menu_version = 7.2.2
|
||||
neoforge_version=21.1.192
|
||||
yarn_mappings_patch_neoforge_version = 1.21+build.4
|
||||
|
||||
mod_menu_version = 9.0.0
|
||||
108
neoforge/build.gradle
Normal file
@@ -0,0 +1,108 @@
|
||||
plugins {
|
||||
id 'com.github.johnrengelman.shadow'
|
||||
id "me.shedaniel.unified-publishing"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'NeoForged'
|
||||
url = 'https://maven.neoforged.net/releases'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
neoForge()
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = project(":common").loom.accessWidenerPath
|
||||
}
|
||||
|
||||
configurations {
|
||||
common {
|
||||
canBeResolved = true
|
||||
canBeConsumed = false
|
||||
}
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentNeoForge.extendsFrom common
|
||||
|
||||
// Files in this configuration will be bundled into your mod using the Shadow plugin.
|
||||
// Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
|
||||
shadowBundle {
|
||||
canBeResolved = true
|
||||
canBeConsumed = false
|
||||
}
|
||||
archivesBaseName = rootProject.archives_base_name
|
||||
version = rootProject.mod_version + "-" + project.name + "+" + rootProject.minecraft_version
|
||||
}
|
||||
|
||||
dependencies {
|
||||
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
|
||||
|
||||
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
||||
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property 'version', rootProject.version
|
||||
|
||||
filesMatching('META-INF/neoforge.mods.toml') {
|
||||
expand version: rootProject.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowBundle]
|
||||
archiveClassifier = 'dev-shadow'
|
||||
}
|
||||
|
||||
remapJar {
|
||||
input.set shadowJar.archiveFile
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
unifiedPublishing {
|
||||
project {
|
||||
displayName = "MidnightLib $rootProject.version - NeoForge $project.minecraft_version"
|
||||
releaseType = "$project.release_type"
|
||||
changelog = releaseChangelog()
|
||||
gameVersions = []
|
||||
gameLoaders = ["neoforge"]
|
||||
mainPublication remapJar
|
||||
|
||||
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
||||
if (CURSEFORGE_TOKEN != null) {
|
||||
curseforge {
|
||||
token = CURSEFORGE_TOKEN
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 21", project.minecraft_version
|
||||
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
|
||||
}
|
||||
}
|
||||
|
||||
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
||||
if (MODRINTH_TOKEN != null) {
|
||||
modrinth {
|
||||
token = MODRINTH_TOKEN
|
||||
id = rootProject.modrinth_id
|
||||
version = rootProject.mod_version + "+" + rootProject.minecraft_version + "-" + project.name
|
||||
gameVersions.addAll project.minecraft_version
|
||||
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
neoforge/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
loom.platform=neoforge
|
||||
@@ -0,0 +1,33 @@
|
||||
package eu.midnightdust.lib.util.neoforge;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.fml.loading.FMLPaths;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static eu.midnightdust.neoforge.MidnightLibNeoForge.commands;
|
||||
|
||||
public class PlatformFunctionsImpl {
|
||||
public static String getPlatformName() {
|
||||
return "neoforge";
|
||||
}
|
||||
/**
|
||||
* This is our actual method to {@link PlatformFunctions#getConfigDirectory()}.
|
||||
*/
|
||||
public static Path getConfigDirectory() {
|
||||
return FMLPaths.CONFIGDIR.get();
|
||||
}
|
||||
public static boolean isClientEnv() {
|
||||
return FMLEnvironment.dist.isClient();
|
||||
}
|
||||
public static boolean isModLoaded(String modid) {
|
||||
return ModList.get().isLoaded(modid);
|
||||
}
|
||||
public static void registerCommand(LiteralArgumentBuilder<ServerCommandSource> command) {
|
||||
commands.add(command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package eu.midnightdust.neoforge;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import eu.midnightdust.core.MidnightLib;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
|
||||
@Mod("midnightlib")
|
||||
public class MidnightLibNeoForge {
|
||||
public static List<LiteralArgumentBuilder<ServerCommandSource>> commands = new ArrayList<>();
|
||||
|
||||
public MidnightLibNeoForge() {
|
||||
if (FMLEnvironment.dist == Dist.CLIENT) MidnightLib.onInitializeClient();
|
||||
}
|
||||
|
||||
@EventBusSubscriber(modid = "midnightlib", value = Dist.CLIENT)
|
||||
public static class MidnightLibBusEvents {
|
||||
@SubscribeEvent
|
||||
public static void onPostInit(FMLClientSetupEvent event) {
|
||||
ModList.get().forEachModContainer((modid, modContainer) -> {
|
||||
if (MidnightConfig.configClass.containsKey(modid) && !MidnightLib.hiddenMods.contains(modid)) {
|
||||
modContainer.registerExtensionPoint(IConfigScreenFactory.class, (minecraftClient, screen) -> MidnightConfig.getScreen(screen, modid));
|
||||
}
|
||||
});
|
||||
MidnightLib.registerAutoCommand();
|
||||
}
|
||||
}
|
||||
|
||||
@EventBusSubscriber(modid = "midnightlib")
|
||||
public static class MidnightLibEvents {
|
||||
@SubscribeEvent
|
||||
public static void registerCommands(RegisterCommandsEvent event) {
|
||||
try {
|
||||
commands.forEach(command -> event.getDispatcher().register(command));
|
||||
}
|
||||
catch (ConcurrentModificationException ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
neoforge/src/main/resources/META-INF/neoforge.mods.toml
Normal file
@@ -0,0 +1,31 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[2,)"
|
||||
#issueTrackerURL = ""
|
||||
license = "MIT License"
|
||||
|
||||
[[mods]]
|
||||
modId = "midnightlib"
|
||||
version = "${version}"
|
||||
displayName = "MidnightLib"
|
||||
logoFile = "midnightlib.png"
|
||||
authors = "TeamMidnightDust, Motschen"
|
||||
description = '''
|
||||
Common Library for Team MidnightDust's mods.
|
||||
'''
|
||||
|
||||
[[mixins]]
|
||||
config = "midnightlib.mixins.json"
|
||||
|
||||
[[dependencies.midnightlib]]
|
||||
modId = "neoforge"
|
||||
mandatory = true
|
||||
versionRange = "[20.5,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.midnightlib]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.20.5,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
BIN
neoforge/src/main/resources/midnightlib.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
@@ -1,4 +1,3 @@
|
||||
/*
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
}
|
||||
@@ -87,4 +86,3 @@ publishing {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -10,8 +10,8 @@ pluginManagement {
|
||||
include("common")
|
||||
include("fabric")
|
||||
include("test-fabric")
|
||||
// include("neoforge")
|
||||
// include("test-neoforge")
|
||||
include("neoforge")
|
||||
include("test-neoforge")
|
||||
//include("quilt")
|
||||
|
||||
rootProject.name = "midnightlib"
|
||||
|
||||