Jump to content

Recommended Posts

Posted

Hi,

 

I've got a huge problem. I'm currently checking some stuff with blocks and this code just crashes because it relies on

stuff like EnumFacing.UP, but it seems to be that not all blocks have this stuff which resulted into a crash of the test server.

Well, for some reason it never happened, but after copying a structure with world edit (forge edition) and rotating it and placing

it, it crashed.

 

Example crash:

java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} as it does not exist in BlockStateContainer{block=primevalforest:stone, properties=[stone]}

 

So how can I still check each direction if the side is solid without getting this crash and without having to add for each mod block which does not support this a check?

 

The code which causes the problem:

state.getBlock().isSideSolid(worldIn.getBlockState(pos.down()), worldIn, pos.down(), EnumFacing.UP)

 

Thx in advance.

Bektor

Developer of Primeval Forest.

Posted

Example code cannot cause the example crash.

You also don't need to do

state.getBlock()

: the IBlockState interface supplies an accessor

isSideSolid()

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Example code cannot cause the example crash.

You also don't need to do

state.getBlock()

: the IBlockState interface supplies an accessor

isSideSolid()

Well, even if it is impossible, it just happened.

 

The crash log is showing me that this line and the line from above are causing the crash:

worldIn, pos, state, EnumFacing.NORTH

 

(for anyone who does not want to scroll, the line from above:)

state.getBlock().isSideSolid(worldIn.getBlockState(pos.down()), worldIn, pos.down(), EnumFacing.UP)

 

Also shows me this line:

if(!state.getBlock().isSideSolid(otherState, worldIn, pos, facing))

 

And here the full crash:

 

java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} as it does not exist in BlockStateContainer{block=primevalforest:stone, properties=[stone]}
at net.minecraft.block.state.BlockStateContainer$StateImplementation.func_177229_b(BlockStateContainer.java:196)
at net.minecraft.block.BlockStairs.func_185706_d(BlockStairs.java:338)
at net.minecraft.block.BlockStairs.func_176221_a(BlockStairs.java:333)
at net.minecraft.block.Block.isSideSolid(Block.java:1009)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.isHorizontalSupport(BlockCollapse.java:198)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.getBlocksToScan(BlockCollapse.java:164)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:144)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.func_180650_b(BlockCollapse.java:50)
at net.minecraft.world.WorldServer.func_72955_a(WorldServer.java:743)
at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:218)
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:698)
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:387)
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:613)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:471)
at java.lang.Thread.run(Unknown Source)

 

 

 

java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} as it does not exist in BlockStateContainer{block=minecraft:air, properties=[]}
at net.minecraft.block.state.BlockStateContainer$StateImplementation.func_177229_b(BlockStateContainer.java:196)
at net.minecraft.block.BlockStairs.func_185706_d(BlockStairs.java:338)
at net.minecraft.block.BlockStairs.func_176221_a(BlockStairs.java:333)
at net.minecraft.block.Block.isSideSolid(Block.java:1009)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:140)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.func_180650_b(BlockCollapse.java:50)
at net.minecraft.world.WorldServer.func_72955_a(WorldServer.java:743)
at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:218)
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:698)
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:387)
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:613)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:471)
at java.lang.Thread.run(Unknown Source)

 

 

I've got no idea why this is happening, just that it never happenend in a test world, only on the test server which has world edit (forge edition) installed to copy&paste stuff and easily build structures with max. speed.

 

EDIT:

Crashed again while doing a copy&paste with rotation with world edit:

 

java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} as it does not exist in BlockStateContainer{block=minecraft:air, properties=[]}
at net.minecraft.block.state.BlockStateContainer$StateImplementation.func_177229_b(BlockStateContainer.java:196)
at net.minecraft.block.BlockStairs.func_185706_d(BlockStairs.java:338)
at net.minecraft.block.BlockStairs.func_176221_a(BlockStairs.java:333)
at net.minecraft.block.Block.isSideSolid(Block.java:1009)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:140)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.func_180650_b(BlockCollapse.java:50)
at net.minecraft.world.WorldServer.func_72955_a(WorldServer.java:743)
at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:218)
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:698)
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:387)
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:613)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:471)
at java.lang.Thread.run(Unknown Source)


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

-- Head --
Thread: Server thread
Stacktrace:
at net.minecraft.block.state.BlockStateContainer$StateImplementation.func_177229_b(BlockStateContainer.java:196)
at net.minecraft.block.BlockStairs.func_185706_d(BlockStairs.java:338)
at net.minecraft.block.BlockStairs.func_176221_a(BlockStairs.java:333)
at net.minecraft.block.Block.isSideSolid(Block.java:1009)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:140)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.func_180650_b(BlockCollapse.java:50)

-- Block being ticked --
Details:
Block: primevalforest:stone[stone=andesite]
Block location: World: (373,1,-876), Chunk: (at 5,0,4 in 23,-55; contains blocks 368,0,-880 to 383,255,-865), Region: (0,-2; contains chunks 0,-64 to 31,-33, blocks 0,0,-1024 to 511,255,-513)
Stacktrace:
at net.minecraft.world.WorldServer.func_72955_a(WorldServer.java:743)
at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:218)

 

 

So what's wrong??

Developer of Primeval Forest.

Posted

Oh, I see what's going on.

Did you create some custom stairs?

 

The important thing is here:

at net.minecraft.block.BlockStairs.func_185706_d(BlockStairs.java:338)

 

That method is called getStairsShape (in my version of Forge) and when passed a blockstate it attempts to figure out what direction the stairs are facing.

 

Somehow you are passing the BlockStairs class a block that is not stairs.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Oh, I see what's going on.

Did you create some custom stairs?

 

The important thing is here:

at net.minecraft.block.BlockStairs.func_185706_d(BlockStairs.java:338)

 

That method is called getStairsShape (in my version of Forge) and when passed a blockstate it attempts to figure out what direction the stairs are facing.

 

Somehow you are passing the BlockStairs class a block that is not stairs.

Hm... weird... I have no custom stairs in my mod.

Developer of Primeval Forest.

Posted

That was a guess, but if not you're going to have to trace the stack yourself to figure out why BlockStairs are being passed a non-stair block yourself.  There is no way vanilla code would enter that method if it wasn't stairs, so its got to be something you are doing.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Hm... it seems to be a problem with this:

 

I'm not sure why this is happening, cause my code has nothing to do with stairs... It just get's the block, blockpos and blockstate and does some sideSolid checks.

Developer of Primeval Forest.

Posted

That was a guess, but if not you're going to have to trace the stack yourself to figure out why BlockStairs are being passed a non-stair block yourself.

 

Debugging tools.  Use 'em.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

That was a guess, but if not you're going to have to trace the stack yourself to figure out why BlockStairs are being passed a non-stair block yourself.

 

Debugging tools.  Use 'em.

A bit hard to use debug tools on a server.

Developer of Primeval Forest.

Posted

Are you, or are you not, running in a development environment?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You're pretty much on your own there.

If you can't get it to happen in dev, then I can't help you.  My guess is that worldedit is fucking something up.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You're pretty much on your own there.

If you can't get it to happen in dev, then I can't help you.  My guess is that worldedit is fucking something up.

Well, your guess is wrong. Happens also with vanilla clone command:

 

 

java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} as it does not exist in BlockStateContainer{block=minecraft:air, properties=[]}
at net.minecraft.block.state.BlockStateContainer$StateImplementation.func_177229_b(BlockStateContainer.java:196)
at net.minecraft.block.BlockStairs.func_185706_d(BlockStairs.java:338)
at net.minecraft.block.BlockStairs.func_176221_a(BlockStairs.java:333)
at net.minecraft.block.Block.isSideSolid(Block.java:1009)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:140)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.func_180650_b(BlockCollapse.java:50)
at net.minecraft.world.WorldServer.func_72955_a(WorldServer.java:743)
at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:218)
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:698)
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:387)
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:613)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:471)
at java.lang.Thread.run(Unknown Source)


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

-- Head --
Thread: Server thread
Stacktrace:
at net.minecraft.block.state.BlockStateContainer$StateImplementation.func_177229_b(BlockStateContainer.java:196)
at net.minecraft.block.BlockStairs.func_185706_d(BlockStairs.java:338)
at net.minecraft.block.BlockStairs.func_176221_a(BlockStairs.java:333)
at net.minecraft.block.Block.isSideSolid(Block.java:1009)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:140)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.func_180650_b(BlockCollapse.java:50)

-- Block being ticked --
Details:
Block: primevalforest:stone_brick[stone=andesite]
Block location: World: (631,17,-790), Chunk: (at 7,1,10 in 39,-50; contains blocks 624,0,-800 to 639,255,-785), Region: (1,-2; contains chunks 32,-64 to 63,-33, blocks 512,0,-1024 to 1023,255,-513)
Stacktrace:
at net.minecraft.world.WorldServer.func_72955_a(WorldServer.java:743)
at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:218)

 

 

I just don't know why. My code has nothing to do with air and stairs.

Developer of Primeval Forest.

Posted

I don't know.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

That's a weird crash, since my code has nothing to do with stairs or air.

 

EDIT: harder then I thought to get it into debug mode.... just ticks every second so the breakpoint on the error will get called 5 times a second.... for each block.

 

EDIT 2: How to debug this??? Got it now running fine in dev environment... Only problem while debugging is that all values are closed in the moment where it crashes....

Developer of Primeval Forest.

Posted

Hm... after running in debug... Showed the value 123 as block id, clicked next breakpoint, crash.

 

Breakpoint was on line 140, so

if(state.getBlock().isSideSolid(worldIn.getBlockState(pos.down()), worldIn, pos.down(), EnumFacing.UP)) {

 

Console output:

 

 

[19:34:51] [server thread/ERROR]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Exception while ticking a block
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:778) ~[MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_102]
Caused by: java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} as it does not exist in BlockStateContainer{block=minecraft:air, properties=[]}
at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:196) ~[blockStateContainer$StateImplementation.class:?]
at net.minecraft.block.BlockStairs.getStairsShape(BlockStairs.java:470) ~[blockStairs.class:?]
at net.minecraft.block.BlockStairs.getActualState(BlockStairs.java:465) ~[blockStairs.class:?]
at net.minecraft.block.Block.isSideSolid(Block.java:1224) ~[block.class:?]
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:140) ~[blockCollapse.class:?]
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59) ~[blockCollapse.class:?]
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.updateTick(BlockCollapse.java:50) ~[blockCollapse.class:?]
at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:775) ~[WorldServer.class:?]
at net.minecraft.world.WorldServer.tick(WorldServer.java:226) ~[WorldServer.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:772) ~[MinecraftServer.class:?]
... 4 more
[19:34:51] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: ---- Minecraft Crash Report ----
// I bet Cylons wouldn't have this problem.

Time: 07.10.16 19:34
Description: Exception while ticking a block

java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} as it does not exist in BlockStateContainer{block=minecraft:air, properties=[]}
at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:196)
at net.minecraft.block.BlockStairs.getStairsShape(BlockStairs.java:470)
at net.minecraft.block.BlockStairs.getActualState(BlockStairs.java:465)
at net.minecraft.block.Block.isSideSolid(Block.java:1224)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:140)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.updateTick(BlockCollapse.java:50)
at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:775)
at net.minecraft.world.WorldServer.tick(WorldServer.java:226)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:772)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Unknown Source)


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

-- Head --
Thread: Client thread
Stacktrace:
at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:196)
at net.minecraft.block.BlockStairs.getStairsShape(BlockStairs.java:470)
at net.minecraft.block.BlockStairs.getActualState(BlockStairs.java:465)
at net.minecraft.block.Block.isSideSolid(Block.java:1224)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:140)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.updateTick(BlockCollapse.java:50)

-- Block being ticked --
Details:
Block: primevalforest:stone_brick[stone=andesite]
Block location: World: (510,6,-676), Chunk: (at 14,0,12 in 31,-43; contains blocks 496,0,-688 to 511,255,-673), Region: (0,-2; contains chunks 0,-64 to 31,-33, blocks 0,0,-1024 to 511,255,-513)
Stacktrace:
at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:775)
at net.minecraft.world.WorldServer.tick(WorldServer.java:226)

-- Affected level --
Details:
Level name: world
All players: 0 total; []
Chunk stats: ServerChunkCache: 625 Drop: 0
Level seed: -519059703706857826
Level generator: ID 01 - flat, ver 0. Features enabled: true
Level generator options: 
Level spawn location: World: (501,4,-681), Chunk: (at 5,0,7 in 31,-43; contains blocks 496,0,-688 to 511,255,-673), Region: (0,-2; contains chunks 0,-64 to 31,-33, blocks 0,0,-1024 to 511,255,-513)
Level time: 2350925 game time, 10898 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.updateTimeLightAndEntities(MinecraftServer.java:772)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Unknown Source)

 

 

Crash Report:

 

---- Minecraft Crash Report ----
// Sorry 

Time: 07.10.16 19:34
Description: Exception while ticking a block

java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} as it does not exist in BlockStateContainer{block=minecraft:air, properties=[]}
at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:196)
at net.minecraft.block.BlockStairs.getStairsShape(BlockStairs.java:470)
at net.minecraft.block.BlockStairs.getActualState(BlockStairs.java:465)
at net.minecraft.block.Block.isSideSolid(Block.java:1224)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:140)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.updateTick(BlockCollapse.java:50)
at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:775)
at net.minecraft.world.WorldServer.tick(WorldServer.java:226)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:772)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Unknown Source)


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

-- Head --
Thread: Server thread
Stacktrace:
at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:196)
at net.minecraft.block.BlockStairs.getStairsShape(BlockStairs.java:470)
at net.minecraft.block.BlockStairs.getActualState(BlockStairs.java:465)
at net.minecraft.block.Block.isSideSolid(Block.java:1224)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.hasSupport(BlockCollapse.java:140)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.doCollapse(BlockCollapse.java:59)
at minecraftplaye.primevalforest.common.blocks.core.BlockCollapse.updateTick(BlockCollapse.java:50)

-- Block being ticked --
Details:
Block: primevalforest:stone_brick[stone=andesite]
Block location: World: (510,6,-676), Chunk: (at 14,0,12 in 31,-43; contains blocks 496,0,-688 to 511,255,-673), Region: (0,-2; contains chunks 0,-64 to 31,-33, blocks 0,0,-1024 to 511,255,-513)
Stacktrace:
at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:775)
at net.minecraft.world.WorldServer.tick(WorldServer.java:226)

-- Affected level --
Details:
Level name: world
All players: 0 total; []
Chunk stats: ServerChunkCache: 625 Drop: 0
Level seed: -519059703706857826
Level generator: ID 01 - flat, ver 0. Features enabled: true
Level generator options: 
Level spawn location: World: (501,4,-681), Chunk: (at 5,0,7 in 31,-43; contains blocks 496,0,-688 to 511,255,-673), Region: (0,-2; contains chunks 0,-64 to 31,-33, blocks 0,0,-1024 to 511,255,-513)
Level time: 2350925 game time, 10898 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.updateTimeLightAndEntities(MinecraftServer.java:772)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Unknown Source)

 

 

The structure which was copied was made out of my stone, my stonebricks, vanilla lava, vanilla stonebricks, vanilla stairs, vanilla fences, much more vanilla stuff I don't recognize and a complete redstone circuit.

 

I hope this helps.

Developer of Primeval Forest.

Posted

BlockID isn't useful information.

You need to look at the blockstate object, that will tell you the block's registry name.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Block ID 123 is an inactive redstone lamp, do you have that in your world or do you reference that anywhere?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

It looks like some blocks are in the process of being replaced, so one block's (stairs') method is being called while another block's (air's) state is at that position. Apparently, some stairs were replaced by air (or air is about to be replaced by stairs that aren't really there yet), and the air can't answer the demand for direction information.

 

It's time to reveal a lot more of your mod's code so we can see where you might be using stale data. Let's see the entirety of class BlockCollapse.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

It looks like some blocks are in the process of being replaced, so one block's (stairs') method is being called while another block's (air's) state is at that position. Apparently, some stairs were replaced by air (or air is about to be replaced by stairs that aren't really there yet), and the air can't answer the demand for direction information.

 

It's time to reveal a lot more of your mod's code so we can see where you might be using stale data. Let's see the entirety of class BlockCollapse.

 

Ok.

 

    @Override
    public boolean hasSupport(World worldIn, BlockPos pos, IBlockState state) {
        if(worldIn.getBlockState(pos.down()).getBlock().isBlockSolid(worldIn, pos.down(), EnumFacing.UP))
            return true;
        
        LinkedList<BlockPos> toScan = new LinkedList<BlockPos>();
        BlockPosList scanned = new BlockPosList();
        scanned.add(pos);
        
        if((toScan.isEmpty() || toScan.peek() == null) && !state.getBlock().isAir(state, worldIn, pos))
            getBlocksToScan(toScan, scanned, worldIn, pos, state);
        
        boolean isSupported = false;
        long supportRangeSq = (long) Math.pow(this.getSupportRange(state), 2);
        
        BlockPos scanPos, posi = new BlockPos(pos.getX() + .5d, 0, pos.getZ() + .5d);
        IBlockState scanState;
        
        while(toScan.peek() != null) {
            scanPos = (BlockPos) toScan.poll();
            scanState = worldIn.getBlockState(scanPos);
            scanned.add(scanPos);
            
            if(pos.subtract(scanPos).getY() > this.getDepth()) {
                isSupported = true;
                break;
            }
            
            if(posi.distanceSq(
                    new BlockPos(scanPos.getX() + .5d, 0, scanPos.getZ() + .5d)) > supportRangeSq)
                continue;
            
            if(this.canBeSupported(state, scanState) && !state.getBlock().isAir(scanState, worldIn, scanPos)) {
                if(scanState.getBlock().isSideSolid(worldIn.getBlockState(scanPos.down()), worldIn, scanPos.down(), EnumFacing.UP)) {
                    if(!scanned.contains(scanPos.down()))
                        toScan.add(scanPos.down());
                } else
                    this.getBlocksToScan(toScan, scanned, worldIn, scanPos, scanState);
            }
        }
        
        return isSupported;
    }
    
    private void getBlocksToScan(LinkedList<BlockPos> toScan, BlockPosList scanned, World worldIn, BlockPos pos, IBlockState state) {
    	if(state.getBlock().isAir(state, worldIn, pos))
    		return;
    	
        if(this.isHorizontalSupport(worldIn, pos, state, EnumFacing.NORTH) && !scanned.contains(pos.north()))
            toScan.add(pos.north());
        if(this.isHorizontalSupport(worldIn, pos, state, EnumFacing.SOUTH) && !scanned.contains(pos.south()))
            toScan.add(pos.south());
        if(this.isHorizontalSupport(worldIn, pos, state, EnumFacing.EAST) && !scanned.contains(pos.east()))
            toScan.add(pos.east());
        if(this.isHorizontalSupport(worldIn, pos, state, EnumFacing.WEST) && !scanned.contains(pos.west()))
            toScan.add(pos.west());
    }
    
    protected boolean canBeSupported(IBlockState state, IBlockState otherState) {
        if(otherState.getBlock() instanceof BlockCollapse || otherState.getBlock() == Blocks.BEDROCK)
            return true;
        
        return false;
    }

    @Override
    public boolean isHorizontalSupport(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing facing) {
        BlockPos otherPos = pos.offset(facing); // go 1 in the negative direction from the facing
        IBlockState otherState = worldIn.getBlockState(otherPos);
        
        if(otherState.getBlock().isAir(otherState, worldIn, otherPos) 
                || !otherState.getBlock().isSideSolid(otherState, worldIn, otherPos, facing.getOpposite()))
            return false;

        if(!state.getBlock().isSideSolid(otherState, worldIn, pos, facing))
            return false;
        
        return true;
    }

 

 

I think I have to explain some stuff about this code. ^^ It's also not the full code cause I don't want to get too much code in here which has really nothing to do with the problem. And just to mention, some methods which might be called in the code above are classes from an interface and are not implemented in this abstract class, because this class is just the ground work from which all other block's extends.

 

The

onBlockAdded

method and the

neighborChanged

just tell Minecraft to schedule an Update, so that I don't get stuff like flying sand which happens sometimes in Minecraft.

The

updateTick

checks for block support with the hasSupport method from above. Before doing so it calls this line:

state = state.getBlock().getActualState(state, worldIn, pos);

The data from the

updateTick

method and the

state

data from the code above go to the

hasSupport

method.

 

Then the

hasSupport

method starts a recursive scan. How many blocks are scanned depends on the location and the block which has asked for a scan, so that different materials can have different abilities (like harder rock does not fall as fast as softer rock).

The hole thing is basically a physics calculation for block support physics.

What to do with the boolean which is returned by

hasSupport 

depens all on the block. It's the block's decision what to do with it. Some blocks get replaced by air, other might spawn a normal falling entity.

 

That's all what it does.

Besides the problem, if you know a way to get it more performant, let me know. (Also trying to get it done that 10k blocks can't fall at the same time which causes the netty thread to crash and for some reason my router seems to stop working when the Netty thread crashes on the local hosted server :P )

Developer of Primeval Forest.

Posted

I think you need to step through a few cycles of recursion to see where blocks are changing before a stale state variable is used to get a block that may no longer be where it used to be.

 

BTW, could you point out where the recursive call is? I'm just not seeing it (I must need a nap).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

I think you need to step through a few cycles of recursion to see where blocks are changing before a stale state variable is used to get a block that may no longer be where it used to be.

 

BTW, could you point out where the recursive call is? I'm just not seeing it (I must need a nap).

The method

hasSupport

get's called in the

updateTick

method like explained above. But the interesting stuff about the problem is, it happens only when copying blocks with the MC or world edit command. When placing them normal in creative or survival everything works fine.

 

Besides, what's a stale state and how can I step through the recursive method in a way I can see when a block is getted which doesn't exist anymore or isn't there yet?

Developer of Primeval Forest.

Posted

I think you need to step through a few cycles of recursion to see where blocks are changing before a stale state variable is used to get a block that may no longer be where it used to be.

 

BTW, could you point out where the recursive call is? I'm just not seeing it (I must need a nap).

 

The method

hasSupport

get's called in the

updateTick

method like explained above.

I got that before. What I can't see is the recursion that you said existed. Recursion can be tricky, so I wanted to trace it. Where do any of your methods call in a circle?

 

But the interesting stuff about the problem is, it happens only when copying blocks with the MC or world edit command. When placing them normal in creative or survival everything works fine.

 

That's because multiple blocks are changing. Something in your code was written with an assumption that is no longer true as soon as you have more than one block changing. In particular, the appearance of stairs somewhere disagrees with a get blockstate for some position. The stairs block has its method called, but by the time that method gets blockstate from the world, the blockstate is air that doesn't have the properties expected by the stairs.

 

Something you can try: Wherever you fetch the blockstate of a pos and thin k you know what kind of block it is, first check the block in the state to verify your assumption. If/when you encounter an "exception", either handle it gracefully or else print a warning. You might even call a debugging  method so you can stop execution for hands-on analysis of how you got there.

 

Besides, what's a stale state and how can I step through the recursive method in a way I can see when a block is getted which doesn't exist anymore or isn't there yet?

 

By stale state I meant stale data. That's a variable that's holding a value that no longer matches what's in the world. It's easy for variables to become invalid when blocks are being replaced. In fact, there was at least one such bug inside vanilla Minecraft 1.8 (but it never crashed simply because no vanilla block did anything more than air did).

 

By "step through recursion" I mean that you should set a breakpoint within the recursive calling cycle (typically at the test that breaks out of the cycle, thus starting the unwinding of the call stack). Since I still can't see where the recursive call is (a method calling itself or another method in its own stack), I can't tell you where that is. BTW, Since recursion can be devilishly tricky (e.g. modifying static data becomes a no-no), I recommend commenting recursion thoroughly.

 

As you step through the unwinding of the recursive call stack, pay attention to the use of any variables whose values were set before the recursive call. Are those values still valid? Is any method using a static variable whose value may have changed (but was assumed to be unchanged)? Do any other face-palms jump out at you?

 

Writing re-entrant code requires some extra discipline, but this forum isn't really for teaching Java or how to do such general programming technique. If what I've written is still unclear, then do some outside research on recursion and its pitfalls. Also become completely comfortable with the debugger as a frequent and handy tool to use at the drop of a hat. Whenever you encounter a runtime problem, you should ask yourself, "How can I investigate further in the debugger?" -- And then do so.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

By stale state I meant stale data. That's a variable that's holding a value that no longer matches what's in the world. It's easy for variables to become invalid when blocks are being replaced. In fact, there was at least one such bug inside vanilla Minecraft 1.8 (but it never crashed simply because no vanilla block did anything more than air did).

 

By "step through recursion" I mean that you should set a breakpoint within the recursive calling cycle (typically at the test that breaks out of the cycle, thus starting the unwinding of the call stack). Since I still can't see where the recursive call is (a method calling itself or another method in its own stack), I can't tell you where that is. BTW, Since recursion can be devilishly tricky (e.g. modifying static data becomes a no-no), I recommend commenting recursion thoroughly.

 

As you step through the unwinding of the recursive call stack, pay attention to the use of any variables whose values were set before the recursive call. Are those values still valid? Is any method using a static variable whose value may have changed (but was assumed to be unchanged)? Do any other face-palms jump out at you?

Ah, ok. Now I understand what you mean. ;) With the debugger, I'm working on it. :) I even think I'm using test cases more frequently outside of Minecraft, cause I'm not always sure how to use them with Minecraft (JUnit Test (have to look more deeply into it, assertions and all of that stuff).

 

Oh and after looking more deeply into the code, it's not real recursion, seems I wrote it that way because I first wrote it that way. :P

But I still think it follows a bit the ways of what recursion does.

 

That's because multiple blocks are changing. Something in your code was written with an assumption that is no longer true as soon as you have more than one block changing. In particular, the appearance of stairs somewhere disagrees with a get blockstate for some position. The stairs block has its method called, but by the time that method gets blockstate from the world, the blockstate is air that doesn't have the properties expected by the stairs.

Well, I think the problem is there not really that the code wasn't written for more than block changing, it's more that the complete stuff got so complex at the end, that I missed somewhere something.. Just where.

Can't imagine what could go so wrong with just checking all neighbour blocks (which get stored in the list) for side solid and getting there block state and block pos to do so.

 

Something you can try: Wherever you fetch the blockstate of a pos and thin k you know what kind of block it is, first check the block in the state to verify your assumption. If/when you encounter an "exception", either handle it gracefully or else print a warning. You might even call a debugging  method so you can stop execution for hands-on analysis of how you got there.

How can I verify my assumption? And I don't think it's that easy to get an idea of what block it is, cause it's a huge structure.

What do you mean by debugging method? Never heard of such a thing in school or while I thaught myself Java, a few years ago with some books.

Maybe I've heard of it in German, cause I learned all of it in German cause my english wasn't the best back then and know we learn it in German in school... even less English than in my books....

 

I think I'm just printing all block-states and load the world which results direclty in a crash. I think that should give me the block pos and block state of the block causing the crash..

 

The result:

BlockPos{x=510, y=6, z=-677}

primevalforest:stone[stone=andesite]

BlockPos{x=511, y=6, z=-676}

primevalforest:stone_brick[stone=andesite]

BlockPos{x=509, y=6, z=-676}

primevalforest:stone_brick[stone=andesite]

BlockPos{x=510, y=5, z=-677}

minecraft:stonebrick[variant=stonebrick]

BlockPos{x=511, y=5, z=-676}

minecraft:stone_brick_stairs[facing=east,half=top,shape=straight]

 

EDIT: all block states on the position seem to be correct. But I'm not quite sure if the stair is correct, because of the

half=top, shape=straigt and facing=east

stuff:

 

EDIT 2: Interesting, to check for the coords I broke the structure a bit apart while disabled the hasSupport check. Enabled it, no crash in the world... Placed a few of my blocks... no crash... broke one of my blocks, a few of my blocks fall down and crash because of BlockStairs.

 

EDIT  3: I really start wondering what line of code can break that stuff so much appart...

Developer of Primeval Forest.

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

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