mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-10 20:45:59 +01:00
LightPacking utility class
This commit is contained in:
parent
555cc2e57e
commit
cc5949a4bb
@ -76,6 +76,12 @@ public abstract class MappedBuffer extends VecBuffer implements AutoCloseable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public MappedBuffer putShort(short s) {
|
||||
checkAndMap();
|
||||
super.putShort(s);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MappedBuffer put(byte b) {
|
||||
checkAndMap();
|
||||
super.put(b);
|
||||
|
@ -72,6 +72,11 @@ public class VecBuffer {
|
||||
return this;
|
||||
}
|
||||
|
||||
public VecBuffer putShort(short s) {
|
||||
internal.putShort(s);
|
||||
return this;
|
||||
}
|
||||
|
||||
public VecBuffer put(byte b) {
|
||||
internal.put(b);
|
||||
return this;
|
||||
|
26
src/main/java/com/jozufozu/flywheel/light/LightPacking.java
Normal file
26
src/main/java/com/jozufozu/flywheel/light/LightPacking.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.jozufozu.flywheel.light;
|
||||
|
||||
/**
|
||||
* Utility class for bit-twiddling light.
|
||||
*/
|
||||
public class LightPacking {
|
||||
public static int getBlock(short packed) {
|
||||
return (packed >> 4) & 0xF;
|
||||
}
|
||||
|
||||
public static int getSky(short packed) {
|
||||
return (packed >> 12) & 0xF;
|
||||
}
|
||||
|
||||
public static byte packLightNibbles(byte block, byte sky) {
|
||||
return (byte) (block | (sky << 4));
|
||||
}
|
||||
|
||||
public static int getBlock(byte packed) {
|
||||
return packed & 0xF;
|
||||
}
|
||||
|
||||
public static int getSky(byte packed) {
|
||||
return (packed >> 4) & 0xF;
|
||||
}
|
||||
}
|
@ -218,24 +218,4 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
||||
return ListenerStatus.OKAY;
|
||||
}
|
||||
|
||||
public static int unpackBlock(short packed) {
|
||||
return (packed >> 4) & 0xF;
|
||||
}
|
||||
|
||||
public static int unpackSky(short packed) {
|
||||
return (packed >> 12) & 0xF;
|
||||
}
|
||||
|
||||
public static byte packLight(byte block, byte sky) {
|
||||
return (byte) (block | (sky << 4));
|
||||
}
|
||||
|
||||
public static int unpackBlock(byte packed) {
|
||||
return packed & 0xF;
|
||||
}
|
||||
|
||||
public static int unpackSky(byte packed) {
|
||||
return (packed >> 4) & 0xF;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user