Removed node system from conveyor belts for the time being

This commit is contained in:
Robert S 2014-05-22 13:31:57 -04:00
parent 7211a85d97
commit 9d84de4761
5 changed files with 14 additions and 124 deletions

View file

@ -1,14 +0,0 @@
package resonantinduction.mechanical.belt;
import resonant.lib.grid.TickingGrid;
/** @author Darkguardsman */
public class BeltNetwork extends TickingGrid<BeltNode>
{
public BeltNetwork(BeltNode node)
{
super(node, BeltNode.class);
}
}

View file

@ -1,76 +0,0 @@
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;
/** @author Darkguardsman */
public class BeltNode extends MechanicalNode
{
public BeltNode(TileConveyorBelt 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 from != ((TileConveyorBelt) parent).getDirection() && from != ((TileConveyorBelt) parent).getDirection().getOpposite();
}
@Override
public BeltNetwork newGrid()
{
return new BeltNetwork(this);
}
}

View file

@ -36,9 +36,9 @@ public class BlockConveyorBelt extends BlockTile
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileConveyorBelt)
((TileConveyorBelt) tile).node.reconstruct();
//TileEntity tile = world.getBlockTileEntity(x, y, z);
//if (tile instanceof TileConveyorBelt)
// ((TileConveyorBelt) tile).node.reconstruct();
}
@Override
@ -273,7 +273,7 @@ public class BlockConveyorBelt extends BlockTile
if (!world.isBlockIndirectlyGettingPowered(x, y, z))
{
double maxSpeed = tile.getMoveVelocity() / 20;
double maxSpeed = 1;
if (maxSpeed > 0)
{

View file

@ -100,7 +100,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer implements ISi
bindTexture(name);
GL11.glRotatef(180, 0f, 1f, 0f);
GL11.glTranslatef(0f, -0.68f, 0f);
MODEL.render(0.0625f, (float) Math.toRadians(tileEntity.node.angle), false, false, false, false);
MODEL.render(0.0625f, 0 /* TODO add rotation */, false, false, false, false);
}
}
else
@ -122,7 +122,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer implements ISi
}
ResourceLocation name = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "belt/frame" + frame + ".png");
bindTexture(name);
MODEL.render(0.0625F, (float) Math.toRadians(tileEntity.node.angle), false, false, false, true);
MODEL.render(0.0625F, 0 /* TODO add rotation */, false, false, false, true);
}

View file

@ -28,7 +28,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
/** Conveyer belt TileEntity that allows entities of all kinds to be moved
*
* @author DarkGuardsman */
public class TileConveyorBelt extends TileBase implements IEntityConveyor, IRotatable, INodeProvider, IPacketReceiverWithID
public class TileConveyorBelt extends TileBase implements IEntityConveyor, IRotatable, IPacketReceiverWithID
{
public enum BeltType
{
@ -56,12 +56,9 @@ public class TileConveyorBelt extends TileBase implements IEntityConveyor, IRota
private boolean markRefresh = true;
public BeltNode node;
public TileConveyorBelt()
{
super(Material.iron);
node = new BeltNode(this);
}
@Override
@ -80,23 +77,21 @@ public class TileConveyorBelt extends TileBase implements IEntityConveyor, IRota
it.remove();
}
}
this.node.torque = 1;
this.node.angularVelocity = 1;
/* DO ANIMATION AND EFFECTS */
if (this.worldObj.isRemote && (node.angularVelocity != 0))
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);
worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, Reference.PREFIX + "conveyor", 0.5f, 0.5f + 0.15f * 1, true);
}
double beltPercentage = node.angle / (2 * Math.PI);
this.animationFrame += 1;
//this.animationFrame = (int) (beltPercentage * MAX_SLANT_FRAME);
// 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)
@ -104,7 +99,6 @@ public class TileConveyorBelt extends TileBase implements IEntityConveyor, IRota
}
else
{
this.animationFrame = (int) (beltPercentage * MAX_SLANT_FRAME);
if (this.animationFrame < 0)
this.animationFrame = 0;
if (this.animationFrame > MAX_SLANT_FRAME)
@ -121,14 +115,6 @@ public class TileConveyorBelt extends TileBase implements IEntityConveyor, IRota
}
}
@Override
public <N extends INode> N getNode(Class<? super N> nodeType, ForgeDirection from)
{
if (nodeType.isAssignableFrom(node.getClass()))
return (N) node;
return null;
}
@Override
public Packet getDescriptionPacket()
{
@ -141,7 +127,7 @@ public class TileConveyorBelt extends TileBase implements IEntityConveyor, IRota
public void sendRefreshPacket()
{
PacketDispatcher.sendPacketToAllPlayers(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_REFRESH, this, node.angle));
//PacketDispatcher.sendPacketToAllPlayers(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_REFRESH, this, node.angle));
}
@Override
@ -156,7 +142,7 @@ public class TileConveyorBelt extends TileBase implements IEntityConveyor, IRota
}
else if (id == PACKET_REFRESH)
{
node.angle = data.readDouble();
//node.angle = data.readDouble();
return true;
}
}
@ -206,11 +192,6 @@ public class TileConveyorBelt extends TileBase implements IEntityConveyor, IRota
}
}
public double getMoveVelocity()
{
return Math.abs(node.getAngularVelocity());
}
public int getAnimationFrame()
{
return this.animationFrame;
@ -228,7 +209,6 @@ public class TileConveyorBelt extends TileBase implements IEntityConveyor, IRota
slantType = BeltType.NORMAL;
}
this.slantType = slantType;
node.reconstruct();
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}