Add methods to easily write/read other types of data to/from the broadcast array
Closed this issue · 1 comments
kazimuth commented
See the get
/ put
methods of https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html
Pear0 commented
For boolean
s, I just use 1 or 0, but for floats, I have:
public class Broadcast {
public static float getFloat(int channel) throws GameActionException {
return Float.intBitsToFloat(rc.readBroadcast(channel));
}
public static void setFloat(int channel, float value) throws GameActionException {
rc.broadcast(channel, Float.floatToIntBits(value));
}
}
The internals of Float.floatToIntBits
and Float.intBitsToFloat
don't cost anything because Float
is in java/lang
.