Jump to content

Recommended Posts

Posted (edited)

As a way to practice modding I'm trying to add signs to my 1.19.2 mod, but when placing the sign and opening the sign edit screen it crashes with this log: https://mclo.gs/hxLFTGn

 

I can't find any info on the crash so i don't know what to do anymore.

package com.an12854.leanmod.block.entity;

import com.an12854.leanmod.Leanmod;
import com.an12854.leanmod.block.ModBlocks;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

public class ModBlockEntities {
    public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES =
            DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, Leanmod.MODID);

    public static final RegistryObject<BlockEntityType<ModSignBlockEntity>> SIGN_BLOCK_ENTITIES =
            BLOCK_ENTITIES.register("sign_block_entity", () ->
                    BlockEntityType.Builder.of(ModSignBlockEntity::new,
                            ModBlocks.LEAN_WALL_SIGN.get(),
                            ModBlocks.LEAN_SIGN.get()).build(null));
    public static void register(IEventBus eventBus) {
        BLOCK_ENTITIES.register(eventBus);
    }
}

Here is the custom BlockEntities

Edited by An12854
Posted

Can you post your Screen and BlockEntity implementation? Looks like there's an NPE when rendering the screen, so I'd bet the problem is in your Screen implementation. The initialization of your BlockEntity doesn't tell us much. Also, did you make sure to register your Screen?

Posted
On 3/14/2024 at 12:50 PM, dee12452 said:

Can you post your Screen and BlockEntity implementation? Looks like there's an NPE when rendering the screen, so I'd bet the problem is in your Screen implementation. The initialization of your BlockEntity doesn't tell us much. Also, did you make sure to register your Screen?

package com.an12854.leanmod.block.entity;

import com.an12854.leanmod.block.entity.ModBlockEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.SignBlockEntity;
import net.minecraft.world.level.block.state.BlockState;

public class ModSignBlockEntity extends SignBlockEntity {
    public ModSignBlockEntity(BlockPos p_155700_, BlockState p_155701_) {
        super (p_155700_, p_155701_);
    }

    @Override
    public BlockEntityType<?> getType() {
        return ModBlockEntities.SIGN_BLOCK_ENTITIES.get();
    }
}

None of the docs i found mention registering the screen so I would ask if you could point me in the right direction.

Posted

Ok I'm sorry, as I was responding I realized that registering screens is only relevant to MenuScreens, i.e. screens that connect to a menu implementation which sounds like this isn't the case. You can disregard registration of this screen as long as it's not connected to a menu (i.e. a class that extends AbstractContainerMenu)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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