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

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); baseTop.render(f5);

View file

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

View file

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

View file

@ -11,7 +11,8 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side; 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 * @author Calclavia
* *

View file

@ -14,6 +14,7 @@ import net.minecraftforge.common.ISidedInventory;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRedstoneReceptor; import universalelectricity.prefab.implement.IRedstoneReceptor;
import universalelectricity.prefab.implement.IRotatable; import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.multiblock.TileEntityMulti;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
import assemblyline.api.IManipulator; import assemblyline.api.IManipulator;
import assemblyline.common.machine.imprinter.TileEntityFilterable; 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 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? * 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() 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 @Override
public void inject() public void inject()
@ -110,7 +112,8 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
if (entity.isDead) if (entity.isDead)
continue; 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(); 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. * 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 }; TileEntityChest[] chests = { (TileEntityChest) tileEntity, null };
@ -323,7 +343,17 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
/** /**
* Try to put items into a chest. * 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 }; 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 public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMultiBlock, IInventory, IPacketReceiver, IJouleStorage, IPeripheral
{ {
private final CommandManager commandManager = new CommandManager(); private final CommandManager commandManager = new CommandManager();
private static final int PACKET_COMMANDS = 128; private static final int PACKET_COMMANDS = 128;
/** /**
* The items this container contains. * The items this container contains.
*/ */
protected ItemStack disk = null; protected ItemStack disk = null;
public final double WATT_REQUEST = 20; public final double WATT_REQUEST = 20;
public double wattsReceived = 0; public double wattsReceived = 0;
private int playerUsing = 0; private int playerUsing = 0;
private int computersAttached = 0; private int computersAttached = 0;
private List<IComputerAccess> connectedComputers = new ArrayList<IComputerAccess>(); private List<IComputerAccess> connectedComputers = new ArrayList<IComputerAccess>();
/** /**
* The rotation of the arms. In Degrees. * The rotation of the arms. In Degrees.
*/ */
public float rotationPitch = 0; public float rotationPitch = 0;
public float rotationYaw = 0; public float rotationYaw = 0;
public float renderPitch = 0; public float renderPitch = 0;
public float renderYaw = 0; public float renderYaw = 0;
private int ticksSincePower = 0; private int ticksSincePower = 0;
public final float ROTATION_SPEED = 1.3f; public final float ROTATION_SPEED = 1.3f;
/** /**
* An entity that the armbot is grabbed onto. * 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 @Override
public void initiate() public void initiate()
@ -215,7 +215,13 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
this.renderYaw -= 360; 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); 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) 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; 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); 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) 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; double distance = 1f;
Vector3 delta = new Vector3(); Vector3 delta = new Vector3();
// The delta Y of the hand. // 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. // The horizontal delta of the hand.
double dH = Math.cos(Math.toRadians(this.renderPitch)) * distance; double dH = Math.cos(Math.toRadians(this.renderPitch)) * distance;
// The delta X and Z. // The delta X and Z.
@ -666,7 +680,8 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
{ {
return new Object[] { this.commandManager.hasTasks() }; 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(); 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)); 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++) 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 }; } { return new Object[] { true }; }
} }
} }

View file

@ -1,7 +1,6 @@
package assemblyline.common.machine.belt; package assemblyline.common.machine.belt;
import java.util.List; import java.util.List;
import java.util.Random;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
@ -68,14 +67,8 @@ public class BlockConveyorBelt extends BlockMachine
{ {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) t; TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) t;
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN) 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 + 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); 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);

View file

@ -3,7 +3,6 @@ package assemblyline.common.machine.belt;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; 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 @Override
public void updatePowerTransferRange() public void updatePowerTransferRange()
@ -119,8 +119,11 @@ 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)
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "assemblyline.conveyor", 0.5f, 0.3f, true); {
// 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; this.wheelRotation += 40;

View file

@ -1,6 +1,5 @@
package assemblyline.common.machine.command; package assemblyline.common.machine.command;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
@ -23,7 +22,8 @@ public class CommandDrop extends Command
entity.worldObj = this.tileEntity.worldObj; entity.worldObj = this.tileEntity.worldObj;
if (entity instanceof EntityItem) if (entity instanceof EntityItem)
if (!world.isRemote) 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); 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

@ -11,13 +11,13 @@ import universalelectricity.core.vector.Vector3;
public class CommandFire extends Command public class CommandFire extends Command
{ {
private static final float MIN_ACTUAL_PITCH = -80; private static final float MIN_ACTUAL_PITCH = -80;
private static final float MAX_ACTUAL_PITCH = 80; private static final float MAX_ACTUAL_PITCH = 80;
private float actualYaw; private float actualYaw;
private float actualPitch; private float actualPitch;
private float velocity; private float velocity;
private Vector3 finalVelocity; private Vector3 finalVelocity;
@Override @Override
public void onTaskStart() public void onTaskStart()

View file

@ -45,11 +45,22 @@ public class CommandGrab extends Command
{ {
for (int i = 0; i < found.size(); i++) 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)); this.tileEntity.grabbedEntities.add(found.get(i));
if (found.get(i) instanceof EntityItem) 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); 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; found.get(i).isDead = false;
return false; return false;

View file

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

View file

@ -6,17 +6,15 @@ import java.util.List;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import assemblyline.common.machine.armbot.TileEntityArmbot; import assemblyline.common.machine.armbot.TileEntityArmbot;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.relauncher.Side;
public class CommandManager 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 ticks = 0;
private int currentTask = 0; private int currentTask = 0;
private int lastTask = -1; private int lastTask = -1;
/** /**
* Must be called every tick by a tileEntity. * Must be called every tick by a tileEntity.
@ -46,17 +44,20 @@ public class CommandManager
task.onTaskStart(); task.onTaskStart();
} }
//if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) // 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)); // 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())
{ {
int tempCurrentTask = this.currentTask; int tempCurrentTask = this.currentTask;
task.onTaskEnd(); task.onTaskEnd();
this.currentTask++; 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())); 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 tileEntity TE instance to register the task for
* @param newCommand Task instance to register * @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. * The amount of tasks above this task to repeat.
*/ */
private int tasksToRepeat; private int tasksToRepeat;
private int numReps; private int numReps;
private int curReps; private int curReps;
private boolean initialized = false; private boolean initialized = false;
public void onTaskStart() public void onTaskStart()
{ {

View file

@ -1,6 +1,5 @@
package assemblyline.common.machine.command; package assemblyline.common.machine.command;
public class CommandReturn extends CommandRotate public class CommandReturn extends CommandRotate
{ {
public static final float IDLE_ROTATION_PITCH = 0; public static final float IDLE_ROTATION_PITCH = 0;
@ -16,31 +15,25 @@ public class CommandReturn extends CommandRotate
this.totalTicks = Math.max(totalTicksYaw, totalTicksPitch); this.totalTicks = Math.max(totalTicksYaw, totalTicksPitch);
} }
/*@Override /*
protected boolean doTask() * @Override protected boolean doTask() { /** Move the arm rotation to idle position if the
{ * machine is not idling
/** *
* 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
if (Math.abs(this.tileEntity.rotationPitch - IDLE_ROTATION_PITCH) > 0.01 || Math.abs(this.tileEntity.rotationYaw - IDLE_ROTATION_YAW) > 0.01) * (Math.abs(IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) > 0.125)
{ * this.tileEntity.rotationPitch += (IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) *
if (Math.abs(IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) > 0.125) * 0.05; else this.tileEntity.rotationPitch += Math.signum(IDLE_ROTATION_PITCH -
this.tileEntity.rotationPitch += (IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) * 0.05; * this.tileEntity.rotationPitch) * (0.125 * 0.05); if (Math.abs(this.tileEntity.rotationPitch -
else * IDLE_ROTATION_PITCH) < 0.0125) this.tileEntity.rotationPitch = IDLE_ROTATION_PITCH;
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) * if (Math.abs(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) > 0.125)
this.tileEntity.rotationPitch = IDLE_ROTATION_PITCH; * this.tileEntity.rotationYaw += (IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * 0.05; else
* this.tileEntity.rotationYaw += Math.signum(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) *
if (Math.abs(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) > 0.125) * (0.125 * 0.05); if (Math.abs(this.tileEntity.rotationYaw - IDLE_ROTATION_YAW) < 0.0125)
this.tileEntity.rotationYaw += (IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * 0.05; * this.tileEntity.rotationYaw = IDLE_ROTATION_YAW; return true; }
else *
this.tileEntity.rotationYaw += Math.signum(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * (0.125 * 0.05); * return false; }
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; package assemblyline.common.machine.command;
/** /**
* Rotates the armbot to a specific direction. If not specified, it will turn right. * Rotates the armbot to a specific direction. If not specified, it will turn right.
* *
@ -64,37 +63,24 @@ public class CommandRotate extends Command
protected boolean doTask() protected boolean doTask()
{ {
super.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; }
*/
if (rotationalDifference < ROTATION_SPEED) // set the rotation to the target immediately and let the client handle animating it
{ // wait for the client to catch up
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) 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)
this.tileEntity.rotationPitch = this.targetRotationPitch; this.tileEntity.rotationPitch = this.targetRotationPitch;
if (this.ticks < this.totalTicks) if (this.ticks < this.totalTicks) { return true; }
{
return true;
}
return false; return false;
} }

View file

@ -52,10 +52,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
@Override @Override
public int getSizeInventorySide(ForgeDirection side) public int getSizeInventorySide(ForgeDirection side)
{ {
if (side == ForgeDirection.UP || side == ForgeDirection.DOWN) if (side == ForgeDirection.UP || side == ForgeDirection.DOWN) { return 1; }
{
return 1;
}
return INVENTORY_LENGTH; 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 @Override
public ItemStack decrStackSize(int i, int amount) 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 @Override
public ItemStack getStackInSlotOnClosing(int slot) 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 @Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
@ -263,17 +263,11 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
{ {
if (object instanceof ShapedRecipes) if (object instanceof ShapedRecipes)
{ {
if (this.hasResource(((ShapedRecipes) object).recipeItems) != null) if (this.hasResource(((ShapedRecipes) object).recipeItems) != null) { return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), ((ShapedRecipes) object).recipeItems); }
{
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), ((ShapedRecipes) object).recipeItems);
}
} }
else if (object instanceof ShapelessRecipes) else if (object instanceof ShapelessRecipes)
{ {
if (this.hasResource(((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[1])) != null) 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])); }
{
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), (ItemStack[]) ((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[1]));
}
} }
else if (object instanceof ShapedOreRecipe) else if (object instanceof ShapedOreRecipe)
{ {
@ -282,11 +276,9 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
ArrayList<ItemStack> hasResources = this.hasResource(oreRecipeInput); 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) else if (object instanceof ShapelessOreRecipe)
{ {
@ -295,10 +287,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
List<ItemStack> hasResources = this.hasResource(oreRecipeInput.toArray()); List<ItemStack> hasResources = this.hasResource(oreRecipeInput.toArray());
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]));
}
} }
} }
} }
@ -446,7 +435,17 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
if (heldEntity instanceof EntityItem) if (heldEntity instanceof EntityItem)
{ {
ItemStack stack = ((EntityItem) heldEntity).func_92014_d(); 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.setInventorySlotContents(3, stack);
this.onInventoryChanged(); this.onInventoryChanged();