nothing much

Started on new belts but to tired to doing anything with them. Will
continue tommorow after physics Class.

New Belts but still WIP
Covered Belt - prevents items from being picked up by player
Elevator Belt - moves items up
Slanted Belt - not new but a change to the normal belt
This commit is contained in:
Rseifert 2012-11-05 02:24:31 -05:00
parent 685f3c2507
commit b3174ce5a0
5 changed files with 125 additions and 52 deletions

View file

@ -1,4 +1,4 @@
package assemblyline.machines.crafter;
package assemblyline.ai;
import java.util.List;

View file

@ -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;
}

View file

@ -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<Entity> 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<Entity> 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()
{

View file

@ -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
{
}

View file

@ -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<Entity> conveyList = new ArrayList<Entity>();
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
}
}