Skip to content

Commit c8cd88f

Browse files
committed
Replace blocks that use the GrassTintedSpriteModel with the TintedSpriteBlock and remove special handling of certain blocks in the 2d surface map. Fix incorrect surface map colors and biome color blending on the 2d surface map.
1 parent cd39b8b commit c8cd88f

File tree

14 files changed

+59
-195
lines changed

14 files changed

+59
-195
lines changed

chunky/src/java/se/llbit/chunky/block/Block.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package se.llbit.chunky.block;
22

33
import se.llbit.chunky.entity.Entity;
4-
import se.llbit.chunky.model.TexturedBlockModel;
54
import se.llbit.chunky.renderer.scene.Scene;
65
import se.llbit.chunky.resources.Texture;
76
import se.llbit.chunky.world.Material;
7+
import se.llbit.chunky.world.biome.Biome;
88
import se.llbit.json.JsonString;
99
import se.llbit.json.JsonValue;
1010
import se.llbit.math.AABB;
@@ -13,11 +13,10 @@
1313
import se.llbit.nbt.CompoundTag;
1414
import se.llbit.nbt.Tag;
1515

16-
import java.util.List;
1716
import java.util.Random;
1817

1918
public abstract class Block extends Material {
20-
private final static AABB block = new AABB(0, 1, 0, 1,0, 1);
19+
private final static AABB block = new AABB(0, 1, 0, 1, 0, 1);
2120

2221
/**
2322
* Set to true if there is a local intersection model for this block. If this is set to
@@ -46,6 +45,7 @@ public int faceCount() {
4645

4746
/**
4847
* Sample a random point on this block. Coordinates are normalized to be in [0, 1].
48+
*
4949
* @param loc Location vector where the point is stored.
5050
* @param rand Random number source.
5151
*/
@@ -103,7 +103,7 @@ public boolean isBlockEntity() {
103103

104104
public Entity toBlockEntity(Vector3 position, CompoundTag entityTag) {
105105
throw new Error("This block type can not be converted to a block entity: "
106-
+ getClass().getSimpleName());
106+
+ getClass().getSimpleName());
107107
}
108108

109109
public boolean isEntity() {
@@ -121,7 +121,7 @@ public boolean isBlockWithEntity() {
121121

122122
public Entity toEntity(Vector3 position) {
123123
throw new Error("This block type can not be converted to an entity: "
124-
+ getClass().getSimpleName());
124+
+ getClass().getSimpleName());
125125
}
126126

127127
/**
@@ -139,7 +139,8 @@ public boolean isModifiedByBlockEntity() {
139139
* block.
140140
* This is used to handle legacy blocks that used to have information stored in block entities
141141
* but are blocks now (e.g. colored beds).
142-
* @param blockTag Tag of this block (not to be modified)
142+
*
143+
* @param blockTag Tag of this block (not to be modified)
143144
* @param entityTag Block entity data
144145
* @return A new tag that will be used to create a new block that will replace this block
145146
*/
@@ -156,9 +157,11 @@ public boolean isBiomeDependant() {
156157

157158
/**
158159
* Get the color to be used for this block on the surface map.
160+
*
161+
* @param biome Biome to return the color for (for tinted blocks)
159162
* @return ARGB color representing this block
160163
*/
161-
public int getMapColor() {
164+
public int getMapColor(Biome biome) {
162165
return texture.getAvgColor();
163166
}
164167
}

chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,9 +1377,9 @@ public Block getBlockByTag(String namespacedName, Tag tag) {
13771377
return new SpriteBlock(name, Texture.cobweb);
13781378
case "grass":
13791379
case "short_grass": // since 1.20.3-pre2
1380-
return new Grass();
1380+
return new TintedSpriteBlock(name, Texture.tallGrass, Tint.BIOME_GRASS);
13811381
case "fern":
1382-
return new Fern();
1382+
return new TintedSpriteBlock(name, Texture.fern, Tint.BIOME_GRASS);
13831383
case "dead_bush":
13841384
return new SpriteBlock(name, Texture.deadBush);
13851385
case "seagrass":
@@ -2372,7 +2372,7 @@ public Block getBlockByTag(String namespacedName, Tag tag) {
23722372
case "redstone_wire":
23732373
return redstoneWire(tag);
23742374
case "sugar_cane":
2375-
return new SugarCane(); // tinted since 1.7.2 (13w36a)
2375+
return new TintedSpriteBlock(name, Texture.sugarCane, Tint.BIOME_GRASS); // tinted since 1.7.2 (13w36a)
23762376
case "kelp":
23772377
return new SpriteBlock(name, Texture.kelp);
23782378
case "kelp_plant":

chunky/src/java/se/llbit/chunky/block/minecraft/Fern.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

chunky/src/java/se/llbit/chunky/block/minecraft/Grass.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

chunky/src/java/se/llbit/chunky/block/minecraft/GrassBlock.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import se.llbit.chunky.block.AbstractModelBlock;
2222
import se.llbit.chunky.model.minecraft.GrassBlockModel;
2323
import se.llbit.chunky.resources.Texture;
24+
import se.llbit.chunky.world.biome.Biome;
2425

2526
public class GrassBlock extends AbstractModelBlock {
2627

@@ -30,4 +31,9 @@ public GrassBlock() {
3031
opaque = true;
3132
solid = true;
3233
}
34+
35+
@Override
36+
public int getMapColor(Biome biome) {
37+
return biome.grassColor | 0xFF000000;
38+
}
3339
}

chunky/src/java/se/llbit/chunky/block/minecraft/LargeFern.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,16 @@
1818

1919
package se.llbit.chunky.block.minecraft;
2020

21-
import se.llbit.chunky.block.AbstractModelBlock;
22-
import se.llbit.chunky.model.GrassTintedSpriteModel;
21+
import se.llbit.chunky.model.Tint;
2322
import se.llbit.chunky.resources.Texture;
2423

25-
public class LargeFern extends AbstractModelBlock {
24+
public class LargeFern extends TintedSpriteBlock {
2625

2726
public LargeFern(String half) {
2827
super("large_fern",
29-
half.equals("upper")
30-
? Texture.largeFernTop
31-
: Texture.largeFernBottom);
32-
solid = false;
33-
model = new GrassTintedSpriteModel(texture);
28+
half.equals("upper")
29+
? Texture.largeFernTop
30+
: Texture.largeFernBottom,
31+
Tint.BIOME_GRASS);
3432
}
3533
}

chunky/src/java/se/llbit/chunky/block/minecraft/LeafLitter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import se.llbit.chunky.block.AbstractModelBlock;
44
import se.llbit.chunky.model.minecraft.LeafLitterModel;
55
import se.llbit.chunky.resources.Texture;
6+
import se.llbit.chunky.world.biome.Biome;
67

78
public class LeafLitter extends AbstractModelBlock {
89
private final String description;
@@ -14,7 +15,7 @@ public LeafLitter(String facing, int segmentAmount) {
1415
}
1516

1617
@Override
17-
public int getMapColor() {
18+
public int getMapColor(Biome biome) {
1819
return 0xAA7B5334;
1920
}
2021

chunky/src/java/se/llbit/chunky/block/minecraft/Leaves.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import se.llbit.chunky.block.AbstractModelBlock;
2222
import se.llbit.chunky.model.minecraft.LeafModel;
2323
import se.llbit.chunky.resources.Texture;
24+
import se.llbit.chunky.world.biome.Biome;
2425

2526
public class Leaves extends AbstractModelBlock {
2627

@@ -35,4 +36,9 @@ public Leaves(String name, Texture texture, int tint) {
3536
solid = false;
3637
this.model = new LeafModel(texture, tint);
3738
}
39+
40+
@Override
41+
public int getMapColor(Biome biome) {
42+
return biome.foliageColor | 0xFF000000;
43+
}
3844
}

chunky/src/java/se/llbit/chunky/block/minecraft/SugarCane.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

chunky/src/java/se/llbit/chunky/block/minecraft/TallGrass.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,16 @@
1818

1919
package se.llbit.chunky.block.minecraft;
2020

21-
import se.llbit.chunky.block.AbstractModelBlock;
22-
import se.llbit.chunky.model.GrassTintedSpriteModel;
21+
import se.llbit.chunky.model.Tint;
2322
import se.llbit.chunky.resources.Texture;
2423

25-
public class TallGrass extends AbstractModelBlock {
24+
public class TallGrass extends TintedSpriteBlock {
2625

2726
public TallGrass(String half) {
2827
super("tall_grass",
29-
half.equals("upper")
30-
? Texture.doubleTallGrassTop
31-
: Texture.doubleTallGrassBottom);
32-
solid = false;
33-
model = new GrassTintedSpriteModel(texture);
28+
half.equals("upper")
29+
? Texture.doubleTallGrassTop
30+
: Texture.doubleTallGrassBottom,
31+
Tint.BIOME_GRASS);
3432
}
3533
}

0 commit comments

Comments
 (0)