Belt Direction Fix

This commit is contained in:
Henry Mao 2012-12-15 12:53:22 +08:00
parent 75bf4c9244
commit f7968b4729
7 changed files with 244 additions and 225 deletions

View file

@ -0,0 +1,30 @@
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);
}
}

View file

@ -5,24 +5,13 @@ import java.util.List;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
/**
* An interface applied to the tile entity of a conveyor belt.
* @author Calclavia
*
*/
public interface IBelt public interface IBelt
{ {
/**
* Gets the facing direction of the belt, used but other machines to know which direction to
* start an item at
*
* @return
*/
public ForgeDirection getFacing();
/**
* Causes the belt to ignore the entity for a few updates help in cases where another machine
* needs to affect this particular entity without the belt interfering
*
* @param entity - entity being ignored
*/
public void ignoreEntity(Entity entity);
/** /**
* Used to get a list of entities the belt exerts an effect upon. * Used to get a list of entities the belt exerts an effect upon.
* *

View file

@ -18,32 +18,23 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer
private void renderAModelAt(TileEntityConveyorBelt tileEntity, double x, double y, double z, float f) private void renderAModelAt(TileEntityConveyorBelt tileEntity, double x, double y, double z, float f)
{ {
String flip = "";// if(tileEntity.flip){flip String flip = "";
// = "F";}
boolean mid = tileEntity.getIsMiddleBelt(); boolean mid = tileEntity.getIsMiddleBelt();
int face = tileEntity.getBeltDirection(); int face = tileEntity.getDirection().ordinal();
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glRotatef(180f, 0f, 0f, 1f); GL11.glRotatef(180f, 0f, 0f, 1f);
bindTextureByName(AssemblyLine.TEXTURE_PATH + "BeltTexture" + flip + ".png"); this.bindTextureByName(AssemblyLine.TEXTURE_PATH + "BeltTexture" + flip + ".png");
if (face == 2) switch(face)
{ {
GL11.glRotatef(180f, 0f, 1f, 0f); case 2: GL11.glRotatef(0f, 0f, 1f, 0f);break;
} case 3: GL11.glRotatef(180f, 0f, 1f, 0f);break;
else if (face == 3) case 4: GL11.glRotatef(-90f, 0f, 1f, 0f);break;
{ case 5: GL11.glRotatef(90f, 0f, 1f, 0f);break;
GL11.glRotatef(0f, 0f, 1f, 0f);
}
else if (face == 4)
{
GL11.glRotatef(90f, 0f, 1f, 0f);
}
else if (face == 5)
{
GL11.glRotatef(270f, 0f, 1f, 0f);
} }
int ent = tileEntity.worldObj.getBlockId(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); int ent = tileEntity.worldObj.getBlockId(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
model.render(0.0625F, (float) Math.toRadians(tileEntity.wheelRotation), tileEntity.getIsBackCap(), tileEntity.getIsFrontCap(), false); model.render(0.0625F, (float) Math.toRadians(tileEntity.wheelRotation), tileEntity.getIsBackCap(), tileEntity.getIsFrontCap(), false);

View file

@ -1,17 +1,64 @@
package assemblyline.common.block; package assemblyline.common.block;
import assemblyline.common.AssemblyLine;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory; import net.minecraftforge.common.ISidedInventory;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager;
import universalelectricity.prefab.tile.TileEntityAdvanced; import universalelectricity.prefab.tile.TileEntityAdvanced;
public class TileEntityCrate extends TileEntityAdvanced implements ISidedInventory public class TileEntityCrate extends TileEntityAdvanced implements ISidedInventory, IPacketReceiver
{ {
public ItemStack[] containingItems = new ItemStack[1]; public ItemStack[] containingItems = new ItemStack[1];
@Override
public boolean canUpdate()
{
return false;
}
@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
{
if (this.worldObj.isRemote)
{
try
{
if (this.containingItems[0] == null)
{
this.containingItems[0] = new ItemStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
}
else
{
this.containingItems[0].itemID = dataStream.readInt();
this.containingItems[0].stackSize = dataStream.readInt();
this.containingItems[0].setItemDamage(dataStream.readInt());
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
@Override
public Packet getDescriptionPacket()
{
if (this.containingItems[0] != null) { return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.containingItems[0].itemID, this.containingItems[0].stackSize, this.containingItems[0].getItemDamage()); }
return null;
}
/** /**
* Inventory functions. * Inventory functions.
*/ */
@ -75,6 +122,11 @@ public class TileEntityCrate extends TileEntityAdvanced implements ISidedInvento
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{ {
par2ItemStack.stackSize = this.getInventoryStackLimit(); par2ItemStack.stackSize = this.getInventoryStackLimit();
if (!this.worldObj.isRemote)
{
PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj);
}
} }
} }
@ -168,5 +220,4 @@ public class TileEntityCrate extends TileEntityAdvanced implements ISidedInvento
{ {
return 1; return 1;
} }
} }

View file

@ -176,11 +176,12 @@ public class TileEntityRejector extends TileEntityElectricityReceiver implements
public void throwItem(ForgeDirection side, Entity entity) public void throwItem(ForgeDirection side, Entity entity)
{ {
this.firePiston = true; this.firePiston = true;
if (this.beltSide != null) if (this.beltSide != null)
{ {
this.beltSide.ignoreEntity(entity); // this.beltSide.ignoreEntity(entity);
} }
entity.motionX = (double) side.offsetX * 0.15; entity.motionX = (double) side.offsetX * 0.15;
entity.motionY += 0.10000000298023224D; entity.motionY += 0.10000000298023224D;
entity.motionZ = (double) side.offsetZ * 0.15; entity.motionZ = (double) side.offsetZ * 0.15;

View file

@ -6,7 +6,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.UniversalElectricity; import universalelectricity.core.UniversalElectricity;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.BlockMachine; import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.UETab; import universalelectricity.prefab.UETab;
import assemblyline.client.render.RenderHelper; import assemblyline.client.render.RenderHelper;
@ -25,152 +27,128 @@ public class BlockConveyorBelt extends BlockMachine
this.setCreativeTab(UETab.INSTANCE); this.setCreativeTab(UETab.INSTANCE);
} }
@Override /**
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving) * Is this conveyor belt slanted towards a direction?
*
* @return The ForgeDirection in which this conveyor belt is slanting against. The direction
* given is the high point of the slant. Return Unknown if not slanting.
*/
public ForgeDirection getSlant(World world, Vector3 position)
{ {
int meta = world.getBlockMetadata(x, y, z); TileEntity t = position.getTileEntity(world);
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockMetadataWithNotify(x, y, z, meta + angle); if (t != null)
{
if (t instanceof TileEntityConveyorBelt)
{
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) t;
Vector3 highCheck = position.clone();
highCheck.modifyPositionFromSide(tileEntity.getDirection());
}
}
return ForgeDirection.UNKNOWN;
} }
@Override @Override
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving)
{ {
int metadata = par1World.getBlockMetadata(x, y, z); int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int change = 2;
if (metadata >= 0 && metadata < 8) switch (angle)
{ {
if (metadata >= 3) case 0:
{ change = 3;
par1World.setBlockAndMetadataWithNotify(x, y, z, this.blockID, 0); break;
return true; case 1:
} change = 4;
else if (metadata >= 7) break;
{ case 2:
par1World.setBlockAndMetadataWithNotify(x, y, z, this.blockID, 4); change = 2;
return true; break;
} case 3:
else change = 5;
{ break;
par1World.setBlockAndMetadataWithNotify(x, y, z, this.blockID, metadata + 1);
return true;
}
} }
world.setBlockMetadataWithNotify(x, y, z, change);
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
int original = world.getBlockMetadata(x, y, z);
int change = 2;
switch (original)
{
case 2:
change = 5;
break;
case 5:
change = 4;
break;
case 4:
change = 3;
break;
case 3:
change = 2;
break;
}
world.setBlockMetadataWithNotify(x, y, z, change);
return true; return true;
} }
/** /**
* Function WIP.
*
* @author AtomicStryker * @author AtomicStryker
*/ */
// @Override @Override
public void onEntityCollidedWithBlockTest(World world, int x, int y, int z, Entity entity) public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{ {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) world.getBlockTileEntity(x, y, z); TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) world.getBlockTileEntity(x, y, z);
if (tileEntity.running) // if (tileEntity.running)
{ {
int metadata = tileEntity.getBeltDirection(); ForgeDirection direction = tileEntity.getDirection();
if (metadata == 4)
{ entity.addVelocity(direction.offsetX * tileEntity.speed, direction.offsetY * tileEntity.speed, direction.offsetZ * tileEntity.speed);
entity.setVelocity(0.1D, 0.2D, 0.0D); entity.onGround = false;
entity.onGround = false; /*
} * else if (metadata == 9) { entity.setVelocity(0.0D, 0.0D, 0.1D); entity.onGround =
else if (metadata == 5) * false; } else if (metadata == 10) { entity.setVelocity(-0.1D, 0.0D, 0.0D);
{ * entity.onGround = false; } else if (metadata == 11) { entity.setVelocity(0.0D, 0.0D,
entity.setVelocity(0.0D, 0.2D, 0.1D); * -0.1D); entity.onGround = false; }
entity.onGround = false; */
}
else if (metadata == 6) /*
{ * if (metadata == 4) { entity.setVelocity(0.1D, 0.2D, 0.0D); entity.onGround = false; }
entity.setVelocity(-0.1D, 0.2D, 0.0D); * else if (metadata == 5) { entity.setVelocity(0.0D, 0.2D, 0.1D); entity.onGround =
entity.onGround = false; * false; } else if (metadata == 6) { entity.setVelocity(-0.1D, 0.2D, 0.0D);
} * entity.onGround = false; } else if (metadata == 7) { entity.setVelocity(0.0D, 0.2D,
else if (metadata == 7) * -0.1D); entity.onGround = false; } else if (metadata == 8) { entity.setVelocity(0.1D,
{ * 0.0D, 0.0D); entity.onGround = false; } else if (metadata == 9) {
entity.setVelocity(0.0D, 0.2D, -0.1D); * entity.setVelocity(0.0D, 0.0D, 0.1D); entity.onGround = false; } else if (metadata ==
entity.onGround = false; * 10) { entity.setVelocity(-0.1D, 0.0D, 0.0D); entity.onGround = false; } else if
} * (metadata == 11) { entity.setVelocity(0.0D, 0.0D, -0.1D); entity.onGround = false; }
else if (metadata == 8) * else if (metadata == 0) { if (entity.posZ > (double) z + 0.55D) {
{ * entity.setVelocity(0.05D, 0.0D, -0.05D); } else if (entity.posZ < (double) z + 0.45D)
entity.setVelocity(0.1D, 0.0D, 0.0D); * { entity.setVelocity(0.05D, 0.0D, 0.05D); } else { entity.setVelocity(0.1D, 0.0D,
entity.onGround = false; * 0.0D); } } else if (metadata == 1) { if (entity.posX > (double) x + 0.55D) {
} * entity.setVelocity(-0.05D, 0.0D, 0.05D); } else if (entity.posX < (double) x + 0.45D)
else if (metadata == 9) * { entity.setVelocity(0.05D, 0.0D, 0.05D); } else { entity.setVelocity(0.0D, 0.0D,
{ * 0.1D); } } else if (metadata == 2) { if (entity.posZ > (double) z + 0.55D) {
entity.setVelocity(0.0D, 0.0D, 0.1D); * entity.setVelocity(-0.05D, 0.0D, -0.05D); } else if (entity.posZ < (double) z +
entity.onGround = false; * 0.45D) { entity.setVelocity(-0.05D, 0.0D, 0.05D); } else { entity.setVelocity(-0.1D,
} * 0.0D, 0.0D); } } else if (metadata == 3) { if (entity.posX > (double) x + 0.55D) {
else if (metadata == 10) * entity.setVelocity(-0.05D, 0.0D, -0.05D); } else if (entity.posX < (double) x +
{ * 0.45D) { entity.setVelocity(0.05D, 0.0D, -0.05D); } else { entity.setVelocity(0.0D,
entity.setVelocity(-0.1D, 0.0D, 0.0D); * 0.0D, -0.1D); } }
entity.onGround = false; */
}
else if (metadata == 11)
{
entity.setVelocity(0.0D, 0.0D, -0.1D);
entity.onGround = false;
}
else if (metadata == 0)
{
if (entity.posZ > (double) z + 0.55D)
{
entity.setVelocity(0.05D, 0.0D, -0.05D);
}
else if (entity.posZ < (double) z + 0.45D)
{
entity.setVelocity(0.05D, 0.0D, 0.05D);
}
else
{
entity.setVelocity(0.1D, 0.0D, 0.0D);
}
}
else if (metadata == 1)
{
if (entity.posX > (double) x + 0.55D)
{
entity.setVelocity(-0.05D, 0.0D, 0.05D);
}
else if (entity.posX < (double) x + 0.45D)
{
entity.setVelocity(0.05D, 0.0D, 0.05D);
}
else
{
entity.setVelocity(0.0D, 0.0D, 0.1D);
}
}
else if (metadata == 2)
{
if (entity.posZ > (double) z + 0.55D)
{
entity.setVelocity(-0.05D, 0.0D, -0.05D);
}
else if (entity.posZ < (double) z + 0.45D)
{
entity.setVelocity(-0.05D, 0.0D, 0.05D);
}
else
{
entity.setVelocity(-0.1D, 0.0D, 0.0D);
}
}
else if (metadata == 3)
{
if (entity.posX > (double) x + 0.55D)
{
entity.setVelocity(-0.05D, 0.0D, -0.05D);
}
else if (entity.posX < (double) x + 0.45D)
{
entity.setVelocity(0.05D, 0.0D, -0.05D);
}
else
{
entity.setVelocity(0.0D, 0.0D, -0.1D);
}
}
} }
} }
@ -178,11 +156,9 @@ public class BlockConveyorBelt extends BlockMachine
* Returns the TileEntity used by this block. * Returns the TileEntity used by this block.
*/ */
@Override @Override
public TileEntity createNewTileEntity(World var1, int metadata) public TileEntity createNewTileEntity(World var1)
{ {
if (metadata >= 0 && metadata < 4) { return new TileEntityConveyorBelt(); } return new TileEntityConveyorBelt();
if (metadata >= 4 && metadata < 8) { return new TileEntityCoveredBelt(); }
return null;
} }
@Override @Override

View file

@ -1,6 +1,5 @@
package assemblyline.common.machine.belt; package assemblyline.common.machine.belt;
import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
@ -16,15 +15,17 @@ import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.electricity.ElectricityConnections; import universalelectricity.core.electricity.ElectricityConnections;
import universalelectricity.core.implement.IConductor; import universalelectricity.core.implement.IConductor;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
import universalelectricity.prefab.tile.TileEntityElectricityReceiver; import universalelectricity.prefab.tile.TileEntityElectricityReceiver;
import assemblyline.api.ConveyorIgnore;
import assemblyline.api.IBelt; import assemblyline.api.IBelt;
import assemblyline.common.AssemblyLine; import assemblyline.common.AssemblyLine;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implements IPacketReceiver, IBelt public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implements IPacketReceiver, IBelt, IRotatable
{ {
/** /**
* Joules required to run this thing. * Joules required to run this thing.
@ -36,15 +37,14 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
*/ */
public double wattsReceived = 0; public double wattsReceived = 0;
private float speed = -0.045F; public float speed = 0.02f;
public float wheelRotation = 0; public float wheelRotation = 0;
public boolean running = false; public boolean running = false;
public boolean textureFlip = false; public boolean textureFlip = false;
public TileEntityConveyorBelt[] adjBelts = { null, null, null, null }; public TileEntityConveyorBelt[] adjBelts = { null, null, null, null };
public int clearCount = 0;
public int powerTransferRange = 0; public int powerTransferRange = 0;
public List<Entity> entityIgnoreList = new ArrayList<Entity>();
public TileEntityConveyorBelt() public TileEntityConveyorBelt()
{ {
@ -189,7 +189,7 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
{ {
int direction = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); int direction = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (!this.entityIgnoreList.contains(entity)) if (!ConveyorIgnore.isIgnore(entity))
{ {
if (!(entity instanceof EntityPlayer && ((EntityPlayer) entity).isSneaking())) if (!(entity instanceof EntityPlayer && ((EntityPlayer) entity).isSneaking()))
{ {
@ -216,12 +216,6 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
} }
} }
if (this.clearCount++ >= 4)
{
// clear the temp ignore
// list every 2 second
this.entityIgnoreList.clear();
}
if (entity instanceof EntityItem) if (entity instanceof EntityItem)
{ {
EntityItem entityItem = (EntityItem) entity; EntityItem entityItem = (EntityItem) entity;
@ -249,71 +243,61 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.wattsReceived); return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.wattsReceived);
} }
public int getBeltDirection() /**
{ * Is this belt in the middile of two belts? Used for rendering.
int meta = worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); */
if (meta >= 0 && meta < 4)
{
switch (meta)
{
case 0:
return 2;
case 1:
return 5;
case 2:
return 3;
case 3:
return 4;
}
}
return 0;
}
public boolean getIsMiddleBelt() public boolean getIsMiddleBelt()
{ {
ForgeDirection front = ForgeDirection.getOrientation(getBeltDirection()); ForgeDirection front = this.getDirection();
ForgeDirection back = ForgeDirection.getOrientation(getBeltDirection()).getOpposite(); ForgeDirection back = this.getDirection().getOpposite();
TileEntity fBelt = worldObj.getBlockTileEntity(xCoord + front.offsetX, yCoord + front.offsetY, zCoord + front.offsetZ); TileEntity fBelt = worldObj.getBlockTileEntity(xCoord + front.offsetX, yCoord + front.offsetY, zCoord + front.offsetZ);
TileEntity BBelt = worldObj.getBlockTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ); TileEntity BBelt = worldObj.getBlockTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ);
if (fBelt instanceof TileEntityConveyorBelt && BBelt instanceof TileEntityConveyorBelt) if (fBelt instanceof TileEntityConveyorBelt && BBelt instanceof TileEntityConveyorBelt)
{ {
int fD = ((TileEntityConveyorBelt) fBelt).getBeltDirection(); ForgeDirection fD = ((TileEntityConveyorBelt) fBelt).getDirection();
int BD = ((TileEntityConveyorBelt) BBelt).getBeltDirection(); ForgeDirection BD = ((TileEntityConveyorBelt) BBelt).getDirection();
int TD = this.getBeltDirection(); ForgeDirection TD = this.getDirection();
if (fD == TD && BD == TD) { return true; } return fD == TD && BD == TD;
} }
return false; return false;
} }
/**
* Is this belt in the front of a conveyor line? Used for rendering.
*/
public boolean getIsFrontCap() public boolean getIsFrontCap()
{ {
ForgeDirection front = ForgeDirection.getOrientation(getBeltDirection()); ForgeDirection front = this.getDirection();
ForgeDirection back = ForgeDirection.getOrientation(getBeltDirection()).getOpposite(); ForgeDirection back = this.getDirection().getOpposite();
TileEntity fBelt = worldObj.getBlockTileEntity(xCoord + front.offsetX, yCoord + front.offsetY, zCoord + front.offsetZ); TileEntity fBelt = worldObj.getBlockTileEntity(xCoord + front.offsetX, yCoord + front.offsetY, zCoord + front.offsetZ);
TileEntity BBelt = worldObj.getBlockTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ); TileEntity BBelt = worldObj.getBlockTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ);
if (fBelt instanceof TileEntityConveyorBelt) if (fBelt instanceof TileEntityConveyorBelt)
{ {
int fD = ((TileEntityConveyorBelt) fBelt).getBeltDirection(); ForgeDirection fD = ((TileEntityConveyorBelt) fBelt).getDirection();
int TD = this.getBeltDirection(); ForgeDirection TD = this.getDirection();
if (fD == TD) { return true; } return fD == TD;
} }
return false; return false;
} }
/**
* Is this belt in the back of a conveyor line? Used for rendering.
*/
public boolean getIsBackCap() public boolean getIsBackCap()
{ {
ForgeDirection front = ForgeDirection.getOrientation(getBeltDirection()); ForgeDirection front = this.getDirection();
ForgeDirection back = ForgeDirection.getOrientation(getBeltDirection()).getOpposite(); ForgeDirection back = this.getDirection().getOpposite();
TileEntity fBelt = worldObj.getBlockTileEntity(xCoord + front.offsetX, yCoord + front.offsetY, zCoord + front.offsetZ); TileEntity fBelt = worldObj.getBlockTileEntity(xCoord + front.offsetX, yCoord + front.offsetY, zCoord + front.offsetZ);
TileEntity BBelt = worldObj.getBlockTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ); TileEntity BBelt = worldObj.getBlockTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ);
if (BBelt instanceof TileEntityConveyorBelt) if (BBelt instanceof TileEntityConveyorBelt)
{ {
int BD = ((TileEntityConveyorBelt) BBelt).getBeltDirection(); ForgeDirection BD = ((TileEntityConveyorBelt) BBelt).getDirection();
int TD = this.getBeltDirection(); ForgeDirection TD = this.getDirection();
if (BD == TD) { return true; } return BD == TD;
} }
return false; return false;
} }
@ -335,19 +319,16 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
} }
public void ignoreEntity(Entity entity) @Override
public void setDirection(ForgeDirection facingDirection)
{ {
if (!this.entityIgnoreList.contains(entity)) this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal());
{
this.entityIgnoreList.add(entity);
}
} }
@Override @Override
public ForgeDirection getFacing() public ForgeDirection getDirection()
{ {
return ForgeDirection.getOrientation(this.getBeltDirection()); return ForgeDirection.getOrientation(this.getBlockMetadata());
} }
@Override @Override