Fixed some network rotation and EntityFx crash
This commit is contained in:
parent
27ec5e6de1
commit
833fab1301
4 changed files with 33 additions and 7 deletions
|
@ -62,6 +62,7 @@ public class ClientProxy extends CommonProxy
|
|||
{
|
||||
EntityFX fx = new EntityDiggingFX(world, position.x, position.y, position.z, velocity.x, velocity.y, velocity.z, Block.blocksList[blockID], 0, 0);
|
||||
fx.multipleParticleScaleBy(scale);
|
||||
fx.noClip = true;
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
/** The current rotation of the network */
|
||||
private float rotation = 0;
|
||||
private long lastRotateTime;
|
||||
private boolean markPacketUpdate = true;
|
||||
|
||||
/** The direction in which a conductor is placed relative to a specific conductor. */
|
||||
protected final HashMap<Object, EnumSet<ForgeDirection>> handlerDirectionMap = new LinkedHashMap<Object, EnumSet<ForgeDirection>>();
|
||||
|
@ -58,11 +57,14 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
private Set<IMechanical> generators = new LinkedHashSet<IMechanical>();
|
||||
private boolean disabled;
|
||||
|
||||
private boolean markUpdateRotation = true;
|
||||
|
||||
@Override
|
||||
public void addConnector(IMechanical connector)
|
||||
{
|
||||
this.markPacketUpdate = true;
|
||||
super.addConnector(connector);
|
||||
NetworkTickHandler.addNetwork(this);
|
||||
markUpdateRotation = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +76,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
/**
|
||||
* Calculation rotations of all generators.
|
||||
*/
|
||||
if (!(prevGenerators.equals(generators)) && generators.size() > 0)
|
||||
if (markUpdateRotation || (!(prevGenerators.equals(generators)) && generators.size() > 0))
|
||||
{
|
||||
Set<IMechanical> closedSet = new LinkedHashSet<IMechanical>();
|
||||
|
||||
|
@ -89,7 +91,8 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
}
|
||||
}
|
||||
|
||||
prevGenerators = new LinkedHashSet<>(generators);
|
||||
markUpdateRotation = false;
|
||||
prevGenerators = new LinkedHashSet<IMechanical>(generators);
|
||||
}
|
||||
|
||||
generators.clear();
|
||||
|
@ -109,7 +112,6 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
if (getPrevTorque() != getTorque() || getPrevAngularVelocity() != getAngularVelocity())
|
||||
{
|
||||
sendNetworkPacket();
|
||||
markPacketUpdate = false;
|
||||
}
|
||||
|
||||
prevTorque = torque;
|
||||
|
@ -121,7 +123,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return !disabled;
|
||||
return !disabled && getConnectors().size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,7 +154,10 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
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
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package resonantinduction.mechanical.network;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.prefab.tile.TileAdvanced;
|
||||
|
||||
public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
||||
|
@ -15,6 +17,24 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
|||
@Override
|
||||
public Object[] getConnections()
|
||||
{
|
||||
connections = new Object[6];
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = new Vector3(this).translate(dir).getTileEntity(worldObj);
|
||||
|
||||
if (tile instanceof IMechanical)
|
||||
{
|
||||
IMechanical mech = (IMechanical) ((IMechanical) tile).getInstance(dir.getOpposite());
|
||||
|
||||
if (mech != null && canConnect(dir) && mech.canConnect(dir.getOpposite()))
|
||||
{
|
||||
connections[dir.ordinal()] = mech;
|
||||
getNetwork().merge(mech.getNetwork());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return connections;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class BlockGrinderWheel extends BlockRIRotatable implements ITileEntityPr
|
|||
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, inversion * dir.offsetZ * speed, Math.random() * speed);
|
||||
entity.addVelocity(inversion * dir.offsetX * speed, Math.random() * speed, inversion * dir.offsetZ * speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue