Posted June 22, 20196 yr Hi, I want to create a letter item where if you use it the item opens a GUI for you to type in, which then adds that string to the NBTTagcompound of the item, just like ItemWritableBook. ItemWritableBook, however, simply called player.openBook() which leads to an empty method with no code, so I don't understand how the entire process should be undertaken. Are there any possible resources or mods that have a similar functionality that someone can point me towards as an example? Thanks in advance!
June 22, 20196 yr player.openBook() would be implemented in more than one place. One would be server side (EntityPlayerMP) and one would be client side (EntityPlayerClient, I think). That's where you need to look. 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.
June 22, 20196 yr Author I found it, thank you for your help! EntityPlayer seems to be extended by EntityPlayerMP and AbstractClientPlayer, the latter I'm guessing is the one that handles client side code. The AbstractClientPlayer is instantiated by EntityPlayerSP, which is where I found the other openBook() implementation. My question now is, how do I emulate this approach on my item? Do I simply have two if conditions like so, where the conditions check whether world.isRemote to execute client side or server side specific code?: @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (!worldIn.isRemote){ //emulate EntityPlayerMP code by doing a bunch of packet stuff }else if(worldIn.isRemote){ //emulate ENtityPlayerSP code like so this.mc.displayGuiScreen(new myCustomItemGUI(this, stack, true)); } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); } Edited June 22, 20196 yr by Lumby EDIT: tidied up spacing for the code segment
June 22, 20196 yr Forge also supplies an easier way of opening a GUI, not sure what the current name is, but it was Player#openGui(...). You'll still want to look at the vanilla gui classes to see how to handle player input and saving the data though. 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.
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.