Adding biomesoplenty:double_plant:half=lower/upper to shaders block.properties throws ArrayIndexOutOfBoundsException.
scearcrovv opened this issue · 2 comments
Issue Report
Mod Version
BiomesOPlenty-1.12.2-7.0.1.2439-universal
What's the issue you encountered?
Adding biomesoplenty:double_plant:half=lower
or [..]=upper
to shaders block.properties
with double_plant
waving results in an ArrayIndexOutOfBoundsException
.
How can the issue be reproduced?
Use a shader that supports double_plant
waving, like Continuum 2.0.2 and change the last two block properties as shown below:
block.175 = double_plant:half=lower biomesoplenty:double_plant:half=lower
block.176 = double_plant:half=upper biomesoplenty:double_plant:half=upper
Cause
biomesoplenty.common.block.BlockBOPDoublePlant.getStateFromMeta(int)
uses binary operations to determine which Half
of the plant and what DoublePlantType
the block in question is. Apparently, when using the selector :half=lower
or :half=lower
an unexpected value exceeding 8
is passed.
Solution
Add an upper bound to the result of both binary operations on the int meta
. I.e. change BlockBOPDoublePlant.java:122 like this:
- Binary logic:
return this.getDefaultState().withProperty(HALF, Half.values()[(meta >> 3) & 1]).withProperty(VARIANT, DoublePlantType.values()[(meta & 7) & 3]);
- Integer logic:
return this.getDefaultState().withProperty(HALF, Half.values()[Math.max(meta >> 3, 1)]).withProperty(VARIANT, DoublePlantType.values()[Math.max(meta & 7, 3)]);
Both solutions have been tested and are working.
Logs
Stacktrace:
java.lang.ArrayIndexOutOfBoundsException: 4 at biomesoplenty.common.block.BlockBOPDoublePlant.func_176203_a(BlockBOPDoublePlant.java:122) at net.optifine.config.ConnectedParser.getStateFromMeta(ConnectedParser.java:393) at net.optifine.config.ConnectedParser.parseBlockMetadatas(ConnectedParser.java:361) at net.optifine.config.ConnectedParser.parseMatchBlock(ConnectedParser.java:191) at net.optifine.config.ConnectedParser.parseMatchBlocks(ConnectedParser.java:95) at net.optifine.shaders.BlockAliases.loadBlockAliases(BlockAliases.java:170) at net.optifine.shaders.BlockAliases.update(BlockAliases.java:98) at net.optifine.shaders.Shaders.loadShaderPackProperties(Shaders.java:1058) at net.optifine.shaders.Shaders.loadShaderPack(Shaders.java:933) at net.optifine.shaders.Shaders.setShaderPack(Shaders.java:862) at net.optifine.shaders.gui.GuiSlotShaders.selectIndex(GuiSlotShaders.java:91) at net.optifine.shaders.gui.GuiSlotShaders.func_148144_a(GuiSlotShaders.java:81) at net.minecraft.client.gui.GuiSlot.func_178039_p(GuiSlot.java:323) at net.optifine.shaders.gui.GuiShaders.func_146274_d(GuiShaders.java:117) at net.minecraft.client.gui.GuiScreen.func_146269_k(GuiScreen.java:501) at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1759) at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1098) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398) at net.minecraft.client.main.Main.main(SourceFile:123) 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.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
We’re no longer supporting 1.12, but you’re welcome to make a pull request and it will be merged.