Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[SOLVED] [1.17.1] Issues with Skull Rendering (again...)


uSkizzik
 Share

Recommended Posts

Basically, I'm trying to make custom skulls and I need to add them to the skull renderer.
Until now I just used reflect to add them to the SKIN_BY_TYPE and MODEL_BY_TYPE maps but now the MODEL_BY_TYPE is using a method instead of being defined directly (like SKIN_BY_TYPE).
Any ideas?

Here's my current code for the rendering:
 

    @SubscribeEvent
    public static void registerCustomSkullRenderers(FMLClientSetupEvent event) {
        Field ModelField;
        Field SkinField;
        try {
            ModelField = SkullBlockRenderer.class.getDeclaredField("modelByType");
            ModelField.setAccessible(true);
            Map<SkullBlock.Type, SkullModelBase> Model = (Map<SkullBlock.Type, SkullModelBase>) ModelField.get(SkullBlockRenderer.class);
            Model.put(CustomSkullTypes.SKIZZIK, new SkullModel(Minecraft.getInstance().getEntityModels().bakeLayer(ModelLayers.SKELETON_SKULL)));
            Model.put(CustomSkullTypes.SKIZZIK_WITH_GEMS, new SkullModel(Minecraft.getInstance().getEntityModels().bakeLayer(ModelLayers.WITHER_SKELETON_SKULL)));

            SkinField = SkullBlockRenderer.class.getDeclaredField("SKIN_BY_TYPE");
            SkinField.setAccessible(true);
            Map<SkullBlock.Type, ResourceLocation> Skin = (Map<SkullBlock.Type, ResourceLocation>) SkinField.get(SkullBlockRenderer.class);
            Skin.put(CustomSkullTypes.SKIZZIK, new ResourceLocation("skizzik:textures/block/skizzik_head.png"));
            Skin.put(CustomSkullTypes.SKIZZIK_WITH_GEMS, new ResourceLocation("skizzik:textures/entity/skizzik/skizzik.png"));
        }
        catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }

 

Edited by uSkizzik
Link to comment
Share on other sites

  • You will need to use SRG names, otherwise your code will fail outside the development environment.
  • That is not how you deal with exceptions, ever.
  • Passing a Class to Field#get means you are trying to get an instance field from the Class class, this makes zero sense. Pass null for static fields and the instance of the target class for non-static fields.
  • Since modelByType is no longer a static field, you can simply set it to a map that contains your skull block types and models after you've created your SkullBlockRenderer.
Link to comment
Share on other sites

1 hour ago, diesieben07 said:
  • You will need to use SRG names, otherwise your code will fail outside the development environment.
  • That is not how you deal with exceptions, ever.
  • Passing a Class to Field#get means you are trying to get an instance field from the Class class, this makes zero sense. Pass null for static fields and the instance of the target class for non-static fields.
  • Since modelByType is no longer a static field, you can simply set it to a map that contains your skull block types and models after you've created your SkullBlockRenderer.

What do you mean by "after you've created your SkullBlockRenderer"?
Do I need a custom renderer class? If so, doesn't that mean that equipping the custom skull will crash the game since that will call the vanilla renderer?

Link to comment
Share on other sites

I realize now that you are talking about the item form.

For this you just need to register your own BlockEntityWithoutLevelRenderer to your BlockItem by overriding initializeClient and providing your custom IItemRenderProperties.

Link to comment
Share on other sites

Posted (edited)
5 minutes ago, diesieben07 said:

I realize now that you are talking about the item form.

For this you just need to register your own BlockEntityWithoutLevelRenderer to your BlockItem by overriding initializeClient and providing your custom IItemRenderProperties.

I'm actually talking about both the block and the item

Edited by uSkizzik
Link to comment
Share on other sites

Well for the item do what I described.

For the block, you need a custom block (and therefore BlockEntityType and therefore BlockEntityRenderer) anyways. So then you can modify the field on that new BlockEntityRenderer after creating it.

Link to comment
Share on other sites

37 minutes ago, diesieben07 said:

Well for the item do what I described.

For the block, you need a custom block (and therefore BlockEntityType and therefore BlockEntityRenderer) anyways. So then you can modify the field on that new BlockEntityRenderer after creating it.

So, I'm having the following issue and I have no idea what is causing it. It seems like the texture is null but I don't know. 
At this point I barely know what I'm doing...
 

Spoiler

java.lang.NullPointerException: Rendering Block Entity
    at java.util.Objects.requireNonNull(Objects.java:208) ~[?:?] {}
    at java.util.Optional.of(Optional.java:113) ~[?:?] {}
    at net.minecraft.client.renderer.RenderStateShard$TextureStateShard.<init>(RenderStateShard.java:503) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.RenderType.lambda$static$4(RenderType.java:51) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.Util$9.lambda$apply$0(Util.java:614) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading}
    at java.util.HashMap.computeIfAbsent(HashMap.java:1224) ~[?:?] {}
    at net.minecraft.Util$9.apply(Util.java:613) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading}
    at net.minecraft.client.renderer.RenderType.entityCutoutNoCullZOffset(RenderType.java:191) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.RenderType.entityCutoutNoCullZOffset(RenderType.java:195) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.SkullBlockRenderer.getRenderType(SkullBlockRenderer.java:97) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.SkullBlockRenderer.render(SkullBlockRenderer.java:70) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.SkullBlockRenderer.render(SkullBlockRenderer.java:35) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher.setupAndRender(BlockEntityRenderDispatcher.java:79) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher.lambda$render$0(BlockEntityRenderDispatcher.java:63) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher.tryRender(BlockEntityRenderDispatcher.java:96) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher.render(BlockEntityRenderDispatcher.java:62) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.LevelRenderer.renderLevel(LevelRenderer.java:1110) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.GameRenderer.renderLevel(GameRenderer.java:1050) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:830) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1039) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.run(Minecraft.java:659) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:186) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
    at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}
    at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.17.1-37.0.15.jar%233!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:89) [bootstraplauncher-0.1.16.jar:?] {}

 

Link to comment
Share on other sites

1 minute ago, diesieben07 said:

Show your code.

Registering the renderer:

    @SubscribeEvent
    @OnlyIn(Dist.CLIENT)
    public static void registerTileEntityRenders(FMLClientSetupEvent event) {
        BlockEntityRenderers.register(PA_SIGN.get(), SignRenderer::new);
        BlockEntityRenderers.register(PA_SKULL.get(), SkizzikHeadRenderer::new);
    }

Renderer:
 

public class SkizzikHeadRenderer extends SkullBlockRenderer implements BlockEntityRenderer<SkullBlockEntity> {
    public static Map<SkullBlock.Type, SkullModelBase> createSkullRenderers(EntityModelSet set) {
        ImmutableMap.Builder<SkullBlock.Type, SkullModelBase> builder = ImmutableMap.builder();
        builder.put(PA_TileEntities.CustomSkullTypes.SKIZZIK, new SkullModel(set.bakeLayer(ModelLayers.SKELETON_SKULL)));
        builder.put(PA_TileEntities.CustomSkullTypes.SKIZZIK_WITH_GEMS, new SkullModel(set.bakeLayer(ModelLayers.WITHER_SKELETON_SKULL)));
        return builder.build();
    }

    public SkizzikHeadRenderer(BlockEntityRendererProvider.Context context) {
        super(context);

        Field ModelField;
        Field SkinField;

        try {
            ModelField = super.getClass().getDeclaredField("modelByType");
            ModelField.setAccessible(true);
            Map<SkullBlock.Type, SkullModelBase> Model = createSkullRenderers(context.getModelSet());
            ModelField.set(super.getClass(), Model);

            SkinField = super.getClass().getDeclaredField("SKIN_BY_TYPE");
            SkinField.setAccessible(true);
            Map<SkullBlock.Type, ResourceLocation> Skin = (Map<SkullBlock.Type, ResourceLocation>) SkinField.get(SkullBlockRenderer.class);
            Skin.put(PA_TileEntities.CustomSkullTypes.SKIZZIK, new ResourceLocation("skizzik:textures/block/skizzik_head.png"));
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}

As I said, I have no idea what I'm doing at this point. I also kept the try and catch since I had no other idea of how to handle the errors.

Link to comment
Share on other sites

  • Do not use @OnlyIn.
  • Use a Foo.class literal when using getDeclaredField, do not use getClass. Also super.getClass() isn't even valid syntax.
  • You are still passing a Class to Fied#get.
  • Do not modify SKIN_BY_TYPE from your constructor. This is a static field, so doing this from the constructor will potentially run it multiple times, which is not what you want.
  • I am not quite sure why a null is showing up there. make sure that you are actually modifying SKIN_BY_TYPE properly.
Link to comment
Share on other sites

25 minutes ago, diesieben07 said:
  • Do not use @OnlyIn.
  • Use a Foo.class literal when using getDeclaredField, do not use getClass. Also super.getClass() isn't even valid syntax.
  • You are still passing a Class to Fied#get.
  • Do not modify SKIN_BY_TYPE from your constructor. This is a static field, so doing this from the constructor will potentially run it multiple times, which is not what you want.
  • I am not quite sure why a null is showing up there. make sure that you are actually modifying SKIN_BY_TYPE properly.

Ok, so, new error:
 

Spoiler

Caused by: java.lang.IllegalArgumentException: Can not set final java.util.Map field net.minecraft.client.renderer.blockentity.SkullBlockRenderer.modelByType to com.google.common.collect.RegularImmutableMap
    at jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[?:?] {}
    at jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[?:?] {}
    at jdk.internal.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58) ~[?:?] {}
    at jdk.internal.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:77) ~[?:?] {}
    at java.lang.reflect.Field.set(Field.java:793) ~[?:?] {}
    at com.skizzium.projectapple.tileentity.renderer.SkizzikHeadRenderer.<init>(SkizzikHeadRenderer.java:42) ~[%2378!:?] {re:classloading}
    at net.minecraft.client.renderer.blockentity.BlockEntityRenderers.lambda$createEntityRenderers$0(BlockEntityRenderers.java:25) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    ... 97 more

 

Here's what I modified after reading your reply:

 

        try {
            ModelField = SkullBlockRenderer.class.getDeclaredField("modelByType");
            ModelField.setAccessible(true);
            Map<SkullBlock.Type, SkullModelBase> Model = createSkullRenderers(context.getModelSet());
            ModelField.set(Model, SkullBlockRenderer.class);

            SkinField = SkullBlockRenderer.class.getDeclaredField("SKIN_BY_TYPE");
            SkinField.setAccessible(true);
            Map<SkullBlock.Type, ResourceLocation> Skin = (Map<SkullBlock.Type, ResourceLocation>) SkinField.get(null);
            Skin.put(PA_TileEntities.CustomSkullTypes.SKIZZIK, new ResourceLocation("skizzik:textures/block/skizzik_head.png"));
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }

 

Link to comment
Share on other sites

31 minutes ago, diesieben07 said:

This does not make any sense. Read the documentation on set for which parameters need to be passed in.

Dear god... New errors!
Also the null variable is a SkullModelBase.

Spoiler

java.lang.NullPointerException: Cannot invoke "net.minecraft.client.model.SkullModelBase.setupAnim(float, float, float)" because "p_173670_" is null
    at net.minecraft.client.renderer.blockentity.SkullBlockRenderer.renderSkull(SkullBlockRenderer.java:85) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.SkullBlockRenderer.render(SkullBlockRenderer.java:71) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.SkullBlockRenderer.render(SkullBlockRenderer.java:35) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher.setupAndRender(BlockEntityRenderDispatcher.java:79) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher.lambda$render$0(BlockEntityRenderDispatcher.java:63) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher.tryRender(BlockEntityRenderDispatcher.java:96) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher.render(BlockEntityRenderDispatcher.java:62) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.LevelRenderer.renderLevel(LevelRenderer.java:1110) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.GameRenderer.renderLevel(GameRenderer.java:1050) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:830) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1039) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.run(Minecraft.java:659) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:186) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
    at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}
    at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.17.1-37.0.15.jar%233!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:89) [bootstraplauncher-0.1.16.jar:?] {}

Either something's wrong or I shouldn't be calling SkullBlockRenderer renderer = new SkullBlockRenderer(context);
I couldn't find another way that didn't give me the error I had before.
Full code:

            SkullBlockRenderer renderer = new SkullBlockRenderer(context);

            ModelField = SkullBlockRenderer.class.getDeclaredField("modelByType");
            ModelField.setAccessible(true);
            Map<SkullBlock.Type, SkullModelBase> Model = createSkullRenderers(context.getModelSet());
            ModelField.set(renderer, Model);

            SkinField = SkullBlockRenderer.class.getDeclaredField("SKIN_BY_TYPE");
            SkinField.setAccessible(true);
            Map<SkullBlock.Type, ResourceLocation> Skin = (Map<SkullBlock.Type, ResourceLocation>) SkinField.get(null);
            Skin.put(PA_TileEntities.CustomSkullTypes.SKIZZIK, new ResourceLocation("skizzik:textures/block/skizzik_head.png"));

 

Link to comment
Share on other sites

So, this?
 

    @SubscribeEvent
    public static void registerTileEntityRenders(FMLClientSetupEvent event) {
        BlockEntityRenderers.register(PA_SIGN.get(), SignRenderer::new);
        BlockEntityRenderers.register(PA_SKULL.get(), SkizzikHeadRenderer::new);
    }

 

Link to comment
Share on other sites

Yes. You can either do it right after calling new (which means you cannot use a method reference) or you do it in the constructor. In either case, do not create yet another BlockEntityRenderer, you have to use the one you just created.

Link to comment
Share on other sites

Alright, the block works perfectly. Now I just need a custom model since the texture height and width of the vanilla one don't do the job for my textures.
I'll see about the item in a minute (I still haven't worked on the "fix" for it.)

Link to comment
Share on other sites

3 hours ago, diesieben07 said:

I realize now that you are talking about the item form.

For this you just need to register your own BlockEntityWithoutLevelRenderer to your BlockItem by overriding initializeClient and providing your custom IItemRenderProperties.

So can you tell me exactly what I have to do?
This is the error I'm getting when opening the creative tab containing the head:
 

Spoiler

java.lang.NullPointerException: Cannot invoke "net.minecraft.client.model.SkullModelBase.setupAnim(float, float, float)" because "p_173670_" is null
    at net.minecraft.client.renderer.blockentity.SkullBlockRenderer.renderSkull(SkullBlockRenderer.java:85) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer.renderByItem(BlockEntityWithoutLevelRenderer.java:111) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.entity.ItemRenderer.render(ItemRenderer.java:159) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.entity.ItemRenderer.renderGuiItem(ItemRenderer.java:258) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.entity.ItemRenderer.tryRenderGuiItem(ItemRenderer.java:299) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.entity.ItemRenderer.tryRenderGuiItem(ItemRenderer.java:290) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.entity.ItemRenderer.renderAndDecorateItem(ItemRenderer.java:286) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.inventory.AbstractContainerScreen.renderSlot(AbstractContainerScreen.java:249) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.inventory.AbstractContainerScreen.render(AbstractContainerScreen.java:109) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen.render(EffectRenderingInventoryScreen.java:47) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen.render(CreativeModeInventoryScreen.java:616) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:307) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2373%2379!:?] {re:classloading}
    at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:885) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1039) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.run(Minecraft.java:659) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:186) ~[forge-1.17.1-37.0.15_mapped_official_1.17.1-recomp.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
    at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}
    at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.17.1-37.0.15.jar%233!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:89) [bootstraplauncher-0.1.16.jar:?] {}

It's the same as the one that I got when making the block. What I did there was to change the renderer that I'm using to set the model field to the custom one, so I guess that I have to make a custom renderer for the item too?

Link to comment
Share on other sites

Posted (edited)
3 hours ago, diesieben07 said:

Yes, you need a custom BlockEntityWithoutLevelRenderer implementation. To do this override initializeClient in your Item class.

Alright, so the item works now but the equipping feature crashes the game.
It seems that when equipping a skull, the game calls "CustomHeadLayer" which calls SkullBlockRenderer (and I need it to call my custom renderer).
How do I fix that?
 

Edited by uSkizzik
Link to comment
Share on other sites

  • uSkizzik changed the title to [SOLVED] [1.17.1] Issues with Skull Rendering (again...)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.