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

Hey how can I switch of Item Rendering in a gui when I press a button in a gui?

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

  • Author

I am unsure what you mean. Do you have a GuiContainer (displaying an inventory) and want to turn off the inventory?

I want all Items,. they are in your inventory, are away, so there icons are away, not the items,so you can't see them anymore

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Are you trying to hide all item in your container?

If so, the player's creative container does a cheaty way of hiding all items. It lifts them up by a couple thousand positions in the y coordinate.

 

First of all, save the y positions of all the slots you want to 'hide' in an array, to keep the actual y position if you want to show the slots again. If you do not want to show them afterwards, you can skip this.

[All of this code should be added to your guicontainer class]

#1

 

 

private boolean _showOptions = false; //To control whether or not if you want to show or hide the slots.
private int[] _slotPosY = new int[16]; //My container contains 16 slots, you can change this number to how many yours has.

//In some load/initialization method eg. GuiScreen#initGui()
/** Saving the containerslots'  y pos in an array. */
public void saveYPos() {
for(int i = 1; i < 16; i++) //I am skipping the first slot of my container, it's not part of the ones I want to move.
_slotPosY[i] = _container.getSlot(i).yDisplayPosition;
}

 

 

 

You're talking about a button (on/off switch?), that's perfect to move the slots up.

#2

 

 

@Override
protected void actionPerformed(GuiButton guibutton) {
if (guibutton instanceof GuiButtonOptions) {
this._showOptions = !this._showOptions;
for(int i = 1; i < 16; i++) //again skipping the first one.
this._container.getSlot(i).yDisplayPosition = this._showOptions ? -2000 : this._slotPosY[i];
}
}

 

 

Whenever you click on a button, for me it's when I click on a button which is an instance of GuiButtonOptions, it's set's the showOptions state to not equals to showOptions. ( if you're using id's for your buttons, you can just change this line to check whether the button id is the button for hiding the slots)

Then I am moving all the container's slots up by 2000 (- = negative guitop) whether the showOptions is true, else I am setting their y position back on their original position using the array.

 

I have used it in my entity's container as well, works fine for me.

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.