Jump to content

[1.15.2] Need help with Registering Tile Ents and Binding them to a Block


Recommended Posts

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

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