Redesigned mechanical system again to fit rotational conflicts better

This commit is contained in:
Calclavia 2014-01-24 16:34:38 +08:00
parent 65c1dfad7a
commit 7c3adc4c2b
13 changed files with 233 additions and 392 deletions

View file

@ -236,4 +236,17 @@ public class BlockEngineeringTable extends BlockRIRotatable
{
return new TileEngineeringTable();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
}

View file

@ -18,58 +18,62 @@ import calclavia.lib.prefab.tile.TileElectrical;
*
* @author Calclavia
*/
public class TileGenerator extends TileElectrical implements IMechanical, IRotatable
public class TileGenerator extends TileElectrical implements IRotatable
{
private IMechanicalNetwork network;
/** Generator turns KE -> EE. Inverted one will turn EE -> KE. */
public boolean isInversed = false;
private float torqueRatio = 8000;
private int torqueRatio = 8000;
public TileGenerator()
{
energy = new EnergyStorageHandler(10000);
this.ioMap = 728;
}
public float toggleRatio()
{
return torqueRatio = (torqueRatio + 1000) % energy.getMaxExtract() + 1000;
return torqueRatio = (int) ((torqueRatio + 1000) % energy.getMaxExtract() + 1000);
}
@Override
public void updateEntity()
{
if (this.isFunctioning())
if (!isInversed)
{
if (!isInversed)
{
energy.receiveEnergy(getNetwork().getPower(), true);
produce();
}
else
{
produceMechanical(this.getDirection());
produceMechanical(this.getDirection().getOpposite());
}
// energy.receiveEnergy(getNetwork().getPower(), true);
produce();
}
else
{
produceMechanical(this.getDirection());
produceMechanical(this.getDirection().getOpposite());
}
}
public void produceMechanical(ForgeDirection outputDir)
{
Vector3 outputVector = new Vector3(this).translate(outputDir);
TileEntity mechanical = outputVector.getTileEntity(worldObj);
TileEntity tile = outputVector.getTileEntity(worldObj);
if (mechanical instanceof IMechanical)
if (tile instanceof IMechanical)
{
IMechanical mech = ((IMechanical) tile).getInstance(outputDir.getOpposite());
long extract = energy.extractEnergy(false);
if (extract > 0)
{
float angularVelocity = extract / torqueRatio;
long torque = (long) (extract / angularVelocity);
energy.extractEnergy(((IMechanical) mechanical).getInstance(outputDir.getOpposite()).getNetwork().onReceiveEnergy(((IMechanical) mechanical), torque, angularVelocity), true);
final float maxAngularVelocity = energy.getEnergyCapacity() / (float) torqueRatio;
final long maxTorque = (long) ((double) energy.getEnergyCapacity() / maxAngularVelocity);
float addAngularVelocity = extract / (float) torqueRatio;
long addTorque = (long) (((double) extract) / addAngularVelocity);
long setTorque = Math.min(mech.getTorque() + addTorque, maxTorque);
float setAngularVelocity = Math.min(mech.getAngularVelocity() + addAngularVelocity, maxAngularVelocity);
mech.setTorque(setTorque);
mech.setAngularVelocity(setAngularVelocity);
energy.extractEnergy((long) (setTorque * setAngularVelocity), true);
}
}
}
@ -77,7 +81,7 @@ public class TileGenerator extends TileElectrical implements IMechanical, IRotat
@Override
public EnumSet<ForgeDirection> getInputDirections()
{
return this.getOutputDirections();
return getOutputDirections();
}
@Override
@ -101,17 +105,12 @@ public class TileGenerator extends TileElectrical implements IMechanical, IRotat
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, dir.ordinal(), 3);
}
private boolean isFunctioning()
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
isInversed = nbt.getBoolean("isInversed");
torqueRatio = nbt.getFloat("torqueRatio");
torqueRatio = nbt.getInteger("torqueRatio");
}
@Override
@ -119,67 +118,6 @@ public class TileGenerator extends TileElectrical implements IMechanical, IRotat
{
super.writeToNBT(nbt);
nbt.setBoolean("isInversed", isInversed);
nbt.setFloat("torqueRatio", torqueRatio);
}
@Override
public boolean isClockwise()
{
return false;
}
@Override
public void setClockwise(boolean isClockwise)
{
}
@Override
public Object[] getConnections()
{
Object[] connections = new Object[6];
connections[getDirection().ordinal()] = new Vector3(this).translate(getDirection()).getTileEntity(worldObj);
return connections;
}
@Override
public IMechanicalNetwork getNetwork()
{
if (this.network == null)
{
this.network = new MechanicalNetwork();
this.network.addConnector(this);
}
return this.network;
}
@Override
public void setNetwork(IMechanicalNetwork network)
{
this.network = network;
}
@Override
public int[] getLocation()
{
return new int[] { xCoord, yCoord, zCoord, 0 };
}
@Override
public float getResistance()
{
return 0;
}
@Override
public boolean isRotationInversed()
{
return false;
}
@Override
public IMechanical getInstance(ForgeDirection from)
{
return this;
nbt.setInteger("torqueRatio", torqueRatio);
}
}

View file

@ -295,10 +295,4 @@ public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatabl
{
return Math.max(getNetwork().getAngularVelocity(), getNetwork().getPrevAngularVelocity());
}
@Override
public float getResistance()
{
return 0.5f;
}
}

View file

@ -30,33 +30,31 @@ public class PartGear extends PartMechanical implements IMechanical
{
if (manualCrankTime > 0)
{
getNetwork().onReceiveEnergy(this, 20, 0.4f);
if (angularVelocity > 0)
angularVelocity += 0.1f;
else
angularVelocity -= 0.1f;
manualCrankTime--;
}
angularVelocity *= 0.9f;
}
super.update();
}
@Override
public float getResistance()
{
return 0.1f;
}
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack item)
{
//System.out.println(world().isRemote + ": " + getNetwork());
if (BlockAdvanced.isUsableWrench(player, player.getCurrentEquippedItem(), tile().xCoord, tile().yCoord, tile().zCoord))
if (BlockAdvanced.isUsableWrench(player, player.getCurrentEquippedItem(), x(), y(), z()))
{
if (player.isSneaking())
{
if (!world().isRemote)
{
setClockwise(!isClockwise());
player.addChatMessage("Flipped gear to rotate " + (isClockwise() ? "clockwise" : "anticlockwise") + ".");
angularVelocity = -angularVelocity;
player.addChatMessage("Flipped gear to rotate " + (angularVelocity > 0 ? "clockwise" : "anticlockwise") + ".");
}
}
else
@ -64,6 +62,9 @@ public class PartGear extends PartMechanical implements IMechanical
this.manualCrankTime = 10;
}
BlockAdvanced.damageWrench(player, player.getCurrentEquippedItem(), x(), y(), z());
return true;
}
return false;
@ -85,22 +86,9 @@ public class PartGear extends PartMechanical implements IMechanical
}
}
@Override
public boolean isRotationInversed()
{
return true;
}
@Override
public String getType()
{
return "resonant_induction_gear";
}
@Override
public IMechanical getInstance(ForgeDirection from)
{
return this;
}
}

View file

@ -37,7 +37,7 @@ public class RenderGear
RenderUtility.rotateFaceBlockToSide(part.placementSide);
GL11.glRotatef((float) Math.toDegrees(part.isClockwise() ? part.getNetwork().getRotation() : -part.getNetwork().getRotation()), 0, 1, 0);
GL11.glRotatef((float) Math.toDegrees(part.angle), 0, 1, 0);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
MODEL.renderAll();

View file

@ -6,27 +6,19 @@ import universalelectricity.api.net.IConnector;
public interface IMechanical extends IConnector<IMechanicalNetwork>
{
/**
* The percentage of resistance caused by this connector.
* The angular velocity.
*
* @return A small value, most likely less than one.
* @return Can be negative.
*/
public float getResistance();
public float getAngularVelocity();
/**
*
* @return int[4]: x,y,z,direction
*/
public int[] getLocation();
public void setAngularVelocity(float velocity);
/**
* @return Is the mechanical machine going clockwise currently?
*/
public boolean isClockwise();
public long getTorque();
public void setClockwise(boolean isClockwise);
public void setTorque(long torque);
public float getRatio();
/**
* @return Return true if the mechanical block should have its rotation set inveresed.
*/
public boolean isRotationInversed();
public IMechanical getInstance(ForgeDirection dir);
}

View file

@ -2,22 +2,16 @@ package resonantinduction.mechanical.network;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.mechanical.Mechanical;
import resonantinduction.mechanical.gear.PartGear;
import universalelectricity.api.net.IUpdate;
import universalelectricity.core.net.Network;
import universalelectricity.core.net.NetworkTickHandler;
import calclavia.lib.network.IPacketReceiver;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.PacketDispatcher;
/**
* A mechanical network for translate speed and force using mechanical rotations.
@ -35,7 +29,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
*
* @author Calclavia
*/
public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical> implements IMechanicalNetwork, IPacketReceiver, IUpdate
public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical> implements IMechanicalNetwork, IUpdate
{
private long prevTorque = 0;
private float prevAngularVelocity = 0;
@ -59,6 +53,9 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
private boolean markUpdateRotation = true;
/**
* Only add the exact instance of the connector into the network. Multipart tiles allowed!
*/
@Override
public void addConnector(IMechanical connector)
{
@ -74,50 +71,45 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
public void update()
{
/**
* Calculation rotations of all generators.
* Update all mechanical nodes.
*/
if (markUpdateRotation || (!(prevGenerators.equals(generators)) && generators.size() > 0))
Iterator<IMechanical> it = new LinkedHashSet<IMechanical>(getConnectors()).iterator();
while (it.hasNext())
{
Set<IMechanical> closedSet = new LinkedHashSet<IMechanical>();
IMechanical mechanical = it.next();
Object[] connections = mechanical.getConnections();
for (IMechanical generatorNode : generators)
for (int i = 0; i < connections.length; i++)
{
if (generatorNode != null)
ForgeDirection dir = ForgeDirection.getOrientation(i);
Object adacent = connections[i];
if (adacent instanceof IMechanical)
{
PathfinderUpdateRotation rotationPathfinder = new PathfinderUpdateRotation(generatorNode, this, closedSet);
rotationPathfinder.findNodes(generatorNode);
closedSet.addAll(rotationPathfinder.closedSet);
sendRotationUpdatePacket(generatorNode);
IMechanical adjacentMech = ((IMechanical) adacent).getInstance(dir);
if (adjacentMech != null)
{
float ratio = adjacentMech.getRatio() / mechanical.getRatio();
float acceleration = 0.5f;
long torque = mechanical.getTorque();
if (Math.abs(torque - adjacentMech.getTorque() / ratio * acceleration) < Math.abs(adjacentMech.getTorque() / ratio))
{
mechanical.setTorque((long) (torque - (adjacentMech.getTorque() / ratio * acceleration)));
}
float velocity = mechanical.getAngularVelocity();
if (Math.abs(velocity - adjacentMech.getAngularVelocity() * ratio * acceleration) < Math.abs(adjacentMech.getAngularVelocity() * ratio))
{
mechanical.setAngularVelocity(velocity - (adjacentMech.getAngularVelocity() * ratio * acceleration));
}
}
}
}
markUpdateRotation = false;
prevGenerators = new LinkedHashSet<IMechanical>(generators);
}
generators.clear();
/**
* Calculate load
*/
if (load > 0)
{
torque /= load / 2;
angularVelocity /= load / 2;
}
/**
* Update all connectors
*/
if (getPrevTorque() != getTorque() || getPrevAngularVelocity() != getAngularVelocity())
{
sendNetworkPacket();
}
prevTorque = torque;
prevAngularVelocity = angularVelocity;
torque = 0;
angularVelocity = 0;
}
@Override
@ -132,58 +124,6 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
return canUpdate();
}
/**
* Send network update packet for connectors.
*/
public void sendNetworkPacket()
{
for (IMechanical connector : this.getConnectors())
{
int[] location = connector.getLocation();
if (location != null)
{
PacketDispatcher.sendPacketToAllPlayers(Mechanical.PACKET_NETWORK.getPacket(location[0], location[1], location[2], location[3], (byte) 0, torque, angularVelocity));
break;
}
}
}
public void sendRotationUpdatePacket(IMechanical connector)
{
int[] location = connector.getLocation();
if (location != null)
{
System.out.println("UPDATING!" + location[0] + "," + location[1] + "," + location[2]);
PacketDispatcher.sendPacketToAllPlayers(Mechanical.PACKET_NETWORK.getPacket(location[0], location[1], location[2], location[3], (byte) 1, connector.isClockwise()));
}
}
@Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
try
{
switch (data.readByte())
{
case 0:
setPower(data.readLong(), data.readFloat());
break;
case 1:
IMechanical updateNode = (IMechanical) extra[0];
updateNode.setClockwise(data.readBoolean());
PathfinderUpdateRotation rotationPathfinder = new PathfinderUpdateRotation(updateNode, this, null);
rotationPathfinder.findNodes(updateNode);
break;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* Applies energy to the mechanical network this tick.
* Note: Server side only.
@ -247,13 +187,13 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
load = 1;
super.reconstruct();
NetworkTickHandler.addNetwork(this);
}
@Override
protected void reconstructConnector(IMechanical connector)
{
connector.setNetwork(this);
load += connector.getResistance();
}
/** Segmented out call so overriding can be done when machines are reconstructed. */

View file

@ -48,15 +48,14 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
/** The mechanical connections this connector has made */
protected Object[] connections = new Object[6];
protected float angularVelocity;
protected long torque;
/** Side of the block this is placed on */
public ForgeDirection placementSide = ForgeDirection.UNKNOWN;
/** The size of the gear */
private float radius = 0.5f;
public boolean isClockwise = true;
/** The current angle the gear is on. In radians per second. */
/** The current angle the gear is on. In radians. */
public float angle = 0;
public void preparePlacement(int side, int itemDamage)
@ -64,6 +63,19 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
this.placementSide = ForgeDirection.getOrientation((byte) (side ^ 1));
}
@Override
public void update()
{
angle += angularVelocity / 20;
if (!world().isRemote)
{
sendRotationPacket();
}
super.update();
}
@Override
public void onAdded()
{
@ -102,6 +114,8 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
*/
public void refresh()
{
connections = new Object[6];
/** Look for gears that are back-to-back with this gear. Equate torque. */
TileEntity tileBehind = new universalelectricity.api.vector.Vector3(tile()).translate(placementSide).getTileEntity(world());
@ -116,6 +130,18 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
}
}
/** Look for gears that are internal and adjacent to this gear. (The 4 sides) */
for (int i = 0; i < 6; i++)
{
ForgeDirection checkDir = ForgeDirection.getOrientation(i);
IMechanical instance = (IMechanical) ((IMechanical) tile()).getInstance(checkDir);
if (connections[checkDir.ordinal()] == null && checkDir != placementSide && checkDir != placementSide.getOpposite() && instance != null && instance.canConnect(checkDir.getOpposite()))
{
connections[checkDir.ordinal()] = instance;
getNetwork().merge(instance.getNetwork());
}
}
/** Look for gears outside this block space, the relative UP, DOWN, LEFT, RIGHT */
for (int i = 0; i < 4; i++)
@ -123,7 +149,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
ForgeDirection checkDir = ForgeDirection.getOrientation(Rotation.rotateSide(this.placementSide.ordinal(), i));
TileEntity checkTile = new universalelectricity.api.vector.Vector3(tile()).translate(checkDir).getTileEntity(world());
if (checkTile instanceof IMechanical)
if (connections[checkDir.ordinal()] == null && checkTile instanceof IMechanical)
{
IMechanical instance = (IMechanical) ((IMechanical) checkTile).getInstance(placementSide);
@ -135,24 +161,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
}
}
/** Look for gears that are internal and adjacent to this gear. (The 2 sides) */
for (int i = 0; i < 6; i++)
{
ForgeDirection checkDir = ForgeDirection.getOrientation(i);
IMechanical instance = (IMechanical) ((IMechanical) tile()).getInstance(checkDir);
if (instance != null && instance.canConnect(checkDir.getOpposite()))
{
connections[checkDir.ordinal()] = instance;
getNetwork().merge(instance.getNetwork());
}
}
getNetwork().reconstruct();
if (!world().isRemote)
{
sendRotationPacket();
}
}
@Override
@ -172,7 +181,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
{
if (world() != null && !world().isRemote && tile() != null)
{
tile().getWriteStream(this).writeByte(0).writeBoolean(isClockwise);
tile().getWriteStream(this).writeByte(0).writeFloat(angularVelocity);
}
}
@ -180,58 +189,10 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
{
if (packetID == 0)
{
refresh();
isClockwise = packet.readBoolean();
angularVelocity = packet.readFloat();
}
}
/**
* Network Methods
*/
@Override
public IMechanicalNetwork getNetwork()
{
if (this.network == null)
{
this.network = new MechanicalNetwork();
this.network.addConnector(this);
}
return this.network;
}
@Override
public void setNetwork(IMechanicalNetwork network)
{
this.network = network;
}
@Override
public boolean canConnect(ForgeDirection direction)
{
return true;
}
@Override
public boolean isClockwise()
{
return isClockwise;
}
@Override
public void setClockwise(boolean isClockwise)
{
if (this.isClockwise != isClockwise)
{
if (getNetwork().getPower() > 0)
{
getNetwork().setPower(0, 0);
}
}
this.isClockwise = isClockwise;
}
/** Packet Code. */
@Override
public void readDesc(MCDataInput packet)
@ -315,11 +276,65 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
return getItem();
}
/**
* Mechanical implementations
*/
@Override
public int[] getLocation()
public IMechanicalNetwork getNetwork()
{
if (tile() != null)
return new int[] { x(), y(), z(), placementSide.ordinal() };
return null;
if (this.network == null)
{
this.network = new MechanicalNetwork();
this.network.addConnector(this);
}
return this.network;
}
@Override
public void setNetwork(IMechanicalNetwork network)
{
this.network = network;
}
@Override
public boolean canConnect(ForgeDirection direction)
{
return true;
}
@Override
public float getAngularVelocity()
{
return angularVelocity;
}
@Override
public void setAngularVelocity(float velocity)
{
this.angularVelocity = velocity;
}
@Override
public long getTorque()
{
return torque;
}
@Override
public void setTorque(long torque)
{
this.torque = torque;
}
@Override
public float getRatio()
{
return 0.5f;
}
@Override
public IMechanical getInstance(ForgeDirection from)
{
return this;
}
}

View file

@ -1,60 +0,0 @@
package resonantinduction.mechanical.network;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import universalelectricity.api.net.IConnector;
import universalelectricity.core.net.ConnectionPathfinder;
/**
* Sets proper rotations on all connected units in the mechanical network.
*
* The pathfinder will find the first point and rotate all adjacent blocks next to it to be the
* opposite of the original.
*
* @author Calclavia
*
*/
public class PathfinderUpdateRotation extends ConnectionPathfinder<IMechanical>
{
private boolean currentRotationFlag = true;
private Set<IMechanical> prevClosedSet;
private IMechanicalNetwork network;
public PathfinderUpdateRotation(IMechanical first, IMechanicalNetwork network, Set<IMechanical> prevClosedSet)
{
super(IMechanical.class, first);
this.currentRotationFlag = first.isClockwise();
this.prevClosedSet = prevClosedSet;
this.network = network;
}
public boolean findNodes(IMechanical currentNode)
{
this.closedSet.add(currentNode);
currentNode.setClockwise(currentRotationFlag);
for (IMechanical node : this.getConnectedNodes(currentNode))
{
if (!this.closedSet.contains(node))
{
currentRotationFlag = (node.isRotationInversed() && currentNode.isRotationInversed()) ? !currentNode.isClockwise() : currentNode.isClockwise();
if ((prevClosedSet != null && prevClosedSet.contains(node)) && (node.isClockwise() != currentRotationFlag))
{
// We have conflicting rotations. Network is now stuck.
network.setDisabled();
}
findNodes(node);
}
}
return false;
}
}

View file

@ -9,10 +9,31 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
{
/** The mechanical connections this connector has made */
protected Object[] connections = new Object[6];
private IMechanicalNetwork network;
protected float angularVelocity;
protected long torque;
public float angle = 0;
private boolean isClockwise = false;
@Override
public void updateEntity()
{
super.updateEntity();
angle += angularVelocity / 20;
torque *= getLoad();
angularVelocity *= getLoad();
}
protected float getLoad()
{
return 0.5f;
}
@Override
public void invalidate()
{
getNetwork().split(this);
super.invalidate();
}
@Override
public Object[] getConnections()
@ -56,33 +77,33 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
}
@Override
public int[] getLocation()
public float getAngularVelocity()
{
return new int[] { xCoord, yCoord, zCoord, 0 };
return angularVelocity;
}
@Override
public float getResistance()
public void setAngularVelocity(float velocity)
{
return 0;
this.angularVelocity = velocity;
}
@Override
public boolean isClockwise()
public long getTorque()
{
return isClockwise;
return torque;
}
@Override
public void setClockwise(boolean isClockwise)
public void setTorque(long torque)
{
this.isClockwise = isClockwise;
this.torque = torque;
}
@Override
public boolean isRotationInversed()
public float getRatio()
{
return true;
return 0.5f;
}
@Override

View file

@ -75,9 +75,8 @@ public class BlockGrinderWheel extends BlockRIRotatable implements ITileEntityPr
// Move entity based on the direction of the block.
ForgeDirection dir = this.getDirection(world, x, y, z);
dir = ForgeDirection.getOrientation(!(dir.ordinal() % 2 == 0) ? dir.ordinal() - 1 : dir.ordinal());
int inversion = tile.isClockwise() ? -1 : 1;
float speed = tile.getNetwork().getAngularVelocity() / 20;
entity.addVelocity(inversion * dir.offsetX * speed, Math.random() * speed, inversion * dir.offsetZ * speed);
float speed = tile.getAngularVelocity() / 20;
entity.addVelocity(dir.offsetX * speed, Math.random() * speed, dir.offsetZ * speed);
}
}
}

View file

@ -36,7 +36,7 @@ public class RenderGrinderWheel extends TileEntitySpecialRenderer
glTranslatef((float) x + 0.5F, (float) y + 0.5f, (float) z + 0.5F);
glScalef(0.51f, 0.51f, 0.51f);
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection());
glRotatef((float) Math.toDegrees(tile.getNetwork().getRotation() * (tile.isClockwise() ? 1 : -1)), 0, 0, 1);
glRotatef((float) Math.toDegrees(tile.angle), 0, 0, 1);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
MODEL.renderAll();
glPopMatrix();

View file

@ -40,6 +40,7 @@ public class TileGrinderWheel extends TileMechanical implements IRotatable
public void updateEntity()
{
super.updateEntity();
counter = Math.max(counter + torque, 0);
doWork();
}
@ -50,7 +51,7 @@ public class TileGrinderWheel extends TileMechanical implements IRotatable
*/
public boolean canWork()
{
return (counter = Math.max(counter + getNetwork().getTorque(), 0)) > requiredTorque;
return counter > requiredTorque;
}
public void doWork()