Manipulators now work with multiblocks
This commit is contained in:
parent
179c92c3bb
commit
2cda43b63c
26 changed files with 503 additions and 474 deletions
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
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
|
||||
*
|
||||
*/
|
||||
|
@ -14,8 +14,9 @@ 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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -8,7 +8,6 @@ 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
|
||||
{
|
||||
|
@ -152,9 +151,9 @@ public class ModelRejectorPiston extends ModelBase
|
|||
|
||||
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.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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
|
@ -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 };
|
||||
|
||||
|
|
|
@ -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 }; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -6,9 +6,7 @@ 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
|
||||
{
|
||||
|
@ -46,17 +44,20 @@ public class CommandManager
|
|||
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
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package assemblyline.common.machine.command;
|
||||
|
||||
|
||||
public class CommandReturn extends CommandRotate
|
||||
{
|
||||
public static final float IDLE_ROTATION_PITCH = 0;
|
||||
|
@ -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
|
||||
/*
|
||||
* @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;
|
||||
}*/
|
||||
* 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; }
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package assemblyline.common.machine.command;
|
||||
|
||||
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue