GloriousAlpaca Posted September 9, 2018 Posted September 9, 2018 (edited) Hello, I'm having a problem with my tile entity while searching for nearby EnergyStorages (Conduits). This is my code for finding adjacent Tile Entities with the EnergyStorage Capability: @Override public void update(){ if ((energy.getEnergyStored() != energy.getMaxEnergyStored())) { for(EnumFacing face : EnumFacing.values()) { BlockPos a = getPos().offset(face); TileEntity tile = world.getTileEntity(a); System.out.println(face.getName()); if (tile.hasCapability(CapabilityEnergy.ENERGY,face.getOpposite())) { System.out.println("ENERGIEZUFUHR"); /*int maxCap = energy.receiveEnergy(energy.getMaxRec(), true); energy.receiveEnergy(tile.getCapability(CapabilityEnergy.ENERGY,face).extractEnergy(maxCap,false), false);*/ } } } } The method for receiving energy is currently a comment to avoid unrelated crashes. This is the crash report I'm getting: ---- Minecraft Crash Report ---- WARNING: coremods are present: EnderCorePlugin (EnderCore-1.12.2-0.5.37.jar) Contact their authors BEFORE contacting forge // Why is it breaking :( Time: 9/9/18 10:00 AM Description: Ticking block entity java.lang.NullPointerException: Ticking block entity at com.andreas.ame.tileentities.EntityLaser.update(EntityLaser.java:34) at net.minecraft.world.World.updateEntities(World.java:2004) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Thread.java:748) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace: at com.andreas.ame.tileentities.EntityLaser.update(EntityLaser.java:34) -- Block entity being ticked -- Details: Name: ame:lasertable // com.andreas.ame.tileentities.EntityLaser Block type: ID #254 (tile.lasertable // com.andreas.ame.block.LaserTable) Block data value: 1 / 0x1 / 0b0001 Block location: World: (-254,65,248), Chunk: (at 2,4,8 in -16,15; contains blocks -256,0,240 to -241,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Actual block type: ID #254 (tile.lasertable // com.andreas.ame.block.LaserTable) Actual block data value: 1 / 0x1 / 0b0001 Stacktrace: at net.minecraft.world.World.updateEntities(World.java:2004) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643) -- Affected level -- Details: Level name: TEST All players: 0 total; [] Chunk stats: ServerChunkCache: 625 Drop: 0 Level seed: 6028521562681449438 Level generator: ID 00 - default, ver 1. Features enabled: true Level generator options: Level spawn location: World: (-228,64,236), Chunk: (at 12,4,12 in -15,14; contains blocks -240,0,224 to -225,255,239), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 257696 game time, 257696 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 123631 (now: false), thunder time: 150 (now: true) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Thread.java:748) -- System Details -- Details: Minecraft Version: 1.12.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_171, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 378688064 bytes (361 MB) / 1168637952 bytes (1114 MB) up to 1894252544 bytes (1806 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP 9.42 Powered by Forge 14.23.4.2705 24 mods loaded, 24 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored | State | ID | Version | Source | Signature | |:--------- |:--------------------------------- |:------------- |:----------------------------------------------- |:---------------------------------------- | | UCHIJAAAA | minecraft | 1.12.2 | minecraft.jar | None | | UCHIJAAAA | mcp | 9.42 | minecraft.jar | None | | UCHIJAAAA | FML | 8.0.99.99 | forgeSrc-1.12.2-14.23.4.2705.jar | None | | UCHIJAAAA | forge | 14.23.4.2705 | forgeSrc-1.12.2-14.23.4.2705.jar | None | | UCHIJAAAA | ame | 1.0 | ame-0.1.jar | None | | UCHIJAAAA | codechickenlib | 3.2.0.345 | CodeChickenLib-1.12.2-3.2.0.345-universal.jar | f1850c39b2516232a2108a7bd84d1cb5df93b261 | | UCHIJAAAA | redstoneflux | 2.0.2 | RedstoneFlux-1.12-2.0.2.3-universal.jar | 8a6abf2cb9e141b866580d369ba6548732eff25f | | UCHIJAAAA | cofhcore | 4.5.2 | CoFHCore-1.12.2-4.5.2.19-universal.jar | None | | UCHIJAAAA | cofhworld | 1.2.0 | CoFHWorld-1.12.2-1.2.0.5-universal.jar | 8a6abf2cb9e141b866580d369ba6548732eff25f | | UCHIJAAAA | endercore | 1.12.2-0.5.37 | EnderCore-1.12.2-0.5.37.jar | None | | UCHIJAAAA | thermalfoundation | 2.5.0 | ThermalFoundation-1.12.2-2.5.0.19-universal.jar | 8a6abf2cb9e141b866580d369ba6548732eff25f | | UCHIJAAAA | thermalexpansion | 5.5.0 | ThermalExpansion-1.12.2-5.5.0.29-universal.jar | 8a6abf2cb9e141b866580d369ba6548732eff25f | | UCHIJAAAA | enderio | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | enderiointegrationtic | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | enderiobase | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | enderioconduits | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | enderioconduitsappliedenergistics | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | enderioconduitsopencomputers | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | enderioconduitsrefinedstorage | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | enderiointegrationforestry | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | enderiointegrationticlate | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | enderiomachines | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | enderiopowertools | 5.0.31 | EnderIO-1.12.2-5.0.31.jar | None | | UCHIJAAAA | thermaldynamics | 2.5.1 | ThermalDynamics-1.12.2-2.5.1.14-universal.jar | 8a6abf2cb9e141b866580d369ba6548732eff25f | Loaded coremods (and transformers): EnderCorePlugin (EnderCore-1.12.2-0.5.37.jar) com.enderio.core.common.transform.EnderCoreTransformer com.enderio.core.common.transform.SimpleMixinPatcher GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Ender IO: No known problems detected. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!You are looking at the diagnostics information, not at the crash. !!! !!!Scroll up until you see the line with '---- Minecraft Crash Report ----'!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Profiler Position: N/A (disabled) Player Count: 0 / 8; [] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' I get it instantly if I place the block. Help would be appreciated! Edited September 9, 2018 by GloriousAlpaca Quote
V0idWa1k3r Posted September 9, 2018 Posted September 9, 2018 2 hours ago, GloriousAlpaca said: TileEntity tile = world.getTileEntity(a); This can and will return null if a block at a given position doesn't have a tile entity. So 2 hours ago, GloriousAlpaca said: if (tile.hasCapability(CapabilityEnergy.ENERGY,face.getOpposite())) You can't just do that a few lines later without checking for null first. Quote
GloriousAlpaca Posted September 9, 2018 Author Posted September 9, 2018 2 minutes ago, V0idWa1k3r said: This can and will return null if a block at a given position doesn't have a tile entity. So You can't just do that a few lines later without checking for null first. Ohhhh ! Thank you, that helped me a lot. Quote
Recommended Posts
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.