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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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