Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

1.16.4 - Overriding Vanilla Blocks not registring BlockItem

Featured Replies

Posted

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?

 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.