Skip to content

Commit 686a642

Browse files
committed
Add copper chests and refactor chests.
1 parent 07f5dda commit 686a642

File tree

10 files changed

+395
-474
lines changed

10 files changed

+395
-474
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,11 @@ private static void addBlocks(Texture texture, String... names) {
11981198
tag.get("Properties").get("powered").stringValue("false").equals("true")));
11991199
addBlock(s + "weathered_lightning_rod", (name, tag) -> new LightningRod(name, Texture.weatheredLightningRod, BlockProvider.facing(tag, "up"),
12001200
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));
12011206
}
12021207
}
12031208

@@ -1578,7 +1583,7 @@ public Block getBlockByTag(String namespacedName, Tag tag) {
15781583
case "dark_oak_stairs":
15791584
return stairs(tag, Texture.darkOakPlanks);
15801585
case "chest":
1581-
return chest(tag, false);
1586+
return chest(tag, Chest.Kind.NORMAL);
15821587
case "diamond_ore":
15831588
return new MinecraftBlock(name, Texture.diamondOre);
15841589
case "diamond_block":
@@ -1795,7 +1800,7 @@ public Block getBlockByTag(String namespacedName, Tag tag) {
17951800
case "damaged_anvil":
17961801
return anvil(tag, 2);
17971802
case "trapped_chest":
1798-
return chest(tag, true);
1803+
return chest(tag, Chest.Kind.TRAPPED);
17991804
case "light_weighted_pressure_plate":
18001805
return new PressurePlate(name, Texture.goldBlock);
18011806
case "heavy_weighted_pressure_plate":
@@ -3287,11 +3292,6 @@ private static boolean isLit(Tag tag) {
32873292
return tag.get("Properties").get("lit").stringValue("false").equals("true");
32883293
}
32893294

3290-
private static boolean isLit(Tag tag, boolean defaultValue) {
3291-
return tag.get("Properties").get("lit").stringValue(Boolean.toString(defaultValue))
3292-
.equals("true");
3293-
}
3294-
32953295
private static Block redstoneWire(Tag tag) {
32963296
Tag properties = tag.get("Properties");
32973297
String north = properties.get("north").stringValue("none");
@@ -3302,12 +3302,12 @@ private static Block redstoneWire(Tag tag) {
33023302
return new RedstoneWire(power, north, south, east, west);
33033303
}
33043304

3305-
private static Block chest(Tag tag, boolean trapped) {
3305+
private static Block chest(Tag tag, Chest.Kind kind) {
33063306
String name = BlockProvider.blockName(tag);
33073307
Tag properties = tag.get("Properties");
33083308
String facing = BlockProvider.facing(tag, "north");
33093309
String type = properties.get("type").stringValue("single");
3310-
return new Chest(name, type, facing, trapped);
3310+
return new Chest(name, type, facing, kind);
33113311
}
33123312

33133313
private static Block chain(Tag tag, String name, Texture texture) {

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/chunk/BlockPalette.java

Lines changed: 4 additions & 1 deletion
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,6 +522,7 @@ 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);
523526

524527
materialProperties.put(s + "lightning_rod", block -> {
525528
// apply copper attributes only to non-powered lightning rods

0 commit comments

Comments
 (0)