@@ -0,0 +1,1284 @@
+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 SyncableVarInt extends SyncableObjectBase implements ISyncableValueProvider%3CInteger%3E %7B%0A%0A%09private int value = 0;%0A%0A%09public SyncableVarInt(int value) %7B%0A%09%09Preconditions.checkArgument(value %3E= 0, %22Value must be non-negative%22);%0A%09%09this.value = value;%0A%09%7D%0A%0A%09public SyncableVarInt() %7B%7D%0A%0A%09public void modify(int by) %7B%0A%09%09if (value + by %3E= 0) set(value + by);%0A%09%7D%0A%0A%09public void set(int val) %7B%0A%09%09Preconditions.checkArgument(val %3E= 0, %22Value must be non-negative%22);%0A%09%09if (val != value) %7B%0A%09%09%09value = val;%0A%09%09%09markDirty();%0A%09%09%7D%0A%09%7D%0A%0A%09public int get() %7B%0A%09%09return value;%0A%09%7D%0A%0A%09@Override%0A%09public Integer getValue() %7B%0A%09%09return value;%0A%09%7D%0A%0A%09@Override%0A%09public void readFromStream(DataInputStream stream) %7B%0A%09%09value = ByteUtils.readVLI(stream);%0A%09%7D%0A%0A%09@Override%0A%09public void writeToStream(DataOutputStream stream) %7B%0A%09%09ByteUtils.writeVLI(stream, value);%0A%09%7D%0A%0A%09@Override%0A%09public void writeToNBT(NBTTagCompound tag, String name) %7B%0A%09%09tag.setInteger(name, value);%0A%09%7D%0A%0A%09@Override%0A%09public void readFromNBT(NBTTagCompound tag, String name) %7B%0A%09%09if (tag.hasKey(name)) value = tag.getInteger(name);%0A%09%7D%0A%0A%7D%0A

Add SyncableVarInt