diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7281e5da..7f5e9eef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,9 +10,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@v1 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: gradle/actions/wrapper-validation@v3 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: 17 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index eaeff183..738a6950 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,9 +6,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@v1 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: gradle/actions/wrapper-validation@v3 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: 17 diff --git a/build.gradle b/build.gradle index d6e32fd0..0f1e0db4 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,8 @@ import com.diffplug.gradle.spotless.JavaExtension plugins { id 'java-library' id 'com.diffplug.spotless' version "6.12.0" - id 'fabric-loom' version "1.6-SNAPSHOT" apply false // To use chocoloom, change the version to a commit hash - id 'legacy-looming' version "1.6-SNAPSHOT" apply false // Version must be the same as fabric-loom's + id 'fabric-loom' version "1.7-SNAPSHOT" apply false // To use chocoloom, change the version to a commit hash + id 'legacy-looming' version "1.7-SNAPSHOT" apply false // Version must be the same as fabric-loom's id 'maven-publish' id "com.modrinth.minotaur" version "2.+" } @@ -175,9 +175,9 @@ modrinth { projectId = "JpHZ1Cyv" // This can be the project ID or the slug. Either will work! versionName = displayVersion changelog = """ -Ensure Forge always loads before Minecraft classes. -Fix crash on server. -Fix compatibility with forge servers. +Fix IC2 crash because of bad reflection again.\\ +Add OptiFabric/OptiFine compatibility.\\ +Don't load multiple variant of a mixin at the same time """ uploadFile = remapJar gameVersions = [project.minecraft_version] // Must be an array, even with only one version diff --git a/gradle.properties b/gradle.properties index 9be5c731..8a846b03 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,6 +15,6 @@ org.gradle.jvmargs=-Xmx2G spasm_version=0.2 # Mod Properties - mod_version = 2.7.2 + mod_version = 2.7.5 maven_group = fr.catcore archives_base_name = fabricated-forge diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 033e24c4..a4b76b95 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 b82aa23a..df97d72b 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.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index fcb6fca1..f5feea6d 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -83,7 +85,9 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -144,7 +148,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -201,11 +205,11 @@ 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 -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 6689b85b..9b42019c 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/src/main/java/cpw/mods/fml/common/ModClassLoader.java b/src/main/java/cpw/mods/fml/common/ModClassLoader.java index 3565848e..2b2deb1a 100644 --- a/src/main/java/cpw/mods/fml/common/ModClassLoader.java +++ b/src/main/java/cpw/mods/fml/common/ModClassLoader.java @@ -110,7 +110,11 @@ public File[] getParentSources() { try { for (URL url : urls) { - files.add(new File(url.toURI())); + try { + files.add(new File(url.toURI())); + } catch (IllegalArgumentException ignored) { + System.err.println("Found non file url while getting sources from Knot classloader: " + url.toURI()); + } } return files.toArray(new File[0]); diff --git a/src/main/java/fr/catcore/fabricatedforge/ForgeModRemapper.java b/src/main/java/fr/catcore/fabricatedforge/ForgeModRemapper.java index fc58fda0..9993ce53 100644 --- a/src/main/java/fr/catcore/fabricatedforge/ForgeModRemapper.java +++ b/src/main/java/fr/catcore/fabricatedforge/ForgeModRemapper.java @@ -128,22 +128,12 @@ public void registerPostVisitors(VisitorInfos visitorInfos) { ); // Forge added fields and methods - visitorInfos.registerMethodInvocation( - "net/minecraft/class_197", - "setBurnProperties", - "", - new VisitorInfos.FullClassMember( - "fr/catcore/fabricatedforge/forged/reflection/ReflectedBlock", - "setBurnProperties", - null - ) - ); visitorInfos.registerFieldRef( "net/minecraft/class_197", "blockFireSpreadSpeed", "", new VisitorInfos.FullClassMember( - "fr/catcore/fabricatedforge/forged/reflection/ReflectedWorld", + "fr/catcore/fabricatedforge/forged/reflection/ReflectedBlock", "blockFireSpreadSpeed", null ) @@ -153,7 +143,7 @@ public void registerPostVisitors(VisitorInfos visitorInfos) { "blockFlammability", "", new VisitorInfos.FullClassMember( - "fr/catcore/fabricatedforge/forged/reflection/ReflectedWorld", + "fr/catcore/fabricatedforge/forged/reflection/ReflectedBlock", "blockFlammability", null ) diff --git a/src/main/java/fr/catcore/fabricatedforge/mixin/FabricatedForgeMixinPlugin.java b/src/main/java/fr/catcore/fabricatedforge/mixin/FabricatedForgeMixinPlugin.java index 8310ae86..e3bd0089 100644 --- a/src/main/java/fr/catcore/fabricatedforge/mixin/FabricatedForgeMixinPlugin.java +++ b/src/main/java/fr/catcore/fabricatedforge/mixin/FabricatedForgeMixinPlugin.java @@ -1,10 +1,14 @@ package fr.catcore.fabricatedforge.mixin; import fr.catcore.cursedmixinextensions.CursedMixinExtensions; +import fr.catcore.fabricatedforge.Constants; +import io.github.fabriccompatibiltylayers.modremappingapi.api.MappingUtils; +import net.fabricmc.loader.api.FabricLoader; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import java.util.Arrays; import java.util.List; import java.util.Set; @@ -19,9 +23,44 @@ public String getRefMapperConfig() { return null; } + private static List OPTIFINE_OVERRIDES = Arrays.asList( + "ast", + "asv", + "atq", + "auv", + "baj", + "ban", + "bau", + "bav", + "bax", + "baz", + "bba", + "bbb", + "bbd", + "bbf", + "bbg", + "bce", + "bdz", + "ik", + "il", + "kc", + "kh", + "md" + ); + @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - return true; + if (FabricLoader.getInstance().isModLoaded("optifabric")) { + if (OPTIFINE_OVERRIDES.contains(FabricLoader.getInstance().getMappingResolver() + .unmapClassName("official", targetClassName)) && !mixinClassName.endsWith("Accessor") && !mixinClassName.contains(".optifine.")) { + System.out.println("[Fabricated-Legacy-Forge] Mixin cancelled for Optifine compatibility: " + mixinClassName); + return false; + } + + return true; + } else { + return !mixinClassName.contains(".optifine."); + } } @Override diff --git a/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/block/BlockMixin.java b/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/block/BlockMixin.java index 2a1d7002..27bc6580 100644 --- a/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/block/BlockMixin.java +++ b/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/block/BlockMixin.java @@ -1,6 +1,7 @@ package fr.catcore.fabricatedforge.mixin.forgefml.block; import cpw.mods.fml.common.registry.BlockProxy; +import fr.catcore.cursedmixinextensions.annotations.Public; import fr.catcore.fabricatedforge.forged.reflection.ReflectedBlock; import fr.catcore.fabricatedforge.mixininterface.IBlock; import fr.catcore.fabricatedforge.mixininterface.IBlockWithEntity; @@ -529,6 +530,11 @@ public boolean canDragonDestroy(World world, int x, int y, int z) { return this.id != OBSIDIAN.id && this.id != END_STONE.id && this.id != BEDROCK.id; } + @Public + private static void setBurnProperties(int id, int encouragement, int flammability) { + ReflectedBlock.setBurnProperties(id, encouragement, flammability); + } + @Override public boolean isBeaconBase(World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { return this.id == EMERALD_BLOCK.id || this.id == GOLD_BLOCK.id || this.id == DIAMOND_BLOCK.id || this.id == IRON_BLOCK.id; diff --git a/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/client/render/TessellatorMixin.java b/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/client/render/TessellatorMixin.java index 441f8dee..1112c453 100644 --- a/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/client/render/TessellatorMixin.java +++ b/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/client/render/TessellatorMixin.java @@ -1,6 +1,7 @@ package fr.catcore.fabricatedforge.mixin.forgefml.client.render; import com.mojang.blaze3d.platform.GLX; +import fr.catcore.cursedmixinextensions.annotations.Public; import fr.catcore.fabricatedforge.mixininterface.ITessellator; import net.minecraft.client.render.Tessellator; import org.lwjgl.opengl.ARBVertexBufferObject; @@ -54,6 +55,7 @@ public abstract class TessellatorMixin implements ITessellator { private static int nativeBufferSize = 0x200000; private static int trivertsInBuffer = nativeBufferSize / 48 * 6; // Should be public + @Public private static boolean renderingWorldRenderer = false; public boolean defaultTexture = false; private int rawBufferSize = 0; diff --git a/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/client/render/optifine/TessellatorMixin.java b/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/client/render/optifine/TessellatorMixin.java new file mode 100644 index 00000000..d8848ad8 --- /dev/null +++ b/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/client/render/optifine/TessellatorMixin.java @@ -0,0 +1,46 @@ +package fr.catcore.fabricatedforge.mixin.forgefml.client.render.optifine; + +import fr.catcore.fabricatedforge.mixininterface.ITessellator; +import net.minecraft.client.render.Tessellator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(Tessellator.class) +public abstract class TessellatorMixin implements ITessellator { + @SuppressWarnings("UnresolvedMixinReference") + @Shadow + public static boolean renderingWorldRenderer; + + @SuppressWarnings("UnresolvedMixinReference") + @Shadow + public boolean defaultTexture; + + @SuppressWarnings("UnresolvedMixinReference") + @Shadow + public int textureID; + + @Override + public boolean defaultTexture() { + return this.defaultTexture; + } + + @Override + public boolean renderingWorldRenderer() { + return renderingWorldRenderer; + } + + @Override + public void renderingWorldRenderer(boolean bool) { + renderingWorldRenderer = bool; + } + + @Override + public void setTextureID(int textureID) { + this.textureID = textureID; + } + + @Override + public int getTextureID() { + return this.textureID; + } +} diff --git a/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/client/render/optifine/WorldRendererMixin.java b/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/client/render/optifine/WorldRendererMixin.java new file mode 100644 index 00000000..d4130ef5 --- /dev/null +++ b/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/client/render/optifine/WorldRendererMixin.java @@ -0,0 +1,9 @@ +package fr.catcore.fabricatedforge.mixin.forgefml.client.render.optifine; + +import fr.catcore.fabricatedforge.mixininterface.IWorldRenderer; +import net.minecraft.client.render.WorldRenderer; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(WorldRenderer.class) +public abstract class WorldRendererMixin implements IWorldRenderer { +} diff --git a/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/entity/mob/optifine/MobEntityMixin.java b/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/entity/mob/optifine/MobEntityMixin.java new file mode 100644 index 00000000..ff982bb6 --- /dev/null +++ b/src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/entity/mob/optifine/MobEntityMixin.java @@ -0,0 +1,23 @@ +package fr.catcore.fabricatedforge.mixin.forgefml.entity.mob.optifine; + +import fr.catcore.fabricatedforge.mixininterface.IMobEntity; +import net.minecraft.entity.mob.MobEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(MobEntity.class) +public abstract class MobEntityMixin implements IMobEntity { + + @Shadow + float field_3344; + + @Override + public float getField_3344() { + return this.field_3344; + } + + @Override + public void setField_3344(float field_3344) { + this.field_3344 = field_3344; + } +} diff --git a/src/main/resources/fabricated-forge.forge.mixins.json b/src/main/resources/fabricated-forge.forge.mixins.json index 04f1cd3e..c31829b2 100644 --- a/src/main/resources/fabricated-forge.forge.mixins.json +++ b/src/main/resources/fabricated-forge.forge.mixins.json @@ -63,6 +63,7 @@ "entity.effect.StatusEffectInstanceMixin", "entity.mob.MobEntityMixin", "entity.mob.SlimeEntityMixin", + "entity.mob.optifine.MobEntityMixin", "entity.passive.MooshroomEntityMixin", "entity.passive.OcelotEntityMixin", "entity.passive.SheepEntityMixin", @@ -220,6 +221,8 @@ "client.render.entity.SnowGolemEntityRendererMixin", "client.render.item.HeldItemRendererMixin", "client.render.item.ItemRendererMixin", + "client.render.optifine.TessellatorMixin", + "client.render.optifine.WorldRendererMixin", "client.sound.SoundLoaderMixin", "client.sound.SoundSystemMixin", "client.texture.ClockSpriteMixin",