Jump to content

Moving items from player to chest


cartycrabber

Recommended Posts

I am trying to find a way to move items from the player into an opened chest, kind of like a death chest mod but completely client side, so that it will work on servers. What I tried using is this (inside of a keybind):

 

EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;

player.openContainer.transferStackInSlot(player, 1);

 

This transfers the items in slot one of the chest into the player's inventory when I press the bound key and have a chest open, but once you try to pick up the transferred items, they revert to where they were before. I tried adding this, to see if it would help:

 

player.openContainer.detectAndSendChanges();

player.inventoryContainer.detectAndSendChanges();

 

But those didn't help either. What should I do to get this code to work, or is there another method that will work? Thanks in advance!

Link to comment
Share on other sites

That may have been a bit unclear. I meant so that I can run it on my client, and it will still work while connected to a server instead of just SSP. Since it has to work on a client while connected to a server, I cant just do something like delete the items in the player inventory and add them in the chest, as the server would not let the client do this.

Link to comment
Share on other sites

You can't.  Client side is visual only.

 

If you want something to function like you have described, it would need to be a mod that is installed on the server.

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.

Link to comment
Share on other sites

The client has to send the message to the server when it receives the shift click on an item in the inventory. Is there not a way to spoof this and send what ever info to the server that it would send if I had actually gone in and shift clicked a slot myself?

 

Having a container open involves a lot of voodoo.  You can't spoof that.  Opening a chest actually DOES stuff on the server side so the server knows what inventory you're interacting with.

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.

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.