Skip to content

Commit

Permalink
Merge pull request #101 from Adventurecraft-Awakening/nostalgia-toolc…
Browse files Browse the repository at this point in the history
…hain

Toolchain upgrade and Nostalgia mappings
  • Loading branch information
TechPizzaDev authored Sep 17, 2024
2 parents b4b0ec1 + e3df126 commit 38b3636
Show file tree
Hide file tree
Showing 400 changed files with 10,997 additions and 11,007 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
build/
out/
classes/
remappedSrc/

# eclipse

Expand Down
45 changes: 26 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
plugins {
// Babric loom version can be checked here: https://github.com/babric/fabric-loom/tags
id 'babric-loom' version '1.5-SNAPSHOT'
id 'fabric-loom' version '1.7.4'
id 'babric-loom-extension' version '1.7.4'
id 'maven-publish'
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
def modId = project.mod_id

base {
archivesName = project.archives_base_name
}

loom {
gluedMinecraftJar()
customMinecraftManifest.set("https://babric.github.io/manifest-polyfill/${minecraft_version}.json")
intermediaryUrl.set("https://maven.glass-launcher.net/babric/babric/intermediary/%1\$s/intermediary-%1\$s-v2.jar")
accessWidenerPath = file("src/main/resources/${modId}.accesswidener")
}

babric {
disableM1Fixes.set(true) // Disable gambac (M1 colours fix.)
}

repositories {
// Used for the fabric toolchain in this project.
maven {
name = 'Babric'
url = 'https://maven.glass-launcher.net/babric'
}
// Used for mappings.
maven {
name 'LegacyFabric'
url = "https://repo.legacyfabric.net/repository/legacyfabric"
name = 'Nostalgia'
url = 'https://maven.wispforest.io'
}
// Used for projects that do not have a maven repository, but do have a GitHub repository with working build scripts.
maven {
name 'Jitpack'
url 'https://jitpack.io/'
name = 'Jitpack'
url = 'https://jitpack.io/'
}
maven {
name 'HalfOf2'
url 'https://storage.googleapis.com/devan-maven/'
name = 'HalfOf2'
url = 'https://storage.googleapis.com/devan-maven/'
}
maven {
name 'LWJGL3'
url 'https://oss.sonatype.org/content/repositories/releases/'
name = 'LWJGL3'
url = 'https://oss.sonatype.org/content/repositories/releases/'
}
mavenLocal()
}
Expand Down Expand Up @@ -78,8 +83,8 @@ dependencies {
implementation 'org.mozilla:rhino:1.7.15'

minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.legacyfabric:beta-yarn:${project.yarn_version}"
modImplementation "babric:fabric-loader:${project.loader_version}"
mappings "me.alphamode:nostalgia:${project.nostalgia_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

implementation "org.slf4j:slf4j-api:1.8.0-beta4"
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"
Expand Down Expand Up @@ -112,11 +117,13 @@ java {
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
rename { "${it}_${project.base.archivesName.get()}"}
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://babric.github.io/develop/
minecraft_version=b1.7.3
yarn_version=b1.7.3+build.4
loader_version=0.15.6-babric.2
nostalgia_mappings=b1.7.3+build.33
loader_version=0.16.5

# Mod Properties
mod_id = adventurecraft
Expand Down
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#Wed Jul 17 12:49:09 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions src/main/java/dev/adventurecraft/awakening/ACMainThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.GameStartupError;
import net.minecraft.client.CrashReport;
import net.minecraft.client.Minecraft;

import java.io.File;
Expand All @@ -21,13 +21,13 @@ public ACMainThread(int width, int height, boolean fullScreen) {
}

@Override
public void showGameStartupError(GameStartupError arg) {
public void onCrash(CrashReport arg) {
// TODO:
}

public static File getMapsDirectory() {
if (mapsDirectory == null) {
mapsDirectory = new File(getGameDirectory(), "../maps");
mapsDirectory = new File(getWorkingDirectory(), "../maps");
}
return mapsDirectory;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
package dev.adventurecraft.awakening.client.gui;

import dev.adventurecraft.awakening.client.options.OptionOF;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widgets.OptionButtonWidget;
import net.minecraft.client.gui.widgets.SliderWidget;
import net.minecraft.client.options.GameOptions;
import net.minecraft.client.options.Option;
import net.minecraft.client.resource.language.TranslationStorage;
import net.minecraft.client.util.ScreenScaler;

import java.util.List;
import net.minecraft.client.Option;
import net.minecraft.client.Options;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.OptionButton;
import net.minecraft.client.gui.components.SliderButton;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.locale.I18n;

public abstract class GuiBaseSettingsOF extends Screen implements OptionTooltipProvider {

protected Screen prevScreen;
protected String title;
protected GameOptions options;
protected Options options;
protected int lastMouseX = 0;
protected int lastMouseY = 0;
protected long mouseStillTime = 0L;

public GuiBaseSettingsOF(Screen prevScreen, GameOptions options, String title) {
public GuiBaseSettingsOF(Screen prevScreen, Options options, String title) {
this.prevScreen = prevScreen;
this.options = options;
this.title = title;
}

@Override
public void initVanillaScreen() {
TranslationStorage ts = TranslationStorage.getInstance();
public void init() {
I18n ts = I18n.getInstance();
int index = 0;
Option[] options = getOptions();

Expand All @@ -38,43 +36,43 @@ public void initVanillaScreen() {
int y = this.height / 6 + 24 * (index / 2);

int id = option.getId();
String text = this.options.getTranslatedValue(option);
String text = this.options.getMessage(option);

if (!option.isSlider()) {
this.buttons.add(new OptionButtonWidget(id, x, y, option, text));
if (!option.isProgress()) {
this.buttons.add(new OptionButton(id, x, y, option, text));
} else {
this.buttons.add(new SliderWidget(id, x, y, option, text, this.options.getFloatValue(option)));
this.buttons.add(new SliderButton(id, x, y, option, text, this.options.getProgressValue(option)));
}

++index;
}

this.buttons.add(new ButtonWidget(200, this.width / 2 - 100, this.height / 6 + 168, ts.translate("gui.done")));
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168, ts.get("gui.done")));
}

@Override
protected void buttonClicked(ButtonWidget button) {
protected void buttonClicked(Button button) {
if (!button.active) {
return;
}

if (button.id < 100 && button instanceof OptionButtonWidget opButton) {
this.options.setIntOption(opButton.getOption(), 1);
button.text = this.options.getTranslatedValue(Option.getById(button.id));
if (button.id < 100 && button instanceof OptionButton opButton) {
this.options.toggle(opButton.getOption(), 1);
button.message = this.options.getMessage(Option.getItem(button.id));
}

if (button.id == 200) {
this.client.options.saveOptions();
this.client.openScreen(this.prevScreen);
this.minecraft.options.save();
this.minecraft.setScreen(this.prevScreen);
}
}

@Override
public void render(int mouseX, int mouseY, float var3) {
TranslationStorage ts = TranslationStorage.getInstance();
I18n ts = I18n.getInstance();

this.renderBackground();
this.drawTextWithShadowCentred(this.textRenderer, ts.translate(this.title), this.width / 2, 20, 16777215);
this.drawCenteredString(this.font, ts.get(this.title), this.width / 2, 20, 16777215);

super.render(mouseX, mouseY, var3);

Expand All @@ -101,7 +99,7 @@ public static <S extends Screen & OptionTooltipProvider> void renderTooltip(S sc

int xEnd = x + 150 + 150;
int yEnd = y + 84 + 10;
ButtonWidget button = getSelectedButton(screen.buttons, mouseX, mouseY);
Button button = getSelectedButton(screen.buttons, mouseX, mouseY);
if (button == null) {
return;
}
Expand All @@ -115,12 +113,12 @@ public static <S extends Screen & OptionTooltipProvider> void renderTooltip(S sc

for (int lineIndex = 0; lineIndex < tooltipLines.size(); ++lineIndex) {
String line = tooltipLines.get(lineIndex);
screen.textRenderer.drawTextWithShadow(line, x + 5, y + 5 + lineIndex * 11, 14540253);
screen.font.drawShadow(line, x + 5, y + 5 + lineIndex * 11, 14540253);
}
}

public static ButtonWidget getSelectedButton(List<ButtonWidget> buttons, int x, int y) {
for (ButtonWidget button : buttons) {
public static Button getSelectedButton(List<Button> buttons, int x, int y) {
for (Button button : buttons) {
boolean hit = x >= button.x &&
y >= button.y &&
x < button.x + button.width &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package dev.adventurecraft.awakening.client.gui;

import dev.adventurecraft.awakening.client.options.OptionOF;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.options.GameOptions;
import net.minecraft.client.options.Option;
import net.minecraft.client.Option;
import net.minecraft.client.Options;
import net.minecraft.client.gui.screens.Screen;

public class GuiDetailSettingsOF extends GuiBaseSettingsOF {

public GuiDetailSettingsOF(Screen prevScreen, GameOptions options) {
public GuiDetailSettingsOF(Screen prevScreen, Options options) {
super(prevScreen, options, "options.of.detailsTitle");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package dev.adventurecraft.awakening.client.gui;

import dev.adventurecraft.awakening.client.options.OptionOF;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.options.GameOptions;
import net.minecraft.client.options.Option;
import net.minecraft.client.Option;
import net.minecraft.client.Options;
import net.minecraft.client.gui.screens.Screen;

public class GuiOtherSettingsOF extends GuiBaseSettingsOF {

public GuiOtherSettingsOF(Screen prevScreen, GameOptions options) {
public GuiOtherSettingsOF(Screen prevScreen, Options options) {
super(prevScreen, options, "options.of.otherTitle");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package dev.adventurecraft.awakening.client.gui;

import dev.adventurecraft.awakening.client.options.OptionOF;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.options.GameOptions;
import net.minecraft.client.options.Option;
import net.minecraft.client.Option;
import net.minecraft.client.Options;
import net.minecraft.client.gui.screens.Screen;

public class GuiTextureSettingsOF extends GuiBaseSettingsOF {

public GuiTextureSettingsOF(Screen prevScreen, GameOptions options) {
public GuiTextureSettingsOF(Screen prevScreen, Options options) {
super(prevScreen, options, "options.of.texturesTitle");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package dev.adventurecraft.awakening.client.gui;

import dev.adventurecraft.awakening.client.options.OptionOF;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.options.GameOptions;
import net.minecraft.client.options.Option;
import net.minecraft.client.Option;
import net.minecraft.client.Options;
import net.minecraft.client.gui.screens.Screen;

public class GuiWorldSettingsOF extends GuiBaseSettingsOF {

public GuiWorldSettingsOF(Screen prevScreen, GameOptions options) {
public GuiWorldSettingsOF(Screen prevScreen, Options options) {
super(prevScreen, options, "options.of.worldTitle");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
package dev.adventurecraft.awakening.client.gui;

import dev.adventurecraft.awakening.ACMod;
import net.minecraft.client.gui.GuiElement;
import net.minecraft.client.gui.widgets.OptionButtonWidget;
import net.minecraft.client.gui.widgets.SliderWidget;
import net.minecraft.client.options.Option;
import net.minecraft.client.resource.language.TranslationStorage;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.minecraft.client.Option;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.components.OptionButton;
import net.minecraft.client.gui.components.SliderButton;
import net.minecraft.locale.I18n;

public interface OptionTooltipProvider {

Pattern QUOTE_PATTERN = Pattern.compile("(\")(?:\\\\.|[^\\\\])*?\\1");

Option[] getOptions();

default List<String> getTooltipLines(GuiElement element) {
TranslationStorage ts = TranslationStorage.getInstance();
if (element instanceof OptionButtonWidget button) {
default List<String> getTooltipLines(GuiComponent element) {
I18n ts = I18n.getInstance();
if (element instanceof OptionButton button) {
Option option = button.getOption();
String value = ts.translate(option.getTranslationKey() + ".tooltip");
String value = ts.get(option.getCaptionId() + ".tooltip");
return parseOptionTooltip(value);
}
if (element instanceof SliderWidget slider) {
if (element instanceof SliderButton slider) {
Option option = slider.option;
String value = ts.translate(option.getTranslationKey() + ".tooltip");
String value = ts.get(option.getCaptionId() + ".tooltip");
return parseOptionTooltip(value);
}
return null;
Expand Down
Loading

0 comments on commit 38b3636

Please sign in to comment.