Armbot can now be pitched with ROTATE

This commit is contained in:
briman0094 2013-01-20 18:05:03 -06:00
parent 9a1aa77adf
commit feaf8d61c7
6 changed files with 264 additions and 203 deletions

View file

@ -8,174 +8,167 @@ import org.lwjgl.opengl.GL11;
public class ModelArmbot extends ModelBase
{
// fields
ModelRenderer baseTop;
ModelRenderer base;
ModelRenderer armMountRight;
ModelRenderer armMountLeft;
ModelRenderer armLower;
ModelRenderer armLower2;
ModelRenderer armLower3;
ModelRenderer armUpper;
ModelRenderer baseRotation;
ModelRenderer clampBody;
ModelRenderer clampBody2;
ModelRenderer clampClawLower;
ModelRenderer clampClawLower2;
ModelRenderer clampClawLower3;
// fields
ModelRenderer baseTop;
ModelRenderer base;
ModelRenderer armMountRight;
ModelRenderer armMountLeft;
ModelRenderer armLower;
ModelRenderer armLower2;
ModelRenderer armLower3;
ModelRenderer armUpper;
ModelRenderer baseRotation;
ModelRenderer clampBody;
ModelRenderer clampBody2;
ModelRenderer clampClawLower;
ModelRenderer clampClawLower2;
ModelRenderer clampClawLower3;
public ModelArmbot()
{
textureWidth = 128;
textureHeight = 128;
public ModelArmbot()
{
textureWidth = 128;
textureHeight = 128;
baseTop = new ModelRenderer(this, 0, 94);
baseTop.addBox(-6F, 0F, -6F, 12, 3, 12);
baseTop.setRotationPoint(0F, 18F, 0F);
baseTop.setTextureSize(64, 32);
baseTop.mirror = true;
setRotation(baseTop, 0F, 0F, 0F);
base = new ModelRenderer(this, 0, 109);
base.addBox(-8F, 0F, -8F, 16, 3, 16);
base.setRotationPoint(0F, 21F, 0F);
base.setTextureSize(64, 32);
base.mirror = true;
setRotation(base, 0F, 0F, 0F);
armMountRight = new ModelRenderer(this, 24, 85);
armMountRight.addBox(-3.8F, -5F, -2F, 4, 5, 4);
armMountRight.setRotationPoint(0F, 17F, 0F);
armMountRight.setTextureSize(128, 128);
armMountRight.mirror = true;
setRotation(armMountRight, 0F, 0F, 0F);
armMountLeft = new ModelRenderer(this, 0, 85);
armMountLeft.addBox(2F, -5F, -2F, 2, 5, 4);
armMountLeft.setRotationPoint(0F, 17F, 0F);
armMountLeft.setTextureSize(64, 32);
armMountLeft.mirror = true;
setRotation(armMountLeft, 0F, 0F, 0F);
armLower = new ModelRenderer(this, 116, 0);
armLower.addBox(0.3F, -15F, -1.5F, 2, 16, 4);
armLower.setRotationPoint(0F, 14F, 0F);
armLower.setTextureSize(64, 32);
armLower.mirror = true;
setRotation(armLower, 0.5235988F, 0F, 0F);
armLower2 = new ModelRenderer(this, 104, 0);
armLower2.addBox(-2.3F, -15F, -1.5F, 2, 16, 4);
armLower2.setRotationPoint(0F, 14F, 0F);
armLower2.setTextureSize(64, 32);
armLower2.mirror = true;
setRotation(armLower2, 0.5235988F, 0F, 0F);
armLower3 = new ModelRenderer(this, 92, 0);
armLower3.addBox(-1F, -14F, -2F, 2, 14, 4);
armLower3.setRotationPoint(0F, 14F, 0F);
armLower3.setTextureSize(64, 32);
armLower3.mirror = true;
setRotation(armLower3, 0.5235988F, 0F, 0F);
armUpper = new ModelRenderer(this, 0, 70);
armUpper.addBox(-1F, -10F, -1.5F, 2, 12, 3);
armUpper.setRotationPoint(0F, 2F, -7F);
armUpper.setTextureSize(64, 32);
armUpper.mirror = true;
setRotation(armUpper, 2.513274F, 0F, 0F);
baseRotation = new ModelRenderer(this, 0, 60);
baseRotation.addBox(-4.5F, 0F, -4.5F, 9, 1, 9);
baseRotation.setRotationPoint(0F, 17F, 0F);
baseRotation.setTextureSize(64, 32);
baseRotation.mirror = true;
setRotation(baseRotation, 0F, 0F, 0F);
clampBody = new ModelRenderer(this, 0, 7);
clampBody.addBox(-1.5F, -12F, -2.5F, 3, 2, 5);
clampBody.setRotationPoint(0F, 2F, -7F);
clampBody.setTextureSize(64, 32);
clampBody.mirror = true;
setRotation(clampBody, 2.513274F, 0F, 0F);
clampBody2 = new ModelRenderer(this, 0, 56);
clampBody2.addBox(-1F, -14F, -1F, 2, 2, 2);
clampBody2.setRotationPoint(0F, 2F, -7F);
clampBody2.setTextureSize(64, 32);
clampBody2.mirror = true;
setRotation(clampBody2, 2.513274F, 0F, 0F);
clampClawLower = new ModelRenderer(this, 0, 25);
clampClawLower.addBox(-1F, -4F, -1F, 2, 5, 1);
clampClawLower.setRotationPoint(0F, 13F, -15F);
clampClawLower.setTextureSize(64, 32);
clampClawLower.mirror = true;
setRotation(clampClawLower, 2.9147F, 0F, 0F);
clampClawLower2 = new ModelRenderer(this, 0, 31);
clampClawLower2.addBox(-1.2F, -3.5F, 0F, 1, 6, 1);
clampClawLower2.setRotationPoint(0F, 14F, -16F);
clampClawLower2.setTextureSize(64, 32);
clampClawLower2.mirror = true;
setRotation(clampClawLower2, 2.897247F, 0F, 0F);
clampClawLower3 = new ModelRenderer(this, 0, 0);
clampClawLower3.addBox(0.2F, -3.5F, 0F, 1, 6, 1);
clampClawLower3.setRotationPoint(0F, 14F, -16F);
clampClawLower3.setTextureSize(64, 32);
clampClawLower3.mirror = true;
setRotation(clampClawLower3, 2.897247F, 0F, 0F);
}
baseTop = new ModelRenderer(this, 0, 94);
baseTop.addBox(-6F, 0F, -6F, 12, 3, 12);
baseTop.setRotationPoint(0F, 18F, 0F);
baseTop.setTextureSize(64, 32);
baseTop.mirror = true;
setRotation(baseTop, 0F, 0F, 0F);
base = new ModelRenderer(this, 0, 109);
base.addBox(-8F, 0F, -8F, 16, 3, 16);
base.setRotationPoint(0F, 21F, 0F);
base.setTextureSize(64, 32);
base.mirror = true;
setRotation(base, 0F, 0F, 0F);
armMountRight = new ModelRenderer(this, 24, 85);
armMountRight.addBox(-3.8F, -5F, -2F, 4, 5, 4);
armMountRight.setRotationPoint(0F, 17F, 0F);
armMountRight.setTextureSize(128, 128);
armMountRight.mirror = true;
setRotation(armMountRight, 0F, 0F, 0F);
armMountLeft = new ModelRenderer(this, 0, 85);
armMountLeft.addBox(2F, -5F, -2F, 2, 5, 4);
armMountLeft.setRotationPoint(0F, 17F, 0F);
armMountLeft.setTextureSize(64, 32);
armMountLeft.mirror = true;
setRotation(armMountLeft, 0F, 0F, 0F);
armLower = new ModelRenderer(this, 116, 0);
armLower.addBox(0.3F, -15F, -1.5F, 2, 16, 4);
armLower.setRotationPoint(0F, 14F, 0F);
armLower.setTextureSize(64, 32);
armLower.mirror = true;
setRotation(armLower, 0.5235988F, 0F, 0F);
armLower2 = new ModelRenderer(this, 104, 0);
armLower2.addBox(-2.3F, -15F, -1.5F, 2, 16, 4);
armLower2.setRotationPoint(0F, 14F, 0F);
armLower2.setTextureSize(64, 32);
armLower2.mirror = true;
setRotation(armLower2, 0.5235988F, 0F, 0F);
armLower3 = new ModelRenderer(this, 92, 0);
armLower3.addBox(-1F, -14F, -2F, 2, 14, 4);
armLower3.setRotationPoint(0F, 14F, 0F);
armLower3.setTextureSize(64, 32);
armLower3.mirror = true;
setRotation(armLower3, 0.5235988F, 0F, 0F);
armUpper = new ModelRenderer(this, 0, 70);
armUpper.addBox(-1F, -10F, -1.5F, 2, 12, 3);
armUpper.setRotationPoint(0F, 2F, -7F);
armUpper.setTextureSize(64, 32);
armUpper.mirror = true;
setRotation(armUpper, 2.513274F, 0F, 0F);
baseRotation = new ModelRenderer(this, 0, 60);
baseRotation.addBox(-4.5F, 0F, -4.5F, 9, 1, 9);
baseRotation.setRotationPoint(0F, 17F, 0F);
baseRotation.setTextureSize(64, 32);
baseRotation.mirror = true;
setRotation(baseRotation, 0F, 0F, 0F);
clampBody = new ModelRenderer(this, 0, 7);
clampBody.addBox(-1.5F, -12F, -2.5F, 3, 2, 5);
clampBody.setRotationPoint(0F, 2F, -7F);
clampBody.setTextureSize(64, 32);
clampBody.mirror = true;
setRotation(clampBody, 2.513274F, 0F, 0F);
clampBody2 = new ModelRenderer(this, 0, 56);
clampBody2.addBox(-1F, -14F, -1F, 2, 2, 2);
clampBody2.setRotationPoint(0F, 2F, -7F);
clampBody2.setTextureSize(64, 32);
clampBody2.mirror = true;
setRotation(clampBody2, 2.513274F, 0F, 0F);
clampClawLower = new ModelRenderer(this, 0, 25);
clampClawLower.addBox(-1F, -4F, -1F, 2, 5, 1);
clampClawLower.setRotationPoint(0F, 13F, -15F);
clampClawLower.setTextureSize(64, 32);
clampClawLower.mirror = true;
setRotation(clampClawLower, 2.9147F, 0F, 0F);
clampClawLower2 = new ModelRenderer(this, 0, 31);
clampClawLower2.addBox(-1.2F, -3.5F, 0F, 1, 6, 1);
clampClawLower2.setRotationPoint(0F, 14F, -16F);
clampClawLower2.setTextureSize(64, 32);
clampClawLower2.mirror = true;
setRotation(clampClawLower2, 2.897247F, 0F, 0F);
clampClawLower3 = new ModelRenderer(this, 0, 0);
clampClawLower3.addBox(0.2F, -3.5F, 0F, 1, 6, 1);
clampClawLower3.setRotationPoint(0F, 14F, -16F);
clampClawLower3.setTextureSize(64, 32);
clampClawLower3.mirror = true;
setRotation(clampClawLower3, 2.897247F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.render(f5, entity.rotationYaw, entity.rotationPitch);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.render(f5, entity.rotationYaw, entity.rotationPitch);
}
public void render(float f5, float rotationYaw, float rotationPitch)
{
public void render(float f5, float rotationYaw, float rotationPitch)
{
/*
* armMountRight.setRotationPoint(baseRotation.rotationPointX,
* armMountRight.rotationPointY, baseRotation.rotationPointX);
* armMountLeft.setRotationPoint(baseRotation.rotationPointX,
* armMountLeft.rotationPointY, baseRotation.rotationPointX);
* armLower.setRotationPoint(baseRotation.rotationPointX,
* armLower.rotationPointY, baseRotation.rotationPointX);
* armUpper.setRotationPoint(baseRotation.rotationPointX,
* armUpper.rotationPointY, baseRotation.rotationPointX);
* baseRotation.setRotationPoint(baseRotation.rotationPointX,
* baseRotation.rotationPointY, baseRotation.rotationPointX);
* clampBody.setRotationPoint(baseRotation.rotationPointX,
* clampBody.rotationPointY, baseRotation.rotationPointX);
* clampBody2.setRotationPoint(baseRotation.rotationPointX,
* clampBody2.rotationPointY, baseRotation.rotationPointX);
* clampClawLower.setRotationPoint(baseRotation.rotationPointX,
* clampClawLower.rotationPointY, baseRotation.rotationPointX);
* clampClawLower2.setRotationPoint(baseRotation.rotationPointX,
* clampClawLower2.rotationPointY, baseRotation.rotationPointX);
*
* armMountRight.rotateAngleY = armBot.rotationYaw;
* armMountLeft.rotateAngleY = armBot.rotationYaw; armLower.rotateAngleY
* = armBot.rotationYaw; armUpper.rotateAngleY = armBot.rotationYaw;
* baseRotation.rotateAngleY = armBot.rotationYaw;
* clampBody.rotateAngleY = armBot.rotationYaw; clampBody2.rotateAngleY
* = armBot.rotationYaw; clampClawLower.rotateAngleY =
* armBot.rotationYaw; clampClawLower2.rotateAngleY =
* armBot.rotationYaw;
*/
/*
* armMountRight.setRotationPoint(baseRotation.rotationPointX, armMountRight.rotationPointY, baseRotation.rotationPointX); armMountLeft.setRotationPoint(baseRotation.rotationPointX, armMountLeft.rotationPointY, baseRotation.rotationPointX); armLower.setRotationPoint(baseRotation.rotationPointX, armLower.rotationPointY, baseRotation.rotationPointX); armUpper.setRotationPoint(baseRotation.rotationPointX, armUpper.rotationPointY, baseRotation.rotationPointX); baseRotation.setRotationPoint(baseRotation.rotationPointX, baseRotation.rotationPointY, baseRotation.rotationPointX); clampBody.setRotationPoint(baseRotation.rotationPointX, clampBody.rotationPointY, baseRotation.rotationPointX); clampBody2.setRotationPoint(baseRotation.rotationPointX, clampBody2.rotationPointY, baseRotation.rotationPointX); clampClawLower.setRotationPoint(baseRotation.rotationPointX, clampClawLower.rotationPointY, baseRotation.rotationPointX); clampClawLower2.setRotationPoint(baseRotation.rotationPointX, clampClawLower2.rotationPointY, baseRotation.rotationPointX);
*
* armMountRight.rotateAngleY = armBot.rotationYaw; armMountLeft.rotateAngleY = armBot.rotationYaw; armLower.rotateAngleY = armBot.rotationYaw; armUpper.rotateAngleY = armBot.rotationYaw; baseRotation.rotateAngleY = armBot.rotationYaw; clampBody.rotateAngleY = armBot.rotationYaw; clampBody2.rotateAngleY = armBot.rotationYaw; clampClawLower.rotateAngleY = armBot.rotationYaw; clampClawLower2.rotateAngleY = armBot.rotationYaw;
*/
baseTop.render(f5);
base.render(f5);
GL11.glPushMatrix();
GL11.glRotatef(rotationYaw, 0, 1, 0);
armMountRight.render(f5);
armMountLeft.render(f5);
armLower.render(f5);
armUpper.render(f5);
baseRotation.render(f5);
clampBody.render(f5);
clampBody2.render(f5);
clampClawLower.render(f5);
clampClawLower2.render(f5);
GL11.glPopMatrix();
baseTop.render(f5);
base.render(f5);
GL11.glPushMatrix();
GL11.glRotatef(rotationYaw, 0, 1, 0);
{
armMountRight.render(f5);
armMountLeft.render(f5);
baseRotation.render(f5);
}
GL11.glPopMatrix();
}
GL11.glPushMatrix();
GL11.glRotatef(rotationYaw, 0, 1, 0);
GL11.glTranslatef(0f, 0.9f, 0f);
GL11.glRotatef(-rotationPitch, 1, 0, 0);
GL11.glTranslatef(0f, -0.9f, 0f);
{
armLower.render(f5);
GL11.glPushMatrix();
GL11.glTranslatef(0f, 0.1f, -0.35f);
GL11.glRotatef(-rotationPitch, 1, 0, 0);
GL11.glTranslatef(0f, -0.05f, 0.35f);
{
armUpper.render(f5);
clampBody.render(f5);
clampBody2.render(f5);
clampClawLower.render(f5);
clampClawLower2.render(f5);
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -11,8 +11,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
/**
* A class to be inherited by all machines on the assembly line. This will allow all machines to be
* able to be powered through the powering of only one machine.
* A class to be inherited by all machines on the assembly line. This will allow all machines to be able to be powered through the powering of only one machine.
*
* @author Calclavia
*

View file

@ -170,13 +170,13 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
}
// keep it within 0 - 360 degrees so ROTATE commands work properly
if (this.rotationPitch <= -360)
if (this.rotationPitch <= 0)
{
this.rotationPitch += 360;
this.rotationPitch = 0;
}
if (this.rotationPitch >= 360)
if (this.rotationPitch >= 135)
{
this.rotationPitch -= 360;
this.rotationPitch = 135;
}
if (this.rotationYaw <= -360)
{
@ -189,20 +189,21 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
if (Math.abs(this.renderYaw - this.rotationYaw) > 0.001f)
{
float speed;
float speedYaw;
if (this.renderYaw > this.rotationYaw)
{
if (Math.abs(this.renderYaw - this.rotationYaw) > 180)
speed = this.ROTATION_SPEED;
speedYaw = this.ROTATION_SPEED;
else
speed = -this.ROTATION_SPEED;
speedYaw = -this.ROTATION_SPEED;
}
else if (Math.abs(this.renderYaw - this.rotationYaw) > 180)
speedYaw = -this.ROTATION_SPEED;
else
if (Math.abs(this.renderYaw - this.rotationYaw) > 180)
speed = -this.ROTATION_SPEED;
else
speed = this.ROTATION_SPEED;
this.renderYaw += speed;
speedYaw = this.ROTATION_SPEED;
this.renderYaw += speedYaw;
if (this.renderYaw <= -360)
{
this.renderYaw += 360;
@ -211,9 +212,10 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
{
this.renderYaw -= 360;
}
if (this.ticks % 5 == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) // sound is 0.5 seconds long (20 ticks/second)
Minecraft.getMinecraft().sndManager.playSound("assemblyline.conveyor", this.xCoord, this.yCoord, this.zCoord, 2f, 1.7f);
if (this.ticks % 5 == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) // sound is 0.25 seconds long (20 ticks/second)
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "assemblyline.conveyor", 2f, 1.7f, true);
if (Math.abs(this.renderYaw - this.rotationYaw) < this.ROTATION_SPEED + 0.1f)
{
this.renderYaw = this.rotationYaw;
@ -224,6 +226,45 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
}
}
if (Math.abs(this.renderPitch - this.rotationPitch) > 0.001f)
{
float speedPitch;
if (this.renderPitch > this.rotationPitch)
{
if (Math.abs(this.renderPitch - this.rotationPitch) > 180)
speedPitch = this.ROTATION_SPEED;
else
speedPitch = -this.ROTATION_SPEED;
}
else if (Math.abs(this.renderPitch - this.rotationPitch) > 180)
speedPitch = -this.ROTATION_SPEED;
else
speedPitch = this.ROTATION_SPEED;
this.renderPitch += speedPitch;
if (this.renderPitch <= 0)
{
this.renderPitch = 0;
}
if (this.renderPitch >= 60)
{
this.renderPitch = 60;
}
if (this.ticks % 4 == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) // sound is 0.25 seconds long (20 ticks/second)
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "assemblyline.conveyor", 2f, 2.5f, true);
if (Math.abs(this.renderPitch - this.rotationPitch) < this.ROTATION_SPEED + 0.1f)
{
this.renderPitch = this.rotationPitch;
}
if (Math.abs(this.renderPitch - this.rotationPitch) > 270f) // something's wrong!
{
this.renderPitch = this.rotationPitch;
}
}
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && this.ticks % 20 == 0)
{
PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj, new Vector3(this), 50);
@ -578,7 +619,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
@Override
public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception
{
{
switch (method)
{
case 0: // rotateBy: rotates by a certain amount
@ -633,7 +674,9 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
for (int i = 0; i < found.size(); i++)
{
if (found.get(i) != null && !(found.get(i) instanceof EntityPlayer) && found.get(i).ridingEntity == null) // isn't null, isn't a player, and isn't riding anything
{ return new Object[] { true }; }
{
return new Object[] { true };
}
}
}

View file

@ -119,8 +119,8 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
if (this.isRunning())
{
if (this.ticks % (10) == 0 && this.worldObj.isRemote) // sound is 0.5 seconds long (20 ticks/second)
Minecraft.getMinecraft().sndManager.playSound("assemblyline.conveyor", this.xCoord, this.yCoord, this.zCoord, 0.125f, 0.3f);
if (this.ticks % 10 == 0 && this.worldObj.isRemote && this.worldObj.getBlockId(xCoord - 1, yCoord, zCoord) != AssemblyLine.blockConveyorBelt.blockID && this.worldObj.getBlockId(xCoord, yCoord, zCoord - 1) != AssemblyLine.blockConveyorBelt.blockID) // sound is 0.5 seconds long (20 ticks/second)
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "assemblyline.conveyor", 0.125f, 0.3f, true);
this.wheelRotation += 40;

View file

@ -9,8 +9,11 @@ public class CommandReturn extends CommandRotate
@Override
public void onTaskStart()
{
this.targetRotation = IDLE_ROTATION_YAW;
this.totalTicks = Math.abs(this.targetRotation - this.tileEntity.rotationYaw) / this.tileEntity.ROTATION_SPEED;
this.targetRotationYaw = IDLE_ROTATION_YAW;
this.targetRotationPitch = IDLE_ROTATION_PITCH;
float totalTicksYaw = Math.abs(this.targetRotationYaw - this.tileEntity.rotationYaw) / this.tileEntity.ROTATION_SPEED;
float totalTicksPitch = Math.abs(this.targetRotationPitch - this.tileEntity.rotationPitch) / this.tileEntity.ROTATION_SPEED;
this.totalTicks = Math.max(totalTicksYaw, totalTicksPitch);
}
/*@Override

View file

@ -8,7 +8,8 @@ package assemblyline.common.machine.command;
*/
public class CommandRotate extends Command
{
float targetRotation = 0;
float targetRotationYaw = 0;
float targetRotationPitch = 0;
float totalTicks = 0f;
@Override
@ -18,25 +19,45 @@ public class CommandRotate extends Command
this.ticks = 0;
if (this.getArg(0) == null)
if (this.getArg(0) != null)
{
this.targetRotation = this.tileEntity.rotationYaw + 90;
this.targetRotationYaw = this.tileEntity.rotationYaw + this.getFloatArg(0);
}
else
{
this.targetRotation = this.tileEntity.rotationYaw + this.getFloatArg(0);
}
while (this.targetRotation >= 360)
{
this.targetRotation -= 360;
}
while (this.targetRotation <= -360)
{
this.targetRotation += 360;
this.targetRotationYaw = this.tileEntity.rotationYaw + 90;
}
this.totalTicks = Math.abs(this.targetRotation - this.tileEntity.rotationYaw) / this.tileEntity.ROTATION_SPEED;
if (this.getArg(1) != null)
{
this.targetRotationPitch = this.tileEntity.rotationPitch + this.getFloatArg(1);
}
else
{
this.targetRotationPitch = this.tileEntity.rotationPitch;
}
while (this.targetRotationYaw >= 360)
{
this.targetRotationYaw -= 360;
}
while (this.targetRotationYaw <= -360)
{
this.targetRotationYaw += 360;
}
if (this.targetRotationPitch >= 60)
{
this.targetRotationPitch = 60;
}
if (this.targetRotationPitch <= 0)
{
this.targetRotationPitch = 0;
}
float totalTicksYaw = Math.abs(this.targetRotationYaw - this.tileEntity.rotationYaw) / this.tileEntity.ROTATION_SPEED;
float totalTicksPitch = Math.abs(this.targetRotationPitch - this.tileEntity.rotationPitch) / this.tileEntity.ROTATION_SPEED;
this.totalTicks = Math.max(totalTicksYaw, totalTicksPitch);
}
@Override
@ -64,8 +85,10 @@ public class CommandRotate extends Command
//set the rotation to the target immediately and let the client handle animating it
//wait for the client to catch up
if (Math.abs(this.tileEntity.rotationYaw - this.targetRotation) > 0.001f)
this.tileEntity.rotationYaw = this.targetRotation;
if (Math.abs(this.tileEntity.rotationYaw - this.targetRotationYaw) > 0.001f)
this.tileEntity.rotationYaw = this.targetRotationYaw;
if (Math.abs(this.tileEntity.rotationPitch - this.targetRotationPitch) > 0.001f)
this.tileEntity.rotationPitch = this.targetRotationPitch;
if (this.ticks < this.totalTicks)
{