Posted July 27, 20205 yr Hello, What's the method that checks if player can take a certain stack? Like, if the player has 35.5 full stacks of dirt in their inventory, they still can take a stack of 32 blocks of dirt, but can't take either a stack of 33 dirt or a stack of any amount of cobblestone. Edited July 27, 20205 yr by RubyNaxela
July 27, 20205 yr 1 hour ago, RubyNaxela said: Hello, What's the method that checks if player can take a certain stack? Like, if the player has 35.5 full stacks of dirt in their inventory, they still can take a stack of 32 blocks of dirt, but can't take either a stack of 33 dirt or a stack of any amount of cobblestone. PlayerInventory#addItemStackToInventory 's javadoc: "Adds the stack to the first empty slot in the player's inventory. Returns {@code false} if it's not possible to place the entire stack in the inventory." Everything said above may be absolutely wrong. No rights reserved.
July 27, 20205 yr There's also: ItemStackHandler.insert(stack, true).isEmpty() Edited July 27, 20205 yr by Draco18s 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.
July 27, 20205 yr Author 5 hours ago, Dzuchun said: PlayerInventory#addItemStackToInventory 's javadoc Wait a minute... where can I get Minecraft source with javadoc? I've always used the .jar that is included in Forge MDK decompiled with Fernflower whenever I need to take a look at the game code.
July 27, 20205 yr 20 minutes ago, RubyNaxela said: Wait a minute... where can I get Minecraft source with javadoc? Its in your external resources. The first one is most of the code, client-extra.jar has a lot of the recipes, blockstates, and such. Edited July 27, 20205 yr by Draco18s 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.
July 27, 20205 yr Author Is this Eclipse? Apparently it has a different initial gradle script than IntelliJ - which I am using. I don't have two forge libraries. I only have one which contains the compiled .jar file. And, yes, I also have client-extra and I use it as well.
July 27, 20205 yr Author Thank you all for trying to point me out where to find the source/recomp library, but I know where would it be, it is just not present in my External Libraries list now, when I work with 1.16.1. The only way I can access it is from file explorer. Maybe some configuration error. Anyway, this thread seems to have deviated much from the topic. I wrote a function: public static void giveItemStack(PlayerEntity player, ItemStack stack) { if (!player.addItemStackToInventory(stack)) { player.dropItem(stack, false); } } that now works pretty much the same as the /give command, which is exactly what I wanted. 7 hours ago, Dzuchun said: PlayerInventory#addItemStackToInventory returns false if it's not possible to place the entire stack in the inventory. Thanks @Dzuchun for that precious piece of information.
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.