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

@ -126,50 +126,43 @@ public class ModelArmbot extends ModelBase
{
/*
* 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.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.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);
}
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)

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,19 +189,20 @@ 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;
speedYaw = this.ROTATION_SPEED;
this.renderYaw += speed;
this.renderYaw += speedYaw;
if (this.renderYaw <= -360)
{
@ -212,8 +213,9 @@ 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);
@ -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);
this.targetRotationYaw = this.tileEntity.rotationYaw + 90;
}
while (this.targetRotation >= 360)
if (this.getArg(1) != null)
{
this.targetRotation -= 360;
this.targetRotationPitch = this.tileEntity.rotationPitch + this.getFloatArg(1);
}
while (this.targetRotation <= -360)
else
{
this.targetRotation += 360;
this.targetRotationPitch = this.tileEntity.rotationPitch;
}
this.totalTicks = Math.abs(this.targetRotation - this.tileEntity.rotationYaw) / this.tileEntity.ROTATION_SPEED;
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)
{