1.19.3 now builds and some things work (code for generator broken tough)

This commit is contained in:
coolGi
2022-12-20 17:11:55 +10:30
parent 993a9a6864
commit 4af31ac5b9
10 changed files with 144 additions and 57 deletions
@@ -43,15 +43,36 @@ import net.minecraft.core.Direction;
*/
public class McObjectConverter
{
private static int bufferIndex(int x, int y) {
return y * 4 + x;
}
/** Taken from Minecraft's com.mojang.math.Matrix4f class from 1.18.2 */
public static void storeMatrix(Matrix4f matrix, FloatBuffer buffer) {
buffer.put(bufferIndex(0, 0), matrix.m00());
buffer.put(bufferIndex(0, 1), matrix.m01());
buffer.put(bufferIndex(0, 2), matrix.m02());
buffer.put(bufferIndex(0, 3), matrix.m03());
buffer.put(bufferIndex(1, 0), matrix.m10());
buffer.put(bufferIndex(1, 1), matrix.m11());
buffer.put(bufferIndex(1, 2), matrix.m12());
buffer.put(bufferIndex(1, 3), matrix.m13());
buffer.put(bufferIndex(2, 0), matrix.m20());
buffer.put(bufferIndex(2, 1), matrix.m21());
buffer.put(bufferIndex(2, 2), matrix.m22());
buffer.put(bufferIndex(2, 3), matrix.m23());
buffer.put(bufferIndex(3, 0), matrix.m30());
buffer.put(bufferIndex(3, 1), matrix.m31());
buffer.put(bufferIndex(3, 2), matrix.m32());
buffer.put(bufferIndex(3, 3), matrix.m33());
}
/** 4x4 float matrix converter */
public static Mat4f Convert(Matrix4f mcMatrix)
{
FloatBuffer buffer = FloatBuffer.allocate(16);
#if PRE_MC_1_19_3
mcMatrix.store(buffer);
#else
mcMatrix.store(buffer);
#endif
storeMatrix(mcMatrix, buffer);
Mat4f matrix = new Mat4f(buffer);
matrix.transpose();
return matrix;
@@ -782,9 +782,9 @@ public abstract class ConfigGui
if (button != null)
{
#if PRE_MC_1_19_3
resetButton.y = y;
button.y = y;
#else
resetButton.setY(y);
button.setY(y);
#endif
button.render(matrices, mouseX, mouseY, tickDelta);
}
@@ -800,9 +800,9 @@ public abstract class ConfigGui
if (indexButton != null)
{
#if PRE_MC_1_19_3
resetButton.y = y;
indexButton.y = y;
#else
resetButton.setY(y);
indexButton.setY(y);
#endif
indexButton.render(matrices, mouseX, mouseY, tickDelta);
}
@@ -196,7 +196,9 @@ public class BiomeWrapper implements IBiomeWrapper
#if PRE_MC_1_19_3
return BuiltinRegistries.BIOME.getOrThrow(r);
#else
return BuiltInRegistries.BIOME.getOrThrow(r);
// FIXME [1.19.3]
// return BuiltInRegistries.BIOME.getOrThrow(r);
return null;
#endif
}
@@ -262,17 +264,19 @@ public class BiomeWrapper implements IBiomeWrapper
@Override
public int getColorForBiome(int x, int z)
{
int colorInt;
Function<Biome, Integer> colorFunction = BIOME_COLOR_MAP.get(biome);
if (colorFunction != null)
{
colorInt = colorFunction.apply(biome);
}
else
{
colorInt = biome.getGrassColor(x, z);
}
return colorInt;
// int colorInt;
// Function<Biome, Integer> colorFunction = BIOME_COLOR_MAP.get(biome);
// if (colorFunction != null)
// {
// colorInt = colorFunction.apply(biome);
// }
// else
// {
// colorInt = biome.getGrassColor(x, z);
// }
// return colorInt;
// FIXME[1.19.3]
return 0;
}
#endif
@Override public String getName()
@@ -59,6 +59,9 @@ import com.seibel.lod.common.wrappers.worldGeneration.step.StepStructureReferenc
import com.seibel.lod.common.wrappers.worldGeneration.step.StepStructureStart;
import com.seibel.lod.common.wrappers.worldGeneration.step.StepSurface;
#if POST_MC_1_19_3
import net.minecraft.core.registries.Registries;
#endif
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.ChunkAccess;
@@ -380,8 +383,14 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
if (chunkData == null)
{
return new ProtoChunk(chunkPos, UpgradeData.EMPTY
#if POST_MC_1_17_1, level #endif
#if POST_MC_1_18_1, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif
#if POST_MC_1_17_1, level #endif
#if POST_MC_1_18_1, level.registryAccess().registryOrThrow(
#if PRE_MC_1_19_3
Registry.BIOME_REGISTRY
#else
Registries.BIOME
#endif
), null #endif
);
}
else
@@ -391,8 +400,14 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
} catch (Exception e) {
LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
return new ProtoChunk(chunkPos, UpgradeData.EMPTY
#if POST_MC_1_17_1, level #endif
#if POST_MC_1_18_1, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif
#if POST_MC_1_17_1, level #endif
#if POST_MC_1_18_1, level.registryAccess().registryOrThrow(
#if PRE_MC_1_19_3
Registry.BIOME_REGISTRY
#else
Registries.BIOME
#endif
), null #endif
);
}
}
@@ -42,6 +42,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
import net.minecraft.world.level.levelgen.RandomState;
#if POST_MC_1_19_3
import net.minecraft.world.level.levelgen.WorldOptions;
import net.minecraft.core.registries.Registries;
#endif
#endif
import net.minecraft.world.level.storage.WorldData;
@@ -81,13 +82,14 @@ public final class GlobalParameters
lightEngine = (ThreadedLevelLightEngine) level.getLightEngine();
MinecraftServer server = level.getServer();
WorldData worldData = server.getWorldData();
registry = server.registryAccess();
#if PRE_MC_1_19_3
worldGenSettings = worldData.worldGenSettings();
biomes = registry.registryOrThrow(Registry.BIOME_REGISTRY);
#else
worldOptions = worldData.worldGenOptions();
biomes = registry.registryOrThrow(Registries.BIOME);
#endif
registry = server.registryAccess();
biomes = registry.registryOrThrow(Registry.BIOME_REGISTRY);
worldSeed = worldOptions.seed();
#if POST_MC_1_18_1
biomeManager = new BiomeManager(level, BiomeManager.obfuscateSeed(worldSeed));
@@ -279,10 +279,11 @@ public class ChunkLoader
LevelChunkTicks<Fluid> fluidTicks = LevelChunkTicks.load(tagLevel.getList(FLUID_TICKS_TAG_18, 10),
string -> Registry.FLUID.getOptional(ResourceLocation.tryParse(string)), chunkPos);
#else
LevelChunkTicks<Block> blockTicks = LevelChunkTicks.load(tagLevel.getList(BLOCK_TICKS_TAG_18, 10),
string -> Registries.BLOCK.cast(ResourceLocation.tryParse(string)), chunkPos);
LevelChunkTicks<Fluid> fluidTicks = LevelChunkTicks.load(tagLevel.getList(FLUID_TICKS_TAG_18, 10),
string -> Registries.FLUID.cast(ResourceLocation.tryParse(string)), chunkPos);
// FIXME[1.19.3]
// LevelChunkTicks<Block> blockTicks = LevelChunkTicks.load(tagLevel.getList(BLOCK_TICKS_TAG_18, 10),
// string -> Registries.BLOCK.cast(ResourceKey.createRegistryKey(ResourceLocation.tryParse(string))), chunkPos);
// LevelChunkTicks<Fluid> fluidTicks = LevelChunkTicks.load(tagLevel.getList(FLUID_TICKS_TAG_18, 10),
// string -> Registries.FLUID.cast(ResourceLocation.tryParse(string)), chunkPos);
#endif
#endif
@@ -293,8 +294,11 @@ public class ChunkLoader
LevelChunk chunk = new LevelChunk((Level) level.getLevel(), chunkPos, chunkBiomeContainer, upgradeData, blockTicks,
fluidTicks, inhabitedTime, levelChunkSections, null);
#else
LevelChunk chunk = new LevelChunk((Level) level, chunkPos, upgradeData, blockTicks,
fluidTicks, inhabitedTime, levelChunkSections, null, blendingData);
// FIXME[1.19.3]
// LevelChunk chunk = new LevelChunk((Level) level, chunkPos, upgradeData, blockTicks,
// fluidTicks, inhabitedTime, levelChunkSections, null, blendingData);
LevelChunk chunk = new LevelChunk((Level) level, chunkPos, upgradeData, new LevelChunkTicks(),
new LevelChunkTicks(), inhabitedTime, levelChunkSections, null, blendingData);
#endif
// Set some states after object creation
chunk.setLightCorrect(isLightOn);
@@ -83,10 +83,11 @@ public final class StepStructureStart {
environment.params.generator.createStructures(environment.params.registry, environment.params.randomState, tParams.structFeat, chunk, environment.params.structures,
environment.params.worldSeed);
#else
environment.params.generator.createStructures(environment.params.registry,
environment.params.generator.createState(
environment.params.level.holderLookup(), environment.params.randomState, environment.params.worldSeed),
tParams.structFeat, chunk, environment.params.structures);
// FIXME[1.19.3]
// environment.params.generator.createStructures(environment.params.registry,
// environment.params.generator.createState(
// environment.params.level.holderLookup(), environment.params.randomState, environment.params.worldSeed),
// tParams.structFeat, chunk, environment.params.structures);
#endif
#if POST_MC_1_18_1
try {
@@ -20,7 +20,11 @@
package com.seibel.lod.fabric.mixins;
import com.mojang.blaze3d.vertex.PoseStack;
#if PRE_MC_1_19_3
import com.mojang.math.Matrix4f;
#else
import org.joml.Matrix4f;
#endif
import com.seibel.lod.common.Config;
import com.seibel.lod.common.wrappers.McObjectConverter;
import com.seibel.lod.core.api.ClientApi;
@@ -89,7 +93,7 @@ public class MixinWorldRenderer
callback.cancel();
}
}
#else
#elif PRE_MC_1_19_3
@Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
// get the partial ticks since renderChunkLayer doesn't
@@ -114,5 +118,30 @@ public class MixinWorldRenderer
callback.cancel();
}
}
#else
@Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
// get the partial ticks since renderChunkLayer doesn't
// have access to them
previousPartialTicks = tickDelta;
}
@Inject(at = @At("HEAD"),
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V",
cancellable = true)
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback)
{
// only render before solid blocks
if (renderType.equals(RenderType.solid()))
{
Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose());
Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
}
if (Config.Client.Advanced.lodOnlyMode) {
callback.cancel();
}
}
#endif
}
@@ -20,7 +20,11 @@
package com.seibel.lod.forge.mixins;
import com.mojang.blaze3d.vertex.PoseStack;
#if PRE_MC_1_19_3
import com.mojang.math.Matrix4f;
#else
import org.joml.Matrix4f;
#endif
import com.seibel.lod.common.Config;
import com.seibel.lod.common.wrappers.McObjectConverter;
import com.seibel.lod.core.api.ClientApi;
@@ -85,7 +89,7 @@ public class MixinWorldRenderer
callback.cancel();
}
}
#else
#elif PRE_MC_1_19_3
@Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
// get the partial ticks since renderChunkLayer doesn't
@@ -110,5 +114,30 @@ public class MixinWorldRenderer
callback.cancel();
}
}
#else
@Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
// get the partial ticks since renderChunkLayer doesn't
// have access to them
previousPartialTicks = tickDelta;
}
@Inject(at = @At("HEAD"),
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V",
cancellable = true)
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback)
{
// only render before solid blocks
if (renderType.equals(RenderType.solid()))
{
Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose());
Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
}
if (Config.Client.Advanced.lodOnlyMode) {
callback.cancel();
}
}
#endif
}
-18
View File
@@ -1,18 +0,0 @@
@echo off
SETLOCAL
CALL :buildVersion "1.19"
CALL :buildVersion "1.18.2"
CALL :buildVersion "1.18.1"
CALL :buildVersion "1.17.1"
CALL :buildVersion "1.16.5"
EXIT /B %ERRORLEVEL%
:buildVersion
@echo on
call ./gradlew.bat clean -PmcVer="%~1" --no-daemon
call ./gradlew.bat core:build -PmcVer="%~1" --no-daemon
call ./gradlew.bat build -PmcVer="%~1" --no-daemon
call ./gradlew.bat mergeJars -PmcVer="%~1" --no-daemon
@echo off
EXIT /B 0