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.15.2] Need help with Registering Tile Ents and Binding them to a Block

Featured Replies

Posted

Hey all,

it's been a while since I've last modded this game and Im kinda struggling, Im trying to register a Tile Entity and then attach it to a block. Unsure if the way Im doing this is outdated, wrong or what, but enough babblin', here's the code.
(Items and Blocks all work, its just when I try to meddle with the Tile Ent stuffs)

Main File

Quote

// ...
    public static CookieJarMod instance;
 

    public CookieJarMod() 
    {
        final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        modEventBus.addListener(this::setup);
        modEventBus.addListener(this::doClientStuff);
        
        instance = this;
        
        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event)
    {
    }

    private void doClientStuff(final FMLClientSetupEvent event) 
    {
        ClientRegistry.bindTileEntityRenderer(/*unsure what to do here... JAR_TILE_ENT is a ? while this needs a specific one*/, JarContainerTileEntityRenderer::new);
    }
 

@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents 
    {
        @SubscribeEvent
        public static void registerItems(final RegistryEvent.Register<Item> event) 
        {
            event.getRegistry().registerAll(
                ObjectList.DEBUG_STAR, //First Item Test, remove later
                ObjectList.COOKIE_JAR_ITEM
            );
        }
        
        @SubscribeEvent
        public static void registerBlocks(final RegistryEvent.Register<Block> event)
        {
            event.getRegistry().registerAll(
                ObjectList.COOKIE_JAR
            );
        }
        
        @SubscribeEvent
        public static void onTileEntitiesTypeRegistry(final RegistryEvent.Register<TileEntityType<?>> event) 
        {
            event.getRegistry().registerAll(
                ObjectList.JAR_TILE_ENT
            );
        }
    }

ObjectList

Quote

// ...
public class ObjectList 
{
    // ...
    private static final Block JAR_TILE_ENT_TILES[] = new Block[] 

    {
        ObjectList.COOKIE_JAR
    };
    public static TileEntityType<?> JAR_TILE_ENT = TileEntityType.Builder.create(JarContainerTileEntity::new, ObjectList.JAR_TILE_ENT_TILES).build(null);
}


 

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.