diff --git a/src/common/assemblyline/machines/crafter/ArmHelper.java b/src/common/assemblyline/ai/ArmHelper.java similarity index 97% rename from src/common/assemblyline/machines/crafter/ArmHelper.java rename to src/common/assemblyline/ai/ArmHelper.java index aaef68fa..184041bc 100644 --- a/src/common/assemblyline/machines/crafter/ArmHelper.java +++ b/src/common/assemblyline/ai/ArmHelper.java @@ -1,4 +1,4 @@ -package assemblyline.machines.crafter; +package assemblyline.ai; import java.util.List; diff --git a/src/common/assemblyline/belts/BlockConveyorBelt.java b/src/common/assemblyline/belts/BlockConveyorBelt.java index 83b48fac..3ad45b63 100644 --- a/src/common/assemblyline/belts/BlockConveyorBelt.java +++ b/src/common/assemblyline/belts/BlockConveyorBelt.java @@ -25,21 +25,11 @@ public class BlockConveyorBelt extends BlockMachine } @Override - public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLiving par5EntityLiving) + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving) { + int meta = world.getBlockMetadata(x, y, z); int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - par1World.setBlockMetadataWithNotify(x, y, z, angle); - /* - * switch (angle) { case 0: - * par1World.setBlockMetadataWithNotify(x, - * y, z, 0); break; case 1: - * par1World.setBlockMetadataWithNotify(x, - * y, z, 3); break; case 2: - * par1World.setBlockMetadataWithNotify(x, - * y, z, 1); break; case 3: - * par1World.setBlockMetadataWithNotify(x, - * y, z, 2); break; } - */ + world.setBlockMetadataWithNotify(x, y, z, meta + angle); } @Override @@ -47,7 +37,7 @@ public class BlockConveyorBelt extends BlockMachine { int metadata = par1World.getBlockMetadata(x, y, z); - if (metadata >= 0 && metadata < 4) + if (metadata >= 0 && metadata < 8) { if (metadata >= 3) { @@ -55,6 +45,12 @@ public class BlockConveyorBelt extends BlockMachine return true; } else + if (metadata >= 7) + { + par1World.setBlockAndMetadataWithNotify(x, y, z, this.blockID, 4); + return true; + } + else { par1World.setBlockAndMetadataWithNotify(x, y, z, this.blockID, metadata + 1); return true; @@ -71,6 +67,9 @@ public class BlockConveyorBelt extends BlockMachine public TileEntity createNewTileEntity(World var1, int metadata) { if (metadata >= 0 && metadata < 4) { return new TileEntityConveyorBelt(); } + if (metadata >= 4 && metadata < 8) { return new TileEntityCoveredBelt(); } + //if (metadata >= 8 && metadata < 12) { //TODO vertical Belt } + //if (metadata >= 12 && metadata < 16) { //TODO IDK} return null; } diff --git a/src/common/assemblyline/belts/TileEntityConveyorBelt.java b/src/common/assemblyline/belts/TileEntityConveyorBelt.java index 30b14e8e..cfcdae41 100644 --- a/src/common/assemblyline/belts/TileEntityConveyorBelt.java +++ b/src/common/assemblyline/belts/TileEntityConveyorBelt.java @@ -38,7 +38,8 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem private float speed = -0.045F; public float wheelRotation = 0; public boolean running = false; - public boolean flip = false; + public boolean textureFlip = false; + public boolean slantedBelt = false; public TileEntityConveyorBelt[] adjBelts = { null, null, null, null }; @@ -125,15 +126,35 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem if (this.running) { - - try - { - List entityOnTop = this.getEntityAbove(); + this.textureFlip = textureFlip ? false : true; + this.wheelRotation -= this.speed; + this.doBeltAction(); + } + } + /** + * almost unneeded but is change for each different belt type + */ + public void doBeltAction() + { + this.conveyItemsHorizontal(true,false); + } + /** + * Causes all items to be moved above the belt + * @param extendLife - increases the items life + * @param preventPickUp - prevent a player from picking the item up + */ + public void conveyItemsHorizontal(boolean extendLife, boolean preventPickUp ) + { + try + { + List entityOnTop = this.getEntityAbove(); - for (Entity entity : entityOnTop) + for (Entity entity : entityOnTop) + { + int direction = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + if (!this.entityIgnoreList.contains(entity)) { - int direction = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - if (!this.entityIgnoreList.contains(entity)) + if(!(entity instanceof EntityPlayer && ((EntityPlayer)entity).isSneaking())) { if (direction == 0) { @@ -152,42 +173,33 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem entity.motionX -= 1 * this.speed; } } - if (this.clearCount++ >= 4) + } + if (this.clearCount++ >= 4) + { + // clear the temp ignore + // list every 2 second + this.entityIgnoreList.clear(); + } + if (entity instanceof EntityItem) + { + EntityItem entityItem = (EntityItem) entity; + + if (extendLife && entityItem.age >= 1000) { - // clear the temp ignore - // list every 2 second - this.entityIgnoreList.clear(); + entityItem.age = 0; } - if (entity instanceof EntityItem) + if (preventPickUp && entityItem.delayBeforeCanPickup <= 1) { - EntityItem entityItem = (EntityItem) entity; - // Make sure the item - // doesn't decay/disappear - if (entityItem.age >= 1000) - { - entityItem.age = 0; - } + entityItem.delayBeforeCanPickup += 10; } } } - catch (Exception e) - { - e.printStackTrace(); - } - - if (flip == true) - { - flip = false; - } - else - { - flip = true; - } - - this.wheelRotation -= this.speed; } - } - + catch (Exception e) + { + e.printStackTrace(); + } + } @Override public Packet getDescriptionPacket() { diff --git a/src/common/assemblyline/belts/TileEntityCoveredBelt.java b/src/common/assemblyline/belts/TileEntityCoveredBelt.java new file mode 100644 index 00000000..d768e91a --- /dev/null +++ b/src/common/assemblyline/belts/TileEntityCoveredBelt.java @@ -0,0 +1,11 @@ +package assemblyline.belts; +/** + * For the moment this is just a render place holder, but will be + * convered to prevent item pickups from the belts. + * @author Rseifert + * + */ +public class TileEntityCoveredBelt extends TileEntityConveyorBelt +{ + +} diff --git a/src/common/assemblyline/belts/TileEntityElevatorBelt.java b/src/common/assemblyline/belts/TileEntityElevatorBelt.java new file mode 100644 index 00000000..d793dcfc --- /dev/null +++ b/src/common/assemblyline/belts/TileEntityElevatorBelt.java @@ -0,0 +1,51 @@ +package assemblyline.belts; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.src.Entity; +import net.minecraft.src.TileEntity; + +/** + * @author Rseifert + * + */ +public class TileEntityElevatorBelt extends TileEntityConveyorBelt +{ + public List conveyList = new ArrayList(); + + public void doBeltAction() + { + this.conveyItemsVertical(true,false); + } + /** + * Used to detect belt bellow for rendering + * and to prevent items from falling + * @return + */ + public boolean isBlockBellowBelt() + { + TileEntity ent = worldObj.getBlockTileEntity(xCoord, xCoord-1, zCoord); + if(ent instanceof TileEntityElevatorBelt) + { + return true; + } + return false; + } + + /** + * Same as conveyItemHorizontal but will pull, or lower the items up/down + * the belt like an elevator + * @param extendLife + * @param preventPickUp + */ + public void conveyItemsVertical(boolean extendLife, boolean preventPickUp ) + { + //TODO find all Entities in bounds + //Prevent entities from falling + //Find if can move up, only a few entities can be moved at a time, 1 EntityLiving, or 3 EntityItems + // ^ has to do with animation why only some not all move + //move those that can up + //IF top find belt, and/or throw slightly over the belt and back + } +}