Jump to content

[1.7.10]How would I check if the players inventory is open?


starwarsmace

Recommended Posts

The server does in fact not know if the player is looking at their inventory or not. As far as the server is concerned you are always looking at your inventory, unless you are looking at another container (such as a chest).

On the client you can check Minecraft.getMinecraft().currentScreen instanceof GuiInventory (which would only cover the survival inventory).

Sorry about not telling you guys. I figured it out. I just used the GUIOPEN event, though diesieben's method is much better.

Anyway, now I have another question is there a good and efficient way to see which slot the player clicked?

 

Edit: By the way, it has to be the middle click. And is using the lwjgl Mouse class x and y and then compare it to the x and y to all the slots in the inventory and see which was the closest a good idea?

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

I should probably make a new thread for this but oh well. This is an open gl questions really.

https://www.opengl.org/discussion_boards/showthread.php/185705-How-do-I-use-smoothing-groups-from-obj-files?p=1264468#post1264468

 

To summarize what I asked in that thread, how would I smooth a .obj model using the smoothiing groups? 

 

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

The server does in fact not know if the player is looking at their inventory or not. As far as the server is concerned you are always looking at your inventory, unless you are looking at another container (such as a chest).

On the client you can check Minecraft.getMinecraft().currentScreen instanceof GuiInventory (which would only cover the survival inventory).

 

I played around with this and was wondering, how would you check for the players HUD inventory bar being open in survival mode and specifically check for a slot number and whether or not it contains an item

Link to comment
Share on other sites

I guess to clarify

 

how would you check whether or not a specific slot in the players HUD inventory bar does not contain an item. And -- if and only if  this specific slot doesnt contain an itemstack (ie is empty where itemstack is null) then add an item to that specific slot. Ive been stumped by this for a while.

Link to comment
Share on other sites

try this it happens the first time but after that it doesnt work... move the items around remove them from the hud it isnt that simple.

 

@SubscribeEvent
public void onPlayerJoin(PlayerLoggedInEvent event) {
	System.out.println("This is called Log In");

	if(!event.player.worldObj.isRemote && !event.player.capabilities.isCreativeMode){
		System.out.println("on server side and not in creative");
		if(event.player.inventory.mainInventory[0] == null){
			System.out.println("Adding itemCustom1");	
			event.player.inventory.addItemStackToInventory(new ItemStack(CommonProxy.itemCustom1));
			} 
		if(event.player.inventory.mainInventory[1] == null){
			System.out.println("Adding itemCustom2");	
			event.player.inventory.addItemStackToInventory(new ItemStack(CommonProxy.itemCustom2));
		    }
		if(event.player.inventory.mainInventory[2] == null){
			System.out.println("Adding itemCustom3");	
			event.player.inventory.addItemStackToInventory(new ItemStack(CommonProxy.itemCustom3));
		    }
	}

}

[EDIT] the weird thing is if you move the item -> itemCustom3 lets say to a different slot lets say slot 5 and then relog. Now slot 3 is empty and so you should get itemCustom 3 placed into slot 3 but you dont you get it in slot 5 now. If you throw the item away then it works again upon relog you get item 3 in slot 3.

Link to comment
Share on other sites

For some reason MouseInputEvent didnt call. It might be because Im not registering it on the right bus. It has no javadocs, so I was wondering whether any of you know. Also, im currently registering it on MinecraftForge.EVENT_BUS

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

You need to register it on the FML bus:

FMLCommonHandler.instance().bus()

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

It appears to me that the Slot.displayX(or y) is offsetted. For example, the first slot on the screen is around 240 pixels on the x. But the slot.displayX is saying the x is on 8, when 8 is all the way at the edge. It looks like to me it is offeseted. Does it start at the left side of the players inventory? And does the y start at the top of the inventory? If so, is there some equation that I can use to get the offset, since I know that the pixel lengths change when the gui size changes or its fullscreen or not.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

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.