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.12.2] Creating a custom ItemMap and rendering it in hand & in ItemFrame

Featured Replies

Posted

Good evening everyone,

 

I am working on a custom map item (original MC is ItemEmptyMap and ItemMap which inherit from ItemMapBase), the purpose is to act the same way as the original one except that I would like some information rendered on it. Also, I would like it to be an item apart but I basically make my item inherit from ItemMap.

 

The part I am struggling with is rendering the map in player's hand and in an item frame. From what I observe in the code, the concerned renderer is the ItemRenderer which renders instances of ItemMap and also MapItemRenderer which renders icons and decorations.

 

Is there any way to affect a specific ItemRenderer for my custom map or an event that could catch the rendering and to play with ?

 

Regards.

Squirrel ! Squirrel ! Squirrel !

  • Author

[UPDATE]

I found out that there is the Forge event RenderSpecificHandEvent which is called for each hand (MAIN_HAND and OFF_HAND). I ended up subscribing to it and making my own rendering functions, based on the ItemRenderer class. Functions that I simply copy-pasted are renderItemInFirstPerson and renderMapFirstPerson.

I find it a bit "dirty" that there is a conditional branching only to render an ItemMap inside the rendering pass of Minecraft. Also, certain rendering functions such as renderArms are private and thus could not be overriden or properly called : I have to copy-paste those functions to simulate the same behavior.

 

Do you think it would be possible create a specific event for the map rendering, considering its unique condition in the code ? What do you think ?

Squirrel ! Squirrel ! Squirrel !

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.