Improvements to FIRE command and ArmBot in general
Fixed dupe bug
This commit is contained in:
parent
2e1adab358
commit
d7b90682f8
8 changed files with 137 additions and 108 deletions
|
@ -1,6 +1,7 @@
|
||||||
package assemblyline.client.render;
|
package assemblyline.client.render;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
import net.minecraft.client.renderer.entity.Render;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -37,10 +38,12 @@ public class RenderArmbot extends TileEntitySpecialRenderer
|
||||||
{
|
{
|
||||||
if (entity != null && entity instanceof EntityItem) //items don't move right, so we render them manually
|
if (entity != null && entity instanceof EntityItem) //items don't move right, so we render them manually
|
||||||
{
|
{
|
||||||
Render render = RenderManager.instance.getEntityRenderObject(entity);
|
EntityItem item = (EntityItem) entity;
|
||||||
|
item.age = 0;
|
||||||
|
RenderItem render = (RenderItem) RenderManager.instance.getEntityRenderObject(entity);
|
||||||
if (render != null)
|
if (render != null)
|
||||||
{
|
{
|
||||||
render.doRender(entity, -handPos.x + 0.5f, handPos.y - 1.5f, -handPos.z + 0.5f, 0, 0);
|
render.doRender(item, -handPos.x + 0.5f, handPos.y - 1.5f, -handPos.z + 0.5f, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityList;
|
import net.minecraft.entity.EntityList;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
@ -169,11 +168,11 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep it within 0 - 360 degrees so ROTATE commands work properly
|
// keep it within 0 - 360 degrees so ROTATE commands work properly
|
||||||
if (this.rotationPitch <= 0)
|
if (this.rotationPitch < 0)
|
||||||
{
|
{
|
||||||
this.rotationPitch = 0;
|
this.rotationPitch = 0;
|
||||||
}
|
}
|
||||||
if (this.rotationPitch >= 135)
|
if (this.rotationPitch > 135)
|
||||||
{
|
{
|
||||||
this.rotationPitch = 135;
|
this.rotationPitch = 135;
|
||||||
}
|
}
|
||||||
|
@ -202,6 +201,10 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
||||||
speedYaw = this.ROTATION_SPEED;
|
speedYaw = this.ROTATION_SPEED;
|
||||||
|
|
||||||
this.renderYaw += speedYaw;
|
this.renderYaw += speedYaw;
|
||||||
|
for (Entity e : (ArrayList<Entity>) this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord + 2, this.zCoord, this.xCoord + 1, this.yCoord + 3, this.zCoord + 1)))
|
||||||
|
{
|
||||||
|
e.rotationYaw += speedYaw;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.renderYaw <= -360)
|
if (this.renderYaw <= -360)
|
||||||
{
|
{
|
||||||
|
|
|
@ -276,19 +276,21 @@ public class BlockConveyorBelt extends BlockMachine
|
||||||
entity.motionZ = direction.offsetZ * maxSpeed;
|
entity.motionZ = direction.offsetZ * maxSpeed;
|
||||||
entity.motionX = 0;
|
entity.motionX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entity.motionY += 0.0125f;
|
||||||
|
|
||||||
if (entity instanceof EntityItem)
|
if (entity instanceof EntityItem)
|
||||||
{
|
{
|
||||||
if (direction.offsetX != 0)
|
if (direction.offsetX != 0)
|
||||||
{
|
{
|
||||||
double difference = (z + 0.5) - entity.posZ;
|
double difference = (z + 0.5) - entity.posZ;
|
||||||
entity.motionZ += difference * 0.06;
|
entity.motionZ += difference * 0.1;
|
||||||
// entity.posZ = z + 0.5;
|
// entity.posZ = z + 0.5;
|
||||||
}
|
}
|
||||||
else if (direction.offsetZ != 0)
|
else if (direction.offsetZ != 0)
|
||||||
{
|
{
|
||||||
double difference = (x + 0.5) - entity.posX;
|
double difference = (x + 0.5) - entity.posX;
|
||||||
entity.motionX += difference * 0.06;
|
entity.motionX += difference * 0.1;
|
||||||
// /entity.posX = x + 0.5;
|
// /entity.posX = x + 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
|
||||||
if (this.isRunning())
|
if (this.isRunning())
|
||||||
{
|
{
|
||||||
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)
|
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.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "assemblyline.conveyor", 0.5f, 0.3f, true);
|
||||||
|
|
||||||
this.wheelRotation += 40;
|
this.wheelRotation += 40;
|
||||||
|
|
||||||
|
|
|
@ -1,98 +1,117 @@
|
||||||
package assemblyline.common.machine.command;
|
package assemblyline.common.machine.command;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import java.util.Random;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.projectile.EntityArrow;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import universalelectricity.core.vector.Vector3;
|
import net.minecraft.entity.projectile.EntityArrow;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
public class CommandFire extends Command
|
import net.minecraft.item.ItemStack;
|
||||||
{
|
import universalelectricity.core.vector.Vector3;
|
||||||
private static final float MIN_ACTUAL_PITCH = 0;
|
|
||||||
private static final float MAX_ACTUAL_PITCH = 100;
|
public class CommandFire extends Command
|
||||||
private static final float VELOCITY = 2f;
|
{
|
||||||
|
private static final float MIN_ACTUAL_PITCH = -80;
|
||||||
private float actualYaw;
|
private static final float MAX_ACTUAL_PITCH = 80;
|
||||||
private float actualPitch;
|
|
||||||
private Vector3 finalVelocity;
|
private float actualYaw;
|
||||||
|
private float actualPitch;
|
||||||
@Override
|
private float velocity;
|
||||||
public void onTaskStart()
|
private Vector3 finalVelocity;
|
||||||
{
|
|
||||||
super.onTaskStart();
|
@Override
|
||||||
this.actualYaw = this.tileEntity.rotationYaw;
|
public void onTaskStart()
|
||||||
this.actualPitch = ((MAX_ACTUAL_PITCH - MIN_ACTUAL_PITCH) * (this.tileEntity.rotationPitch / 60f)) + MIN_ACTUAL_PITCH;
|
{
|
||||||
|
super.onTaskStart();
|
||||||
double x, y, z;
|
|
||||||
double yaw, pitch;
|
velocity = this.getFloatArg(0);
|
||||||
yaw = Math.toRadians(actualYaw);
|
if (velocity > 2.5f)
|
||||||
pitch = Math.toRadians(actualPitch);
|
velocity = 2.5f;
|
||||||
// yaw = actualYaw;
|
if (velocity < 0.125f)
|
||||||
// pitch = actualPitch;
|
velocity = 1f;
|
||||||
|
|
||||||
x = Math.sin(yaw) * Math.cos(pitch);
|
this.actualYaw = this.tileEntity.rotationYaw;
|
||||||
y = Math.sin(pitch);
|
this.actualPitch = ((MAX_ACTUAL_PITCH - MIN_ACTUAL_PITCH) * (this.tileEntity.rotationPitch / 60f)) + MIN_ACTUAL_PITCH;
|
||||||
z = Math.cos(yaw) * Math.cos(pitch);
|
|
||||||
|
double x, y, z;
|
||||||
this.finalVelocity = new Vector3(x, y, z);
|
double yaw, pitch;
|
||||||
|
yaw = Math.toRadians(actualYaw);
|
||||||
this.finalVelocity.multiply(VELOCITY);
|
pitch = Math.toRadians(actualPitch);
|
||||||
}
|
// yaw = actualYaw;
|
||||||
|
// pitch = actualPitch;
|
||||||
@Override
|
|
||||||
protected boolean doTask()
|
x = -Math.sin(yaw) * Math.cos(pitch);
|
||||||
{
|
y = Math.sin(pitch);
|
||||||
if (this.finalVelocity == null) // something went wrong
|
z = Math.cos(yaw) * Math.cos(pitch);
|
||||||
{
|
|
||||||
this.finalVelocity = new Vector3(0, 0, 0);
|
this.finalVelocity = new Vector3(x, y, z);
|
||||||
}
|
Random random = new Random(System.currentTimeMillis());
|
||||||
if (this.tileEntity.grabbedEntities.size() > 0)
|
this.finalVelocity.x *= (1f - (1f / 200f)) + (random.nextFloat() * (1f / 100f));
|
||||||
{
|
this.finalVelocity.y *= (1f - (1f / 200f)) + (random.nextFloat() * (1f / 100f));
|
||||||
Entity held = this.tileEntity.grabbedEntities.get(0);
|
this.finalVelocity.z *= (1f - (1f / 200f)) + (random.nextFloat() * (1f / 100f));
|
||||||
if (held != null)
|
|
||||||
{
|
this.finalVelocity.multiply(velocity);
|
||||||
if (held instanceof EntityItem)
|
}
|
||||||
{
|
|
||||||
EntityItem item = (EntityItem) held;
|
@Override
|
||||||
if (item.func_92014_d().stackSize > 1)
|
protected boolean doTask()
|
||||||
{
|
{
|
||||||
item.func_92014_d().stackSize--;
|
if (this.finalVelocity == null) // something went wrong
|
||||||
}
|
{
|
||||||
else
|
this.finalVelocity = new Vector3(0, 0, 0);
|
||||||
{
|
}
|
||||||
this.commandManager.getNewCommand(this.tileEntity, CommandDrop.class, new String[] {}).doTask();
|
if (this.tileEntity.grabbedEntities.size() > 0)
|
||||||
if (!this.world.isRemote)
|
{
|
||||||
this.world.removeEntity(held);
|
Entity held = this.tileEntity.grabbedEntities.get(0);
|
||||||
}
|
if (held != null)
|
||||||
if (item.func_92014_d().itemID == Item.arrow.itemID)
|
{
|
||||||
{
|
this.world.playSound(this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord, "random.bow", velocity, 2f - (velocity / 4f), true);
|
||||||
EntityArrow arrow = new EntityArrow(world, this.tileEntity.getHandPosition().x, this.tileEntity.getHandPosition().y, this.tileEntity.getHandPosition().z);
|
if (held instanceof EntityItem)
|
||||||
arrow.motionX = this.finalVelocity.x;
|
{
|
||||||
arrow.motionY = this.finalVelocity.y;
|
EntityItem item = (EntityItem) held;
|
||||||
arrow.motionZ = this.finalVelocity.z;
|
ItemStack stack = item.func_92014_d();
|
||||||
if (!this.world.isRemote)
|
ItemStack thrown = stack.copy();
|
||||||
this.world.spawnEntityInWorld(arrow);
|
thrown.stackSize = 1;
|
||||||
}
|
if (item.func_92014_d().stackSize > 0)
|
||||||
else
|
{
|
||||||
{
|
stack.stackSize--;
|
||||||
EntityItem item2 = new EntityItem(world, this.tileEntity.getHandPosition().x, this.tileEntity.getHandPosition().y, this.tileEntity.getHandPosition().z, item.func_92014_d());
|
item.func_92013_a(stack);
|
||||||
item2.motionX = this.finalVelocity.x;
|
}
|
||||||
item2.motionY = this.finalVelocity.y;
|
else
|
||||||
item2.motionZ = this.finalVelocity.z;
|
{
|
||||||
if (!this.world.isRemote)
|
this.commandManager.getNewCommand(this.tileEntity, CommandDrop.class, new String[] {}).doTask();
|
||||||
this.world.spawnEntityInWorld(item2);
|
if (!this.world.isRemote)
|
||||||
}
|
this.world.removeEntity(held);
|
||||||
}
|
}
|
||||||
else
|
if (item.func_92014_d().itemID == Item.arrow.itemID)
|
||||||
{
|
{
|
||||||
this.commandManager.getNewCommand(this.tileEntity, CommandDrop.class, new String[] {}).doTask();
|
EntityArrow arrow = new EntityArrow(world, this.tileEntity.getHandPosition().x, this.tileEntity.getHandPosition().y, this.tileEntity.getHandPosition().z);
|
||||||
held.motionX = this.finalVelocity.x;
|
arrow.motionX = this.finalVelocity.x;
|
||||||
held.motionY = this.finalVelocity.y;
|
arrow.motionY = this.finalVelocity.y;
|
||||||
held.motionZ = this.finalVelocity.z;
|
arrow.motionZ = this.finalVelocity.z;
|
||||||
}
|
if (!this.world.isRemote)
|
||||||
}
|
this.world.spawnEntityInWorld(arrow);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return false;
|
{
|
||||||
}
|
EntityItem item2 = new EntityItem(world, this.tileEntity.getHandPosition().x, this.tileEntity.getHandPosition().y, this.tileEntity.getHandPosition().z, thrown);
|
||||||
}
|
item2.motionX = this.finalVelocity.x;
|
||||||
|
item2.motionY = this.finalVelocity.y;
|
||||||
|
item2.motionZ = this.finalVelocity.z;
|
||||||
|
if (!this.world.isRemote)
|
||||||
|
this.world.spawnEntityInWorld(item2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.commandManager.getNewCommand(this.tileEntity, CommandDrop.class, new String[] {}).doTask();
|
||||||
|
held.motionX = this.finalVelocity.x;
|
||||||
|
held.motionY = this.finalVelocity.y;
|
||||||
|
held.motionZ = this.finalVelocity.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class CommandIdle extends Command
|
||||||
/**
|
/**
|
||||||
* Randomly move the arm to simulate life in the arm if the arm is powered
|
* Randomly move the arm to simulate life in the arm if the arm is powered
|
||||||
*/
|
*/
|
||||||
this.tileEntity.rotationPitch *= 0.98 * this.world.rand.nextFloat();
|
//this.tileEntity.rotationPitch *= 0.98 * this.world.rand.nextFloat();
|
||||||
|
|
||||||
if (this.idleTime > 0)
|
if (this.idleTime > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,7 +46,8 @@ public class CommandManager
|
||||||
task.onTaskStart();
|
task.onTaskStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
//System.out.println("curTask: " + currentTask);
|
//if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||||
|
//System.out.println("curTask: " + this.currentTask + ": " + this.tasks.get(this.currentTask).toString().substring(this.tasks.get(this.currentTask).toString().lastIndexOf('.') + 1));
|
||||||
|
|
||||||
if (!task.doTask())
|
if (!task.doTask())
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,6 +85,7 @@ public class CommandRotate extends Command
|
||||||
|
|
||||||
//set the rotation to the target immediately and let the client handle animating it
|
//set the rotation to the target immediately and let the client handle animating it
|
||||||
//wait for the client to catch up
|
//wait for the client to catch up
|
||||||
|
|
||||||
if (Math.abs(this.tileEntity.rotationYaw - this.targetRotationYaw) > 0.001f)
|
if (Math.abs(this.tileEntity.rotationYaw - this.targetRotationYaw) > 0.001f)
|
||||||
this.tileEntity.rotationYaw = this.targetRotationYaw;
|
this.tileEntity.rotationYaw = this.targetRotationYaw;
|
||||||
if (Math.abs(this.tileEntity.rotationPitch - this.targetRotationPitch) > 0.001f)
|
if (Math.abs(this.tileEntity.rotationPitch - this.targetRotationPitch) > 0.001f)
|
||||||
|
|
Loading…
Reference in a new issue