Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] Why does armor rendering use ItemStack#isItemEnchanted ?


coolAlias
 Share

Recommended Posts

I've got an item that I want to have a base enchantment that is just its 'normal' state, so I don't want the enchanted glow to render. Overriding Item#hasEffect(ItemStack) works great for the item (a helmet, btw) everywhere EXCEPT when it is worn, which I have traced down to this bizarre discrepancy:

 

The easily-customizable Forge method Item#hasEffect(ItemStack) which is called by ItemStack#hasEffect is used everywhere except for LayorArmorBase, which instead calls the impossible-to-modify ItemStack#isItemEnchanted.

 

Was this just missed, or is it intentional?

Link to comment
Share on other sites

  • 2 months later...

I'm in 1.7.10, I'm coming across the same issue. I was going to ignore it for the time being (because my gf wants to play and not watch me code), but thought I would do some rudimentary research on the matter to see if there was a "quick" fix.

 

I thought I'd post in your thread instead of writing my own.

Link to comment
Share on other sites

I thought I'd post in your thread instead of writing my own.

Wow, someone who uses search! Thanks for bumping the thread, I'd totally forgotten about it ;)

 

It seems there is no way to fix this other than to submit a PR to the Forge project or open an issue and hope Lex decides to work on it. All it would need to change is line 80 of LayerArmorBase to use #hasEffect(ItemStack) instead of #isItemEnchanted.

 

I tried setting up a Forge workspace before but had some issues. The first time I set it up the code base was somehow 2000+ commits behind master. No idea how that could have happened, as I cloned straight from the master branch. Second time I got the latest commits but there was an error in the build script that prevented the project from setting up or something, don't remember exactly what it was now, as this was over a month ago, but there was a post with the same problem from back in 1.7.10 and the fix was on Forge's end then.

 

Anyway, long story short, due to technical difficulties, I won't be submitting PRs myself anytime soon.

Link to comment
Share on other sites

I have one weird idea that might work as a workaround.

 

I think that the getSubTypes() method is called on all items when they are used on the client. This method provides a list of ItemStacks with quantity 1 for each subtype. I think this may be the source of ALL ItemStacks on the client, since it would make sense that you always need to check subtypes before rendering, creative tab, etc.

 

Now, the problem method in ItemStack() is the isItemEnchanged(). So what if you made a custom class that extends ItemStack that overrides the isItemEnchanted() method to return false? Then in the getSubTypes() method for your custom Item, for the base item return the custom ItemStack and return regular ItemStacks for the rest?

 

Just possibly might work with only a dozen lines of code.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Hmmm. I guess that makes sense. What if there was code that used a tick event handler to replace the ItemStack in the player inventory with the custom extended ItemStack? The packets of course would not contain this information, but if both the client and server were replacing the ItemStack it might stay synced.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Turns out I'm stupid. Changing the folder name to "🅱️orge" screwed up the unicode system.
    • Hello There! In the 104th episode of Hunger Games, Ben, Logan and Cad for some reason have most of their fights in the water this game, we actually have no idea why but it did work in our favor... sometimes!  
    • I've been trying to get a server running on my Raspberry Pi, but run.sh won't function properly! I've used chmod, but it fails every time I try to run it. Here's the output: pi@raspberrypi:~/🅱️orge $ sudo chmod +x run.sh pi@raspberrypi:~/🅱️orge $ ./run.sh Exception in thread "main" java.lang.ExceptionInInitializerError at cpw.mods.securejarhandler@1.0.3/cpw.mods.jarhandling.SecureJar.from(SecureJar.java:58) at cpw.mods.securejarhandler@1.0.3/cpw.mods.jarhandling.SecureJar.from(SecureJar.java:50) at cpw.mods.securejarhandler@1.0.3/cpw.mods.jarhandling.SecureJar.from(SecureJar.java:42) at cpw.mods.bootstraplauncher@1.0.0/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:93) Caused by: java.lang.IllegalArgumentException: Error decoding percent encoded characters at java.base/sun.net.www.ParseUtil.decode(ParseUtil.java:218) at java.base/jdk.internal.loader.URLClassPath$FileLoader.<init>(URLClassPath.java:1219) at java.base/jdk.internal.loader.URLClassPath$3.run(URLClassPath.java:488) at java.base/jdk.internal.loader.URLClassPath$3.run(URLClassPath.java:482) at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) at java.base/jdk.internal.loader.URLClassPath.getLoader(URLClassPath.java:481) at java.base/jdk.internal.loader.URLClassPath.getLoader(URLClassPath.java:449) at java.base/jdk.internal.loader.URLClassPath$1.next(URLClassPath.java:345) at java.base/jdk.internal.loader.URLClassPath$1.hasMoreElements(URLClassPath.java:356) at java.base/jdk.internal.loader.BuiltinClassLoader$1.hasNext(BuiltinClassLoader.java:408) at java.base/jdk.internal.loader.BuiltinClassLoader$1.hasMoreElements(BuiltinClassLoader.java:416) at java.base/java.lang.CompoundEnumeration.next(ClassLoader.java:2725) at java.base/java.lang.CompoundEnumeration.hasMoreElements(ClassLoader.java:2734) at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1210) at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1228) at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273) at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309) at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393) at java.base/java.nio.file.spi.FileSystemProvider.loadInstalledProviders(FileSystemProvider.java:156) at java.base/java.nio.file.spi.FileSystemProvider$1.run(FileSystemProvider.java:207) at java.base/java.nio.file.spi.FileSystemProvider$1.run(FileSystemProvider.java:204) at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) at java.base/java.nio.file.spi.FileSystemProvider.installedProviders(FileSystemProvider.java:204) at cpw.mods.securejarhandler@1.0.3/cpw.mods.jarhandling.impl.Jar.<clinit>(Jar.java:29) ... 4 more (Yes, the 🅱️s are intentional)
    • when i press install on any version it says "adfoc.us redirected you too many times" and i cant install any version. please help.
    • I've got flywheel installed but it still gives me the exit on error
  • Topics

×
×
  • Create New...

Important Information

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