Released 0.1.0!

This commit is contained in:
Calclavia 2012-10-28 21:56:50 +08:00
parent 4242c45a9f
commit 8fef86026c
5 changed files with 123 additions and 61 deletions

View file

@ -1 +1 @@
1 3

View file

@ -1 +1,3 @@
x AssemblyLine_v0.0.6.1.jar @ AssemblyLine_v0.0.6.1.jar
@ AssemblyLine_v0.0.6.2.jar
* AssemblyLine_v0.0.6.3.jar

View file

@ -40,7 +40,7 @@ echo %PROMOTION% %FILE_NAME%>>info.txt
::GENERATE FTP Script ::GENERATE FTP Script
echo open www.calclavia.com>ftpscript.txt echo open www.calclavia.com>ftpscript.txt
echo al@calclavia.com>>ftpscript.txt echo al@calclavia.com>>ftpscript.txt
echo f@Gwk%qFJ4kc>>ftpscript.txt echo VkE4laBa84R9>>ftpscript.txt
echo binary>>ftpscript.txt echo binary>>ftpscript.txt
echo put "builds\%FILE_NAME%">>ftpscript.txt echo put "builds\%FILE_NAME%">>ftpscript.txt
::echo put "builds\%API_NAME%">>ftpscript.txt ::echo put "builds\%API_NAME%">>ftpscript.txt

View file

@ -167,8 +167,6 @@ public class BlockMulti extends BlockMachine
if (!par1World.isRemote) if (!par1World.isRemote)
{ {
par5EntityPlayer.addChatMessage("Manipulator Output: " + tileEntity.isOutput);
PacketDispatcher.sendPacketToAllPlayers(tileEntity.getDescriptionPacket()); PacketDispatcher.sendPacketToAllPlayers(tileEntity.getDescriptionPacket());
} }
return true; return true;

View file

@ -71,6 +71,12 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
*/ */
Vector3 inputPosition = Vector3.get(this); Vector3 inputPosition = Vector3.get(this);
Vector3 outputUp = Vector3.get(this);
outputUp.modifyPositionFromSide(ForgeDirection.UP);
Vector3 outputDown = Vector3.get(this);
outputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 outputPosition = Vector3.get(this); Vector3 outputPosition = Vector3.get(this);
outputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite()); outputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite());
@ -79,7 +85,24 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
for (EntityItem entity : itemsInBound) for (EntityItem entity : itemsInBound)
{ {
ItemStack remainingStack = this.tryPlaceInPosition(entity.item.copy(), outputPosition); /**
* Try top first, then
* bottom, then the sides
* to see if it is
* possible to insert the
* item into a inventory.
*/
ItemStack remainingStack = this.tryPlaceInPosition(entity.item.copy(), outputUp, ForgeDirection.DOWN);
if (remainingStack != null)
{
remainingStack = this.tryPlaceInPosition(remainingStack, outputDown, ForgeDirection.UP);
}
if (remainingStack != null)
{
remainingStack = this.tryPlaceInPosition(remainingStack, outputPosition, this.getBeltDirection().getOpposite());
}
if (remainingStack != null) if (remainingStack != null)
{ {
@ -88,6 +111,7 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
EntityItem entityItem = new EntityItem(worldObj, outputPosition.x + 0.5, outputPosition.y + 0.8, outputPosition.z + 0.5, remainingStack); EntityItem entityItem = new EntityItem(worldObj, outputPosition.x + 0.5, outputPosition.y + 0.8, outputPosition.z + 0.5, remainingStack);
entityItem.motionX = 0; entityItem.motionX = 0;
entityItem.motionZ = 0; entityItem.motionZ = 0;
entityItem.motionY /= 5;
worldObj.spawnEntityInWorld(entityItem); worldObj.spawnEntityInWorld(entityItem);
} }
} }
@ -98,19 +122,38 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
else else
{ {
/** /**
* Finds the connected inventory and outputs the items upon a redstone pulse. * Finds the connected
* inventory and outputs the
* items upon a redstone
* pulse.
*/ */
if (this.isPowered) if (this.isPowered)
{ {
this.onPowerOff(); this.onPowerOff();
Vector3 inputUp = Vector3.get(this);
inputUp.modifyPositionFromSide(ForgeDirection.UP);
Vector3 inputDown = Vector3.get(this);
inputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 inputPosition = Vector3.get(this); Vector3 inputPosition = Vector3.get(this);
inputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite()); inputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite());
Vector3 outputPosition = Vector3.get(this); Vector3 outputPosition = Vector3.get(this);
outputPosition.modifyPositionFromSide(this.getBeltDirection()); outputPosition.modifyPositionFromSide(this.getBeltDirection());
ItemStack itemStack = this.tryGrabFromPosition(inputPosition); ItemStack itemStack = this.tryGrabFromPosition(inputUp, ForgeDirection.DOWN);
if (itemStack == null)
{
itemStack = this.tryGrabFromPosition(inputDown, ForgeDirection.UP);
}
if (itemStack == null)
{
itemStack = this.tryGrabFromPosition(inputPosition, this.getBeltDirection().getOpposite());
}
if (itemStack != null) if (itemStack != null)
{ {
@ -119,7 +162,7 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
EntityItem entityItem = new EntityItem(worldObj, outputPosition.x + 0.5, outputPosition.y + 0.8, outputPosition.z + 0.5, itemStack); EntityItem entityItem = new EntityItem(worldObj, outputPosition.x + 0.5, outputPosition.y + 0.8, outputPosition.z + 0.5, itemStack);
entityItem.motionX = 0; entityItem.motionX = 0;
entityItem.motionZ = 0; entityItem.motionZ = 0;
entityItem.motionY /= 4; entityItem.motionY /= 5;
worldObj.spawnEntityInWorld(entityItem); worldObj.spawnEntityInWorld(entityItem);
} }
} }
@ -138,7 +181,7 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
* @return The ItemStack remained after place * @return The ItemStack remained after place
* attempt * attempt
*/ */
private ItemStack tryPlaceInPosition(ItemStack itemStack, Vector3 position) private ItemStack tryPlaceInPosition(ItemStack itemStack, Vector3 position, ForgeDirection direction)
{ {
TileEntity tileEntity = position.getTileEntity(this.worldObj); TileEntity tileEntity = position.getTileEntity(this.worldObj);
@ -161,19 +204,23 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
Vector3 searchPosition = position.clone(); Vector3 searchPosition = position.clone();
searchPosition.modifyPositionFromSide(searchDirection); searchPosition.modifyPositionFromSide(searchDirection);
if (searchPosition.getTileEntity(this.worldObj) instanceof TileEntityChest) if (searchPosition.getTileEntity(this.worldObj) != null)
{
if (searchPosition.getTileEntity(this.worldObj).getClass() == chests[0].getClass())
{ {
chests[1] = (TileEntityChest) searchPosition.getTileEntity(this.worldObj); chests[1] = (TileEntityChest) searchPosition.getTileEntity(this.worldObj);
break; break;
} }
} }
}
for (TileEntityChest chest : chests) for (TileEntityChest chest : chests)
{ {
for (int i = 0; i < chest.getSizeInventory(); i++) for (int i = 0; i < chest.getSizeInventory(); i++)
{ {
itemStack = this.addStackToInventory(i, chest, itemStack); itemStack = this.addStackToInventory(i, chest, itemStack);
if(itemStack == null) return null; if (itemStack == null)
return null;
} }
} }
} }
@ -181,12 +228,12 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
{ {
ISidedInventory inventory = (ISidedInventory) tileEntity; ISidedInventory inventory = (ISidedInventory) tileEntity;
int startIndex = inventory.getStartInventorySide(this.getBeltDirection()); int startIndex = inventory.getStartInventorySide(direction);
for (int i = startIndex; i < inventory.getSizeInventorySide(this.getBeltDirection()); i++) for (int i = startIndex; i < startIndex + inventory.getSizeInventorySide(direction); i++)
{ {
itemStack = this.addStackToInventory(startIndex, inventory, itemStack); itemStack = this.addStackToInventory(startIndex, inventory, itemStack);
if(itemStack == null) return null; if (itemStack == null) { return null; }
} }
} }
else if (tileEntity instanceof IInventory) else if (tileEntity instanceof IInventory)
@ -196,7 +243,7 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
for (int i = 0; i < inventory.getSizeInventory(); i++) for (int i = 0; i < inventory.getSizeInventory(); i++)
{ {
itemStack = this.addStackToInventory(i, inventory, itemStack); itemStack = this.addStackToInventory(i, inventory, itemStack);
if(itemStack == null) return null; if (itemStack == null) { return null; }
} }
} }
} }
@ -208,32 +255,38 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
public ItemStack addStackToInventory(int slotIndex, IInventory inventory, ItemStack itemStack) public ItemStack addStackToInventory(int slotIndex, IInventory inventory, ItemStack itemStack)
{ {
ItemStack stackInChest = inventory.getStackInSlot(slotIndex); if (inventory.getSizeInventory() > slotIndex)
{
ItemStack stackInInventory = inventory.getStackInSlot(slotIndex);
if (stackInChest == null) if (stackInInventory == null)
{ {
inventory.setInventorySlotContents(slotIndex, itemStack); inventory.setInventorySlotContents(slotIndex, itemStack);
return null; return null;
} }
else if (stackInChest.getItem().equals(itemStack.getItem()) && stackInChest.getItemDamage() == itemStack.getItemDamage()) else if (stackInInventory.isItemEqual(itemStack))
{ {
int rejectedAmount = Math.max((stackInChest.stackSize + itemStack.stackSize) - stackInChest.getItem().getItemStackLimit(), 0); int rejectedAmount = Math.max((stackInInventory.stackSize + itemStack.stackSize) - stackInInventory.getItem().getItemStackLimit(), 0);
stackInChest.stackSize = Math.min(Math.max((stackInChest.stackSize + itemStack.stackSize - rejectedAmount), 0), stackInChest.getItem().getItemStackLimit()); stackInInventory.stackSize = Math.min(Math.max((stackInInventory.stackSize + itemStack.stackSize - rejectedAmount), 0), stackInInventory.getItem().getItemStackLimit());
itemStack.stackSize = rejectedAmount; itemStack.stackSize = rejectedAmount;
inventory.setInventorySlotContents(slotIndex, stackInChest); inventory.setInventorySlotContents(slotIndex, stackInInventory);
}
}
if (itemStack.stackSize <= 0) { return null; } if (itemStack.stackSize <= 0) { return null; }
}
return itemStack; return itemStack;
} }
/** /**
* Tries to take a item from a inventory at a specific position. * Tries to take a item from a inventory at a
* specific position.
*
* @param position * @param position
* @return * @return
*/ */
private ItemStack tryGrabFromPosition(Vector3 position) private ItemStack tryGrabFromPosition(Vector3 position, ForgeDirection direction)
{ {
TileEntity tileEntity = position.getTileEntity(this.worldObj); TileEntity tileEntity = position.getTileEntity(this.worldObj);
@ -256,19 +309,26 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
Vector3 searchPosition = position.clone(); Vector3 searchPosition = position.clone();
searchPosition.modifyPositionFromSide(searchDirection); searchPosition.modifyPositionFromSide(searchDirection);
if (searchPosition.getTileEntity(this.worldObj) != null)
{
if (searchPosition.getTileEntity(this.worldObj).getClass() == chests[0].getClass()) if (searchPosition.getTileEntity(this.worldObj).getClass() == chests[0].getClass())
{ {
chests[1] = (TileEntityChest) searchPosition.getTileEntity(this.worldObj); chests[1] = (TileEntityChest) searchPosition.getTileEntity(this.worldObj);
break; break;
} }
} }
}
for (TileEntityChest chest : chests) for (TileEntityChest chest : chests)
{
if (chest != null)
{ {
for (int i = 0; i < chest.getSizeInventory(); i++) for (int i = 0; i < chest.getSizeInventory(); i++)
{ {
ItemStack itemStack = this.removeStackFromInventory(i, chest); ItemStack itemStack = this.removeStackFromInventory(i, chest);
if(itemStack != null) return itemStack; if (itemStack != null)
return itemStack;
}
} }
} }
} }
@ -276,12 +336,13 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
{ {
ISidedInventory inventory = (ISidedInventory) tileEntity; ISidedInventory inventory = (ISidedInventory) tileEntity;
int startIndex = inventory.getStartInventorySide(this.getBeltDirection()); int startIndex = inventory.getStartInventorySide(direction);
for (int i = startIndex; i < inventory.getSizeInventorySide(this.getBeltDirection()); i++) for (int i = startIndex; i < startIndex + inventory.getSizeInventorySide(direction); i++)
{ {
ItemStack itemStack = this.removeStackFromInventory(i, inventory); ItemStack itemStack = this.removeStackFromInventory(i, inventory);
if(itemStack != null) return itemStack; if (itemStack != null)
return itemStack;
} }
} }
else if (tileEntity instanceof IInventory) else if (tileEntity instanceof IInventory)
@ -291,7 +352,8 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
for (int i = 0; i < inventory.getSizeInventory(); i++) for (int i = 0; i < inventory.getSizeInventory(); i++)
{ {
ItemStack itemStack = this.removeStackFromInventory(i, inventory); ItemStack itemStack = this.removeStackFromInventory(i, inventory);
if(itemStack != null) return itemStack; if (itemStack != null)
return itemStack;
} }
} }
} }