我在使用可在Minecraft中控制的实体时遇到问题。我能够安装它,它会移动,但是移动它几秒后,它就会跳回原来移动它之前的位置。这是我的实体类:
package net.minecraft.src;
public class mod_EntityMech extends EntityMob // this to make mob hostile
{
public boolean stationary;
public mod_EntityMech(World par1World)
{
super(par1World);
isImmuneToFire = false;
}
public int func_82193_c(Entity par1Entity) //the amount of damage
{
return 4;
}
protected void fall(float par1)
{}
public int getMaxHealth() // Mob health
{
return 1000;
}
protected int getDropItemId()
{
return 0;
}
protected boolean canDespawn()
{
return false;
}
public boolean interact(EntityPlayer entityplayer)
{
if (riddenByEntity == null || riddenByEntity == entityplayer)
{
entityplayer.mountEntity(this);
return true;
}
else
{
return false;
}
}
protected boolean isMovementCeased()
{
return stationary;
}
public void moveEntity(double d, double d1, double d2)
{
if (riddenByEntity != null)
{
this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw;
this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F;
this.setRotation(this.rotationYaw, this.rotationPitch);
this.rotationYawHead = this.renderYawOffset = this.rotationYaw;
stationary = true;
motionX += riddenByEntity.motionX * 10; // * 0.20000000000000001D;
motionZ += riddenByEntity.motionZ * 10; // * 0.20000000000000001D;
if (isCollidedHorizontally)
{
isJumping = true;
}
else
{
isJumping = false;
}
super.moveEntity(motionX, motionY, motionZ);
}
else
{
stationary = false;
super.moveEntity(d, d1, d2);
}
}
public void onUpdate()
{
super.onUpdate();
if (riddenByEntity != null) //check if there is a rider
{
//currentTarget = this;
this.randomYawVelocity = 0; //try not to let the horse control where to look.
this.rotationYaw = riddenByEntity.rotationYaw;
}
}
protected boolean isAIEnabled() //Allow your AI task to work?
{
return true;
}
}
P.S。我正在使用ModLoader
答案 0 :(得分:0)
您需要使用消息处理添加客户端 - 服务器同步。我建议使用本教程:http://www.minecraftforge.net/forum/index.php/topic,20138.0.html