use of mcjty.rftools.network.PacketReturnRfInRange in project RFTools by McJty.
the class RFToolsTools method returnRfInRange.
public static void returnRfInRange(EntityPlayer player) {
BlockPos pos = player.getPosition();
World world = player.getEntityWorld();
Map<BlockPos, MachineInfo> result = new HashMap<>();
int range = 12;
for (int x = -range; x <= range; x++) {
for (int y = -range; y <= range; y++) {
for (int z = -range; z <= range; z++) {
BlockPos p = pos.add(x, y, z);
TileEntity te = world.getTileEntity(p);
if (EnergyTools.isEnergyTE(te)) {
EnergyTools.EnergyLevel level = EnergyTools.getEnergyLevel(te);
Integer usage = null;
if (te instanceof IMachineInformation) {
usage = ((IMachineInformation) te).getEnergyDiffPerTick();
}
result.put(p, new MachineInfo(level.getEnergy(), level.getMaxEnergy(), usage));
}
}
}
}
RFToolsMessages.INSTANCE.sendTo(new PacketReturnRfInRange(result), (EntityPlayerMP) player);
}
Aggregations