Skip to content

Commit

Permalink
Add some new blocks and update blocks from 23w12a, 23w13a and 23w16a (c…
Browse files Browse the repository at this point in the history
…hunky-dev#1568)

* Add new pottery patterns and handle renamed pottery pattern blocks and textures.

* Add suspicious gravel.

* Add sniffer egg.

* Add cherry grove biome.

* Update sniffer egg model for 23w13a.

* Remove torchflower crop stage 2.

* Add pink petals and a generic flowerbed model.

* Rename shards to sherds.
  • Loading branch information
leMaik committed Apr 23, 2023
1 parent 550542f commit db6975d
Show file tree
Hide file tree
Showing 10 changed files with 726 additions and 51 deletions.
10 changes: 5 additions & 5 deletions chunky/src/java/se/llbit/chunky/block/DecoratedPot.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ public class DecoratedPot extends AbstractModelBlock {
private final String facing;
private final String description;

public DecoratedPot(String facing, boolean waterlogged, String[] shards) {
public DecoratedPot(String facing, boolean waterlogged, String[] sherds) {
super("decorated_pot", Texture.decoratedPotSide);
this.waterlogged = waterlogged;
this.facing = facing;
description = "waterlogged=" + waterlogged
+ ", facing=" + facing
+ ", shards=" + Arrays.stream(shards)
.map(shard -> shard == null ? "minecraft:brick" : shard)
+ ", sherds=" + Arrays.stream(sherds)
.map(sherd -> sherd == null ? "minecraft:brick" : sherd)
.collect(Collectors.joining(", ", "[", "]"));
model = new DecoratedPotModel(facing, shards);
model = new DecoratedPotModel(facing, sherds);
}

@Override
Expand Down Expand Up @@ -60,7 +60,7 @@ public Tag getNewTagWithBlockEntity(Tag blockTag, CompoundTag entityTag) {
newBlockTag.add("Properties", properties); // because set is not implemented
blockTag.get("Properties").asCompound().iterator().forEachRemaining(properties::add);

properties.add("blockEntity#shards", entityTag.get("shards").asList());
properties.add("blockEntity#sherds", entityTag.get("sherds").asList());
properties.add("chunky#debugCoordinates", new StringTag(
entityTag.get("x").intValue() + " " + entityTag.get("z").intValue()
));
Expand Down
33 changes: 25 additions & 8 deletions chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ private static void addBlocks(Texture texture, String... names) {
addBlock("cherry_fence_gate", (name, tag) -> fenceGate(tag, Texture.cherryPlanks));
addBlock("cherry_leaves", (name, tag) -> new UntintedLeaves(name, Texture.cherryLeaves));
addBlock("cherry_log", (name, tag) -> log(tag, Texture.cherryLog, Texture.cherryLogTop));
addBlock("stripped_cherry_log", (name, tag) -> log(tag, Texture.strippedCherryLog, Texture.strippedCherryLogTop));
addBlock("stripped_cherry_log", (name, tag) -> log(tag, Texture.strippedCherryLog, Texture.strippedCherryLogTop));
addBlock("cherry_planks", Texture.cherryPlanks);
addBlock("cherry_pressure_plate", (name, tag) -> new PressurePlate(name, Texture.cherryPlanks));
addBlock("cherry_sign", (name, tag) -> sign(tag, "cherry"));
Expand All @@ -1020,11 +1020,11 @@ private static void addBlocks(Texture texture, String... names) {
addBlock("stripped_cherry_wood", (name, tag) -> log(tag, Texture.strippedCherryLog, Texture.strippedCherryLog));
addBlock("cherry_sapling", (name, tag) -> new SpriteBlock(name, Texture.cherrySapling));
addBlock("potted_cherry_sapling", (name, tag) -> new FlowerPot(name, Kind.CHERRY_SAPLING));

addBlock("torchflower", (name, tag) -> new SpriteBlock(name, Texture.torchflower));
addBlock("torchflower_crop", (name, tag) -> new TorchflowerCrop(BlockProvider.stringToInt(tag.get("Properties").get("age"), 2)));
addBlock("potted_torchflower", (name, tag) -> new FlowerPot(name, Kind.TORCHFLOWER));
addBlock("suspicious_sand", (name, tag) -> suspiciousSand(tag));
addBlock("suspicious_gravel", (name, tag) -> suspiciousGravel(tag));
addBlock("chiseled_bookshelf", (name, tag) -> new ChiseledBookshelf(
BlockProvider.facing(tag),
tag.get("Properties").get("slot_0_occupied").stringValue("false").equals("true"),
Expand All @@ -1034,6 +1034,8 @@ private static void addBlocks(Texture texture, String... names) {
tag.get("Properties").get("slot_4_occupied").stringValue("false").equals("true"),
tag.get("Properties").get("slot_5_occupied").stringValue("false").equals("true")));
addBlock("decorated_pot", (name, tag) -> decoratedPot(tag));
addBlock("sniffer_egg", (name, tag) -> new SnifferEgg(name, BlockProvider.stringToInt(tag.get("Properties").get("age"), 0)));
addBlock("pink_petals", (name, tag) -> new PinkPetals(name, BlockProvider.stringToInt(tag.get("Properties").get("flower_amount"), 1), BlockProvider.facing(tag)));
}

@Override
Expand Down Expand Up @@ -3489,20 +3491,35 @@ private static Block suspiciousSand(Tag tag) {
}
}

private static Block suspiciousGravel(Tag tag) {
Tag properties = tag.get("Properties");
String dusted = properties.get("dusted").stringValue("0");
switch(dusted) {
case "1":
return new MinecraftBlock("suspicious_gravel", Texture.suspiciousGravelStage1);
case "2":
return new MinecraftBlock("suspicious_gravel", Texture.suspiciousGravelStage2);
case "3":
return new MinecraftBlock("suspicious_gravel", Texture.suspiciousGravelStage3);
default:
return new MinecraftBlock("suspicious_gravel", Texture.suspiciousGravelStage0);
}
}

private static Block decoratedPot(Tag tag) {
Tag properties = tag.get("Properties");
String facing = BlockProvider.facing(tag);
boolean waterlogged = properties.get("waterlogged").stringValue("").equals("true");
String[] shards = new String[4];
ListTag shardTags = properties.get("blockEntity#shards").asList();
for(int i = 0; i < shardTags.size() && i < 4; i++) {
String shard = shardTags.get(i).stringValue();
if(!shard.equals("minecraft:brick")) shards[i] = shard;
String[] sherds = new String[4];
ListTag sherdTags = properties.get("blockEntity#sherds").asList();
for(int i = 0; i < sherdTags.size() && i < 4; i++) {
String sherd = sherdTags.get(i).stringValue();
if(!sherd.equals("minecraft:brick")) sherds[i] = sherd;
}
return new DecoratedPot(
facing,
waterlogged,
shards
sherds
);
}

Expand Down
19 changes: 19 additions & 0 deletions chunky/src/java/se/llbit/chunky/block/PinkPetals.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package se.llbit.chunky.block;

import se.llbit.chunky.model.Flowerbed;
import se.llbit.chunky.resources.Texture;

public class PinkPetals extends AbstractModelBlock {
private final String description;

public PinkPetals(String name, int flowerAmount, String facing) {
super(name, Texture.pinkPetals);
this.description = String.format("facing=%s, flower_amount=%d", facing, flowerAmount);
this.model = new Flowerbed(Texture.pinkPetals, Texture.pinkPetalsStem, flowerAmount, facing);
}

@Override
public String description() {
return this.description;
}
}
32 changes: 32 additions & 0 deletions chunky/src/java/se/llbit/chunky/block/SnifferEgg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package se.llbit.chunky.block;

import se.llbit.chunky.model.SnifferEggModel;
import se.llbit.chunky.resources.Texture;

public class SnifferEgg extends AbstractModelBlock {

private final String description;

public SnifferEgg(String name, int age) {
super(name, getTopTexture(age));
this.description = "age=" + age;
this.model = new SnifferEggModel(age);
}

@Override
public String description() {
return description;
}

private static Texture getTopTexture(int age) {
switch (age) {
case 1:
return Texture.snifferEggSlightlyCrackedTop;
case 2:
return Texture.snifferEggVeryCrackedTop;
default:
case 0:
return Texture.snifferEggNotCrackedTop;
}
}
}
24 changes: 11 additions & 13 deletions chunky/src/java/se/llbit/chunky/block/TorchflowerCrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
import se.llbit.chunky.resources.Texture;

public class TorchflowerCrop extends SpriteBlock {
public TorchflowerCrop(int age) {
super("torchflower_crop", getTextureByAge(age));
}
public TorchflowerCrop(int age) {
super("torchflower_crop", getTextureByAge(age));
}

protected static Texture getTextureByAge(int age) {
switch (age) {
case 0:
return Texture.torchflowerCropStage0;
case 1:
return Texture.torchflowerCropStage1;
case 2:
default:
return Texture.torchflowerCropStage2;
}
protected static Texture getTextureByAge(int age) {
switch (age) {
case 1:
return Texture.torchflowerCropStage1;
case 0:
default:
return Texture.torchflowerCropStage0;
}
}
}
72 changes: 53 additions & 19 deletions chunky/src/java/se/llbit/chunky/model/DecoratedPotModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,35 +126,69 @@ public JsonValue toJson() {
}
}

public DecoratedPotModel(String facing, String[] shards) {
public DecoratedPotModel(String facing, String[] sherds) {
super(facing, DEFAULT_QUADS, new Texture[]{
// shards[0] top crafting slot -> north
getTextureForShard(shards[0]),
// shards[3] bottom crafting slot -> south
getTextureForShard(shards[3]),
// shards[1] left crafting slot -> west
getTextureForShard(shards[1]),
// shards[2] right crafting slot -> east
getTextureForShard(shards[2]),
// sherds[0] top crafting slot -> north
getTextureForsherd(sherds[0]),
// sherds[3] bottom crafting slot -> south
getTextureForsherd(sherds[3]),
// sherds[1] left crafting slot -> west
getTextureForsherd(sherds[1]),
// sherds[2] right crafting slot -> east
getTextureForsherd(sherds[2]),
Texture.decoratedPotBase, // top
Texture.decoratedPotBase // bottom
});
}

private static Texture getTextureForShard(String shard) {
if(shard == null)
private static Texture getTextureForsherd(String sherd) {
if(sherd == null) {
return Texture.decoratedPotSide;
switch(shard) {
case "minecraft:pottery_shard_skull":
return Texture.decoratedPotPatternSkull;
case "minecraft:pottery_shard_prize":
return Texture.decoratedPotPatternPrize;
case "minecraft:pottery_shard_archer":
}

switch(sherd) {
case "minecraft:angler_pottery_sherd":
return Texture.decoratedPotPatternAngler;
case "minecraft:archer_pottery_sherd":
return Texture.decoratedPotPatternArcher;
case "minecraft:pottery_shard_arms_up":
case "minecraft:arms_up_pottery_sherd":
return Texture.decoratedPotPatternArmsUp;
case "minecraft:blade_pottery_sherd":
return Texture.decoratedPotPatternBlade;
case "minecraft:brewer_pottery_sherd":
return Texture.decoratedPotPatternBrewer;
case "minecraft:burn_pottery_sherd":
return Texture.decoratedPotPatternBurn;
case "minecraft:danger_pottery_sherd":
return Texture.decoratedPotPatternDanger;
case "minecraft:explorer_pottery_sherd":
return Texture.decoratedPotPatternExplorer;
case "minecraft:friend_pottery_sherd":
return Texture.decoratedPotPatternFriend;
case "minecraft:heartbreak_pottery_sherd":
return Texture.decoratedPotPatternHeartbreak;
case "minecraft:heart_pottery_sherd":
return Texture.decoratedPotPatternHeart;
case "minecraft:howl_pottery_sherd":
return Texture.decoratedPotPatternHowl;
case "minecraft:miner_pottery_sherd":
return Texture.decoratedPotPatternMiner;
case "minecraft:moutner_pottery_sherd":
return Texture.decoratedPotPatternMourner;
case "minecraft:plenty_pottery_sherd":
return Texture.decoratedPotPatternPlenty;
case "minecraft:prize_pottery_sherd":
return Texture.decoratedPotPatternPrize;
case "minecraft:sheaf_pottery_sherd":
return Texture.decoratedPotPatternSheaf;
case "minecraft:shelter_pottery_sherd":
return Texture.decoratedPotPatternShelter;
case "minecraft:skull_pottery_sherd":
return Texture.decoratedPotPatternSkull;
case "minecraft:snort_pottery_sherd":
return Texture.decoratedPotPatternSnort;
default:
Log.warn("Unknown pottery shard: " + shard);
Log.warn("Unknown pottery sherd: " + sherd);
return Texture.decoratedPotSide;
}
}
Expand Down
Loading

0 comments on commit db6975d

Please sign in to comment.