Jump to content

Recommended Posts

Posted

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!

Posted

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.

  • Thanks 1

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.

Posted (edited)

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 by Lumby
EDIT: tidied up spacing for the code segment
Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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