@@ -127,19 +127,21 @@ Let's take a closer look at the ``overviewer_core/`` directory:
127
127
128
128
* ``signals.py `` is multiprocessing communication code. Scary stuff.
129
129
130
- * ``textures.py `` contains all the block definitions and how Overviewer should
131
- render them. If you want to add a new block to the Overviewer, this is where
132
- you'll want to do it. Additionally, this code also controls how the textures
133
- are loaded.
130
+ * ``textures.py `` contains the custom block definitions and how Overviewer
131
+ should render them. If a block is not rendering properly in Overviewer,
132
+ this is where you'll want to fix it. Additionally, this code also controls
133
+ how the textures are loaded.
134
134
135
135
* ``tileset.py `` contains code that maps a render dict entry to the output tiled
136
136
image structure.
137
137
138
138
* ``util.py `` contains random utility code that has no home anywhere else.
139
139
140
140
* ``world.py `` is a whole lot of code that does things like choosing which
141
- chunks to load and to cache, and general functionality revolving around the
142
- concept of Minecraft worlds.
141
+ chunks to load and to cache, how to interpret block properties, and
142
+ general functionality revolving around the concept of Minecraft worlds.
143
+ If a block is not behaving like you expect this is probably where
144
+ you'll fix that.
143
145
144
146
docs
145
147
----
@@ -184,8 +186,8 @@ Adding a Block
184
186
185
187
Let's assume you want to add support for a new block to the Overviewer. This is
186
188
probably one of the most common ways people start contributing to the project,
187
- as all blocks in the Overviewer are currently hardcoded and code to handle them
188
- needs to be added by hand.
189
+ as anything but the simplest blocks in the Overviewer are currently hardcoded
190
+ and code to handle them needs to be added by hand.
189
191
190
192
The place to look here is ``textures.py ``. It contains the block definitions,
191
193
which are assisted by Python decorators _, which make it quite a bit simpler to
@@ -202,46 +204,25 @@ as ``solid=True`` to indicate that the block is a solid block.
202
204
Simple Solid 6-Sided Block
203
205
~~~~~~~~~~~~~~~~~~~~~~~~~~
204
206
205
- A lot of times, new blocks are basically just your standard full-height block
206
- with a new texture. For a block this simple, we don't even really need to use
207
- the material decorator. As an example, check out the definition of the coal
208
- block::
207
+ Most blocks are simple full height solid blocks. These blocks are automatically
208
+ picked up by the `` unbound_models() `` method from the minecraft assets.
209
+ Sometimes these blocks have special properties that can not be picked up
210
+ from the assets, like transparency. These blocks can be added like this::
209
211
210
- block(blockid=173, top_image="assets/minecraft/textures/blocks/coal_block.png")
211
-
212
- Block with a Different Top
213
- ~~~~~~~~~~~~~~~~~~~~~~~~~~
214
-
215
- Another common theme is a block where the top is a different texture than the
216
- sides. Here we use the ``@material `` decorator to create the jukebox block::
217
-
218
- @material(blockid=84, data=range(16), solid=True)
219
- def jukebox(self, blockid, data):
220
- return self.build_block(self.load_image_texture("assets/minecraft/textures/blocks/jukebox_top.png"), self.load_image_texture("assets/minecraft/textures/blocks/noteblock.png"))
221
-
222
- As you can see, we define a method called ``jukebox ``, taking the parameters
223
- ``blockid `` and ``data ``, decorated by a decorator stating that the following
224
- definition is a material with a ``blockid `` of ``84 `` and a data value range
225
- from ``0 `` to ``15 `` (or ``range(16) ``), which we won't use as it doesn't affect
226
- the rendering of the block. We also specify that the block is solid.
227
-
228
- Inside the method, we then return the return value of ``self.build_block() ``,
229
- which is a helper method that takes a texture for the top and a texture for the
230
- side as its arguments.
212
+ transparentmodelblock(blockid=1125, name="mangrove_roots")
231
213
232
214
Block with Variable Colors
233
215
~~~~~~~~~~~~~~~~~~~~~~~~~~
234
216
235
217
Occasionally, blocks can have colors stored in their data values.
236
218
``textures.py `` includes an easy mapping list, called ``color_map ``, to map
237
- between data values and Minecraft color names. Let's take stained hardened clay
219
+ between data values and Minecraft color names. Let's take carpet
238
220
as an example of how this is used::
239
221
240
- @material(blockid=159, data=range(16), solid=True)
241
- def stained_clay(self, blockid, data):
242
- texture = self.load_image_texture("assets/minecraft/textures/blocks/hardened_clay_stained_%s.png" % color_map[data])
243
-
244
- return self.build_block(texture,texture)
222
+ @material(blockid=171, data=list(range(17)), transparent=True)
223
+ def carpet(self, blockid, data):
224
+ if data < 16:
225
+ texture = self.load_image_texture("assets/minecraft/textures/block/%s_wool.png" % color_map[data])
245
226
246
227
As you can see, we specify that the block has 16 data values, then depending
247
228
on the data value we load the right block texture by looking up the color name
0 commit comments