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.

What to use to override player hotbar engine?

Featured Replies

Posted

I made custom inventory, hotbar GUI(it contains 2 items), overriden pickup. But I don't know how to override hotbar mechanics. It can render items from standart player inventory. Shound I extend InventoryPlayer and replace standart EntityPlayer.inventory, or is there another way?

  • Author

By hotbar engine I mean item selection with keys and, if it is possible, with mouse wheel.

Removing vanilla hotbar or inventory LOGIC is like charging into goddamn sun with water hose.

 

Just don't. Even if that was somehow possible without coremodding (ASM) I seriosly doubt that it will work anywhere near well.

 

You need IEEP or Capability on your player that will hold your own inventory and then simply don't render vanilla one, but your own using RenderGameOverlayEvent. As to mechanics behind scrolling/buttons of hotbar - from events side (not coremodding) you can only fight that with some client input events (MouseEvent, Keyboard or Keybinding Event, etc.) to simply detect when player pressed proper stuff and not do it. Also - since that is not only way to change currently selected slot in hotbar - you need PlayerTickEvent that will reset current slot back to "desired" one.

 

Seriously, modding something like this will break compatibility with most of inventory mods there are and probably some other.

 

Can't you just leave hotbar alone and simply add additional hotbar on e.g right of screen? Then just make it use other input, like "<" and ">"?

1.7.10 is no longer supported by forge, you are on your own.

  • Author

I want do decrease avaible slots in inventory to make game harder. The main problem is that item in hand is taken from standart inventory. Can I just replace standart ItemStack array with mine? Or the only way to fill standart inventory with empty items?

I want do decrease avaible slots in inventory to make game harder.

 

To what end exacly?

 

Vanilla has 27 normal and 9 hotbar slots.

Do you want payers to have ONLY 2 hotbar slots and nothing else?

 

I might have some hints for ya.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

I'm developing an RPG mod, so player will have "strength" attribute that will affect count of inventory slots. Min count is 2, max is 12.

Okay then:

Leave vanilla inventory alone. Just don't touch it. What you want to do is to change display and "some" of internals.

 

Client:

* Use GuiOpenEvent, check if gui is gui inventory and open your own GuiContainer instead.

* Now you can just make your GuiCustomInv display whatever you want (make it extend vanilla one for convinience).

 

Both sides:

* PlayerTickEvent  - event.phase == START.

* Check if there are items in slots you don't want them to be - move them to possibly other or throw on ground.

* Pick up events - check if you can pickup.

 

Some might be useful if you didn't alredy come up with that.

1.7.10 is no longer supported by forge, you are on your own.

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.