From d187facbdd47eca0afa5d91b9ed559b2c6b9863e Mon Sep 17 00:00:00 2001 From: lantice3720 <65650884+lantice3720@users.noreply.github.com> Date: Sun, 7 May 2023 15:03:23 +0900 Subject: REI Integration. Needed to add recipe identifier. Small change in itemlist. --- build.gradle | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'build.gradle') diff --git a/build.gradle b/build.gradle index dc1b09be..c0ba2b6a 100644 --- a/build.gradle +++ b/build.gradle @@ -50,6 +50,10 @@ dependencies { // Mod Menu modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}" + // REI + modImplementation "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" + modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" + // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" @@ -113,7 +117,8 @@ modrinth { versionType = "release" dependencies = [ // Yet another array. Create a new `ModDependency` or `VersionDependency` with two strings - the ID and the scope new ModDependency("P7dR8mSH", "required"), // Creates a new required dependency on Fabric API - new ModDependency("mOgUt4GM", "optional") // modmenu + new ModDependency("mOgUt4GM", "optional"), // modmenu + new ModDependency("nfn13YXA", "optional") // REI ] changelog = System.getenv('CHANGELOG') } -- cgit From 506a4b1e80a16846b5404d1ae47a23afcf6b784e Mon Sep 17 00:00:00 2001 From: lantice3720 <65650884+lantice3720@users.noreply.github.com> Date: Thu, 18 May 2023 01:25:41 +0900 Subject: Added crafting requirement text, fixed dependency --- build.gradle | 2 +- .../skyblock/itemlist/SearchResultsWidget.java | 2 +- .../skyblock/itemlist/SkyblockCraftingRecipe.java | 8 ++- .../skyblocker/skyblock/rei/SkyblockCategory.java | 57 ++++++++++++++++++++++ .../skyblock/rei/SkyblockCraftingDisplay.java | 35 ++++++++++--- .../rei/SkyblockCraftingDisplayGenerator.java | 2 +- .../skyblock/rei/SkyblockerREIClientPlugin.java | 5 -- 7 files changed, 94 insertions(+), 17 deletions(-) (limited to 'build.gradle') diff --git a/build.gradle b/build.gradle index c0ba2b6a..5ee08867 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ dependencies { modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}" // REI - modImplementation "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" + modCompileOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}" modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" // Fabric API. This is technically optional, but you probably want it anyway. diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/SearchResultsWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/SearchResultsWidget.java index 63ccbd52..ce53112b 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/SearchResultsWidget.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/SearchResultsWidget.java @@ -109,7 +109,7 @@ public class SearchResultsWidget implements Drawable { public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { RenderSystem.disableDepthTest(); if (this.displayRecipes) { - String craftText = this.recipeResults.get(this.currentPage).text; + String craftText = this.recipeResults.get(this.currentPage).craftText; this.client.textRenderer.drawWithShadow(matrices, craftText, this.parentX + 11, this.parentY + 31, 0xffffffff); Text resultText = this.recipeResults.get(this.currentPage).result.getName(); this.client.textRenderer.drawWithShadow(matrices, resultText, this.parentX + 11, this.parentY + 43, 0xffffffff); diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/SkyblockCraftingRecipe.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/SkyblockCraftingRecipe.java index 56e5c041..29aed7a1 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/SkyblockCraftingRecipe.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/SkyblockCraftingRecipe.java @@ -11,13 +11,13 @@ import java.util.List; public class SkyblockCraftingRecipe { private static final Logger LOGGER = LoggerFactory.getLogger(SkyblockCraftingRecipe.class); - String text = ""; + String craftText = ""; final List grid = new ArrayList<>(9); ItemStack result; public static SkyblockCraftingRecipe fromJsonObject(JsonObject jsonObj) { SkyblockCraftingRecipe recipe = new SkyblockCraftingRecipe(); - if (jsonObj.has("crafttext")) recipe.text = jsonObj.get("crafttext").getAsString(); + if (jsonObj.has("crafttext")) recipe.craftText = jsonObj.get("crafttext").getAsString(); recipe.grid.add(getItemStack(jsonObj.getAsJsonObject("recipe").get("A1").getAsString())); recipe.grid.add(getItemStack(jsonObj.getAsJsonObject("recipe").get("A2").getAsString())); recipe.grid.add(getItemStack(jsonObj.getAsJsonObject("recipe").get("A3").getAsString())); @@ -53,4 +53,8 @@ public class SkyblockCraftingRecipe { public ItemStack getResult() { return result; } + + public String getCraftText() { + return craftText; + } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCategory.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCategory.java index 737adfa8..a52abeaa 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCategory.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCategory.java @@ -1,15 +1,27 @@ package me.xmrvizzy.skyblocker.skyblock.rei; +import com.google.common.collect.Lists; import com.mojang.brigadier.exceptions.CommandSyntaxException; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Label; +import me.shedaniel.rei.api.client.gui.widgets.Slot; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.util.EntryStacks; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import net.minecraft.client.MinecraftClient; import net.minecraft.item.ItemStack; import net.minecraft.nbt.StringNbtReader; import net.minecraft.text.Text; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.Locale; /** @@ -39,4 +51,49 @@ public class SkyblockCategory implements DisplayCategory setupDisplay(SkyblockCraftingDisplay display, Rectangle bounds) { + List out = new ArrayList<>(); + out.add(Widgets.createRecipeBase(bounds)); + + Point startPoint; + if (!display.getCraftText().isEmpty() && display.getCraftText() != null) { + startPoint = new Point(bounds.getCenterX() - 58, bounds.getCenterY() - 31); + } + else { + startPoint = new Point(bounds.getCenterX() - 58, bounds.getCenterY() - 26); + } + Point resultPoint = new Point(startPoint.x + 95, startPoint.y + 19); + out.add(Widgets.createArrow(new Point(startPoint.x + 60, startPoint.y + 18))); + out.add(Widgets.createResultSlotBackground(resultPoint)); + + // Generate Slots + List input = display.getInputEntries(); + List slots = Lists.newArrayList(); + for (int y = 0; y < 3; y++) + for (int x = 0; x < 3; x++) + slots.add(Widgets.createSlot(new Point(startPoint.x + 1 + x * 18, startPoint.y + 1 + y * 18)).markInput()); + for (int i = 0; i < input.size(); i++) { + slots.get(i).entries(input.get(i)).markInput(); + } + out.addAll(slots); + out.add(Widgets.createSlot(resultPoint).entries(display.getOutputEntries().get(0)).disableBackground().markOutput()); + + // Add craftingText Label + Label craftTextLabel = Widgets.createLabel(new Point(bounds.getCenterX(), startPoint.y + 55), Text.of(display.getCraftText())); + out.add(craftTextLabel); + return out; + } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCraftingDisplay.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCraftingDisplay.java index aee78990..5820780c 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCraftingDisplay.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCraftingDisplay.java @@ -1,18 +1,39 @@ package me.xmrvizzy.skyblocker.skyblock.rei; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay; +import me.shedaniel.rei.api.common.display.basic.BasicDisplay; import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomDisplay; -import net.minecraft.recipe.Recipe; -import org.jetbrains.annotations.Nullable; import java.util.List; /** * Skyblock Crafting Recipe display class for REI */ -public class SkyblockCraftingDisplay extends DefaultCustomDisplay { - public SkyblockCraftingDisplay(@Nullable Recipe possibleRecipe, List input, List output) { - super(possibleRecipe, input, output); +public class SkyblockCraftingDisplay extends BasicDisplay implements SimpleGridMenuDisplay { + + private final String craftText; + public SkyblockCraftingDisplay(List input, List output, String craftText) { + super(input, output); + this.craftText = craftText; + } + public String getCraftText() { + return craftText; + } + + @Override + public int getWidth() { + return 3; + } + + @Override + public int getHeight() { + return 3; + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return SkyblockerREIClientPlugin.SKYBLOCK; } -} +} \ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCraftingDisplayGenerator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCraftingDisplayGenerator.java index 7d10f202..fd3f56ee 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCraftingDisplayGenerator.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockCraftingDisplayGenerator.java @@ -60,7 +60,7 @@ public class SkyblockCraftingDisplayGenerator implements DynamicDisplayGenerator } outputs.add(EntryIngredient.of(EntryStacks.of(recipe.getResult()))); - displays.add(new SkyblockCraftingDisplay(null, inputs, outputs)); + displays.add(new SkyblockCraftingDisplay(inputs, outputs, recipe.getCraftText())); } return displays; } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockerREIClientPlugin.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockerREIClientPlugin.java index fee71765..9d428a24 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockerREIClientPlugin.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rei/SkyblockerREIClientPlugin.java @@ -29,12 +29,7 @@ public class SkyblockerREIClientPlugin implements REIClientPlugin { @Override public void registerDisplays(DisplayRegistry displayRegistry) { - - ViewSearchBuilder builder = ViewSearchBuilder.builder(); - builder.addCategory(SKYBLOCK); - displayRegistry.registerDisplayGenerator(SKYBLOCK, new SkyblockCraftingDisplayGenerator()); - } @Override -- cgit From 66387b1fe7dbdf4a0c3e82e53e59a5c24cce6075 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Tue, 30 May 2023 20:46:58 -0400 Subject: Update Loom and Gradle (#163) --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.jar | Bin 61608 -> 62076 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 7 +- gradlew.bat | 184 +++++++++++++++---------------- 5 files changed, 98 insertions(+), 97 deletions(-) (limited to 'build.gradle') diff --git a/build.gradle b/build.gradle index 5ee08867..4d2dc8ef 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.1-SNAPSHOT' + id 'fabric-loom' version '1.2-SNAPSHOT' id 'maven-publish' id 'com.modrinth.minotaur' version '2.+' } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index ccebba77..c1962a79 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bdc9a83b..37aef8d3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 79a61d42..aeb74cbb 100755 --- a/gradlew +++ b/gradlew @@ -85,9 +85,6 @@ done APP_BASE_NAME=${0##*/} APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f..6689b85b 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,92 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega -- cgit From 027426aacac048b85cd310e9e3d4101e0156a917 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Mon, 22 May 2023 20:30:12 -0400 Subject: Add Fairy Souls Helper --- build.gradle | 3 + gradle.properties | 2 + .../java/me/xmrvizzy/skyblocker/SkyblockerMod.java | 22 +-- .../skyblocker/config/SkyblockerConfig.java | 8 + .../accessor/BeaconBlockEntityRendererInvoker.java | 16 ++ .../xmrvizzy/skyblocker/skyblock/FairySouls.java | 184 +++++++++++++++++++++ .../skyblocker/skyblock/api/RepositoryUpdate.java | 62 ------- .../skyblocker/skyblock/dungeon/LividColor.java | 3 +- .../skyblocker/skyblock/itemlist/ItemRegistry.java | 75 ++------- .../skyblock/itemlist/ItemStackBuilder.java | 5 +- .../java/me/xmrvizzy/skyblocker/utils/NEURepo.java | 90 ++++++++++ .../me/xmrvizzy/skyblocker/utils/RenderHelper.java | 30 ++++ .../java/me/xmrvizzy/skyblocker/utils/Utils.java | 91 +++++++++- .../resources/assets/skyblocker/lang/en_us.json | 6 +- 14 files changed, 454 insertions(+), 143 deletions(-) create mode 100644 src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/BeaconBlockEntityRendererInvoker.java create mode 100644 src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java delete mode 100644 src/main/java/me/xmrvizzy/skyblocker/skyblock/api/RepositoryUpdate.java create mode 100644 src/main/java/me/xmrvizzy/skyblocker/utils/NEURepo.java create mode 100644 src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java (limited to 'build.gradle') diff --git a/build.gradle b/build.gradle index 4d2dc8ef..83da3489 100644 --- a/build.gradle +++ b/build.gradle @@ -60,6 +60,9 @@ dependencies { // https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit used pull data from the NEU item repo include(implementation("org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r")) + // Renderer (https://github.com/0x3C50/Renderer) + include modImplementation("com.github.0x3C50:Renderer:${project.renderer_version}") + include(modImplementation ("meteordevelopment:discord-ipc:1.1")) } diff --git a/gradle.properties b/gradle.properties index 14a4fffc..d90dc6f2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,8 @@ clothconfig_version=11.0.99 mod_menu_version=7.0.1 ## REI (https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items/files) rei_version=12.0.625 +## Renderer (https://github.com/0x3C50/Renderer) +renderer_version = master-SNAPSHOT # Mod Properties mod_version = 1.10.0 diff --git a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java index 189ecca3..04ab384f 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java +++ b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java @@ -1,14 +1,12 @@ package me.xmrvizzy.skyblocker; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import me.xmrvizzy.skyblocker.chat.ChatMessageListener; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import me.xmrvizzy.skyblocker.discord.DiscordRPCManager; import me.xmrvizzy.skyblocker.gui.ContainerSolverManager; -import me.xmrvizzy.skyblocker.skyblock.BackpackPreview; -import me.xmrvizzy.skyblocker.skyblock.FishingHelper; -import me.xmrvizzy.skyblocker.skyblock.HotbarSlotLock; -import me.xmrvizzy.skyblocker.skyblock.StatusBarTracker; -import me.xmrvizzy.skyblocker.skyblock.api.RepositoryUpdate; +import me.xmrvizzy.skyblocker.skyblock.*; import me.xmrvizzy.skyblocker.skyblock.api.StatsCommand; import me.xmrvizzy.skyblocker.skyblock.dungeon.DungeonBlaze; import me.xmrvizzy.skyblocker.skyblock.dungeon.DungeonMap; @@ -20,14 +18,14 @@ import me.xmrvizzy.skyblocker.skyblock.itemlist.ItemRegistry; import me.xmrvizzy.skyblocker.skyblock.quicknav.QuickNav; import me.xmrvizzy.skyblocker.skyblock.tabhud.TabHud; import me.xmrvizzy.skyblocker.skyblock.tabhud.util.PlayerListMgr; -import me.xmrvizzy.skyblocker.utils.MessageScheduler; -import me.xmrvizzy.skyblocker.utils.Scheduler; -import me.xmrvizzy.skyblocker.utils.UpdateChecker; -import me.xmrvizzy.skyblocker.utils.Utils; +import me.xmrvizzy.skyblocker.utils.*; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; +import java.nio.file.Path; + /** * Main class for Skyblocker which initializes features, registers events, and * manages ticks. This class will be instantiated by Fabric. Do not instantiate @@ -35,6 +33,8 @@ import net.minecraft.client.MinecraftClient; */ public class SkyblockerMod implements ClientModInitializer { public static final String NAMESPACE = "skyblocker"; + public static final Path CONFIG_DIR = FabricLoader.getInstance().getConfigDir().resolve(NAMESPACE); + public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); private static SkyblockerMod INSTANCE; @SuppressWarnings("deprecation") @@ -63,12 +63,13 @@ public class SkyblockerMod implements ClientModInitializer { @Override public void onInitializeClient() { ClientTickEvents.END_CLIENT_TICK.register(this::tick); + Utils.init(); HotbarSlotLock.init(); SkyblockerConfig.init(); PriceInfoTooltip.init(); WikiLookup.init(); ItemRegistry.init(); - RepositoryUpdate.init(); + NEURepo.init(); BackpackPreview.init(); QuickNav.init(); StatsCommand.init(); @@ -78,6 +79,7 @@ public class SkyblockerMod implements ClientModInitializer { DiscordRPCManager.init(); LividColor.init(); FishingHelper.init(); + FairySouls.init(); TabHud.init(); containerSolverManager.init(); DungeonMap.init(); diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java index b1bc2001..f296e487 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java @@ -150,6 +150,10 @@ public class SkyblockerConfig implements ConfigData { @ConfigEntry.Gui.CollapsibleObject() public Fishing fishing = new Fishing(); + @ConfigEntry.Category("fairySouls") + @ConfigEntry.Gui.CollapsibleObject() + public FairySouls fairySouls = new FairySouls(); + @ConfigEntry.Category("itemList") @ConfigEntry.Gui.CollapsibleObject() public ItemList itemList = new ItemList(); @@ -219,6 +223,10 @@ public class SkyblockerConfig implements ConfigData { public boolean enableFishingHelper = true; } + public static class FairySouls { + public boolean enableFairySouls = true; + } + public static class Hitbox { public boolean oldFarmlandHitbox = true; public boolean oldLeverHitbox = false; diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/BeaconBlockEntityRendererInvoker.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/BeaconBlockEntityRendererInvoker.java new file mode 100644 index 00000000..ff7c7cbc --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/BeaconBlockEntityRendererInvoker.java @@ -0,0 +1,16 @@ +package me.xmrvizzy.skyblocker.mixin.accessor; + +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer; +import net.minecraft.client.util.math.MatrixStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(BeaconBlockEntityRenderer.class) +public interface BeaconBlockEntityRendererInvoker { + @SuppressWarnings("unused") + @Invoker("renderBeam") + static void renderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float tickDelta, long worldTime, int yOffset, int maxY, float[] color) { + throw new IllegalStateException("Mixin invoker failed to apply."); + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java new file mode 100644 index 00000000..4480c5e1 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java @@ -0,0 +1,184 @@ +package me.xmrvizzy.skyblocker.skyblock; + +import com.google.common.collect.ImmutableSet; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import me.xmrvizzy.skyblocker.SkyblockerMod; +import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import me.xmrvizzy.skyblocker.utils.NEURepo; +import me.xmrvizzy.skyblocker.utils.RenderHelper; +import me.xmrvizzy.skyblocker.utils.Utils; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; +import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.text.Text; +import net.minecraft.util.DyeColor; +import net.minecraft.util.math.BlockPos; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; +import java.util.*; +import java.util.concurrent.CompletableFuture; + +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; + +public class FairySouls { + private static final Logger LOGGER = LoggerFactory.getLogger(FairySouls.class); + private static CompletableFuture fairySoulsLoaded; + private static final Map> fairySouls = new HashMap<>(); + private static final Map>> foundFairies = new HashMap<>(); + + public static void init() { + fairySoulsLoaded = NEURepo.runAsyncAfterLoad(() -> { + try { + BufferedReader reader = new BufferedReader(new FileReader(NEURepo.LOCAL_REPO_DIR.resolve("constants").resolve("fairy_souls.json").toFile())); + for (Map.Entry fairySoulJson : JsonParser.parseReader(reader).getAsJsonObject().asMap().entrySet()) { + if (fairySoulJson.getKey().equals("//") || fairySoulJson.getKey().equals("Max Souls")) { + continue; + } + ImmutableSet.Builder fairySoulsForLocation = ImmutableSet.builder(); + for (JsonElement fairySoul : fairySoulJson.getValue().getAsJsonArray().asList()) { + fairySoulsForLocation.add(parseBlockPos(fairySoul)); + } + fairySouls.put(fairySoulJson.getKey(), fairySoulsForLocation.build()); + } + reader = new BufferedReader(new FileReader(SkyblockerMod.CONFIG_DIR.resolve("found_fairy_souls.json").toFile())); + for (Map.Entry foundFairiesForProfileJson : JsonParser.parseReader(reader).getAsJsonObject().asMap().entrySet()) { + Map> foundFairiesForProfile = new HashMap<>(); + for (Map.Entry foundFairiesForLocationJson : foundFairiesForProfileJson.getValue().getAsJsonObject().asMap().entrySet()) { + Set foundFairiesForLocation = new HashSet<>(); + for (JsonElement foundFairy : foundFairiesForLocationJson.getValue().getAsJsonArray().asList()) { + foundFairiesForLocation.add(parseBlockPos(foundFairy)); + } + foundFairiesForProfile.put(foundFairiesForLocationJson.getKey(), foundFairiesForLocation); + } + foundFairies.put(foundFairiesForProfileJson.getKey(), foundFairiesForProfile); + } + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + LOGGER.error("Failed to load found fairy souls."); + } catch (Exception e) { + e.printStackTrace(); + } + }); + ClientLifecycleEvents.CLIENT_STOPPING.register(FairySouls::saveFoundFairySouls); + WorldRenderEvents.AFTER_TRANSLUCENT.register(FairySouls::render); + ClientReceiveMessageEvents.GAME.register(FairySouls::onChatMessage); + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE) + .then(literal("fairySouls") + .then(literal("markAllInCurrentIslandFound").executes(context -> { + FairySouls.markAllFairiesFound(); + context.getSource().sendFeedback(Text.translatable("skyblocker.fairySouls.markAllFound")); + return 1; + })) + .then(literal("markAllInCurrentIslandMissing").executes(context -> { + FairySouls.markAllFairiesNotFound(); + context.getSource().sendFeedback(Text.translatable("skyblocker.fairySouls.markAllMissing")); + return 1; + }))))); + } + + private static BlockPos parseBlockPos(JsonElement posJson) { + String[] posArray = posJson.getAsString().split(","); + return new BlockPos(Integer.parseInt(posArray[0]), Integer.parseInt(posArray[1]), Integer.parseInt(posArray[2])); + } + + public static void saveFoundFairySouls(MinecraftClient client) { + try { + BufferedWriter writer = new BufferedWriter(new FileWriter(SkyblockerMod.CONFIG_DIR.resolve("found_fairy_souls.json").toFile())); + JsonObject foundFairiesJson = new JsonObject(); + for (Map.Entry>> foundFairiesForProfile : foundFairies.entrySet()) { + JsonObject foundFairiesForProfileJson = new JsonObject(); + for (Map.Entry> foundFairiesForLocation : foundFairiesForProfile.getValue().entrySet()) { + JsonArray foundFairiesForLocationJson = new JsonArray(); + for (BlockPos foundFairy : foundFairiesForLocation.getValue()) { + foundFairiesForLocationJson.add(foundFairy.getX() + "," + foundFairy.getY() + "," + foundFairy.getZ()); + } + foundFairiesForProfileJson.add(foundFairiesForLocation.getKey(), foundFairiesForLocationJson); + } + foundFairiesJson.add(foundFairiesForProfile.getKey(), foundFairiesForProfileJson); + } + SkyblockerMod.GSON.toJson(foundFairiesJson, writer); + writer.close(); + } catch (IOException e) { + LOGGER.error("Failed to write found fairy souls to file."); + } + } + + public static void render(WorldRenderContext context) { + if (!SkyblockerConfig.get().general.fairySouls.enableFairySouls) { + return; + } + if (!fairySoulsLoaded.isDone()) { + LOGGER.warn("Fairy souls are not loaded yet."); + return; + } + if (!fairySouls.containsKey(Utils.getLocationRaw())) { + return; + } + for (BlockPos fairySoul : fairySouls.get(Utils.getLocationRaw())) { + float[] colorComponents = isFairySoulNotFound(fairySoul) ? DyeColor.GREEN.getColorComponents() : DyeColor.RED.getColorComponents(); + RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, fairySoul, colorComponents, 0.5F); + } + } + + private static boolean isFairySoulNotFound(BlockPos fairySoul) { + Map> foundFairiesForProfile = foundFairies.get(Utils.getProfile()); + if (foundFairiesForProfile == null) { + return true; + } + Set foundFairiesForProfileAndLocation = foundFairiesForProfile.get(Utils.getLocationRaw()); + if (foundFairiesForProfileAndLocation == null) { + return true; + } + return !foundFairiesForProfileAndLocation.contains(fairySoul); + } + + public static void onChatMessage(Text text, boolean overlay) { + String message = text.getString(); + if (message.equals("You have already found that Fairy Soul!") || message.equals("SOUL! You found a Fairy Soul!")) { + markClosestFairyFound(); + } + } + + private static void markClosestFairyFound() { + PlayerEntity player = MinecraftClient.getInstance().player; + if (player == null) { + LOGGER.warn("Failed to mark closest fairy soul as found because player is null."); + return; + } + fairySouls.get(Utils.getLocationRaw()).stream().filter(FairySouls::isFairySoulNotFound).min(Comparator.comparingDouble(fairySoul -> fairySoul.getSquaredDistance(player.getPos()))).ifPresent(fairySoul -> { + initializeFoundFairiesForCurrentProfileAndLocation(); + foundFairies.get(Utils.getProfile()).get(Utils.getLocationRaw()).add(fairySoul); + }); + } + + public static void markAllFairiesFound() { + initializeFoundFairiesForCurrentProfileAndLocation(); + foundFairies.get(Utils.getProfile()).get(Utils.getLocationRaw()).addAll(fairySouls.get(Utils.getLocationRaw())); + } + + public static void markAllFairiesNotFound() { + Map> foundFairiesForProfile = foundFairies.get(Utils.getProfile()); + if (foundFairiesForProfile != null) { + foundFairiesForProfile.remove(Utils.getLocationRaw()); + } + } + + private static void initializeFoundFairiesForCurrentProfileAndLocation() { + initializeFoundFairiesForProfileAndLocation(Utils.getProfile(), Utils.getLocationRaw()); + } + + private static void initializeFoundFairiesForProfileAndLocation(String profile, String location) { + foundFairies.computeIfAbsent(profile, profileKey -> new HashMap<>()); + foundFairies.get(profile).computeIfAbsent(location, locationKey -> new HashSet<>()); + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/api/RepositoryUpdate.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/api/RepositoryUpdate.java deleted file mode 100644 index e08cb1c0..00000000 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/api/RepositoryUpdate.java +++ /dev/null @@ -1,62 +0,0 @@ -package me.xmrvizzy.skyblocker.skyblock.api; - -import me.xmrvizzy.skyblocker.skyblock.itemlist.ItemRegistry; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; - -import java.io.File; -import java.nio.file.Files; -import java.util.concurrent.CompletableFuture; - -public class RepositoryUpdate { - public static final MinecraftClient client = MinecraftClient.getInstance(); - - /** - * Adds command to update repository manually from ingame. - *

- * TODO A button could be added to the settings menu that will trigger this command. - */ - public static void init(){ - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( - ClientCommandManager.literal("skyblocker") - .then(ClientCommandManager.literal("updaterepository") - .executes(context -> { - updateRepository(); - return 1; - }) - ) - ) - ); - - } - - public static void updateRepository() { - CompletableFuture.runAsync(() -> { - try { - ItemRegistry.filesImported = false; - File dir = ItemRegistry.LOCAL_ITEM_REPO_DIR.toFile(); - recursiveDelete(dir); - } catch (Exception ex) { - if (client.player != null) - client.player.sendMessage( - Text.translatable("skyblocker.updaterepository.failed") - , false - ); - return; - } - - ItemRegistry.init(); - }); - } - - private static void recursiveDelete(File dir) { - if (dir.isDirectory() && !Files.isSymbolicLink(dir.toPath())) { - for (File child : dir.listFiles()) { - recursiveDelete(child); - } - } - dir.delete(); - } -} diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/LividColor.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/LividColor.java index 276a41b6..4701c485 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/LividColor.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/LividColor.java @@ -11,11 +11,10 @@ public class LividColor { private static int tenTicks = 0; public static void init() { - ClientReceiveMessageEvents.ALLOW_GAME.register((message, overlay) -> { + ClientReceiveMessageEvents.GAME.register((message, overlay) -> { if (SkyblockerConfig.get().locations.dungeons.lividColor.enableLividColor && message.getString().equals("[BOSS] Livid: I respect you for making it to here, but I'll be your undoing.")) { tenTicks = 8; } - return true; }); } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemRegistry.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemRegistry.java index d9f3b473..13ca356a 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemRegistry.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemRegistry.java @@ -2,32 +2,23 @@ package me.xmrvizzy.skyblocker.skyblock.itemlist; import com.google.gson.JsonObject; import com.google.gson.JsonParser; - -import me.xmrvizzy.skyblocker.skyblock.api.RepositoryUpdate; -import net.fabricmc.loader.api.FabricLoader; +import me.xmrvizzy.skyblocker.utils.NEURepo; import net.minecraft.client.MinecraftClient; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.text.Text; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.PullResult; -import org.eclipse.jgit.errors.RepositoryNotFoundException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.*; -import java.util.concurrent.CompletableFuture; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class ItemRegistry { - private static final Logger LOGGER = LoggerFactory.getLogger(ItemRegistry.class); - protected static final String REMOTE_ITEM_REPO = "https://github.com/NotEnoughUpdates/NotEnoughUpdates-REPO"; - public static final Path LOCAL_ITEM_REPO_DIR = FabricLoader.getInstance().getConfigDir().resolve("skyblocker/item-repo"); - - protected static final Path ITEM_LIST_DIR = LOCAL_ITEM_REPO_DIR.resolve("items"); + protected static final Path ITEM_LIST_DIR = NEURepo.LOCAL_REPO_DIR.resolve("items"); protected static final List items = new ArrayList<>(); protected static final Map itemsMap = new HashMap<>(); @@ -36,52 +27,8 @@ public class ItemRegistry { public static boolean filesImported = false; public static void init() { - CompletableFuture.runAsync(ItemRegistry::updateItemRepo) - .whenComplete((result, ex) -> { - if (ex == null) { - ItemStackBuilder.init(); - importItemFiles(); - } - else { - LOGGER.error("[Skyblocker-ItemRegistry] " + ex); - } - }); - } - - private static void updateItemRepo() { - Git git; - if (!Files.isDirectory(LOCAL_ITEM_REPO_DIR)) { - try { - git = Git.cloneRepository() - .setURI(REMOTE_ITEM_REPO) - .setDirectory(LOCAL_ITEM_REPO_DIR.toFile()) - .setBranchesToClone(List.of("refs/heads/master")) - .setBranch("refs/heads/master") - .call(); - git.close(); - LOGGER.info("[Skyblocker Repository Update] Repository updated."); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - try { - git = Git.open(LOCAL_ITEM_REPO_DIR.toFile()); - PullResult pull = git.pull().setRebase(true).call(); - git.close(); - - if (pull.getRebaseResult() == null) { - LOGGER.info("[Skyblocker Repository Update] No update result"); - } else if (pull.getRebaseResult().getStatus().isSuccessful()) { - LOGGER.info("[Skyblocker Repository Update] Status: " + pull.getRebaseResult().getStatus().name()); - } else if (!pull.getRebaseResult().getStatus().isSuccessful()) { - LOGGER.warn("[Skyblocker Repository Update] Status: " + pull.getRebaseResult().getStatus().name()); - } - } catch (RepositoryNotFoundException e) { - RepositoryUpdate.updateRepository(); - } catch (Exception e) { - e.printStackTrace(); - } - } + NEURepo.runAsyncAfterLoad(ItemStackBuilder::loadPetNums); + NEURepo.runAsyncAfterLoad(ItemRegistry::importItemFiles); } private static void importItemFiles() { @@ -119,8 +66,7 @@ public class ItemRegistry { if (lhsFamilyName.equals(rhsFamilyName)) { if (lhsInternalName.length() != rhsInternalName.length()) return lhsInternalName.length() - rhsInternalName.length(); - else - return lhsInternalName.compareTo(rhsInternalName); + else return lhsInternalName.compareTo(rhsInternalName); } return lhsFamilyName.compareTo(rhsFamilyName); }); @@ -147,8 +93,7 @@ public class ItemRegistry { public static List getRecipes(String internalName) { List result = new ArrayList<>(); for (SkyblockCraftingRecipe recipe : recipes) - if (getInternalName(recipe.result).equals(internalName)) - result.add(recipe); + if (getInternalName(recipe.result).equals(internalName)) result.add(recipe); for (SkyblockCraftingRecipe recipe : recipes) for (ItemStack ingredient : recipe.grid) if (!ingredient.getItem().equals(Items.AIR) && getInternalName(ingredient).equals(internalName)) { diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemStackBuilder.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemStackBuilder.java index b2d909a8..d420d54f 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemStackBuilder.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemStackBuilder.java @@ -4,6 +4,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import me.xmrvizzy.skyblocker.utils.NEURepo; import net.minecraft.item.ItemStack; import net.minecraft.nbt.*; import net.minecraft.text.Text; @@ -16,10 +17,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class ItemStackBuilder { - private final static Path PETNUMS_PATH = ItemRegistry.LOCAL_ITEM_REPO_DIR.resolve("constants/petnums.json"); + private final static Path PETNUMS_PATH = NEURepo.LOCAL_REPO_DIR.resolve("constants/petnums.json"); private static JsonObject petNums; - public static void init() { + public static void loadPetNums() { try { petNums = JsonParser.parseString(Files.readString(PETNUMS_PATH)).getAsJsonObject(); } catch (Exception e) { diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/NEURepo.java b/src/main/java/me/xmrvizzy/skyblocker/utils/NEURepo.java new file mode 100644 index 00000000..027cfa7a --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/NEURepo.java @@ -0,0 +1,90 @@ +package me.xmrvizzy.skyblocker.utils; + +import me.xmrvizzy.skyblocker.SkyblockerMod; +import me.xmrvizzy.skyblocker.skyblock.itemlist.ItemRegistry; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.Text; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.errors.RepositoryNotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class NEURepo { + private static final Logger LOGGER = LoggerFactory.getLogger(NEURepo.class); + public static final String REMOTE_REPO_URL = "https://github.com/NotEnoughUpdates/NotEnoughUpdates-REPO.git"; + public static final Path LOCAL_REPO_DIR = SkyblockerMod.CONFIG_DIR.resolve("item-repo"); + private static final CompletableFuture REPO_INITIALIZED = initRepository(); + + /** + * Adds command to update repository manually from ingame. + *

+ * TODO A button could be added to the settings menu that will trigger this command. + */ + public static void init() { + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> + dispatcher.register(ClientCommandManager.literal(SkyblockerMod.NAMESPACE) + .then(ClientCommandManager.literal("updaterepository").executes(context -> { + deleteAndDownloadRepository(); + return 1; + })))); + } + + public static CompletableFuture initRepository() { + return CompletableFuture.runAsync(() -> { + try { + if (Files.isDirectory(NEURepo.LOCAL_REPO_DIR)) { + try (Git localRepo = Git.open(NEURepo.LOCAL_REPO_DIR.toFile())) { + localRepo.pull().setRebase(true).call(); + LOGGER.info("[Skyblocker] NEU Repository Updated"); + } + } else { + Git.cloneRepository().setURI(REMOTE_REPO_URL).setDirectory(NEURepo.LOCAL_REPO_DIR.toFile()).setBranchesToClone(List.of("refs/heads/master")).setBranch("refs/heads/master").call().close(); + LOGGER.info("[Skyblocker] NEU Repository Downloaded"); + } + } catch (RepositoryNotFoundException e) { + LOGGER.warn("Local NEU Repository not found or corrupted, downloading new one", e); + deleteAndDownloadRepository(); + } catch (Exception e) { + LOGGER.error("Encountered unknown exception while initializing NEU Repository", e); + } + }); + } + + public static void deleteAndDownloadRepository() { + CompletableFuture.runAsync(() -> { + try { + ItemRegistry.filesImported = false; + File dir = NEURepo.LOCAL_REPO_DIR.toFile(); + recursiveDelete(dir); + } catch (Exception ex) { + if (MinecraftClient.getInstance().player != null) + MinecraftClient.getInstance().player.sendMessage(Text.translatable("skyblocker.updaterepository.failed"), false); + return; + } + initRepository(); + }); + } + + @SuppressWarnings("ResultOfMethodCallIgnored") + private static void recursiveDelete(File dir) { + File[] children; + if (dir.isDirectory() && !Files.isSymbolicLink(dir.toPath()) && (children = dir.listFiles()) != null) { + for (File child : children) { + recursiveDelete(child); + } + } + dir.delete(); + } + + public static CompletableFuture runAsyncAfterLoad(Runnable runnable) { + return REPO_INITIALIZED.thenRunAsync(runnable); + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java new file mode 100644 index 00000000..79308dc3 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java @@ -0,0 +1,30 @@ +package me.xmrvizzy.skyblocker.utils; + +import me.x150.renderer.render.Renderer3d; +import me.xmrvizzy.skyblocker.mixin.accessor.BeaconBlockEntityRendererInvoker; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +import java.awt.*; + +public class RenderHelper { + public static void renderFilledThroughWallsWithBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { + renderFilledThroughWalls(context, pos, colorComponents, alpha); + renderBeaconBeam(context, pos, colorComponents); + } + + public static void renderFilledThroughWalls(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { + Renderer3d.renderThroughWalls(); + Renderer3d.renderFilled(context.matrixStack(), new Color(colorComponents[0], colorComponents[1], colorComponents[2], alpha), Vec3d.of(pos), new Vec3d(1, 1, 1)); + Renderer3d.stopRenderThroughWalls(); + } + + public static void renderBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents) { + context.matrixStack().push(); + context.matrixStack().translate(pos.getX() - context.camera().getPos().x, pos.getY() - context.camera().getPos().y, pos.getZ() - context.camera().getPos().z); + BeaconBlockEntityRendererInvoker.renderBeam(context.matrixStack(), context.consumers(), context.tickDelta(), context.world().getTime(), 0, BeaconBlockEntityRenderer.MAX_BEAM_HEIGHT, colorComponents); + context.matrixStack().pop(); + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java index a4e403fc..40c96660 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java @@ -1,13 +1,21 @@ package me.xmrvizzy.skyblocker.utils; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import me.xmrvizzy.skyblocker.SkyblockerMod; import me.xmrvizzy.skyblocker.skyblock.item.PriceInfoTooltip; import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; +import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.networking.v1.PacketSender; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; +import net.minecraft.text.Text; import net.minecraft.util.Formatting; import java.util.ArrayList; @@ -21,6 +29,14 @@ public class Utils { private static boolean isOnSkyblock = false; private static boolean isInDungeons = false; private static boolean isInjected = false; + private static String profile = ""; + private static String server = ""; + private static String gameType = ""; + private static String locationRaw = ""; + private static String map = ""; + private static long clientWorldJoinTime = 0; + private static boolean sentLocRaw = false; + private static long lastLocRaw = 0; public static boolean isOnSkyblock() { return isOnSkyblock; @@ -34,6 +50,31 @@ public class Utils { return isInjected; } + public static String getProfile() { + return profile; + } + + public static String getServer() { + return server; + } + + public static String getGameType() { + return gameType; + } + + public static String getLocationRaw() { + return locationRaw; + } + + public static String getMap() { + return map; + } + + public static void init() { + ClientPlayConnectionEvents.JOIN.register(Utils::onClientWorldJoin); + ClientReceiveMessageEvents.ALLOW_GAME.register(Utils::onChatMessage); + } + public static void sbChecker() { MinecraftClient client = MinecraftClient.getInstance(); List sidebar; @@ -61,13 +102,14 @@ public class Utils { SkyblockEvents.LEAVE.invoker().onSkyblockLeave(); } isInDungeons = isOnSkyblock && string.contains("The Catacombs"); + updateLocRaw(); } public static String getLocation() { String location = null; List sidebarLines = getSidebar(); try { - if( sidebarLines != null) { + if (sidebarLines != null) { for (String sidebarLine : sidebarLines) { if (sidebarLine.contains("⏣")) location = sidebarLine; } @@ -149,4 +191,51 @@ public class Utils { return null; } } + + public static void onClientWorldJoin(ClientPlayNetworkHandler handler, PacketSender sender, MinecraftClient client) { + clientWorldJoinTime = System.currentTimeMillis(); + resetLocRawInfo(); + } + + private static void updateLocRaw() { + if (isOnSkyblock) { + long currentTime = System.currentTimeMillis(); + if (!sentLocRaw && currentTime > clientWorldJoinTime + 1000 && currentTime > lastLocRaw + 15000) { + SkyblockerMod.getInstance().messageScheduler.sendMessageAfterCooldown("/locraw"); + sentLocRaw = true; + lastLocRaw = currentTime; + } + } else { + resetLocRawInfo(); + } + } + + public static boolean onChatMessage(Text text, boolean overlay) { + String message = text.getString(); + if (message.startsWith("{\"server\":") && message.endsWith("}")) { + JsonObject locRaw = JsonParser.parseString(message).getAsJsonObject(); + if (locRaw.has("server")) { + server = locRaw.get("server").getAsString(); + if (locRaw.has("gameType")) { + gameType = locRaw.get("gameType").getAsString(); + } + if (locRaw.has("mode")) { + locationRaw = locRaw.get("mode").getAsString(); + } + if (locRaw.has("map")) { + map = locRaw.get("map").getAsString(); + } + return !sentLocRaw; + } + } + return true; + } + + private static void resetLocRawInfo() { + sentLocRaw = false; + server = ""; + gameType = ""; + locationRaw = ""; + map = ""; + } } \ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 858507fe..b40dd52e 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -22,6 +22,8 @@ "text.autoconfig.skyblocker.option.general.bars.barpositions.experienceBarPosition": "Experience Bar Position", "text.autoconfig.skyblocker.option.general.fishing": "Fishing Helper", "text.autoconfig.skyblocker.option.general.fishing.enableFishingHelper": "Enable Fishing Helper", + "text.autoconfig.skyblocker.option.general.fairySouls": "Fairy Souls Helper", + "text.autoconfig.skyblocker.option.general.fairySouls.enableFairySoulsHelper": "Enable Fairy Souls Helper", "text.autoconfig.skyblocker.option.general.quicknav": "Quicknav", "text.autoconfig.skyblocker.option.general.quicknav.enableQuicknav": "Enable Quicknav", "text.autoconfig.skyblocker.option.general.backpackPreviewWithoutShift": "View backpack preview without holding Shift", @@ -222,5 +224,7 @@ "skyblocker.api.got_key": "§b[§6Skyblocker§b] §2Automatically set your API key!", - "skyblocker.fishing.reelNow": "Reel in now!" + "skyblocker.fishing.reelNow": "Reel in now!", + "skyblocker.fairySouls.markAllFound": "Marked all fairy souls in the current island as found", + "skyblocker.fairySouls.markAllMissing": "Marked all fairy souls in the current island as missing" } -- cgit From 2abd16260b6b3296d32853baa7d062a518ec2b1c Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Wed, 5 Jul 2023 15:51:41 -0400 Subject: Loom 1.3 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build.gradle') diff --git a/build.gradle b/build.gradle index 83da3489..8c83e515 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.2-SNAPSHOT' + id 'fabric-loom' version '1.3-SNAPSHOT' id 'maven-publish' id 'com.modrinth.minotaur' version '2.+' } -- cgit