8989import se .llbit .chunky .world .Material ;
9090import se .llbit .json .JsonString ;
9191import se .llbit .json .JsonValue ;
92+ import se .llbit .math .ColorUtil ;
9293import se .llbit .math .Ray ;
9394
9495import java .util .Arrays ;
@@ -113,7 +114,7 @@ public class Block extends Material {
113114 private static final boolean UNKNOWN_INVISIBLE = !PersistentSettings .drawUnknownBlocks ();
114115
115116 public static final int AIR_ID = 0x00 ;
116- public static final Block AIR = new Block (AIR_ID , "Air " , Texture .air );
117+ public static final Block AIR = new Block (AIR_ID , "block:air " , Texture .air );
117118 public static final int STONE_ID = 0x01 ;
118119 public static final Block STONE = new Block (STONE_ID , "block:stone" , Texture .stone ) {
119120 final Texture [] texture = {
@@ -277,12 +278,31 @@ public class Block extends Material {
277278 };
278279 public static final int LEAVES_ID = 0x12 ;
279280 public static final Block LEAVES = new Block (LEAVES_ID , "block:leaves" , Texture .oakLeaves ) {
280- final Texture [] texture =
281- { Texture . oakLeaves , Texture . spruceLeaves , Texture . birchLeaves , Texture . jungleTreeLeaves } ;
281+ private final float [] SPRUCE_COLOR = new float [ 4 ];
282+ private final float [] BIRCH_COLOR = new float [ 4 ] ;
282283
283- @ Override public boolean intersect (Ray ray , Scene scene ) {
284- return LeafModel .intersect (ray , scene , getTexture (ray .getBlockData ()));
284+ {
285+ // Spruce and birch colors are hard-coded.
286+ ColorUtil .getRGBAComponents (0x2b472b , SPRUCE_COLOR );
287+ ColorUtil .getRGBAComponents (0x3a4e25 , BIRCH_COLOR );
288+ }
289+
290+ final Texture [] texture = {
291+ Texture .oakLeaves , Texture .spruceLeaves , Texture .birchLeaves , Texture .jungleTreeLeaves
292+ };
285293
294+ @ Override public boolean intersect (Ray ray , Scene scene ) {
295+ int data = ray .getBlockData ();
296+ switch (data ) {
297+ case 1 :
298+ // Spruce leaf color is not based on biome.
299+ return LeafModel .intersect (ray , getTexture (data ), SPRUCE_COLOR );
300+ case 2 :
301+ // Birch leaf color is not based on biome.
302+ return LeafModel .intersect (ray , getTexture (data ), BIRCH_COLOR );
303+ default :
304+ return LeafModel .intersect (ray , scene , getTexture (data ));
305+ }
286306 }
287307
288308 final String [] woodType = {"oak" , "spruce" , "birch" , "jungle" ,};
0 commit comments