Add accessor to BlockEntityRenderer map.

This commit is contained in:
Jozufozu 2022-01-18 13:44:28 -08:00
parent 26ea6bd315
commit 2638e79aa2
3 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,16 @@
package com.jozufozu.flywheel.mixin;
import java.util.Map;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.world.level.block.entity.BlockEntityType;
@Mixin(BlockEntityRenderDispatcher.class)
public interface BlockEntityRenderDispatcherAccessor {
@Accessor("renderers")
Map<BlockEntityType<?>, BlockEntityRenderer<?>> flywheel$getRenderers();
}

View file

@ -1,9 +1,25 @@
package com.jozufozu.flywheel.util;
import java.util.Arrays;
import java.util.Map;
import com.jozufozu.flywheel.mixin.BlockEntityRenderDispatcherAccessor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.world.level.block.entity.BlockEntityType;
public class FlwUtil {
/**
* Get the (effectively global) map of BlockEntityTypes to Renderers.
* @return An immutable map of BlockEntityTypes to BlockEntityRenderers.
*/
public static Map<BlockEntityType<?>, BlockEntityRenderer<?>> getBlockEntityRenderers() {
Minecraft mc = Minecraft.getInstance();
return ((BlockEntityRenderDispatcherAccessor) mc.getBlockEntityRenderDispatcher()).flywheel$getRenderers();
}
public static String repeatChar(char c, int n) {
char[] arr = new char[n];

View file

@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_17",
"refmap": "flywheel.refmap.json",
"client": [
"BlockEntityRenderDispatcherAccessor",
"BlockEntityTypeMixin",
"BufferBuilderMixin",
"BufferUploaderMixin",