Jump to content

[Solved?][1.12.2] Custom Falling Block Entity crashes for unknown reason.


Highlord_Will

Recommended Posts

Whenever the Entity is spawned my game crashes. The code is directly copy/pasted from Vanilla code. (Vanilla does not crash)
From my tests and observation it seems to be something Client/Server side with the blockstate (the fallTile variable is not set on the Client (or Server?))


Crash Report:

Spoiler

---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.

Time: 3/4/19 1:28 PM
Description: Ticking entity

java.lang.NullPointerException: Ticking entity
    at net.minecraft.entity.item.EntityFallingBlock.onUpdate(EntityFallingBlock.java:114)
    at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2171)
    at net.minecraft.world.World.updateEntity(World.java:2130)
    at net.minecraft.world.World.updateEntities(World.java:1931)
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1974)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1188)
    at net.minecraft.client.Minecraft.run(Minecraft.java:442)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)


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

-- Head --
Thread: Client thread
Stacktrace:
    at net.minecraft.entity.item.EntityFallingBlock.onUpdate(EntityFallingBlock.java:114)
    at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2171)
    at net.minecraft.world.World.updateEntity(World.java:2130)

-- Entity being ticked --
Details:
    Entity Type: minecraft:dungeontoolsfalling_push_block (com.theredmajora.dungeontools.extra.EntityFallingPushBlock)
    Entity ID: 13402
    Entity Name: entity.falling_push_block.name
    Entity's Exact location: 548.50, 63.01, -145.50
    Entity's Block location: World: (548,63,-146), Chunk: (at 4,3,14 in 34,-10; contains blocks 544,0,-160 to 559,255,-145), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,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.updateEntities(World.java:1931)

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityPlayerSP['Player183'/0, l='MpServer', x=547.91, y=63.00, z=-148.37]]
    Chunk stats: MultiplayerChunkCache: 529, 529
    Level seed: 0
    Level generator: ID 01 - flat, ver 0. Features enabled: false
    Level generator options: 
    Level spawn location: World: (544,4,-150), Chunk: (at 0,0,10 in 34,-10; contains blocks 544,0,-160 to 559,255,-145), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,255,-1)
    Level time: 292 game time, 292 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: 2 total; [EntityFallingPushBlock['entity.falling_push_block.name'/13402, l='MpServer', x=548.50, y=63.01, z=-145.50], EntityPlayerSP['Player183'/0, l='MpServer', x=547.91, y=63.00, z=-148.37]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:461)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2889)
    at net.minecraft.client.Minecraft.run(Minecraft.java:463)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)

-- 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: 641511480 bytes (611 MB) / 915931136 bytes (873 MB) up to 3790077952 bytes (3614 MB)
    JVM Flags: 0 total; 
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.5.2807 5 mods loaded, 5 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 |
    |:------ |:------------ |:------------ |:-------------------------------- |:--------- |
    | LCHIJA | minecraft    | 1.12.2       | minecraft.jar                    | None      |
    | LCHIJA | mcp          | 9.42         | minecraft.jar                    | None      |
    | LCHIJA | FML          | 8.0.99.99    | forgeSrc-1.12.2-14.23.5.2807.jar | None      |
    | LCHIJA | forge        | 14.23.5.2807 | forgeSrc-1.12.2-14.23.5.2807.jar | None      |
    | LCHIJA | dungeontools | 1.0          | bin                              | None      |

    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 419.17' Renderer: 'GeForce GTX 1070/PCIe/SSE2'
    Launched Version: 1.12.2
    LWJGL: 2.9.4
    OpenGL: GeForce GTX 1070/PCIe/SSE2 GL version 4.6.0 NVIDIA 419.17, NVIDIA Corporation
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    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)
    CPU: 8x Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz

---

Entity Class:

Spoiler

public class EntityFallingPushBlock extends EntityFallingBlock
{
	public EntityFallingPushBlock(World worldIn) {
		super(worldIn);
	}

	public EntityFallingPushBlock(World worldIn, double x, double y, double z, IBlockState state)
	{
		super(worldIn, x, y, z, state);
	}
}

Block Class:

Spoiler

public class BlockPush extends BlockDungeon implements ITileEntityProvider
{
	public BlockPush()
	{
		super(Material.ROCK, "push_block");
		this.setBlockUnbreakable();
	}

    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
    {
        worldIn.scheduleUpdate(pos, this, 2);
    }

    public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
    {
        worldIn.scheduleUpdate(pos, this, 2);
    }

    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
    {
        if (!worldIn.isRemote)
        {
            this.checkFallable(worldIn, pos);
        }
    }

    private void checkFallable(World worldIn, BlockPos pos)
    {
        if ((worldIn.isAirBlock(pos.down()) || canFallThrough(worldIn.getBlockState(pos.down()))) && pos.getY() >= 0)
        {
            if (worldIn.isAreaLoaded(pos.add(-32, -32, -32), pos.add(32, 32, 32)))
            {
                if (!worldIn.isRemote)
                {
                	EntityFallingPushBlock entityfallingblock = new EntityFallingPushBlock(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, worldIn.getBlockState(pos));
                    
                    worldIn.spawnEntity(entityfallingblock);
                }
            }
            else
            {
                IBlockState state = worldIn.getBlockState(pos);
                worldIn.setBlockToAir(pos);
                BlockPos blockpos;

                for (blockpos = pos.down(); (worldIn.isAirBlock(blockpos) || canFallThrough(worldIn.getBlockState(blockpos))) && blockpos.getY() > 0; blockpos = blockpos.down())
                {
                    ;
                }

                if (blockpos.getY() > 0)
                {
                    worldIn.setBlockState(blockpos.up(), state); //Forge: Fix loss of state information during world gen.
                }
            }
        }
    }

    public static boolean canFallThrough(IBlockState state)
    {
        Block block = state.getBlock();
        Material material = state.getMaterial();
        return block == Blocks.FIRE || material == Material.AIR || material == Material.WATER || material == Material.LAVA;
    }

    @SideOnly(Side.CLIENT)
    public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
    {
        if (rand.nextInt(16) == 0)
        {
            BlockPos blockpos = pos.down();

            if (canFallThrough(worldIn.getBlockState(blockpos)))
            {
                double d0 = (double)((float)pos.getX() + rand.nextFloat());
                double d1 = (double)pos.getY() - 0.05D;
                double d2 = (double)((float)pos.getZ() + rand.nextFloat());
                worldIn.spawnParticle(EnumParticleTypes.FALLING_DUST, d0, d1, d2, 0.0D, 0.0D, 0.0D, Block.getStateId(stateIn));
            }
        }
    }

    @SideOnly(Side.CLIENT)
    public int getDustColor(IBlockState state)
    {
        return -16777216;
    }

	@Override
	public TileEntity createNewTileEntity(World worldIn, int meta) {
		return new TileEntityPushBlock();
	}
}

Code in Client Proxy:

Spoiler

public void preInit()
	{ RenderingRegistry.registerEntityRenderingHandler(EntityFallingPushBlock.class, new RenderFallingPushBlockFactory()); }

public class RenderFallingPushBlockFactory implements IRenderFactory<EntityFallingBlock> {
		@Override
		public Render<? super EntityFallingBlock> createRenderFor(RenderManager manager) {
			{ return new RenderFallingBlock(manager); }
		}
	}

preInit() is called from the FMLPreInitializationEvent. Also, I don't have a CommonProxy, is that a problem?

Registry of Entity:

Spoiler

@SubscribeEvent
    	public static void registerEntities(RegistryEvent.Register<EntityEntry> event)
    	{
    		int ID = 0;
    		
    		EntityEntry[] entityList = { 
    				EntityEntryBuilder.create()
    			    .entity(EntityFallingPushBlock.class)
    			    .id(new ResourceLocation(DungeonTools.ID + "falling_push_block"), ID++)
    			    .name("falling_push_block")
    			    .tracker(160, 20, true)
    			    .build()
    			    
    		};
    		
    		for(EntityEntry entry : entityList)
    		{
    			event.getRegistry().register(entry);
    		}
    	}

I am aware of the fact that I don't need the "for" loop, but I will probably add more entities in the future so that's why.
 

I am really lost on what I'm doing wrong, help will be appreciated!

 

 

If the given code is not enough to pinpoint the error please have a look at the Github page: https://github.com/TheRedMajora/DungeonTools

Edited by Highlord_Will
Solved?
Link to comment
Share on other sites

Thanks for the reply!

 

1. Ahh, rookie mistake. I've changed it to ResourceLocation(modID, "entity_name") now.

2. Great.

3. I have not implemented my own features yet, but there are some features I plan on implementing into the falling block.

4. I tried using the hasTileEntity and createTileEntity methods (even checked with @Override and there were no errors), but that crashed my Minecraft.

5. Another rookie mistake. BlockDungeon is gone!

6. I was expecting it to be something like that. I've fixed it using a boolean to determine what type of "Push Block" the entity is. That seems to work well. (My custom entity can only be a push block anyway, I know it's not the best solution, but I had lots of trouble with networking in the past so yeah.)

Link to comment
Share on other sites

Crash:

Spoiler

---- Minecraft Crash Report ----
// Everything's going to plan. No, really, that was supposed to happen.

Time: 3/5/19 4:38 PM
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
    at com.theredmajora.dungeontools.blocks.BlockPush.onBlockActivated(BlockPush.java:97)
    at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:455)
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1694)
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2381)
    at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2147)
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1935)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1188)
    at net.minecraft.client.Minecraft.run(Minecraft.java:442)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)


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

-- Head --
Thread: Client thread
Stacktrace:
    at com.theredmajora.dungeontools.blocks.BlockPush.onBlockActivated(BlockPush.java:97)
    at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:455)
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1694)
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2381)
    at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2147)

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityPlayerSP['Player20'/0, l='MpServer', x=540.27, y=63.00, z=-136.82]]
    Chunk stats: MultiplayerChunkCache: 597, 597
    Level seed: 0
    Level generator: ID 01 - flat, ver 0. Features enabled: false
    Level generator options: 
    Level spawn location: World: (544,4,-150), Chunk: (at 0,0,10 in 34,-10; contains blocks 544,0,-160 to 559,255,-145), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,255,-1)
    Level time: 21204 game time, 129 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: 1 total; [EntityPlayerSP['Player20'/0, l='MpServer', x=540.27, y=63.00, z=-136.82]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:461)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2889)
    at net.minecraft.client.Minecraft.run(Minecraft.java:471)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)

-- 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: 538105368 bytes (513 MB) / 878706688 bytes (838 MB) up to 3790077952 bytes (3614 MB)
    JVM Flags: 0 total; 
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.5.2807 6 mods loaded, 6 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 |
    |:------ |:------------------- |:------------ |:------------------------------------------ |:--------- |
    | LCHIJA | minecraft           | 1.12.2       | minecraft.jar                              | None      |
    | LCHIJA | mcp                 | 9.42         | minecraft.jar                              | None      |
    | LCHIJA | FML                 | 8.0.99.99    | forgeSrc-1.12.2-14.23.5.2807.jar           | None      |
    | LCHIJA | forge               | 14.23.5.2807 | forgeSrc-1.12.2-14.23.5.2807.jar           | None      |
    | LCHIJA | dungeontools        | 1.0          | bin                                        | None      |
    | LCHIJA | itemtransformhelper | 1.12.2a      | itemtransformhelper-1-12-2a-1534166164.zip | None      |

    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 419.17' Renderer: 'GeForce GTX 1070/PCIe/SSE2'
    Launched Version: 1.12.2
    LWJGL: 2.9.4
    OpenGL: GeForce GTX 1070/PCIe/SSE2 GL version 4.6.0 NVIDIA 419.17, NVIDIA Corporation
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    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)
    CPU: 8x Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz

 

Code in Block Class:

@Override
public TileEntity createTileEntity(World world, IBlockState state)
{ return new TileEntityPushBlock(); }

@Override
public boolean hasTileEntity()
{ return true; }

And the line that returns the error:

((TileEntityPushBlock) world.getTileEntity(pos)).setActive(true);

 

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.