Search In
• More options...
Find results that contain...
Find results in...

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

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

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

##### Share on other sites

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.

##### 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/

##### Share on other sites

Yeah, nice idea, but that's not going to work. getSubTypes is by far not the only source of ItemStacks. getSubTypes fills the creative-tab, that's all.

The stacks in the armor slots (=inventory) are filled from packets, where ItemStacks are read from pure bytes.

##### 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/

##### Share on other sites

Yes, you could do that. But it would most likely be very glitchy.

Plus you would need an AccessTransformer to make ItemStack non-final.

A much better way (for now) would be to reflectively replace the armor layer instance.

You're my hero

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×

• ### Posts

• I checked my list of mod and immersive portal wasn't even installed.
• Look at your image. You are showing  /Applications/Minecraft/Contents/mods Your mods folder is Take a screenshot of the contents of second one. Although we can guess, you have been downloading your mods into the first folder when you should be putting them in the second one.
• I play the world yesterday and it was fine, upon loading it today it crashed ╥_╥. Pls help.  [main/ERROR]: Exception caught during firing event: null     Index: 6     Listeners:         0: HIGH         1: ASM: class me.shedaniel.architectury.event.forge.EventHandlerImplClient event(Lnet/minecraftforge/client/event/RecipesUpdatedEvent;)V         2: NORMAL         3: ASM: class owmii.lib.client.wiki.Wiki collect(Lnet/minecraftforge/client/event/RecipesUpdatedEvent;)V         4: ASM: class com.blamejared.crafttweaker.impl.events.CTStateEventHandler onRecipesUpdated(Lnet/minecraftforge/client/event/RecipesUpdatedEvent;)V         5: ASM: mekanism.client.ClientTickHandler@43d9842f recipesUpdated(Lnet/minecraftforge/client/event/RecipesUpdatedEvent;)V         6: net.minecraftforge.eventbus.EventBus$$Lambda2959/736640638@6d07c39b java.util.ConcurrentModificationException at java.util.ArrayListItr.checkForComodification(ArrayList.java:901) at java.util.ArrayListItr.next(ArrayList.java:851) at mezz.jei.load.PluginCaller.callOnPlugins(PluginCaller.java:21) at mezz.jei.load.PluginLoader.<init>(PluginLoader.java:109) at mezz.jei.startup.JeiStarter.start(JeiStarter.java:69) at mezz.jei.startup.ClientLifecycleHandler.startJEI(ClientLifecycleHandler.java:147) at mezz.jei.startup.ClientLifecycleHandler.setupJEI(ClientLifecycleHandler.java:140) at mezz.jei.startup.ClientLifecycleHandler.lambdanew3(ClientLifecycleHandler.java:106) at mezz.jei.startup.ClientLifecycleHandler$$Lambda$29176/1547335276.accept(Unknown Source) at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:247) at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:239) at net.minecraftforge.eventbus.EventBus$$Lambda2959/736640638.invoke(Unknown Source) at net.minecraftforge.eventbus.EventBus$$Lambda$3273/1859299978.invoke(Unknown Source)     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302)     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283)     at net.minecraftforge.client.ForgeHooksClient.onRecipesUpdated(ForgeHooksClient.java:772)     at net.minecraft.client.network.play.ClientPlayNetHandler.func_199525_a(ClientPlayNetHandler.java:1314)     at net.minecraft.network.play.server.SUpdateRecipesPacket.func_148833_a(SourceFile:27)     at net.minecraft.network.play.server.SUpdateRecipesPacket.func_148833_a(SourceFile:15)     at net.minecraft.network.PacketThreadUtil.func_225383_a(SourceFile:21)     at net.minecraft.network.PacketThreadUtil$$Lambda34638/1869809823.run(Unknown Source) at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213166_h(SourceFile:144) at net.minecraft.util.concurrent.RecursiveEventLoop.func_213166_h(SourceFile:23) at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213168_p(SourceFile:118) at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213160_bf(SourceFile:103) at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:948) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:607) at net.minecraft.client.main.Main.main(Main.java:184) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambdalaunchService0(FMLClientLaunchProvider.java:37) at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$502/1391735333.call(Unknown Source) at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [main/FATAL]: Error executing task on Client java.util.ConcurrentModificationException: null at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901) ~[?:1.8.0_51]     at java.util.ArrayList$Itr.next(ArrayList.java:851) ~[?:1.8.0_51] at mezz.jei.load.PluginCaller.callOnPlugins(PluginCaller.java:21) ~[?:7.7.1.152] at mezz.jei.load.PluginLoader.<init>(PluginLoader.java:109) ~[?:7.7.1.152] at mezz.jei.startup.JeiStarter.start(JeiStarter.java:69) ~[?:7.7.1.152] at mezz.jei.startup.ClientLifecycleHandler.startJEI(ClientLifecycleHandler.java:147) ~[?:7.7.1.152] at mezz.jei.startup.ClientLifecycleHandler.setupJEI(ClientLifecycleHandler.java:140) ~[?:7.7.1.152] at mezz.jei.startup.ClientLifecycleHandler.lambda$new$3(ClientLifecycleHandler.java:106) ~[?:7.7.1.152] at mezz.jei.startup.ClientLifecycleHandler$$Lambda29176/1547335276.accept(Unknown Source) ~[?:?] at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:247) ~[eventbus-4.0.0.jar:?] at net.minecraftforge.eventbus.EventBus.lambdaaddListener11(EventBus.java:239) ~[eventbus-4.0.0.jar:?] at net.minecraftforge.eventbus.EventBus$$Lambda$2959/736640638.invoke(Unknown Source) ~[?:?]     at net.minecraftforge.eventbus.EventBus$$Lambda3273/1859299978.invoke(Unknown Source) ~[?:?] at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] at net.minecraftforge.client.ForgeHooksClient.onRecipesUpdated(ForgeHooksClient.java:772) ~[?:?] at net.minecraft.client.network.play.ClientPlayNetHandler.func_199525_a(ClientPlayNetHandler.java:1314) ~[?:?] at net.minecraft.network.play.server.SUpdateRecipesPacket.func_148833_a(SourceFile:27) ~[?:?] at net.minecraft.network.play.server.SUpdateRecipesPacket.func_148833_a(SourceFile:15) ~[?:?] at net.minecraft.network.PacketThreadUtil.func_225383_a(SourceFile:21) ~[?:?] at net.minecraft.network.PacketThreadUtil$$Lambda$34638/1869809823.run(Unknown Source) ~[?:?] at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213166_h(SourceFile:144) [?:?] at net.minecraft.util.concurrent.RecursiveEventLoop.func_213166_h(SourceFile:23) [?:?] at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213168_p(SourceFile:118) [?:?] at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213160_bf(SourceFile:103) [?:?] at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:948) [?:?] at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:607) [?:?] at net.minecraft.client.main.Main.main(Main.java:184) [?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:37) [forge-1.16.5-36.2.35.jar:36.2] at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$502/1391735333.call(Unknown Source) [forge-1.16.5-36.2.35.jar:36.2]     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.1.3.jar:?]     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.1.3.jar:?]     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.1.3.jar:?]     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.1.3.jar:?]     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.1.3.jar:?]
• NEVER MIND I AM STUPID I HAD EXTRACTED MODS IN MY MOD FOLDER IM SORRY

• 21
• 68
• 0
• 1
• 0
• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...