From 8b4c5d4c7a134c1a29541b5de9a22e12d5eefab1 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Thu, 10 Aug 2023 22:44:06 -0400 Subject: [PATCH] C U B E --- fabric/testmod/build.gradle | 3 +++ .../embeddedt/modernfix/testmod/TestMod.java | 11 ++++++---- .../testmod/client/TestModClient.java | 2 ++ .../modernfix/testmod/mixin/ChunkMixin.java | 10 +++------ .../testmod/mixin/DebugLevelSourceMixin.java | 21 +++++++++++-------- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/fabric/testmod/build.gradle b/fabric/testmod/build.gradle index e7f14c44..7ecb1346 100644 --- a/fabric/testmod/build.gradle +++ b/fabric/testmod/build.gradle @@ -4,6 +4,7 @@ loom { accessWidenerPath = project(":common").loom.accessWidenerPath runs { client { + vmArgs "-Xmx8G" property("modernfix.config.mixin.perf.blast_search_trees", "true") property("modernfix.config.mixin.perf.dynamic_resources", "true") property("modernfix.config.mixin.perf.dynamic_block_codecs", "true") @@ -24,6 +25,8 @@ dependencies { 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-renderer-api-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' } + modImplementation(fabricApi.module("fabric-rendering-data-attachment-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' } + modImplementation(fabricApi.module("fabric-rendering-fluids-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' } implementation project(path: ":common", configuration: "namedElements") diff --git a/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/TestMod.java b/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/TestMod.java index 5ad72e50..3541e750 100644 --- a/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/TestMod.java +++ b/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/TestMod.java @@ -16,7 +16,7 @@ public class TestMod implements ModInitializer { public static final String ID = "mfix_testmod"; public static final Logger LOGGER = LogManager.getLogger("ModernFix TestMod"); - public static final int NUM_COLORS = 100; + public static final int NUM_COLORS = 256; public static final int MAX_COLOR = NUM_COLORS - 1; public static final List WOOL_STATES = new ArrayList<>(); @@ -34,7 +34,7 @@ public class TestMod implements ModInitializer { ResourceLocation name = new ResourceLocation(ID, "wool_" + r + "_" + g + "_" + b); TestBlock block = Registry.register(Registry.BLOCK, name, new TestBlock()); WOOL_STATES.add(block.defaultBlockState()); - Registry.register(Registry.ITEM, name, new TestBlockItem(block)); + //Registry.register(Registry.ITEM, name, new TestBlockItem(block)); numRegistered++; if((numRegistered % progressReport) == 0) { LOGGER.info(String.format("Registering... %.02f%%", ((float)numRegistered)/totalToRegister * 100)); @@ -49,11 +49,14 @@ public class TestMod implements ModInitializer { private static final BlockState AIR = Blocks.AIR.defaultBlockState(); public static BlockState getColorCubeStateFor(int chunkX, int chunkY, int chunkZ) { - BlockState blockState = AIR; - if (chunkX >= 0 && chunkY >= 0 && chunkZ >= 0 && chunkX % 2 == 0 && chunkY % 2 == 0 && chunkZ % 2 == 0) { + BlockState blockState = null; + if (chunkX >= 0 && chunkY >= 0 && chunkZ >= 0) { // && chunkX % 2 == 0 && chunkY % 2 == 0 && chunkZ % 2 == 0) { + /* chunkX /= 2; chunkY /= 2; chunkZ /= 2; + + */ if(chunkX <= TestMod.MAX_COLOR && chunkY <= TestMod.MAX_COLOR && chunkZ <= TestMod.MAX_COLOR) { blockState = TestMod.WOOL_STATES.get((chunkX * TestMod.NUM_COLORS * TestMod.NUM_COLORS) + (chunkY * TestMod.NUM_COLORS) + chunkZ); } diff --git a/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/client/TestModClient.java b/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/client/TestModClient.java index 3bf0c36a..7f82a508 100644 --- a/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/client/TestModClient.java +++ b/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/client/TestModClient.java @@ -2,6 +2,7 @@ package org.embeddedt.modernfix.testmod.client; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; +import org.embeddedt.modernfix.fabric.api.dynresources.ModelScanController; import org.embeddedt.modernfix.testmod.TestMod; import java.util.regex.Matcher; @@ -11,6 +12,7 @@ public class TestModClient implements ClientModInitializer { private static final Pattern RGB_PATTERN = Pattern.compile("^wool_([0-9]+)_([0-9]+)_([0-9]+)$"); @Override public void onInitializeClient() { + ModelScanController.SCAN_PREDICATES.add(rl -> !rl.getNamespace().equals(TestMod.ID)); ModelLoadingRegistry.INSTANCE.registerVariantProvider(resourceManager -> (modelId, context) -> { if(modelId.getNamespace().equals(TestMod.ID)) { Matcher matcher = RGB_PATTERN.matcher(modelId.getPath()); diff --git a/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/mixin/ChunkMixin.java b/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/mixin/ChunkMixin.java index 1356aece..142faf51 100644 --- a/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/mixin/ChunkMixin.java +++ b/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/mixin/ChunkMixin.java @@ -1,25 +1,21 @@ package org.embeddedt.modernfix.testmod.mixin; import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.LevelChunk; 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(LevelChunk.class) public class ChunkMixin { - @Shadow @Final private Level level; - @Inject(method = "getBlockState", at = @At("HEAD"), cancellable = true) private void redirectDebugWorld(BlockPos pos, CallbackInfoReturnable cir) { - if(this.level.isDebug()) { - cir.setReturnValue(TestMod.getColorCubeStateFor(pos.getX(), pos.getY(), pos.getZ())); + BlockState overrideState = TestMod.getColorCubeStateFor(pos.getX(), pos.getY(), pos.getZ()); + if(overrideState != null) { + cir.setReturnValue(overrideState); } } } diff --git a/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/mixin/DebugLevelSourceMixin.java b/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/mixin/DebugLevelSourceMixin.java index 40d3eba9..99860393 100644 --- a/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/mixin/DebugLevelSourceMixin.java +++ b/fabric/testmod/src/main/java/org/embeddedt/modernfix/testmod/mixin/DebugLevelSourceMixin.java @@ -3,19 +3,22 @@ package org.embeddedt.modernfix.testmod.mixin; import net.minecraft.core.BlockPos; import net.minecraft.server.level.WorldGenRegion; import net.minecraft.world.level.StructureFeatureManager; +import net.minecraft.world.level.biome.BiomeSource; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.DebugLevelSource; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.FlatLevelSource; +import net.minecraft.world.level.levelgen.StructureSettings; import org.embeddedt.modernfix.testmod.TestMod; 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(DebugLevelSource.class) -public class DebugLevelSourceMixin { - @Inject(method = "applyBiomeDecoration", at = @At("HEAD"), cancellable = true) - private void showColorCube(WorldGenRegion region, StructureFeatureManager structureManager, CallbackInfo ci) { - ci.cancel(); +@Mixin(FlatLevelSource.class) +public abstract class DebugLevelSourceMixin extends ChunkGenerator { + public DebugLevelSourceMixin(BiomeSource biomeSource, StructureSettings structureSettings) { + super(biomeSource, structureSettings); + } + + @Override + public void applyBiomeDecoration(WorldGenRegion region, StructureFeatureManager structureManager) { BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); int i = region.getCenterX(); int j = region.getCenterZ();