Cleaned up belt code in prep for rework

This commit is contained in:
Robert S 2014-03-29 09:08:05 -04:00
parent a1ad7358af
commit 8b92f8f6bc
4 changed files with 291 additions and 258 deletions

View file

@ -0,0 +1,71 @@
package resonantinduction.mechanical.belt;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.mechanical.belt.TileConveyorBelt.BeltType;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorWorld;
import calclavia.lib.grid.INodeProvider;
/** @author Darkguardsman */
public class BeltNode extends MechanicalNode
{
public BeltNode(INodeProvider parent)
{
super(parent);
}
@Override
public void doRecache()
{
connections.clear();
TileConveyorBelt belt = ((TileConveyorBelt) parent);
for (int side = 2; side < 6; side++)
{
ForgeDirection dir = ForgeDirection.getOrientation(side);
VectorWorld pos = (VectorWorld) new VectorWorld(belt).translate(dir);
TileEntity tile = pos.getTileEntity();
if (dir == belt.getDirection() || dir == belt.getDirection().getOpposite())
{
if (dir == belt.getDirection())
{
if (belt.getBeltType() == BeltType.SLANT_DOWN)
{
pos.translate(new Vector3(0, -1, 0));
}
else if (belt.getBeltType() == BeltType.SLANT_UP)
{
pos.translate(new Vector3(0, 1, 0));
}
}
else if (dir == belt.getDirection().getOpposite())
{
if (belt.getBeltType() == BeltType.SLANT_DOWN)
{
pos.translate(new Vector3(0, 1, 0));
}
else if (belt.getBeltType() == BeltType.SLANT_UP)
{
pos.translate(new Vector3(0, -1, 0));
}
}
tile = pos.getTileEntity(belt.worldObj);
if (tile instanceof TileConveyorBelt)
{
connections.put(((TileConveyorBelt) tile).getNode(BeltNode.class, dir.getOpposite()), dir);
}
}
}
}
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
return source instanceof TileConveyorBelt && (from == ((TileConveyorBelt) parent).getDirection() || from == ((TileConveyorBelt) parent).getDirection().getOpposite());
}
}

View file

@ -14,7 +14,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Reference;
import resonantinduction.mechanical.belt.TileConveyorBelt.SlantType;
import resonantinduction.mechanical.belt.TileConveyorBelt.BeltType;
import universalelectricity.api.UniversalElectricity;
import calclavia.lib.prefab.block.BlockTile;
import calclavia.lib.render.block.BlockRenderingHandler;
@ -48,12 +48,12 @@ public class BlockConveyorBelt extends BlockTile
{
TileConveyorBelt tileEntity = (TileConveyorBelt) world.getBlockTileEntity(x, y, z);
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN)
if (tileEntity.getBeltType() == BeltType.SLANT_UP || tileEntity.getBeltType() == BeltType.SLANT_DOWN)
{
this.setBlockBounds(0f, 0f, 0f, 1f, 0.96f, 1f);
return;
}
if (tileEntity.getSlant() == SlantType.TOP)
if (tileEntity.getBeltType() == BeltType.RAISED)
{
this.setBlockBounds(0f, 0.68f, 0f, 1f, 0.96f, 1f);
return;
@ -72,11 +72,11 @@ public class BlockConveyorBelt extends BlockTile
{
TileConveyorBelt tileEntity = (TileConveyorBelt) t;
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN)
if (tileEntity.getBeltType() == BeltType.SLANT_UP || tileEntity.getBeltType() == BeltType.SLANT_DOWN)
{
return AxisAlignedBB.getAABBPool().getAABB(x + this.minX, y + this.minY, z + this.minZ, (double) x + 1, (double) y + 1, (double) z + 1);
}
if (tileEntity.getSlant() == SlantType.TOP)
if (tileEntity.getBeltType() == BeltType.RAISED)
{
return AxisAlignedBB.getAABBPool().getAABB(x + this.minX, (double) y + 0.68f, z + this.minZ, x + this.maxX, (double) y + 0.98f, z + this.maxZ);
}
@ -86,7 +86,7 @@ public class BlockConveyorBelt extends BlockTile
}
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB boundBox, List boxList, Entity entity)
{
TileEntity t = world.getBlockTileEntity(x, y, z);
@ -94,26 +94,26 @@ public class BlockConveyorBelt extends BlockTile
{
TileConveyorBelt tile = (TileConveyorBelt) t;
if (tile.getSlant() == SlantType.UP || tile.getSlant() == SlantType.DOWN)
if (tile.getBeltType() == BeltType.SLANT_UP || tile.getBeltType() == BeltType.SLANT_DOWN)
{
AxisAlignedBB boundBottom = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.3, z + 1);
AxisAlignedBB boundTop = null;
ForgeDirection direction = tile.getDirection();
if (tile.getSlant() != SlantType.NONE)
if (tile.getBeltType() != BeltType.NORMAL)
{
AxisAlignedBB newBounds = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.1, z + 1);
if (newBounds != null && par5AxisAlignedBB.intersectsWith(newBounds))
if (newBounds != null && boundBox.intersectsWith(newBounds))
{
par6List.add(newBounds);
boxList.add(newBounds);
}
return;
}
if (tile.getSlant() == SlantType.UP)
if (tile.getBeltType() == BeltType.SLANT_UP)
{
if (direction.offsetX > 0)
{
@ -132,7 +132,7 @@ public class BlockConveyorBelt extends BlockTile
boundTop = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.8, z + (float) direction.offsetZ / -2);
}
}
else if (tile.getSlant() == SlantType.DOWN)
else if (tile.getBeltType() == BeltType.SLANT_DOWN)
{
if (direction.offsetX > 0)
{
@ -152,25 +152,25 @@ public class BlockConveyorBelt extends BlockTile
}
}
if (par5AxisAlignedBB.intersectsWith(boundBottom))
if (boundBox.intersectsWith(boundBottom))
{
par6List.add(boundBottom);
boxList.add(boundBottom);
}
if (boundTop != null && par5AxisAlignedBB.intersectsWith(boundTop))
if (boundTop != null && boundBox.intersectsWith(boundTop))
{
par6List.add(boundTop);
boxList.add(boundTop);
}
return;
}
if (tile.getSlant() == SlantType.TOP)
if (tile.getBeltType() == BeltType.RAISED)
{
AxisAlignedBB newBounds = AxisAlignedBB.getAABBPool().getAABB(x, y + 0.68, z, x + 1, y + 0.98, z + 1);
if (newBounds != null && par5AxisAlignedBB.intersectsWith(newBounds))
if (newBounds != null && boundBox.intersectsWith(newBounds))
{
par6List.add(newBounds);
boxList.add(newBounds);
}
return;
@ -179,17 +179,17 @@ public class BlockConveyorBelt extends BlockTile
AxisAlignedBB newBounds = AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 0.1, z + 1);
if (newBounds != null && par5AxisAlignedBB.intersectsWith(newBounds))
if (newBounds != null && boundBox.intersectsWith(newBounds))
{
par6List.add(newBounds);
boxList.add(newBounds);
}
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack stack)
{
super.onBlockPlacedBy(world, x, y, z, par5EntityLiving, stack);
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
super.onBlockPlacedBy(world, x, y, z, entityLiving, stack);
int angle = MathHelper.floor_double((entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int change = 2;
switch (angle)
@ -244,14 +244,14 @@ public class BlockConveyorBelt extends BlockTile
{
TileConveyorBelt tileEntity = (TileConveyorBelt) world.getBlockTileEntity(x, y, z);
int slantOrdinal = tileEntity.getSlant().ordinal() + 1;
int slantOrdinal = tileEntity.getBeltType().ordinal() + 1;
if (slantOrdinal >= SlantType.values().length)
if (slantOrdinal >= BeltType.values().length)
{
slantOrdinal = 0;
}
tileEntity.setSlant(SlantType.values()[slantOrdinal]);
tileEntity.setSlant(BeltType.values()[slantOrdinal]);
return true;
}
@ -277,20 +277,20 @@ public class BlockConveyorBelt extends BlockTile
if (maxSpeed > 0)
{
SlantType slantType = tile.getSlant();
BeltType slantType = tile.getBeltType();
ForgeDirection direction = tile.getDirection();
if (slantType != SlantType.NONE)
if (slantType != BeltType.NORMAL)
{
entity.onGround = false;
}
if (slantType == SlantType.UP)
if (slantType == BeltType.SLANT_UP)
{
// We need at least 0.25 to move items up.
entity.motionY = maxSpeed * 3;// Math.max(0.25, maxSpeed);
}
else if (slantType == SlantType.DOWN)
else if (slantType == BeltType.SLANT_DOWN)
{
entity.motionY = -maxSpeed;
}

View file

@ -8,7 +8,7 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import resonantinduction.core.Reference;
import resonantinduction.mechanical.belt.TileConveyorBelt.SlantType;
import resonantinduction.mechanical.belt.TileConveyorBelt.BeltType;
import calclavia.lib.render.item.ISimpleItemRenderer;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
@ -24,7 +24,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer implements ISi
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
{
TileConveyorBelt tileEntity = (TileConveyorBelt) t;
SlantType slantType = tileEntity.getSlant();
BeltType slantType = tileEntity.getBeltType();
int face = tileEntity.getDirection().ordinal();
GL11.glPushMatrix();
@ -33,7 +33,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer implements ISi
int frame = tileEntity.getAnimationFrame();
if (slantType != null && slantType != SlantType.NONE)
if (slantType != null && slantType != BeltType.NORMAL)
{
switch (face)
{
@ -51,7 +51,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer implements ISi
break;
}
if (slantType == SlantType.UP)
if (slantType == BeltType.SLANT_UP)
{
ResourceLocation name = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "slantedbelt/frame" + frame + ".png");
bindTexture(name);
@ -64,7 +64,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer implements ISi
{
if (test instanceof TileConveyorBelt)
{
if (((TileConveyorBelt) test).getSlant() == SlantType.TOP)
if (((TileConveyorBelt) test).getBeltType() == BeltType.RAISED)
{
GL11.glRotatef(10f, 1f, 0f, 0f);
slantAdjust = true;
@ -73,7 +73,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer implements ISi
}
MODEL2.render(0.0625F, true);
}
else if (slantType == SlantType.DOWN)
else if (slantType == BeltType.SLANT_DOWN)
{
ResourceLocation name = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "slantedbelt/frame" + frame + ".png");
bindTexture(name);
@ -84,7 +84,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer implements ISi
{
if (test instanceof TileConveyorBelt)
{
if (((TileConveyorBelt) test).getSlant() == SlantType.TOP)
if (((TileConveyorBelt) test).getBeltType() == BeltType.RAISED)
{
GL11.glRotatef(-10f, 1f, 0f, 0f);
GL11.glTranslatef(0f, 0.25f, 0f);

View file

@ -4,272 +4,234 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.mechanical.Mechanical;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
import resonantinduction.mechanical.energy.grid.TileMechanical;
import universalelectricity.api.vector.Vector3;
import calclavia.api.resonantinduction.mechanical.IBelt;
import calclavia.lib.content.module.TileBase;
import calclavia.lib.grid.INode;
import calclavia.lib.grid.INodeProvider;
import calclavia.lib.network.IPacketReceiverWithID;
import calclavia.lib.prefab.tile.IRotatable;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.PacketDispatcher;
/**
* Conveyer belt TileEntity that allows entities of all kinds to be moved
/** Conveyer belt TileEntity that allows entities of all kinds to be moved
*
* @author DarkGuardsman
*/
public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatable
* @author DarkGuardsman */
public class TileConveyorBelt extends TileBase implements IBelt, IRotatable, INodeProvider, IPacketReceiverWithID
{
public enum SlantType
{
NONE, UP, DOWN, TOP
}
public enum BeltType
{
NORMAL,
SLANT_UP,
SLANT_DOWN,
RAISED
}
public TileConveyorBelt()
{
mechanicalNode = new PacketMechanicalNode(this)
{
@Override
public void doRecache()
{
connections.clear();
/** Static constants. */
public static final int MAX_FRAME = 13;
public static final int MAX_SLANT_FRAME = 23;
public static final int PACKET_SLANT = 0;
public static final int PACKET_REFRESH = 1;
/** Acceleration of entities on the belt */
public static final float ACCELERATION = 0.01f;
boolean didRefresh = false;
/** Frame count for texture animation from 0 - maxFrame */
private int animationFrame = 0;
for (int i = 2; i < 6; i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
Vector3 pos = new Vector3(TileConveyorBelt.this).translate(dir);
TileEntity tile = pos.getTileEntity(TileConveyorBelt.this.worldObj);
private BeltType slantType = BeltType.NORMAL;
if (dir == TileConveyorBelt.this.getDirection() || dir == TileConveyorBelt.this.getDirection().getOpposite())
{
if (dir == TileConveyorBelt.this.getDirection())
{
if (TileConveyorBelt.this.slantType == SlantType.DOWN)
{
pos.translate(new Vector3(0, -1, 0));
}
else if (TileConveyorBelt.this.slantType == SlantType.UP)
{
pos.translate(new Vector3(0, 1, 0));
}
}
else if (dir == TileConveyorBelt.this.getDirection().getOpposite())
{
if (TileConveyorBelt.this.slantType == SlantType.DOWN)
{
pos.translate(new Vector3(0, 1, 0));
}
else if (TileConveyorBelt.this.slantType == SlantType.UP)
{
pos.translate(new Vector3(0, -1, 0));
}
}
/** Entities that are ignored allowing for other tiles to interact with them */
public List<Entity> ignoreList = new ArrayList<Entity>();
tile = pos.getTileEntity(worldObj);
private boolean markRefresh = true;
if (tile instanceof TileConveyorBelt)
{
connections.put(((TileConveyorBelt) tile).getNode(MechanicalNode.class, dir.getOpposite()), dir);
didRefresh = true;
}
}
}
public BeltNode mechanicalNode;
if (!worldObj.isRemote)
{
markRefresh = true;
}
}
public TileConveyorBelt()
{
super(Material.iron);
mechanicalNode = new BeltNode(this);
}
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
return from != getDirection() || from != getDirection().getOpposite();
}
}.setLoad(0.15f);
}
@Override
public void updateEntity()
{
super.updateEntity();
/**
* Static constants.
*/
public static final int MAX_FRAME = 13;
public static final int MAX_SLANT_FRAME = 23;
public static final int PACKET_SLANT = Mechanical.contentRegistry.getNextPacketID();
public static final int PACKET_REFRESH = Mechanical.contentRegistry.getNextPacketID();
/** Acceleration of entities on the belt */
public static final float ACCELERATION = 0.01f;
/* PROCESSES IGNORE LIST AND REMOVES UNNEED ENTRIES */
Iterator<Entity> it = this.ignoreList.iterator();
/** Frame count for texture animation from 0 - maxFrame */
private int animationFrame = 0;
List<Entity> effect_list = this.getAffectedEntities();
while (it.hasNext())
{
if (!effect_list.contains(it.next()))
{
it.remove();
}
}
private SlantType slantType = SlantType.NONE;
if (this.worldObj.isRemote)
{
if (this.ticks % 10 == 0 && this.worldObj.getBlockId(this.xCoord - 1, this.yCoord, this.zCoord) != Mechanical.blockConveyorBelt.blockID && this.worldObj.getBlockId(xCoord, yCoord, zCoord - 1) != Mechanical.blockConveyorBelt.blockID)
{
worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, Reference.PREFIX + "conveyor", 0.5f, 0.5f + 0.15f * (float) getMoveVelocity(), true);
}
/** Entities that are ignored allowing for other tiles to interact with them */
public List<Entity> ignoreList = new ArrayList<Entity>();
double beltPercentage = mechanicalNode.angle / (2 * Math.PI);
private boolean markRefresh = true;
// Sync the animation. Slant belts are slower.
if (this.getBeltType() == BeltType.NORMAL || this.getBeltType() == BeltType.RAISED)
{
this.animationFrame = (int) (beltPercentage * MAX_FRAME);
if (this.animationFrame < 0)
this.animationFrame = 0;
if (this.animationFrame > MAX_FRAME)
this.animationFrame = MAX_FRAME;
}
else
{
this.animationFrame = (int) (beltPercentage * MAX_SLANT_FRAME);
if (this.animationFrame < 0)
this.animationFrame = 0;
if (this.animationFrame > MAX_SLANT_FRAME)
this.animationFrame = MAX_SLANT_FRAME;
}
}
else
{
if (markRefresh)
{
sendRefreshPacket();
markRefresh = false;
}
}
}
@Override
public void updateEntity()
{
super.updateEntity();
@Override
public <N extends INode> N getNode(Class<? super N> nodeType, ForgeDirection from)
{
if (nodeType.isAssignableFrom(mechanicalNode.getClass()))
return (N) mechanicalNode;
return null;
}
/* PROCESSES IGNORE LIST AND REMOVES UNNEED ENTRIES */
Iterator<Entity> it = this.ignoreList.iterator();
@Override
public Packet getDescriptionPacket()
{
if (this.getBeltType() != BeltType.NORMAL)
{
return ResonantInduction.PACKET_TILE.getPacket(this, PACKET_SLANT, this.getBeltType().ordinal());
}
return super.getDescriptionPacket();
}
List<Entity> effect_list = this.getAffectedEntities();
while (it.hasNext())
{
if (!effect_list.contains(it.next()))
{
it.remove();
}
}
public void sendRefreshPacket()
{
PacketDispatcher.sendPacketToAllPlayers(ResonantInduction.PACKET_TILE.getPacket(this, PACKET_REFRESH));
}
if (this.worldObj.isRemote)
{
if (this.ticks % 10 == 0 && this.worldObj.getBlockId(this.xCoord - 1, this.yCoord, this.zCoord) != Mechanical.blockConveyorBelt.blockID && this.worldObj.getBlockId(xCoord, yCoord, zCoord - 1) != Mechanical.blockConveyorBelt.blockID)
{
worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, Reference.PREFIX + "conveyor", 0.5f, 0.5f + 0.15f * (float) getMoveVelocity(), true);
}
@Override
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
if (this.worldObj.isRemote)
{
if (id == PACKET_SLANT)
{
this.setBeltType(BeltType.values()[data.readInt()]);
return true;
}
else if (id == PACKET_REFRESH)
{
mechanicalNode.reconstruct();
return true;
}
}
return false;
}
double beltPercentage = mechanicalNode.angle / (2 * Math.PI);
public void setSlant(BeltType slantType)
{
if (slantType == null)
{
slantType = BeltType.NORMAL;
}
// Sync the animation. Slant belts are slower.
if (this.getSlant() == SlantType.NONE || this.getSlant() == SlantType.TOP)
{
this.animationFrame = (int) (beltPercentage * MAX_FRAME);
if (this.animationFrame < 0)
this.animationFrame = 0;
if (this.animationFrame > MAX_FRAME)
this.animationFrame = MAX_FRAME;
}
else
{
this.animationFrame = (int) (beltPercentage * MAX_SLANT_FRAME);
if (this.animationFrame < 0)
this.animationFrame = 0;
if (this.animationFrame > MAX_SLANT_FRAME)
this.animationFrame = MAX_SLANT_FRAME;
}
}
else
{
if (markRefresh)
{
sendRefreshPacket();
markRefresh = false;
}
}
}
this.setBeltType(slantType);
mechanicalNode.reconstruct();
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public Packet getDescriptionPacket()
{
if (this.slantType != SlantType.NONE)
{
return ResonantInduction.PACKET_TILE.getPacket(this, PACKET_SLANT, this.slantType.ordinal());
}
return super.getDescriptionPacket();
}
@Override
public void setDirection(ForgeDirection facingDirection)
{
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3);
}
public void sendRefreshPacket()
{
PacketDispatcher.sendPacketToAllPlayers(ResonantInduction.PACKET_TILE.getPacket(this, PACKET_REFRESH));
}
@Override
public ForgeDirection getDirection()
{
return ForgeDirection.getOrientation(this.getBlockMetadata());
}
@Override
public void onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
super.onReceivePacket(id, data, player, extra);
@Override
public List<Entity> getAffectedEntities()
{
return worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1));
}
if (id == PACKET_SLANT)
this.slantType = SlantType.values()[data.readInt()];
else if (id == PACKET_REFRESH)
mechanicalNode.reconstruct();
}
/** NBT Data */
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
this.setBeltType(BeltType.values()[nbt.getByte("slant")]);
}
public SlantType getSlant()
{
return slantType;
}
/** Writes a tile entity to NBT. */
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setByte("slant", (byte) this.getBeltType().ordinal());
}
public void setSlant(SlantType slantType)
{
if (slantType == null)
{
slantType = SlantType.NONE;
}
@Override
public void ignoreEntity(Entity entity)
{
if (!this.ignoreList.contains(entity))
{
this.ignoreList.add(entity);
}
}
this.slantType = slantType;
mechanicalNode.reconstruct();
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
public double getMoveVelocity()
{
return Math.abs(mechanicalNode.getAngularVelocity());
}
@Override
public void setDirection(ForgeDirection facingDirection)
{
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3);
}
public int getAnimationFrame()
{
return this.animationFrame;
}
@Override
public ForgeDirection getDirection()
{
return ForgeDirection.getOrientation(this.getBlockMetadata());
}
public BeltType getBeltType()
{
return slantType;
}
@Override
public List<Entity> getAffectedEntities()
{
return worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1));
}
public int getAnimationFrame()
{
return this.animationFrame;
}
/** 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());
}
@Override
public void ignoreEntity(Entity entity)
{
if (!this.ignoreList.contains(entity))
{
this.ignoreList.add(entity);
}
}
public double getMoveVelocity()
{
return Math.abs(mechanicalNode.getAngularVelocity());
}
public void setBeltType(BeltType slantType)
{
this.slantType = slantType;
}
}