cleanup setClientPosition
This commit is contained in:
parent
431d54f779
commit
256721aa12
9 changed files with 246 additions and 282 deletions
|
@ -553,11 +553,11 @@ public class ClientPlayer implements IClientPlayer
|
|||
|
||||
if (Math.abs(entity.posX - d0) < 0.03125D && Math.abs(entity.posY - d1) < 0.015625D && Math.abs(entity.posZ - d2) < 0.03125D)
|
||||
{
|
||||
entity.setPositionAndRotation2(entity.posX, entity.posY, entity.posZ, f, f1, 3, true);
|
||||
entity.setClientPosition(entity.posX, entity.posY, entity.posZ, f, f1, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.setPositionAndRotation2(d0, d1, d2, f, f1, 3, true);
|
||||
entity.setClientPosition(d0, d1, d2, f, f1, true);
|
||||
}
|
||||
|
||||
entity.onGround = packetIn.getOnGround();
|
||||
|
@ -597,7 +597,7 @@ public class ClientPlayer implements IClientPlayer
|
|||
double d2 = (double)entity.serverPosZ / 32.0D;
|
||||
float f = packetIn.hasRotations() ? (float)(packetIn.getYaw() * 360) / 256.0F : entity.rotYaw;
|
||||
float f1 = packetIn.hasRotations() ? (float)(packetIn.getPitch() * 360) / 256.0F : entity.rotPitch;
|
||||
entity.setPositionAndRotation2(d0, d1, d2, f, f1, 3, false);
|
||||
entity.setClientPosition(d0, d1, d2, f, f1, false);
|
||||
entity.onGround = packetIn.getOnGround();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1875,7 +1875,7 @@ public abstract class Entity
|
|||
}
|
||||
}
|
||||
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
||||
public void setClientPosition(double x, double y, double z, float yaw, float pitch, boolean teleport)
|
||||
{
|
||||
this.setPosition(x, y, z);
|
||||
this.setRotation(yaw, pitch);
|
||||
|
|
|
@ -172,9 +172,9 @@ public class EntityBoat extends Entity
|
|||
return !this.dead;
|
||||
}
|
||||
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
||||
public void setClientPosition(double x, double y, double z, float yaw, float pitch, boolean teleport)
|
||||
{
|
||||
if (p_180426_10_ && this.passenger != null)
|
||||
if (teleport && this.passenger != null)
|
||||
{
|
||||
this.prevX = this.posX = x;
|
||||
this.prevY = this.posY = y;
|
||||
|
@ -191,7 +191,7 @@ public class EntityBoat extends Entity
|
|||
{
|
||||
if (this.isBoatEmpty)
|
||||
{
|
||||
this.boatPosRotationIncrements = posRotationIncrements + 5;
|
||||
this.boatPosRotationIncrements = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -896,14 +896,14 @@ public abstract class EntityCart extends Entity implements IWorldNameable
|
|||
}
|
||||
}
|
||||
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
||||
public void setClientPosition(double x, double y, double z, float yaw, float pitch, boolean teleport)
|
||||
{
|
||||
this.minecartX = x;
|
||||
this.minecartY = y;
|
||||
this.minecartZ = z;
|
||||
this.minecartYaw = (double)yaw;
|
||||
this.minecartPitch = (double)pitch;
|
||||
this.turnProgress = posRotationIncrements + 2;
|
||||
this.turnProgress = 5;
|
||||
this.motionX = this.velocityX;
|
||||
this.motionY = this.velocityY;
|
||||
this.motionZ = this.velocityZ;
|
||||
|
|
|
@ -2791,7 +2791,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
// START OTHER
|
||||
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
||||
public void setClientPosition(double x, double y, double z, float yaw, float pitch, boolean teleport)
|
||||
{
|
||||
if(this.slave && this.client == null) {
|
||||
this.otherPlayerMPX = x;
|
||||
|
@ -2799,10 +2799,10 @@ public abstract class EntityNPC extends EntityLiving
|
|||
this.otherPlayerMPZ = z;
|
||||
this.otherPlayerMPYaw = (double)yaw;
|
||||
this.otherPlayerMPPitch = (double)pitch;
|
||||
this.otherPlayerMPPosRotationIncrements = posRotationIncrements;
|
||||
this.otherPlayerMPPosRotationIncrements = 3;
|
||||
}
|
||||
else {
|
||||
super.setPositionAndRotation2(x, y, z, yaw, pitch, posRotationIncrements, p_180426_10_);
|
||||
super.setClientPosition(x, y, z, yaw, pitch, teleport);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
|
|||
this.ticksInGround = 0;
|
||||
}
|
||||
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
||||
public void setClientPosition(double x, double y, double z, float yaw, float pitch, boolean teleport)
|
||||
{
|
||||
this.setPosition(x, y, z);
|
||||
this.setRotation(yaw, pitch);
|
||||
|
|
|
@ -19,38 +19,33 @@ import common.vars.Vars;
|
|||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
||||
public class EntityBullet extends Entity implements IProjectile, IObjectData
|
||||
{
|
||||
public class EntityBullet extends Entity implements IProjectile, IObjectData {
|
||||
private Entity shooter;
|
||||
private int ticksMoved;
|
||||
private int age;
|
||||
private int damage = 5;
|
||||
|
||||
public EntityBullet(World world)
|
||||
{
|
||||
public EntityBullet(World world) {
|
||||
super(world);
|
||||
this.renderDistWeight = 10.0D;
|
||||
this.setSize(0.5F, 0.5F);
|
||||
}
|
||||
|
||||
public EntityBullet(World world, double x, double y, double z)
|
||||
{
|
||||
public EntityBullet(World world, double x, double y, double z) {
|
||||
super(world);
|
||||
this.renderDistWeight = 10.0D;
|
||||
this.setSize(0.5F, 0.5F);
|
||||
this.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
public EntityBullet(World world, double x, double y, double z, int data)
|
||||
{
|
||||
public EntityBullet(World world, double x, double y, double z, int data) {
|
||||
this(world, x, y, z);
|
||||
Entity entity = world.getEntityByID(data);
|
||||
if(entity instanceof EntityLiving)
|
||||
this.shooter = entity;
|
||||
}
|
||||
|
||||
public EntityBullet(World world, EntityLiving shooter, EntityLiving target, float velocity, float innacuracy)
|
||||
{
|
||||
public EntityBullet(World world, EntityLiving shooter, EntityLiving target, float velocity, float innacuracy) {
|
||||
super(world);
|
||||
this.renderDistWeight = 10.0D;
|
||||
this.shooter = shooter;
|
||||
|
@ -59,8 +54,7 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
|||
double yd = target.getEntityBoundingBox().minY + (double)(target.height * 0.7f) - this.posY;
|
||||
double zd = target.posZ - shooter.posZ;
|
||||
double xzd = (double)ExtMath.sqrtd(xd * xd + zd * zd);
|
||||
if (xzd >= 1.0E-7D)
|
||||
{
|
||||
if(xzd >= 1.0E-7D) {
|
||||
float yaw = (float)(ExtMath.atan2(zd, xd) * 180.0D / Math.PI) - 90.0F;
|
||||
float pitch = (float)(-(ExtMath.atan2(yd, xzd) * 180.0D / Math.PI));
|
||||
double x = xd / xzd;
|
||||
|
@ -70,8 +64,7 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
|||
}
|
||||
}
|
||||
|
||||
public EntityBullet(World world, EntityLiving shooter, float velocity)
|
||||
{
|
||||
public EntityBullet(World world, EntityLiving shooter, float velocity) {
|
||||
super(world);
|
||||
this.renderDistWeight = 10.0D;
|
||||
this.shooter = shooter;
|
||||
|
@ -87,12 +80,10 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
|||
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, velocity, 0.5F);
|
||||
}
|
||||
|
||||
protected void entityInit()
|
||||
{
|
||||
protected void entityInit() {
|
||||
}
|
||||
|
||||
public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy)
|
||||
{
|
||||
public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) {
|
||||
float sq = ExtMath.sqrtd(x * x + y * y + z * z);
|
||||
x = x / (double)sq;
|
||||
y = y / (double)sq;
|
||||
|
@ -111,19 +102,16 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
|||
this.prevPitch = this.rotPitch = (float)(ExtMath.atan2(y, (double)f1) * 180.0D / Math.PI);
|
||||
}
|
||||
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
||||
{
|
||||
public void setClientPosition(double x, double y, double z, float yaw, float pitch, boolean teleport) {
|
||||
this.setPosition(x, y, z);
|
||||
this.setRotation(yaw, pitch);
|
||||
}
|
||||
|
||||
public void setVelocity(double x, double y, double z)
|
||||
{
|
||||
public void setVelocity(double x, double y, double z) {
|
||||
this.motionX = x;
|
||||
this.motionY = y;
|
||||
this.motionZ = z;
|
||||
if (this.prevPitch == 0.0F && this.prevYaw == 0.0F)
|
||||
{
|
||||
if(this.prevPitch == 0.0F && this.prevYaw == 0.0F) {
|
||||
float xz = ExtMath.sqrtd(x * x + z * z);
|
||||
this.prevYaw = this.rotYaw = (float)(ExtMath.atan2(x, z) * 180.0D / Math.PI);
|
||||
this.prevPitch = this.rotPitch = (float)(ExtMath.atan2(y, (double)xz) * 180.0D / Math.PI);
|
||||
|
@ -133,12 +121,10 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
|||
}
|
||||
}
|
||||
|
||||
public void onUpdate()
|
||||
{
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if (this.prevPitch == 0.0F && this.prevYaw == 0.0F)
|
||||
{
|
||||
if(this.prevPitch == 0.0F && this.prevYaw == 0.0F) {
|
||||
float xz = ExtMath.sqrtd(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.prevYaw = this.rotYaw = (float)(ExtMath.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
this.prevPitch = this.rotPitch = (float)(ExtMath.atan2(this.motionY, (double)xz) * 180.0D / Math.PI);
|
||||
|
@ -155,31 +141,27 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
|||
current = new Vec3(this.posX, this.posY, this.posZ);
|
||||
next = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
|
||||
if (hit != null)
|
||||
{
|
||||
if(hit != null) {
|
||||
next = new Vec3(hit.vec.xCoord, hit.vec.yCoord, hit.vec.zCoord);
|
||||
}
|
||||
|
||||
Entity entity = null;
|
||||
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this,
|
||||
this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
double min = 0.0D;
|
||||
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
for(int i = 0; i < list.size(); ++i) {
|
||||
Entity ent = list.get(i);
|
||||
|
||||
if (ent.canBeCollidedWith() && (ent != this.shooter || this.ticksMoved >= 5))
|
||||
{
|
||||
if(ent.canBeCollidedWith() && (ent != this.shooter || this.ticksMoved >= 5)) {
|
||||
float expand = 0.3F;
|
||||
BoundingBox bb = ent.getEntityBoundingBox().expand((double)expand, (double)expand, (double)expand);
|
||||
HitPosition entityHit = bb.calculateIntercept(current, next);
|
||||
|
||||
if (entityHit != null)
|
||||
{
|
||||
if(entityHit != null) {
|
||||
double dist = current.squareDistanceTo(entityHit.vec);
|
||||
|
||||
if (dist < min || min == 0.0D)
|
||||
{
|
||||
if(dist < min || min == 0.0D) {
|
||||
entity = ent;
|
||||
min = dist;
|
||||
}
|
||||
|
@ -187,33 +169,26 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
|||
}
|
||||
}
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
if(entity != null) {
|
||||
hit = new HitPosition(entity);
|
||||
}
|
||||
|
||||
if (hit != null)
|
||||
{
|
||||
if (hit.entity != null)
|
||||
{
|
||||
if(hit != null) {
|
||||
if(hit.entity != null) {
|
||||
float velo = ExtMath.sqrtd(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
int damage = ExtMath.ceild((double)velo * (double)this.damage);
|
||||
|
||||
DamageSource source;
|
||||
|
||||
if (this.shooter == null)
|
||||
{
|
||||
if(this.shooter == null) {
|
||||
source = DamageSource.causeShotDamage(this, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
source = DamageSource.causeShotDamage(this, this.shooter);
|
||||
}
|
||||
|
||||
if ((this.worldObj.client || Vars.damageBullet) && hit.entity.attackEntityFrom(source, damage))
|
||||
{
|
||||
if (hit.entity instanceof EntityLiving living && this.shooter instanceof EntityLiving shooter)
|
||||
{
|
||||
if((this.worldObj.client || Vars.damageBullet) && hit.entity.attackEntityFrom(source, damage)) {
|
||||
if(hit.entity instanceof EntityLiving living && this.shooter instanceof EntityLiving shooter) {
|
||||
EnchantmentHelper.applyThornEnchantments(living, shooter);
|
||||
EnchantmentHelper.applyArthropodEnchantments(shooter, living);
|
||||
}
|
||||
|
@ -221,8 +196,7 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
|||
}
|
||||
this.setDead();
|
||||
}
|
||||
else if(!this.worldObj.client)
|
||||
{
|
||||
else if(!this.worldObj.client) {
|
||||
State state = hit.block != null ? this.worldObj.getState(hit.block) : null;
|
||||
if(state == null || state.getBlock().onShot(this.worldObj, hit.block, state, this)) {
|
||||
this.playSound(SoundEvent.METALHIT, 0.5F);
|
||||
|
@ -237,23 +211,20 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
|||
float xzMotion = ExtMath.sqrtd(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotYaw = (float)(ExtMath.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
|
||||
for (this.rotPitch = (float)(ExtMath.atan2(this.motionY, (double)xzMotion) * 180.0D / Math.PI); this.rotPitch - this.prevPitch < -180.0F; this.prevPitch -= 360.0F)
|
||||
{
|
||||
for(this.rotPitch = (float)(ExtMath.atan2(this.motionY, (double)xzMotion) * 180.0D / Math.PI); this.rotPitch
|
||||
- this.prevPitch < -180.0F; this.prevPitch -= 360.0F) {
|
||||
;
|
||||
}
|
||||
|
||||
while (this.rotPitch - this.prevPitch >= 180.0F)
|
||||
{
|
||||
while(this.rotPitch - this.prevPitch >= 180.0F) {
|
||||
this.prevPitch += 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotYaw - this.prevYaw < -180.0F)
|
||||
{
|
||||
while(this.rotYaw - this.prevYaw < -180.0F) {
|
||||
this.prevYaw -= 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotYaw - this.prevYaw >= 180.0F)
|
||||
{
|
||||
while(this.rotYaw - this.prevYaw >= 180.0F) {
|
||||
this.prevYaw += 360.0F;
|
||||
}
|
||||
|
||||
|
@ -262,40 +233,33 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
|||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
}
|
||||
|
||||
public void writeEntity(TagObject tag)
|
||||
{
|
||||
public void writeEntity(TagObject tag) {
|
||||
tag.setInt("damage", this.damage);
|
||||
tag.setInt("age", this.age);
|
||||
}
|
||||
|
||||
public void readEntity(TagObject tag)
|
||||
{
|
||||
public void readEntity(TagObject tag) {
|
||||
this.damage = tag.getInt("damage");
|
||||
this.age = tag.getInt("age");
|
||||
}
|
||||
|
||||
protected boolean canTriggerWalking()
|
||||
{
|
||||
protected boolean canTriggerWalking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setDamage(int damage)
|
||||
{
|
||||
public void setDamage(int damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public int getDamage()
|
||||
{
|
||||
public int getDamage() {
|
||||
return this.damage;
|
||||
}
|
||||
|
||||
public boolean canAttackWithItem()
|
||||
{
|
||||
public boolean canAttackWithItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getEyeHeight()
|
||||
{
|
||||
public float getEyeHeight() {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,14 +164,14 @@ public class EntityHook extends Entity implements IObjectData
|
|||
this.ticksInGround = 0;
|
||||
}
|
||||
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
||||
public void setClientPosition(double x, double y, double z, float yaw, float pitch, boolean teleport)
|
||||
{
|
||||
this.fishX = x;
|
||||
this.fishY = y;
|
||||
this.fishZ = z;
|
||||
this.fishYaw = (double)yaw;
|
||||
this.fishPitch = (double)pitch;
|
||||
this.fishPosRotationIncrements = posRotationIncrements;
|
||||
this.fishPosRotationIncrements = 3;
|
||||
this.motionX = this.clientMotionX;
|
||||
this.motionY = this.clientMotionY;
|
||||
this.motionZ = this.clientMotionZ;
|
||||
|
|
|
@ -2135,14 +2135,14 @@ public abstract class EntityLiving extends Entity
|
|||
this.fallDistance = 0.0F;
|
||||
}
|
||||
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
||||
public void setClientPosition(double x, double y, double z, float yaw, float pitch, boolean teleport)
|
||||
{
|
||||
this.newX = x;
|
||||
this.newY = y;
|
||||
this.newZ = z;
|
||||
this.newYaw = (double)yaw;
|
||||
this.newPitch = (double)pitch;
|
||||
this.moveIncrements = posRotationIncrements;
|
||||
this.moveIncrements = 3;
|
||||
}
|
||||
|
||||
public void setJumping(boolean jumping)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue