AtomicStryker's Infernal Mobs

AtomicStryker's Infernal Mobs

34M Downloads

[PetBats] Calling wild bats with pie doesn't work reliably, produces errors

Tora-B opened this issue ยท 1 comments

commented

EntityBat has two fields:
private static final DataParameter<Byte> HANGING
private BlockPos spawnPosition

In your preInit(), you're calling EntityBat.class.getDeclaredFields()[0], presumably to get the spawnPosition field. However, according to the documentation for Class.getDeclaredFields():

The elements in the returned array are not sorted and are not in any particular order.

So under some circumstances, you'll get the spawnPosition field as desired, while under others, you'll get the HANGING field, wild bats will ignore pie, and the log will spit out this error:

[04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: java.lang.IllegalAccessException: Can not set static final net.minecraft.network.datasync.DataParameter field net.minecraft.entity.passive.EntityBat.field_184660_a to net.minecraft.util.math.BlockPos [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at sun.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:76) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at sun.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:80) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at sun.reflect.UnsafeQualifiedStaticObjectFieldAccessorImpl.set(UnsafeQualifiedStaticObjectFieldAccessorImpl.java:77) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.lang.reflect.Field.set(Field.java:764) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at atomicstryker.petbat.common.PetBatMod.lambda$onPlayerLeftClick$1(PetBatMod.java:232) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at atomicstryker.petbat.common.PetBatMod$$Lambda$525/171636232.accept(Unknown Source) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at atomicstryker.petbat.common.PetBatMod.onPlayerLeftClick(PetBatMod.java:229) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_188_PetBatMod_onPlayerLeftClick_BreakSpeed.invoke(.dynamic) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraftforge.event.ForgeEventFactory.getBreakSpeed(ForgeEventFactory.java:170) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.entity.player.EntityPlayer.getDigSpeed(EntityPlayer.java:836) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraftforge.common.ForgeHooks.blockStrength(ForgeHooks.java:232) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.block.Block.func_180647_a(Block.java:559) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.block.state.BlockStateContainer$StateImplementation.func_185903_a(BlockStateContainer.java:408) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.client.multiplayer.PlayerControllerMP.func_180511_b(PlayerControllerMP.java:246) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.client.Minecraft.func_147116_af(Minecraft.java:1516) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.client.Minecraft.redirect$onClickMouse$zzj000(Minecraft.java:3480) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.client.Minecraft.func_184117_aA(Minecraft.java:2247) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.client.Minecraft.func_184118_az(Minecraft.java:2018) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1806) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1096) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:397) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.client.main.Main.main(SourceFile:123) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at java.lang.reflect.Method.invoke(Method.java:497) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [04:55:51] [main/INFO]: [atomicstryker.petbat.common.PetBatMod:lambda$onPlayerLeftClick$1:236]: at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

commented

c47f14b
Thank you for reporting this, you are correct