@@ -0,0 +1,1761 @@
+package openmods.sync;%0A%0Aimport java.io.DataInputStream;%0Aimport java.io.DataOutputStream;%0A%0Aimport net.minecraft.nbt.NBTTagCompound;%0Aimport openmods.utils.ByteUtils;%0A%0Aimport com.google.common.base.Preconditions;%0A%0Apublic class SyncableEnum%3CE extends Enum%3CE%3E%3E extends SyncableObjectBase implements ISyncableValueProvider%3CE%3E %7B%0A%0A%09private final E%5B%5D values;%0A%0A%09private E value;%0A%0A%09public static %3CE extends Enum%3CE%3E%3E SyncableEnum%3CE%3E create(E initialValue) %7B%0A%09%09return new SyncableEnum%3CE%3E(initialValue);%0A%09%7D%0A%0A%09@SuppressWarnings(%22unchecked%22)%0A%09public SyncableEnum(E value) %7B%0A%09%09this.value = value;%0A%09%09this.values = (E%5B%5D)value.getClass().getEnumConstants();%0A%09%7D%0A%0A%09@Override%0A%09public void readFromStream(DataInputStream stream) %7B%0A%09%09int ordinal = ByteUtils.readVLI(stream);%0A%09%09value = values%5Bordinal%5D;%0A%09%7D%0A%0A%09@Override%0A%09public void writeToStream(DataOutputStream stream, boolean fullData) %7B%0A%09%09ByteUtils.writeVLI(stream, value.ordinal());%0A%09%7D%0A%0A%09@Override%0A%09public void writeToNBT(NBTTagCompound nbt, String name) %7B%0A%09%09nbt.setInteger(name, value.ordinal());%0A%09%7D%0A%0A%09@Override%0A%09public void readFromNBT(NBTTagCompound nbt, String name) %7B%0A%09%09int original = nbt.getInteger(name);%0A%09%09value = values%5Boriginal%5D;%0A%09%7D%0A%0A%09@Override%0A%09public E getValue() %7B%0A%09%09return value;%0A%09%7D%0A%0A%09public E get() %7B%0A%09%09return value;%0A%09%7D%0A%0A%09public void set(E value) %7B%0A%09%09Preconditions.checkNotNull(value);%0A%09%09if (this.value != value) %7B%0A%09%09%09this.value = value;%0A%09%09%09markDirty();%0A%09%09%7D%0A%09%7D%0A%0A%09public E increment() %7B%0A%09%09final int next = value.ordinal() + 1;%0A%09%09if (next %3E= values.length) value = values%5B0%5D;%0A%09%09else value = values%5Bnext%5D;%0A%09%09markDirty();%0A%09%09return value;%0A%09%7D%0A%0A%09public E decrement() %7B%0A%09%09final int prev = value.ordinal() - 1;%0A%09%09if (prev %3C 0) value = values%5Bvalues.length - 1%5D;%0A%09%09else value = values%5Bprev%5D;%0A%09%09markDirty();%0A%09%09return value;%0A%09%7D%0A%7D%0A

Implement SyncableEnum