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

I have made a custom GUI and custom slot, but when I try to click on an item that is inside my custom slot it just falls to the ground instead of following my mouse round like in an inventory. Also it only seems to do it at a certain place. In some places nearer the edge of the screen it will just pop out like before but nearer the center it acts normally.

  • Author

Container Class:

 

public class ContainerCustom extends Container {
protected IInventory i;

private int playerInventoryX = 70;
private int playerInventoryY = 8;

public ContainerCustom(InventoryPlayer inventoryPlayer, IInventory c) {
	i = c; {

		addSlotToContainer(new SlotCustom(c, 0, 144, -55));

	}
	bindPlayerInventory(inventoryPlayer);
}

public boolean canInteractWith(EntityPlayer player) {
	return i.isUseableByPlayer(player);
}

protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 9; j++) {
			addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, playerInventoryX + j * 18, playerInventoryY + i * 18));
		}
	}
	for (int i = 0; i < 9; i++) {
		addSlotToContainer(new Slot(inventoryPlayer, i, playerInventoryX + i * 18, playerInventoryY + 54 + 4));
	}
}

@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
	return null;
}

@Override
public void onContainerClosed(EntityPlayer par1EntityPlayer) {
	super.onContainerClosed(par1EntityPlayer);
	this.i.closeInventory();
}
}

 

Slot Class:

 

public class SlotCustom extends Slot {

public SlotCustom(IInventory inventory, int par2, int par3, int par4) {
	super(inventory, par2, par3, par4);
}

@Override
public boolean isItemValid(ItemStack itemstack) {
	return itemstack.getItem() == Items.arrow;
}

@Override
public int getSlotStackLimit() {
	return 1;
}

}

 

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.