mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-08 13:26:39 +01:00
Loading visualization
- Fix up/comment out some touchy mixins. - Get chests to render. - There's something wrong with the projection matrix. - Add comment to DebugMemoryBlockImpl's stack walker usage.
This commit is contained in:
parent
90cfd967dc
commit
9f019fc72f
5 changed files with 45 additions and 13 deletions
|
@ -49,6 +49,7 @@ import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.IExtensionPoint;
|
import net.minecraftforge.fml.IExtensionPoint;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
|
||||||
|
@ -116,6 +117,10 @@ public class Flywheel {
|
||||||
|
|
||||||
ShadersModHandler.init();
|
ShadersModHandler.init();
|
||||||
|
|
||||||
|
modEventBus.addListener(Flywheel::lateInit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void lateInit(final FMLClientSetupEvent event) {
|
||||||
VertexTypes.init();
|
VertexTypes.init();
|
||||||
InstanceTypes.init();
|
InstanceTypes.init();
|
||||||
Materials.init();
|
Materials.init();
|
||||||
|
@ -124,12 +129,12 @@ public class Flywheel {
|
||||||
MaterialIndices.init();
|
MaterialIndices.init();
|
||||||
|
|
||||||
VanillaVisuals.init();
|
VanillaVisuals.init();
|
||||||
|
|
||||||
|
RegistryImpl.freezeAll();
|
||||||
|
IdRegistryImpl.freezeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setup(final FMLCommonSetupEvent event) {
|
private static void setup(final FMLCommonSetupEvent event) {
|
||||||
RegistryImpl.freezeAll();
|
|
||||||
IdRegistryImpl.freezeAll();
|
|
||||||
|
|
||||||
ArgumentTypeInfos.registerByClass(BackendArgument.class, SingletonArgumentInfo.contextFree(() -> BackendArgument.INSTANCE));
|
ArgumentTypeInfos.registerByClass(BackendArgument.class, SingletonArgumentInfo.contextFree(() -> BackendArgument.INSTANCE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,12 @@ class DebugMemoryBlockImpl extends MemoryBlockImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
static StackWalker.StackFrame[] getStackTrace() {
|
static StackWalker.StackFrame[] getStackTrace() {
|
||||||
|
// skip 4 frames to get to the caller:
|
||||||
|
// - this method
|
||||||
|
// - DebugMemoryBlockImpl::new
|
||||||
|
// - DebugMemoryBlockImpl::malloc/calloc
|
||||||
|
// - MemoryBlock::malloc/calloc
|
||||||
|
// - {caller is here}
|
||||||
return StackWalker.getInstance().walk(s -> s.skip(4).toArray(StackWalker.StackFrame[]::new));
|
return StackWalker.getInstance().walk(s -> s.skip(4).toArray(StackWalker.StackFrame[]::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class LevelRendererMixin {
|
||||||
flywheel$dispatch(RenderStage.AFTER_FINAL_END_BATCH);
|
flywheel$dispatch(RenderStage.AFTER_FINAL_END_BATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V", ordinal = 6, shift = Shift.AFTER))
|
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V", ordinal = 6, shift = Shift.AFTER))
|
||||||
private void flywheel$onStage$afterTranslucentTerrain(CallbackInfo ci) {
|
private void flywheel$onStage$afterTranslucentTerrain(CallbackInfo ci) {
|
||||||
flywheel$dispatch(RenderStage.AFTER_TRANSLUCENT_TERRAIN);
|
flywheel$dispatch(RenderStage.AFTER_TRANSLUCENT_TERRAIN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,10 @@ public class FixNormalScalingMixin {
|
||||||
* applied, which negates the matrix again, resulting in the matrix being the
|
* applied, which negates the matrix again, resulting in the matrix being the
|
||||||
* same as in the beginning.
|
* same as in the beginning.
|
||||||
*/
|
*/
|
||||||
@Inject(method = "scale(FFF)V", at = @At(value = "INVOKE", target = "Lcom/mojang/math/Matrix3f;mul(F)V", shift = Shift.AFTER), cancellable = true)
|
// @Inject(method = "scale(FFF)V", at = @At(value = "INVOKE", target = "Lcom/mojang/math/Matrix3f;mul(F)V", shift = Shift.AFTER), cancellable = true)
|
||||||
private void flywheel$returnAfterNegate(float x, float y, float z, CallbackInfo ci) {
|
// private void flywheel$returnAfterNegate(float x, float y, float z, CallbackInfo ci) {
|
||||||
ci.cancel();
|
// ci.cancel();
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minecraft takes the inverse cube root of the product of all scales to provide a
|
* Minecraft takes the inverse cube root of the product of all scales to provide a
|
||||||
|
|
|
@ -5,18 +5,39 @@ import java.util.Set;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.impl.visualization.VisualizationHelper;
|
import com.jozufozu.flywheel.impl.visualization.VisualizationHelper;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
|
||||||
|
import net.minecraft.client.renderer.chunk.RenderChunkRegion;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
|
||||||
@Mixin(targets = "net.minecraft.client.renderer.chunk.SectionRenderDispatcher$RenderSection$RebuildTask")
|
@Mixin(targets = "net.minecraft.client.renderer.chunk.ChunkRenderDispatcher$RenderChunk$RebuildTask")
|
||||||
public class ChunkRebuildHooksMixin {
|
public class ChunkRebuildHooksMixin {
|
||||||
@Inject(method = "handleBlockEntity(Lnet/minecraft/client/renderer/chunk/SectionRenderDispatcher$RenderSection$RebuildTask$CompileResults;Lnet/minecraft/world/level/block/entity/BlockEntity;)V", at = @At("HEAD"), cancellable = true)
|
|
||||||
private <E extends BlockEntity> void flywheel$tryAddBlockEntity(Object pCompileResults, E pBlockEntity, CallbackInfo ci) {
|
// FIXME: use this instead of the redirect if there's a clean way to reference the CompileResults
|
||||||
if (VisualizationHelper.tryAddBlockEntity(pBlockEntity)) {
|
// @Inject(method = "handleBlockEntity(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk$RebuildTask$CompileResults;Lnet/minecraft/world/level/block/entity/BlockEntity;)V", at = @At("HEAD"), cancellable = true)
|
||||||
ci.cancel();
|
// private <E extends BlockEntity> void flywheel$tryAddBlockEntity(Object pCompileResults, E pBlockEntity, CallbackInfo ci) {
|
||||||
|
// if (VisualizationHelper.tryAddBlockEntity(pBlockEntity)) {
|
||||||
|
// ci.cancel();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Redirect(method = "compile", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/chunk/RenderChunkRegion;getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"))
|
||||||
|
private BlockEntity flywheel$interceptGetBlockEntity(RenderChunkRegion region, BlockPos pos) {
|
||||||
|
BlockEntity blockEntity = region.getBlockEntity(pos);
|
||||||
|
|
||||||
|
if (blockEntity == null) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (VisualizationHelper.tryAddBlockEntity(blockEntity)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return blockEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue