I am having some issues with the server updating the client as to its position.
My full project can be view here: https://github.com/allout58/SpaceCraft
Here is the code file for the entity in question:
EntityRocket.java
package allout58.mods.SpaceCraft.Rockets.Entity;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import allout58.mods.SpaceCraft.Rockets.Rocket;
public class EntityRocket extends Entity
{
Rocket rocketLogic;
public EntityRocket(World world)
{
super(world);
// this.preventEntitySpawning = true;
}
public EntityRocket(World par1World, Rocket rLogic, double x, double y, double z)
{
this(par1World);
this.setPosition(x, y, z);
rocketLogic = rLogic;
rocketLogic.Launch();
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
rocketLogic = new Rocket();
rocketLogic.readFromNBT(nbttagcompound);
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
rocketLogic.writeToNBT(nbttagcompound);
}
@Override
public void onUpdate()
{
super.onUpdate();
if (ticksExisted > 500) this.kill();
if (rocketLogic == null) return;
if (!worldObj.isRemote)
{
rocketLogic.tick();
this.motionX = rocketLogic.velX;
this.motionY = rocketLogic.velY;
this.motionZ = rocketLogic.velZ;
}
setPosition(posX + motionX, posY + motionY, posZ + motionZ);
if (worldObj.isRemote)
{
Random rand = new Random();
for (int i = 0; i < (rocketLogic.Size.ordinal() + 1) * (2 - Minecraft.getMinecraft().gameSettings.particleSetting); i++)
{
worldObj.spawnParticle("flame", this.posX + rand.nextDouble() * (rand.nextBoolean() ? -1 : 1), this.posY - rand.nextDouble(), this.posZ + rand.nextDouble() * (rand.nextBoolean() ? -1 : 1), rand.nextInt(35) / 100 * (rand.nextBoolean() ? -1 : 1), -rand.nextDouble(), rand.nextInt(35) / 100 * (rand.nextBoolean() ? -1 : 1));
}
}
System.out.println("Rocket entity-" + (worldObj.isRemote ? "Client" : "Server") + " x:" + posX + " y:" + posY + " z:" + posZ);
}
@Override
protected void entityInit()
{
}
}
FYI, the class Rocket updates "velY" on "tick()". See the github for the full file.
Here is some of the output:
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Server x:-594.5 y:246.40848585690674 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Client x:-594.5 y:231.5 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Server x:-594.5 y:246.40848585690674 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Client x:-594.5 y:231.5 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Server x:-594.5 y:246.40848585690674 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Client x:-594.5 y:231.5 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Server x:-594.5 y:246.40848585690674 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Client x:-594.5 y:231.5 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Server x:-594.5 y:246.40848585690674 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Client x:-594.5 y:231.5 z:-165.5
Thanks for any help you can give!