mcpi 0.0.1.0 → 0.0.1.1
raw patch · 5 files changed
+76/−12 lines, 5 files
Files
- CHANGELOG +46/−0
- examples/DebugMCPI.hs +2/−2
- examples/Shapes.hs +21/−4
- mcpi.cabal +6/−5
- src/Network/MineCraft/Pi/Client/Internal.hs +1/−1
+ CHANGELOG view
@@ -0,0 +1,46 @@+Version 0.0.1.1+===============++Renamec the change log from CHANGES.md to CHANGELOG so+that Hackage will display it.++Minor HLint changes (no change in behavior or API).++Version 0.0.1.0+===============++Updated to use pipes version 4; there is no change in the+library API (pipes is only used by the hmcpi executable).++Version 0.0.0.4+===============++An initial attempt at handling invalid commands has been added by+flushing the connection buffer each time a command or query is sent.++Queries now raise an `IOError` if they return the message `Fail` (it+could also be due to the previous command failing if the buffer+flush mentioned above did not catch the error).++Added the debugmcpi example. This is now built, along with hmcpi,+by setting the build-debug configure option (which is turned off+by default).++Version 0.0.0.3+===============++The examples - apart from `hmcpi` - now accept the `--debug` command-line+option which causes the messages sent to, and received from, MineCraft+to be printed to the standard-error channel. The format of these +messages has been changed slightly.++Version 0.0.0.2+===============++Minor document improvements. Added examples/XJump.hs, which is the+example used in the documentation for Network.MineCraft.Pi.Client.++Version 0.0.0.1+===============++Initial version.
examples/DebugMCPI.hs view
@@ -57,8 +57,8 @@ -- @query@ rather than handle the output here. handleUser :: String -> MCPI () handleUser [] = return ()-handleUser "quit" = liftIO $ exitSuccess-handleUser "exit" = liftIO $ exitSuccess+handleUser "quit" = liftIO exitSuccess+handleUser "exit" = liftIO exitSuccess handleUser user = case words user of ("command":comm:args) -> command comm args
examples/Shapes.hs view
@@ -1,5 +1,23 @@ {-# LANGUAGE RecordWildCards #-} +{-+License:++This code is placed in the Public Domain.++Author:++Douglas Burke (dburke.gw@gmail.com)++Usage:++ ./shapes++Every second, report the block type that the user is standing on+if it is different than the last report.++-}+ module Main where import Control.Concurrent (threadDelay)@@ -75,7 +93,7 @@ renderShape :: Shapes -> MCPI () renderShape = - let rs (BlockList bt pos) = mapM_ (\p -> setBlock p bt) pos+ let rs (BlockList bt pos) = mapM_ (`setBlock` bt) pos rs (BlockCuboid bt p1 p2) = setBlocks p1 p2 bt in mapM_ rs @@ -117,7 +135,7 @@ Pos {..} <- getPlayerTile let x1 = _x - 128 y1 = _y + 20 - setBlocks (Pos x1 y1 (_z-1)) (Pos (x1+255) (y1+4) (_z+1)) $ sandstone+ setBlocks (Pos x1 y1 (_z-1)) (Pos (x1+255) (y1+4) (_z+1)) sandstone forM_ [0..255] $ \ctr -> setBlocks @@ -135,7 +153,7 @@ x2 = x1 + 2 * hw y2 = y1 + 2 * hw z = _z - 1- setBlocks (Pos x1 y1 (z-1)) (Pos x2 y2 (z-1)) $ sandstone+ setBlocks (Pos x1 y1 (z-1)) (Pos x2 y2 (z-1)) sandstone forM_ [0..15] $ \j -> let ys = y1 + j * w@@ -150,7 +168,6 @@ (Pos xe ye z) $ BlockType ctr --- TODO: report only when block data differs reportBlock :: MCPI () reportBlock = let go oPos = do
mcpi.cabal view
@@ -1,5 +1,5 @@ Name: mcpi-Version: 0.0.1.0+Version: 0.0.1.1 Homepage: https://github.com/DougBurke/hmcpi Bug-Reports: https://github.com/DougBurke/hmcpi/issues Stability: experimental@@ -20,17 +20,18 @@ as well as a program that lets you interact with MineCraft directly. . Please see the TODO.md file in the source code for an incomplete- list of possible changes, and the CHANGES.md file for changes+ list of possible changes, and the CHANGELOG file for changes in the module. Tested-With: GHC==7.4.1 Cabal-Version: >= 1.8 Build-Type: Simple -Data-Files: examples/README.md- examples/*.hs+Extra-Source-Files: CHANGELOG+ examples/README.md+ examples/*.hs -source-repository head+Source-Repository head type: git location: git://github.com/DougBurke/hmcpi.git
src/Network/MineCraft/Pi/Client/Internal.hs view
@@ -146,7 +146,7 @@ withForeignPtr fbuf $ \bufPtr -> let loop store = do nrec <- hGetBufNonBlocking _ciHandle bufPtr bufSize- if (nrec > 0)+ if nrec > 0 then peekCStringLen (bufPtr, nrec) >>= \str -> loop (store ++ str) else unless (null store) $ logMsg ci "FLUSH" store in loop []