Skip to content

Commit dfbed58

Browse files
author
Lieuwe Westra
committed
modiefied docs to reflect new textures.py setup
1 parent 6ac3c7d commit dfbed58

File tree

2 files changed

+168
-130
lines changed

2 files changed

+168
-130
lines changed

docs/contributing.rst

+20-39
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,21 @@ Let's take a closer look at the ``overviewer_core/`` directory:
127127

128128
* ``signals.py`` is multiprocessing communication code. Scary stuff.
129129

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.
134134

135135
* ``tileset.py`` contains code that maps a render dict entry to the output tiled
136136
image structure.
137137

138138
* ``util.py`` contains random utility code that has no home anywhere else.
139139

140140
* ``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.
143145

144146
docs
145147
----
@@ -184,8 +186,8 @@ Adding a Block
184186

185187
Let's assume you want to add support for a new block to the Overviewer. This is
186188
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.
189191

190192
The place to look here is ``textures.py``. It contains the block definitions,
191193
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.
202204
Simple Solid 6-Sided Block
203205
~~~~~~~~~~~~~~~~~~~~~~~~~~
204206

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::
209211

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")
231213

232214
Block with Variable Colors
233215
~~~~~~~~~~~~~~~~~~~~~~~~~~
234216

235217
Occasionally, blocks can have colors stored in their data values.
236218
``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
238220
as an example of how this is used::
239221

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])
245226

246227
As you can see, we specify that the block has 16 data values, then depending
247228
on the data value we load the right block texture by looking up the color name

0 commit comments

Comments
 (0)