Jump to content

1.16.4 - Overriding Vanilla Blocks not registring BlockItem


than00ber1

Recommended Posts

This is my first post here so I'm not even sure if this is the correct place to address my problem but anyways:

 

Using DeferredRegisterI was able to successfully override a few block's functionality (the snow block) however, while ingame, the BlockItem does not seem to have been kept from the vanilla game.

 

Here are some of the side effects I currently have:

  • There are two textureless instances of the snow's BlockItem present within the creative menu (both have the same functionality - behaves like the overriden block)
  • doing /give Dev minecraft:snow gives a textured version of the block (again works as expected)

 

My understanding is that the reason why this happens is because I have overridden the block and I also need to register a new BlockItem for the new blocks.

 

This is how I register blocks.

 

import static com.than00ber.wintersnow.init.AllItems.ITEMS;

public class AllBlocks {

    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Main.MODID);
    public static final DeferredRegister<Block> OVERRIDDEN_BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "minecraft");

    // some cusotm mod blocks fully registered correctly
      
    public static final RegistryObject<Block> BASIC_SNOW = registerBlockOverride(Blocks.SNOW, "snow", BasicSnow::new);

    private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block) {
        // register mod blocks - unimportant
    }

    private static <T extends Block> RegistryObject<T> registerBlockOverride(Block defaultBlock, String name, Supplier<T> block) {
        RegistryObject<T> reg = OVERRIDDEN_BLOCKS.register(name, block);
        BlockItem blockItem = new BlockItem(defaultBlock, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS));
        ITEMS.register(name, () -> blockItem);
        return reg;
    }
}

 

I register the blocks I want to override with a DeferredRegister set with modid minecraft and within my mod's constructor I register the blocks to an event bus:

 

    public Main() {

        // Registering blocks
        IEventBus iEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        BLOCKS.register(iEventBus);
        OVERRIDDEN_BLOCKS.register(iEventBus);
        
        // some other stuff - unimportant
    }

 

I could just get the textures of the block and put them in my mod folder but this seems a bit redundant. Is there any other way I could get the item's normal BlockItem?

 

Link to comment
Share on other sites

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.