Skip to content

Commit c137dee

Browse files
authored
Add new blocks from 25w31a. (#1818)
* Add new lightning rod variants. * Add proper copper material properties to the new lightning rod and waxed lightning rod variants. * Add copper chests and refactor chests. * Add the oak shelf block. * Add the other shelf variants. * Fix texture mapping of large chests.
1 parent 7f9de85 commit c137dee

File tree

15 files changed

+786
-568
lines changed

15 files changed

+786
-568
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public interface BlockProvider {
1010
Block getBlockByTag(String name, Tag tag);
1111

1212
/**
13-
*
1413
* @return A collection of block IDs that this provider provides.
1514
*/
1615
Collection<String> getSupportedBlocks();
@@ -25,7 +24,8 @@ static String facing(Tag tag) {
2524

2625
/**
2726
* Get the integer value of the given tag (either a {@link StringTag} or an {@link IntTag}.
28-
* @param tag String or int tag
27+
*
28+
* @param tag String or int tag
2929
* @param defaultValue Default value if the tag doesn't exist or the value is not an integer
3030
* @return Integer value of the given tag or the default value
3131
*/
@@ -40,6 +40,16 @@ static int stringToInt(Tag tag, int defaultValue) {
4040
}
4141
}
4242

43+
/**
44+
* Get the boolean value of the given {@link StringTag}.
45+
*
46+
* @param tag String tag
47+
* @return True if the tag is a string tag with the value "true", false otherwise
48+
*/
49+
static boolean stringToBoolean(Tag tag) {
50+
return tag.stringValue("false").equals("true");
51+
}
52+
4353
static String blockName(Tag tag) {
4454
String name = tag.get("Name").stringValue();
4555
if (name.startsWith("minecraft:")) {

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

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ public class MinecraftBlockProvider implements BlockProvider {
468468
"minecraft:exposed_cut_copper",
469469
"minecraft:exposed_cut_copper_slab",
470470
"minecraft:exposed_cut_copper_stairs",
471-
"minecraft:lightning_rod",
472471
"minecraft:light_weighted_pressure_plate",
473472
"minecraft:lilac",
474473
"minecraft:lily_of_the_valley",
@@ -1188,6 +1187,35 @@ private static void addBlocks(Texture texture, String... names) {
11881187
addBlock("short_dry_grass", (name, tag) -> new SpriteBlock(name, Texture.shortDryGrass));
11891188
addBlock("tall_dry_grass", (name, tag) -> new SpriteBlock(name, Texture.tallDryGrass));
11901189
addBlock("dried_ghast", (name, tag) -> new DriedGhast(BlockProvider.facing(tag), BlockProvider.stringToInt(tag.get("Properties").get("hydration"), 0)));
1190+
1191+
// 1.21.x (2025 Fall Drop)
1192+
for (String s : new String[]{"", "waxed_"}) {
1193+
addBlock(s + "lightning_rod", (name, tag) -> new LightningRod(name, Texture.lightningRod, BlockProvider.facing(tag, "up"),
1194+
tag.get("Properties").get("powered").stringValue("false").equals("true")));
1195+
addBlock(s + "exposed_lightning_rod", (name, tag) -> new LightningRod(name, Texture.exposedLightningRod, BlockProvider.facing(tag, "up"),
1196+
tag.get("Properties").get("powered").stringValue("false").equals("true")));
1197+
addBlock(s + "oxidized_lightning_rod", (name, tag) -> new LightningRod(name, Texture.oxidizedLightningRod, BlockProvider.facing(tag, "up"),
1198+
tag.get("Properties").get("powered").stringValue("false").equals("true")));
1199+
addBlock(s + "weathered_lightning_rod", (name, tag) -> new LightningRod(name, Texture.weatheredLightningRod, BlockProvider.facing(tag, "up"),
1200+
tag.get("Properties").get("powered").stringValue("false").equals("true")));
1201+
1202+
addBlock(s + "copper_chest", (name, tag) -> chest(tag, Chest.Kind.COPPER));
1203+
addBlock(s + "exposed_copper_chest", (name, tag) -> chest(tag, Chest.Kind.EXPOSED_COPPER));
1204+
addBlock(s + "weathered_copper_chest", (name, tag) -> chest(tag, Chest.Kind.WEATHERED_COPPER));
1205+
addBlock(s + "oxidized_copper_chest", (name, tag) -> chest(tag, Chest.Kind.OXIDIZED_COPPER));
1206+
}
1207+
addBlock("acacia_shelf", (name, tag) -> shelf(tag, Texture.acaciaShelf));
1208+
addBlock("bamboo_shelf", (name, tag) -> shelf(tag, Texture.bambooShelf));
1209+
addBlock("birch_shelf", (name, tag) -> shelf(tag, Texture.birchShelf));
1210+
addBlock("cherry_shelf", (name, tag) -> shelf(tag, Texture.cherryShelf));
1211+
addBlock("crimson_shelf", (name, tag) -> shelf(tag, Texture.crimsonShelf));
1212+
addBlock("dark_oak_shelf", (name, tag) -> shelf(tag, Texture.darkOakShelf));
1213+
addBlock("jungle_shelf", (name, tag) -> shelf(tag, Texture.jungleShelf));
1214+
addBlock("mangrove_shelf", (name, tag) -> shelf(tag, Texture.mangroveShelf));
1215+
addBlock("oak_shelf", (name, tag) -> shelf(tag, Texture.oakShelf));
1216+
addBlock("pale_oak_shelf", (name, tag) -> shelf(tag, Texture.paleOakShelf));
1217+
addBlock("spruce_shelf", (name, tag) -> shelf(tag, Texture.spruceShelf));
1218+
addBlock("warped_shelf", (name, tag) -> shelf(tag, Texture.warpedShelf));
11911219
}
11921220

11931221
@Override
@@ -1567,7 +1595,7 @@ public Block getBlockByTag(String namespacedName, Tag tag) {
15671595
case "dark_oak_stairs":
15681596
return stairs(tag, Texture.darkOakPlanks);
15691597
case "chest":
1570-
return chest(tag, false);
1598+
return chest(tag, Chest.Kind.NORMAL);
15711599
case "diamond_ore":
15721600
return new MinecraftBlock(name, Texture.diamondOre);
15731601
case "diamond_block":
@@ -1784,7 +1812,7 @@ public Block getBlockByTag(String namespacedName, Tag tag) {
17841812
case "damaged_anvil":
17851813
return anvil(tag, 2);
17861814
case "trapped_chest":
1787-
return chest(tag, true);
1815+
return chest(tag, Chest.Kind.TRAPPED);
17881816
case "light_weighted_pressure_plate":
17891817
return new PressurePlate(name, Texture.goldBlock);
17901818
case "heavy_weighted_pressure_plate":
@@ -3019,8 +3047,6 @@ public Block getBlockByTag(String namespacedName, Tag tag) {
30193047
return slab(tag, Texture.oxidizedCutCopper);
30203048
case "lava_cauldron":
30213049
return new LavaCauldron();
3022-
case "lightning_rod":
3023-
return new LightningRod(BlockProvider.facing(tag, "up"), tag.get("Properties").get("powered").stringValue("false").equals("true"));
30243050
case "small_amethyst_bud":
30253051
return new SpriteBlock(name, Texture.smallAmethystBud, BlockProvider.facing(tag, "up"));
30263052
case "medium_amethyst_bud":
@@ -3278,11 +3304,6 @@ private static boolean isLit(Tag tag) {
32783304
return tag.get("Properties").get("lit").stringValue("false").equals("true");
32793305
}
32803306

3281-
private static boolean isLit(Tag tag, boolean defaultValue) {
3282-
return tag.get("Properties").get("lit").stringValue(Boolean.toString(defaultValue))
3283-
.equals("true");
3284-
}
3285-
32863307
private static Block redstoneWire(Tag tag) {
32873308
Tag properties = tag.get("Properties");
32883309
String north = properties.get("north").stringValue("none");
@@ -3293,12 +3314,12 @@ private static Block redstoneWire(Tag tag) {
32933314
return new RedstoneWire(power, north, south, east, west);
32943315
}
32953316

3296-
private static Block chest(Tag tag, boolean trapped) {
3317+
private static Block chest(Tag tag, Chest.Kind kind) {
32973318
String name = BlockProvider.blockName(tag);
32983319
Tag properties = tag.get("Properties");
32993320
String facing = BlockProvider.facing(tag, "north");
33003321
String type = properties.get("type").stringValue("single");
3301-
return new Chest(name, type, facing, trapped);
3322+
return new Chest(name, type, facing, kind);
33023323
}
33033324

33043325
private static Block chain(Tag tag, String name, Texture texture) {
@@ -3680,6 +3701,13 @@ private static Block decoratedPot(Tag tag) {
36803701
);
36813702
}
36823703

3704+
private static Block shelf(Tag tag, Texture texture) {
3705+
return new Shelf(BlockProvider.blockName(tag), texture,
3706+
BlockProvider.facing(tag),
3707+
BlockProvider.stringToBoolean(tag.get("Properties").get("powered")),
3708+
tag.get("Properties").get("side_chain").stringValue("unconnected"));
3709+
}
3710+
36833711
private static Block nonSolid(Block block) {
36843712
block.solid = false;
36853713
return block;

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

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,45 @@
2323
import se.llbit.chunky.resources.Texture;
2424

2525
public class Chest extends AbstractModelBlock {
26+
public enum Kind {
27+
NORMAL,
28+
TRAPPED,
29+
ENDER,
30+
COPPER,
31+
EXPOSED_COPPER,
32+
OXIDIZED_COPPER,
33+
WEATHERED_COPPER
34+
}
35+
36+
public enum Type {
37+
SINGLE,
38+
LEFT,
39+
RIGHT
40+
}
2641

2742
private final String description;
2843

29-
public Chest(String name, String typeString, String facingString, boolean trapped) {
30-
super(name, trapped ? Texture.trappedChestFront : Texture.chestFront);
44+
public Chest(String name, String typeString, String facingString, Kind kind) {
45+
super(name, switch (kind) {
46+
case TRAPPED -> Texture.trappedChest.front;
47+
case ENDER -> Texture.enderChest.front;
48+
case COPPER -> Texture.copperChest.front;
49+
default -> Texture.chest.front;
50+
});
3151
this.description = String.format("type=%s, facing=%s", typeString, facingString);
32-
int type;
33-
switch (typeString) {
34-
default:
35-
case "single":
36-
type = 0;
37-
break;
38-
case "left":
39-
type = 1;
40-
break;
41-
case "right":
42-
type = 2;
43-
break;
44-
}
45-
int facing;
46-
switch (facingString) {
47-
default:
48-
case "north":
49-
facing = 2;
50-
break;
51-
case "south":
52-
facing = 3;
53-
break;
54-
case "west":
55-
facing = 4;
56-
break;
57-
case "east":
58-
facing = 5;
59-
break;
60-
}
61-
model = new ChestModel(type, facing, trapped, false);
52+
Type type = switch (typeString) {
53+
case "left" -> Type.LEFT;
54+
case "right" -> Type.RIGHT;
55+
default -> Type.SINGLE;
56+
};
57+
int facing = switch (facingString) {
58+
case "north" -> 2;
59+
case "south" -> 3;
60+
case "west" -> 4;
61+
case "east" -> 5;
62+
default -> 2;
63+
};
64+
model = new ChestModel(type, facing, kind);
6265
}
6366

6467
@Override

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class EnderChest extends AbstractModelBlock {
2727
private final String description;
2828

2929
public EnderChest(String facingString) {
30-
super("ender_chest", Texture.chestFront);
30+
super("ender_chest", Texture.enderChest.front);
3131
this.description = "facing=" + facingString;
3232
int facing;
3333
switch (facingString) {
@@ -45,7 +45,7 @@ public EnderChest(String facingString) {
4545
facing = 5;
4646
break;
4747
}
48-
model = new ChestModel(0, facing, false, true);
48+
model = new ChestModel(Chest.Type.SINGLE, facing, Chest.Kind.ENDER);
4949
}
5050

5151
@Override

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public class LightningRod extends AbstractModelBlock {
2727
private final String facing;
2828
private final boolean powered;
2929

30-
public LightningRod(String facing, boolean powered) {
31-
super("lightning_rod", Texture.lightningRod);
32-
this.model = new LightningRodModel(facing, powered);
30+
public LightningRod(String name, Texture texture, String facing, boolean powered) {
31+
super(name, texture);
32+
this.model = new LightningRodModel(texture, facing, powered);
3333
this.powered = powered;
3434
this.facing = facing;
3535
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package se.llbit.chunky.block.minecraft;
2+
3+
import se.llbit.chunky.block.AbstractModelBlock;
4+
import se.llbit.chunky.model.minecraft.ShelfModel;
5+
import se.llbit.chunky.resources.Texture;
6+
7+
public class Shelf extends AbstractModelBlock {
8+
private final String description;
9+
10+
public Shelf(String name, Texture texture, String facing, boolean powered, String sideChain) {
11+
super(name, texture);
12+
description = String.format("facing=%s, powered=%b, side_chain=%s", facing, powered, sideChain);
13+
model = new ShelfModel(texture, facing, powered, sideChain);
14+
}
15+
16+
@Override
17+
public String description() {
18+
return description;
19+
}
20+
}

chunky/src/java/se/llbit/chunky/chunk/BlockPalette.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ public static Map<String, Consumer<Block>> getDefaultMaterialProperties() {
502502
materialProperties.put(s + "copper_grate", copperConfig);
503503
materialProperties.put(s + "copper_door", copperConfig);
504504
materialProperties.put(s + "copper_trapdoor", copperConfig);
505-
505+
materialProperties.put(s + "copper_chest", copperConfig);
506+
506507
materialProperties.put(s + "exposed_copper", exposedCopperConfig);
507508
materialProperties.put(s + "exposed_cut_copper", exposedCopperConfig);
508509
materialProperties.put(s + "exposed_cut_copper_stairs", exposedCopperConfig);
@@ -511,6 +512,7 @@ public static Map<String, Consumer<Block>> getDefaultMaterialProperties() {
511512
materialProperties.put(s + "exposed_copper_grate", exposedCopperConfig);
512513
materialProperties.put(s + "exposed_copper_door", exposedCopperConfig);
513514
materialProperties.put(s + "exposed_copper_trapdoor", exposedCopperConfig);
515+
materialProperties.put(s + "exposed_copper_chest", exposedCopperConfig);
514516

515517
materialProperties.put(s + "weathered_copper", weatheredCopperConfig);
516518
materialProperties.put(s + "weathered_cut_copper", weatheredCopperConfig);
@@ -520,13 +522,27 @@ public static Map<String, Consumer<Block>> getDefaultMaterialProperties() {
520522
materialProperties.put(s + "weathered_copper_grate", weatheredCopperConfig);
521523
materialProperties.put(s + "weathered_copper_door", weatheredCopperConfig);
522524
materialProperties.put(s + "weathered_copper_trapdoor", weatheredCopperConfig);
525+
materialProperties.put(s + "weathered_copper_chest", weatheredCopperConfig);
526+
527+
materialProperties.put(s + "lightning_rod", block -> {
528+
// apply copper attributes only to non-powered lightning rods
529+
if (block instanceof LightningRod && !((LightningRod) block).isPowered()) {
530+
copperConfig.accept(block);
531+
}
532+
});
533+
materialProperties.put(s + "exposed_lightning_rod", block -> {
534+
// apply copper attributes only to non-powered lightning rods
535+
if (block instanceof LightningRod && !((LightningRod) block).isPowered()) {
536+
exposedCopperConfig.accept(block);
537+
}
538+
});
539+
materialProperties.put(s + "weathered_lightning_rod", block -> {
540+
// apply copper attributes only to non-powered lightning rods
541+
if (block instanceof LightningRod && !((LightningRod) block).isPowered()) {
542+
weatheredCopperConfig.accept(block);
543+
}
544+
});
523545
}
524-
materialProperties.put("minecraft:lightning_rod", block -> {
525-
// apply copper attributes only to non-powered lightning rods
526-
if (block instanceof LightningRod && !((LightningRod) block).isPowered()) {
527-
copperConfig.accept(block);
528-
}
529-
});
530546
materialProperties.put("minecraft:small_amethyst_bud", block -> {
531547
block.emittance = 1.0f / 15f;
532548
});

0 commit comments

Comments
 (0)