Fastcraft compat

#165
This commit is contained in:
FalsePattern committed 2025-06-09 18:41:34 +02:00
1 parent 76fdd16906
commit 7a6dd9adaa
8 files changed
+166

No files matched your search

+1
View File
@@ -77,6 +77,7 @@ This mod also contains patches for the following mods:
- Extra Planets
- Extra Utilities
- Factorization
- FastCraft
- Futurepack
- Gadomancy
- GalactiCraft
+3
View File
@@ -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"))
@@ -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 {
@@ -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 <https://www.gnu.org/licenses/>.
*/
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();
});
}
}
@@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}
}
@@ -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
@@ -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")),
@@ -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 <https://www.gnu.org/licenses/>.
*/
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<String, String> lineTransformer, Supplier<String> generator, Consumer<IOException> 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);
}
}
}