Jump to content

Recommended Posts

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.

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.