Posted January 14, 20187 yr Hi, I've been trying to make a server-side mod to open up a regular chest inventory screen on a client and display some items, but for some reason the screen either flashes very briefly, or just doesnt open at all. I thought maybe it was something to do with setting Inventory slot contents, but after commenting out that code, the problem persisted. This is the class that opens up the inventory as well as updates it (haven't gotten to that part yet though.) public class RandOMat { private final EntityPlayerMP target; private final EntiyPlayerMP fakePlayer; private int stepCounter = 0; private int counterMax = 5; public RandOMat(OxideForgeVotifier plugin, EntityPlayerMP target) { this.target = target; //Create a fake player for our GUI //This method basically just returns FakePlayerFactory.get(world, new GameProfile(UUID.randomUUID(), "MyFakePlayer")); fakePlayer = plugin.getFakePlayerManager().getFakePlayer(target.getServerWorld()); ItemStack filler = new ItemStack(Blocks.GLASS_PANE, 1, 0); /*for(int i=0; i < 9*5; i++) { this.inventory.setInventorySlotContents(i, filler); } */ //Show the GUI to the player target.displayGUIChest(fakePlayer.inventory); } private void updateInventory() { //Do some things here. //Show the GUI to the player (Doing this makes the inventory flash very briefly every so often, before instantly closing again) //target.displayGUIChest(fakePlayer.inventory); ResourceLocation location = new ResourceLocation("minecraft", "block.note.hat"); this.target.world.playSound(this.target, this.target.getPosition(), new SoundEvent(location), SoundCategory.MASTER, 1, 1); } public void doTick() { if(stepCounter >= counterMax) { updateInventory(); stepCounter = 0; } stepCounter++; } } I read about fakeplayers not being able to do a lot of things, but didn't see anything about them not having an inventory. Was this perhaps just a part missing from the documentation? Or am I missing something else here? EDIT: nevermind, looking again at the code from https://github.com/LatvianModder/FTBUtilities/blob/master/src/main/java/com/feed_the_beast/ftbutilities/cmd/InvSeeInventory.java I realized that I messed it up by setting the method "isUsableByPlayer" to return false. Not quite sure why I did that either. (It's not shown in my example here that I use that extra class to wrap the inventory in because when posting here I thought it was obsolete. Mainly since in Spigot/Sponge development, it wasnt required) Problem solved anyway! Edited January 14, 20187 yr by xorinzor
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.