Manipulators now work with multiblocks

This commit is contained in:
Henry Mao 2013-01-25 19:35:56 +08:00
parent 179c92c3bb
commit 2cda43b63c
26 changed files with 503 additions and 474 deletions

View file

@ -1 +1 @@
61
61

View file

@ -1 +1 @@
0.2.4
0.2.4

View file

@ -1,30 +0,0 @@
package assemblyline.api;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.Entity;
/**
* A class that allows you to ignore specific entities on the Conveyor Belt.
*
* @author Calclavia
*
*/
public class ConveyorIgnore
{
private static final List<Entity> entityIgnoreList = new ArrayList<Entity>();
public static void ignore(Entity entity)
{
if (!entityIgnoreList.contains(entity))
{
entityIgnoreList.add(entity);
}
}
public static boolean isIgnore(Entity entity)
{
return entityIgnoreList.contains(entity);
}
}

View file

@ -1,25 +1,26 @@
package assemblyline.api;
import assemblyline.common.machine.armbot.TileEntityArmbot;
import net.minecraft.entity.Entity;
import assemblyline.common.machine.armbot.TileEntityArmbot;
/**
* The IUseable inteface is used by the ArmBot so that it may interact with Tile Entities.
* onUse will be called on the block an ArmBot is touching whenver the USE command is run
* on it.
* The IUseable inteface is used by the ArmBot so that it may interact with Tile Entities. onUse
* will be called on the block an ArmBot is touching whenver the USE command is run on it.
*
* @author Briman0094
*
*
*/
public interface IArmbotUseable
{
/**
* Called when the ArmBot command "USE" is run. This is called on any IUseable the
* ArmBot is touching.
* Called when the ArmBot command "USE" is run. This is called on any IUseable the ArmBot is
* touching.
*
* @param tileEntity the TileEntityArmbot that is using this IUseable
* @param heldEntity the Entity being held by the ArmBot, or null if there is none
* @return whether or not the "use" did anything
*/
public boolean onUse(TileEntityArmbot tileEntity, Entity heldEntity);
}

View file

@ -126,9 +126,28 @@ 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);

View file

@ -8,163 +8,162 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelRejectorPiston extends ModelBase
{
// fields
ModelRenderer BodyBottom;
ModelRenderer PistonFace2;
ModelRenderer PistonShaft;
ModelRenderer Piston;
ModelRenderer H1;
ModelRenderer H2;
ModelRenderer H3;
ModelRenderer PistonFace;
ModelRenderer WireCCRight;
ModelRenderer WireCCLeft;
ModelRenderer BodyP2;
ModelRenderer BodyP1;
ModelRenderer LeftSide;
ModelRenderer RightSide;
ModelRenderer PistonBack;
ModelRenderer WireCCFront;
// fields
ModelRenderer BodyBottom;
ModelRenderer PistonFace2;
ModelRenderer PistonShaft;
ModelRenderer Piston;
ModelRenderer H1;
ModelRenderer H2;
ModelRenderer H3;
ModelRenderer PistonFace;
ModelRenderer WireCCRight;
ModelRenderer WireCCLeft;
ModelRenderer BodyP2;
ModelRenderer BodyP1;
ModelRenderer LeftSide;
ModelRenderer RightSide;
ModelRenderer PistonBack;
ModelRenderer WireCCFront;
public ModelRejectorPiston()
{
textureWidth = 128;
textureHeight = 128;
public ModelRejectorPiston()
{
textureWidth = 128;
textureHeight = 128;
BodyBottom = new ModelRenderer(this, 29, 69);
BodyBottom.addBox(-5F, 0F, -2F, 10, 5, 15);
BodyBottom.setRotationPoint(0F, 19F, -6F);
BodyBottom.setTextureSize(128, 128);
BodyBottom.mirror = true;
setRotation(BodyBottom, 0F, 0F, 0F);
PistonFace2 = new ModelRenderer(this, 0, 53);
PistonFace2.addBox(-2F, -2F, -1F, 4, 6, 1);
PistonFace2.setRotationPoint(0F, 15F, -6F);
PistonFace2.setTextureSize(128, 128);
PistonFace2.mirror = true;
setRotation(PistonFace2, 0F, 0F, 0F);
PistonShaft = new ModelRenderer(this, 0, 75);
PistonShaft.addBox(-1.5F, -1.5F, 0F, 3, 3, 10);
PistonShaft.setRotationPoint(0F, 16F, -6F);
PistonShaft.setTextureSize(128, 128);
PistonShaft.mirror = true;
setRotation(PistonShaft, 0F, 0F, 0F);
Piston = new ModelRenderer(this, 0, 22);
Piston.addBox(-3F, -1F, 0F, 6, 6, 10);
Piston.setRotationPoint(0F, 14F, -5F);
Piston.setTextureSize(128, 128);
Piston.mirror = true;
setRotation(Piston, 0F, 0F, 0F);
H1 = new ModelRenderer(this, 33, 23);
H1.addBox(-1.5F, 0F, 0F, 3, 1, 8);
H1.setRotationPoint(0F, 12F, -4F);
H1.setTextureSize(128, 128);
H1.mirror = true;
setRotation(H1, 0F, 0F, 0F);
H2 = new ModelRenderer(this, 90, 23);
H2.addBox(0F, -1.5F, 0F, 1, 3, 8);
H2.setRotationPoint(-4F, 16F, -4F);
H2.setTextureSize(128, 128);
H2.mirror = true;
setRotation(H2, 0F, 0F, 0F);
H3 = new ModelRenderer(this, 70, 23);
H3.addBox(0F, -1.5F, 0F, 1, 3, 8);
H3.setRotationPoint(3F, 16F, -4F);
H3.setTextureSize(128, 128);
H3.mirror = true;
setRotation(H3, 0F, 0F, 0F);
PistonFace = new ModelRenderer(this, 0, 62);
PistonFace.addBox(-3F, -2F, -1F, 6, 4, 1);
PistonFace.setRotationPoint(0F, 16F, -6F);
PistonFace.setTextureSize(128, 128);
PistonFace.mirror = true;
setRotation(PistonFace, 0F, 0F, 0F);
WireCCRight = new ModelRenderer(this, 69, 52);
WireCCRight.addBox(-3F, -3F, 0F, 6, 11, 1);
WireCCRight.setRotationPoint(0F, 16F, 7F);
WireCCRight.setTextureSize(128, 128);
WireCCRight.mirror = true;
setRotation(WireCCRight, 0F, 0F, 0F);
WireCCLeft = new ModelRenderer(this, 54, 37);
WireCCLeft.addBox(0F, -3F, -3F, 1, 8, 6);
WireCCLeft.setRotationPoint(7F, 16F, 0F);
WireCCLeft.setTextureSize(128, 128);
WireCCLeft.mirror = true;
setRotation(WireCCLeft, 0F, 0F, 0F);
BodyP2 = new ModelRenderer(this, 100, 60);
BodyP2.addBox(1F, -2F, -2F, 2, 7, 4);
BodyP2.setRotationPoint(-8F, 16F, 0F);
BodyP2.setTextureSize(128, 128);
BodyP2.mirror = true;
setRotation(BodyP2, 0F, 0F, 0F);
BodyP1 = new ModelRenderer(this, 87, 60);
BodyP1.addBox(3F, -2F, -2F, 2, 7, 4);
BodyP1.setRotationPoint(2F, 16F, 0F);
BodyP1.setTextureSize(128, 128);
BodyP1.mirror = true;
setRotation(BodyP1, 0F, 0F, 0F);
LeftSide = new ModelRenderer(this, 29, 91);
LeftSide.addBox(0F, 0F, -2F, 3, 3, 14);
LeftSide.setRotationPoint(5F, 21F, -5F);
LeftSide.setTextureSize(128, 128);
LeftSide.mirror = true;
setRotation(LeftSide, 0F, 0F, 0F);
RightSide = new ModelRenderer(this, 64, 91);
RightSide.addBox(0F, 0F, -2F, 3, 3, 14);
RightSide.setRotationPoint(-8F, 21F, -5F);
RightSide.setTextureSize(128, 128);
RightSide.mirror = true;
setRotation(RightSide, 0F, 0F, 0F);
PistonBack = new ModelRenderer(this, 0, 12);
PistonBack.addBox(-2.5F, -2.5F, -1F, 5, 5, 2);
PistonBack.setRotationPoint(0F, 16F, 6F);
PistonBack.setTextureSize(128, 128);
PistonBack.mirror = true;
setRotation(PistonBack, 0F, 0F, 0F);
WireCCFront = new ModelRenderer(this, 69, 37);
WireCCFront.addBox(0F, -3F, -3F, 1, 8, 6);
WireCCFront.setRotationPoint(-8F, 16F, 0F);
WireCCFront.setTextureSize(128, 128);
WireCCFront.mirror = true;
setRotation(WireCCFront, 0F, 0F, 0F);
}
BodyBottom = new ModelRenderer(this, 29, 69);
BodyBottom.addBox(-5F, 0F, -2F, 10, 5, 15);
BodyBottom.setRotationPoint(0F, 19F, -6F);
BodyBottom.setTextureSize(128, 128);
BodyBottom.mirror = true;
setRotation(BodyBottom, 0F, 0F, 0F);
PistonFace2 = new ModelRenderer(this, 0, 53);
PistonFace2.addBox(-2F, -2F, -1F, 4, 6, 1);
PistonFace2.setRotationPoint(0F, 15F, -6F);
PistonFace2.setTextureSize(128, 128);
PistonFace2.mirror = true;
setRotation(PistonFace2, 0F, 0F, 0F);
PistonShaft = new ModelRenderer(this, 0, 75);
PistonShaft.addBox(-1.5F, -1.5F, 0F, 3, 3, 10);
PistonShaft.setRotationPoint(0F, 16F, -6F);
PistonShaft.setTextureSize(128, 128);
PistonShaft.mirror = true;
setRotation(PistonShaft, 0F, 0F, 0F);
Piston = new ModelRenderer(this, 0, 22);
Piston.addBox(-3F, -1F, 0F, 6, 6, 10);
Piston.setRotationPoint(0F, 14F, -5F);
Piston.setTextureSize(128, 128);
Piston.mirror = true;
setRotation(Piston, 0F, 0F, 0F);
H1 = new ModelRenderer(this, 33, 23);
H1.addBox(-1.5F, 0F, 0F, 3, 1, 8);
H1.setRotationPoint(0F, 12F, -4F);
H1.setTextureSize(128, 128);
H1.mirror = true;
setRotation(H1, 0F, 0F, 0F);
H2 = new ModelRenderer(this, 90, 23);
H2.addBox(0F, -1.5F, 0F, 1, 3, 8);
H2.setRotationPoint(-4F, 16F, -4F);
H2.setTextureSize(128, 128);
H2.mirror = true;
setRotation(H2, 0F, 0F, 0F);
H3 = new ModelRenderer(this, 70, 23);
H3.addBox(0F, -1.5F, 0F, 1, 3, 8);
H3.setRotationPoint(3F, 16F, -4F);
H3.setTextureSize(128, 128);
H3.mirror = true;
setRotation(H3, 0F, 0F, 0F);
PistonFace = new ModelRenderer(this, 0, 62);
PistonFace.addBox(-3F, -2F, -1F, 6, 4, 1);
PistonFace.setRotationPoint(0F, 16F, -6F);
PistonFace.setTextureSize(128, 128);
PistonFace.mirror = true;
setRotation(PistonFace, 0F, 0F, 0F);
WireCCRight = new ModelRenderer(this, 69, 52);
WireCCRight.addBox(-3F, -3F, 0F, 6, 11, 1);
WireCCRight.setRotationPoint(0F, 16F, 7F);
WireCCRight.setTextureSize(128, 128);
WireCCRight.mirror = true;
setRotation(WireCCRight, 0F, 0F, 0F);
WireCCLeft = new ModelRenderer(this, 54, 37);
WireCCLeft.addBox(0F, -3F, -3F, 1, 8, 6);
WireCCLeft.setRotationPoint(7F, 16F, 0F);
WireCCLeft.setTextureSize(128, 128);
WireCCLeft.mirror = true;
setRotation(WireCCLeft, 0F, 0F, 0F);
BodyP2 = new ModelRenderer(this, 100, 60);
BodyP2.addBox(1F, -2F, -2F, 2, 7, 4);
BodyP2.setRotationPoint(-8F, 16F, 0F);
BodyP2.setTextureSize(128, 128);
BodyP2.mirror = true;
setRotation(BodyP2, 0F, 0F, 0F);
BodyP1 = new ModelRenderer(this, 87, 60);
BodyP1.addBox(3F, -2F, -2F, 2, 7, 4);
BodyP1.setRotationPoint(2F, 16F, 0F);
BodyP1.setTextureSize(128, 128);
BodyP1.mirror = true;
setRotation(BodyP1, 0F, 0F, 0F);
LeftSide = new ModelRenderer(this, 29, 91);
LeftSide.addBox(0F, 0F, -2F, 3, 3, 14);
LeftSide.setRotationPoint(5F, 21F, -5F);
LeftSide.setTextureSize(128, 128);
LeftSide.mirror = true;
setRotation(LeftSide, 0F, 0F, 0F);
RightSide = new ModelRenderer(this, 64, 91);
RightSide.addBox(0F, 0F, -2F, 3, 3, 14);
RightSide.setRotationPoint(-8F, 21F, -5F);
RightSide.setTextureSize(128, 128);
RightSide.mirror = true;
setRotation(RightSide, 0F, 0F, 0F);
PistonBack = new ModelRenderer(this, 0, 12);
PistonBack.addBox(-2.5F, -2.5F, -1F, 5, 5, 2);
PistonBack.setRotationPoint(0F, 16F, 6F);
PistonBack.setTextureSize(128, 128);
PistonBack.mirror = true;
setRotation(PistonBack, 0F, 0F, 0F);
WireCCFront = new ModelRenderer(this, 69, 37);
WireCCFront.addBox(0F, -3F, -3F, 1, 8, 6);
WireCCFront.setRotationPoint(-8F, 16F, 0F);
WireCCFront.setTextureSize(128, 128);
WireCCFront.mirror = true;
setRotation(WireCCFront, 0F, 0F, 0F);
}
public void render(float f5)
{
BodyBottom.render(f5);
Piston.render(f5);
H1.render(f5);
H2.render(f5);
H3.render(f5);
WireCCRight.render(f5);
WireCCLeft.render(f5);
BodyP2.render(f5);
BodyP1.render(f5);
LeftSide.render(f5);
RightSide.render(f5);
PistonBack.render(f5);
WireCCFront.render(f5);
}
public void render(float f5)
{
BodyBottom.render(f5);
Piston.render(f5);
H1.render(f5);
H2.render(f5);
H3.render(f5);
WireCCRight.render(f5);
WireCCLeft.render(f5);
BodyP2.render(f5);
BodyP1.render(f5);
LeftSide.render(f5);
RightSide.render(f5);
PistonBack.render(f5);
WireCCFront.render(f5);
}
public void renderPiston(float f5, int p)
{
PistonFace2.setRotationPoint(0F, 15F, -6F-p);
PistonShaft.setRotationPoint(0F, 16F, -6F-p);
PistonFace.setRotationPoint(0F, 16F, -6F-p);
PistonFace2.render(f5);
PistonShaft.render(f5);
PistonFace.render(f5);
}
public void renderPiston(float f5, int p)
{
PistonFace2.setRotationPoint(0F, 15F, -6F - p);
PistonShaft.setRotationPoint(0F, 16F, -6F - p);
PistonFace.setRotationPoint(0F, 16F, -6F - p);
PistonFace2.render(f5);
PistonShaft.render(f5);
PistonFace.render(f5);
}
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

@ -1,6 +1,5 @@
package assemblyline.client.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.tileentity.TileEntitySpecialRenderer;
@ -36,7 +35,8 @@ public class RenderArmbot extends TileEntitySpecialRenderer
GL11.glRotatef(180, 0, 0, 1);
for (Entity entity : ((TileEntityArmbot) tileEntity).grabbedEntities)
{
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
{
EntityItem item = (EntityItem) entity;
item.age = 0;

View file

@ -11,7 +11,7 @@ public class RenderCrate implements ISimpleBlockRenderingHandler
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
}
@Override

View file

@ -90,7 +90,7 @@ public class BlockCrate extends BlockMachine
return false;
}
@Override
public int getRenderType()
{

View file

@ -11,7 +11,8 @@ 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

@ -14,6 +14,7 @@ import net.minecraftforge.common.ISidedInventory;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.multiblock.TileEntityMulti;
import universalelectricity.prefab.network.PacketManager;
import assemblyline.api.IManipulator;
import assemblyline.common.machine.imprinter.TileEntityFilterable;
@ -21,14 +22,14 @@ import cpw.mods.fml.common.network.PacketDispatcher;
public class TileEntityManipulator extends TileEntityFilterable implements IRotatable, IRedstoneReceptor, IManipulator
{
public boolean selfPulse = false;
public boolean selfPulse = false;
/**
* Is the manipulator wrenched to turn into output mode?
*/
private boolean isOutput = false;
private boolean isOutput = false;
private boolean isRedstonePowered = false;
private boolean isRedstonePowered = false;
public boolean isOutput()
{
@ -86,7 +87,8 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
}
/**
* Find items going into the manipulator and input them into an inventory behind this manipulator.
* Find items going into the manipulator and input them into an inventory behind this
* manipulator.
*/
@Override
public void inject()
@ -110,7 +112,8 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
if (entity.isDead)
continue;
/**
* Try top first, then bottom, then the sides to see if it is possible to insert the item into a inventory.
* Try top first, then bottom, then the sides to see if it is possible to insert the
* item into a inventory.
*/
ItemStack remainingStack = entity.func_92014_d().copy();
@ -180,9 +183,16 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
}
/*
* @Override public ArrayList getPacketData() { ArrayList list = super.getPacketData(); list.add(this.isOutput); list.add(this.wattsReceived); return list; }
* @Override public ArrayList getPacketData() { ArrayList list = super.getPacketData();
* list.add(this.isOutput); list.add(this.wattsReceived); return list; }
*
* @Override public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) { if (worldObj.isRemote) { ByteArrayInputStream bis = new ByteArrayInputStream(packet.data); DataInputStream dis = new DataInputStream(bis); int id, x, y, z; try { id = dis.readInt(); x = dis.readInt(); y = dis.readInt(); z = dis.readInt(); NBTTagCompound tag = Packet.readNBTTagCompound(dis); readFromNBT(tag); this.wattsReceived = dis.readDouble(); this.isOutput = dis.readBoolean(); } catch (IOException e) { e.printStackTrace(); } } }
* @Override public void handlePacketData(INetworkManager network, int packetType,
* Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) { if
* (worldObj.isRemote) { ByteArrayInputStream bis = new ByteArrayInputStream(packet.data);
* DataInputStream dis = new DataInputStream(bis); int id, x, y, z; try { id = dis.readInt(); x
* = dis.readInt(); y = dis.readInt(); z = dis.readInt(); NBTTagCompound tag =
* Packet.readNBTTagCompound(dis); readFromNBT(tag); this.wattsReceived = dis.readDouble();
* this.isOutput = dis.readBoolean(); } catch (IOException e) { e.printStackTrace(); } } }
*/
/**
@ -215,7 +225,17 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
/**
* Try to put items into a chest.
*/
if (tileEntity instanceof TileEntityChest)
if (tileEntity instanceof TileEntityMulti)
{
Vector3 mainBlockPosition = ((TileEntityMulti) tileEntity).mainBlockPosition;
if (mainBlockPosition != null)
{
if (!(mainBlockPosition.getTileEntity(this.worldObj) instanceof TileEntityMulti))
return tryPlaceInPosition(itemStack, mainBlockPosition, direction);
}
}
else if (tileEntity instanceof TileEntityChest)
{
TileEntityChest[] chests = { (TileEntityChest) tileEntity, null };
@ -323,7 +343,17 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
/**
* Try to put items into a chest.
*/
if (tileEntity instanceof TileEntityChest)
if (tileEntity instanceof TileEntityMulti)
{
Vector3 mainBlockPosition = ((TileEntityMulti) tileEntity).mainBlockPosition;
if (mainBlockPosition != null)
{
if (!(mainBlockPosition.getTileEntity(this.worldObj) instanceof TileEntityMulti))
return tryGrabFromPosition(mainBlockPosition, direction);
}
}
else if (tileEntity instanceof TileEntityChest)
{
TileEntityChest[] chests = { (TileEntityChest) tileEntity, null };

View file

@ -51,32 +51,32 @@ import dan200.computer.api.IPeripheral;
public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMultiBlock, IInventory, IPacketReceiver, IJouleStorage, IPeripheral
{
private final CommandManager commandManager = new CommandManager();
private static final int PACKET_COMMANDS = 128;
private final CommandManager commandManager = new CommandManager();
private static final int PACKET_COMMANDS = 128;
/**
* The items this container contains.
*/
protected ItemStack disk = null;
public final double WATT_REQUEST = 20;
public double wattsReceived = 0;
private int playerUsing = 0;
private int computersAttached = 0;
private List<IComputerAccess> connectedComputers = new ArrayList<IComputerAccess>();
protected ItemStack disk = null;
public final double WATT_REQUEST = 20;
public double wattsReceived = 0;
private int playerUsing = 0;
private int computersAttached = 0;
private List<IComputerAccess> connectedComputers = new ArrayList<IComputerAccess>();
/**
* The rotation of the arms. In Degrees.
*/
public float rotationPitch = 0;
public float rotationYaw = 0;
public float renderPitch = 0;
public float renderYaw = 0;
private int ticksSincePower = 0;
public final float ROTATION_SPEED = 1.3f;
public float rotationPitch = 0;
public float rotationYaw = 0;
public float renderPitch = 0;
public float renderYaw = 0;
private int ticksSincePower = 0;
public final float ROTATION_SPEED = 1.3f;
/**
* An entity that the armbot is grabbed onto.
*/
public final List<Entity> grabbedEntities = new ArrayList<Entity>();
public final List<Entity> grabbedEntities = new ArrayList<Entity>();
@Override
public void initiate()
@ -215,7 +215,13 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
this.renderYaw -= 360;
}
if (this.ticks % 5 == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) // sound is 0.25 seconds long (20 ticks/second)
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)
@ -254,7 +260,13 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
this.renderPitch = 60;
}
if (this.ticks % 4 == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) // sound is 0.25 seconds long (20 ticks/second)
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)
@ -284,7 +296,9 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
double distance = 1f;
Vector3 delta = new Vector3();
// The delta Y of the hand.
delta.y = Math.sin(Math.toRadians(this.renderPitch)) * distance * 2; //arm bend up in a taller-than-wide arc
delta.y = Math.sin(Math.toRadians(this.renderPitch)) * distance * 2; // arm bend up in a
// taller-than-wide
// arc
// The horizontal delta of the hand.
double dH = Math.cos(Math.toRadians(this.renderPitch)) * distance;
// The delta X and Z.
@ -666,7 +680,8 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
{
return new Object[] { this.commandManager.hasTasks() };
}
case 5: // touchingEntity: returns whether or not the ArmBot is touching an entity it is able to pick up
case 5: // touchingEntity: returns whether or not the ArmBot is touching an entity it is
// able to pick up
{
Vector3 serachPosition = this.getHandPosition();
List<Entity> found = this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(serachPosition.x - 0.5f, serachPosition.y - 0.5f, serachPosition.z - 0.5f, serachPosition.x + 0.5f, serachPosition.y + 0.5f, serachPosition.z + 0.5f));
@ -675,7 +690,15 @@ 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
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 }; }
}
}

View file

@ -1,7 +1,6 @@
package assemblyline.common.machine.belt;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
@ -34,7 +33,7 @@ public class BlockConveyorBelt extends BlockMachine
this.setBlockBounds(0, 0, 0, 1, 0.3f, 1);
this.setCreativeTab(TabAssemblyLine.INSTANCE);
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
{
@ -68,14 +67,8 @@ public class BlockConveyorBelt extends BlockMachine
{
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) t;
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN)
{
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + 1, (double) y + 1, (double) z + 1);
}
if (tileEntity.getSlant() == SlantType.TOP)
{
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + 0.68f, (double) z + this.minZ, (double) x + this.maxX, (double) y + 0.98f, (double) z + this.maxZ);
}
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN) { return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + 1, (double) y + 1, (double) z + 1); }
if (tileEntity.getSlant() == SlantType.TOP) { return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + 0.68f, (double) z + this.minZ, (double) x + this.maxX, (double) y + 0.98f, (double) z + this.maxZ); }
}
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
@ -276,7 +269,7 @@ public class BlockConveyorBelt extends BlockMachine
entity.motionZ = direction.offsetZ * maxSpeed;
entity.motionX = 0;
}
entity.motionY += 0.0125f;
if (entity instanceof EntityItem)

View file

@ -3,7 +3,6 @@ package assemblyline.common.machine.belt;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
@ -53,7 +52,8 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
}
/**
* This function is overriden to allow conveyor belts to power belts that are diagonally going up.
* This function is overriden to allow conveyor belts to power belts that are diagonally going
* up.
*/
@Override
public void updatePowerTransferRange()
@ -119,8 +119,11 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
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)
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "assemblyline.conveyor", 0.5f, 0.3f, true);
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.3f, 0.3f, true);
}
this.wheelRotation += 40;

View file

@ -125,13 +125,13 @@ public abstract class Command
}
catch (Exception e)
{
}
}
return 0;
}
protected Double getDoubleArg(int i)
{
if (getArg(i) != null)
@ -142,13 +142,13 @@ public abstract class Command
}
catch (Exception e)
{
}
}
return 0.0;
}
protected Float getFloatArg(int i)
{
if (getArg(i) != null)
@ -159,7 +159,7 @@ public abstract class Command
}
catch (Exception e)
{
}
}

View file

@ -1,6 +1,5 @@
package assemblyline.common.machine.command;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
@ -10,7 +9,7 @@ public class CommandDrop extends Command
protected boolean doTask()
{
super.doTask();
if (this.tileEntity.grabbedEntities.size() == 0)
return false;
@ -23,7 +22,8 @@ public class CommandDrop extends Command
entity.worldObj = this.tileEntity.worldObj;
if (entity instanceof EntityItem)
if (!world.isRemote)
world.spawnEntityInWorld(entity); // items don't move right, so we render them manually
world.spawnEntityInWorld(entity); // items don't move right, so we render
// them manually
this.world.playSound(this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord, "random.pop", 0.2F, ((this.tileEntity.worldObj.rand.nextFloat() - this.tileEntity.worldObj.rand.nextFloat()) * 0.7F + 1.0F) * 1.0F, true);
}
}

View file

@ -1,117 +1,117 @@
package assemblyline.common.machine.command;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import universalelectricity.core.vector.Vector3;
public class CommandFire extends Command
{
private static final float MIN_ACTUAL_PITCH = -80;
private static final float MAX_ACTUAL_PITCH = 80;
private float actualYaw;
private float actualPitch;
private float velocity;
private Vector3 finalVelocity;
@Override
public void onTaskStart()
{
super.onTaskStart();
velocity = this.getFloatArg(0);
if (velocity > 2.5f)
velocity = 2.5f;
if (velocity < 0.125f)
velocity = 1f;
this.actualYaw = this.tileEntity.rotationYaw;
this.actualPitch = ((MAX_ACTUAL_PITCH - MIN_ACTUAL_PITCH) * (this.tileEntity.rotationPitch / 60f)) + MIN_ACTUAL_PITCH;
double x, y, z;
double yaw, pitch;
yaw = Math.toRadians(actualYaw);
pitch = Math.toRadians(actualPitch);
// yaw = actualYaw;
// pitch = actualPitch;
x = -Math.sin(yaw) * Math.cos(pitch);
y = Math.sin(pitch);
z = Math.cos(yaw) * Math.cos(pitch);
this.finalVelocity = new Vector3(x, y, z);
Random random = new Random(System.currentTimeMillis());
this.finalVelocity.x *= (1f - (1f / 200f)) + (random.nextFloat() * (1f / 100f));
this.finalVelocity.y *= (1f - (1f / 200f)) + (random.nextFloat() * (1f / 100f));
this.finalVelocity.z *= (1f - (1f / 200f)) + (random.nextFloat() * (1f / 100f));
this.finalVelocity.multiply(velocity);
}
@Override
protected boolean doTask()
{
if (this.finalVelocity == null) // something went wrong
{
this.finalVelocity = new Vector3(0, 0, 0);
}
if (this.tileEntity.grabbedEntities.size() > 0)
{
Entity held = this.tileEntity.grabbedEntities.get(0);
if (held != null)
{
this.world.playSound(this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord, "random.bow", velocity, 2f - (velocity / 4f), true);
if (held instanceof EntityItem)
{
EntityItem item = (EntityItem) held;
ItemStack stack = item.func_92014_d();
ItemStack thrown = stack.copy();
thrown.stackSize = 1;
if (item.func_92014_d().stackSize > 0)
{
stack.stackSize--;
item.func_92013_a(stack);
}
else
{
this.commandManager.getNewCommand(this.tileEntity, CommandDrop.class, new String[] {}).doTask();
if (!this.world.isRemote)
this.world.removeEntity(held);
}
if (item.func_92014_d().itemID == Item.arrow.itemID)
{
EntityArrow arrow = new EntityArrow(world, this.tileEntity.getHandPosition().x, this.tileEntity.getHandPosition().y, this.tileEntity.getHandPosition().z);
arrow.motionX = this.finalVelocity.x;
arrow.motionY = this.finalVelocity.y;
arrow.motionZ = this.finalVelocity.z;
if (!this.world.isRemote)
this.world.spawnEntityInWorld(arrow);
}
else
{
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;
}
}
package assemblyline.common.machine.command;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import universalelectricity.core.vector.Vector3;
public class CommandFire extends Command
{
private static final float MIN_ACTUAL_PITCH = -80;
private static final float MAX_ACTUAL_PITCH = 80;
private float actualYaw;
private float actualPitch;
private float velocity;
private Vector3 finalVelocity;
@Override
public void onTaskStart()
{
super.onTaskStart();
velocity = this.getFloatArg(0);
if (velocity > 2.5f)
velocity = 2.5f;
if (velocity < 0.125f)
velocity = 1f;
this.actualYaw = this.tileEntity.rotationYaw;
this.actualPitch = ((MAX_ACTUAL_PITCH - MIN_ACTUAL_PITCH) * (this.tileEntity.rotationPitch / 60f)) + MIN_ACTUAL_PITCH;
double x, y, z;
double yaw, pitch;
yaw = Math.toRadians(actualYaw);
pitch = Math.toRadians(actualPitch);
// yaw = actualYaw;
// pitch = actualPitch;
x = -Math.sin(yaw) * Math.cos(pitch);
y = Math.sin(pitch);
z = Math.cos(yaw) * Math.cos(pitch);
this.finalVelocity = new Vector3(x, y, z);
Random random = new Random(System.currentTimeMillis());
this.finalVelocity.x *= (1f - (1f / 200f)) + (random.nextFloat() * (1f / 100f));
this.finalVelocity.y *= (1f - (1f / 200f)) + (random.nextFloat() * (1f / 100f));
this.finalVelocity.z *= (1f - (1f / 200f)) + (random.nextFloat() * (1f / 100f));
this.finalVelocity.multiply(velocity);
}
@Override
protected boolean doTask()
{
if (this.finalVelocity == null) // something went wrong
{
this.finalVelocity = new Vector3(0, 0, 0);
}
if (this.tileEntity.grabbedEntities.size() > 0)
{
Entity held = this.tileEntity.grabbedEntities.get(0);
if (held != null)
{
this.world.playSound(this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord, "random.bow", velocity, 2f - (velocity / 4f), true);
if (held instanceof EntityItem)
{
EntityItem item = (EntityItem) held;
ItemStack stack = item.func_92014_d();
ItemStack thrown = stack.copy();
thrown.stackSize = 1;
if (item.func_92014_d().stackSize > 0)
{
stack.stackSize--;
item.func_92013_a(stack);
}
else
{
this.commandManager.getNewCommand(this.tileEntity, CommandDrop.class, new String[] {}).doTask();
if (!this.world.isRemote)
this.world.removeEntity(held);
}
if (item.func_92014_d().itemID == Item.arrow.itemID)
{
EntityArrow arrow = new EntityArrow(world, this.tileEntity.getHandPosition().x, this.tileEntity.getHandPosition().y, this.tileEntity.getHandPosition().z);
arrow.motionX = this.finalVelocity.x;
arrow.motionY = this.finalVelocity.y;
arrow.motionZ = this.finalVelocity.z;
if (!this.world.isRemote)
this.world.spawnEntityInWorld(arrow);
}
else
{
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;
}
}

View file

@ -34,10 +34,10 @@ public class CommandGrab extends Command
protected boolean doTask()
{
super.doTask();
if (this.tileEntity.grabbedEntities.size() > 0)
return false;
Vector3 serachPosition = this.tileEntity.getHandPosition();
List<Entity> found = this.world.getEntitiesWithinAABB(this.entityToInclude, AxisAlignedBB.getBoundingBox(serachPosition.x - radius, serachPosition.y - radius, serachPosition.z - radius, serachPosition.x + radius, serachPosition.y + radius, serachPosition.z + radius));
@ -45,11 +45,22 @@ public class CommandGrab extends Command
{
for (int i = 0; i < found.size(); i++)
{
if (found.get(i) != null && !(found.get(i) instanceof EntityPlayer) && !(found.get(i) instanceof EntityArrow) && found.get(i).ridingEntity == null) // isn't null, isn't a player, and isn't riding anything
if (found.get(i) != null && !(found.get(i) instanceof EntityPlayer) && !(found.get(i) instanceof EntityArrow) && found.get(i).ridingEntity == null) // isn't
// null,
// isn't
// a
// player,
// and
// isn't
// riding
// anything
{
this.tileEntity.grabbedEntities.add(found.get(i));
if (found.get(i) instanceof EntityItem)
this.tileEntity.worldObj.removeEntity(found.get(i)); // items don't move right, so we render them manually\
this.tileEntity.worldObj.removeEntity(found.get(i)); // items don't move
// right, so we
// render them
// manually\
this.world.playSound(this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord, "random.pop", 0.2F, ((this.tileEntity.worldObj.rand.nextFloat() - this.tileEntity.worldObj.rand.nextFloat()) * 0.7F + 1.0F) * 1.0F, true);
found.get(i).isDead = false;
return false;

View file

@ -1,6 +1,5 @@
package assemblyline.common.machine.command;
public class CommandIdle extends Command
{
/**
@ -23,7 +22,7 @@ public class CommandIdle extends Command
/**
* 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)
{

View file

@ -6,17 +6,15 @@ import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import assemblyline.common.machine.armbot.TileEntityArmbot;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.relauncher.Side;
public class CommandManager
{
private final List<Command> tasks = new ArrayList<Command>();
private final List<Command> tasks = new ArrayList<Command>();
private int ticks = 0;
private int currentTask = 0;
private int lastTask = -1;
private int ticks = 0;
private int currentTask = 0;
private int lastTask = -1;
/**
* Must be called every tick by a tileEntity.
@ -45,18 +43,21 @@ public class CommandManager
this.lastTask = this.currentTask;
task.onTaskStart();
}
//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 (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())
{
int tempCurrentTask = this.currentTask;
task.onTaskEnd();
this.currentTask++;
if (!(task instanceof CommandRepeat)) //repeat needs to be persistent
if (!(task instanceof CommandRepeat)) // repeat needs to be persistent
{
// End the task and reinitialize it into a new class to make sure it is fresh.
// End the task and reinitialize it into a new class to make sure it is
// fresh.
this.tasks.set(tempCurrentTask, this.getNewCommand(task.tileEntity, task.getClass(), task.getArgs()));
}
}
@ -97,7 +98,8 @@ public class CommandManager
}
/**
* Used to register Tasks for a TileEntity, executes onTaskStart for the Task after registering it
* Used to register Tasks for a TileEntity, executes onTaskStart for the Task after registering
* it
*
* @param tileEntity TE instance to register the task for
* @param newCommand Task instance to register

View file

@ -11,10 +11,10 @@ public class CommandRepeat extends Command
/**
* The amount of tasks above this task to repeat.
*/
private int tasksToRepeat;
private int numReps;
private int curReps;
private boolean initialized = false;
private int tasksToRepeat;
private int numReps;
private int curReps;
private boolean initialized = false;
public void onTaskStart()
{

View file

@ -1,11 +1,10 @@
package assemblyline.common.machine.command;
public class CommandReturn extends CommandRotate
{
public static final float IDLE_ROTATION_PITCH = 0;
public static final float IDLE_ROTATION_YAW = 0;
@Override
public void onTaskStart()
{
@ -16,31 +15,25 @@ public class CommandReturn extends CommandRotate
this.totalTicks = Math.max(totalTicksYaw, totalTicksPitch);
}
/*@Override
protected boolean doTask()
{
/**
* Move the arm rotation to idle position if the machine is not idling
*
if (Math.abs(this.tileEntity.rotationPitch - IDLE_ROTATION_PITCH) > 0.01 || Math.abs(this.tileEntity.rotationYaw - IDLE_ROTATION_YAW) > 0.01)
{
if (Math.abs(IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) > 0.125)
this.tileEntity.rotationPitch += (IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) * 0.05;
else
this.tileEntity.rotationPitch += Math.signum(IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) * (0.125 * 0.05);
if (Math.abs(this.tileEntity.rotationPitch - IDLE_ROTATION_PITCH) < 0.0125)
this.tileEntity.rotationPitch = IDLE_ROTATION_PITCH;
if (Math.abs(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) > 0.125)
this.tileEntity.rotationYaw += (IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * 0.05;
else
this.tileEntity.rotationYaw += Math.signum(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * (0.125 * 0.05);
if (Math.abs(this.tileEntity.rotationYaw - IDLE_ROTATION_YAW) < 0.0125)
this.tileEntity.rotationYaw = IDLE_ROTATION_YAW;
return true;
}
return false;
}*/
/*
* @Override protected boolean doTask() { /** Move the arm rotation to idle position if the
* machine is not idling
*
* if (Math.abs(this.tileEntity.rotationPitch - IDLE_ROTATION_PITCH) > 0.01 ||
* Math.abs(this.tileEntity.rotationYaw - IDLE_ROTATION_YAW) > 0.01) { if
* (Math.abs(IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) > 0.125)
* this.tileEntity.rotationPitch += (IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) *
* 0.05; else this.tileEntity.rotationPitch += Math.signum(IDLE_ROTATION_PITCH -
* this.tileEntity.rotationPitch) * (0.125 * 0.05); if (Math.abs(this.tileEntity.rotationPitch -
* IDLE_ROTATION_PITCH) < 0.0125) this.tileEntity.rotationPitch = IDLE_ROTATION_PITCH;
*
* if (Math.abs(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) > 0.125)
* this.tileEntity.rotationYaw += (IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * 0.05; else
* this.tileEntity.rotationYaw += Math.signum(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) *
* (0.125 * 0.05); if (Math.abs(this.tileEntity.rotationYaw - IDLE_ROTATION_YAW) < 0.0125)
* this.tileEntity.rotationYaw = IDLE_ROTATION_YAW; return true; }
*
* return false; }
*/
}

View file

@ -1,6 +1,5 @@
package assemblyline.common.machine.command;
/**
* Rotates the armbot to a specific direction. If not specified, it will turn right.
*
@ -16,7 +15,7 @@ public class CommandRotate extends Command
public void onTaskStart()
{
super.onTaskStart();
this.ticks = 0;
if (this.getArg(0) != null)
@ -27,7 +26,7 @@ public class CommandRotate extends Command
{
this.targetRotationYaw = this.tileEntity.rotationYaw + 90;
}
if (this.getArg(1) != null)
{
this.targetRotationPitch = this.tileEntity.rotationPitch + this.getFloatArg(1);
@ -45,7 +44,7 @@ public class CommandRotate extends Command
{
this.targetRotationYaw += 360;
}
if (this.targetRotationPitch >= 60)
{
this.targetRotationPitch = 60;
@ -54,7 +53,7 @@ public class CommandRotate extends Command
{
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);
@ -64,37 +63,24 @@ public class CommandRotate extends Command
protected boolean doTask()
{
super.doTask();
/*float rotationalDifference = Math.abs(this.tileEntity.rotationYaw - this.targetRotation);
/*
* float rotationalDifference = Math.abs(this.tileEntity.rotationYaw - this.targetRotation);
*
* if (rotationalDifference < ROTATION_SPEED) { this.tileEntity.rotationYaw =
* this.targetRotation; } else { if (this.tileEntity.rotationYaw > this.targetRotation) {
* this.tileEntity.rotationYaw -= ROTATION_SPEED; } else { this.tileEntity.rotationYaw +=
* ROTATION_SPEED; } this.ticks = 0; }
*/
// set the rotation to the target immediately and let the client handle animating it
// wait for the client to catch up
if (rotationalDifference < ROTATION_SPEED)
{
this.tileEntity.rotationYaw = this.targetRotation;
}
else
{
if (this.tileEntity.rotationYaw > this.targetRotation)
{
this.tileEntity.rotationYaw -= ROTATION_SPEED;
}
else
{
this.tileEntity.rotationYaw += ROTATION_SPEED;
}
this.ticks = 0;
}*/
//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.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)
{
return true;
}
if (this.ticks < this.totalTicks) { return true; }
return false;
}

View file

@ -38,12 +38,12 @@ public class CommandUse extends Command
((IArmbotUseable) handTile).onUse(this.tileEntity, handEntity);
}
}
curTimes++;
if (curTimes >= times)
return false;
return true;
}
}

View file

@ -19,7 +19,7 @@ public class BlockImprinter extends BlockMachine
this.setCreativeTab(TabAssemblyLine.INSTANCE);
this.setTextureFile(AssemblyLine.BLOCK_TEXTURE_PATH);
}
@Override
public void onBlockAdded(World world, int x, int y, int z)
{

View file

@ -52,10 +52,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
@Override
public int getSizeInventorySide(ForgeDirection side)
{
if (side == ForgeDirection.UP || side == ForgeDirection.DOWN)
{
return 1;
}
if (side == ForgeDirection.UP || side == ForgeDirection.DOWN) { return 1; }
return INVENTORY_LENGTH;
}
@ -72,7 +69,8 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
}
/**
* Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a new stack.
* Removes from an inventory slot (first arg) up to a specified number (second arg) of items and
* returns them in a new stack.
*/
@Override
public ItemStack decrStackSize(int i, int amount)
@ -106,7 +104,8 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
}
/**
* When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - like when you close a workbench GUI.
* When some containers are closed they call this on each slot, then drop whatever it returns as
* an EntityItem - like when you close a workbench GUI.
*/
@Override
public ItemStack getStackInSlotOnClosing(int slot)
@ -124,7 +123,8 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
}
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor
* sections).
*/
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
@ -263,17 +263,11 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
{
if (object instanceof ShapedRecipes)
{
if (this.hasResource(((ShapedRecipes) object).recipeItems) != null)
{
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), ((ShapedRecipes) object).recipeItems);
}
if (this.hasResource(((ShapedRecipes) object).recipeItems) != null) { return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), ((ShapedRecipes) object).recipeItems); }
}
else if (object instanceof ShapelessRecipes)
{
if (this.hasResource(((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[1])) != null)
{
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), (ItemStack[]) ((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[1]));
}
if (this.hasResource(((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[1])) != null) { return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), (ItemStack[]) ((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[1])); }
}
else if (object instanceof ShapedOreRecipe)
{
@ -282,11 +276,9 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
ArrayList<ItemStack> hasResources = this.hasResource(oreRecipeInput);
if (hasResources != null)
{
if (hasResources != null) {
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), hasResources.toArray(new ItemStack[1]));
}
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), hasResources.toArray(new ItemStack[1])); }
}
else if (object instanceof ShapelessOreRecipe)
{
@ -295,10 +287,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
List<ItemStack> hasResources = this.hasResource(oreRecipeInput.toArray());
if (hasResources != null)
{
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), hasResources.toArray(new ItemStack[1]));
}
if (hasResources != null) { return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), hasResources.toArray(new ItemStack[1])); }
}
}
}
@ -446,7 +435,17 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
if (heldEntity instanceof EntityItem)
{
ItemStack stack = ((EntityItem) heldEntity).func_92014_d();
if (this.getStackInSlot(3) == null && stack != null && stack.itemID == AssemblyLine.itemImprint.itemID) // no crafting imprint and stack not null and stack is imprint
if (this.getStackInSlot(3) == null && stack != null && stack.itemID == AssemblyLine.itemImprint.itemID) // no
// crafting
// imprint
// and
// stack
// not
// null
// and
// stack
// is
// imprint
{
this.setInventorySlotContents(3, stack);
this.onInventoryChanged();