@Override public void onUpdate() { super.onUpdate(); double newSumTemp = 0; double newHeatLost = 0; double newHeatTransferred = 0; if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { for (IGridTransmitter<IHeatTransfer, HeatNetwork> transmitter : transmitters) { if (transmitter instanceof MultipartTransmitter && ((MultipartTransmitter) transmitter).getPart() instanceof IHeatTransfer) { IHeatTransfer heatTransmitter = (IHeatTransfer) ((MultipartTransmitter) transmitter).getPart(); double[] d = heatTransmitter.simulateHeat(); newHeatTransferred += d[0]; newHeatLost += d[1]; } } for (IGridTransmitter<IHeatTransfer, HeatNetwork> transmitter : transmitters) { if (transmitter instanceof MultipartTransmitter && ((MultipartTransmitter) transmitter).getPart() instanceof IHeatTransfer) { IHeatTransfer heatTransmitter = (IHeatTransfer) ((MultipartTransmitter) transmitter).getPart(); newSumTemp += heatTransmitter.applyTemperatureChange(); } } } heatLost = newHeatLost; heatTransferred = newHeatTransferred; meanTemp = newSumTemp / transmitters.size(); }
@Override public void getTileInfo( List<ILogicInfo> infoList, World world, int x, int y, int z, ForgeDirection dir) { int id = this.getID(); TileEntity target = world.getTileEntity(x, y, z); if (target instanceof IHeatTransfer) { IHeatTransfer block = (IHeatTransfer) target; infoList.add(new LogicInfo(id, 0, 0, (int) block.getTemp()).addSuffix("degrees")); } if (target instanceof IEvaporationSolar) { IEvaporationSolar block = (IEvaporationSolar) target; infoList.add(new LogicInfo(id, 0, 1, block.seesSun())); } if (target instanceof ILaserReceptor) { ILaserReceptor block = (ILaserReceptor) target; infoList.add(new LogicInfo(id, 0, 2, block.canLasersDig())); } if (target instanceof IStrictEnergyStorage) { IStrictEnergyStorage block = (IStrictEnergyStorage) target; infoList.add(new LogicInfo(id, 1, 3, (long) block.getEnergy()).addSuffix("J")); ; infoList.add(new LogicInfo(id, 1, 4, (long) block.getMaxEnergy()).addSuffix("J")); } if (target instanceof IStrictEnergyAcceptor) { IStrictEnergyAcceptor block = (IStrictEnergyAcceptor) target; infoList.add(new LogicInfo(id, 1, 5, block.canReceiveEnergy(dir))); } }
public static double[] simulate(IHeatTransfer source) { double heatTransferred[] = new double[] {0, 0}; for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { IHeatTransfer sink = source.getAdjacent(side); if (sink != null) { double invConduction = sink.getInverseConductionCoefficient() + source.getInverseConductionCoefficient(); double heatToTransfer = source.getTemp() / invConduction; source.transferHeatTo(-heatToTransfer); sink.transferHeatTo(heatToTransfer); if (!(sink instanceof ITransmitterTile)) { heatTransferred[0] += heatToTransfer; } continue; } // Transfer to air otherwise double invConduction = IHeatTransfer.AIR_INVERSE_COEFFICIENT + source.getInsulationCoefficient(side) + source.getInverseConductionCoefficient(); double heatToTransfer = source.getTemp() / invConduction; source.transferHeatTo(-heatToTransfer); heatTransferred[1] += heatToTransfer; } return heatTransferred; }