Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED][1.12.2] Access to another player's inventory through dimensions
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
Sunser

[SOLVED][1.12.2] Access to another player's inventory through dimensions

By Sunser, November 12 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Sunser    3

Sunser

Sunser    3

  • Tree Puncher
  • Sunser
  • Members
  • 3
  • 32 posts
Posted November 12 (edited)

I'm trying to implement the well-known /invsee command. This is what I have done so far:

    @Override
    public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
        if (args.length != 1) {
            throw new InvalidNumberOfArgumentsException();
        }
        // fetch target's inventory
        EntityPlayerMP target = server.getPlayerList().getPlayerByUsername(args[0]);
        if (target == null) return; // TODO: send an error message
        IInventory targetInventory = target.inventory;
        // displaying it to sender
        EntityPlayerMP player = (EntityPlayerMP)sender;
        player.displayGUIChest(targetInventory);
    }

 

It works perfectly when both sender and target are in the same dimension, but if they are not, the GUI closes instantly. So I took a look at the

net.minecraft.entity.player.EntityPlayerMP#displayGUIChest

source code and tried to understand why.

 

This is the piece of code which I think blocks me: (l.948)

      if (this.openContainer != this.inventoryContainer)
            {
                this.closeScreen();
            }

 

I also took a look at

net.minecraft.entity.player.EntityPlayerMP#changeDimension

to check if EntityPlayerMP's attributes openContainer and inventoryContainer where changed but it is not the case.

 

What is wrong with what I am doing ? I feel like I missed something!

Edited November 12 by Sunser
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6684

diesieben07

diesieben07    6684

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6684
  • 45696 posts
Posted November 12

It has nothing to do with dimension. InventoryPlayer#isUsableByPlayer requires the using player to be within 8 blocks of the target player.

You need to create your own inventory wrapper which does not have this limitation.

  • Quote

Share this post


Link to post
Share on other sites

Sunser    3

Sunser

Sunser    3

  • Tree Puncher
  • Sunser
  • Members
  • 3
  • 32 posts
Posted November 12

Ouch, I totally missed it. Thank you !

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • EmerProd
      Forge 1.12.2 Crash

      By EmerProd · Posted 10 minutes ago

      It worked by removing the 1.7.10 and 1.8.9 Optifine from mods folder, thank you.
    • J3sq
      Minecraft v1.15 - Supported by Forge?

      By J3sq · Posted 11 minutes ago

      I have just re-installed Minecraft Java Edition onto a new Windows 10 PC, after a while of not playing. I haven't had many issues with modding (that I couldn't solve though reading) in the past, however this time I can't seem to get Forge to recognise any mods. I'm fairly sure my issue is that I'm running version 1.15 of Minecraft and version 1.14.4 of Forge - I have searched and searched for Forge 1.15 and have found a couple of dodgy links (which I did not click), however as Forge version 1.15 is not on the official site I was wondering if anyone can advise me on what to do? Is there a current fix for this or do I just wait for a compatible version?   debug.log: https://pastebin.com/6HzEwf0K    
    • bandofbros20
      1.12.2 Forge isnt working, are these the logs you need?

      By bandofbros20 · Posted 30 minutes ago

      [1211/164737.130:WARNING:angle_platform_impl.cc(41)] rx::HLSLCompiler::compileToBinary(224):  C:\fakepath(37,8-56): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them C:\fakepath(43,8-26): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them
    • Draco18s
      Distinguish singleplayer vs. multiplayer

      By Draco18s · Posted 53 minutes ago

      Items are not proxies. Proxies are proxies, Items are Items. The Item is supposed to call a method in the proxy, it is not the proxy itself.
    • vMystic
      [1.12.2] plugin with id 'net.minecraftforge.gradle.forge' not found

      By vMystic · Posted 1 hour ago

      Ive tried googling for a long time and i cant find anything on this, Whenever I try to run gradlew setupDecompWorkspace I get the error plugin with id 'net.minecraftforge.gradle.forge' not found ive talked with someone and they said the people here can help me with this issue. Any suggestions?
  • Topics

    • EmerProd
      4
      Forge 1.12.2 Crash

      By EmerProd
      Started Sunday at 06:23 PM

    • J3sq
      0
      Minecraft v1.15 - Supported by Forge?

      By J3sq
      Started 11 minutes ago

    • bandofbros20
      0
      1.12.2 Forge isnt working, are these the logs you need?

      By bandofbros20
      Started 30 minutes ago

    • solitone
      15
      Distinguish singleplayer vs. multiplayer

      By solitone
      Started December 5

    • vMystic
      0
      [1.12.2] plugin with id 'net.minecraftforge.gradle.forge' not found

      By vMystic
      Started 1 hour ago

  • Who's Online (See full list)

    • J3sq
    • Ommina
    • coolsim
    • Ellis,Hunter
    • ComputerCraft32
    • Darren Hayden
    • EmerProd
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED][1.12.2] Access to another player's inventory through dimensions
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community