Assembly Line Release 0.1.6

This commit is contained in:
Henry Mao 2012-12-15 21:55:34 +08:00
parent c8439b6590
commit 481b0d9852
10 changed files with 114 additions and 144 deletions

View file

@ -1 +1 @@
20
22

View file

@ -14,3 +14,6 @@ Minecraft 1.4.2
* AssemblyLine_v0.1.4.14.jar AssemblyLine_v0.1.4.14_api.zip
* AssemblyLine_v0.1.5.18.jar AssemblyLine_v0.1.5.18_api.zip
@ AssemblyLine_v0.1.6.19.jar AssemblyLine_v0.1.6.19_api.zip
@ AssemblyLine_v0.1.6.20.jar AssemblyLine_v0.1.6.20_api.zip
@ AssemblyLine_v0.1.6.21.jar AssemblyLine_v0.1.6.21_api.zip
* AssemblyLine_v0.1.6.22.jar AssemblyLine_v0.1.6.22_api.zip

View file

@ -1 +1 @@
0.1.5
0.1.6

View file

@ -3,12 +3,12 @@ package assemblyline.api;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraftforge.common.ForgeDirection;
/**
* An interface applied to the tile entity of a conveyor belt.
*
* @author Calclavia
*
*
*/
public interface IBelt
{

View file

@ -5,12 +5,10 @@ import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
import assemblyline.client.model.ModelConveyorBelt;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.belt.BlockConveyorBelt;
import assemblyline.common.machine.belt.BlockConveyorBelt.SlantType;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import assemblyline.common.machine.belt.TileEntityConveyorBelt.SlantType;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
@ -23,7 +21,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer
{
String flip = "";
boolean mid = tileEntity.getIsMiddleBelt();
SlantType slantType = BlockConveyorBelt.getSlant(tileEntity.worldObj, new Vector3(tileEntity));
SlantType slantType = tileEntity.getSlant();
int face = tileEntity.getDirection().ordinal();
GL11.glPushMatrix();

View file

@ -4,7 +4,6 @@ import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;

View file

@ -2,13 +2,10 @@ package assemblyline.common.block;
import java.util.List;
import assemblyline.common.AssemblyLine;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
public class ItemBlockCrate extends ItemBlock

View file

@ -1,9 +1,5 @@
package assemblyline.common.block;
import assemblyline.common.AssemblyLine;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -16,6 +12,9 @@ import net.minecraftforge.common.ISidedInventory;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager;
import universalelectricity.prefab.tile.TileEntityAdvanced;
import assemblyline.common.AssemblyLine;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityCrate extends TileEntityAdvanced implements ISidedInventory, IPacketReceiver
{
@ -203,7 +202,7 @@ public class TileEntityCrate extends TileEntityAdvanced implements ISidedInvento
var2.appendTag(var4);
}
}
nbt.setTag("Items", var2);
if (this.containingItems[0] != null)

View file

@ -2,17 +2,17 @@ package assemblyline.common.machine.belt;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.UETab;
import assemblyline.client.render.RenderHelper;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.belt.TileEntityConveyorBelt.SlantType;
/**
* The block for the actual conveyor belt!
@ -21,11 +21,6 @@ import assemblyline.common.AssemblyLine;
*/
public class BlockConveyorBelt extends BlockMachine
{
public enum SlantType
{
UP, DOWN
}
public BlockConveyorBelt(int id)
{
super("conveyorBelt", id, UniversalElectricity.machine);
@ -33,37 +28,6 @@ public class BlockConveyorBelt extends BlockMachine
this.setCreativeTab(UETab.INSTANCE);
}
/**
* Checks the front and the back position to find any conveyor blocks either higher or lower
* than this block to determine if it this conveyor block needs to slant.
*
* @return Returns of this belt is slanting up or down. Returns null if not slanting.
*/
public static SlantType getSlant(World world, Vector3 position)
{
TileEntity t = position.getTileEntity(world);
if (t != null)
{
if (t instanceof TileEntityConveyorBelt)
{
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) t;
Vector3 frontCheck = position.clone();
frontCheck.modifyPositionFromSide(tileEntity.getDirection());
Vector3 backCheck = position.clone();
backCheck.modifyPositionFromSide(tileEntity.getDirection().getOpposite());
if (Vector3.add(frontCheck, new Vector3(0, 1, 0)).getBlockID(world) == AssemblyLine.blockConveyorBelt.blockID && Vector3.add(backCheck, new Vector3(0, -1, 0)).getBlockID(world) == AssemblyLine.blockConveyorBelt.blockID)
{
return SlantType.UP;
}
else if (Vector3.add(frontCheck, new Vector3(0, -1, 0)).getBlockID(world) == AssemblyLine.blockConveyorBelt.blockID && Vector3.add(backCheck, new Vector3(0, 1, 0)).getBlockID(world) == AssemblyLine.blockConveyorBelt.blockID) { return SlantType.DOWN; }
}
}
return null;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving)
{
@ -116,10 +80,25 @@ public class BlockConveyorBelt extends BlockMachine
return true;
}
@Override
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) world.getBlockTileEntity(x, y, z);
int slantOrdinal = tileEntity.getSlant().ordinal() + 1;
if (slantOrdinal >= SlantType.values().length)
{
slantOrdinal = 0;
}
tileEntity.setSlant(SlantType.values()[slantOrdinal]);
return true;
}
/**
* Function WIP.
*
* @author AtomicStryker
* Moves the entity if the conductor is powered.
*/
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
@ -128,26 +107,43 @@ public class BlockConveyorBelt extends BlockMachine
if (tileEntity.running)
{
SlantType slantType = this.getSlant(world, new Vector3(x, y, z));
SlantType slantType = tileEntity.getSlant();
ForgeDirection direction = tileEntity.getDirection();
float modifier = 1;
if (entity instanceof EntityLiving)
{
modifier = 10;
}
// Move the entity based on the conveyor belt's direction.
entity.addVelocity(direction.offsetX * tileEntity.speed, 0, direction.offsetZ * tileEntity.speed);
entity.addVelocity(direction.offsetX * tileEntity.acceleration * modifier, 0, direction.offsetZ * tileEntity.acceleration * modifier);
if (direction.offsetX != 0 && Math.abs(entity.motionX) > Math.abs(direction.offsetX * tileEntity.maxSpeed))
{
entity.motionX = direction.offsetX * tileEntity.maxSpeed;
}
if (direction.offsetZ != 0 && Math.abs(entity.motionZ) > Math.abs(direction.offsetZ * tileEntity.maxSpeed))
{
entity.motionZ = direction.offsetZ * tileEntity.maxSpeed;
}
// Attempt to move entity to the center of the belt to prevent them from flying off.
if (direction.offsetX != 0)
{
double difference = (z + 0.5) - entity.posZ;
entity.motionZ += difference * 0.005;
entity.motionZ += difference * 0.01;
// entity.posZ = z + 0.5;
}
else if (direction.offsetZ != 0)
{
double difference = (x + 0.5) - entity.posX;
entity.motionX += difference * 0.005;
entity.motionX += difference * 0.01;
// entity.posX = z + 0.5;
}
entity.onGround = false;
if (slantType == SlantType.UP)
{
if (entity.motionY < 0.2)
@ -162,6 +158,13 @@ public class BlockConveyorBelt extends BlockMachine
entity.addVelocity(0, -0.1, 0);
}
}
if (entity instanceof EntityItem)
{
((EntityItem) entity).age++;
((EntityItem) entity).delayBeforeCanPickup = 2;
entity.onGround = false;
}
}
}

View file

@ -4,8 +4,8 @@ import java.util.EnumSet;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet250CustomPayload;
@ -19,7 +19,6 @@ import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager;
import universalelectricity.prefab.tile.TileEntityElectricityReceiver;
import assemblyline.api.ConveyorIgnore;
import assemblyline.api.IBelt;
import assemblyline.common.AssemblyLine;
@ -27,6 +26,11 @@ import com.google.common.io.ByteArrayDataInput;
public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implements IPacketReceiver, IBelt, IRotatable
{
public enum SlantType
{
NONE, UP, DOWN
}
/**
* Joules required to run this thing.
*/
@ -37,14 +41,15 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
*/
public double wattsReceived = 0;
public float speed = 0.02f;
public float acceleration = 0.01f;
public float maxSpeed = 0.2f;
public float wheelRotation = 0;
public boolean running = false;
public boolean textureFlip = false;
public TileEntityConveyorBelt[] adjBelts = { null, null, null, null };
public int powerTransferRange = 0;
private SlantType slantType = SlantType.NONE;
public TileEntityConveyorBelt()
{
@ -52,6 +57,23 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
ElectricityConnections.registerConnector(this, EnumSet.of(ForgeDirection.DOWN));
}
public SlantType getSlant()
{
return slantType;
}
public void setSlant(SlantType slantType)
{
if (slantType == null)
{
slantType = SlantType.NONE;
}
this.slantType = slantType;
PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj);
}
/**
* Steal power from nearby belts.
*
@ -128,7 +150,7 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
{
if (!worldObj.isRemote)
{
PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj, Vector3.get(this), 15);
PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj, new Vector3(this), 15);
}
if (this.wattsReceived >= WATT_REQUEST)
@ -160,87 +182,14 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
if (this.running)
{
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.getAffectedEntities();
for (Entity entity : entityOnTop)
{
int direction = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (!ConveyorIgnore.isIgnore(entity))
{
if (!(entity instanceof EntityPlayer && ((EntityPlayer) entity).isSneaking()))
{
if (direction == 0)
{
entity.motionZ -= 1 * this.speed;
// entity.posX = this.xCoord + 0.5D;
}
if (direction == 1)
{
entity.motionX += 1 * this.speed;
// entity.posZ = this.zCoord + 0.5D;
}
if (direction == 2)
{
entity.motionZ += 1 * this.speed;
// entity.posX = this.xCoord + 0.5D;
}
if (direction == 3)
{
entity.motionX -= 1 * this.speed;
// entity.posZ = this.zCoord + 0.5D;
}
}
}
if (entity instanceof EntityItem)
{
EntityItem entityItem = (EntityItem) entity;
if (extendLife && entityItem.age >= 1000)
{
entityItem.age = 0;
}
if (preventPickUp && entityItem.delayBeforeCanPickup <= 1)
{
entityItem.delayBeforeCanPickup += 10;
}
}
}
}
catch (Exception e)
{
e.printStackTrace();
this.wheelRotation -= this.maxSpeed;
}
}
@Override
public Packet getDescriptionPacket()
{
return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.wattsReceived);
return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.wattsReceived, this.slantType.ordinal());
}
/**
@ -310,6 +259,7 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
try
{
this.wattsReceived = dataStream.readDouble();
this.slantType = SlantType.values()[dataStream.readInt()];
}
catch (Exception e)
{
@ -337,4 +287,25 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1);
return worldObj.getEntitiesWithinAABB(Entity.class, bounds);
}
/**
* NBT Data
*/
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
this.slantType = SlantType.values()[nbt.getByte("slant")];
}
/**
* Writes a tile entity to NBT.
*/
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setByte("slant", (byte) this.slantType.ordinal());
}
}