The Meaning of Life, the Universe, and Everything.
Join Date:
7/2/2014
Posts:
43
Member Details
Hello.
I'm creating a mod. In my mod I have custom falling entity (I created it, because vanilla EntityFallingBlock drops wrong item for my NBT-based block and has wrong texture, because I use custom render for block, that spawns this entity).
And now all works fine: entity drops right item and has right texture. But I have strange problem with moving of entity. This problem occurs only on client-side, when there's any block above entity. On server side it moves properly. But on client my falling entity I have that situation:
- I spawn my falling entity (for example, at 35.5, 6.5, 54.5) by breaking my falling block.
- First two ticks entity moves properly (falls to 35.5, 6.38, 54.5, for example).
- But next 3-4 ticks it is on top of the block, that was above it! (35.5, 8.0, 54.5);
- And finally it moves roughly to the same coordinates, where entity is on server-side.
How to fix that problem? How to sync moving of falling enitites on server and client sides?
I suspect you are spawning the entity on the client, and then the server syncs the client to the server, hence you see the block move back to where it was.
I suspect you are spawning the entity on the client, and then the server syncs the client to the server, hence you see the block move back to where it was.
The Meaning of Life, the Universe, and Everything.
Join Date:
7/2/2014
Posts:
43
Member Details
I think, that it is problem in registration of entity. Because all code of entity class (except reading data from TileEntity, saving data to TileEntity, getting drops and some preparations for rendering) I got from vanilla EntityFallingBlock. And I many times checked, that my entity spawns on server-side only (and method Block#updateTick always calls from WorldServer).
Now I think, that it can be bug in... (OMG!) Forge. Because I and my IntelliJ IDEA can't find any problems in that code.
Hello.
I'm creating a mod. In my mod I have custom falling entity (I created it, because vanilla EntityFallingBlock drops wrong item for my NBT-based block and has wrong texture, because I use custom render for block, that spawns this entity).
And now all works fine: entity drops right item and has right texture. But I have strange problem with moving of entity. This problem occurs only on client-side, when there's any block above entity. On server side it moves properly. But on client my falling entity I have that situation:
- I spawn my falling entity (for example, at 35.5, 6.5, 54.5) by breaking my falling block.
- First two ticks entity moves properly (falls to 35.5, 6.38, 54.5, for example).
- But next 3-4 ticks it is on top of the block, that was above it! (35.5, 8.0, 54.5);
- And finally it moves roughly to the same coordinates, where entity is on server-side.
How to fix that problem? How to sync moving of falling enitites on server and client sides?
P. S. Sorry for my English. I'm from Russia.
Can someone help me?!
Show some code.
Only spawn entities on the server!
I suspect you are spawning the entity on the client, and then the server syncs the client to the server, hence you see the block move back to where it was.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
1) Entity class: https://github.com/OneEyePro/TechnoMotion/blob/master/src/main/java/oneeyepro/technomotion/entities/geology/ores/OreGravelFallingEntity.java
2) Entity registration: https://github.com/OneEyePro/TechnoMotion/blob/master/src/main/java/oneeyepro/technomotion/entities/TechnoMotionEntities.java
3) Entity spawn: https://github.com/OneEyePro/TechnoMotion/blob/master/src/main/java/oneeyepro/technomotion/blocks/geology/ores/OreGravelBlock.java#L214
Wow, a bit complicated. I took a look, some stuff I'm too tired to understand right now. I don't think it is the problem I thought it might be
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
I think, that it is problem in registration of entity. Because all code of entity class (except reading data from TileEntity, saving data to TileEntity, getting drops and some preparations for rendering) I got from vanilla EntityFallingBlock. And I many times checked, that my entity spawns on server-side only (and method Block#updateTick always calls from WorldServer).
Now I think, that it can be bug in... (OMG!) Forge. Because I and my IntelliJ IDEA can't find any problems in that code.
Please, see code! And reread first message.
1) I don't use this method on server-side.
2) I haven't problems on server-side - on server-side entity moves properly.
3) I added this method only for some render tweaks (that I'll add in future).
If there are no arguments in the case, please, do not reply to this thread.
Replace all of this:
TechnoMotionEntities.OreGravelFallingEntityID = EntityRegistry.findGlobalUniqueEntityId();
EntityRegistry.registerGlobalEntityID(OreGravelFallingEntity.class, OresNames.OreGravelFallingEntityName,
TechnoMotionEntities.OreGravelFallingEntityID);
EntityRegistry.registerModEntity(OreGravelFallingEntity.class, OresNames.OreGravelFallingEntityName,
TechnoMotionEntities.OreGravelFallingEntityID, TechnoMotion.INSTANCE, 64, 1, false);
By
EntityRegistry.registerModEntity(OreGravelFallingEntity.class, OresNames.OreGravelFallingEntityName, TechnoMotionEntities.EntityIDs++, TechnoMotion.INSTANCE, 160, 20, true);
Great thanks!!! It helps!