Posted December 28, 20186 yr I am trying to make a command thing that edits NBT on an item and changes how the item functions. This is really hard to explain can someone take a look at this? https://gist.github.com/OtisGoodman/96da24295c450bc02f4d58890ef60faf https://gist.github.com/OtisGoodman/57480c48b4dc516cb11bf4dad7a353a5 https://gist.github.com/OtisGoodman/487e771261a107a451c20d97f7712504 https://gist.github.com/OtisGoodman/eededaa5f545629153278e8e58ce3027
December 29, 20186 yr Author 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.
December 29, 20186 yr 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?
December 30, 20186 yr Author 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
December 31, 20186 yr Author 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?
December 31, 20186 yr 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 Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
December 31, 20186 yr Author Ok, nearly working my last problem is when I right click on the book the shout cast's twice.
January 1, 20196 yr 12 hours ago, Otis Goodman said: Ok, nearly working my last problem is when I right click on the book the shout cast's twice. Maybe check if world is remote? I've had this problem before with duplicate events.
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.