- 63
- 1
- 5
Привет.
У меня есть обычный EntityThrowable который практически без изменений, разве что убрана гравитация. И дело в том что на сервере и клиенте ЧЕРЕЗ эклипс с ее поворотом все нормально (летит прямо), а после компиляции на сервере она спавнится с поворотом в одну сторону и дальше ей приходится разворачиваться. Что не есть хорошо.
Ясно дело что СКОРЕЕ ВСЕГО будут придирки к коду с её направлением (который я не редачил), но мне интересно почему это происходит именно после компиляции.
Код если нужен:
У меня есть обычный EntityThrowable который практически без изменений, разве что убрана гравитация. И дело в том что на сервере и клиенте ЧЕРЕЗ эклипс с ее поворотом все нормально (летит прямо), а после компиляции на сервере она спавнится с поворотом в одну сторону и дальше ей приходится разворачиваться. Что не есть хорошо.
Ясно дело что СКОРЕЕ ВСЕГО будут придирки к коду с её направлением (который я не редачил), но мне интересно почему это происходит именно после компиляции.
Код если нужен:
EntityCustomArrow:
public class EntityCustomArrow extends EntityThrowable
{
private EntityPlayer shooter;
private int damage;
private int xTile = -1;
private int yTile = -1;
private int zTile = -1;
private int inTile = 0;
protected boolean inGround = false;
public int throwableShake = 0;
private String shooterName;
private int ticksInGround;
private int ticksInAir = 0;
public String hitSound;
public EntityCustomArrow(World world)
{
super(world);
}
public EntityCustomArrow(World world, EntityLiving el, int damage, String hitSound)
{
super(world, el);
this.shooter = (EntityPlayer)el;
this.damage = damage;
this.hitSound = hitSound;
this.shooter = (EntityPlayer) el;
this.setSize(0.25F, 0.25F);
this.setLocationAndAngles(el.posX, el.posY + (double)el.getEyeHeight(), el.posZ, el.rotationYaw, el.rotationPitch);
this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.posY -= 0.10000000149011612D;
this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
float f = 0.4F;
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.func_70183_g()) / 180.0F * (float)Math.PI) * f);
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, 2.0f, 0.0F);
}
public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8)
{
float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
par1 /= (double)f2;
par3 /= (double)f2;
par5 /= (double)f2;
par1 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
par3 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
par5 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
par1 *= (double)par7;
par3 *= (double)par7;
par5 *= (double)par7;
this.motionX = par1;
this.motionY = par3;
this.motionZ = par5;
float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f3) * 180.0D / Math.PI);
}
public void onUpdate()
{
this.lastTickPosX = this.posX;
this.lastTickPosY = this.posY;
this.lastTickPosZ = this.posZ;
super.onUpdate();
if (this.throwableShake > 0)
{
--this.throwableShake;
}
/*
if (this.inGround)
{
int i = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
if (i == this.inTile)
{
++this.ticksInGround;
if (this.ticksInGround == 1200)
{
this.setDead();
}
return;
}
this.inGround = false;
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
this.ticksInGround = 0;
this.ticksInAir = 0;
}
else
{*/
++this.ticksInAir;
if(this.ticksInAir == 1200) {
this.setDead();
}
Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31);
vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
if (!this.worldObj.isRemote)
{
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
EntityLiving entityliving = this.getThrower();
for (int j = 0; j < list.size(); ++j)
{
Entity entity1 = (Entity)list.get(j);
if (entity1.canBeCollidedWith() && (entity1 != entityliving || this.ticksInAir >= 5))
{
float f = 0.25F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.expand((double)f, (double)f, (double)f);
MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31);
if (movingobjectposition1 != null)
{
double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
}
}
if (movingobjectposition != null)
{
if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE && this.worldObj.getBlockId(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Block.portal.blockID)
{
this.setInPortal();
}
else
{
this.onImpact(movingobjectposition);
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f2 = 0.99F;
float f3 = this.getGravityVelocity();
if (this.isInWater())
{
for (int k = 0; k < 4; ++k)
{
float f4 = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
}
f2 = 0.8F;
}
this.motionX *= (double)f2;
this.motionY *= (double)f2;
this.motionZ *= (double)f2;
this.motionY -= (double)f3;
this.setPosition(this.posX, this.posY, this.posZ);
}
protected float getGravityVelocity()
{
return 0.00F;
}
@Override
protected void onImpact(MovingObjectPosition movingobjectposition)
{
if (movingobjectposition.entityHit instanceof EntityLiving)
{
DamageSource playerSource = DamageSource.causePlayerDamage(this.shooter);
movingobjectposition.entityHit.attackEntityFrom(playerSource, this.damage);
}
this.playSound(this.hitSound, 0.16f, 1.0f);
this.setDead();
}
}