Skip to content

Instantly share code, notes, and snippets.

@Cazzar
Created December 16, 2014 04:51
Show Gist options
  • Save Cazzar/b8348f4f6959d8801eef to your computer and use it in GitHub Desktop.
Save Cazzar/b8348f4f6959d8801eef to your computer and use it in GitHub Desktop.
implicit class RichByteBuf(buf: ByteBuf) {
def writeString(str: String) = ByteBufUtils.writeUTF8String(buf, String)
def readString() = ByteBufUtils.readUTF8String(buf)
def writeItemStack(is: ItemStack) = ByteBufUtils.writeItemStack(buf, is)
def readItemStack() = ByteBufUtils.readItemStack(buf)
def writePos(pos: BlockPos): Unit = {
buf.writeInt(pos.getX)
buf.writeInt(pos.getY)
buf.writeInt(pos.getZ)
}
def readPos() = {
val x = buf.readInt()
val y = buf.readInt()
val z = buf.readInt()
new BlockPos(x, y, z)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment