Fixed up some stuff (Got busy so finish it later)

This commit is contained in:
TomTheFurry
2022-04-04 17:48:37 +08:00
parent 139c5869c9
commit 38102ac17f
3 changed files with 47 additions and 22 deletions
+24 -11
View File
@@ -35,6 +35,15 @@ def loadProperties() {
}
writeBuildGradlePredefine()
// Stuff for access wideners
def mcVersionToAcsessWidenerVersion = [
"1_16_5": "1_16",
"1.17.1": "1_17",
"1.18.1": "1_18",
"1.18.2": "1_18",
]
// Use this as sometimes multiple versions use the same access wideners
rootProject.ext.set("acsessWidenerVersion", mcVersionToAcsessWidenerVersion.get(mcVersion))
}
loadProperties()
@@ -44,14 +53,6 @@ architectury {
minecraft = rootProject.minecraft_version
}
// Stuff for access wideners
def mcVersionToAcsessWidenerVersion = [
"1_16_5": "1_16",
"1_17_1": "1_17",
"1_18_1": "1_18",
"1_18_2": "1_18"
] // Use this as sometimes multiple versions use the same access wideners
def acsessWidenerVersion = mcVersionToAcsessWidenerVersion.get(minecraft_version.replace(".", "_"))
subprojects { p ->
apply plugin: "dev.architectury.loom"
@@ -60,7 +61,7 @@ subprojects { p ->
silentMojangMappingsLicense()
if (p != project(":core")) {
accessWidenerPath.set(project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener"))
accessWidenerPath.set(project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener"))
}
}
@@ -193,9 +194,9 @@ allprojects { p ->
// This method copies the access wideners from the common project to the fabric project. And it was generated by Github Copilot
task copyAccessWidener(type: Copy) {
from project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener")
from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener")
into(file(p.file("build/resources/main")))
rename "${acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
}
@@ -231,6 +232,18 @@ allprojects { p ->
runClient.enabled = false
runServer.enabled = false
}
// this is necessary for running the fabric build
if (p == project(":common")) {
println "Copying [common/src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidner] to [fabric/build/resources/main]."
copy {
from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener")
into "$rootProject.rootDir/fabric/build/resources/main"
rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
}
}
}
@@ -368,7 +368,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
if (chunkData == null)
{
return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif);
return new ProtoChunk(chunkPos, UpgradeData.EMPTY
#if MC_VERSION_1_17_1, level #endif
#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif
);
}
else
{
@@ -376,7 +379,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
return ChunkLoader.read(level, lightEngine, chunkPos, chunkData);
} catch (Exception e) {
LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif);
return new ProtoChunk(chunkPos, UpgradeData.EMPTY
#if MC_VERSION_1_17_1, level #endif
#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif
);
}
}
@@ -414,8 +420,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
// Continue...
}
if (target == null)
target = new ProtoChunk(chunkPos, UpgradeData.EMPTY, params.level
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1, params.biomes, null #endif);
target = new ProtoChunk(chunkPos, UpgradeData.EMPTY
#if MC_VERSION_1_17_1, params.level #endif
#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2, params.biomes, null #endif
);
return target;
};
@@ -41,6 +41,7 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
@@ -49,7 +50,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLLoader;
#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2
import net.minecraftforge.client.ConfigGuiHandler;
#elif MC_VERSION_1_16_5 || MC_VERSION_1_17_1
#elif MC_VERSION_1_17_1
import net.minecraftforge.fmlclient.ConfigGuiHandler;
#endif
@@ -92,13 +93,15 @@ public class ForgeMain implements LodForgeMethodCaller
ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor());
}
ModAccessorHandler.finishBinding();
ModAccessorHandler.finishBinding();
#if MC_VERSION_1_16_5
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY,
() -> (client, parent) -> ConfigGui.getScreen(parent, ""));
#else
ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class,
() -> new ConfigGuiHandler.ConfigGuiFactory((client, parent) -> ConfigGui.getScreen(parent, "")));
#endif
forgeClientProxy = new ForgeClientProxy();
MinecraftForge.EVENT_BUS.register(forgeClientProxy);
}
@@ -111,10 +114,11 @@ public class ForgeMain implements LodForgeMethodCaller
@Override
public int colorResolverGetColor(ColorResolver resolver, Biome biome, double x, double z) {
#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2
return resolver.getColor(biome, x, z);
#elif MC_VERSION_1_17_1
#if MC_VERSION_1_17_1
return resolver.m_130045_(biome, x, z);
#else
return resolver.getColor(biome, x, z);
#endif
}
}