Jump to content

[1.7.10] Having issues with getting the closest player.


thatsimplekid

Recommended Posts

Hey everyone,

I'm trying to code an openblocks-esque elevator block that shoots the player up or down to another "platform" when they jump or sneak. My code is as follows:

 

 

public void updateEntity() {

        if(this.worldObj != null && !this.worldObj.isRemote) {

            EntityPlayer player = this.worldObj.getClosestPlayer(xCoord, yCoord, zCoord, -1);

            if (player != null) {

                if (player.posY == yCoord + 1 && player.posX == xCoord && player.posZ == zCoord) {

                    if (!player.onGround) {

                        for (int i = 1; i < 10; i++) {

                            if (worldObj.getBlock(xCoord, yCoord + i, zCoord).getUnlocalizedName() == RSBlocks.blockDebugLift.getUnlocalizedName()) {

                                player.setPosition(xCoord, yCoord + i + 1, zCoord);

                            }

                        }

                    } else if (player.isSneaking()) {

                        for (int i = 1; i < 10; i++) {

                            if (worldObj.getBlock(xCoord, yCoord - i, zCoord).getUnlocalizedName() == RSBlocks.blockDebugLift.getUnlocalizedName()) {

                                player.setPosition(xCoord, yCoord - i + 1, zCoord);

                            }

                        }

                    }

                }

            }

        }

    }

 

 

my game crashes everytime I attempt to load the world and my crash report is as follows:

 

 

---- Minecraft Crash Report ----

// I blame Dinnerbone.

 

Time: 01/03/16 11:10

Description: Ticking block entity

 

java.lang.NullPointerException: Ticking block entity

at com.thatsimplekid.rocketscience.blocks.tileentities.TileEntityLift.updateEntity(TileEntityLift.java:11)

at net.minecraft.world.World.updateEntities(World.java:2160)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2087)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1029)

at net.minecraft.client.Minecraft.run(Minecraft.java:951)

at net.minecraft.client.main.Main.main(Main.java:164)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at com.thatsimplekid.rocketscience.blocks.tileentities.TileEntityLift.updateEntity(TileEntityLift.java:11)

 

-- Block entity being ticked --

Details:

Name: ent.blockLift // com.thatsimplekid.rocketscience.blocks.tileentities.TileEntityLift

Block type: ID #184 (tile.rs-3.blockLift // com.thatsimplekid.rocketscience.blocks.BlockLift)

Block data value: 0 / 0x0 / 0b0000

Block location: World: (3,237,7), Chunk: (at 3,14,7 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

Actual block type: ID #184 (tile.rs-3.blockLift // com.thatsimplekid.rocketscience.blocks.BlockLift)

Actual block data value: 0 / 0x0 / 0b0000

Stacktrace:

at net.minecraft.world.World.updateEntities(World.java:2160)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['Player828'/39, l='MpServer', x=4.54, y=239.62, z=8.43]]

Chunk stats: MultiplayerChunkCache: 625, 625

Level seed: 0

Level generator: ID 01 - flat, ver 0. Features enabled: false

Level generator options:

Level spawn location: World: (0,4,0), Chunk: (at 0,0,0 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

Level time: 74146 game time, 74146 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 5 total; [EntityCreeper['Creeper'/23, l='MpServer', x=-24.72, y=237.00, z=18.23], EntityCreeper['Creeper'/22, l='MpServer', x=-58.66, y=237.00, z=74.97], EntityItem['item.item.rottenFlesh'/25, l='MpServer', x=47.19, y=237.13, z=71.97], EntitySkeleton['Skeleton'/24, l='MpServer', x=12.75, y=237.00, z=58.84], EntityClientPlayerMP['Player828'/39, l='MpServer', x=4.54, y=239.62, z=8.43]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2556)

at net.minecraft.client.Minecraft.run(Minecraft.java:972)

at net.minecraft.client.main.Main.main(Main.java:164)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

 

-- System Details --

Details:

Minecraft Version: 1.7.10

Operating System: Windows 8.1 (amd64) version 6.3

Java Version: 1.7.0_79, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 586807880 bytes (559 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.05 FML v7.10.85.1291 Minecraft Forge 10.13.2.1291 7 mods loaded, 7 mods active

mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{7.10.85.1291} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{10.13.2.1291} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

CodeChickenCore{1.0.4.29} [CodeChicken Core] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

NotEnoughItems{1.0.3.74} [Not Enough Items] (NotEnoughItems-1.7.10-1.0.3.74-universal.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

rs-3{1.0.2} [RocketScience-3] (rs3) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Waila{1.5.4a} [Waila] (Waila-1.5.4a_1.7.10.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Launched Version: 1.7.10

LWJGL: 2.9.1

OpenGL: GeForce GT 640/PCIe/SSE2 GL version 4.5.0 NVIDIA 353.62, NVIDIA Corporation

GL Caps: Using GL 1.3 multitexturing.

Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.

Anisotropic filtering is supported and maximum anisotropy is 16.

Shaders are available because OpenGL 2.1 is supported.

 

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Packs: []

Current Language: English (US)

Profiler Position: N/A (disabled)

Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Anisotropic Filtering: Off (1)

 

 

 

i get the crash at line 11, which is "EntityPlayer player = this.worldObj.getClosestPlayer(xCoord, yCoord, zCoord, -1);"

 

any help is greatly appreciated!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.