diff --git a/README.MD b/README.MD index f0b87ef..98922fb 100644 --- a/README.MD +++ b/README.MD @@ -77,6 +77,7 @@ This mod also contains patches for the following mods: - Extra Planets - Extra Utilities - Factorization +- FastCraft - Futurepack - Gadomancy - GalactiCraft diff --git a/build.gradle.kts b/build.gradle.kts index 689f274..4d064bd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -156,6 +156,9 @@ dependencies { //Factorization 0.8.109 compileOnly(deobfModrinth("factorization:0.8.109")) + //Fastcraft 1.23 + compileOnly("curse.maven:fastcraft-242677:2292386") + //Futurepack v18.7 compileOnly(deobfCurse("futurepack-237333:2263966")) diff --git a/src/main/java/com/falsepattern/endlessids/asm/EndlessIDsCore.java b/src/main/java/com/falsepattern/endlessids/asm/EndlessIDsCore.java index 6c7966f..78b1618 100644 --- a/src/main/java/com/falsepattern/endlessids/asm/EndlessIDsCore.java +++ b/src/main/java/com/falsepattern/endlessids/asm/EndlessIDsCore.java @@ -24,6 +24,7 @@ package com.falsepattern.endlessids.asm; import com.falsepattern.endlessids.Tags; import com.falsepattern.endlessids.config.GeneralConfig; +import com.falsepattern.endlessids.util.ConfigFixUtil; import lombok.SneakyThrows; import lombok.val; @@ -32,6 +33,7 @@ import net.minecraft.launchwrapper.LaunchClassLoader; import cpw.mods.fml.relauncher.FMLInjectionData; import cpw.mods.fml.relauncher.IFMLLoadingPlugin; +import java.io.IOException; import java.util.Map; import java.util.Set; @@ -46,6 +48,17 @@ import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions; @DependsOn("falsepatternlib") public class EndlessIDsCore implements IFMLLoadingPlugin { public static boolean deobfuscated; + static { + if (GeneralConfig.extendBlockItem) { + try { + if (Launch.classLoader.getClassBytes("fastcraft.Tweaker") != null) { + FCCompat.patchConfig(); + } + } catch (Exception ignored) { + } + } + } + public EndlessIDsCore() { super(); try { diff --git a/src/main/java/com/falsepattern/endlessids/asm/FCCompat.java b/src/main/java/com/falsepattern/endlessids/asm/FCCompat.java new file mode 100644 index 0000000..296b7f3 --- /dev/null +++ b/src/main/java/com/falsepattern/endlessids/asm/FCCompat.java @@ -0,0 +1,42 @@ +/* + * EndlessIDs + * + * Copyright (C) 2022-2025 FalsePattern, The MEGA Team + * All Rights Reserved + * + * The above copyright notice, this permission notice and the word "MEGA" + * shall be included in all copies or substantial portions of the Software. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, only version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.falsepattern.endlessids.asm; + +import com.falsepattern.endlessids.util.ConfigFixUtil; + +public class FCCompat { + public static void patchConfig() { + //Breaks with the blockitem module + ConfigFixUtil.fixConfig("fastcraft.ini", (line) -> { + if (line.contains("asyncCulling") || line.contains("enableCullingTweaks")) { + return line.replace("true", "false"); + } + return line; + }, () -> "[extra tweaks]\nasyncCulling = false\n[transparent tweaks]\nenableCullingTweaks=false\n", + e -> { + System.err.println( + "Failed to apply FastCraft occlusion tweak compatibility patches!"); + e.printStackTrace(); + }); + } +} diff --git a/src/main/java/com/falsepattern/endlessids/mixin/mixins/client/blockitem/fastcraft/EntityRendererMixin.java b/src/main/java/com/falsepattern/endlessids/mixin/mixins/client/blockitem/fastcraft/EntityRendererMixin.java new file mode 100644 index 0000000..6924e1e --- /dev/null +++ b/src/main/java/com/falsepattern/endlessids/mixin/mixins/client/blockitem/fastcraft/EntityRendererMixin.java @@ -0,0 +1,44 @@ +/* + * EndlessIDs + * + * Copyright (C) 2022-2025 FalsePattern, The MEGA Team + * All Rights Reserved + * + * The above copyright notice, this permission notice and the word "MEGA" + * shall be included in all copies or substantial portions of the Software. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, only version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.falsepattern.endlessids.mixin.mixins.client.blockitem.fastcraft; + +import org.spongepowered.asm.mixin.Dynamic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.entity.EntityLivingBase; + +@Mixin(EntityRenderer.class) +public class EntityRendererMixin { + @Dynamic + @Redirect(method = "renderWorld", + at = @At(value = "INVOKE", + target = "Lfastcraft/HC;t(Lnet/minecraft/client/renderer/RenderGlobal;Lnet/minecraft/entity/EntityLivingBase;Z)Z", + remap = false)) + private boolean killHook2(RenderGlobal rg, EntityLivingBase entity, boolean doUpdates) { + return rg.updateRenderers(entity, doUpdates); + } +} diff --git a/src/main/java/com/falsepattern/endlessids/mixin/plugin/Mixin.java b/src/main/java/com/falsepattern/endlessids/mixin/plugin/Mixin.java index b45ecb3..d811e28 100644 --- a/src/main/java/com/falsepattern/endlessids/mixin/plugin/Mixin.java +++ b/src/main/java/com/falsepattern/endlessids/mixin/plugin/Mixin.java @@ -54,6 +54,7 @@ import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.EXTENDEDPLANE import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.EXTRAPLANETS; import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.EXTRAUTILITIES; import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.FACTORIZATION; +import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.FASTCRAFT; import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.FUTUREPACK; import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.GADOMANCY; import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.GALACTICRAFTCORE; @@ -353,6 +354,8 @@ public class Mixin { blockitem_vanilla_NetHandlerPlayClientMixin(EXT_BLOCK_ITEM), blockitem_vanilla_PlayerControllerMPMixin(EXT_BLOCK_ITEM), blockitem_vanilla_RenderGlobalMixin(EXT_BLOCK_ITEM), + + blockitem_fastcraft_EntityRendererMixin(EXT_BLOCK_ITEM, require(FASTCRAFT)), //endregion //region potion diff --git a/src/main/java/com/falsepattern/endlessids/mixin/plugin/TargetedMod.java b/src/main/java/com/falsepattern/endlessids/mixin/plugin/TargetedMod.java index ccaca6e..2f01d81 100644 --- a/src/main/java/com/falsepattern/endlessids/mixin/plugin/TargetedMod.java +++ b/src/main/java/com/falsepattern/endlessids/mixin/plugin/TargetedMod.java @@ -55,6 +55,7 @@ public enum TargetedMod implements ITargetedMod { EXTRAPLANETS("Extra Planets", false, contains("extraplanets-")), EXTRAUTILITIES("Extra Utilities", false, contains("extrautilities-")), FACTORIZATION("Factorization", false, contains("factorization-")), + FASTCRAFT("Fastcraft", false, contains("fastcraft-")), FUTUREPACK("Futurepack", false, contains("futurepack")), GADOMANCY("Gadomancy", false, contains("gadomancy-")), GALACTICRAFTCORE("GalactiCraftCore", false, contains("galacticraftcore")), diff --git a/src/main/java/com/falsepattern/endlessids/util/ConfigFixUtil.java b/src/main/java/com/falsepattern/endlessids/util/ConfigFixUtil.java new file mode 100644 index 0000000..8e74593 --- /dev/null +++ b/src/main/java/com/falsepattern/endlessids/util/ConfigFixUtil.java @@ -0,0 +1,59 @@ +/* + * EndlessIDs + * + * Copyright (C) 2022-2025 FalsePattern, The MEGA Team + * All Rights Reserved + * + * The above copyright notice, this permission notice and the word "MEGA" + * shall be included in all copies or substantial portions of the Software. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, only version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.falsepattern.endlessids.util; + +import com.falsepattern.lib.util.FileUtil; +import lombok.val; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +public class ConfigFixUtil { + public static void fixConfig(String configFile, Function lineTransformer, Supplier generator, Consumer exceptionHandler) { + val targetPath = FileUtil.getMinecraftHomePath().resolve("config").resolve(configFile); + if (!Files.exists(targetPath)) { + val genned = generator.get(); + if (genned == null) { + return; + } + try { + Files.write(targetPath, genned.getBytes(StandardCharsets.UTF_8)); + } catch (IOException e) { + exceptionHandler.accept(e); + } + return; + } + try { + val fileText = Files.readAllLines(targetPath); + val result = fileText.stream().map(lineTransformer).collect(Collectors.toList()); + Files.write(targetPath, result); + } catch (IOException e) { + exceptionHandler.accept(e); + } + } +} \ No newline at end of file