3b17a92aa31b

Block and item type mappings.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 03 Aug 2011 20:14:46 -0400
parents 3a6904455feb
children 085e63240d4f
branches/tags (none)
files src/clojurecraft/core.clj src/clojurecraft/mappings.clj src/clojurecraft/util.clj

Changes

diff -r 3a6904455feb -r 3b17a92aa31b src/clojurecraft/core.clj
--- a/src/clojurecraft/core.clj	Wed Aug 03 19:30:42 2011 -0400
+++ b/src/clojurecraft/core.clj	Wed Aug 03 20:14:46 2011 -0400
@@ -116,4 +116,3 @@
 (defn disconnect [bot]
   (dosync (alter (:connection bot) merge {:exit true})))
 
-
diff -r 3a6904455feb -r 3b17a92aa31b src/clojurecraft/mappings.clj
--- a/src/clojurecraft/mappings.clj	Wed Aug 03 19:30:42 2011 -0400
+++ b/src/clojurecraft/mappings.clj	Wed Aug 03 20:14:46 2011 -0400
@@ -1,4 +1,6 @@
-(ns clojurecraft.mappings)
+(ns clojurecraft.mappings
+  (:use [clojurecraft.util]))
+
 
 (def packet-types {
   0x00 :keepalive
@@ -59,5 +61,215 @@
   0xC8 :incrementstatistic
   0xFF :disconnectkick
 })
+(def packet-ids (invert packet-types))
 
-(def packet-ids (apply assoc {} (mapcat reverse packet-types)))
+(def block-types {
+  -1   nil
+  0x00 :air
+  0x01 :stone
+  0x02 :grass
+  0x03 :dirt
+  0x04 :cobblestone
+  0x05 :planks
+  0x06 :sapling
+  0x07 :bedrock
+  0x08 :water
+  0x09 :stationary-water
+  0x0A :lava
+  0x0B :stationary-lava
+  0x0C :sand
+  0x0D :gravel
+  0x0E :gold-ore
+  0x0F :iron-ore
+  0x10 :coal-ore
+  0x11 :wood
+  0x12 :leaves
+  0x13 :sponge
+  0x14 :glass
+  0x15 :lapis-ore
+  0x16 :lapis-block
+  0x17 :dispenser
+  0x18 :sandstone
+  0x19 :note
+  0x1A :bed
+  0x1B :powered-rail
+  0x1C :detector-rail
+  0x1D :sticky-piston
+  0x1E :cobweb
+  0x1F :tall-grass
+  0x20 :shrub
+  0x21 :piston
+  0x22 :piston-head
+  0x23 :wool
+  0x25 :flower-yellow
+  0x26 :flower-red
+  0x27 :mushroom-brown
+  0x28 :mushroom-red
+  0x29 :gold-block
+  0x2A :iron-block
+  0x2B :double-slab
+  0x2C :slab
+  0x2D :brick
+  0x2E :tnt
+  0x2F :books
+  0x30 :mossy-cobblestone
+  0x31 :obsidian
+  0x32 :torch
+  0x33 :fire
+  0x34 :spawner
+  0x35 :wood-stairs
+  0x36 :chest
+  0x37 :redstone-wire
+  0x38 :diamond-ore
+  0x39 :diamond-block
+  0x3A :crafting-table
+  0x3B :wheat
+  0x3C :farmland
+  0x3D :furnace
+  0x3E :furnace-lit
+  0x3F :sign-standing
+  0x40 :wood-door
+  0x41 :ladder
+  0x42 :rail
+  0x43 :cobblestone-stairs
+  0x44 :sign-wall
+  0x45 :lever
+  0x46 :stone-plate
+  0x47 :iron-door
+  0x48 :wood-plate
+  0x49 :redstone-ore
+  0x4A :redstone-ore-glowing
+  0x4B :redstone-torch-off
+  0x4C :redstone-torch-on
+  0x4D :stone-button
+  0x4E :snow
+  0x4F :ice
+  0x50 :snow-block
+  0x51 :cactus
+  0x52 :clay
+  0x53 :reeds
+  0x54 :jukebox
+  0x55 :fence
+  0x56 :pumpkin
+  0x57 :netherrack
+  0x58 :soulsand
+  0x59 :glowstone
+  0x5A :portal
+  0x5B :jackolantern
+  0x5C :cake
+  0x5D :repeater-off
+  0x5E :repeater-off
+  0x60 :hatch
+})
+(def block-ids (invert block-types))
+
+(def item-types {
+  -1    nil
+  0x100 :iron-shovel
+  0x101 :iron-pick
+  0x102 :iron-axe
+  0x103 :flint-and-steel
+  0x104 :apple
+  0x105 :box
+  0x106 :arrow
+  0x107 :coal
+  0x108 :diamond
+  0x109 :iron-ingot
+  0x10A :gold-ingot
+  0x10B :gold-sword
+  0x10C :wood-sword
+  0x10D :wood-shovel
+  0x10E :wood-pick
+  0x10F :wood-axe
+  0x110 :stone-sword
+  0x111 :stone-shovel
+  0x112 :stone-pick
+  0x113 :stone-axe
+  0x114 :diamond-sword
+  0x115 :diamond-shovel
+  0x116 :diamond-pick
+  0x117 :diamond-axe
+  0x118 :stick
+  0x119 :bowl
+  0x11A :mushroom-stew
+  0x11B :gold-sword
+  0x11C :gold-shovel
+  0x11D :gold-pick
+  0x11E :gold-axe
+  0x11F :string
+  0x120 :feather
+  0x121 :gunpowder
+  0x122 :wood-hoe
+  0x123 :stone-hoe
+  0x124 :iron-hoe
+  0x125 :diamond-hoe
+  0x126 :gold-hoe
+  0x127 :seeds
+  0x128 :wheat
+  0x129 :bread
+  0x12A :leather-helm
+  0x12B :leather-chestplate
+  0x12C :leather-leggings
+  0x12D :leather-boots
+  0x12E :chain-helm
+  0x12F :chain-chestplate
+  0x130 :chain-leggings
+  0x131 :chain-boots
+  0x132 :iron-helm
+  0x133 :iron-chestplate
+  0x134 :iron-leggings
+  0x135 :iron-boots
+  0x136 :diamond-helm
+  0x137 :diamond-chestplate
+  0x138 :diamond-leggings
+  0x139 :diamond-boots
+  0x13A :gold-helm
+  0x13B :gold-chestplate
+  0x13C :gold-leggings
+  0x13D :gold-boots
+  0x13E :flint
+  0x13F :pork-raw
+  0x140 :pork-cooked
+  0x141 :painting
+  0x142 :golden-apple
+  0x143 :sign
+  0x144 :wood-door
+  0x145 :bucket
+  0x146 :bucket-water
+  0x147 :bucket-lava
+  0x148 :minecart
+  0x149 :saddle
+  0x14A :iron-door
+  0x14B :redstone
+  0x14C :snowball
+  0x14D :boat
+  0x14E :leader
+  0x14F :bucket-milk
+  0x150 :brick
+  0x151 :clay
+  0x152 :reeds
+  0x153 :paper
+  0x154 :book
+  0x155 :slimeball
+  0x156 :minecart-storage
+  0x157 :minecart-powered
+  0x158 :egg
+  0x159 :compass
+  0x15A :fishing-rod
+  0x15B :clock
+  0x15C :glowstone-dust
+  0x15D :fish-raw
+  0x15E :fish-cooked
+  0x15F :ink-sac
+  0x160 :bone
+  0x161 :sugar
+  0x162 :cake
+  0x163 :bed
+  0x164 :repeater
+  0x165 :cookie
+  0x166 :map
+  0x167 :shears
+  0x8D0 :record-gold
+  0x8D1 :record-green
+})
+(def item-ids (invert item-types))
diff -r 3a6904455feb -r 3b17a92aa31b src/clojurecraft/util.clj
--- a/src/clojurecraft/util.clj	Wed Aug 03 19:30:42 2011 -0400
+++ b/src/clojurecraft/util.clj	Wed Aug 03 20:14:46 2011 -0400
@@ -4,3 +4,6 @@
   `(let [result# (~@body)]
      (println result#)
      result#))
+
+(defn invert [m]
+  (apply assoc {} (mapcat reverse m)))