Posted December 29, 20231 yr Hello! I have a tile entity and want it so if a player is holding an item and right clicks my tile entity, the item will be inserted in slot 5. How can I do this? I have a use() and made it so the inventory gui will open if you shift right click the block. Edited January 3, 20241 yr by Bunnly Solved
December 29, 20231 yr On the server for the Item's useOn, you need to get hold of the block's IItemHandler capability and use that to modify the inventory. https://forge.gemwire.uk/wiki/Capabilities The block can be found using the UseOnContext.hitResult See also (in case you need to override the default rules): https://github.com/MinecraftForge/MinecraftForge/blob/f09fd1f05b39df98f6415b44478b13723cee74cd/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java#L125 Alternatively, if it is your block, you can change Block.use() to check what the player is holding when they right click from the passed Player/InteractionHand. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
January 3, 20241 yr Author I solved it. I made a public Boolean() and a few others to do this. blockEntity.blah() I am so bad at explaining
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.