Topic category: Help with Minecraft modding (Java Edition)
when the entity spawns, it logs its coordinates in its synced data. Then when it turns night time, the entity walks back to the coordinates where it spawned. Once the entity gets close enough (like within a block), then the entity teleports to the origin block. Since i want the entity to stand in the middle of the block, and synced data doesnt allow decimal numbers, i use local variables to offset the X and Z coordinates by 0.5
(before offsetting the coords, the entity would teleport to the corner of the block because the coordinates were whole numbers)
at first it worked perfectly, but then after that day it stopped working the same. Sometimes it works ok but most of the time the entity gets teleported one block off (sometimes even one block to the side and one block forward/back)
The red block is where the origin is. I think my code should work perfectly ok but idk why its not. If anyone knows why and can help itll be very appreciated