diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index e6b7a0087..5966071c8 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -357,8 +357,8 @@ if (isNotCommonProject) { // JVM args runTask.jvmArgs( "-Dio.netty.leakDetection.level=advanced", - "-XX:+UseZGC", - "-XX:+ZGenerational", + //"-XX:+UseZGC", + //"-XX:+ZGenerational", ) if (isClient) { runTask.jvmArgs( diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java index e28f25fd5..4f04819d0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java @@ -4,6 +4,7 @@ import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; import com.seibel.distanthorizons.core.api.internal.ServerApi; import com.seibel.distanthorizons.core.api.internal.SharedApi; +import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.chunk.ChunkAccess; @@ -17,8 +18,18 @@ public class MixinChunkMapCommon { IServerLevelWrapper levelWrapper = ServerLevelWrapper.getWrapper(level); + int chunkPosX; + int chunkPosZ; + #if MC_VER <= MC_1_21_11 + chunkPosX = chunk.getPos().x; + chunkPosZ = chunk.getPos().z; + #else + chunkPosX = chunk.getPos().x(); + chunkPosZ = chunk.getPos().z(); + #endif + // is this position already being updated? - if (SharedApi.isChunkAtChunkPosAlreadyUpdating(levelWrapper, chunk.getPos().x, chunk.getPos().z)) + if (SharedApi.isChunkAtChunkPosAlreadyUpdating(levelWrapper, chunkPosX, chunkPosZ)) { return; } @@ -39,7 +50,7 @@ public class MixinChunkMapCommon // MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks) // this logic should prevent that from happening - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_17_1 if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect()) { return; @@ -56,7 +67,7 @@ public class MixinChunkMapCommon // biome validation // // some chunks may be missing their biomes, which cause issues when attempting to save them - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_17_1 if (chunk.getBiomes() == null) { return; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFarFadeRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFarFadeRenderer.java index 75d819d71..6faa8a1fe 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFarFadeRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFarFadeRenderer.java @@ -100,10 +100,10 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder(); { pipelineBuilder.withCull(false); - pipelineBuilder.withDepthWrite(false); - pipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST); - pipelineBuilder.withColorWrite(true); - pipelineBuilder.withoutBlend(); + //pipelineBuilder.withDepthWrite(false); + //pipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST); + //pipelineBuilder.withColorWrite(true); + //pipelineBuilder.withoutBlend(); pipelineBuilder.withPolygonMode(PolygonMode.FILL); pipelineBuilder.withLocation(Identifier.parse("distanthorizons:far_fade")); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFogRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFogRenderer.java index 94a7400c9..1157a2801 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFogRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFogRenderer.java @@ -121,10 +121,10 @@ public class BlazeDhFogRenderer implements IDhFogRenderer RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder(); { pipelineBuilder.withCull(false); - pipelineBuilder.withDepthWrite(false); - pipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST); - pipelineBuilder.withColorWrite(true); - pipelineBuilder.withoutBlend(); + //pipelineBuilder.withDepthWrite(false); + //pipelineBuilder.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST); + //pipelineBuilder.withColorWrite(true); + //pipelineBuilder.withoutBlend(); pipelineBuilder.withPolygonMode(PolygonMode.FILL); pipelineBuilder.withLocation(Identifier.parse("distanthorizons:fog_render")); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/util/BlazeDhVertexFormatUtil.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/util/BlazeDhVertexFormatUtil.java index 5de6f3be2..f7ef4e83b 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/util/BlazeDhVertexFormatUtil.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/util/BlazeDhVertexFormatUtil.java @@ -57,18 +57,18 @@ public class BlazeDhVertexFormatUtil try { - SCREEN_POS = VertexFormatElement.register(/*id*/22, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.POSITION, /*count*/ 2); - RGBA_FLOAT_COLOR = VertexFormatElement.register(/*id*/23, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.COLOR, /*count*/ 4); + SCREEN_POS = null;//VertexFormatElement.register(/*id*/22, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.POSITION, /*count*/ 2); + RGBA_FLOAT_COLOR = null;//VertexFormatElement.register(/*id*/23, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.COLOR, /*count*/ 4); - SHORT_XYZ_POS = VertexFormatElement.register(/*id*/24, /*index*/0, VertexFormatElement.Type.USHORT, VertexFormatElement.Usage.POSITION, /*count*/ 3); - BYTE_PAD = VertexFormatElement.register(/*id*/25, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1); + SHORT_XYZ_POS = null;//VertexFormatElement.register(/*id*/24, /*index*/0, VertexFormatElement.Type.USHORT, VertexFormatElement.Usage.POSITION, /*count*/ 3); + BYTE_PAD = null;//VertexFormatElement.register(/*id*/25, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1); - META = VertexFormatElement.register(/*id*/26, /*index*/0, VertexFormatElement.Type.USHORT, VertexFormatElement.Usage.GENERIC, /*count*/ 1); - RGBA_UBYTE_COLOR = VertexFormatElement.register(/*id*/27, /*index*/0, VertexFormatElement.Type.UBYTE, VertexFormatElement.Usage.COLOR, /*count*/ 4); - IRIS_MATERIAL = VertexFormatElement.register(/*id*/28, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1); - IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1); + META = null;//VertexFormatElement.register(/*id*/26, /*index*/0, VertexFormatElement.Type.USHORT, VertexFormatElement.Usage.GENERIC, /*count*/ 1); + RGBA_UBYTE_COLOR = null;//VertexFormatElement.register(/*id*/27, /*index*/0, VertexFormatElement.Type.UBYTE, VertexFormatElement.Usage.COLOR, /*count*/ 4); + IRIS_MATERIAL = null;//VertexFormatElement.register(/*id*/28, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1); + IRIS_NORMAL = null;//VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1); - FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.POSITION, /*count*/ 3); + FLOAT_XYZ_POS = null;//VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.POSITION, /*count*/ 3); } catch (Exception e) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java index 4eba1f648..cff8c85e7 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java @@ -139,7 +139,16 @@ public class McObjectConverter } public static BlockPos Convert(DhBlockPos wrappedPos) { return new BlockPos(wrappedPos.getX(), wrappedPos.getY(), wrappedPos.getZ()); } + public static ChunkPos Convert(DhChunkPos wrappedPos) { return new ChunkPos(wrappedPos.getX(), wrappedPos.getZ()); } + public static DhChunkPos Convert(ChunkPos mcPos) + { + #if MC_VER <= MC_1_21_11 + return new DhChunkPos(mcPos.x, mcPos.z); + #else + return new DhChunkPos(mcPos.x(), mcPos.z()); + #endif + } public static Direction Convert(EDhDirection lodDirection) { return directions[lodDirection.ordinal()]; } public static EDhDirection Convert(Direction direction) { return lodDirections[direction.ordinal()]; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java index 1253f9131..f147aeea9 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java @@ -49,6 +49,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; +import net.minecraft.core.component.DataComponentMap; #endif import net.minecraft.world.level.biome.Biome; @@ -221,17 +222,17 @@ public class BiomeWrapper implements IBiomeWrapper Level level = (Level)levelWrapper.getWrappedMcObject(); net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); - #if MC_VER < MC_1_21_11 + #if MC_VER <= MC_1_21_10 ResourceLocation resourceLocation; #else Identifier resourceLocation; #endif - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_17_1 resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome); - #elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2 + #elif MC_VER <= MC_1_19_2 resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome.value()); - #elif MC_VER < MC_1_21_3 + #elif MC_VER <= MC_1_21_4 resourceLocation = registryAccess.registryOrThrow(Registries.BIOME).getKey(this.biome.value()); #else resourceLocation = registryAccess.lookupOrThrow(Registries.BIOME).getKey(this.biome.value()); @@ -240,7 +241,7 @@ public class BiomeWrapper implements IBiomeWrapper if (resourceLocation == null) { String biomeName; - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_17_1 biomeName = this.biome.toString(); #else biomeName = this.biome.value().toString(); @@ -354,18 +355,18 @@ public class BiomeWrapper implements IBiomeWrapper boolean success; - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_17_1 Biome biome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation); success = (biome != null); - #elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2 + #elif MC_VER <= MC_1_19_2 Biome unwrappedBiome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation); success = (unwrappedBiome != null); Holder biome = new Holder.Direct<>(unwrappedBiome); - #elif MC_VER < MC_1_21_3 + #elif MC_VER <= MC_1_21_4 Biome unwrappedBiome = registryAccess.registryOrThrow(Registries.BIOME).get(resourceLocation); success = (unwrappedBiome != null); Holder biome = new Holder.Direct<>(unwrappedBiome); - #else + #elif MC_VER <= MC_1_21_11 Holder biome; Optional> optionalBiomeHolder = registryAccess.lookupOrThrow(Registries.BIOME).get(resourceLocation); if (optionalBiomeHolder.isPresent()) @@ -379,6 +380,20 @@ public class BiomeWrapper implements IBiomeWrapper success = false; biome = null; } + #else + Holder biome; + Optional> optionalBiomeHolder = registryAccess.lookupOrThrow(Registries.BIOME).get(resourceLocation); + if (optionalBiomeHolder.isPresent()) + { + Biome unwrappedBiome = optionalBiomeHolder.get().value(); + success = (unwrappedBiome != null); + biome = new Holder.Direct<>(unwrappedBiome, DataComponentMap.EMPTY); + } + else + { + success = false; + biome = null; + } #endif return new BiomeDeserializeResult(success, biome); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index b34a1c228..fcdcdb2c1 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -214,7 +214,14 @@ public class BlockStateWrapper implements IBlockStateWrapper if (blockState != null) { // check if this block has any tags - Stream> tags = blockState.getTags(); + + Stream> tags; + #if MC_VER <= MC_1_21_11 + tags = blockState.getTags(); + #else + tags = blockState.tags(); + #endif + this.isBeaconBaseBlock = tags.anyMatch((TagKey tag) -> tag.location().getPath().toLowerCase().contains("beacon_base_blocks")); } else @@ -667,22 +674,23 @@ public class BlockStateWrapper implements IBlockStateWrapper // older versions of MC have a static registry - #if MC_VER > MC_1_17_1 + #if MC_VER <= MC_1_16_5 + #else Level level = (Level)levelWrapper.getWrappedMcObject(); net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); #endif - #if MC_VER < MC_1_21_11 + #if MC_VER <= MC_1_21_10 ResourceLocation resourceLocation; #else Identifier resourceLocation; #endif - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_17_1 resourceLocation = Registry.BLOCK.getKey(this.blockState.getBlock()); - #elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2 + #elif MC_VER <= MC_1_19_2 resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(this.blockState.getBlock()); - #elif MC_VER < MC_1_21_3 + #elif MC_VER <= MC_1_21_4 resourceLocation = registryAccess.registryOrThrow(Registries.BLOCK).getKey(this.blockState.getBlock()); #else resourceLocation = registryAccess.lookupOrThrow(Registries.BLOCK).getKey(this.blockState.getBlock()); @@ -771,18 +779,19 @@ public class BlockStateWrapper implements IBlockStateWrapper try { - #if MC_VER > MC_1_17_1 + #if MC_VER <= MC_1_16_5 + #else LodUtil.assertTrue(levelWrapper != null && levelWrapper.getWrappedMcObject() != null); Level level = (Level)levelWrapper.getWrappedMcObject(); #endif Block block; - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_17_1 block = Registry.BLOCK.get(resourceLocation); - #elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2 + #elif MC_VER <= MC_1_19_2 net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); block = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).get(resourceLocation); - #elif MC_VER < MC_1_21_3 + #elif MC_VER <= MC_1_21_4 net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); block = registryAccess.registryOrThrow(Registries.BLOCK).get(resourceLocation); #else diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index b2fe09cb2..48f4caf95 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -46,6 +46,7 @@ import java.util.List; import java.util.concurrent.locks.ReentrantLock; #if MC_VER < MC_1_21_5 +import net.minecraft.client.renderer.block.model.BakedQuad; #elif MC_VER <= MC_1_21_11 import net.minecraft.client.renderer.block.model.BlockModelPart; import net.minecraft.client.renderer.block.model.BakedQuad; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TextureAtlasSpriteWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TextureAtlasSpriteWrapper.java index 6d89fb043..81c441c30 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TextureAtlasSpriteWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TextureAtlasSpriteWrapper.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.block; +import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import net.minecraft.client.renderer.texture.TextureAtlasSprite; #if MC_VER < MC_1_17_1 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintGetterOverride.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintGetterOverride.java index f55d1a59e..1e9bfb0e4 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintGetterOverride.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintGetterOverride.java @@ -63,8 +63,10 @@ public class TintGetterOverride extends AbstractDhTintGetter // methods // //=========// + #if MC_VER <= MC_1_21_11 @Override public float getShade(Direction direction, boolean bl) { return this.parent.getShade(direction, bl); } + #endif @Override public LevelLightEngine getLightEngine() { return this.parent.getLightEngine(); } @@ -175,6 +177,13 @@ public class TintGetterOverride extends AbstractDhTintGetter @Override public int getSectionYFromSectionIndex(int i) { return this.parent.getSectionYFromSectionIndex(i); } + #endif + + + #if MC_VER <= MC_1_21_11 + #else + @Override + public CardinalLighting cardinalLighting() { return CardinalLighting.DEFAULT; } #endif diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java index a613bed4f..406b625c7 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java @@ -19,8 +19,6 @@ package com.seibel.distanthorizons.common.wrappers.block; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; -import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.LevelReader; @@ -30,6 +28,12 @@ import net.minecraft.world.level.lighting.LevelLightEngine; import net.minecraft.world.level.material.FluidState; import org.jetbrains.annotations.Nullable; +#if MC_VER <= MC_1_21_11 +#else +import net.minecraft.world.level.CardinalLighting; +#endif + + public class TintWithoutLevelOverrider extends AbstractDhTintGetter { @@ -46,9 +50,12 @@ public class TintWithoutLevelOverrider extends AbstractDhTintGetter // methods // //=========// + #if MC_VER <= MC_1_21_11 @Override public float getShade(Direction direction, boolean shade) { throw new UnsupportedOperationException("ERROR: getShade() called on TintWithoutLevelOverrider. Object is for tinting only."); } + #endif + @Override public LevelLightEngine getLightEngine() { throw new UnsupportedOperationException("ERROR: getLightEngine() called on TintWithoutLevelOverrider. Object is for tinting only."); } @@ -87,4 +94,18 @@ public class TintWithoutLevelOverrider extends AbstractDhTintGetter #endif + + //=================// + // post MC 1.21.11 // + //=================// + + #if MC_VER <= MC_1_21_11 + #else + @Override + public CardinalLighting cardinalLighting() + { throw new UnsupportedOperationException("ERROR: cardinalLighting() called on TintWithoutLevelOverrider. Object is for tinting only."); } + #endif + + + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java index 9a6e13199..022c3fb93 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java @@ -122,7 +122,12 @@ public class ChunkWrapper implements IChunkWrapper { this.chunk = chunk; this.wrappedLevel = wrappedLevel; + + #if MC_VER <= MC_1_21_11 this.chunkPos = new DhChunkPos(chunk.getPos().x, chunk.getPos().z); + #else + this.chunkPos = new DhChunkPos(chunk.getPos().x(), chunk.getPos().z()); + #endif } @Override diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java index 5d4f83240..92da56ae0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java @@ -46,8 +46,10 @@ import org.jetbrains.annotations.Nullable; #if MC_VER < MC_1_20_1 import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.GuiComponent; -#else +#elif MC_VER <= MC_1_21_11 import net.minecraft.client.gui.GuiGraphics; +#else +import net.minecraft.client.gui.GuiGraphicsExtractor; #endif #if MC_VER >= MC_1_17_1 @@ -581,7 +583,7 @@ public class ClassicConfigGUI widget.insertText(String.valueOf(configEntry.get())); Predicate processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton); - widget.setFilter(processor); + //widget.setFilter(processor); this.configListWidget.addButton(this, configEntry, widget, resetButton, null, textComponent); @@ -698,17 +700,26 @@ public class ClassicConfigGUI @Override #if MC_VER < MC_1_20_1 public void render(PoseStack matrices, int mouseX, int mouseY, float delta) - #else + #elif MC_VER <= MC_1_21_11 public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta) + #else + public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { #if MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function - this.renderBackground(matrices); // Renders background - #else + this.renderBackground(matrices); + #elif MC_VER <= MC_1_21_11 super.render(matrices, mouseX, mouseY, delta); + #else + super.extractRenderState(matrices, mouseX, mouseY, delta); #endif - this.configListWidget.render(matrices, mouseX, mouseY, delta); // Render buttons + // Render buttons + #if MC_VER <= MC_1_21_11 + this.configListWidget.render(matrices, mouseX, mouseY, delta); + #else + this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta); + #endif // Render config title @@ -751,7 +762,7 @@ public class ClassicConfigGUI #if MC_VER < MC_1_20_1 private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta) #else - private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta) + private void renderTooltip(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY); @@ -953,8 +964,10 @@ public class ClassicConfigGUI public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) #elif MC_VER < MC_1_21_9 public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) - #else + #elif MC_VER <= MC_1_21_11 public void renderContent(GuiGraphics matrices, int mouseX, int mouseY, boolean hovered, float tickDelta) + #else + public void extractContent(GuiGraphicsExtractor matrices, int mouseX, int mouseY, boolean hovered, float tickDelta) #endif { try @@ -973,19 +986,31 @@ public class ClassicConfigGUI if (this.button != null) { SetY(this.button, y); + #if MC_VER <= MC_1_21_11 this.button.render(matrices, mouseX, mouseY, tickDelta); + #else + this.button.extractRenderState(matrices, mouseX, mouseY, tickDelta); + #endif } if (this.resetButton != null) { SetY(this.resetButton, y); + #if MC_VER <= MC_1_21_11 this.resetButton.render(matrices, mouseX, mouseY, tickDelta); + #else + this.resetButton.extractRenderState(matrices, mouseX, mouseY, tickDelta); + #endif } if (this.indexButton != null) { SetY(this.indexButton, y); + #if MC_VER <= MC_1_21_11 this.indexButton.render(matrices, mouseX, mouseY, tickDelta); + #else + this.indexButton.extractRenderState(matrices, mouseX, mouseY, tickDelta); + #endif } if (this.text != null) @@ -1034,11 +1059,16 @@ public class ClassicConfigGUI this.text, textXPos, y + 5, 0xFFFFFF); - #else + #elif MC_VER <= MC_1_21_11 matrices.drawString(textRenderer, this.text, textXPos, y + 5, 0xFFFFFFFF); + #else + matrices.text(textRenderer, + this.text, + textXPos, y + 5, + 0xFFFFFFFF); #endif } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhDebugScreenEntry.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhDebugScreenEntry.java index 775e7c5f1..4a06bc23d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhDebugScreenEntry.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhDebugScreenEntry.java @@ -3,6 +3,7 @@ package com.seibel.distanthorizons.common.wrappers.gui; #if MC_VER < MC_1_21_9 // not supported for older MC versions #else + import com.seibel.distanthorizons.core.logging.f3.F3Screen; import com.seibel.distanthorizons.coreapi.ModInfo; @@ -19,6 +20,8 @@ import net.minecraft.world.level.chunk.LevelChunk; #if MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; +#else +import net.minecraft.resources.Identifier; #endif #endif @@ -32,6 +35,7 @@ public class DhDebugScreenEntry implements net.minecraft.client.gui.components.d { public static void register() { + #if MC_VER <= MC_1_21_11 // This method is private, so its access will need to be widened DebugScreenEntries.register( // The id, this will be displayed on the options screen @@ -44,6 +48,15 @@ public class DhDebugScreenEntry implements net.minecraft.client.gui.components.d // The screen entry new DhDebugScreenEntry() ); + #else + DebugScreenEntries.allEntries().put( + // The id, this will be displayed on the options screen + Identifier.fromNamespaceAndPath(ModInfo.RESOURCE_NAMESPACE, "distant_horizons"), + + // The screen entry + new DhDebugScreenEntry() + ); + #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java index 34ce892b1..b2f4f3571 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java @@ -1,15 +1,19 @@ package com.seibel.distanthorizons.common.wrappers.gui; import net.minecraft.client.gui.Font; -#if MC_VER < MC_1_20_1 -import com.mojang.blaze3d.vertex.PoseStack; -#else -import net.minecraft.client.gui.GuiGraphics; -#endif + import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; +#if MC_VER < MC_1_20_1 +import com.mojang.blaze3d.vertex.PoseStack; +#elif MC_VER <= MC_1_21_11 +import net.minecraft.client.gui.GuiGraphics; +#else +import net.minecraft.client.gui.GuiGraphicsExtractor; +#endif + import java.util.List; public class DhScreen extends Screen @@ -73,7 +77,7 @@ public class DhScreen extends Screen { guiStack.renderTooltip(font, text, x, y); } - #else + #elif MC_VER <= MC_1_21_11 protected void DhDrawCenteredString(GuiGraphics guiStack, Font font, Component text, int x, int y, int color) { guiStack.drawCenteredString(font, text, x, y, color); @@ -82,10 +86,6 @@ public class DhScreen extends Screen { guiStack.drawString(font, text, x, y, color); } - //protected void DhRenderTooltip(GuiGraphics guiStack, Font font, List text, int x, int y) - //{ - // //guiStack.renderTooltip(font, text, x, y); - //} protected void DhRenderComponentTooltip(GuiGraphics guiStack, Font font, List comp, int x, int y) { guiStack.setComponentTooltipForNextFrame(font, comp, x, y); @@ -94,6 +94,23 @@ public class DhScreen extends Screen { guiStack.setTooltipForNextFrame(font, text, x, y); } + #else + protected void DhDrawCenteredString(GuiGraphicsExtractor guiStack, Font font, Component text, int x, int y, int color) + { + guiStack.centeredText(font, text, x, y, color); + } + protected void DhDrawString(GuiGraphicsExtractor guiStack, Font font, Component text, int x, int y, int color) + { + guiStack.text(font, text, x, y, color); + } + protected void DhRenderComponentTooltip(GuiGraphicsExtractor guiStack, Font font, List comp, int x, int y) + { + guiStack.setComponentTooltipForNextFrame(font, comp, x, y); + } + protected void DhRenderTooltip(GuiGraphicsExtractor guiStack, Font font, Component text, int x, int y) + { + guiStack.setTooltipForNextFrame(font, text, x, y); + } #endif diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java index 7b35a173f..9e1f4ae30 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java @@ -1,16 +1,24 @@ package com.seibel.distanthorizons.common.wrappers.gui; import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.vertex.PoseStack; + + import com.seibel.distanthorizons.core.config.gui.AbstractScreen; + import net.minecraft.client.Minecraft; -#if MC_VER >= MC_1_20_1 -import net.minecraft.client.gui.GuiGraphics; -#endif import net.minecraft.client.gui.components.ContainerObjectSelectionList; import net.minecraft.client.gui.screens.Screen; + import org.jetbrains.annotations.NotNull; +#if MC_VER < MC_1_20_1 +import com.mojang.blaze3d.vertex.PoseStack; +#elif MC_VER <= MC_1_21_11 +import net.minecraft.client.gui.GuiGraphics; +#else +import net.minecraft.client.gui.GuiGraphicsExtractor; +#endif + import java.nio.file.Path; import java.util.*; @@ -74,8 +82,10 @@ public class MinecraftScreen @Override #if MC_VER < MC_1_20_1 public void render(PoseStack matrices, int mouseX, int mouseY, float delta) - #else + #elif MC_VER <= MC_1_21_11 public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta) + #else + public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { #if MC_VER < MC_1_20_2 @@ -86,13 +96,21 @@ public class MinecraftScreen // background blur is already being rendered, rendering again causes the game to crash #endif + #if MC_VER <= MC_1_21_11 this.configListWidget.render(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker) - + #else + this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker) + #endif + this.screen.mouseX = mouseX; this.screen.mouseY = mouseY; this.screen.render(delta); // Render everything on the main screen + #if MC_VER <= MC_1_21_11 super.render(matrices, mouseX, mouseY, delta); // Render the vanilla stuff (currently only used for the background and tint) + #else + super.extractRenderState(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker) + #endif } #if MC_VER <= MC_1_21_10 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java index c83a91ee5..436daa73f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java @@ -45,9 +45,12 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderPipelines; -#else +#elif MC_VER <= MC_1_21_11 import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.RenderPipelines; +#else +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.renderer.RenderPipelines; #endif #if MC_VER <= MC_1_21_10 @@ -196,9 +199,12 @@ public class TexturedButtonWidget extends Button #if MC_VER < MC_1_21_11 @Override public void renderWidget(GuiGraphics matrices, int mouseX, int mouseY, float delta) - #else + #elif MC_VER <= MC_1_21_11 @Override protected void renderContents(GuiGraphics matrices, int mouseX, int mouseY, float delta) + #else + @Override + protected void extractContents(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { if (this.renderBackground) @@ -212,11 +218,11 @@ public class TexturedButtonWidget extends Button this.getX(), this.getY(), this.getWidth(), this.getHeight()); #else - matrices.blitSprite( - RenderPipelines.GUI_TEXTURED, - SPRITES.get(this.active, this.isHoveredOrFocused()), - this.getX(), this.getY(), - this.getWidth(), this.getHeight()); + //matrices.blitSprite( + // RenderPipelines.GUI_TEXTURED, + // SPRITES.get(this.active, this.isHoveredOrFocused()), + // this.getX(), this.getY(), + // this.getWidth(), this.getHeight()); #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java index d234b960c..c578c0451 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java @@ -23,8 +23,10 @@ import net.minecraft.client.gui.narration.NarratableEntry; #if MC_VER < MC_1_20_1 import net.minecraft.client.gui.GuiComponent; import com.mojang.blaze3d.vertex.PoseStack; -#else +#elif MC_VER <= MC_1_21_11 import net.minecraft.client.gui.GuiGraphics; +#else +import net.minecraft.client.gui.GuiGraphicsExtractor; #endif @@ -168,8 +170,10 @@ public class ChangelogScreen extends DhScreen @Override #if MC_VER < MC_1_20_1 public void render(PoseStack matrices, int mouseX, int mouseY, float delta) - #else + #elif MC_VER <= MC_1_21_11 public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta) + #else + public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { #if MC_VER < MC_1_20_2 @@ -206,8 +210,14 @@ public class ChangelogScreen extends DhScreen // render order matters, otherwise on 1.20.6+ the blurred background will render on top of the text + #if MC_VER <= MC_1_21_11 super.render(matrices, mouseX, mouseY, delta); // Render the buttons this.changelogArea.render(matrices, mouseX, mouseY, delta); // Render the changelog + #else + super.extractRenderState(matrices, mouseX, mouseY, delta); // Render the buttons + this.changelogArea.extractRenderState(matrices, mouseX, mouseY, delta); // Render the changelog + #endif + this.DhDrawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 0xFFFFFF); // Render title } @@ -264,10 +274,14 @@ public class ChangelogScreen extends DhScreen @Override public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { matrices.drawString(textRenderer, this.text, 12, y + 5, 0xFFFFFF); } - #else + #elif MC_VER <= MC_1_21_11 @Override public void renderContent(GuiGraphics matrices, int y, int x, boolean hovered, float tickDelta) { matrices.drawString(textRenderer, this.text, 12, y + 5, 0xFFFFFF); } + #else + @Override + public void extractContent(GuiGraphicsExtractor matrices, int y, int x, boolean hovered, float tickDelta) + { matrices.text(textRenderer, this.text, 12, y + 5, 0xFFFFFF); } #endif @Override diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java index 5fe7872e5..077567c83 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java @@ -13,10 +13,12 @@ import com.seibel.distanthorizons.core.logging.DhLogger; import net.minecraft.client.gui.screens.Screen; -#if MC_VER >= MC_1_20_1 +#if MC_VER < MC_1_20_1 +import com.mojang.blaze3d.vertex.PoseStack; +#elif MC_VER <= MC_1_21_11 import net.minecraft.client.gui.GuiGraphics; #else -import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiGraphicsExtractor; #endif #if MC_VER <= MC_1_21_10 @@ -172,8 +174,10 @@ public class UpdateModScreen extends DhScreen @Override #if MC_VER < MC_1_20_1 public void render(PoseStack matrices, int mouseX, int mouseY, float delta) - #else + #elif MC_VER <= MC_1_21_11 public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta) + #else + public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { #if MC_VER < MC_1_20_2 @@ -184,8 +188,12 @@ public class UpdateModScreen extends DhScreen // background blur is already being rendered, rendering again causes the game to crash #endif + #if MC_VER <= MC_1_21_11 super.render(matrices, mouseX, mouseY, delta); // Render the buttons - + #else + super.extractRenderState(matrices, mouseX, mouseY, delta); + #endif + // Render the text's this.DhDrawCenteredString(matrices, this.font, Translatable(ModInfo.ID + ".updater.text1"), diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java index 3e7dd09f9..408ba1d15 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -172,7 +172,12 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra #else ChunkPos playerPos = player.chunkPosition(); #endif + + #if MC_VER <= MC_1_21_11 return new DhChunkPos(playerPos.x, playerPos.z); + #else + return new DhChunkPos(playerPos.x(), playerPos.z()); + #endif } //endregion @@ -227,7 +232,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("MinecraftClientWrapper sendChatMessage", () -> { + #if MC_VER <= MC_1_21_11 player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/false); + #else + player.sendSystemMessage(net.minecraft.network.chat.Component.translatable(string)); + #endif }); #endif } @@ -243,8 +252,10 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra #if MC_VER < MC_1_19_2 player.displayClientMessage(new TextComponent(string), /*isOverlay*/true); - #else + #elif MC_VER <= MC_1_21_11 player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/true); + #else + player.sendOverlayMessage(net.minecraft.network.chat.Component.translatable(string)); #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index fede80a71..e5388b07d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -182,8 +182,10 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper return MC.getFrameTime(); #elif MC_VER < MC_1_21_3 return MC.getTimer().getRealtimeDeltaTicks(); - #else + #elif MC_VER <= MC_1_21_11 return MC.deltaTracker.getRealtimeDeltaTicks(); + #else + return MC.getDeltaTracker().getRealtimeDeltaTicks(); #endif } @@ -513,7 +515,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper if (MC.level != null) { Direction mcDir = McObjectConverter.Convert(lodDirection); + #if MC_VER <= MC_1_21_11 return MC.level.getShade(mcDir, true); + #else + return MC.level.cardinalLighting().byFace(mcDir); + #endif } else { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java index a0feb826f..a15a5fb79 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java @@ -1,6 +1,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration; import com.seibel.distanthorizons.api.DhApi; +import com.seibel.distanthorizons.common.wrappers.McObjectConverter; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.GlobalWorldGenParams; import com.seibel.distanthorizons.core.api.internal.ClientApi; @@ -245,7 +246,7 @@ public class InternalServerGenerator // ignore chunk update events for this position if (this.updateManager != null) { - this.updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x, chunkPos.z)); + this.updateManager.addPosToIgnore(McObjectConverter.Convert(chunkPos)); } #if MC_VER < MC_1_21_5 @@ -258,7 +259,10 @@ public class InternalServerGenerator // probably not the most optimal to run updates here, but fast enough level.getChunkSource().distanceManager.runAllUpdates(level.getChunkSource().chunkMap); - ChunkHolder chunkHolder = level.getChunkSource().chunkMap.getUpdatingChunkIfPresent(chunkPos.toLong()); + ChunkHolder chunkHolder = level.getChunkSource().chunkMap + .getUpdatingChunkIfPresent( + #if MC_VER <= MC_1_21_11 chunkPos.toLong() #else chunkPos.pack() #endif + ); if (chunkHolder == null) { throw new IllegalStateException("No chunk chunkHolder for pos ["+chunkPos+"] after ticket has been added."); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkCompoundTagParser.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkCompoundTagParser.java index 4ffef0959..f19e145d5 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkCompoundTagParser.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkCompoundTagParser.java @@ -20,12 +20,14 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling; import com.mojang.serialization.Codec; +import com.seibel.distanthorizons.common.wrappers.McObjectConverter; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.level.IDhServerLevel; import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; +import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.ChunkLightStorage; @@ -673,7 +675,9 @@ public class ChunkCompoundTagParser { LOGGED_ERROR_MESSAGE_MAP.computeIfAbsent(message, (newMessage) -> { - LOGGER.warn("Unable to deserialize blocks for chunk section [" + chunkPos.x + ", " + sectionYIndex + ", " + chunkPos.z + "], error: ["+newMessage+"]. " + + DhChunkPos dhChunkPos = McObjectConverter.Convert(chunkPos); + + LOGGER.warn("Unable to deserialize blocks for chunk section [" + dhChunkPos.getX() + ", " + sectionYIndex + ", " + dhChunkPos.getZ() + "], error: ["+newMessage+"]. " + "This can probably be ignored, although if your world looks wrong, optimizing it via the single player menu then deleting your DH database(s) should fix the problem."); return newMessage; @@ -683,7 +687,9 @@ public class ChunkCompoundTagParser { LOGGED_ERROR_MESSAGE_MAP.computeIfAbsent(message, (newMessage) -> { - LOGGER.warn("Unable to deserialize biomes for chunk section [" + chunkPos.x + ", " + sectionYIndex + ", " + chunkPos.z + "], error: ["+newMessage+"]. " + + DhChunkPos dhChunkPos = McObjectConverter.Convert(chunkPos); + + LOGGER.warn("Unable to deserialize biomes for chunk section [" + dhChunkPos.getX() + ", " + sectionYIndex + ", " + dhChunkPos.getZ() + "], error: ["+newMessage+"]. " + "This can probably be ignored, although if your world looks wrong, optimizing it via the single player menu then deleting your DH database(s) should fix the problem."); return newMessage; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java index dcd9a36a0..c58b181f8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java @@ -22,9 +22,12 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject; import java.lang.invoke.MethodHandles; import java.util.List; import java.util.concurrent.locks.ReentrantLock; + +import com.seibel.distanthorizons.common.wrappers.McObjectConverter; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; +import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.util.LodUtil; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.SpawnerBlock; @@ -89,7 +92,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion public final int writeRadius; public final int size; - private final ChunkPos firstPos; + private final DhChunkPos firstPos; private final List cache; private final Long2ObjectOpenHashMap chunkMap = new Long2ObjectOpenHashMap(); @@ -149,7 +152,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion centerChunk); #endif - this.firstPos = chunkList.get(0).getPos(); + this.firstPos = McObjectConverter.Convert(chunkList.get(0).getPos()); this.serverLevel = serverLevel; this.generator = generator; this.lightEngine = lightEngine; @@ -165,17 +168,22 @@ public class DhLitWorldGenRegion extends WorldGenRegion @Override public boolean ensureCanWrite(BlockPos blockPos) { - int i = SectionPos.blockToSectionCoord(blockPos.getX()); - int j = SectionPos.blockToSectionCoord(blockPos.getZ()); - ChunkPos chunkPos = this.getCenter(); - ChunkAccess center = this.getChunk(chunkPos.x, chunkPos.z); - int k = Math.abs(chunkPos.x - i); - int l = Math.abs(chunkPos.z - j); - if (k > this.writeRadius || l > this.writeRadius) + DhChunkPos chunkPos = McObjectConverter.Convert(this.getCenter()); + + int sectionCoordX = SectionPos.blockToSectionCoord(blockPos.getX()); + int sectionCoordZ = SectionPos.blockToSectionCoord(blockPos.getZ()); + + // TODO what do these "abs" positions mean? + int absX = Math.abs(chunkPos.getX() - sectionCoordX); + int absZ = Math.abs(chunkPos.getZ() - sectionCoordZ); + if (absX > this.writeRadius + || absZ > this.writeRadius) { return false; } + #if MC_VER >= MC_1_18_2 + ChunkAccess center = this.getChunk(chunkPos.getX(), chunkPos.getZ()); if (center.isUpgrading()) { LevelHeightAccessor levelHeightAccessor = center.getHeightAccessorForGeneration(); @@ -196,6 +204,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion } } #endif + return true; } #endif @@ -401,17 +410,18 @@ public class DhLitWorldGenRegion extends WorldGenRegion /** Use this instead of super.hasChunk() to bypass C2ME concurrency checks */ public boolean superHasChunk(int x, int z) { - int k = x - this.firstPos.x; - int l = z - this.firstPos.z; - return l >= 0 && l < this.size && k >= 0 && k < this.size; + int xOffset = x - this.firstPos.getX(); + int zOffset = z - this.firstPos.getZ(); + return zOffset >= 0 && zOffset < this.size + && xOffset >= 0 && xOffset < this.size; } /** Use this instead of super.getChunk() to bypass C2ME concurrency checks */ private ChunkAccess superGetChunk(int x, int z) { - int k = x - this.firstPos.x; - int l = z - this.firstPos.z; - return this.cache.get(k + l * this.size); + int xOffset = x - this.firstPos.getX(); + int zOffset = z - this.firstPos.getZ(); + return this.cache.get(xOffset + zOffset * this.size); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java index d7b2df37d..ae2fb9b04 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java @@ -69,8 +69,13 @@ public class RegionFileStorageExternalCache implements AutoCloseable } + long chunkPosLong; + #if MC_VER <= MC_1_21_11 + chunkPosLong = ChunkPos.asLong(chunkPos.getRegionX(), chunkPos.getRegionZ()); + #else + chunkPosLong = ChunkPos.pack(chunkPos.getRegionX(), chunkPos.getRegionZ()); + #endif - long chunkPosLong = ChunkPos.asLong(chunkPos.getRegionX(), chunkPos.getRegionZ()); RegionFile regionFile = null; // Check vanilla cache @@ -179,7 +184,7 @@ public class RegionFileStorageExternalCache implements AutoCloseable regionFile = new RegionFile(new RegionStorageInfo("level", null, "level type"), regionFilePath, storageFolderPath, false); #endif - this.regionFileCache.add(new RegionFileCache(ChunkPos.asLong(chunkPos.getRegionX(), chunkPos.getRegionZ()), regionFile)); + this.regionFileCache.add(new RegionFileCache(chunkPosLong, regionFile)); while (this.regionFileCache.size() > MAX_CACHE_SIZE) { this.regionFileCache.poll().file.close(); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java index 558b232c9..2d55f3bdf 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java @@ -28,6 +28,8 @@ import java.util.stream.Stream; import com.google.common.collect.ImmutableList; +import com.seibel.distanthorizons.common.wrappers.McObjectConverter; +import com.seibel.distanthorizons.core.pos.DhChunkPos; import it.unimi.dsi.fastutil.longs.LongSet; import net.minecraft.core.BlockPos; import net.minecraft.core.SectionPos; @@ -222,9 +224,10 @@ public class WorldGenStructFeatManager extends #if MC_VER < MC_1_19_2 StructureF } #else @Override - public List startsForStructure(ChunkPos sectionPos, Predicate predicate) + public List startsForStructure(ChunkPos chunkPos, Predicate predicate) { - ChunkAccess chunk = _getChunk(sectionPos.x, sectionPos.z, ChunkStatus.STRUCTURE_REFERENCES); + DhChunkPos dhChunkPos = McObjectConverter.Convert(chunkPos); + ChunkAccess chunk = _getChunk(dhChunkPos.getX(), dhChunkPos.getZ(), ChunkStatus.STRUCTURE_REFERENCES); if (chunk == null) return List.of(); // Copied from StructureFeatureManager::startsForFeature(...) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/GlobalWorldGenParams.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/GlobalWorldGenParams.java index 2f5b729d0..d3d1fa551 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/GlobalWorldGenParams.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/GlobalWorldGenParams.java @@ -113,10 +113,14 @@ public final class GlobalWorldGenParams this.worldOptions = worldData.worldGenOptions(); this.biomes = registry.registryOrThrow(Registries.BIOME); this.worldSeed = worldOptions.seed(); - #else + #elif MC_VER <= MC_1_21_11 this.worldOptions = worldData.worldGenOptions(); this.biomes = this.registry.lookupOrThrow(Registries.BIOME); this.worldSeed = this.worldOptions.seed(); + #else + this.worldOptions = null;//worldData.worldGenOptions(); + this.biomes = this.registry.lookupOrThrow(Registries.BIOME); + this.worldSeed = this.worldOptions.seed(); #endif #if MC_VER >= MC_1_18_2 diff --git a/gradle.properties b/gradle.properties index 393d8b95d..343a6ad13 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ versionStr= # This defines what MC version Intellij will use for the preprocessor # and what version is used automatically by build and run commands -mcVer=1.26.1 +mcVer=1.21.11 # Defines the maximum amount of memory Minecraft is allowed when run in a development environment #minecraftMemoryJavaArg="-Xmx4G"