Skip to content

Commit

Permalink
Update testmod to 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Aug 10, 2023
1 parent 0779058 commit d52e646
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
1 change: 1 addition & 0 deletions fabric/testmod/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modImplementation(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
modImplementation(fabricApi.module("fabric-models-v0", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
modImplementation(fabricApi.module("fabric-registry-sync-v0", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
modImplementation(fabricApi.module("fabric-renderer-api-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
modRuntimeOnly(fabricApi.module("fabric-renderer-indigo", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.minecraft.client.Minecraft;
import org.embeddedt.modernfix.testmod.TestMod;

import java.util.regex.Matcher;
Expand All @@ -23,5 +24,7 @@ public void onInitializeClient() {
}
return null;
});
// needed to make debug level rendering work correctly
Minecraft.getInstance().smartCull = false;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.embeddedt.modernfix.testmod.mixin;

import net.minecraft.core.BlockPos;
import net.minecraft.server.level.WorldGenRegion;
import net.minecraft.core.SectionPos;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.levelgen.DebugLevelSource;
import org.embeddedt.modernfix.testmod.TestMod;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -14,20 +17,21 @@
@Mixin(DebugLevelSource.class)
public class DebugLevelSourceMixin {
@Inject(method = "applyBiomeDecoration", at = @At("HEAD"), cancellable = true)
private void showColorCube(WorldGenRegion region, StructureFeatureManager structureManager, CallbackInfo ci) {
private void showColorCube(WorldGenLevel level, ChunkAccess chunk, StructureFeatureManager structureFeatureManager, CallbackInfo ci) {
ci.cancel();
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
int i = region.getCenterX();
int j = region.getCenterZ();
ChunkPos chunkPos = chunk.getPos();
int i = chunkPos.x;
int j = chunkPos.z;

for(int k = 0; k < 16; ++k) {
for(int l = 0; l < 16; ++l) {
int m = (i << 4) + k;
int n = (j << 4) + l;
int m = SectionPos.sectionToBlockCoord(i, k);
int n = SectionPos.sectionToBlockCoord(j, l);
for(int y = 0; y < 255; y++) {
BlockState blockState = TestMod.getColorCubeStateFor(m, y, n);
if (blockState != null) {
region.setBlock(mutableBlockPos.set(m, y, n), blockState, 2);
level.setBlock(mutableBlockPos.set(m, y, n), blockState, 2);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.embeddedt.modernfix.testmod.mixin;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import org.embeddedt.modernfix.testmod.TestMod;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(targets = { "net/minecraft/client/renderer/chunk/RenderChunk" })
public class RenderChunkMixin {
@Shadow @Final private boolean debug;

@Inject(method = "getBlockState", at = @At("HEAD"), cancellable = true)
private void redirectDebugWorld(BlockPos pos, CallbackInfoReturnable<BlockState> cir) {
if(this.debug) {
cir.setReturnValue(TestMod.getColorCubeStateFor(pos.getX(), pos.getY(), pos.getZ()));
}
}
}
3 changes: 3 additions & 0 deletions fabric/testmod/src/main/resources/testmod.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"ChunkMixin",
"DebugLevelSourceMixin"
],
"client": [
"RenderChunkMixin"
],
"injectors": {
"defaultRequire": 1
}
Expand Down

0 comments on commit d52e646

Please sign in to comment.