use of blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection in project ImmersiveEngineering by BluSunrize.
the class TileEntityBreakerSwitch method calculateLeftConn.
protected void calculateLeftConn(Matrix4 transform) {
Vec3d leftVec = transform.apply(new Vec3d(-1, .5, .5)).subtract(0, .5, .5);
EnumFacing dir = EnumFacing.getFacingFromVector((float) leftVec.xCoord, (float) leftVec.yCoord, (float) leftVec.zCoord);
int maxDiff = Integer.MIN_VALUE;
Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, pos);
if (conns != null)
for (Connection c : conns) {
Vec3i diff = pos.equals(c.start) ? c.end.subtract(pos) : c.start.subtract(pos);
int val = 0;
switch(dir.getAxis()) {
case X:
val = diff.getX();
break;
case Y:
val = diff.getY();
break;
case Z:
val = diff.getZ();
}
val *= dir.getAxisDirection().getOffset();
if (val > maxDiff) {
maxDiff = val;
endOfLeftConnection = pos == c.end ? c.start : c.end;
}
}
}
use of blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection in project ImmersiveEngineering by BluSunrize.
the class TileEntityBreakerSwitch method onConnectionChange.
protected void onConnectionChange() {
if (worldObj != null && worldObj.isRemote) {
endOfLeftConnection = null;
ImmersiveEngineering.proxy.clearConnectionModelCache();
// reset cached connection vertices
Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, pos);
if (conns != null)
for (Connection c : conns) {
c.catenaryVertices = null;
worldObj.markBlockRangeForRenderUpdate(c.end, c.end);
Set<Connection> connsThere = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, c.end);
if (connsThere != null)
for (Connection c2 : connsThere) if (c2.end.equals(pos))
c2.catenaryVertices = null;
}
}
if (worldObj != null)
markContainingBlockForUpdate(null);
}
use of blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection in project ImmersiveEngineering by BluSunrize.
the class TileEntityEnergyMeter method updateComparatorValues.
private void updateComparatorValues() {
int oldVal = compVal;
int maxTrans = 0;
Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, dummy ? pos.up() : pos);
if (conns == null) {
compVal = 0;
return;
}
for (Connection c : conns) maxTrans += c.cableType.getTransferRate();
maxTrans /= 2;
double val = getAveragePower() / (double) maxTrans;
compVal = (int) Math.ceil(15 * val);
if (oldVal != compVal)
worldObj.updateComparatorOutputLevel(pos, getBlockType());
}
use of blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection in project ImmersiveEngineering by BluSunrize.
the class TileEntityConnectorLV method update.
@Override
public void update() {
if (!worldObj.isRemote) {
// }
if (energyStorage.getEnergyStored() > 0) {
int temp = this.transferEnergy(energyStorage.getEnergyStored(), true, 0);
if (temp > 0) {
energyStorage.modifyEnergyStored(-this.transferEnergy(temp, false, 0));
markDirty();
}
}
currentTickAccepted = 0;
} else if (firstTick) {
Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, pos);
if (conns != null)
for (Connection conn : conns) if (pos.compareTo(conn.end) < 0 && worldObj.isBlockLoaded(conn.end))
this.markContainingBlockForUpdate(null);
firstTick = false;
}
}
use of blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection in project ImmersiveEngineering by BluSunrize.
the class TileEntityImmersiveConnectable method genConnBlockstate.
public Set<Connection> genConnBlockstate() {
Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, pos);
if (conns == null)
return ImmutableSet.of();
Set<Connection> ret = new HashSet<Connection>() {
@Override
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof HashSet))
return false;
HashSet<Connection> other = (HashSet<Connection>) o;
if (other.size() != this.size())
return false;
for (Connection c : this) if (!other.contains(c))
return false;
return true;
}
};
for (Connection c : conns) {
IImmersiveConnectable end = ApiUtils.toIIC(c.end, worldObj, false);
if (end == null)
continue;
// generate subvertices
c.getSubVertices(worldObj);
ret.add(c);
}
return ret;
}
Aggregations