-
Notifications
You must be signed in to change notification settings - Fork 4
/
bravo_blocks.py
384 lines (348 loc) · 7.85 KB
/
bravo_blocks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#stolen from the awesome server Bravo (http://github.com/MostAwesomeDude/bravo)
#insert MIT attribution and copyright here
from __future__ import division
class Block(object):
"""
A model for a block.
There are lots of rule and properties specific to different types of
blocks. This class encapsulates those properties in a singleton-style
interface, allowing many blocks to be referenced in one location.
"""
__slots__ = (
"drop",
"key",
"name",
"quantity",
"ratio",
"replace",
"slot",
"dim",
)
def __init__(self, slot, name, drop=None, replace=0, ratio=1,
quantity=1, dim=16):
"""
A block in a chunk.
:Parameters:
slot : int
The index of this block. Globally unique.
name : str
A common name for this block.
drop : int
The type of block that should be dropped when an instance of
this block is destroyed. Defaults to the slot value, to drop
instances of this same type of block.
replace : int
The type of block to place in the map when instances of this
block are destroyed. Defaults to air.
ratio : float
The probability of this block dropping a block on destruction.
quantity : int
The number of blocks dropped when this block is destroyed.
dim : int
How much light dims when passing through this kind of block.
Defaults to 16 = opaque block.
"""
self.slot = slot
self.name = name
# XXX
self.key = (self.slot, 0)
if drop is None:
self.drop = slot
else:
self.drop = drop
self.replace = replace
self.ratio = ratio
self.quantity = quantity
self.dim = dim
class Item(object):
"""
An item.
"""
__slots__ = (
"key",
"name",
"slot",
)
def __init__(self, slot, name):
"""
An item.
"""
self.slot = slot
self.name = name
# XXX
self.key = (self.slot, 0)
block_names = [
"air",
"stone",
"grass",
"dirt",
"cobblestone",
"wood",
"sapling",
"bedrock",
"water",
"spring",
"lava",
"lava-spring",
"sand",
"gravel",
"gold-ore",
"iron-ore",
"coal-ore",
"log",
"leaves",
"sponge",
"glass",
"lapis-lazuli-ore",
"lapis-lazuli",
"dispenser",
"sandstone",
"note-block",
"aqua-cloth",
"cyan-cloth",
"blue-cloth",
"purple-cloth",
"indigo-cloth",
"violet-cloth",
"magenta-cloth",
"pink-cloth",
"black-cloth",
"grey-cloth",
"wool",
"flower",
"rose",
"brown-mushroom",
"red-mushroom",
"gold",
"iron",
"double-step",
"step",
"brick",
"tnt",
"bookshelf",
"mossy-cobblestone",
"obsidian",
"torch",
"fire",
"mob-spawner",
"wooden-stairs",
"chest",
"redstone-wire",
"diamond-ore",
"diamond",
"workbench",
"crops",
"soil",
"furnace",
"burning-furnace",
"signpost",
"wooden-door",
"ladder",
"tracks",
"stone-stairs",
"wall-sign",
"lever",
"stone-plate",
"iron-door",
"wooden-plate",
"redstone-ore",
"glowing-redstone-ore",
"redstone-torch",
"redstone-torch-on",
"stone-button",
"snow",
"ice",
"snow-block",
"cactus",
"clay",
"sugar-cane",
"jukebox",
"fence",
"pumpkin",
"brimstone",
"slow-sand",
"lightstone",
"portal",
"jack-o-lantern",
"cake",
]
item_names = [
"iron-shovel",
"iron-pickaxe",
"iron-axe",
"flint-and-steel",
"apple",
"bow",
"arrow",
"coal",
"diamond",
"iron-ingot",
"gold-ingot",
"iron-sword",
"wooden-sword",
"wooden-shovel",
"wooden-pickaxe",
"wooden-axe",
"stone-sword",
"stone-shovel",
"stone-pickaxe",
"stone-axe",
"diamond-sword",
"diamond-shovel",
"diamond-pickaxe",
"diamond-axe",
"stick",
"bowl",
"mushroom-soup",
"gold-sword",
"gold-shovel",
"gold-pickaxe",
"gold-axe",
"string",
"feather",
"sulphur",
"wooden-hoe",
"stone-hoe",
"iron-hoe",
"diamond-hoe",
"gold-hoe",
"seeds",
"wheat",
"bread",
"leather-helmet",
"leather-chestplate",
"leather-leggings",
"leather-boots",
"chainmail-helmet",
"chainmail-chestplate",
"chainmail-leggings",
"chainmail-boots",
"iron-helmet",
"iron-chestplate",
"iron-leggings",
"iron-boots",
"diamond-helmet",
"diamond-chestplate",
"diamond-leggings",
"diamond-boots",
"gold-helmet",
"gold-chestplate",
"gold-leggings",
"gold-boots",
"flint",
"raw-porkchop",
"cooked-porkchop",
"paintings",
"golden-apple",
"sign",
"wooden-door",
"bucket",
"water-bucket",
"lava-bucket",
"mine-cart",
"saddle",
"iron-door",
"redstone",
"snowball",
"boat",
"leather",
"milk",
"clay-brick",
"clay-balls",
"sugar-cane",
"paper",
"book",
"slimeball",
"storage-minecart",
"powered-minecart",
"egg",
"compass",
"fishing-rod",
"clock",
"glowstone-dust",
"raw-fish",
"cooked-fish",
"ink-sack",
"bone",
"sugar",
"cake",
]
special_item_names = [
"gold-music-disc",
"green-music-disc",
]
drops = {}
# Block -> block drops.
# If the drop block is zero, then it drops nothing.
drops[1] = 4 # Stone -> Cobblestone
drops[2] = 3 # Grass -> Dirt
drops[18] = 6 # Leaves -> Sapling
drops[20] = 0 # Glass
drops[60] = 3 # Soil -> Dirt
drops[62] = 61 # Burning Furnace -> Furnace
drops[78] = 0 # Snow
drops[79] = 0 # Ice
# Block -> item drops.
drops[13] = 318 # Gravel -> Flint
drops[16] = 263 # Coal Ore Block -> Coal
drops[56] = 264 # Diamond Ore Block -> Diamond
drops[63] = 323 # Sign Post -> Sign Item
drops[64] = 324 # Wooden Door -> Wooden Door Item
drops[68] = 323 # Wall Sign -> Sign Item
drops[71] = 330 # Iron Door -> Iron Door Item
drops[73] = 331 # Redstone Ore -> Redstone Dust
drops[74] = 331 # Redstone Ore -> Redstone Dust
drops[82] = 337 # Clay -> Clay Balls
drops[83] = 338 # Reed -> Reed Item
drops[89] = 348 # Lightstone -> Lightstone Dust
replaces = {}
replaces[79] = 8 # Ice -> Water
ratios = {}
ratios[13] = 1 / 10 # Gravel
ratios[18] = 1 / 9 # Leaves
quantities = {}
quantities[73] = 5 # Redstone Ore -> Redstone Dust
quantities[74] = 5 # Redstone Ore -> Redstone Dust
quantities[82] = 4 # Clay -> Clay Balls
blocks = {}
"""
A dictionary of ``Block`` objects.
This dictionary can be indexed by slot number or block name.
"""
items = {}
"""
A dictionary of ``Item`` objects.
This dictionary can be indexed by slot number or block name.
"""
for i, name in enumerate(block_names):
kwargs = {}
if i in drops:
kwargs["drop"] = drops[i]
if i in replaces:
kwargs["replace"] = replaces[i]
if i in ratios:
kwargs["ratio"] = ratios[i]
if i in quantities:
kwargs["quantity"] = quantities[i]
b = Block(i, name, **kwargs)
blocks[i] = b
blocks[name] = b
for i, name in enumerate(item_names):
kwargs = {}
i += 0x100
item = Item(i, name, **kwargs)
items[i] = item
items[name] = item
for i, name in enumerate(special_item_names):
kwargs = {}
i += 0x8D0
item = Item(i, name, **kwargs)
items[i] = item
items[name] = item
glowing_blocks = {
blocks["torch"].slot: 14,
}
blocks["air"].dim = 0
blocks["water"].dim = 3
blocks["spring"].dim = 3
blocks["ice"].dim = 3