Jump to content

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


uSkizzik

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

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

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

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

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...)

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • "Minecraft APK is an absolute gem for mobile gaming enthusiasts. With its immersive pixelated world and limitless creative possibilities, it offers an unparalleled gaming experience on the go. Whether you're building magnificent structures, exploring vast landscapes, or engaging in thrilling multiplayer battles, Minecraft APK delivers endless hours of entertainment. The controls are intuitive, and the regular updates keep the game fresh and exciting. It's a must-have for any gaming aficionado looking to unleash their creativity and embark on extraordinary adventures right from their mobile device." https://apk-minecraft.com/
    • This is the Crash message that comes when it crashes and the mods im using. ---------------------------------------------------- jei-1.16.5-7.7.1.152.jar journeymap-1.16.5-5.8.5p5.jar OptiFine_1.16.5_HD_U_G8.jar Pixelmon-1.16.5-9.1.3-universal.jar ReAuth-1.16-Forge-4.0.4.jar ---------------------------------------------------- ---- Minecraft Crash Report ---- // Hi. I'm Minecraft, and I'm a crashaholic. Time: 5/30/23 9:24 PM Description: Rendering screen java.lang.ArrayIndexOutOfBoundsException: 0     at com.pixelmonmod.pixelmon.client.gui.battles.BattleScreen.setTargeting(BattleScreen.java:663) ~[?:1.16.5-9.1.3] {re:classloading}     at com.pixelmonmod.pixelmon.client.gui.battles.battleScreens.ChooseAttack.render(ChooseAttack.java:109) ~[?:1.16.5-9.1.3] {re:classloading}     at com.pixelmonmod.pixelmon.client.gui.battles.BattleScreen.func_230430_a_(BattleScreen.java:440) ~[?:1.16.5-9.1.3] {re:classloading}     at net.minecraftforge.client.ForgeHooksClient.drawScreenInternal(ForgeHooksClient.java:377) ~[?:?] {re:classloading}     at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:370) ~[?:?] {re:classloading}     at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source) ~[?:?] {}     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {}     at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {}     at net.optifine.reflect.Reflector.callVoid(Reflector.java:789) ~[?:?] {re:classloading}     at net.minecraft.client.renderer.GameRenderer.func_195458_a(GameRenderer.java:821) ~[?:?] {re:classloading,pl:accesstransformer:B,xf:OptiFine:default}     at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:977) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:607) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:184) [?:?] {re:classloading,pl:runtimedistcleaner:A}     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] {}     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] {}     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {}     at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {}     at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51) [forge-1.16.5-36.2.34.jar:36.2] {}     at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$474/2041611826.call(Unknown Source) [forge-1.16.5-36.2.34.jar:36.2] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.1.3.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace:     at com.pixelmonmod.pixelmon.client.gui.battles.BattleScreen.setTargeting(BattleScreen.java:663) ~[?:1.16.5-9.1.3] {re:classloading}     at com.pixelmonmod.pixelmon.client.gui.battles.battleScreens.ChooseAttack.render(ChooseAttack.java:109) ~[?:1.16.5-9.1.3] {re:classloading}     at com.pixelmonmod.pixelmon.client.gui.battles.BattleScreen.func_230430_a_(BattleScreen.java:440) ~[?:1.16.5-9.1.3] {re:classloading}     at net.minecraftforge.client.ForgeHooksClient.drawScreenInternal(ForgeHooksClient.java:377) ~[?:?] {re:classloading}     at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:370) ~[?:?] {re:classloading}     at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source) ~[?:?] {}     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {}     at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {}     at net.optifine.reflect.Reflector.callVoid(Reflector.java:789) ~[?:?] {re:classloading} -- Screen render details -- Details:     Screen name: com.pixelmonmod.pixelmon.client.gui.battles.BattleScreen     Mouse location: Scaled: (408, 302). Absolute: (1225.000000, 907.000000)     Screen size: Scaled: (640, 360). Absolute: (1920, 1080). Scale factor of 3.000000 -- Affected level -- Details:     All players: 1 total; [ClientPlayerEntity['SebPer2708'/551350, l='ClientLevel', x=-162.35, y=28.94, z=-208.94]]     Chunk stats: Client Chunk Cache: 225, 98     Level dimension: minecraft:safari     Level spawn location: World: (7461,68,-15650), Chunk: (at 5,4,14 in 466,-979; contains blocks 7456,0,-15664 to 7471,255,-15649), Region: (14,-31; contains chunks 448,-992 to 479,-961, blocks 7168,0,-15872 to 7679,255,-15361)     Level time: 1243445879 game time, 1255605750 day time     Server brand: forge arclight (Velocity)     Server type: Non-integrated multiplayer server Stacktrace:     at net.minecraft.client.world.ClientWorld.func_72914_a(ClientWorld.java:617) ~[?:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.client.Minecraft.func_71396_d(Minecraft.java:2031) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:623) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:184) [?:?] {re:classloading,pl:runtimedistcleaner:A}     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] {}     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] {}     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {}     at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {}     at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51) [forge-1.16.5-36.2.34.jar:36.2] {}     at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$474/2041611826.call(Unknown Source) [forge-1.16.5-36.2.34.jar:36.2] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.1.3.jar:?] {} -- System Details -- Details:     Minecraft Version: 1.16.5     Minecraft Version ID: 1.16.5     Operating System: Windows 10 (amd64) version 10.0     Java Version: 1.8.0_51, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 1736668104 bytes (1656 MB) / 4697620480 bytes (4480 MB) up to 5368709120 bytes (5120 MB)     CPUs: 8     JVM Flags: 10 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -XX:+IgnoreUnrecognizedVMOptions -Xmx5G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     ModLauncher: 8.1.3+8.1.3+main-8.1.x.c94d18ec     ModLauncher launch target: fmlclient     ModLauncher naming: srg     ModLauncher services:          /mixin-0.8.4.jar mixin PLUGINSERVICE          /eventbus-4.0.0.jar eventbus PLUGINSERVICE          /forge-1.16.5-36.2.34.jar object_holder_definalize PLUGINSERVICE          /forge-1.16.5-36.2.34.jar runtime_enum_extender PLUGINSERVICE          /accesstransformers-3.0.1.jar accesstransformer PLUGINSERVICE          /forge-1.16.5-36.2.34.jar capability_inject_definalize PLUGINSERVICE          /forge-1.16.5-36.2.34.jar runtimedistcleaner PLUGINSERVICE          /mixin-0.8.4.jar mixin TRANSFORMATIONSERVICE          /OptiFine_1.16.5_HD_U_G8.jar OptiFine TRANSFORMATIONSERVICE          /forge-1.16.5-36.2.34.jar fml TRANSFORMATIONSERVICE      FML: 36.2     Forge: net.minecraftforge:36.2.34     FML Language Providers:          javafml@36.2         minecraft@1     Mod List:          forge-1.16.5-36.2.34-client.jar                   |Minecraft                     |minecraft                     |1.16.5              |DONE      |Manifest: NOSIGNATURE         forge-1.16.5-36.2.34-universal.jar                |Forge                         |forge                         |36.2.34             |DONE      |Manifest: 22:af:21:d8:19:82:7f:93:94:fe:2b:ac:b7:e4:41:57:68:39:87:b1:a7:5c:c6:44:f9:25:74:21:14:f5:0d:90         journeymap-1.16.5-5.8.5p5 (1).jar                 |Journeymap                    |journeymap                    |5.8.5p5             |DONE      |Manifest: NOSIGNATURE         ReAuth-1.16-Forge-4.0.4.jar                       |ReAuth                        |reauth                        |4.0.4               |DONE      |Manifest: 3d:06:1e:e5:da:e2:ff:ae:04:00:be:45:5b:ff:fd:70:65:00:67:0b:33:87:a6:5f:af:20:3c:b6:a1:35:ca:7e         Pixelmon-1.16.5-9.1.3-universal.jar               |Pixelmon Mod                  |pixelmon                      |9.1.3               |DONE      |Manifest: NOSIGNATURE         jei-1.16.5-7.7.1.152.jar                          |Just Enough Items             |jei                           |7.7.1.152           |DONE      |Manifest: NOSIGNATURE     Crash Report UUID: 717af89e-5f3d-4e21-a252-816efbf74f7d     Launched Version: 1.16.5-forge-36.2.34     Backend library: LWJGL version 3.2.2 build 10     Backend API: NVIDIA GeForce GTX 1650 with Max-Q Design/PCIe/SSE2 GL version 4.6.0 NVIDIA 526.86, NVIDIA Corporation     GL Caps: Using framebuffer using OpenGL 3.0     Using VBOs: Yes     Is Modded: Definitely; Client brand changed to 'forge'     Type: Client (map_client.txt)     Graphics mode: fast     Resource Packs: mod_resources, vanilla     Current Language: English (US)     CPU: 8x Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz     OptiFine Version: OptiFine_1.16.5_HD_U_G8     OptiFine Build: 20210515-161946     Render Distance Chunks: 7     Mipmaps: 4     Anisotropic Filtering: 1     Antialiasing: 0     Multitexture: false     Shaders: null     OpenGlVersion: 4.6.0 NVIDIA 526.86     OpenGlRenderer: NVIDIA GeForce GTX 1650 with Max-Q Design/PCIe/SSE2     OpenGlVendor: NVIDIA Corporation     CpuCount: 8  
    • Whenever I attempt to create a singleplayer world the world generation gets stuck in 0% and minecraft stops responding after a few seconds and I'm forced to close it. However, I am still able to play multiplayer servers Log: https://paste.gg/p/anonymous/aad7e1be3fc545359383677fbdc3c6e9
    • I have the same issue with no mod installed in 1.18.2 v40.2.6 and v40.2.7 (i don't have try previous version). I have too nothing unusual in the log or debug files (modified) I just try in 40.2.5 and water is placeable
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.