Jump to content

Wealthyturtle

Members
  • Posts

    5
  • Joined

  • Last visited

Wealthyturtle's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. KeyInputEvent works, thank you! Successfully extracts inventory content
  2. Thanks for the help, but now I seem to be stuck... From what I can see, the only real solution is to add a custom PacketHandler. The problem is, all the examples I could find were with custom packet sending/recieving (e.g. https://github.com/sinkillerj/ProjectE/blob/c17ff6e1b7151b9ef12396af47a937bb599bf7bf/src/main/java/moze_intel/projecte/network/PacketHandler.java#L23-L52), I couldn't find any examples for vanilla packets, like at all.
  3. Just tried implementing a KeyHandler, it works, but only when the user is not in a GUI Screen, otherwise the keystroke isn't registered
  4. Sorry for the late response, but originally I wanted to test if the GuiContainer contained a particular item, e.g. diamond, and if it's true, alert the player. The rest can be settled later, the main issue is the deriving of the container's items. I've tried additional things like Thread.sleep, which just hangs the client and doesn't actually affect the result. I've also tried tried TickEvent.ClientTickEvent, however even when the container is opened for a few seconds, it doesn't register the items at all for some reason... Any advice?
  5. Which packet type would contain the inventory data, and how would I possibly go about adding a listener to it?
  6. Foreword: Sorry if I make any silly mistakes here, I'm not too familiar with how Forge handles Inventories and such... Essentially, I want to make a client-side Forge mod that will be able to extract the contents of any GUI and print it into the logs (for now). I do not wish to use the PlayerContainerEvent because it does not work properly (i.e. just returns a NonNullList<ItemStack> full of air) when getting GUIs from some servers' plugins (perhaps due to Bukkit/Spigot doing some funky stuff backend) Listener Class: public class Listeners { @SubscribeEvent public static void onContainerOpen(GuiOpenEvent event) { GuiScreen gui = event.getGui(); if(gui instanceof GuiContainer) { GuiContainer gc = (GuiContainer)gui; NonNullList<ItemStack> items = gc.inventorySlots.getInventory(); for(int i = 0; i < items.size(); i++) { project.LOGGER.debug("CONTAINER/" + i + ": " + items.get(i).toString()); } } } } Currently, when using this class, even through there are items in the chest being right clicked, this occurs [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/0: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/1: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/2: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/3: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/4: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/5: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/6: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/7: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/8: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/9: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/10: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/11: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/12: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/13: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/14: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/15: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/16: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/17: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/18: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/19: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/20: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/21: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/22: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/23: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/24: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/25: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/26: 1xblock.minecraft.air [Client thread/DEBUG] [co.we.au.project/]: CONTAINER/27: 64xblock.minecraft.bedrock Where indices 0 to 26 are supposed to contain the chest's items (I put sand inside) but it returns air instead? Indices 27 and onwards contains the player's inventory. I think the issue might be that the client is not properly receiving the items from the server, but I'm not sure if that is truly the case, and how to fix it if it is the case... Any assistance would be greatly appreciated. Thanks!
×
×
  • Create New...

Important Information

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