Skip to content

Commit

Permalink
get it to build
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfudge committed May 18, 2024
1 parent b74d457 commit 6c50c10
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 52 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ allprojects {

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(21))
}
withSourcesJar()
}
Expand Down
7 changes: 0 additions & 7 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
}
dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations
// Do NOT use other classes from fabric loader
modImplementation libs.fabric.loader
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}

configurations {
Expand All @@ -22,6 +18,3 @@ architectury {
repositories {
mavenCentral()
}
kotlin {
jvmToolchain(17)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package fudge.notenoughcrashes.config;

import com.google.common.collect.Lists;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import fudge.notenoughcrashes.NotEnoughCrashes;
import com.mojang.blaze3d.systems.RenderSystem;
import fudge.notenoughcrashes.platform.NecPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand All @@ -19,7 +20,6 @@
import net.minecraft.client.gui.tab.TabManager;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.OrderedText;
Expand Down Expand Up @@ -168,7 +168,7 @@ private static void textField(EntryInfo info, Function<String,Number> f, Pattern
info.value = isNumber? value : s;
else if (inLimits) {
if (((List<String>) info.value).size() == info.index) ((List<String>) info.value).add("");
((List<String>) info.value).set(info.index, Arrays.stream(info.tempValue.replace("[", "").replace("]", "").split(", ")).toList().get(0));
((List<String>) info.value).set(info.index, Arrays.stream(info.tempValue.replace("[", "").replace("]", "").split(", ")).toList().getFirst());
}

if (info.field.getAnnotation(Entry.class).isColor()) {
Expand Down Expand Up @@ -292,7 +292,7 @@ public void init() {
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.CANCEL, button -> {
loadValues();
Objects.requireNonNull(client).setScreen(parent);
}).dimensions(this.width / 2 - 154, this.height - 28, 150, 20).build());
}).dimensions(this.width / 2 - 154, this.height - 26, 150, 20).build());
done = this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
for (EntryInfo info : entries)
if (info.id.equals(modid)) {
Expand All @@ -302,10 +302,9 @@ public void init() {
}
write(modid);
Objects.requireNonNull(client).setScreen(parent);
}).dimensions(this.width / 2 + 4, this.height - 28, 150, 20).build());
}).dimensions(this.width / 2 + 4, this.height - 26, 150, 20).build());

this.list = new MidnightConfigListWidget(this.client, this.width, this.height - 64, 32, 25);
if (this.client != null && this.client.world != null) this.list.setRenderBackground(false);
this.list = new MidnightConfigListWidget(this.client, this.width, this.height - 57, 24, 25);
this.addSelectableChild(this.list);

fillList();
Expand All @@ -321,7 +320,7 @@ public void fillList() {
info.index = 0;
list.clear();
fillList();
}), true).texture(new Identifier(NotEnoughCrashes.MOD_ID,"icon/reset"), 12, 12).dimension(40, 20).build();
}), true).texture(new Identifier("midnightlib","icon/reset"), 12, 12).dimension(40, 20).build();
resetButton.setPosition(width - 205, 0);

if (info.widget instanceof Map.Entry) {
Expand Down Expand Up @@ -382,62 +381,61 @@ public void fillList() {
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
if (client != null && client.world != null) super.renderInGameBackground(context);
this.list.render(context, mouseX, mouseY, delta);
super.render(context,mouseX,mouseY,delta);
this.list.render(context, mouseX, mouseY, delta);

if (tabs.size() < 2) context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 15, 0xFFFFFF);
if (tabs.size() < 2)
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 10, 0xFFFFFF);
list.renderHeaderSeperator = tabs.size() < 2;
}
@Override public void renderBackground(DrawContext c, int x, int y, float d) {}
}
@Environment(EnvType.CLIENT)
public static class MidnightConfigListWidget extends ElementListWidget<ButtonEntry> {
boolean renderHeaderSeperator = true;
public MidnightConfigListWidget(MinecraftClient client, int width, int height, int y, int itemHeight) {
super(client, width, height, y, itemHeight);
}
@Override
public int getScrollbarPositionX() { return this.width -7; }
public int getScrollbarX() { return this.width -7; }

@Override
protected void drawHeaderAndFooterSeparators(DrawContext context) {
if (renderHeaderSeperator) super.drawHeaderAndFooterSeparators(context);
else {
RenderSystem.enableBlend();
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; }
@Override
protected void renderDecorations(DrawContext c, int mouseX, int mouseY) {
c.setShaderColor(0.25F, 0.25F, 0.25F, 1.0F);
c.drawTexture(Screen.OPTIONS_BACKGROUND_TEXTURE, this.getX(), 0, 0.0F, 0.0F, this.width, this.getY(), 32, 32);
c.drawTexture(Screen.OPTIONS_BACKGROUND_TEXTURE, this.getX(), this.getBottom(), 0.0F, 0.0F, this.width, this.height, 32, 32);
c.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
if (client == null || client.world == null) return;
c.fillGradient(RenderLayer.getGuiOverlay(), this.getX(), this.getY(), this.getRight(), this.getY() + 4, -16777216, 0, 0);
c.fillGradient(RenderLayer.getGuiOverlay(), this.getX(), this.getBottom() - 4, this.getRight(), this.getBottom(), 0, -16777216, 0);
}
}
public static class ButtonEntry extends ElementListWidget.Entry<ButtonEntry> {
private static final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
public final List<ClickableWidget> buttons;
private final Text text;
public final EntryInfo info;
public boolean centered = false;
public static final Map<ClickableWidget, Text> buttonsWithText = new HashMap<>();

private ButtonEntry(List<ClickableWidget> buttons, Text text, EntryInfo info) {
if (!buttons.isEmpty()) buttonsWithText.put(buttons.get(0),text);
public ButtonEntry(List<ClickableWidget> buttons, Text text, EntryInfo info) {
if (!buttons.isEmpty()) buttonsWithText.put(buttons.getFirst(),text);
this.buttons = buttons;
this.text = text;
this.info = info;
if (info != null) this.centered = info.centered;
}
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
buttons.forEach(b -> { b.setY(y); b.render(context, mouseX, mouseY, tickDelta); });
if (text != null && (!text.getString().contains("spacer") || !buttons.isEmpty())) {
if (info.centered) context.drawTextWithShadow(textRenderer, text, MinecraftClient.getInstance().getWindow().getScaledWidth() / 2 - (textRenderer.getWidth(text) / 2), y + 5, 0xFFFFFF);
else {
int wrappedY = y;
for(Iterator<OrderedText> iterator = textRenderer.wrapLines(text, (buttons.size() > 1 ? buttons.get(1).getX()-24 : MinecraftClient.getInstance().getWindow().getScaledWidth() - 24)).iterator(); iterator.hasNext(); wrappedY += 9) {
OrderedText orderedText = iterator.next();
context.drawTextWithShadow(textRenderer, orderedText, 12, wrappedY + 5, 0xFFFFFF);
}
int wrappedY = y;
for(Iterator<OrderedText> textIterator = textRenderer.wrapLines(text, (buttons.size() > 1 ? buttons.get(1).getX()-24 : MinecraftClient.getInstance().getWindow().getScaledWidth() - 24)).iterator(); textIterator.hasNext(); wrappedY += 9) {
context.drawTextWithShadow(textRenderer, textIterator.next(), (centered) ? (MinecraftClient.getInstance().getWindow().getScaledWidth() / 2 - (textRenderer.getWidth(text) / 2)) : 12, wrappedY + 5, 0xFFFFFF);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fudge.notenoughcrashes.mixins;

import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.crash.CrashReportSection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -13,11 +12,16 @@ public class MixinTileEntity {

private boolean noNBT = false;

@SuppressWarnings("UnreachableCode")
@Inject(method = "populateCrashReport", at = @At("TAIL"))
private void onPopulateCrashReport(CrashReportSection section, CallbackInfo ci) {
if (!noNBT) {
noNBT = true;
section.add("Block Entity NBT", () -> ((BlockEntity) (Object) this).createNbt().toString());
var self = (BlockEntity) (Object) this;
var world = self.getWorld();
if (world != null) {
section.add("Block Entity NBT", () -> self.createNbt(world.getRegistryManager()).toString());
}
noNBT = false;
}
}
Expand Down
16 changes: 8 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod_version = "4.4.7"

# Gradle Plugins
architectury_plugin = "3.4-SNAPSHOT"
architectury_loom = "1.4-SNAPSHOT"
architectury_loom = "1.6-SNAPSHOT"

minotaur = "2.8.7"
#loom_quiltflower = "1.11.0"
Expand All @@ -26,23 +26,23 @@ shadow = "7.1.2"
task_tree = "2.1.0"

# Minecraft
minecraft = "1.20.4"
minecraft = "1.20.6"

# CurseForge & Modrinth MC overrides (or "mc" to use the main version)
overrides_curseforge = "mc"
overrides_modrinth = "mc"
release_type = "release"

# Mods & Libraries
yarn_mappings = "1.20.4+build.3"
fabric_loader = "0.15.5"
fabric_api = "0.93.1+1.20.4"
modmenu = "9.0.0"
yarn_mappings = "1.20.6+build.1"
fabric_loader = "0.15.11"
fabric_api = "0.98.0+1.20.6"
modmenu = "10.0.0-beta.1"


quilt_loader = "0.17.6"
forge = "49.0.19"
architectury_api = "11.0.11"
forge = "50.0.22"
architectury_api = "12.0.27"

[libraries]

Expand Down
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.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pluginManagement {

plugins {
id 'de.fayard.refreshVersions' version '0.51.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}

include("common")
Expand Down

0 comments on commit 6c50c10

Please sign in to comment.