diff --git a/CubicChunksCore b/CubicChunksCore index 51399cc8..2140f296 160000 --- a/CubicChunksCore +++ b/CubicChunksCore @@ -1 +1 @@ -Subproject commit 51399cc8ad426108e008ebe2f84a1a0fd45b981e +Subproject commit 2140f296f64fbbb07d304a15741d1466c24889d5 diff --git a/build.gradle.kts b/build.gradle.kts index e4313260..18775ef7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,6 +18,7 @@ plugins { id("io.github.opencubicchunks.gradle.mcGitVersion") id("io.github.opencubicchunks.gradle.mixingen") id("io.github.opencubicchunks.gradle.dasm") + id("io.github.opencubicchunks.stirrin").version("1.3.4") } val minecraftVersion: String by project @@ -28,6 +29,20 @@ val lwjglNatives: String by project val modId: String by project val debugArtifactTransforms: String by project +stirrin { + setAcceptedJars(".*minecraft.*") + setConfigs(setOf( + "cubicchunks.mixins.access.json", + "cubicchunks.mixins.asm.json", + "cubicchunks.mixins.asmfixes.json", + "cubicchunks.mixins.core.json", + "cubicchunks.mixins.debug.json", + "cubicchunks.mixins.levelgen.json", + "cubicchunks.mixins.optifine.json" + )) + setDebug(debugArtifactTransforms.toBoolean()) +} + javaHeaders { setAcceptedJars(".*CubicChunksCore.*") setConfig(file("javaHeaders.json")) @@ -235,6 +250,8 @@ when (OperatingSystem.current()) { } dependencies { + stirrin.addDependency("net.fabricmc:sponge-mixin:0.11.4+mixin.0.8.5") + minecraft("com.mojang:minecraft:${minecraftVersion}") mappings(loom.layered { officialMojangMappings { @@ -256,17 +273,26 @@ dependencies { // } // we shade the core classes directly into CC, so it gets remapped - shade(implementation(project(":CubicChunksCore")) { + shade(implementation(stirrin.addDependency(project(":CubicChunksCore"))) { attributes { attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements::class, LibraryElements.JAR)) } isTransitive = false }) + // To work around an Intellij bug where compile and runtime dependencies of a project differ, causing artifact transforms to run twice on a dependency + // which then creates two jars in the same dependency, resulting in Intellij failing to resolve the classes. + { + stirrin.addDependency("org.jetbrains:annotations:24.0.0") // core dependency + + implementation("com.google.guava:guava:31.1-jre") + implementation("com.google.code.gson:gson:2.9.0") + } + debugCompile("org.lwjgl:lwjgl-vulkan:$lwjglVersion") debugRuntime("org.lwjgl:lwjgl::$lwjglNatives") - include(implementation("com.github.OpenCubicChunks:dasm:81e0a37")!!) + include(implementation("com.github.OpenCubicChunks:dasm:2895c9ccc8")!!) include(implementation("io.github.opencubicchunks:regionlib:0.63.0-SNAPSHOT")!!) include(implementation("org.spongepowered:noise:2.0.0-SNAPSHOT")!!) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f..943f0cbf 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661e..f398c33c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c7873..65dcd68d 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32..93e3f59f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/AnnotationConfigPlugin.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/AnnotationConfigPlugin.java index 1e19ca64..1803aa52 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/AnnotationConfigPlugin.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/AnnotationConfigPlugin.java @@ -2,6 +2,7 @@ import static org.objectweb.asm.Opcodes.*; +import java.util.Iterator; import java.util.List; import java.util.Set; @@ -50,5 +51,15 @@ public AnnotationConfigPlugin() { } @Override public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + // Removing any @StirrinStub annotated methods (our mixins can now create those methods normally) + for (Iterator it = targetClass.methods.iterator(); it.hasNext();) { + MethodNode method = it.next(); + List visibleAnnotations = method.visibleAnnotations; + if (visibleAnnotations != null) { + if (visibleAnnotations.stream().anyMatch(annotationNode -> annotationNode.desc.equals("Lio/github/opencubicchunks/stirrin/StirrinStub;"))) { + it.remove(); + } + } + } } } \ No newline at end of file diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/LoaderMixin.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/LoaderMixin.java deleted file mode 100644 index b9278d3e..00000000 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/LoaderMixin.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.opencubicchunks.cubicchunks.mixin.core; - -import net.minecraft.world.level.levelgen.NoiseRouterData; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin({ - NoiseRouterData.class -}) -public class LoaderMixin { - @Inject(method = "", at = @At("HEAD")) - private static void initializing(CallbackInfo ci) { - System.out.println("Loading Class"); - } -} diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/MixinClientPacketListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/MixinClientPacketListener.java index f01ceabf..a601603f 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/MixinClientPacketListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/MixinClientPacketListener.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.client; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientPacketListener; @@ -24,7 +23,7 @@ public abstract class MixinClientPacketListener { @Redirect(method = "lambda$queueLightUpdate$4(Lnet/minecraft/network/protocol/game/ClientboundForgetLevelChunkPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getMaxSection()I")) private int getFakeMaxSectionY(ClientLevel clientLevel) { - if (!((CubicLevelHeightAccessor) clientLevel).isCubic()) { + if (!clientLevel.isCubic()) { return clientLevel.getMaxSection(); } return clientLevel.getMinSection() - 1; // disable the loop, cube packets do the necessary work @@ -36,7 +35,7 @@ private int getFakeMaxSectionY(ClientLevel clientLevel) { at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;getLightSectionCount()I") ) private int getFakeSectionCount(LevelLightEngine engine) { - if (!((CubicLevelHeightAccessor) getLevel()).isCubic()) { + if (!getLevel().isCubic()) { return engine.getLightSectionCount(); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/MixinOptions.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/MixinOptions.java index 42371f24..1cff9500 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/MixinOptions.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/MixinOptions.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.client; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.CubicChunks; import net.minecraft.client.CloudStatus; import net.minecraft.client.Minecraft; @@ -21,7 +20,7 @@ public class MixinOptions { private void getCloudsTypeForVerticalViewDistance(CallbackInfoReturnable cir) { ClientLevel level = Minecraft.getInstance().level; if (level != null) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return; } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/chunk/MixinLevelChunk.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/chunk/MixinLevelChunk.java index bfede3da..d2aa1083 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/chunk/MixinLevelChunk.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/chunk/MixinLevelChunk.java @@ -53,13 +53,13 @@ public MixinLevelChunk(ChunkPos chunkPos, UpgradeData upgradeData, at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;")) private Object getBlockEntity(Map map, Object key) { if (map == this.blockEntities) { - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { return map.get(key); } LevelCube cube = (LevelCube) ((ColumnCubeGetter) this).getCube(Coords.blockToSection(((BlockPos) key).getY())); return cube.getTileEntityMap().get(key); } else if (map == this.pendingBlockEntities) { - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { return map.get(key); } LevelCube cube = (LevelCube) ((ColumnCubeGetter) this).getCube(Coords.blockToSection(((BlockPos) key).getY())); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/entity/MixinTransientEntitySectionManager.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/entity/MixinTransientEntitySectionManager.java index 0f707037..30e6e723 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/entity/MixinTransientEntitySectionManager.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/entity/MixinTransientEntitySectionManager.java @@ -22,6 +22,6 @@ public class MixinTransientEntitySectionManager implemen @Override public void setIsCubic(boolean isCubic) { this.isCubic = isCubic; - ((IsCubicEntityContext) this.sectionStorage).setIsCubic(isCubic); + this.sectionStorage.setIsCubic(isCubic); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/level/MixinClientChunkCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/level/MixinClientChunkCache.java index e108ae84..cea966bb 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/level/MixinClientChunkCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/level/MixinClientChunkCache.java @@ -48,7 +48,7 @@ public abstract class MixinClientChunkCache implements ClientCubeCache { @Inject(method = "", at = @At("RETURN")) private void onConstruct(ClientLevel clientWorldIn, int viewDistance, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) clientWorldIn).isCubic()) { + if (!clientWorldIn.isCubic()) { return; } @@ -176,7 +176,7 @@ public void updateCubeViewRadius(int hDistance, int vDistance) { */ @Inject(method = "gatherStats", at = @At("HEAD"), cancellable = true) public void gatherStats(CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/level/MixinClientLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/level/MixinClientLevel.java index f62ad90f..e23cd8e9 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/level/MixinClientLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/level/MixinClientLevel.java @@ -67,7 +67,7 @@ public void onCubeLoaded(int cubeX, int cubeY, int cubeZ) { @Redirect(method = "onChunkLoaded", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/entity/TransientEntitySectionManager;startTicking(Lnet/minecraft/world/level/ChunkPos;)V")) private void doNothingOnLoadIfCube(TransientEntitySectionManager transientEntitySectionManager, ChunkPos pos) { - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { transientEntitySectionManager.startTicking(pos); } } @@ -76,7 +76,7 @@ private void doNothingOnLoadIfCube(TransientEntitySectionManager transientEnt @Redirect(method = "unload", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/entity/TransientEntitySectionManager;stopTicking(Lnet/minecraft/world/level/ChunkPos;)V")) private void doNothingOnUnloadIfCube(TransientEntitySectionManager transientEntitySectionManager, ChunkPos pos) { - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { transientEntitySectionManager.stopTicking(pos); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/progress/MixinLevelLoadingScreen.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/progress/MixinLevelLoadingScreen.java index d834cc04..a2b03bb6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/progress/MixinLevelLoadingScreen.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/progress/MixinLevelLoadingScreen.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.client.progress; import com.mojang.blaze3d.vertex.PoseStack; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.client.gui.screens.CubicLevelLoadingScreen; import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.client.Minecraft; @@ -32,7 +31,7 @@ private static void renderCubes(PoseStack mStack, StoringChunkProgressListener t int xBase, int yBase, int scale, int spacing, CallbackInfo ci) { Level level = Minecraft.getInstance().getSingleplayerServer().overworld(); - if (level == null || !((CubicLevelHeightAccessor) level).isCubic()) { + if (level == null || !level.isCubic()) { return; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/progress/MixinStoringChunkProgressListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/progress/MixinStoringChunkProgressListener.java index 7950230f..ef3ce1bd 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/progress/MixinStoringChunkProgressListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/progress/MixinStoringChunkProgressListener.java @@ -33,7 +33,7 @@ public abstract class MixinStoringChunkProgressListener implements CubeProgressL @Override public void startCubes(CubePos spawn) { if (this.started) { - ((CubeProgressListener) this.delegate).startCubes(spawn); + this.delegate.startCubes(spawn); this.spawnCube = spawn; this.spawnPos = spawnCube.asChunkPos(); } @@ -42,7 +42,7 @@ public void startCubes(CubePos spawn) { @Override public void onCubeStatusChange(CubePos cubePos, @Nullable ChunkStatus newStatus) { if (this.started) { - ((CubeProgressListener) this.delegate).onCubeStatusChange(cubePos, newStatus); + this.delegate.onCubeStatusChange(cubePos, newStatus); if (newStatus == null) { this.cubeStatuses.remove(cubePos.asLong()); } else { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinGameRenderer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinGameRenderer.java index e74c84a8..1ac42bb5 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinGameRenderer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinGameRenderer.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.client.render; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.CubicChunks; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GameRenderer; @@ -21,7 +20,7 @@ public class MixinGameRenderer { @Inject(method = "getDepthFar", at = @At("HEAD"), cancellable = true) private void getDepthFarWithVerticalViewDistance(CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) this.minecraft.level).isCubic()) { + if (!this.minecraft.level.isCubic()) { return; } float horizontalRenderDistance = this.renderDistance * 4.0F; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinOtherRenderChunk.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinOtherRenderChunk.java index 1d7984a1..da112a9c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinOtherRenderChunk.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinOtherRenderChunk.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.client.render; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import net.minecraft.client.renderer.chunk.RenderChunk; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.state.BlockState; @@ -18,7 +17,7 @@ public class MixinOtherRenderChunk { @Inject(method = "getBlockState", at = @At("HEAD"), cancellable = true) private void goThroughLevel(BlockPos blockPos, CallbackInfoReturnable cir) { - if (((CubicLevelHeightAccessor) this.wrapped).isCubic()) { + if (this.wrapped.isCubic()) { cir.setReturnValue(this.wrapped.getBlockState(blockPos)); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinRenderChunk.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinRenderChunk.java index 3fb4858a..1bd51901 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinRenderChunk.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinRenderChunk.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.client.render; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.mixin.access.client.ChunkRenderDispatcherAccess; import io.github.opencubicchunks.cubicchunks.world.level.CubicLevelAccessor; import net.minecraft.client.Minecraft; @@ -34,7 +33,7 @@ public abstract class MixinRenderChunk { private void doesChunkAndCubeExistAt(BlockPos blockPos, CallbackInfoReturnable cir) { ClientLevel level = Minecraft.getInstance().level; if (level != null) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return; } } @@ -61,7 +60,7 @@ private void doesChunkAndCubeExistAt(BlockPos blockPos, CallbackInfoReturnable cir) { ClientLevel level = Minecraft.getInstance().level; if (level != null) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return; } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinRenderChunkRegion.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinRenderChunkRegion.java index 733dadc3..23743d4d 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinRenderChunkRegion.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinRenderChunkRegion.java @@ -18,9 +18,9 @@ public abstract class MixinRenderChunkRegion implements CubicLevelHeightAccessor @Inject(method = "", at = @At("RETURN")) private void initIsCubic(Level level, int i, int j, RenderChunk[][] renderChunks, CallbackInfo ci) { - isCubic = ((CubicLevelHeightAccessor) level).isCubic(); - generates2DChunks = ((CubicLevelHeightAccessor) level).generates2DChunks(); - worldStyle = ((CubicLevelHeightAccessor) level).worldStyle(); + isCubic = level.isCubic(); + generates2DChunks = level.generates2DChunks(); + worldStyle = level.worldStyle(); } @Override public WorldStyle worldStyle() { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinViewArea.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinViewArea.java index 85785972..7743cc97 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinViewArea.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/render/MixinViewArea.java @@ -32,7 +32,7 @@ public abstract class MixinViewArea { protected void setViewDistance(int renderDistanceChunks, CallbackInfo ci) { ClientLevel level = Minecraft.getInstance().level; if (level != null) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return; } } @@ -49,7 +49,7 @@ protected void setViewDistance(int renderDistanceChunks, CallbackInfo ci) { private void repositionCamera(double viewEntityX, double viewEntityZ, CallbackInfo ci) { ClientLevel level = Minecraft.getInstance().level; if (level != null) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return; } } @@ -91,7 +91,7 @@ private void repositionCamera(double viewEntityX, double viewEntityZ, CallbackIn private void getRenderChunkAt(BlockPos pos, CallbackInfoReturnable cir) { ClientLevel level = Minecraft.getInstance().level; if (level != null) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return; } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/server/MixinIntegratedPlayerList.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/server/MixinIntegratedPlayerList.java index 5881acc1..4c1ac321 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/server/MixinIntegratedPlayerList.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/server/MixinIntegratedPlayerList.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.client.server; -import io.github.opencubicchunks.cubicchunks.chunk.VerticalViewDistanceListener; import net.minecraft.client.server.IntegratedPlayerList; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -10,7 +9,7 @@ public class MixinIntegratedPlayerList { @Redirect(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/server/IntegratedPlayerList;setViewDistance(I)V")) private void setVerticalViewDistance(IntegratedPlayerList integratedPlayerList, int viewDistance) { - ((VerticalViewDistanceListener) integratedPlayerList).setIncomingVerticalViewDistance(viewDistance); + integratedPlayerList.setIncomingVerticalViewDistance(viewDistance); ((IntegratedPlayerList) (Object) this).setViewDistance(viewDistance); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/server/MixinIntegratedServer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/server/MixinIntegratedServer.java index 04c2d770..b5628715 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/server/MixinIntegratedServer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/client/server/MixinIntegratedServer.java @@ -27,7 +27,7 @@ private void updateVerticalViewDistance(BooleanSupplier shouldKeepTicking, Callb if (verticalViewDistance != currentVerticalViewDistance1) { CubicChunks.LOGGER.info("Changing vertical view distance to {}, from {}", verticalViewDistance, currentVerticalViewDistance1); - ((VerticalViewDistanceListener) ((IntegratedServer) (Object) this).getPlayerList()).setIncomingVerticalViewDistance(verticalViewDistance); + ((IntegratedServer) (Object) this).getPlayerList().setIncomingVerticalViewDistance(verticalViewDistance); ((IntegratedServer) (Object) this).getPlayerList().setViewDistance(horizontalViewDistance); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/MixinMinecraftServer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/MixinMinecraftServer.java index c61f8478..b1f6ca8e 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/MixinMinecraftServer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/MixinMinecraftServer.java @@ -13,7 +13,6 @@ import com.mojang.datafixers.DataFixer; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.config.ServerConfig; import io.github.opencubicchunks.cubicchunks.levelgen.feature.CubicFeatures; import io.github.opencubicchunks.cubicchunks.mixin.access.common.BiomeGenerationSettingsAccess; @@ -125,7 +124,7 @@ private void prepareLevels(ChunkProgressListener statusListener, CallbackInfo ci System.out.println("PREPARELEVELS HERE " + MinecraftServer.class.getClassLoader().getClass().getName()); ServerLevel serverLevel = this.overworld(); - if (!((CubicLevelHeightAccessor) serverLevel).isCubic()) { + if (!serverLevel.isCubic()) { return; } ci.cancel(); @@ -144,11 +143,11 @@ private void prepareLevels(ChunkProgressListener statusListener, CallbackInfo ci int d = radius * 2 + 1; ((ServerCubeCache) serverChunkCache).addCubeRegionTicket(TicketType.START, spawnPosCube, radius + 1, Unit.INSTANCE); - while (this.isRunning() && ((ServerCubeCache) serverChunkCache).getTickingGeneratedCubes() < d * d * d) { + while (this.isRunning() && serverChunkCache.getTickingGeneratedCubes() < d * d * d) { this.nextTickTime = Util.getMillis() + 10L; this.waitUntilNextTick(); } - LOGGER.info("Current loaded chunks: " + serverChunkCache.getTickingGenerated() + " | " + ((ServerCubeCache) serverChunkCache).getTickingGeneratedCubes()); + LOGGER.info("Current loaded chunks: " + serverChunkCache.getTickingGenerated() + " | " + serverChunkCache.getTickingGeneratedCubes()); this.nextTickTime = Util.getMillis() + 10L; this.waitUntilNextTick(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/MixinServerChunkCache.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/MixinServerChunkCache.java index e0f62838..4e45efa4 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/MixinServerChunkCache.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/MixinServerChunkCache.java @@ -24,7 +24,6 @@ import io.github.opencubicchunks.cubicchunks.mixin.access.common.ChunkMapAccess; import io.github.opencubicchunks.cubicchunks.server.level.CubeHolder; import io.github.opencubicchunks.cubicchunks.server.level.CubeMap; -import io.github.opencubicchunks.cubicchunks.server.level.CubicDistanceManager; import io.github.opencubicchunks.cubicchunks.server.level.CubicTicketType; import io.github.opencubicchunks.cubicchunks.server.level.ServerCubeCache; import io.github.opencubicchunks.cubicchunks.world.CubicNaturalSpawner; @@ -32,7 +31,6 @@ import io.github.opencubicchunks.cubicchunks.world.level.chunk.CubeStatus; import io.github.opencubicchunks.cubicchunks.world.level.chunk.LevelCube; import io.github.opencubicchunks.cubicchunks.world.level.chunk.LightCubeGetter; -import io.github.opencubicchunks.cubicchunks.world.server.CubicServerLevel; import net.minecraft.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.SectionPos; @@ -95,15 +93,15 @@ public abstract class MixinServerChunkCache implements ServerCubeCache, LightCub @Override public void addCubeRegionTicket(TicketType type, CubePos pos, int distance, T value) { - ((CubicDistanceManager) this.distanceManager).addCubeRegionTicket(type, pos, distance, value); + this.distanceManager.addCubeRegionTicket(type, pos, distance, value); } public void removeCubeRegionTicket(TicketType type, CubePos pos, int distance, T value) { - ((CubicDistanceManager) this.distanceManager).removeCubeRegionTicket(type, pos, distance, value); + this.distanceManager.removeCubeRegionTicket(type, pos, distance, value); } @Override public int getTickingGeneratedCubes() { - return ((CubeMap) chunkMap).getTickingGeneratedCubes(); + return chunkMap.getTickingGeneratedCubes(); } @Nullable @@ -183,7 +181,7 @@ public LevelCube getCubeNow(int cubeX, int cubeY, int cubeZ) { // forceChunk @Override public void forceCube(CubePos pos, boolean add) { - ((CubicDistanceManager) this.distanceManager).updateCubeForced(pos, add); + this.distanceManager.updateCubeForced(pos, add); } @@ -217,7 +215,7 @@ private CompletableFuture> g int j = 33 + CubeStatus.getDistance(requiredStatus); ChunkHolder chunkholder = this.getVisibleCubeIfPresent(i); if (load) { - ((CubicDistanceManager) this.distanceManager).addCubeTicket(CubicTicketType.UNKNOWN, cubePos, j, cubePos); + this.distanceManager.addCubeTicket(CubicTicketType.UNKNOWN, cubePos, j, cubePos); if (this.chunkAbsent(chunkholder, j)) { ProfilerFiller profiler = this.level.getProfiler(); profiler.push("chunkLoad"); @@ -230,7 +228,7 @@ private CompletableFuture> g } } - return this.chunkAbsent(chunkholder, j) ? CubeHolder.UNLOADED_CUBE_FUTURE : ((CubeHolder) chunkholder).getOrScheduleCubeFuture(requiredStatus, + return this.chunkAbsent(chunkholder, j) ? CubeHolder.UNLOADED_CUBE_FUTURE : chunkholder.getOrScheduleCubeFuture(requiredStatus, this.chunkMap); } @@ -286,7 +284,7 @@ private void clearCubeCache() { @Nullable public BlockGetter getCubeForLighting(int cubeX, int cubeY, int cubeZ) { long cubePosAsLong = CubePos.of(cubeX, cubeY, cubeZ).asLong(); - ChunkHolder chunkholder = ((CubeMap) this.chunkMap).getVisibleCubeIfPresent(cubePosAsLong); + ChunkHolder chunkholder = this.chunkMap.getVisibleCubeIfPresent(cubePosAsLong); if (chunkholder == null) { return null; } else { @@ -310,7 +308,7 @@ public BlockGetter getCubeForLighting(int cubeX, int cubeY, int cubeZ) { private void initChunkMapForCC(ServerLevel serverLevel, LevelStorageSource.LevelStorageAccess levelStorageAccess, DataFixer dataFixer, StructureManager structureManager, Executor executor, ChunkGenerator chunkGenerator, int i, int j, boolean bl, ChunkProgressListener chunkProgressListener, ChunkStatusUpdateListener chunkStatusUpdateListener, Supplier supplier, CallbackInfo ci) { - ((CubeMap) this.chunkMap).setServerChunkCache((ServerChunkCache) (Object) this); + this.chunkMap.setServerChunkCache((ServerChunkCache) (Object) this); } /** @@ -322,7 +320,7 @@ public void onBlockChanged(BlockPos pos, CallbackInfo ci) { if (!((CubicLevelHeightAccessor) this.level).isCubic()) { return; } - ChunkHolder chunkholder = ((CubeMap) this.chunkMap).getUpdatingCubeIfPresent(CubePos.from(pos).asLong()); + ChunkHolder chunkholder = this.chunkMap.getUpdatingCubeIfPresent(CubePos.from(pos).asLong()); if (chunkholder != null) { // markBlockChanged chunkholder.blockChanged(new BlockPos(Coords.localX(pos), Coords.localY(pos), Coords.localZ(pos))); @@ -334,10 +332,10 @@ public void onBlockChanged(BlockPos pos, CallbackInfo ci) { + "Lnet/minecraft/world/level/LocalMobCapCalculator;)Lnet/minecraft/world/level/NaturalSpawner$SpawnState;")) private NaturalSpawner.SpawnState cubicChunksSpawnState(int spawnableChunkCount, Iterable entities, NaturalSpawner.ChunkGetter chunkGetter, LocalMobCapCalculator localMobCapCalculator) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return NaturalSpawner.createState(spawnableChunkCount, entities, chunkGetter, localMobCapCalculator); } - int naturalSpawnCountForColumns = ((CubicDistanceManager) this.distanceManager).getNaturalSpawnCubeCount() + int naturalSpawnCountForColumns = this.distanceManager.getNaturalSpawnCubeCount() * CubicConstants.DIAMETER_IN_SECTIONS * CubicConstants.DIAMETER_IN_SECTIONS / (CubicNaturalSpawner.SPAWN_RADIUS * 2 / CubicConstants.DIAMETER_IN_BLOCKS + 1); return CubicNaturalSpawner.createState(naturalSpawnCountForColumns, entities, this::getFullCube, localMobCapCalculator); @@ -348,7 +346,7 @@ private NaturalSpawner.SpawnState cubicChunksSpawnState(int spawnableChunkCount, locals = LocalCapture.CAPTURE_FAILHARD) private void tickCubes(CallbackInfo ci, long gameTime, long timeSinceUpdate, LevelData levelData, ProfilerFiller profilerFiller, int randomTicking, boolean bl2, int spawnChunkCount, NaturalSpawner.SpawnState spawnState, List list) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } @@ -356,10 +354,10 @@ private void tickCubes(CallbackInfo ci, long gameTime, long timeSinceUpdate, Lev LevelCube cube = ((CubeHolder) cubeHolder).getTickingCube(); if (cube != null) { this.level.getProfiler().push("broadcast"); - ((CubeHolder) cubeHolder).broadcastChanges(cube); + cubeHolder.broadcastChanges(cube); this.level.getProfiler().pop(); - if (!((CubeMap) this.chunkMap).noPlayersCloseForSpawning(cube.getCubePos())) { + if (!this.chunkMap.noPlayersCloseForSpawning(cube.getCubePos())) { // TODO probably want to make sure column-based inhabited time works too cube.setInhabitedTime(cube.getInhabitedTime() + timeSinceUpdate); @@ -369,7 +367,7 @@ private void tickCubes(CallbackInfo ci, long gameTime, long timeSinceUpdate, Lev CubicNaturalSpawner.spawnForCube(this.level, cube, spawnState, this.spawnFriendlies, this.spawnEnemies, bl2); } } - ((CubicServerLevel) this.level).tickCube(cube, randomTicking); + this.level.tickCube(cube, randomTicking); } } }); @@ -399,7 +397,7 @@ private void getFullCube(long pos, Consumer chunkConsumer) { */ @Inject(method = "gatherStats", at = @At("HEAD"), cancellable = true) public void gatherStatsForCubicChunks(CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } cir.setReturnValue("ServerChunkCache: " + this.getLoadedChunksCount() + " | " + ((CubeMap) chunkMap).sizeCubes()); @@ -407,7 +405,7 @@ public void gatherStatsForCubicChunks(CallbackInfoReturnable cir) { @Inject(method = "isPositionTicking", at = @At("HEAD"), cancellable = true) private void isCubeAtPositionTicking(long pos, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } cir.setReturnValue(this.checkCubeFuture(pos, (chunkHolder) -> unsafeCast(chunkHolder.getTickingChunkFuture()))); @@ -417,7 +415,7 @@ private void isCubeAtPositionTicking(long pos, CallbackInfoReturnable c @SuppressWarnings("target") @Inject(method = "lambda$onLightUpdate$6(Lnet/minecraft/core/SectionPos;Lnet/minecraft/world/level/LightLayer;)V", at = @At(value = "HEAD"), cancellable = true) private void onlyCubes(SectionPos pos, LightLayer type, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } ci.cancel(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/blockentity/MixinBeaconBlockEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/blockentity/MixinBeaconBlockEntity.java index 54eb5436..1a229a84 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/blockentity/MixinBeaconBlockEntity.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/blockentity/MixinBeaconBlockEntity.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.common.blockentity; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.CubicChunks; import net.minecraft.core.BlockPos; import net.minecraft.world.effect.MobEffect; @@ -22,7 +21,7 @@ public abstract class MixinBeaconBlockEntity { @Redirect(method = "applyEffects", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;expandTowards(DDD)Lnet/minecraft/world/phys/AABB;")) private static AABB limitBeaconEffectYRange(AABB aabb, double x, double y, double z, Level level, BlockPos pos, int beaconLevel, @Nullable MobEffect primaryEffect, @Nullable MobEffect secondaryEffect) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return aabb.expandTowards(x, y, z); } CubicChunks.LOGGER.warn("on$expand called"); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/blockentity/MixinConduitBlockEntity.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/blockentity/MixinConduitBlockEntity.java index d06d6f81..8819fc48 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/blockentity/MixinConduitBlockEntity.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/blockentity/MixinConduitBlockEntity.java @@ -2,7 +2,6 @@ import java.util.List; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.ConduitBlockEntity; @@ -21,7 +20,7 @@ public class MixinConduitBlockEntity { // TODO: redirect getHeight() @Redirect(method = "applyEffects", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;expandTowards(DDD)Lnet/minecraft/world/phys/AABB;")) private static AABB limitConduitEffectYRange(AABB aabb, double x, double y, double z, Level level, BlockPos pos, List activatingBlocks) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return aabb.expandTowards(x, y, z); } // TODO: limit this to vertical view distance? diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinBulkSectionAccess.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinBulkSectionAccess.java index 3a5f8270..66ce2b94 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinBulkSectionAccess.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinBulkSectionAccess.java @@ -2,7 +2,6 @@ import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.levelgen.CubeWorldGenRegion; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import net.minecraft.core.BlockPos; @@ -32,7 +31,7 @@ public class MixinBulkSectionAccess { @Inject(method = "getSection", at = @At("HEAD"), cancellable = true) private void returnCubeSection(BlockPos blockPos, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } ChunkAccess cube = ((CubeWorldGenRegion) this.level).getCube(blockPos); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkHolder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkHolder.java index 948071b0..ca035225 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkHolder.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkHolder.java @@ -15,6 +15,7 @@ import javax.annotation.Nullable; import com.mojang.datafixers.util.Either; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; @@ -81,7 +82,7 @@ public abstract class MixinChunkHolder implements CubeHolder { @Shadow private boolean hasChangedSections; - private CubePos cubePos; // set from ASM + @UsedFromASM private CubePos cubePos; private final ShortArraySet[] changedLocalBlocks = new ShortArraySet[CubicConstants.SECTION_COUNT]; @@ -112,7 +113,7 @@ public abstract class MixinChunkHolder implements CubeHolder { + "Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionsCount()I")) private int getFakeSectionCountCC(LevelHeightAccessor accessor) { - if (!((CubicLevelHeightAccessor) accessor).isCubic()) { + if (!accessor.isCubic()) { return accessor.getSectionsCount(); } return 0; @@ -124,7 +125,7 @@ private int getFakeSectionCountCC(LevelHeightAccessor accessor) { + "Lnet/minecraft/server/level/ChunkHolder$PlayerProvider;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionsCount()I")) private int getFakeSectionCountVanilla(LevelHeightAccessor accessor) { - if (!((CubicLevelHeightAccessor) accessor).isCubic()) { + if (!accessor.isCubic()) { return accessor.getSectionsCount(); } return 0; @@ -143,13 +144,13 @@ private int getFakeSectionCountVanilla(LevelHeightAccessor accessor) { public void onConstructCubeHolder(CubePos newCubePos, int level, LevelHeightAccessor heightAccessor, LevelLightEngine lightEngine, ChunkHolder.LevelChangeListener levelChangeListener, ChunkHolder.PlayerProvider playerProviderArg, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic()) { //TODO: Vanilla Chunks - Figure out how to handle ASM Targets + if (!this.levelHeightAccessor.isCubic()) { //TODO: Vanilla Chunks - Figure out how to handle ASM Targets return; } this.pos = newCubePos.asChunkPos(); } - // used from ASM + @UsedFromASM private static ChunkStatus getCubeStatus(int cubeLevel) { return CubeHolder.getCubeStatusFromLevel(cubeLevel); } @@ -157,7 +158,7 @@ private static ChunkStatus getCubeStatus(int cubeLevel) { @Inject(method = "updateFutures", at = @At("HEAD"), cancellable = true) void updateFutures(ChunkMap chunkMap, Executor executor, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic()) { + if (!this.levelHeightAccessor.isCubic()) { return; } /* @@ -234,7 +235,7 @@ private CompletableFuture onRunAsyncFullChunkStatusChange(CompletableFutur Executor executorParam, ChunkHolder.FullChunkStatus fullChunkStatus) { - if (!((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic()) { + if (!this.levelHeightAccessor.isCubic()) { return completableFuture.thenRunAsync(action, executor); } if (cubePos == null) { @@ -261,7 +262,7 @@ private CompletableFuture onCompleteScheduleFullChunkPromotion(Completable Consumer> action) { CompletableFuture f2 = pendingFullStateConfirmation; - if (!((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic()) { + if (!this.levelHeightAccessor.isCubic()) { return completableFuture.thenAccept(action); } @@ -280,7 +281,7 @@ private CompletableFuture onCompleteScheduleFullChunkPromotion(Completable @Redirect(method = "demoteFullChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;onFullChunkStatusChange" + "(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/ChunkHolder$FullChunkStatus;)V")) private void handleDemoteCubes(ChunkMap chunkMap, ChunkPos chunkPos, ChunkHolder.FullChunkStatus fullChunkStatus) { - if (!((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic() || cubePos != null) { + if (!this.levelHeightAccessor.isCubic() || cubePos != null) { ((ChunkMapAccess) chunkMap).invokeOnFullChunkStatusChange(chunkPos, fullChunkStatus); } } @@ -342,7 +343,7 @@ private ChunkStatus getChunkOrCubeStatus(int level) { + "Ljava/util/concurrent/CompletableFuture;" )) private CompletableFuture scheduleChunkOrCube(ChunkMap chunkMap, ChunkHolder _this, ChunkStatus status) { - if (!((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic() || cubePos == null) { + if (!this.levelHeightAccessor.isCubic() || cubePos == null) { return chunkMap.schedule(_this, status); } else { return ((CubeMap) chunkMap).scheduleCube(_this, status); @@ -387,7 +388,7 @@ public void addCubeStageListener(ChunkStatus status, BiConsumer updatingCubeMap = new Long2ObjectLinkedOpenHashMap<>(); - private volatile Long2ObjectLinkedOpenHashMap visibleCubeMap = this.updatingCubeMap.clone(); + @UsedFromASM private final Long2ObjectLinkedOpenHashMap updatingCubeMap = new Long2ObjectLinkedOpenHashMap<>(); + @UsedFromASM private volatile Long2ObjectLinkedOpenHashMap visibleCubeMap = this.updatingCubeMap.clone(); - // NOTE: used from ASM, don't rename private final LongSet cubeEntitiesInLevel = new LongOpenHashSet(); - private final Long2ObjectLinkedOpenHashMap pendingCubeUnloads = new Long2ObjectLinkedOpenHashMap<>(); + @UsedFromASM private final Long2ObjectLinkedOpenHashMap pendingCubeUnloads = new Long2ObjectLinkedOpenHashMap<>(); - // worldgenMailbox private ProcessorHandle> cubeWorldgenMailbox; - // mainThreadMailbox private ProcessorHandle> cubeMainThreadMailbox; private final AtomicInteger tickingGeneratedCubes = new AtomicInteger(); - private final Long2ByteMap cubeTypeCache = new Long2ByteOpenHashMap(); + @UsedFromASM private final Long2ByteMap cubeTypeCache = new Long2ByteOpenHashMap(); private final Queue cubeUnloadQueue = Queues.newConcurrentLinkedQueue(); private ServerChunkCache serverChunkCache; @@ -254,7 +249,7 @@ public BlockGetter getChunkForLighting(int i, int j) { private ChunkMap.DistanceManager setIsCubic(ChunkMap chunkMap, Executor executor, Executor executor2, ServerLevel levelArg) { ChunkMap.DistanceManager newDistanceManager = chunkMap.new DistanceManager(executor, executor2); //noinspection ConstantConditions - ((CubicDistanceManager) newDistanceManager).initCubic(((CubicLevelHeightAccessor) this.level).isCubic()); + newDistanceManager.initCubic(this.level.isCubic()); return newDistanceManager; } @@ -264,7 +259,7 @@ private void onConstruct(ServerLevel serverLevel, LevelStorageSource.LevelStorag ChunkStatusUpdateListener chunkStatusUpdateListener, Supplier supplier, int i, boolean bl, CallbackInfo ci, Path path, ProcessorMailbox worldgenMailbox, ProcessorHandle mainThreadProcessorHandle, ProcessorMailbox lightMailbox) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } @@ -272,8 +267,7 @@ private void onConstruct(ServerLevel serverLevel, LevelStorageSource.LevelStorag this.cubeWorldgenMailbox = this.cubeQueueSorter.getProcessor(worldgenMailbox, false); this.cubeMainThreadMailbox = this.cubeQueueSorter.getProcessor(mainThreadProcessorHandle, false); - ((CubicThreadedLevelLightEngine) this.lightEngine).postConstructorSetup(this.cubeQueueSorter, - this.cubeQueueSorter.getProcessor(lightMailbox, false)); + this.lightEngine.postConstructorSetup(this.cubeQueueSorter, this.cubeQueueSorter.getProcessor(lightMailbox, false)); try { regionCubeIO = new RegionCubeIO(path.toFile(), "chunk", "cube"); @@ -285,7 +279,7 @@ private void onConstruct(ServerLevel serverLevel, LevelStorageSource.LevelStorag @Inject(method = "tick(Ljava/util/function/BooleanSupplier;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;processUnloads(Ljava/util/function/BooleanSupplier;)V")) protected void onTickScheduleUnloads(BooleanSupplier hasMoreTime, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } this.processCubeUnloads(hasMoreTime); @@ -300,7 +294,7 @@ protected void onTickScheduleUnloads(BooleanSupplier hasMoreTime, CallbackInfo c @Inject(method = "saveAllChunks", at = @At("HEAD")) protected void save(boolean flush, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } @@ -314,17 +308,17 @@ protected void save(boolean flush, CallbackInfo ci) { for (Map.Entry heightmapEntry : chunk.getHeightmaps()) { Heightmap heightmap = heightmapEntry.getValue(); if (heightmap != null) { - ((SurfaceTrackerWrapper) heightmap).saveAll(((CubicServerLevel) this.level).getHeightmapStorage()); + ((SurfaceTrackerWrapper) heightmap).saveAll(this.level.getHeightmapStorage()); } } LightSurfaceTrackerWrapper lightHeightmap = ((LightHeightmapGetter) chunk).getServerLightHeightmap(); if (lightHeightmap != null) { - lightHeightmap.saveAll(((CubicServerLevel) this.level).getHeightmapStorage()); + lightHeightmap.saveAll(this.level.getHeightmapStorage()); } }); try { - ((CubicServerLevel) this.level).getHeightmapStorage().flush(); + this.level.getHeightmapStorage().flush(); } catch (IOException e) { e.printStackTrace(); } @@ -341,9 +335,9 @@ protected void save(boolean flush, CallbackInfo ci) { @SuppressWarnings("unchecked") final CompletableFuture[] saveFutures = list.stream().map((cubeHolder) -> { CompletableFuture cubeFuture; do { - cubeFuture = ((CubeHolder) cubeHolder).getCubeToSave(); + cubeFuture = cubeHolder.getCubeToSave(); this.mainThreadExecutor.managedBlock(cubeFuture::isDone); - } while (cubeFuture != ((CubeHolder) cubeHolder).getCubeToSave()); + } while (cubeFuture != cubeHolder.getCubeToSave()); return cubeFuture.join(); }).filter((cube) -> cube instanceof ImposterProtoCube || cube instanceof LevelCube) @@ -378,7 +372,7 @@ protected void save(boolean flush, CallbackInfo ci) { // save() private boolean cubeSave(CubeAccess cube) { - ((CubicSectionStorage) this.poiManager).flush(cube.getCubePos()); + this.poiManager.flush(cube.getCubePos()); if (!cube.isUnsaved()) { return false; } else { @@ -422,7 +416,7 @@ private boolean cubeSave(CubeAccess cube) { } private CompletableFuture cubeSaveAsync(CubeAccess cube) { - ((CubicSectionStorage) this.poiManager).flush(cube.getCubePos()); + this.poiManager.flush(cube.getCubePos()); if (!cube.isUnsaved()) { return CompletableFuture.completedFuture(false); } else { @@ -472,7 +466,7 @@ private void onTick(CallbackInfo info) { cubeSavingFutures.entrySet().removeIf(entry -> entry.getValue().isDone()); } - // Called from ASM + @UsedFromASM private CompoundTag readCubeNBT(CubePos cubePos) throws IOException { return regionCubeIO.loadCubeNBT(cubePos); } @@ -500,9 +494,9 @@ private void processCubeUnloads(BooleanSupplier hasMoreTime) { // scheduleUnload private void scheduleCubeUnload(long cubePos, ChunkHolder cubeHolder) { - CompletableFuture toSaveFuture = ((CubeHolder) cubeHolder).getCubeToSave(); + CompletableFuture toSaveFuture = cubeHolder.getCubeToSave(); toSaveFuture.thenAcceptAsync(cube -> { - CompletableFuture newToSaveFuture = ((CubeHolder) cubeHolder).getCubeToSave(); + CompletableFuture newToSaveFuture = cubeHolder.getCubeToSave(); if (newToSaveFuture != toSaveFuture) { this.scheduleCubeUnload(cubePos, cubeHolder); } else { @@ -519,10 +513,10 @@ private void scheduleCubeUnload(long cubePos, ChunkHolder cubeHolder) { this.cubeSave(cube); } if (this.cubeEntitiesInLevel.remove(cubePos) && cube instanceof LevelCube levelCube) { - ((CubicServerLevel) this.level).onCubeUnloading(levelCube); + this.level.onCubeUnloading(levelCube); } - ((CubicThreadedLevelLightEngine) this.lightEngine).setCubeStatusEmpty(cube.getCubePos()); + this.lightEngine.setCubeStatusEmpty(cube.getCubePos()); this.lightEngine.tryScheduleUpdate(); CubePos pos = CubePos.from(cubePos); @@ -544,12 +538,12 @@ private void scheduleCubeUnload(long cubePos, ChunkHolder cubeHolder) { } } - cube.unloadSource(((CubicServerLevel) this.level).getHeightmapStorage()); + cube.unloadSource(this.level.getHeightmapStorage()); } } }, this.cubeUnloadQueue::add).whenComplete((v, throwable) -> { if (throwable != null) { - LOGGER.error("Failed to save cube " + ((CubeHolder) cubeHolder).getCubePos(), throwable); + LOGGER.error("Failed to save cube " + cubeHolder.getCubePos(), throwable); } }); } @@ -587,10 +581,10 @@ public ChunkHolder getVisibleCubeIfPresent(long cubePosIn) { ) private void changeCubeStatus(ChunkHolder chunkHolderIn, ChunkStatus chunkStatusIn, CallbackInfoReturnable>> cir) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } - CubePos cubePos = ((CubeHolder) chunkHolderIn).getCubePos(); + CubePos cubePos = chunkHolderIn.getCubePos(); if (cubePos != null) { ((CubeProgressListener) progressListener).onCubeStatusChange(cubePos, chunkStatusIn); } @@ -604,12 +598,11 @@ private void changeCubeStatus(ChunkHolder chunkHolderIn, ChunkStatus chunkStatus @Group(name = "MixinChunkManager.onScheduleSaveStatusChange", min = 1, max = 1) private void onScheduleSaveStatusChange(ChunkHolder chunkHolderIn, CompletableFuture completablefuture, long chunkPosIn, ChunkAccess chunk, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } - if (((CubeHolder) chunkHolderIn).getCubePos() != null) { - ((CubeProgressListener) progressListener).onCubeStatusChange( - ((CubeHolder) chunkHolderIn).getCubePos(), null); + if (chunkHolderIn.getCubePos() != null) { + ((CubeProgressListener) progressListener).onCubeStatusChange(chunkHolderIn.getCubePos(), null); } } @@ -627,9 +620,8 @@ private void onGenerateStatusChange(ChunkPos chunkpos, ChunkHolder chunkHolderIn if (!((CubicLevelHeightAccessor) this.level).isCubic()) { return; } - if (((CubeHolder) chunkHolderIn).getCubePos() != null) { - ((CubeProgressListener) progressListener).onCubeStatusChange( - ((CubeHolder) chunkHolderIn).getCubePos(), null); + if (chunkHolderIn.getCubePos() != null) { + ((CubeProgressListener) progressListener).onCubeStatusChange(chunkHolderIn.getCubePos(), null); } } @@ -640,7 +632,7 @@ private void onGenerateStatusChange(ChunkPos chunkpos, ChunkHolder chunkHolderIn ) ) private void promoteCubeMap(CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } this.visibleCubeMap = updatingCubeMap.clone(); @@ -653,7 +645,7 @@ public Iterable getCubes() { @Override public CompletableFuture> scheduleCube(ChunkHolder cubeHolder, ChunkStatus chunkStatus) { - CubePos cubePos = ((CubeHolder) cubeHolder).getCubePos(); + CubePos cubePos = cubeHolder.getCubePos(); if (chunkStatus == ChunkStatus.EMPTY) { CompletableFuture>> columnsFuture = scheduleColumnFutures(ChunkStatus.EMPTY, cubePos); return columnsFuture.thenComposeAsync(col -> this.scheduleCubeLoad(cubePos).thenApply(cubeEither -> { @@ -716,7 +708,7 @@ private ChunkStatus getCubeDependencyStatus(ChunkStatus status, int distance) { // scheduleChunkGeneration private CompletableFuture> scheduleCubeGeneration(ChunkHolder cubeHolder, ChunkStatus chunkStatusIn, List> columns) { - CubePos cubePos = ((CubeHolder) cubeHolder).getCubePos(); + CubePos cubePos = cubeHolder.getCubePos(); CompletableFuture, ChunkHolder.ChunkLoadingFailure>> future = this.getCubeRangeFuture(cubePos, CubeStatus.getCubeTaskRange(chunkStatusIn), (count) -> this.getCubeDependencyStatus(chunkStatusIn, count)); this.level.getProfiler().incrementCounter(() -> "cubeGenerate " + chunkStatusIn.getName()); @@ -759,7 +751,7 @@ private CompletableFuture, ChunkHolder.ChunkLoadingFailur long posLong = cubePos.asLong(); // get the required cube's chunk holder - CubeHolder chunkholder = (CubeHolder) this.getUpdatingCubeIfPresent(posLong); + CubeHolder chunkholder = this.getUpdatingCubeIfPresent(posLong); if (chunkholder == null) { //noinspection MixinInnerClass return CompletableFuture.completedFuture(Either.right(new ChunkHolder.ChunkLoadingFailure() { @@ -867,7 +859,7 @@ private CompletableFuture> p return fullFuture.thenApplyAsync((sectionOrError) -> { ChunkStatus chunkstatus = CubeHolder.getCubeStatusFromLevel(holder.getTicketLevel()); return !chunkstatus.isOrAfter(ChunkStatus.FULL) ? CubeHolder.UNLOADED_CUBE : sectionOrError.mapLeft((prevCube) -> { - CubePos cubePos = ((CubeHolder) holder).getCubePos(); + CubePos cubePos = holder.getCubePos(); LevelCube cube; if (prevCube instanceof ImposterProtoCube) { cube = ((ImposterProtoCube) prevCube).getWrapped(); @@ -876,7 +868,7 @@ private CompletableFuture> p cube = new LevelCube(this.level, (ProtoCube) prevCube, (bigCube) -> { postLoadProtoChunk(this.level, ((ProtoCube) prevCube).getEntities()); }); - ((CubeHolder) holder).replaceProtoCube(new ImposterProtoCube(cube, false)); + holder.replaceProtoCube(new ImposterProtoCube(cube, false)); } cube.setFullStatus(() -> ChunkHolder.getFullChunkStatus(holder.getTicketLevel())); @@ -890,7 +882,7 @@ private CompletableFuture> p }); }, (runnable) -> { this.cubeMainThreadMailbox.tell(CubeTaskPriorityQueueSorter.message( - runnable, ((CubeHolder) holder).getCubePos().asLong(), holder::getTicketLevel)); + runnable, holder.getCubePos().asLong(), holder::getTicketLevel)); }); } @@ -905,7 +897,7 @@ public CompletableFuture> pre @Override public CompletableFuture> prepareTickingCube(ChunkHolder chunkHolder) { - CubePos cubePos = ((CubeHolder) chunkHolder).getCubePos(); + CubePos cubePos = chunkHolder.getCubePos(); CompletableFuture, ChunkHolder.ChunkLoadingFailure>> tickingFuture = this.getCubeRangeFuture(cubePos, 1, (i) -> { return ChunkStatus.FULL; @@ -945,7 +937,7 @@ public CompletableFuture> pre @Redirect(method = "save", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;write(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/nbt/CompoundTag;)V")) private void writeColumn(ChunkMap chunkManager, ChunkPos chunkPos, CompoundTag chunkNBT) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { chunkManager.write(chunkPos, chunkNBT); return; } @@ -956,7 +948,7 @@ private void writeColumn(ChunkMap chunkManager, ChunkPos chunkPos, CompoundTag c @Redirect(method = "lambda$scheduleChunkLoad$16(Lnet/minecraft/world/level/ChunkPos;)Lcom/mojang/datafixers/util/Either;", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;readChunk(Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag;")) private CompoundTag readColumn(ChunkMap chunkManager, ChunkPos chunkPos) throws IOException { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return this.readChunk(chunkPos); } return regionCubeIO.loadChunkNBT(chunkPos); @@ -983,7 +975,7 @@ private CompletableFuture> s if (flag) { ChunkIoMainThreadTaskUtils.executeMain(() -> { if (poiNBT != null) { - ((CubicSectionStorage) this.poiManager).updateCube(cubePos, poiNBT); + this.poiManager.updateCube(cubePos, poiNBT); } }); return CubeSerializer.read(this.level, this.structureManager, poiManager, cubePos, cubeNBT); @@ -1027,7 +1019,7 @@ public Stream getPlayers(CubePos pos, boolean boundaryOnly) { */ @Inject(method = "updatePlayerStatus", at = @At("HEAD"), cancellable = true) void updatePlayerStatus(ServerPlayer player, boolean track, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } ci.cancel(); @@ -1082,7 +1074,7 @@ void updatePlayerStatus(ServerPlayer player, boolean track, CallbackInfo ci) { */ @Inject(method = "move", at = @At("HEAD"), cancellable = true) public void move(ServerPlayer player, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } ci.cancel(); @@ -1228,7 +1220,7 @@ public void move(ServerPlayer player, CallbackInfo ci) { // this needs to be at HEAD, otherwise we are not going to see the view distance being different. Should not set view distance. Should NOT BE CANCELLED @Inject(method = "setViewDistance", at = @At("HEAD")) protected void setVerticalViewDistance(int horizontalDistance, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } @@ -1245,7 +1237,7 @@ protected void setVerticalViewDistance(int horizontalDistance, CallbackInfo ci) this.viewDistance = hViewDistanceSections; this.verticalViewDistance = vViewDistanceSections; - ((CubicDistanceManager) this.distanceManager).updatePlayerCubeTickets(hViewDistanceSections, vViewDistanceSections); + this.distanceManager.updatePlayerCubeTickets(hViewDistanceSections, vViewDistanceSections); for (ChunkHolder chunkholder : this.updatingCubeMap.values()) { CubePos cubePos = ((CubeHolder) chunkholder).getCubePos(); @@ -1281,7 +1273,7 @@ protected void updateCubeTracking(ServerPlayer player, CubePos cubePosIn, Object //TODO: reimplement forge event //net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(wasLoaded, load, player, cubePosIn, this.world); if (load && !wasLoaded) { - ChunkHolder chunkholder = ((CubeMap) this).getVisibleCubeIfPresent(cubePosIn.asLong()); + ChunkHolder chunkholder = this.getVisibleCubeIfPresent(cubePosIn.asLong()); if (chunkholder != null) { LevelCube cube = ((CubeHolder) chunkholder).getTickingCube(); if (cube != null) { @@ -1331,7 +1323,7 @@ private void untrackPlayerChunk(ServerPlayer player, CubePos cubePosIn) { @Redirect(method = "playerLoadedChunk", at = @At(value = "NEW", target = "(Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/lighting/LevelLightEngine;" + "Ljava/util/BitSet;Ljava/util/BitSet;Z)Lnet/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket;")) private ClientboundLevelChunkWithLightPacket onVanillaLightPacketConstruct(LevelChunk levelChunk, LevelLightEngine levelLightEngine, BitSet bitSet, BitSet bitSet2, boolean bl) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return new ClientboundLevelChunkWithLightPacket(levelChunk, levelLightEngine, bitSet, bitSet2, bl); } @@ -1382,7 +1374,7 @@ private void playerLoadedCube(ServerPlayer player, Object[] packetCache, LevelCu @Override public boolean noPlayersCloseForSpawning(CubePos cubePos) { long cubePosAsLong = cubePos.asLong(); - return !((CubicDistanceManager) this.distanceManager).hasPlayersNearbyCube(cubePosAsLong) || this.playerMap.getPlayers(cubePosAsLong).stream().noneMatch( + return !this.distanceManager.hasPlayersNearbyCube(cubePosAsLong) || this.playerMap.getPlayers(cubePosAsLong).stream().noneMatch( (serverPlayer) -> !serverPlayer.isSpectator() && euclideanDistanceSquared(cubePos, serverPlayer) < (TICK_UPDATE_DISTANCE * TICK_UPDATE_DISTANCE)); } @@ -1466,7 +1458,7 @@ public IntSupplier getCubeQueueLevel(long cubePosIn) { @Inject(method = "close", at = @At("HEAD"), remap = false) public void closeCubeIO(CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } regionCubeIO.flush(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkSerializer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkSerializer.java index d3818082..39ea00a2 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkSerializer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkSerializer.java @@ -5,7 +5,6 @@ import javax.annotation.Nullable; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import net.minecraft.SharedConstants; import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; @@ -41,7 +40,7 @@ public abstract class MixinChunkSerializer { */ @Inject(method = "read", at = @At("HEAD"), cancellable = true) private static void read(ServerLevel serverLevel, PoiManager poiManager, ChunkPos pos, CompoundTag compound, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) serverLevel).isCubic()) { + if (!serverLevel.isCubic()) { return; } cir.cancel(); @@ -93,7 +92,7 @@ private static void read(ServerLevel serverLevel, PoiManager poiManager, ChunkPo */ @Inject(method = "write", at = @At("HEAD"), cancellable = true) private static void write(ServerLevel serverLevel, ChunkAccess column, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) serverLevel).isCubic()) { + if (!serverLevel.isCubic()) { return; } cir.cancel(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkStatus.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkStatus.java index c919e987..01dbeeb1 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkStatus.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkStatus.java @@ -101,7 +101,7 @@ private static void generateStructureStatus( List chunks, ChunkAccess chunk, boolean bl, CallbackInfoReturnable>> cir) { - if (((CubicLevelHeightAccessor) level).generates2DChunks()) { + if (level.generates2DChunks()) { if (!(chunk instanceof CubeAccess)) { return; } @@ -143,7 +143,7 @@ private static void generateStructureStatus( at = @At("HEAD"), cancellable = true ) private static void cubicChunksStructureReferences(ChunkStatus status, ServerLevel level, ChunkGenerator generator, List neighbors, ChunkAccess chunk, CallbackInfo ci) { - if (((CubicLevelHeightAccessor) level).generates2DChunks()) { + if (level.generates2DChunks()) { return; } ci.cancel(); @@ -163,7 +163,7 @@ private static void cubicChunksStructureReferences(ChunkStatus status, ServerLev private static void cubicChunksBiome(ChunkStatus chunkStatus, Executor executor, ServerLevel level, ChunkGenerator chunkGenerator, StructureManager structureManager, ThreadedLevelLightEngine threadedLevelLightEngine, Function function, List cubes, ChunkAccess chunkAccess, boolean bl, CallbackInfoReturnable>> cir) { - if (((CubicLevelHeightAccessor) level).generates2DChunks()) { + if (level.generates2DChunks()) { return; } if (/*!bl && */chunkAccess.getStatus().isOrAfter(chunkStatus)) { // bl is probably for terrain blending @@ -201,7 +201,7 @@ private static void cubicChunksNoise(ChunkStatus status, Executor executor, Serv CallbackInfoReturnable>> ci) { - if (((CubicLevelHeightAccessor) level).generates2DChunks()) { + if (level.generates2DChunks()) { if (chunk instanceof CubeAccess) { ci.setReturnValue(CompletableFuture.completedFuture(Either.left(chunk))); } @@ -301,7 +301,7 @@ private static boolean areSectionsEmpty(int cubeY, ChunkPos pos, CubeAccess cube at = @At("HEAD"), cancellable = true ) private static void cubicChunksSurface(ChunkStatus status, ServerLevel level, ChunkGenerator generator, List neighbors, ChunkAccess chunk, CallbackInfo ci) { - if (((CubicLevelHeightAccessor) level).generates2DChunks()) { + if (level.generates2DChunks()) { return; } ci.cancel(); @@ -314,7 +314,7 @@ private static void cubicChunksSurface(ChunkStatus status, ServerLevel level, Ch at = @At("HEAD"), cancellable = true ) private static void cubicChunksCarvers(ChunkStatus status, ServerLevel level, ChunkGenerator generator, List neighbors, ChunkAccess chunk, CallbackInfo ci) { - if (((CubicLevelHeightAccessor) level).generates2DChunks()) { + if (level.generates2DChunks()) { return; } ci.cancel(); @@ -327,7 +327,7 @@ private static void cubicChunksCarvers(ChunkStatus status, ServerLevel level, Ch at = @At("HEAD"), cancellable = true ) private static void cubicChunksLiquidCarvers(ChunkStatus status, ServerLevel level, ChunkGenerator generator, List neighbors, ChunkAccess chunk, CallbackInfo ci) { - if (((CubicLevelHeightAccessor) level).generates2DChunks()) { + if (level.generates2DChunks()) { return; } ci.cancel(); @@ -348,7 +348,7 @@ private static void featuresSetStatus( List chunks, ChunkAccess chunk, boolean bl, CallbackInfoReturnable>> cir) { - if (((CubicLevelHeightAccessor) level).generates2DChunks()) { + if (level.generates2DChunks()) { if (!(chunk instanceof ProtoCube protoCube)) { return; } @@ -385,7 +385,7 @@ private static void featuresSetStatus( private static void lightChunkCC(ChunkStatus status, ThreadedLevelLightEngine lightEngine, ChunkAccess chunk, CallbackInfoReturnable>> cir) { - if (!((CubicLevelHeightAccessor) chunk).isCubic()) { + if (!chunk.isCubic()) { return; } @@ -400,7 +400,7 @@ private static void lightChunkCC(ChunkStatus status, ThreadedLevelLightEngine li cir.setReturnValue(CompletableFuture.completedFuture(Either.left(chunk))); return; } - boolean flag = ((ProtoCube) chunk).getStatus().isOrAfter(status) && chunk.isLightCorrect(); + boolean flag = chunk.getStatus().isOrAfter(status) && chunk.isLightCorrect(); if (!chunk.getStatus().isOrAfter(status)) { ((ProtoCube) chunk).updateCubeStatus(status); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkStatusSimpleGenerationTask.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkStatusSimpleGenerationTask.java index 17eb963a..c30c13ee 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkStatusSimpleGenerationTask.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinChunkStatusSimpleGenerationTask.java @@ -6,7 +6,6 @@ import java.util.function.Function; import com.mojang.datafixers.util.Either; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.world.level.chunk.ProtoCube; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerLevel; @@ -34,7 +33,7 @@ default CompletableFuture> ChunkStatus status, Executor executor, ServerLevel level, ChunkGenerator generator, StructureManager structureManager, ThreadedLevelLightEngine threadedLevelLightEngine, Function>> function, List neighbors, ChunkAccess chunk, boolean bl) { - if (!((CubicLevelHeightAccessor) chunk).isCubic()) { + if (!chunk.isCubic()) { if (!chunk.getStatus().isOrAfter(status)) { this.doWork(status, level, generator, neighbors, chunk); if (chunk instanceof ProtoChunk) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinLevelChunk.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinLevelChunk.java index 61aedfad..b2915dc6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinLevelChunk.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinLevelChunk.java @@ -19,7 +19,6 @@ import io.github.opencubicchunks.cubicchunks.world.level.levelgen.heightmap.ClientSurfaceTracker; import io.github.opencubicchunks.cubicchunks.world.level.levelgen.heightmap.surfacetrackertree.LightSurfaceTrackerWrapper; import io.github.opencubicchunks.cubicchunks.world.level.levelgen.heightmap.surfacetrackertree.SurfaceTrackerWrapper; -import io.github.opencubicchunks.cubicchunks.world.lighting.SkyLightColumnChecker; import io.github.opencubicchunks.cubicchunks.world.server.CubicServerLevel; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; @@ -111,8 +110,8 @@ private void onInitFromProtoChunk(ServerLevel serverLevel, ProtoChunk protoChunk if (!this.isCubic()) { return; } - lightHeightmap = ((LightHeightmapGetter) protoChunk).getLightHeightmap(); - columnCubeMap = ((ColumnCubeMapGetter) protoChunk).getCubeMap(); + lightHeightmap = protoChunk.getLightHeightmap(); + columnCubeMap = protoChunk.getCubeMap(); } @Inject( @@ -137,7 +136,7 @@ private void onSetBlock(BlockPos pos, BlockState state, boolean moved, CallbackI serverLightHeightmap.update(relX, pos.getY(), relZ, state); int newHeight = serverLightHeightmap.getFirstAvailable(relX, relZ); if (newHeight != oldHeight) { - ((SkyLightColumnChecker) this.level.getChunkSource().getLightEngine()).checkSkyLightColumn(this, pos.getX(), pos.getZ(), oldHeight, newHeight); + this.level.getChunkSource().getLightEngine().checkSkyLightColumn(this, pos.getX(), pos.getZ(), oldHeight, newHeight); } } } @@ -149,7 +148,7 @@ private void onSetBlock(BlockPos pos, BlockState state, boolean moved, CallbackI + "Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V", at = @At(value = "NEW", target = "net/minecraft/world/level/levelgen/Heightmap")) private Heightmap createSurfaceTracker(ChunkAccess chunkAccess, Heightmap.Types type) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { // The fields are not initialized here yet. + if (!this.level.isCubic()) { // The fields are not initialized here yet. return new Heightmap(chunkAccess, type); } if (this.level.isClientSide()) { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinProtoChunk.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinProtoChunk.java index f30eed28..5e40f4cb 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinProtoChunk.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/MixinProtoChunk.java @@ -66,7 +66,7 @@ private void onSetStatus(ChunkStatus status, CallbackInfo ci) { } if (lightHeightmap == null && this.getStatus().isOrAfter(ChunkStatus.FEATURES)) { // Lighting only starts happening after FEATURES, so we init here to avoid creating unnecessary heightmaps - lightHeightmap = new LightSurfaceTrackerWrapper((ChunkAccess) this, ((CubicServerLevel) this.levelHeightAccessor).getHeightmapStorage()); + lightHeightmap = new LightSurfaceTrackerWrapper(this, ((CubicServerLevel) this.levelHeightAccessor).getHeightmapStorage()); } } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinChunkAccess.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinChunkAccess.java index b9c4b8bc..782f1ed8 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinChunkAccess.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinChunkAccess.java @@ -34,21 +34,21 @@ public class MixinChunkAccess implements CubicLevelHeightAccessor { @Inject(method = "", at = @At("RETURN")) private void onInit(ChunkPos chunkPos, UpgradeData upgradeData, LevelHeightAccessor levelAccessor, Registry registry, long l, LevelChunkSection[] levelChunkSections, BlendingData blendingData, CallbackInfo ci) { - isCubic = ((CubicLevelHeightAccessor) levelAccessor).isCubic(); - generates2DChunks = ((CubicLevelHeightAccessor) levelAccessor).generates2DChunks(); - worldStyle = ((CubicLevelHeightAccessor) levelAccessor).worldStyle(); + isCubic = levelAccessor.isCubic(); + generates2DChunks = levelAccessor.generates2DChunks(); + worldStyle = levelAccessor.worldStyle(); } @Redirect(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelHeightAccessor;getSectionsCount()I")) private int getFakeSectionsCount(LevelHeightAccessor accessor) { - if (!((CubicLevelHeightAccessor) accessor).isCubic()) { + if (!accessor.isCubic()) { return this.levelHeightAccessor.getSectionsCount(); } if (accessor instanceof ProtoCube.FakeSectionCount) { return accessor.getSectionsCount(); } if (accessor instanceof Level) { - if (((CubicLevelHeightAccessor) accessor).generates2DChunks()) { + if (accessor.generates2DChunks()) { int height = ((Level) accessor).dimensionType().height(); int minY = ((Level) accessor).dimensionType().minY(); @@ -67,7 +67,7 @@ private int getFakeSectionsCount(LevelHeightAccessor accessor) { @Inject(method = "getHeight()I", at = @At("HEAD"), cancellable = true) private void setHeight(CallbackInfoReturnable cir) { if (this.levelHeightAccessor instanceof Level level) { - if (((CubicLevelHeightAccessor) this).generates2DChunks()) { + if (this.generates2DChunks()) { cir.setReturnValue(level.dimensionType().height()); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinEntityStorage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinEntityStorage.java index db8a8e97..1853d6f3 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinEntityStorage.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinEntityStorage.java @@ -10,7 +10,6 @@ import com.google.common.collect.ImmutableList; import com.mojang.datafixers.DataFixer; import io.github.opencubicchunks.cc_core.api.CubePos; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.CubicChunks; import io.github.opencubicchunks.cubicchunks.world.ImposterChunkPos; import io.github.opencubicchunks.cubicchunks.world.level.chunk.storage.CubicEntityStorage; @@ -48,7 +47,7 @@ public abstract class MixinEntityStorage implements CubicEntityStorage { @Inject(method = "", at = @At("RETURN")) private void setupCubeIO(ServerLevel serverLevel, Path path, DataFixer dataFixer, boolean bl, Executor executor, CallbackInfo ci) throws IOException { - if (((CubicLevelHeightAccessor) serverLevel).isCubic()) { + if (serverLevel.isCubic()) { cubeWorker = new RegionCubeIO(path.toFile(), path.toFile().getName(), path.toFile().getName()); } } @@ -86,7 +85,7 @@ private static ChunkEntities emptyCube(CubePos pos) { @Inject(method = "storeEntities", at = @At("HEAD"), cancellable = true) private void storeEntitiesForCube(ChunkEntities dataList, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } ci.cancel(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinPoiManager.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinPoiManager.java index f43a1e11..8ffd33ea 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinPoiManager.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinPoiManager.java @@ -13,7 +13,6 @@ import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Codec; import io.github.opencubicchunks.cc_core.api.CubePos; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.mixin.access.common.PoiSectionAccess; import io.github.opencubicchunks.cubicchunks.world.level.CubicLevelAccessor; import io.github.opencubicchunks.cubicchunks.world.level.chunk.storage.PoiDeserializationContext; @@ -60,7 +59,7 @@ public MixinPoiManager(Path file, Function> function @Inject(method = "getInSquare", at = @At("HEAD"), cancellable = true) private void getInSquare(Predicate typePredicate, BlockPos pos, int radius, PoiManager.Occupancy occupancy, CallbackInfoReturnable> cir) { - if (!((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic()) { + if (!this.levelHeightAccessor.isCubic()) { return; } @@ -95,7 +94,7 @@ public Stream getInSections(Predicate predicate, SectionPos @Inject(method = "ensureLoadedAndValid", at = @At("HEAD"), cancellable = true) private void ensureCubeLoadedAndValid(LevelReader level, BlockPos pos, int radius, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return; } ci.cancel(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinSectionStorage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinSectionStorage.java index d8aa26a9..7b285978 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinSectionStorage.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/chunk/storage/MixinSectionStorage.java @@ -18,7 +18,6 @@ import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.world.level.chunk.storage.CubicSectionStorage; import io.github.opencubicchunks.cubicchunks.world.storage.RegionCubeIO; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; @@ -80,14 +79,14 @@ public abstract class MixinSectionStorage implements CubicSectionStorage { private void getServerLevel(Path path, Function function, Function function2, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean bl, LevelHeightAccessor levelAccessor, CallbackInfo ci) throws IOException { - if (((CubicLevelHeightAccessor) levelAccessor).isCubic()) { + if (levelAccessor.isCubic()) { cubeWorker = new RegionCubeIO(path.toFile(), path.toFile().getName() + "-chunk", path.toFile().getName()); } } @Inject(method = "tick", at = @At("HEAD"), cancellable = true) private void tickCube(BooleanSupplier shouldKeepTicking, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) levelHeightAccessor).isCubic()) { + if (!levelHeightAccessor.isCubic()) { return; } ci.cancel(); @@ -100,7 +99,7 @@ private void tickCube(BooleanSupplier shouldKeepTicking, CallbackInfo ci) { @Inject(method = "getOrLoad", at = @At("HEAD"), cancellable = true) private void getOrLoadCube(long pos, CallbackInfoReturnable> cir) { - if (!((CubicLevelHeightAccessor) levelHeightAccessor).isCubic()) { + if (!levelHeightAccessor.isCubic()) { return; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/entity/MixinServerPlayer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/entity/MixinServerPlayer.java index f84509ec..fba062e6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/entity/MixinServerPlayer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/entity/MixinServerPlayer.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.common.entity; import com.mojang.authlib.GameProfile; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.network.PacketCCLevelInfo; import io.github.opencubicchunks.cubicchunks.network.PacketDispatcher; import net.minecraft.core.BlockPos; @@ -36,11 +35,11 @@ public void onSendChunkLoad(ServerGamePacketListenerImpl packetListener, Packet< // ClientboundRespawnPacket instantiates the ClientLevel on the client, so we send our packet just before that @Inject(method = "changeDimension", at = @At(value = "NEW", target = "net/minecraft/network/protocol/game/ClientboundRespawnPacket")) private void onChangeDimension(ServerLevel serverLevel, CallbackInfoReturnable cir) { - PacketDispatcher.sendTo(new PacketCCLevelInfo(((CubicLevelHeightAccessor) serverLevel).worldStyle()), (ServerPlayer) (Object) this); + PacketDispatcher.sendTo(new PacketCCLevelInfo(serverLevel.worldStyle()), (ServerPlayer) (Object) this); } @Inject(method = "teleportTo(Lnet/minecraft/server/level/ServerLevel;DDDFF)V", at = @At(value = "NEW", target = "net/minecraft/network/protocol/game/ClientboundRespawnPacket")) private void onTeleportTo(ServerLevel serverLevel, double d, double e, double f, float g, float h, CallbackInfo ci) { - PacketDispatcher.sendTo(new PacketCCLevelInfo(((CubicLevelHeightAccessor) serverLevel).worldStyle()), (ServerPlayer) (Object) this); + PacketDispatcher.sendTo(new PacketCCLevelInfo(serverLevel.worldStyle()), (ServerPlayer) (Object) this); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinNaturalSpawner.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinNaturalSpawner.java index 86b1eb08..2734006f 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinNaturalSpawner.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinNaturalSpawner.java @@ -3,7 +3,6 @@ import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.levelgen.CubeWorldGenRegion; import io.github.opencubicchunks.cubicchunks.world.CubicNaturalSpawner; import io.github.opencubicchunks.cubicchunks.world.level.chunk.LevelCube; @@ -37,7 +36,7 @@ public abstract class MixinNaturalSpawner { @Inject(method = "spawnForChunk", at = @At("HEAD"), cancellable = true) private static void cancelSpawnForChunk(ServerLevel serverLevel, LevelChunk levelChunk, NaturalSpawner.SpawnState spawnState, boolean bl, boolean bl2, boolean bl3, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) serverLevel).isCubic()) { + if (!serverLevel.isCubic()) { return; } ci.cancel(); @@ -46,7 +45,7 @@ private static void cancelSpawnForChunk(ServerLevel serverLevel, LevelChunk leve @Inject(method = "isSpawnPositionOk", at = @At(value = "HEAD"), cancellable = true) private static void isSpawnPositionOkForCubeWorldGenRegion(SpawnPlacements.Type location, LevelReader reader, BlockPos pos, @Nullable EntityType entityType, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) reader).isCubic()) { + if (!reader.isCubic()) { return; } if (reader instanceof CubeWorldGenRegion) { @@ -61,7 +60,7 @@ private static void isSpawnPositionOkForCubeWorldGenRegion(SpawnPlacements.Type @Inject(method = "getTopNonCollidingPos", at = @At("HEAD"), cancellable = true) private static void returnOnBrokenPosition(LevelReader reader, EntityType entityType, int x, int z, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) reader).isCubic()) { + if (!reader.isCubic()) { return; } if (reader instanceof CubeWorldGenRegion) { @@ -109,7 +108,7 @@ private static BlockPos ceilingLogic(EntityType entityType, CubeWorldGenRegio @Redirect(method = "getTopNonCollidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/dimension/DimensionType;hasCeiling()Z")) private static boolean useOverWorldLogic(DimensionType dimensionType, LevelReader level, EntityType entityType, int x, int z) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return dimensionType.hasCeiling(); } return false; @@ -139,7 +138,7 @@ private static BlockPos getRandomPosWithinCube(Level level, LevelCube cubeAccess @Inject(method = "isRightDistanceToPlayerAndSpawnPoint", at = @At("HEAD"), cancellable = true) private static void useCubePos(ServerLevel level, ChunkAccess chunk, BlockPos.MutableBlockPos pos, double squaredDistance, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return; } cir.setReturnValue(CubicNaturalSpawner.isRightDistanceToPlayerAndSpawnPoint(level, chunk, pos, squaredDistance)); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinNaturalSpawnerSpawnState.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinNaturalSpawnerSpawnState.java index 8e1087e6..dd48102b 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinNaturalSpawnerSpawnState.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinNaturalSpawnerSpawnState.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.common.level; import io.github.opencubicchunks.cc_core.api.CubePos; -import io.github.opencubicchunks.cubicchunks.world.CubicLocalMobCapCalculator; import io.github.opencubicchunks.cubicchunks.world.CubicNaturalSpawner; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobCategory; @@ -21,7 +20,7 @@ public class MixinNaturalSpawnerSpawnState implements CubicNaturalSpawner.CubicS @Override public boolean canSpawnForCategory(MobCategory mobCategory, CubePos cubePos) { - return ((CubicLocalMobCapCalculator) localMobCapCalculator).canSpawn(mobCategory, cubePos); + return localMobCapCalculator.canSpawn(mobCategory, cubePos); } @Redirect( @@ -29,10 +28,8 @@ public boolean canSpawnForCategory(MobCategory mobCategory, CubePos cubePos) { at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LocalMobCapCalculator;addMob(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/entity/MobCategory;)V") ) private void addToCubic(LocalMobCapCalculator instance, ChunkPos chunkPos, MobCategory mobCategory, Mob mob, ChunkAccess chunkAccess) { - CubicLocalMobCapCalculator cubicLocalMobCapCalculator = (CubicLocalMobCapCalculator) instance; - - if (cubicLocalMobCapCalculator.isCubic()) { - cubicLocalMobCapCalculator.addMob(new CubePos(mob.blockPosition()), mobCategory); + if (instance.isCubic()) { + instance.addMob(new CubePos(mob.blockPosition()), mobCategory); } else { instance.addMob(chunkPos, mobCategory); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinPlayerRespawnLogic.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinPlayerRespawnLogic.java index 85718a25..bbad48f1 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinPlayerRespawnLogic.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinPlayerRespawnLogic.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.common.level; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cc_core.world.SpawnPlaceFinder; import net.minecraft.core.BlockPos; import net.minecraft.server.level.PlayerRespawnLogic; @@ -20,11 +19,11 @@ public abstract class MixinPlayerRespawnLogic { */ @Inject(method = "getOverworldRespawnPos", at = @At("HEAD"), cancellable = true) private static void getOverworldRespawnPos(ServerLevel world, int posX, int posZ, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) world).isCubic()) { + if (!world.isCubic()) { return; } cir.setReturnValue(SpawnPlaceFinder.getTopBlockBisect(world, new BlockPos(posX, 0, posZ), false, - pos -> world.getBlockState((BlockPos) pos).is(BlockTags.VALID_SPAWN), - pos -> world.getBlockState((BlockPos) pos).getCollisionShape(world, (BlockPos) pos).isEmpty())); + pos -> world.getBlockState(pos).is(BlockTags.VALID_SPAWN), + pos -> world.getBlockState(pos).getCollisionShape(world, (BlockPos) pos).isEmpty())); } } \ No newline at end of file diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinPortalForcer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinPortalForcer.java index ffd3111b..9e53fa7a 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinPortalForcer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinPortalForcer.java @@ -2,7 +2,6 @@ import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.server.level.ServerCubeCache; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -31,7 +30,7 @@ public class MixinPortalForcer { "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")) private void addCubeRegionTicket(ServerChunkCache serverChunkCache, TicketType ticketType, ChunkPos chunkPos, int radius, T argument, PoiRecord poiRecord) { - if (!((CubicLevelHeightAccessor) serverChunkCache.getLevel()).isCubic()) { + if (!serverChunkCache.getLevel().isCubic()) { serverChunkCache.addRegionTicket(ticketType, chunkPos, radius, argument); return; } @@ -40,16 +39,16 @@ private void addCubeRegionTicket(ServerChunkCache serverChunkCache, TicketTy @Redirect(method = "createPortal", at = @At(value = "INVOKE", target = "Ljava/lang/Math;min(II)I", ordinal = 0)) private int limitYUp(int a, int b, BlockPos pos, Direction.Axis axis) { - return !((CubicLevelHeightAccessor) this.level).isCubic() ? Math.min(a, b) : pos.getY() + Y_PORTAL_RADIUS; + return !this.level.isCubic() ? Math.min(a, b) : pos.getY() + Y_PORTAL_RADIUS; } @Redirect(method = "createPortal", at = @At(value = "INVOKE", target = "Ljava/lang/Math;max(II)I")) private int limitYDown(int a, int b, BlockPos pos, Direction.Axis axis) { - return !((CubicLevelHeightAccessor) this.level).isCubic() ? Math.max(a, b) : pos.getY() - Y_PORTAL_RADIUS; + return !this.level.isCubic() ? Math.max(a, b) : pos.getY() - Y_PORTAL_RADIUS; } @Redirect(method = "createPortal", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;getMinBuildHeight()I")) private int limitYDown(ServerLevel serverLevel, BlockPos pos, Direction.Axis axis) { - return !((CubicLevelHeightAccessor) serverLevel).isCubic() ? serverLevel.getMinBuildHeight() : pos.getY() - Y_PORTAL_RADIUS; + return !serverLevel.isCubic() ? serverLevel.getMinBuildHeight() : pos.getY() - Y_PORTAL_RADIUS; } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinServerLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinServerLevel.java index a54890fe..3a86c80d 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinServerLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinServerLevel.java @@ -14,13 +14,10 @@ import io.github.opencubicchunks.cc_core.world.heightmap.HeightmapStorage; import io.github.opencubicchunks.cc_core.world.heightmap.surfacetrackertree.InterleavedHeightmapStorage; import io.github.opencubicchunks.cubicchunks.CubicChunks; -import io.github.opencubicchunks.cubicchunks.chunk.entity.ChunkEntityStateEventSource; -import io.github.opencubicchunks.cubicchunks.chunk.entity.IsCubicEntityContext; import io.github.opencubicchunks.cubicchunks.levelgen.CubicNoiseBasedChunkGenerator; import io.github.opencubicchunks.cubicchunks.world.CubicChunksSavedData; import io.github.opencubicchunks.cubicchunks.world.level.CubicLevelTicks; import io.github.opencubicchunks.cubicchunks.world.level.chunk.LevelCube; -import io.github.opencubicchunks.cubicchunks.world.server.CubicMinecraftServer; import io.github.opencubicchunks.cubicchunks.world.server.CubicServerLevel; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; @@ -94,7 +91,7 @@ private void initSetCubic(MinecraftServer minecraftServer, Executor executor, Le Path dimensionFolderPath = levelStorageAccess.getDimensionPath(levelKey); File dimensionFolder = dimensionFolderPath.toFile(); - var config = ((CubicMinecraftServer) minecraftServer).getServerConfig(); + var config = minecraftServer.getServerConfig(); this.heightmapStorage = new InterleavedHeightmapStorage(new File(dimensionFolder, "tempHeightmap")); @@ -130,7 +127,7 @@ private void initSetCubic(MinecraftServer minecraftServer, Executor executor, Le @Redirect(method = "", at = @At(value = "NEW", target = "net/minecraft/world/ticks/LevelTicks")) private LevelTicks constructTickList(LongPredicate longPredicate, Supplier supplier) { - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { return new LevelTicks<>(longPredicate, supplier); } return new CubicLevelTicks<>(longPredicate, supplier); @@ -140,12 +137,12 @@ private LevelTicks constructTickList(LongPredicate longPredicate, Supplie private void markCubic(MinecraftServer minecraftServer, Executor executor, LevelStorageSource.LevelStorageAccess levelStorageAccess, ServerLevelData serverLevelData, ResourceKey resourceKey, Holder holder, ChunkProgressListener chunkProgressListener, ChunkGenerator chunkGenerator, boolean bl, long l, List list, boolean bl2, CallbackInfo ci) { - ((IsCubicEntityContext) this.entityManager).setIsCubic(((CubicLevelHeightAccessor) this).isCubic()); + this.entityManager.setIsCubic(((CubicLevelHeightAccessor) this).isCubic()); if (this.fluidTicks instanceof CubicLevelTicks ticks) { - ((ChunkEntityStateEventSource) this.entityManager).registerChunkEntityStateEventHandler(ticks); + this.entityManager.registerChunkEntityStateEventHandler(ticks); } if (this.blockTicks instanceof CubicLevelTicks ticks) { - ((ChunkEntityStateEventSource) this.entityManager).registerChunkEntityStateEventHandler(ticks); + this.entityManager.registerChunkEntityStateEventHandler(ticks); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinWorldGenRegion.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinWorldGenRegion.java index c64167f9..7a1bb8e4 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinWorldGenRegion.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/MixinWorldGenRegion.java @@ -21,9 +21,9 @@ public class MixinWorldGenRegion implements CubicLevelHeightAccessor { @Inject(method = "", at = @At("RETURN")) private void setCubic(ServerLevel serverLevel, List list, ChunkStatus status, int i, CallbackInfo ci) { - isCubic = ((CubicLevelHeightAccessor) serverLevel).isCubic(); - generates2DChunks = ((CubicLevelHeightAccessor) serverLevel).generates2DChunks(); - worldStyle = ((CubicLevelHeightAccessor) serverLevel).worldStyle(); + isCubic = serverLevel.isCubic(); + generates2DChunks = serverLevel.generates2DChunks(); + worldStyle = serverLevel.worldStyle(); } @Override public WorldStyle worldStyle() { diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinBlockLightEngine.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinBlockLightEngine.java index 8a876323..bf566afc 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinBlockLightEngine.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinBlockLightEngine.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.common.level.lighting; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.world.level.chunk.LightCubeGetter; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; @@ -21,7 +20,7 @@ public abstract class MixinBlockLightEngine extends MixinLayerLightEngine { */ @Inject(method = "getLightEmission", at = @At("HEAD"), cancellable = true) private void getLightEmission(long blockPos, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) this.chunkSource.getLevel()).isCubic()) { + if (!this.chunkSource.getLevel().isCubic()) { return; } cir.cancel(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLayerLightEngine.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLayerLightEngine.java index 0da453f3..3e5ed074 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLayerLightEngine.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLayerLightEngine.java @@ -5,11 +5,9 @@ import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.mixin.access.common.LayerLightSectionStorageAccess; import io.github.opencubicchunks.cubicchunks.world.level.chunk.LightCubeGetter; import io.github.opencubicchunks.cubicchunks.world.lighting.CubicLayerLightEngine; -import io.github.opencubicchunks.cubicchunks.world.lighting.CubicLayerLightSectionStorage; import net.minecraft.core.BlockPos; import net.minecraft.core.SectionPos; import net.minecraft.world.level.BlockGetter; @@ -51,7 +49,7 @@ public abstract class MixinLayerLightEngine, S @Override public void retainCubeData(CubePos posIn, boolean retain) { long i = posIn.asSectionPos().asLong(); - ((CubicLayerLightSectionStorage) this.storage).retainCubeData(i, retain); + this.storage.retainCubeData(i, retain); } @Override @@ -73,7 +71,7 @@ private void setCubic(LightChunkGetter lightChunkGetter, LightLayer lightLayer, return; } - this.isCubic = ((CubicLevelHeightAccessor) this.chunkSource.getLevel()).isCubic(); + this.isCubic = this.chunkSource.getLevel().isCubic(); // this.generates2DChunks = ((CubicLevelHeightAccessor) this.chunkSource.getLevel()).generates2DChunks(); // this.worldStyle = ((CubicLevelHeightAccessor) this.chunkSource.getLevel()).worldStyle(); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLayerLightSectionStorage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLayerLightSectionStorage.java index 1ff69153..137f9398 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLayerLightSectionStorage.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLayerLightSectionStorage.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.common.level.lighting; import io.github.opencubicchunks.cc_core.api.CubePos; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.world.lighting.CubicLayerLightSectionStorage; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; @@ -70,7 +69,7 @@ public void retainCubeData(long cubeSectionPos, boolean retain) { */ @Inject(method = "markNewInconsistencies", at = @At("HEAD"), cancellable = true) protected void markNewInconsistenciesForCube(LayerLightEngine engine, boolean updateSkyLight, boolean updateBlockLight, CallbackInfo ci) { - if (this.chunkSource.getLevel() == null || !((CubicLevelHeightAccessor) this.chunkSource.getLevel()).isCubic()) { + if (this.chunkSource.getLevel() == null || !this.chunkSource.getLevel().isCubic()) { return; } ci.cancel(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLevelLightEngine.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLevelLightEngine.java index e81adb02..cb212743 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLevelLightEngine.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinLevelLightEngine.java @@ -5,7 +5,6 @@ import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.world.ColumnCubeMapGetter; import io.github.opencubicchunks.cubicchunks.world.level.chunk.CubeAccess; -import io.github.opencubicchunks.cubicchunks.world.lighting.CubicLayerLightEngine; import io.github.opencubicchunks.cubicchunks.world.lighting.CubicLevelLightEngine; import io.github.opencubicchunks.cubicchunks.world.lighting.CubicSkyLightEngine; import io.github.opencubicchunks.cubicchunks.world.lighting.SkyLightColumnChecker; @@ -49,22 +48,22 @@ public abstract class MixinLevelLightEngine implements CubicLevelLightEngine, Li @Override public void retainData(CubePos cubePos, boolean retain) { if (this.blockEngine != null) { - ((CubicLayerLightEngine) this.blockEngine).retainCubeData(cubePos, retain); + this.blockEngine.retainCubeData(cubePos, retain); } if (this.skyEngine != null) { - ((CubicLayerLightEngine) this.skyEngine).retainCubeData(cubePos, retain); + this.skyEngine.retainCubeData(cubePos, retain); } } @Override public void enableLightSources(CubePos cubePos, boolean retain) { if (this.blockEngine != null) { - ((CubicLayerLightEngine) this.blockEngine).enableLightSources(cubePos, retain); + this.blockEngine.enableLightSources(cubePos, retain); } if (this.skyEngine != null) { - ((CubicLayerLightEngine) this.skyEngine).enableLightSources(cubePos, retain); + this.skyEngine.enableLightSources(cubePos, retain); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinSkyLightSectionStorage.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinSkyLightSectionStorage.java index 01ed6819..81e6cf61 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinSkyLightSectionStorage.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinSkyLightSectionStorage.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.mixin.core.common.level.lighting; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.mixin.access.common.LayerLightSectionStorageAccess; import io.github.opencubicchunks.cubicchunks.world.level.chunk.CubeAccess; import io.github.opencubicchunks.cubicchunks.world.level.chunk.LightCubeGetter; @@ -40,7 +39,7 @@ private void onInit(LightChunkGetter lightChunkGetter, CallbackInfo ci) { isCubic = true; return; } - isCubic = ((CubicLevelHeightAccessor) lightChunkGetter.getLevel()).isCubic(); + isCubic = lightChunkGetter.getLevel().isCubic(); } @Inject(method = "getLightValue(JZ)I", cancellable = true, at = @At("HEAD")) diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinThreadedLevelLightEngine.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinThreadedLevelLightEngine.java index 0e962a6e..a86168c0 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinThreadedLevelLightEngine.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/level/lighting/MixinThreadedLevelLightEngine.java @@ -10,7 +10,6 @@ import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; import io.github.opencubicchunks.cc_core.world.ColumnCubeMapGetter; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.server.level.CubeMap; import io.github.opencubicchunks.cubicchunks.server.level.CubeTaskPriorityQueueSorter; import io.github.opencubicchunks.cubicchunks.world.level.chunk.CubeAccess; @@ -59,7 +58,7 @@ public abstract class MixinThreadedLevelLightEngine extends MixinLevelLightEngin */ @Inject(method = "checkBlock", at = @At("HEAD"), cancellable = true) public void checkBlock(BlockPos blockPosIn, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic()) { + if (!this.levelHeightAccessor.isCubic()) { return; } ci.cancel(); @@ -155,7 +154,7 @@ public void checkSkyLightColumn(ColumnCubeMapGetter chunk, int x, int z, int old @Inject(method = "updateChunkStatus", at = @At("HEAD"), cancellable = true) private void cancelUpdateChunkStatus(ChunkPos pos, CallbackInfo ci) { - if (((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic()) { + if (this.levelHeightAccessor.isCubic()) { ci.cancel(); } } @@ -166,7 +165,7 @@ private void cancelUpdateChunkStatus(ChunkPos pos, CallbackInfo ci) { */ @Inject(method = "updateSectionStatus", at = @At("HEAD"), cancellable = true) public void updateSectionStatus(SectionPos pos, boolean isEmpty, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic()) { + if (!this.levelHeightAccessor.isCubic()) { return; } ci.cancel(); @@ -189,7 +188,7 @@ public void enableLightSources(CubePos cubePos, boolean flag) { */ @Inject(method = "queueSectionData", at = @At("HEAD"), cancellable = true) public void queueSectionData(LightLayer type, SectionPos pos, @Nullable DataLayer array, boolean flag, CallbackInfo ci) { - if (!((CubicLevelHeightAccessor) this.levelHeightAccessor).isCubic()) { + if (!this.levelHeightAccessor.isCubic()) { return; } ci.cancel(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/MixinPlayerList.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/MixinPlayerList.java index 2dc45c93..afbf7381 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/MixinPlayerList.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/MixinPlayerList.java @@ -52,8 +52,8 @@ private void setVerticalViewDistance(int viewDistance, CallbackInfo ci) { for (ServerLevel serverLevel : this.server.getAllLevels()) { if (serverLevel != null) { - if (((CubicLevelHeightAccessor) serverLevel).isCubic()) { - ((VerticalViewDistanceListener) serverLevel.getChunkSource()).setIncomingVerticalViewDistance(this.verticalViewDistance); + if (serverLevel.isCubic()) { + serverLevel.getChunkSource().setIncomingVerticalViewDistance(this.verticalViewDistance); } } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/ticket/MixinDistanceManager.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/ticket/MixinDistanceManager.java index cfd4f8ed..c34b2ee2 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/ticket/MixinDistanceManager.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/ticket/MixinDistanceManager.java @@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; @@ -51,20 +52,20 @@ public abstract class MixinDistanceManager implements CubicDistanceManager, Vert private boolean isCubic; // fields below used from ASM - final Long2ObjectMap> playersPerCube = new Long2ObjectOpenHashMap<>(); - final Long2ObjectOpenHashMap>> cubeTickets = new Long2ObjectOpenHashMap<>(); - private final CubeTicketTracker cubeTicketTracker = new CubeTicketTracker(this); - - private final FixedPlayerDistanceCubeTracker naturalSpawnCubeCounter = new FixedPlayerDistanceCubeTracker(this, 8 / CubicConstants.DIAMETER_IN_SECTIONS); - private final CubeTickingTracker tickingCubeTicketsTracker = new CubeTickingTracker(); - private final CubicPlayerTicketTracker cubicPlayerTicketManager = new CubicPlayerTicketTracker(this, MathUtil.ceilDiv(33, CubicConstants.DIAMETER_IN_SECTIONS)); - final Set cubesToUpdateFutures = Sets.newHashSet(); - CubeTaskPriorityQueueSorter cubeTicketThrottler; - ProcessorHandle> cubeTicketThrottlerInput; - ProcessorHandle cubeTicketThrottlerReleaser; - final LongSet cubeTicketsToRelease = new LongOpenHashSet(); - - private long cubeTicketTickCounter; + @UsedFromASM final Long2ObjectMap> playersPerCube = new Long2ObjectOpenHashMap<>(); + @UsedFromASM final Long2ObjectOpenHashMap>> cubeTickets = new Long2ObjectOpenHashMap<>(); + @UsedFromASM private final CubeTicketTracker cubeTicketTracker = new CubeTicketTracker(this); + + @UsedFromASM private final FixedPlayerDistanceCubeTracker naturalSpawnCubeCounter = new FixedPlayerDistanceCubeTracker(this, 8 / CubicConstants.DIAMETER_IN_SECTIONS); + @UsedFromASM private final CubeTickingTracker tickingCubeTicketsTracker = new CubeTickingTracker(); + @UsedFromASM private final CubicPlayerTicketTracker cubicPlayerTicketManager = new CubicPlayerTicketTracker(this, MathUtil.ceilDiv(33, CubicConstants.DIAMETER_IN_SECTIONS)); + @UsedFromASM final Set cubesToUpdateFutures = Sets.newHashSet(); + @UsedFromASM CubeTaskPriorityQueueSorter cubeTicketThrottler; + @UsedFromASM ProcessorHandle> cubeTicketThrottlerInput; + @UsedFromASM ProcessorHandle cubeTicketThrottlerReleaser; + @UsedFromASM final LongSet cubeTicketsToRelease = new LongOpenHashSet(); + + @UsedFromASM private long cubeTicketTickCounter; @Shadow abstract void addTicket(long position, Ticket ticket); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/server/chunk/MixinLevelChunk.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/server/chunk/MixinLevelChunk.java index f482b953..99fcb895 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/server/chunk/MixinLevelChunk.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/server/chunk/MixinLevelChunk.java @@ -5,7 +5,6 @@ import javax.annotation.Nullable; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.world.level.chunk.ColumnCubeGetter; import io.github.opencubicchunks.cubicchunks.world.level.chunk.LevelCube; import net.fabricmc.api.EnvType; @@ -51,13 +50,13 @@ public MixinLevelChunk(ChunkPos chunkPos, UpgradeData upgradeData, at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;")) private Object getTileEntity(Map map, Object key) { if (map == this.blockEntities) { - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { return map.get(key); } LevelCube cube = (LevelCube) ((ColumnCubeGetter) this).getCube(Coords.blockToSection(((BlockPos) key).getY())); return cube.getTileEntityMap().get(key); } else if (map == this.pendingBlockEntities) { - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { return map.get(key); } LevelCube cube = (LevelCube) ((ColumnCubeGetter) this).getCube(Coords.blockToSection(((BlockPos) key).getY())); @@ -76,7 +75,7 @@ private Object removeTileEntity(Map map, // to respect our priority over theirs. if (map == this.blockEntities) { - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { @Nullable Object removed = map.remove(key); @@ -95,7 +94,7 @@ private Object removeTileEntity(Map map, } return removed; } else if (map == this.pendingBlockEntities) { - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { return map.remove(key); } LevelCube cube = (LevelCube) ((ColumnCubeGetter) this).getCube(Coords.blockToSection(((BlockPos) key).getY())); @@ -114,13 +113,13 @@ private Object putTileEntity(Map map, Object key, Object value) { ServerBlockEntityEvents.BLOCK_ENTITY_LOAD.invoker().onLoad((BlockEntity) value, (ServerLevel) this.getLevel()); } - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { return map.put(key, value); } LevelCube cube = (LevelCube) ((ColumnCubeGetter) this).getCube(Coords.blockToSection(((BlockPos) key).getY())); return cube.getTileEntityMap().put((BlockPos) key, (BlockEntity) value); } else if (map == this.pendingBlockEntities) { - if (!((CubicLevelHeightAccessor) this).isCubic()) { + if (!this.isCubic()) { return map.put(key, value); } LevelCube cube = (LevelCube) ((ColumnCubeGetter) this).getCube(Coords.blockToSection(((BlockPos) key).getY())); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinClientLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinClientLevel.java index ea46acb4..7739f28d 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinClientLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinClientLevel.java @@ -2,7 +2,6 @@ import java.util.function.Supplier; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.debug.DebugVisualization; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientPacketListener; @@ -32,7 +31,7 @@ protected MixinClientLevel(WritableLevelData writableLevelData, private void onClientWorldConstruct(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey, Holder holder, int i, int j, Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) { - if (((CubicLevelHeightAccessor) this).isCubic()) { + if (this.isCubic()) { DebugVisualization.onWorldLoad(this); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinMinecraft.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinMinecraft.java index 5989cc0f..804cf229 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinMinecraft.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinMinecraft.java @@ -2,7 +2,6 @@ import javax.annotation.Nullable; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.debug.DebugVisualization; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; @@ -21,7 +20,7 @@ public class MixinMinecraft { @Inject(method = "setLevel", at = @At("HEAD")) private void unloadWorld(ClientLevel clientLevel, CallbackInfo ci) { if (this.level != null) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } DebugVisualization.onWorldUnload(this.level); @@ -31,7 +30,7 @@ private void unloadWorld(ClientLevel clientLevel, CallbackInfo ci) { @Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD")) private void unloadWorld(Screen screen, CallbackInfo ci) { if (this.level != null) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } DebugVisualization.onWorldUnload(this.level); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinMinecraftServer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinMinecraftServer.java index 155c2e52..3b8e44a9 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinMinecraftServer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/client/MixinMinecraftServer.java @@ -3,7 +3,6 @@ import java.io.IOException; import java.util.Map; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.debug.DebugVisualization; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; @@ -31,7 +30,7 @@ public class MixinMinecraftServer { private void onLoadWorlds(ChunkProgressListener chunkProgressListener, CallbackInfo ci) { for (Map.Entry, LevelStem> lvl : this.worldData.worldGenSettings().dimensions().entrySet()) { ServerLevel serverLevel = levels.get(lvl.getKey()); - if (((CubicLevelHeightAccessor) serverLevel).isCubic()) { + if (serverLevel.isCubic()) { DebugVisualization.onWorldLoad(serverLevel); } } @@ -39,7 +38,7 @@ private void onLoadWorlds(ChunkProgressListener chunkProgressListener, CallbackI @Redirect(method = "stopServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;close()V")) private void onUnloadWorld(ServerLevel serverLevel) throws IOException { - if (((CubicLevelHeightAccessor) serverLevel).isCubic()) { + if (serverLevel.isCubic()) { DebugVisualization.onWorldUnload(serverLevel); } serverLevel.close(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/common/MixinMinecraftServer.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/common/MixinMinecraftServer.java index 8904a95f..b698d374 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/common/MixinMinecraftServer.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/common/MixinMinecraftServer.java @@ -72,20 +72,19 @@ private void prepareLevels(ChunkProgressListener progressListener, CallbackInfo serverChunkCache.getLightEngine().setTaskPerBatch(500); this.nextTickTime = Util.getMillis(); - ServerCubeCache prov = (ServerCubeCache) serverChunkCache; addChunk(serverChunkCache, new ChunkPos(0, 0)); - addCube(prov, CubePos.of(0, 0, 0)); - - addCube(prov, CubePos.of(5, 5, 5)); - addCube(prov, CubePos.of(-5, 5, 5)); - addCube(prov, CubePos.of(-5, -5, 5)); - addCube(prov, CubePos.of(-5, -5, -5)); - addCube(prov, CubePos.of(5, -5, 5)); - addCube(prov, CubePos.of(5, -5, -5)); - addCube(prov, CubePos.of(5, 5, -5)); - addCube(prov, CubePos.of(-5, 5, -5)); - - while (this.isRunning() && (serverChunkCache.getTickingGenerated() + prov.getTickingGeneratedCubes() < count)) { + addCube(serverChunkCache, CubePos.of(0, 0, 0)); + + addCube(serverChunkCache, CubePos.of(5, 5, 5)); + addCube(serverChunkCache, CubePos.of(-5, 5, 5)); + addCube(serverChunkCache, CubePos.of(-5, -5, 5)); + addCube(serverChunkCache, CubePos.of(-5, -5, -5)); + addCube(serverChunkCache, CubePos.of(5, -5, 5)); + addCube(serverChunkCache, CubePos.of(5, -5, -5)); + addCube(serverChunkCache, CubePos.of(5, 5, -5)); + addCube(serverChunkCache, CubePos.of(-5, 5, -5)); + + while (this.isRunning() && (serverChunkCache.getTickingGenerated() + serverChunkCache.getTickingGeneratedCubes() < count)) { this.nextTickTime = Util.getMillis() + 10L; this.waitUntilNextTick(); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/common/MixinServerLevel.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/common/MixinServerLevel.java index 4773bd6e..1daa2c14 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/common/MixinServerLevel.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/debug/common/MixinServerLevel.java @@ -60,8 +60,8 @@ private void verifyHeightmapState(BooleanSupplier booleanSupplier, CallbackInfo //ProtoChunks only contain a global light heightmap if (chunk instanceof ProtoChunk protoChunk && !(chunk instanceof ImposterProtoChunk)) { - ColumnCubeMap cubeMap = ((ColumnCubeMapGetter) protoChunk).getCubeMap(); - LightSurfaceTrackerWrapper heightmap = ((LightHeightmapGetter) protoChunk).getServerLightHeightmap(); + ColumnCubeMap cubeMap = protoChunk.getCubeMap(); + LightSurfaceTrackerWrapper heightmap = protoChunk.getServerLightHeightmap(); if (heightmap != null) { SurfaceTrackerBranch root = heightmap.getSurfaceTrackerSection(); verifyHeightmapTree(root, cubeMap); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/MixinBeardifier.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/MixinBeardifier.java index 3f0553a1..95bd6dbb 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/MixinBeardifier.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/MixinBeardifier.java @@ -5,7 +5,6 @@ import javax.annotation.Nullable; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import net.minecraft.world.level.StructureFeatureManager; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.levelgen.Beardifier; @@ -25,7 +24,7 @@ public class MixinBeardifier { at = @At(value = "INVOKE", target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V")) private void setupChunkAccess(List list, Consumer action, StructureFeatureManager structureFeatureManager, ChunkAccess chunk) { - if (((CubicLevelHeightAccessor) chunk).generates2DChunks()) { + if (chunk.generates2DChunks()) { list.forEach(action); return; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/MixinChunkGenerator.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/MixinChunkGenerator.java index 24fa685b..3980db0e 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/MixinChunkGenerator.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/MixinChunkGenerator.java @@ -20,13 +20,11 @@ import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.Coords; import io.github.opencubicchunks.cc_core.utils.Utils; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.levelgen.CubeWorldGenRegion; import io.github.opencubicchunks.cubicchunks.levelgen.biome.StripedBiomeSource; import io.github.opencubicchunks.cubicchunks.levelgen.chunk.CubeGenerator; import io.github.opencubicchunks.cubicchunks.levelgen.util.CubicWorldGenUtils; import io.github.opencubicchunks.cubicchunks.levelgen.util.NonAtomicWorldgenRandom; -import io.github.opencubicchunks.cubicchunks.world.level.CubicLevelAccessor; import io.github.opencubicchunks.cubicchunks.world.level.chunk.CubeAccess; import io.github.opencubicchunks.cubicchunks.world.level.chunk.ProtoCube; import it.unimi.dsi.fastutil.ints.IntArraySet; @@ -118,7 +116,7 @@ private void switchBiomeSource(Registry registry, Optional configuredStruct @Inject(method = "createReferences", at = @At("HEAD"), cancellable = true) public void createReferences(WorldGenLevel worldGenLevel, StructureFeatureManager featureManager, ChunkAccess chunkAccess, CallbackInfo ci) { - if (((CubicLevelHeightAccessor) chunkAccess).generates2DChunks()) { + if (chunkAccess.generates2DChunks()) { return; } if (!(chunkAccess instanceof CubeAccess cube)) { @@ -358,7 +356,7 @@ public void findNearestMapFeature3D(ServerLevel serverLevel, HolderSet>>> cir, Set> structureBiomes, Set> possibleBiomes, Pair>> nearestStructure, double nearestDistance, Map>>> structuresPerPlacement) { - if (((CubicLevelHeightAccessor) serverLevel).generates2DChunks()) { + if (serverLevel.generates2DChunks()) { return; } @@ -471,7 +469,7 @@ public void findNearestMapFeature3D(ServerLevel serverLevel, HolderSet featurePlaceContext, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) featurePlaceContext.level()).isCubic()) { + if (!featurePlaceContext.level().isCubic()) { return; } if (featurePlaceContext.origin().getY() > featurePlaceContext.chunkGenerator().getSeaLevel() diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/MixinLakeFeature.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/MixinLakeFeature.java index 154387da..3dcc58a5 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/MixinLakeFeature.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/MixinLakeFeature.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.levelgen.common.feature; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.LakeFeature; @@ -14,7 +13,7 @@ public class MixinLakeFeature { @Redirect(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/WorldGenLevel;getMinBuildHeight()I", ordinal = 0)) private int cubicLakeFeature(WorldGenLevel level, FeaturePlaceContext featurePlaceContext) { - if (!((CubicLevelHeightAccessor) featurePlaceContext.level()).isCubic()) { + if (!featurePlaceContext.level().isCubic()) { return featurePlaceContext.level().getMinBuildHeight(); } return featurePlaceContext.origin().getY(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/MixinSpringFeature.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/MixinSpringFeature.java index 57025129..edbec3fa 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/MixinSpringFeature.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/MixinSpringFeature.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.levelgen.common.feature; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.SpringFeature; import net.minecraft.world.level.levelgen.feature.configurations.SpringConfiguration; @@ -15,7 +14,7 @@ public class MixinSpringFeature { @Inject(at = @At("HEAD"), method = "place", cancellable = true) private void cancel(FeaturePlaceContext featurePlaceContext, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) featurePlaceContext.level()).isCubic()) { + if (!featurePlaceContext.level().isCubic()) { return; } cir.setReturnValue(true); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinBasaltPillarFeature.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinBasaltPillarFeature.java index 4610bca8..7362878b 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinBasaltPillarFeature.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinBasaltPillarFeature.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.levelgen.common.feature.nether; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.levelgen.CubeWorldGenRegion; import net.minecraft.core.BlockPos; import net.minecraft.world.level.WorldGenLevel; @@ -14,7 +13,7 @@ public class MixinBasaltPillarFeature { @Redirect(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/WorldGenLevel;isOutsideBuildHeight(Lnet/minecraft/core/BlockPos;)Z")) private boolean useCubeMinY(WorldGenLevel worldGenLevel, BlockPos blockPos) { - if (!((CubicLevelHeightAccessor) worldGenLevel).isCubic()) { + if (!worldGenLevel.isCubic()) { return worldGenLevel.isOutsideBuildHeight(blockPos); } return !((CubeWorldGenRegion) worldGenLevel).insideCubeHeight(blockPos.getY()); @@ -22,7 +21,7 @@ private boolean useCubeMinY(WorldGenLevel worldGenLevel, BlockPos blockPos) { @Redirect(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/WorldGenLevel;isEmptyBlock(Lnet/minecraft/core/BlockPos;)Z", ordinal = 4)) private boolean cancelOutOfCubeBounds(WorldGenLevel level, BlockPos pos) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return level.isEmptyBlock(pos); } return ((CubeWorldGenRegion) level).insideCubeHeight(pos.getY()) && level.isEmptyBlock(pos); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinHugeFungusFeature.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinHugeFungusFeature.java index 289dbcea..2df235d5 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinHugeFungusFeature.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinHugeFungusFeature.java @@ -3,7 +3,6 @@ import java.util.Random; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.levelgen.CubeWorldGenRegion; import net.minecraft.core.BlockPos; import net.minecraft.tags.FluidTags; @@ -25,7 +24,7 @@ public class MixinHugeFungusFeature { @Redirect(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/ChunkGenerator;getGenDepth()I")) private int useCubeRegionBounds(ChunkGenerator chunkGenerator, FeaturePlaceContext context) { - if (!((CubicLevelHeightAccessor) context.level()).isCubic()) { + if (!context.level().isCubic()) { return chunkGenerator.getGenDepth(); } return Coords.cubeToMaxBlock(((CubeWorldGenRegion) context.level()).getMaxCubeY()); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinReplaceBlobsFeature.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinReplaceBlobsFeature.java index a256d06a..ec8690a8 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinReplaceBlobsFeature.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinReplaceBlobsFeature.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.mixin.levelgen.common.feature.nether; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.levelgen.CubeWorldGenRegion; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.levelgen.feature.ReplaceBlobsFeature; @@ -14,7 +13,7 @@ public class MixinReplaceBlobsFeature { @Redirect(method = "findTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelAccessor;getMinBuildHeight()I")) private static int useCubeMinY(LevelAccessor levelAccessor) { - if (!((CubicLevelHeightAccessor) levelAccessor).isCubic()) { + if (!levelAccessor.isCubic()) { return levelAccessor.getMinBuildHeight(); } return Coords.cubeToMinBlock(((CubeWorldGenRegion) levelAccessor).getMainCubeY()); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinTwistyVinesFeature.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinTwistyVinesFeature.java index 3b4438bb..47976d58 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinTwistyVinesFeature.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/feature/nether/MixinTwistyVinesFeature.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.levelgen.common.feature.nether; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.levelgen.CubeWorldGenRegion; import net.minecraft.core.BlockPos; import net.minecraft.world.level.LevelAccessor; @@ -14,7 +13,7 @@ public class MixinTwistyVinesFeature { @Redirect(method = "findFirstAirBlockAboveGround", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelAccessor;isOutsideBuildHeight(Lnet/minecraft/core/BlockPos;)Z")) private static boolean isOutsideCubeY(LevelAccessor levelAccessor, BlockPos blockPos) { - if (!((CubicLevelHeightAccessor) levelAccessor).isCubic()) { + if (!levelAccessor.isCubic()) { return levelAccessor.isOutsideBuildHeight(blockPos); } return !((CubeWorldGenRegion) levelAccessor).insideCubeHeight(blockPos.getY()); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/placement/MixinHeightRangePlacement.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/placement/MixinHeightRangePlacement.java index 62b52b87..f616bb75 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/placement/MixinHeightRangePlacement.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/placement/MixinHeightRangePlacement.java @@ -5,7 +5,6 @@ import java.util.stream.Stream; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.levelgen.CubeWorldGenRegion; import io.github.opencubicchunks.cubicchunks.levelgen.placement.CubicHeightProvider; import net.minecraft.core.BlockPos; @@ -26,7 +25,7 @@ public class MixinHeightRangePlacement { @Inject(method = "getPositions", at = @At("HEAD"), cancellable = true) private void handleCubicRangeDecorator(PlacementContext placementContext, Random random, BlockPos blockPos, CallbackInfoReturnable> cir) { - if (!((CubicLevelHeightAccessor) placementContext.getLevel()).isCubic()) { + if (!placementContext.getLevel().isCubic()) { return; } CubeWorldGenRegion level = (CubeWorldGenRegion) placementContext.getLevel(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/structure/MixinStructurePiece.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/structure/MixinStructurePiece.java index b530cde5..678986bd 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/structure/MixinStructurePiece.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/levelgen/common/structure/MixinStructurePiece.java @@ -1,7 +1,6 @@ package io.github.opencubicchunks.cubicchunks.mixin.levelgen.common.structure; import io.github.opencubicchunks.cc_core.utils.Coords; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.levelgen.CubeWorldGenRegion; import io.github.opencubicchunks.cubicchunks.world.level.CubicLevelAccessor; import net.minecraft.core.BlockPos; @@ -18,7 +17,7 @@ public class MixinStructurePiece { @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/WorldGenLevel;getChunk(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/chunk/ChunkAccess;"), method = "placeBlock") private ChunkAccess getCube(WorldGenLevel worldGenLevel, BlockPos blockPos) { - if (((CubicLevelHeightAccessor) worldGenLevel).generates2DChunks()) { + if (worldGenLevel.generates2DChunks()) { return worldGenLevel.getChunk(blockPos); } return ((CubicLevelAccessor) worldGenLevel).getCube(blockPos); @@ -26,7 +25,7 @@ private ChunkAccess getCube(WorldGenLevel worldGenLevel, BlockPos blockPos) { @Redirect(method = "fillColumnDown", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/WorldGenLevel;getMinBuildHeight()I")) private int fillToRegionBottom(WorldGenLevel level) { - if (!((CubicLevelHeightAccessor) level).isCubic()) { + if (!level.isCubic()) { return level.getMinBuildHeight(); } return Coords.cubeToMinBlock(((CubeWorldGenRegion) level).getMinCubeY()); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/optifine/client/vanilla/MixinWorldRenderer_Vanilla.java b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/optifine/client/vanilla/MixinWorldRenderer_Vanilla.java index 48abd62a..d74962f6 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/optifine/client/vanilla/MixinWorldRenderer_Vanilla.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/mixin/optifine/client/vanilla/MixinWorldRenderer_Vanilla.java @@ -1,6 +1,5 @@ package io.github.opencubicchunks.cubicchunks.mixin.optifine.client.vanilla; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cubicchunks.CubicChunks; import io.github.opencubicchunks.cubicchunks.mixin.access.client.ViewAreaAccess; import net.minecraft.client.Camera; @@ -63,7 +62,7 @@ private void setLastVerticalViewDistance(CallbackInfo ci) { private void getRelativeFrom(BlockPos playerPos, ChunkRenderDispatcher.RenderChunk renderChunkBase, Direction facing, CallbackInfoReturnable cir) { - if (!((CubicLevelHeightAccessor) this.level).isCubic()) { + if (!this.level.isCubic()) { return; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeHolder.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeHolder.java index e4e15bd8..699b6b4f 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeHolder.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeHolder.java @@ -9,6 +9,7 @@ import javax.annotation.Nullable; import com.mojang.datafixers.util.Either; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cubicchunks.mixin.access.common.ChunkHolderAccess; import io.github.opencubicchunks.cubicchunks.world.level.chunk.CubeAccess; @@ -38,6 +39,7 @@ static ChunkStatus getCubeStatusFromLevel(int cubeLevel) { @Nullable LevelCube getTickingCube(); + @UsedFromASM CubePos getCubePos(); // getOrScheduleFuture @@ -65,6 +67,7 @@ static ChunkStatus getCubeStatusFromLevel(int cubeLevel) { // added with ASM, can't be shadow because mixin validates shadows before preApply runs void updateCubeFutures(ChunkMap chunkManagerIn, Executor executor); + @UsedFromASM class CubeLoadingError implements ChunkHolder.ChunkLoadingFailure { private final ChunkHolder holder; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeHolderLevelChangeListener.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeHolderLevelChangeListener.java index ec750095..23f5576b 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeHolderLevelChangeListener.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeHolderLevelChangeListener.java @@ -3,8 +3,10 @@ import java.util.function.IntConsumer; import java.util.function.IntSupplier; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; public interface CubeHolderLevelChangeListener { + @UsedFromASM void onCubeLevelChange(CubePos pos, IntSupplier intSupplier, int i, IntConsumer consumer); } \ No newline at end of file diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeMap.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeMap.java index ef7fd34e..1c009080 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeMap.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeMap.java @@ -8,6 +8,7 @@ import javax.annotation.Nullable; import com.mojang.datafixers.util.Either; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.utils.Coords; import io.github.opencubicchunks.cubicchunks.world.level.chunk.CubeAccess; @@ -22,7 +23,7 @@ import net.minecraft.world.level.chunk.ChunkStatus; public interface CubeMap { - int MAX_CUBE_DISTANCE = 33 + CubeStatus.maxDistance(); + @UsedFromASM int MAX_CUBE_DISTANCE = 33 + CubeStatus.maxDistance(); // getTickingGenerated int getTickingGeneratedCubes(); @@ -32,21 +33,19 @@ public interface CubeMap { // implemented by ASM in MainTransformer @Nullable - ChunkHolder updateCubeScheduling(long cubePosIn, int newLevel, @Nullable ChunkHolder holder, int oldLevel); + @UsedFromASM ChunkHolder updateCubeScheduling(long cubePosIn, int newLevel, @Nullable ChunkHolder holder, int oldLevel); void setServerChunkCache(ServerChunkCache cache); - // used from ASM - void markCubePositionReplaceable(CubePos cubePos); + @UsedFromASM void markCubePositionReplaceable(CubePos cubePos); - // used from ASM - byte markCubePosition(CubePos cubePos, ChunkStatus.ChunkType status); + @UsedFromASM byte markCubePosition(CubePos cubePos, ChunkStatus.ChunkType status); LongSet getCubesToDrop(); // getUpdatingChunkIfPresent @Nullable - ChunkHolder getUpdatingCubeIfPresent(long cubePosIn); + @UsedFromASM ChunkHolder getUpdatingCubeIfPresent(long cubePosIn); // getVisibleChunkIfPresent @Nullable @@ -57,18 +56,18 @@ CompletableFuture> scheduleC ChunkStatus chunkStatusIn); // prepareAccessibleChunk - CompletableFuture> prepareAccessibleCube(ChunkHolder chunkHolder); + @UsedFromASM CompletableFuture> prepareAccessibleCube(ChunkHolder chunkHolder); // prepareTickingChunk - CompletableFuture> prepareTickingCube(ChunkHolder chunkHolder); + @UsedFromASM CompletableFuture> prepareTickingCube(ChunkHolder chunkHolder); + + // prepareEntityTickingChunk + @UsedFromASM CompletableFuture> prepareEntityTickingCube(CubePos pos); // getChunkRangeFuture CompletableFuture, ChunkHolder.ChunkLoadingFailure>> getCubeRangeFuture(CubePos pos, int radius, IntFunction getParentStatus); - // prepareEntityTickingChunk - CompletableFuture> prepareEntityTickingCube(CubePos pos); - // getChunks Iterable getCubes(); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTaskPriorityQueue.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTaskPriorityQueue.java index 6ab24712..01b8a85c 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTaskPriorityQueue.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTaskPriorityQueue.java @@ -1,5 +1,8 @@ package io.github.opencubicchunks.cubicchunks.server.level; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; + public class CubeTaskPriorityQueue { + @UsedFromASM public static int LEVEL_COUNT = -1; } \ No newline at end of file diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTaskPriorityQueueSorter.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTaskPriorityQueueSorter.java index 945c9af1..66431fe1 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTaskPriorityQueueSorter.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTaskPriorityQueueSorter.java @@ -6,40 +6,48 @@ import java.util.function.IntConsumer; import java.util.function.IntSupplier; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import net.minecraft.server.level.ChunkHolder; import net.minecraft.util.Unit; import net.minecraft.util.thread.ProcessorHandle; +@UsedFromASM public class CubeTaskPriorityQueueSorter implements AutoCloseable, CubeHolderLevelChangeListener { public CubeTaskPriorityQueueSorter(List> taskExecutors, Executor executor, int p_i50713_3_) { throw new Error("ASM didn't apply"); } + @UsedFromASM public static Message message(Runnable runnable, long pos, IntSupplier intSupplier) { throw new Error("ASM didn't apply"); } + @UsedFromASM public static Message message(ChunkHolder holder, Runnable runnable) { throw new Error("ASM didn't apply"); } + @UsedFromASM public static Release release(Runnable runnable, long pos, boolean flag) { throw new Error("ASM didn't apply"); } + @UsedFromASM public ProcessorHandle> getProcessor(ProcessorHandle processorHandle, boolean flag) { throw new Error("ASM didn't apply"); } // func_219091_a, getReleaseProcessor + @UsedFromASM public ProcessorHandle getReleaseProcessor(ProcessorHandle processorHandle) { throw new Error("ASM didn't apply"); } // func_219066_a, onLevelChange @Override + @UsedFromASM public void onCubeLevelChange(CubePos pos, IntSupplier getLevel, int level, IntConsumer setLevel) { throw new Error("ASM didn't apply"); } @@ -48,10 +56,11 @@ public void onCubeLevelChange(CubePos pos, IntSupplier getLevel, int level, IntC throw new Error("ASM didn't apply"); } + @UsedFromASM public static final class Message { - final Function, T> task; - final long pos; - final IntSupplier level; + @UsedFromASM final Function, T> task; + @UsedFromASM final long pos; + @UsedFromASM final IntSupplier level; Message(Function, T> function, long l, IntSupplier intSupplier) { this.task = function; @@ -60,10 +69,11 @@ public static final class Message { } } + @UsedFromASM public static final class Release { - final Runnable task; - final long pos; - final boolean clearQueue; + @UsedFromASM final Runnable task; + @UsedFromASM final long pos; + @UsedFromASM final boolean clearQueue; Release(Runnable runnable, long l, boolean bl) { this.task = runnable; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTicketTracker.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTicketTracker.java index cb41cc53..cd3c619d 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTicketTracker.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTicketTracker.java @@ -1,11 +1,13 @@ package io.github.opencubicchunks.cubicchunks.server.level; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.Ticket; import net.minecraft.util.SortedArraySet; // TODO: DASM, have to duplicate whole class +@UsedFromASM public class CubeTicketTracker extends CubeTracker { private final CubicDistanceManager cubicDistanceManager; @@ -47,7 +49,7 @@ protected void setLevel(long sectionPos, int level) { } } - // Used from ASM + @UsedFromASM public int runDistanceUpdates(int distance) { return this.runUpdates(distance); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTickingTracker.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTickingTracker.java index 8fade133..c697204f 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTickingTracker.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTickingTracker.java @@ -4,6 +4,7 @@ import java.util.List; import com.mojang.datafixers.util.Pair; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cubicchunks.mixin.access.common.TicketAccess; import it.unimi.dsi.fastutil.longs.Long2ByteMap; @@ -15,6 +16,7 @@ import net.minecraft.server.level.TicketType; import net.minecraft.util.SortedArraySet; +@UsedFromASM public class CubeTickingTracker extends CubeTracker { private static final int INITIAL_TICKET_LIST_CAPACITY = 4; protected final Long2ByteMap chunks = new Long2ByteOpenHashMap(); @@ -25,6 +27,7 @@ public CubeTickingTracker() { this.chunks.defaultReturnValue((byte) 33); } + @UsedFromASM private SortedArraySet> getTickets(long l) { return this.tickets.computeIfAbsent(l, (lx) -> SortedArraySet.create(4)); } @@ -33,6 +36,7 @@ private int getTicketLevelAt(SortedArraySet> sortedArraySet) { return sortedArraySet.isEmpty() ? 34 : sortedArraySet.first().getTicketLevel(); } + @UsedFromASM public void addTicket(long l, Ticket ticket) { SortedArraySet> sortedArraySet = this.getTickets(l); int i = this.getTicketLevelAt(sortedArraySet); @@ -42,10 +46,12 @@ public void addTicket(long l, Ticket ticket) { } } + @UsedFromASM public void addTicket(TicketType ticketType, CubePos chunkPos, int i, T object) { this.addTicket(chunkPos.asLong(), TicketAccess.createNew(ticketType, i, object)); } + @UsedFromASM public void removeTicket(long l, Ticket ticket) { SortedArraySet> sortedArraySet = this.getTickets(l); sortedArraySet.remove(ticket); @@ -56,11 +62,13 @@ public void removeTicket(long l, Ticket ticket) { this.update(l, this.getTicketLevelAt(sortedArraySet), false); } + @UsedFromASM public void removeTicket(TicketType ticketType, CubePos chunkPos, int i, T object) { Ticket ticket = TicketAccess.createNew(ticketType, i, object); this.removeTicket(chunkPos.asLong(), ticket); } + @UsedFromASM public void replacePlayerTicketsLevel(int i) { List, Long>> list = new ArrayList<>(); ObjectIterator>>> var3 = this.tickets.long2ObjectEntrySet().iterator(); @@ -92,6 +100,7 @@ protected int getLevelFromSource(long pos) { return sortedArraySet != null && !sortedArraySet.isEmpty() ? sortedArraySet.first().getTicketLevel() : Integer.MAX_VALUE; } + @UsedFromASM public int getLevel(CubePos chunkPos) { return this.getLevel(chunkPos.asLong()); } @@ -108,10 +117,12 @@ protected void setLevel(long sectionPos, int level) { } } + @UsedFromASM public void runAllUpdates() { this.runUpdates(Integer.MAX_VALUE); } + @UsedFromASM public String getTicketDebugString(long l) { SortedArraySet> sortedArraySet = this.tickets.get(l); return sortedArraySet != null && !sortedArraySet.isEmpty() ? sortedArraySet.first().toString() : "no_ticket"; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTracker.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTracker.java index 6e6be050..fa0b5fe4 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTracker.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubeTracker.java @@ -1,5 +1,6 @@ package io.github.opencubicchunks.cubicchunks.server.level; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import net.minecraft.world.level.lighting.DynamicGraphMinFixedPoint; @@ -86,6 +87,7 @@ protected CubeTracker(int levelCount, int expectedUpdatesByLevel, int expectedPr protected abstract int getLevelFromSource(long pos); + @UsedFromASM public void update(long pos, int level, boolean isDecreasing) { this.checkEdge(Long.MAX_VALUE, pos, level, isDecreasing); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubicDistanceManager.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubicDistanceManager.java index aa89369d..137e2df9 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubicDistanceManager.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubicDistanceManager.java @@ -5,6 +5,7 @@ import javax.annotation.Nullable; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cubicchunks.world.level.chunk.CubeStatus; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; @@ -27,8 +28,7 @@ public interface CubicDistanceManager { int PLAYER_CUBE_TICKET_LEVEL = 33 + CubeStatus.getDistance(ChunkStatus.FULL) - 2; - // implemented by ASM unless specified otherwise - void purgeStaleCubeTickets(); + @UsedFromASM void purgeStaleCubeTickets(); // isChunkToRemove boolean isCubeToRemove(long sectionPos); @@ -39,41 +39,40 @@ public interface CubicDistanceManager { @Nullable ChunkHolder updateCubeScheduling(long cubePosIn, int newLevel, @Nullable ChunkHolder holder, int oldLevel); - boolean runAllUpdatesCubic(ChunkMap chunkManager); + @UsedFromASM boolean runAllUpdatesCubic(ChunkMap chunkManager); - void addCubeTicket(long chunkPosIn, Ticket ticketIn); + @UsedFromASM void addCubeTicket(long chunkPosIn, Ticket ticketIn); - void removeCubeTicket(long chunkPosIn, Ticket ticketIn); + @UsedFromASM void removeCubeTicket(long chunkPosIn, Ticket ticketIn); - void addCubeTicket(TicketType type, CubePos pos, int level, T value); + @UsedFromASM void addCubeTicket(TicketType type, CubePos pos, int level, T value); - void removeCubeTicket(TicketType type, CubePos pos, int level, T value); + @UsedFromASM void removeCubeTicket(TicketType type, CubePos pos, int level, T value); - void addCubeRegionTicket(TicketType type, CubePos pos, int distance, T value); + @UsedFromASM void addCubeRegionTicket(TicketType type, CubePos pos, int distance, T value); - void removeCubeRegionTicket(TicketType type, CubePos pos, int distance, T value); + @UsedFromASM void removeCubeRegionTicket(TicketType type, CubePos pos, int distance, T value); - SortedArraySet> getCubeTickets(long cubePosLong); + @UsedFromASM SortedArraySet> getCubeTickets(long cubePosLong); - void updateCubeForced(CubePos pos, boolean add); + @UsedFromASM void updateCubeForced(CubePos pos, boolean add); - void addCubePlayer(SectionPos sectionPos, ServerPlayer player); + @UsedFromASM void addCubePlayer(SectionPos sectionPos, ServerPlayer player); - void removeCubePlayer(SectionPos sectionPos, ServerPlayer player); + @UsedFromASM void removeCubePlayer(SectionPos sectionPos, ServerPlayer player); - boolean isEntityTickingRangeCube(long cubePos); + @UsedFromASM boolean isEntityTickingRangeCube(long cubePos); - boolean isBlockTickingRangeCube(long cubePos); + @UsedFromASM boolean isBlockTickingRangeCube(long cubePos); // updatePlayerTickets, implemented manually - horizontal+vertical distance void updatePlayerCubeTickets(int horizontalViewDistance, int verticalViewDistance); - int getNaturalSpawnCubeCount(); + @UsedFromASM int getNaturalSpawnCubeCount(); - boolean hasPlayersNearbyCube(long cubePosIn); - - void removeCubeTicketsOnClosing(); + @UsedFromASM boolean hasPlayersNearbyCube(long cubePosIn); + @UsedFromASM void removeCubeTicketsOnClosing(); // accessors implemented manually diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubicPlayerTicketTracker.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubicPlayerTicketTracker.java index db692a7c..b90ba955 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubicPlayerTicketTracker.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/CubicPlayerTicketTracker.java @@ -1,5 +1,6 @@ package io.github.opencubicchunks.cubicchunks.server.level; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cubicchunks.CubicChunks; @@ -13,6 +14,7 @@ import it.unimi.dsi.fastutil.longs.LongSet; import net.minecraft.server.level.Ticket; +@UsedFromASM public class CubicPlayerTicketTracker extends FixedPlayerDistanceCubeTracker { private int horizontalViewDistance; private int verticalViewDistance; diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/FixedPlayerDistanceCubeTracker.java b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/FixedPlayerDistanceCubeTracker.java index 49df8a12..c3979260 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/FixedPlayerDistanceCubeTracker.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/server/level/FixedPlayerDistanceCubeTracker.java @@ -1,11 +1,14 @@ package io.github.opencubicchunks.cubicchunks.server.level; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import it.unimi.dsi.fastutil.longs.Long2ByteMap; import it.unimi.dsi.fastutil.longs.Long2ByteOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectSet; import net.minecraft.server.level.ServerPlayer; +@UsedFromASM public class FixedPlayerDistanceCubeTracker extends CubeTracker { + @UsedFromASM public final Long2ByteMap cubes = new Long2ByteOpenHashMap(); protected final int range; private final CubicDistanceManager cubicDistanceManager; // this$0 @@ -43,7 +46,7 @@ private boolean hasPlayerInChunk(long cubePosIn) { return cubePlayers != null && !cubePlayers.isEmpty(); } - // used from ASM + @UsedFromASM public void runAllUpdates() { this.runUpdates(Integer.MAX_VALUE); } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/CubicNaturalSpawner.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/CubicNaturalSpawner.java index 78cf7e34..f4e50e34 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/CubicNaturalSpawner.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/CubicNaturalSpawner.java @@ -4,6 +4,7 @@ import java.lang.reflect.Method; import java.util.function.Consumer; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cubicchunks.mixin.access.common.NaturalSpawnerAccess; import io.github.opencubicchunks.cubicchunks.world.level.chunk.CubeAccess; @@ -72,11 +73,13 @@ public static NaturalSpawner.SpawnState createCubicState(int spawningChunkCount, } @FunctionalInterface + @UsedFromASM public interface CubeGetter { void query(long pos, Consumer chunkConsumer); } public interface CubicSpawnState { + @UsedFromASM boolean canSpawnForCategory(MobCategory mobCategory, CubePos cubePos); } } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/INaturalSpawnerInternal.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/INaturalSpawnerInternal.java index 87ebb164..6b48f0a5 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/INaturalSpawnerInternal.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/INaturalSpawnerInternal.java @@ -1,5 +1,6 @@ package io.github.opencubicchunks.cubicchunks.world; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cubicchunks.world.level.chunk.LevelCube; @@ -10,8 +11,7 @@ //TODO: Implement in the transformer public interface INaturalSpawnerInternal { - - + @UsedFromASM static BlockPos getRandomPosWithinCube(Level level, LevelCube cube) { CubePos pos = cube.getCubePos(); int blockX = pos.minCubeX() + level.random.nextInt(CubicConstants.DIAMETER_IN_BLOCKS); diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/CubeAccess.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/CubeAccess.java index 9c083d3d..a041bc90 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/CubeAccess.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/CubeAccess.java @@ -17,6 +17,7 @@ import com.google.common.collect.Maps; import com.mojang.datafixers.util.Either; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cc_core.world.heightmap.HeightmapSource; @@ -86,6 +87,7 @@ public CubeAccess(CubePos pos, CubicLevelHeightAccessor levelHeightAccessor, Upg this.cubeHeightmaps = Maps.newEnumMap(Heightmap.Types.class); } + @UsedFromASM public CubePos getCubePos() { return cubePos; } diff --git a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/LevelCube.java b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/LevelCube.java index d91ffe9a..66671d56 100644 --- a/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/LevelCube.java +++ b/src/main/java/io/github/opencubicchunks/cubicchunks/world/level/chunk/LevelCube.java @@ -25,11 +25,11 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; +import io.github.opencubicchunks.cc_core.annotation.UsedFromASM; import io.github.opencubicchunks.cc_core.api.CubePos; import io.github.opencubicchunks.cc_core.api.CubicConstants; import io.github.opencubicchunks.cc_core.utils.MathUtil; import io.github.opencubicchunks.cc_core.world.ColumnCubeMapGetter; -import io.github.opencubicchunks.cc_core.world.CubicLevelHeightAccessor; import io.github.opencubicchunks.cc_core.world.heightmap.HeightmapStorage; import io.github.opencubicchunks.cc_core.world.heightmap.surfacetrackertree.SurfaceTrackerLeaf; import io.github.opencubicchunks.cc_core.world.heightmap.surfacetrackertree.SurfaceTrackerNode; @@ -76,6 +76,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +@UsedFromASM public class LevelCube extends CubeAccess { private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { public void tick() { @@ -115,7 +116,7 @@ public LevelCube(Level level, CubePos cubePos, UpgradeData upgradeData, LevelChu @Nullable LevelChunkSection[] sections, @Nullable BlendingData blendingData, @Nullable Consumer postLoad) { super( cubePos, - ((CubicLevelHeightAccessor) level), + level, upgradeData, new ProtoCube.FakeSectionCount(cubePos.getY(), level, CubicConstants.SECTION_COUNT), level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY),