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.

Featured Replies

Posted

So I'm trying to make a very small mod to ban the use of specific items.  The mod just constantly checks each player's inventory and sets any slot with a "restricted" item to null.

 

This works fine when it's loaded on both the client and the server; the moment I move an item from the Creative Inventory to my hotbar, it disappears.  But I really want this mod to be server-side only.  Here's my code:

 

@SubscribeEvent
    public void onPlayerTick(PlayerTickEvent e) {
        EntityPlayer player = e.player;
        if (!e.player.worldObj.isRemote) {
            for (int i = 0; i < player.inventory.mainInventory.length; i++) {
                ItemStack is = player.inventory.mainInventory[i];
                if (is != null) {
                    Item it = is.getItem();
                    // MFYLog.bannedItems is an ArrayList<Item>
                    for (Item compare : MFYLog.bannedItems) {
                        if (it == compare) {
                            player.inventory.setInventorySlotContents(i, null);
} } } } }

 

The Bug: The item isn't usable, which is good, but it is visible.  It sticks around on the hotbar, and can be moved around my inventory.  The item will disappear if I interact with any other block in the game.

 

Reading other posts, my best guess is I need to send a packet of some type, but I don't have much experience with packets, and the tutorials I could find only talked about custom packets.  In this case I just want to send whatever vanilla packet is normally sent with an inventory update.  Any hints?

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.