Skip to content
This repository was archived by the owner on Oct 4, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand Down Expand Up @@ -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 {
Expand All @@ -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")!!)

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
18 changes: 14 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -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/.
Expand All @@ -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"'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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%

Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.objectweb.asm.Opcodes.*;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -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<MethodNode> it = targetClass.methods.iterator(); it.hasNext();) {
MethodNode method = it.next();
List<AnnotationNode> visibleAnnotations = method.visibleAnnotations;
if (visibleAnnotations != null) {
if (visibleAnnotations.stream().anyMatch(annotationNode -> annotationNode.desc.equals("Lio/github/opencubicchunks/stirrin/StirrinStub;"))) {
it.remove();
}
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,7 +20,7 @@ public class MixinOptions {
private void getCloudsTypeForVerticalViewDistance(CallbackInfoReturnable<CloudStatus> cir) {
ClientLevel level = Minecraft.getInstance().level;
if (level != null) {
if (!((CubicLevelHeightAccessor) level).isCubic()) {
if (!level.isCubic()) {
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public class MixinTransientEntitySectionManager<T extends EntityAccess> implemen

@Override public void setIsCubic(boolean isCubic) {
this.isCubic = isCubic;
((IsCubicEntityContext) this.sectionStorage).setIsCubic(isCubic);
this.sectionStorage.setIsCubic(isCubic);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public abstract class MixinClientChunkCache implements ClientCubeCache {

@Inject(method = "<init>", at = @At("RETURN"))
private void onConstruct(ClientLevel clientWorldIn, int viewDistance, CallbackInfo ci) {
if (!((CubicLevelHeightAccessor) clientWorldIn).isCubic()) {
if (!clientWorldIn.isCubic()) {
return;
}

Expand Down Expand Up @@ -176,7 +176,7 @@ public void updateCubeViewRadius(int hDistance, int vDistance) {
*/
@Inject(method = "gatherStats", at = @At("HEAD"), cancellable = true)
public void gatherStats(CallbackInfoReturnable<String> cir) {
if (!((CubicLevelHeightAccessor) this.level).isCubic()) {
if (!this.level.isCubic()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,7 +20,7 @@ public class MixinGameRenderer {

@Inject(method = "getDepthFar", at = @At("HEAD"), cancellable = true)
private void getDepthFarWithVerticalViewDistance(CallbackInfoReturnable<Float> cir) {
if (!((CubicLevelHeightAccessor) this.minecraft.level).isCubic()) {
if (!this.minecraft.level.isCubic()) {
return;
}
float horizontalRenderDistance = this.renderDistance * 4.0F;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,7 +17,7 @@ public class MixinOtherRenderChunk {

@Inject(method = "getBlockState", at = @At("HEAD"), cancellable = true)
private void goThroughLevel(BlockPos blockPos, CallbackInfoReturnable<BlockState> cir) {
if (((CubicLevelHeightAccessor) this.wrapped).isCubic()) {
if (this.wrapped.isCubic()) {
cir.setReturnValue(this.wrapped.getBlockState(blockPos));
}
}
Expand Down
Loading