Jump to content

Troubles With Many Nbt/Idk Things


Otis Goodman

Recommended Posts

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

Okay, you just vomited a huge chunk of code into gists without even enabling syntax-highlighting.

Please, at the very least, explain what your issue is, except "troubles with many idk things".

2

Your right and I am sorry.

 

I am trying to use ShoutSetBook code to change the NBT of the ShoutBook  item so that it runs the shout by right-clicking but, I can't seem to get the shout to cast and I don't know what's wrong.

 

I hope that explains that better.

Link to comment
Share on other sites

https://gist.github.com/OtisGoodman/96da24295c450bc02f4d58890ef60faf#file-shoutbook-L59

https://gist.github.com/OtisGoodman/96da24295c450bc02f4d58890ef60faf#file-shoutbook-L124

So if the stack has no NBTTag you create a new one and then do nothing with it. You need to assign it to the stack with ItemStack#setTagCompound

 

https://gist.github.com/OtisGoodman/487e771261a107a451c20d97f7712504#file-cmdshout-L45

Any particular reason you are implementing ICommand directly instead of using CommandBase?

Link to comment
Share on other sites

The NBT problem is fixed but I have another.

I am not sure if my if statement that checks if the player is holding the shout book is working, can someone take a look and correct me if I am wrong.

Shout Book Item Class https://gist.github.com/OtisGoodman/96da24295c450bc02f4d58890ef60faf

Shout Set Book Class: https://gist.github.com/OtisGoodman/57480c48b4dc516cb11bf4dad7a353a5

 

Link to comment
Share on other sites

2 hours ago, diesieben07 said:
  • You cannot do this. Data like that must be stored in the ItemStack (like you already do). You cannot store it in the Item instance in any way.
  • You cannot compare strings using ==.
  •  Use TextComponentTranslation instead of TextComponentString + I18n. Otherwise you are translating on the server and you will always get English.
  •  You cannot compare ItemStacks using ==.

Thanks that helped what is the best way to compare strings and item stacks?

Link to comment
Share on other sites

43 minutes ago, Otis Goodman said:

Thanks that helped what is the best way to compare strings and item stacks?

String are Objects, not primitives - even though they are given special handling in java. They override the equals method so string1.equals(string2). ItemStack has a number of methods starting with areItemStacksEqual to compare 2 stacks

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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