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);
|
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.multipleParticleScaleBy(scale);
|
||||||
|
fx.noClip = true;
|
||||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
|
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
/** The current rotation of the network */
|
/** The current rotation of the network */
|
||||||
private float rotation = 0;
|
private float rotation = 0;
|
||||||
private long lastRotateTime;
|
private long lastRotateTime;
|
||||||
private boolean markPacketUpdate = true;
|
|
||||||
|
|
||||||
/** The direction in which a conductor is placed relative to a specific conductor. */
|
/** 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>>();
|
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 Set<IMechanical> generators = new LinkedHashSet<IMechanical>();
|
||||||
private boolean disabled;
|
private boolean disabled;
|
||||||
|
|
||||||
|
private boolean markUpdateRotation = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConnector(IMechanical connector)
|
public void addConnector(IMechanical connector)
|
||||||
{
|
{
|
||||||
this.markPacketUpdate = true;
|
|
||||||
super.addConnector(connector);
|
super.addConnector(connector);
|
||||||
|
NetworkTickHandler.addNetwork(this);
|
||||||
|
markUpdateRotation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,7 +76,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
/**
|
/**
|
||||||
* Calculation rotations of all generators.
|
* 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>();
|
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();
|
generators.clear();
|
||||||
|
@ -109,7 +112,6 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
if (getPrevTorque() != getTorque() || getPrevAngularVelocity() != getAngularVelocity())
|
if (getPrevTorque() != getTorque() || getPrevAngularVelocity() != getAngularVelocity())
|
||||||
{
|
{
|
||||||
sendNetworkPacket();
|
sendNetworkPacket();
|
||||||
markPacketUpdate = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prevTorque = torque;
|
prevTorque = torque;
|
||||||
|
@ -121,7 +123,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
@Override
|
@Override
|
||||||
public boolean canUpdate()
|
public boolean canUpdate()
|
||||||
{
|
{
|
||||||
return !disabled;
|
return !disabled && getConnectors().size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -152,7 +154,10 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
int[] location = connector.getLocation();
|
int[] location = connector.getLocation();
|
||||||
|
|
||||||
if (location != null)
|
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()));
|
PacketDispatcher.sendPacketToAllPlayers(Mechanical.PACKET_NETWORK.getPacket(location[0], location[1], location[2], location[3], (byte) 1, connector.isClockwise()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package resonantinduction.mechanical.network;
|
package resonantinduction.mechanical.network;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import universalelectricity.api.vector.Vector3;
|
||||||
import calclavia.lib.prefab.tile.TileAdvanced;
|
import calclavia.lib.prefab.tile.TileAdvanced;
|
||||||
|
|
||||||
public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
||||||
|
@ -15,6 +17,24 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
||||||
@Override
|
@Override
|
||||||
public Object[] getConnections()
|
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;
|
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());
|
dir = ForgeDirection.getOrientation(!(dir.ordinal() % 2 == 0) ? dir.ordinal() - 1 : dir.ordinal());
|
||||||
int inversion = tile.isClockwise() ? -1 : 1;
|
int inversion = tile.isClockwise() ? -1 : 1;
|
||||||
float speed = tile.getNetwork().getAngularVelocity() / 20;
|
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…
Reference in a new issue