Worked on car a bit
Noticed it has a flaw updating serverside
This commit is contained in:
parent
78fb37d51a
commit
603874d94c
1 changed files with 45 additions and 24 deletions
|
@ -112,7 +112,7 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
|
||||||
public void onUpdate()
|
public void onUpdate()
|
||||||
{
|
{
|
||||||
super.onUpdate();
|
super.onUpdate();
|
||||||
this.applyFriction();
|
|
||||||
if (this.worldObj.isRemote)
|
if (this.worldObj.isRemote)
|
||||||
{
|
{
|
||||||
this.worldObj.spawnParticle("mobSpell", this.posX, this.posY, this.posZ, 0, 0, 0);
|
this.worldObj.spawnParticle("mobSpell", this.posX, this.posY, this.posZ, 0, 0, 0);
|
||||||
|
@ -120,14 +120,17 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
|
||||||
|
|
||||||
if (this.worldObj.isRemote && (this.riddenByEntity == null || !(this.riddenByEntity instanceof EntityPlayer) || !FMLClientHandler.instance().getClient().thePlayer.equals(this.riddenByEntity)))
|
if (this.worldObj.isRemote && (this.riddenByEntity == null || !(this.riddenByEntity instanceof EntityPlayer) || !FMLClientHandler.instance().getClient().thePlayer.equals(this.riddenByEntity)))
|
||||||
{
|
{
|
||||||
double x, y, z;
|
double x;
|
||||||
|
double y;
|
||||||
|
double var12;
|
||||||
|
double z;
|
||||||
if (this.boatPosRotationIncrements > 0)
|
if (this.boatPosRotationIncrements > 0)
|
||||||
{
|
{
|
||||||
x = this.posX + (this.boatX - this.posX) / this.boatPosRotationIncrements;
|
x = this.posX + (this.boatX - this.posX) / this.boatPosRotationIncrements;
|
||||||
y = this.posY + (this.boatY - this.posY) / this.boatPosRotationIncrements;
|
y = this.posY + (this.boatY - this.posY) / this.boatPosRotationIncrements;
|
||||||
z = this.posZ + (this.boatZ - this.posZ) / this.boatPosRotationIncrements;
|
z = this.posZ + (this.boatZ - this.posZ) / this.boatPosRotationIncrements;
|
||||||
|
var12 = MathHelper.wrapAngleTo180_double(this.boatYaw - this.rotationYaw);
|
||||||
this.rotationYaw = (float) (this.rotationYaw + MathHelper.wrapAngleTo180_double(this.boatYaw - this.rotationYaw) / this.boatPosRotationIncrements);
|
this.rotationYaw = (float) (this.rotationYaw + var12 / this.boatPosRotationIncrements);
|
||||||
this.rotationPitch = (float) (this.rotationPitch + (this.boatPitch - this.rotationPitch) / this.boatPosRotationIncrements);
|
this.rotationPitch = (float) (this.rotationPitch + (this.boatPitch - this.rotationPitch) / this.boatPosRotationIncrements);
|
||||||
--this.boatPosRotationIncrements;
|
--this.boatPosRotationIncrements;
|
||||||
this.setPosition(x, y, z);
|
this.setPosition(x, y, z);
|
||||||
|
@ -156,10 +159,13 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.applyFriction();
|
||||||
|
if (this.speed > this.maxSpeed)
|
||||||
|
{
|
||||||
|
this.speed = this.maxSpeed;
|
||||||
|
}
|
||||||
if (this.isCollidedHorizontally)
|
if (this.isCollidedHorizontally)
|
||||||
{
|
{
|
||||||
this.speed *= 0.9;
|
|
||||||
this.motionY = 0.1D;
|
this.motionY = 0.1D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,25 +179,18 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
|
||||||
this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.speed > this.maxSpeed)
|
|
||||||
{
|
|
||||||
this.speed = this.maxSpeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.prevPosX = this.posX;
|
|
||||||
this.prevPosY = this.posY;
|
|
||||||
this.prevPosZ = this.posZ;
|
|
||||||
if (ticks % 5 == 0)
|
if (ticks % 5 == 0)
|
||||||
{
|
{
|
||||||
if (this.worldObj.isRemote && Minecraft.getMinecraft().thePlayer == this.riddenByEntity)
|
PacketManagerEntity.sendEntityUpdatePacket(this, this.worldObj.isRemote, "Desc", this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch, this.motionX, this.motionY, this.motionZ);
|
||||||
{
|
|
||||||
PacketManagerEntity.sendEntityUpdatePacket(this, true, "Desc", this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch, this.motionX, this.motionY, this.motionZ);
|
if (!this.worldObj.isRemote)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.updateClients();
|
this.updateClients();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.prevPosX = this.posX;
|
||||||
|
this.prevPosY = this.posY;
|
||||||
|
this.prevPosZ = this.posZ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,17 +200,39 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
|
||||||
@Override
|
@Override
|
||||||
public boolean simplePacket(String id, ByteArrayDataInput data, Player player)
|
public boolean simplePacket(String id, ByteArrayDataInput data, Player player)
|
||||||
{
|
{
|
||||||
if (id.equalsIgnoreCase("Desc") && player == this.riddenByEntity)
|
if (id.equalsIgnoreCase("Desc"))
|
||||||
{
|
{
|
||||||
this.setPositionAndRotation(data.readDouble(), data.readDouble(), data.readDouble(), data.readFloat(), data.readFloat());
|
this.setPositionRotationAndMotion(data.readDouble(), data.readDouble(), data.readDouble(), data.readFloat(), data.readFloat(), data.readDouble(), data.readDouble(), data.readDouble());
|
||||||
this.motionX = data.readDouble();
|
|
||||||
this.motionY = data.readDouble();
|
|
||||||
this.motionZ = data.readDouble();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPositionRotationAndMotion(double x, double y, double z, float yaw, float pitch, double motX, double motY, double motZ)
|
||||||
|
{
|
||||||
|
if (this.worldObj.isRemote)
|
||||||
|
{
|
||||||
|
this.boatX = x;
|
||||||
|
this.boatY = y;
|
||||||
|
this.boatZ = z;
|
||||||
|
this.boatYaw = yaw;
|
||||||
|
this.boatPitch = pitch;
|
||||||
|
this.motionX = motX;
|
||||||
|
this.motionY = motY;
|
||||||
|
this.motionZ = motZ;
|
||||||
|
this.boatPosRotationIncrements = 5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setPosition(x, y, z);
|
||||||
|
this.setRotation(yaw, pitch);
|
||||||
|
this.motionX = motX;
|
||||||
|
this.motionY = motY;
|
||||||
|
this.motionZ = motZ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void checkCollisions()
|
public void checkCollisions()
|
||||||
{
|
{
|
||||||
if (!this.worldObj.isRemote)
|
if (!this.worldObj.isRemote)
|
||||||
|
|
Loading…
Reference in a new issue