packages feed

nbt 0.6 → 0.7

raw patch · 3 files changed

+16/−6 lines, 3 files

Files

nbt.cabal view
@@ -1,21 +1,21 @@ Name:                nbt-Version:             0.6+Version:             0.7 Synopsis: A parser/serializer for Minecraft's Named Binary Tag (NBT)   data format. Description: This package includes a data type for the NBT file   format, notably used to represent saved data in Minecraft and-  significant parts of the Minecraft network protocol.  All twelve-  tags of verion 19133 (needed for Anvil maps) are implemented.+  significant parts of the Minecraft network protocol.  All thirteen+  tags used in Minecraft 1.13 are implemented. Homepage:            https://github.com/acfoltzer/nbt Bug-reports:         https://github.com/acfoltzer/nbt/issues License:             BSD3 License-file:        LICENSE Author:              Adam C. Foltzer <acfoltzer@gmail.com>, Stijn van Drongelen <rhymoid@gmail.com> Maintainer:          Adam C. Foltzer <acfoltzer@gmail.com>-Tested-With:         GHC==7.0.4, GHC==7.4.1, GHC==7.6.2+Tested-With:         GHC==7.0.4, GHC==7.4.1, GHC==7.6.2, GHC==8.0.2 Category:            Data Build-type:          Simple-Cabal-version:       >=1.14+Cabal-version:       1.14 data-files:          test/testWorld/level.dat                      test/testWorld/region/r.-1.-1.mcr                      test/testWorld/region/r.0.-1.mcr
src/Data/NBT.hs view
@@ -58,6 +58,7 @@     | ListType     | CompoundType     | IntArrayType+    | LongArrayType     deriving (Show, Eq, Enum)  instance Serialize TagType where@@ -81,6 +82,7 @@     | ListTag      (Array Int32 NbtContents)     | CompoundTag  [NBT]     | IntArrayTag  (UArray Int32 Int32)+    | LongArrayTag (UArray Int32 Int64)     deriving (Show, Eq)  getByType :: TagType -> Get NbtContents@@ -96,6 +98,7 @@ getByType ListType      = ListTag      <$> getList getByType CompoundType  = CompoundTag  <$> getCompoundElements getByType IntArrayType  = IntArrayTag  <$> getArrayElements get+getByType LongArrayType = LongArrayTag <$> getArrayElements get  getList :: Get (Array Int32 NbtContents) getList = do@@ -165,6 +168,7 @@     ListTag ts          -> putList ts     CompoundTag ts      -> putCompoundElements ts     IntArrayTag is      -> putArray put is+    LongArrayTag is     -> putArray put is  instance Serialize NBT where     get = do@@ -190,3 +194,4 @@ typeOf ListTag      {} = ListType typeOf CompoundTag  {} = CompoundType typeOf IntArrayTag  {} = IntArrayType+typeOf LongArrayTag {} = LongArrayType
test/RoundTrip.hs view
@@ -28,7 +28,7 @@ #endif  instance Arbitrary TagType where-    arbitrary = toEnum <$> choose (1, 11)+    arbitrary = toEnum <$> choose (1, 12)     -- don't arbitrarily pick end type, it has special meaning  eitherErr :: (Either String a -> a)@@ -73,6 +73,11 @@             v    <- vector len             let a = listArray (0, fromIntegral len - 1) v             return (IntArrayTag a)+          LongArrayType -> do+            len  <- choose (0, 100)+            v    <- vector len+            let a = listArray (0, fromIntegral len - 1) v+            return (LongArrayTag a)  prop_NBTroundTrip :: NBT -> Bool prop_NBTroundTrip nbt = eitherErr (decode (encode nbt)) == nbt