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 want to make a "ghost" slot for my inventory.

By ghost, think about Applied Energistics Level Emitters. When you place an item in, instead of placing the item in the slot, it creates a copy of it, that you can't take out or use.

Does anyone know how to do this? Is there an open source mod that does it so I can see how it works?

RedPower's filters and relays use this as well.

 

Offhand I can't think of how it's done, though.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Buildcraft's diamond pipes do.

Oh yeah, they do!

I went into the code(BC is open source), and it uses this GuiAdvancedSlot stuff. I'm going to try to explain it:

This appears to be the important part:

	protected void mouseClicked(int i, int j, int k) {
	super.mouseClicked(i, j, k);

	int cornerX = (width - xSize) / 2;
	int cornerY = (height - ySize) / 2;

	int position = getSlotAtLocation(i - cornerX, j - cornerY);

	IInventorySlot slot = null;

	if (position != -1) {
		slot = (IInventorySlot) slots[position];
	}

	if (slot != null) {
		ItemStack playerStack = mc.thePlayer.inventory.getItemStack();

		ItemStack newStack;
		if (playerStack != null) {
			newStack = playerStack.copy();
			newStack.stackSize = 1;
		} else {
			newStack = null;
		}

		filterInventory.setInventorySlotContents(position, newStack);

		if (CoreProxy.proxy.isRenderWorld(filterInventory.worldObj)) {
			PacketSlotChange packet = new PacketSlotChange(PacketIds.EMERALD_PIPE_SELECT, filterInventory.xCoord, filterInventory.yCoord,
					filterInventory.zCoord, position, newStack);
			CoreProxy.proxy.sendToServer(packet.getPacket());
		}
	}
}

When the mouse is clicked in the GUI, it gets the slot at the location that was clicked(int i and int j seem to be the x and y of where they clicked). cornerX and cornerY I think are a thing to determine where the window is so it can know where it's clicked. Once it gets the slot where it's clicked, it checks if the slot number is not -1(I think that's the number that's returned if there's no slot where they clicked). If it isn't -1. it creates a new "slot" and sets it to the slot that was clicked. Then it gets the player's held item stack when they clicked, creates a copy of it, sets the stack size to one, and puts it in at the location.

 

The IInventorySlot is in the buildcraft.core.gui.GuiAdvancedInterface class; it extends the AdvancedSlot class. That class has this method:

		public ItemStack getItemStack() {
		return null;
	}

This means that when the player tries to click and access the slot, it gives them nothing.

 

If you want to look at this code in more detail, check out Buildcraft's source code.

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.