BlakeBr0 / MysticalAgradditions

An addon for Mystical Agriculture.
https://blakesmods.com/mystical-agradditions
MIT License
12 stars 23 forks source link

Harvesting Inferium Seeds Tier 6 with Pneumaticcraft's Drones causes crash and broken world #39

Closed Syrious closed 5 years ago

Syrious commented 5 years ago

Minecraft Version: 1.12.2 Forge Version: 14.23.5.2796 Mod Version: 0.8.4-303

Problem: Placing a harvesting drone near a grown inferieum essence plant the game crashes the second the drone scans the flower, rendering the entire world useless.

How to reproduce:

Stacktrace: -- Head -- Thread: Client thread Stacktrace: at com.blakebr0.mysticalagradditions.blocks.BlockTier6InferiumCrop.getDrops(BlockTier6InferiumCrop.java:38) at me.desht.pneumaticcraft.api.harvesting.IHarvestHandler.addFilterItems(IHarvestHandler.java:78) at me.desht.pneumaticcraft.common.ai.DroneAIHarvest.hasApplicableItemFilters(DroneAIHarvest.java:62) at me.desht.pneumaticcraft.common.ai.DroneAIHarvest.lambda$getApplicableHandler$0(DroneAIHarvest.java:54) at me.desht.pneumaticcraft.common.ai.DroneAIHarvest$$Lambda$4937/447511784.test(Unknown Source) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1351) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:529) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:516) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at me.desht.pneumaticcraft.common.ai.DroneAIHarvest.getApplicableHandler(DroneAIHarvest.java:55) at me.desht.pneumaticcraft.common.ai.DroneAIHarvest.isValidPosition(DroneAIHarvest.java:35) at me.desht.pneumaticcraft.common.ai.DroneAIBlockInteraction.func_75253_b(DroneAIBlockInteraction.java:138) at me.desht.pneumaticcraft.common.ai.DroneAIManager.onUpdateTasks(DroneAIManager.java:367) at me.desht.pneumaticcraft.common.entity.living.EntityDrone.func_70071h(EntityDrone.java:414) at net.minecraft.world.World.func_72866_a(World.java:1993) at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:832) at net.minecraft.world.World.func_72870_g(World.java:1955)

-- Entity being ticked -- Details: Entity Type: pneumaticcraft:harvesting_drone (me.desht.pneumaticcraft.common.entity.living.EntityHarvestingDrone) Entity ID: 764 Entity Name: Harvesting Drone Entity's Exact location: -36.50, 4.50, -503.50 Entity's Block location: World: (-37,4,-504), Chunk: (at 11,0,8 in -3,-32; contains blocks -48,0,-512 to -33,255,-497), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1) Entity's Momentum: 0.00, -0.00, 0.00 Entity's Passengers: [] Entity's Vehicle: ERROR NullPointerException: null Stacktrace: at net.minecraft.world.World.func_72939_s(World.java:1759) at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:613)

-- Affected level -- Details: Level name: Creative All players: 1 total; [GCEntityPlayerMP['[Erased]'/612, l='Creative', x=-33.96, y=4.00, z=-499.83]] Chunk stats: ServerChunkCache: 1355 Drop: 0 Level seed: -1372003077712429255 Level generator: ID 01 - flat, ver 0. Features enabled: true Level generator options: Level spawn location: World: (-468,4,509), Chunk: (at 12,0,13 in -30,31; contains blocks -480,0,496 to -465,255,511), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 1836521 game time, 6000 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 1 (now: false), thunder time: 1 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:767) at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:185) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) at java.lang.Thread.run(Thread.java:745)

At thePneumaticCraft's issue tracker (I initially thought it was their bug) they pointed out the wrong casting in line BlockTier6InferiumCrop.java:38

desht commented 5 years ago

Just to note (I'm the PneumaticCraft dev): the cast of IBlockAccess world to World isn't valid; you can't assume an IBlockAccess is a World (and in the case of PNC Drones, it isn't - it's a ChunkCache).

Suggest changing that line to:

Random rand = world instanceof World ? ((World) world).rand : new Random();