From f668eff88ec7b5c0f5f4121036fbc72178e57027 Mon Sep 17 00:00:00 2001 From: Maik Marschner Date: Wed, 4 Dec 2024 00:54:11 +0100 Subject: [PATCH 1/6] Add chiseled resin bricks and closed eyeblossom. --- .../se/llbit/chunky/block/MinecraftBlockProvider.java | 4 +++- .../se/llbit/chunky/model/minecraft/FlowerPotModel.java | 6 +++++- chunky/src/java/se/llbit/chunky/resources/Texture.java | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java index 9dffa6a66..24551de22 100644 --- a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java +++ b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java @@ -8,7 +8,6 @@ import se.llbit.chunky.entity.SkullEntity; import se.llbit.chunky.model.minecraft.FlowerPotModel; import se.llbit.chunky.model.minecraft.FlowerPotModel.Kind; -import se.llbit.chunky.model.minecraft.PaleMossCarpetModel; import se.llbit.chunky.resources.ShulkerTexture; import se.llbit.chunky.resources.Texture; import se.llbit.nbt.ListTag; @@ -1156,6 +1155,9 @@ private static void addBlocks(Texture texture, String... names) { addBlock("creaking_heart", (name, tag) -> new CreakingHeart(name, tag.get("Properties").get("axis").stringValue("y"), tag.get("Properties").get("creaking").stringValue("active"))); + addBlock("chiseled_resin_bricks", Texture.chiseledResinBricks); + addBlock("closed_eyeblossom", (name, tag) -> new SpriteBlock(name, Texture.closedEyeblossom)); + addBlock("potted_closed_eyeblossom", (name, tag) -> new FlowerPot(name, FlowerPotModel.Kind.CLOSED_EYEBLOSSOM)); } @Override diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java index 860223c59..0be049186 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java @@ -69,7 +69,8 @@ public enum Kind { MANGROVE_PROPAGULE, TORCHFLOWER, CHERRY_SAPLING, - PALE_OAK_SAPLING + PALE_OAK_SAPLING, + CLOSED_EYEBLOSSOM } private static final Texture flowerpot = Texture.flowerPot; @@ -620,6 +621,9 @@ public FlowerPotModel(Kind kind) { case PALE_OAK_SAPLING: Arrays.fill(textures, flowerPotTex.length, textures.length, Texture.paleOakSapling); break; + case CLOSED_EYEBLOSSOM: + Arrays.fill(textures, flowerPotTex.length, textures.length, Texture.closedEyeblossom); + break; } break; } diff --git a/chunky/src/java/se/llbit/chunky/resources/Texture.java b/chunky/src/java/se/llbit/chunky/resources/Texture.java index 3fc9da080..1ec0b8259 100644 --- a/chunky/src/java/se/llbit/chunky/resources/Texture.java +++ b/chunky/src/java/se/llbit/chunky/resources/Texture.java @@ -1556,6 +1556,14 @@ public class Texture { public static final Texture creakingHeartActive = new Texture(); @TexturePath("assets/minecraft/textures/block/creaking_heart_top_active") public static final Texture creakingHeartTopActive = new Texture(); + @TexturePath("assets/minecraft/textures/block/chiseled_resin_bricks") + public static final Texture chiseledResinBricks = new Texture(); + @TexturePath("assets/minecraft/textures/block/closed_eyeblossom") + public static final Texture closedEyeblossom = new Texture(); + @TexturePath("assets/minecraft/textures/block/open_eyeblossom") + public static final Texture openEyeblossom = new Texture(); + @TexturePath("assets/minecraft/textures/block/open_eyeblossom_emissive") + public static final Texture openEyeblossomEmissive = new Texture(); /** Banner base texture. */ public static final Texture bannerBase = new Texture(); From 8ff18000d0dff7bf5d7c63473d24008e2a51019c Mon Sep 17 00:00:00 2001 From: Maik Marschner Date: Wed, 4 Dec 2024 01:05:18 +0100 Subject: [PATCH 2/6] Add resin block and resin bricks blocks. --- .../java/se/llbit/chunky/block/MinecraftBlockProvider.java | 5 +++++ chunky/src/java/se/llbit/chunky/resources/Texture.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java index 24551de22..0435db7c8 100644 --- a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java +++ b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java @@ -1158,6 +1158,11 @@ private static void addBlocks(Texture texture, String... names) { addBlock("chiseled_resin_bricks", Texture.chiseledResinBricks); addBlock("closed_eyeblossom", (name, tag) -> new SpriteBlock(name, Texture.closedEyeblossom)); addBlock("potted_closed_eyeblossom", (name, tag) -> new FlowerPot(name, FlowerPotModel.Kind.CLOSED_EYEBLOSSOM)); + addBlock("resin_block", Texture.resinBlock); + addBlock("resin_bricks", Texture.resinBricks); + addBlock("resin_brick_stairs", (name, tag) -> stairs(tag, Texture.resinBricks)); + addBlock("resin_brick_slab", (name, tag) -> slab(tag, Texture.resinBricks)); + addBlock("resin_brick_walls", (name, tag) -> wall(tag, Texture.resinBricks)); } @Override diff --git a/chunky/src/java/se/llbit/chunky/resources/Texture.java b/chunky/src/java/se/llbit/chunky/resources/Texture.java index 1ec0b8259..25c9464df 100644 --- a/chunky/src/java/se/llbit/chunky/resources/Texture.java +++ b/chunky/src/java/se/llbit/chunky/resources/Texture.java @@ -1564,6 +1564,10 @@ public class Texture { public static final Texture openEyeblossom = new Texture(); @TexturePath("assets/minecraft/textures/block/open_eyeblossom_emissive") public static final Texture openEyeblossomEmissive = new Texture(); + @TexturePath("assets/minecraft/textures/block/resin_block") + public static final Texture resinBlock = new Texture(); + @TexturePath("assets/minecraft/textures/block/resin_bricks") + public static final Texture resinBricks = new Texture(); /** Banner base texture. */ public static final Texture bannerBase = new Texture(); From 4c1dc6af4dbd40c17afffc4cb51edea50d5dfc1f Mon Sep 17 00:00:00 2001 From: Maik Marschner Date: Wed, 4 Dec 2024 01:22:01 +0100 Subject: [PATCH 3/6] Replace creaking heart creaking property with active. --- .../chunky/block/MinecraftBlockProvider.java | 56 +++++++------------ .../chunky/block/minecraft/CreakingHeart.java | 8 +-- 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java index 0435db7c8..288268a10 100644 --- a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java +++ b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java @@ -1154,7 +1154,7 @@ private static void addBlocks(Texture texture, String... names) { tag.get("Properties").get("west").stringValue("none"))); addBlock("creaking_heart", (name, tag) -> new CreakingHeart(name, tag.get("Properties").get("axis").stringValue("y"), - tag.get("Properties").get("creaking").stringValue("active"))); + tag.get("Properties").get("active").stringValue("false").equals("true"))); addBlock("chiseled_resin_bricks", Texture.chiseledResinBricks); addBlock("closed_eyeblossom", (name, tag) -> new SpriteBlock(name, Texture.closedEyeblossom)); addBlock("potted_closed_eyeblossom", (name, tag) -> new FlowerPot(name, FlowerPotModel.Kind.CLOSED_EYEBLOSSOM)); @@ -3592,22 +3592,14 @@ private static Block seaPickle(Tag tag) { private static Block structureBlock(Tag tag) { Tag properties = tag.get("Properties"); - Texture texture = Texture.structureBlock; String mode = properties.get("mode").stringValue(""); - switch (mode) { - case "corner": - texture = Texture.structureBlockCorner; - break; - case "data": - texture = Texture.structureBlockData; - break; - case "load": - texture = Texture.structureBlockLoad; - break; - case "save": - texture = Texture.structureBlockSave; - break; - } + Texture texture = switch (mode) { + case "corner" -> Texture.structureBlockCorner; + case "data" -> Texture.structureBlockData; + case "load" -> Texture.structureBlockLoad; + case "save" -> Texture.structureBlockSave; + default -> Texture.structureBlock; + }; return new MinecraftBlock("structure_block", texture); } @@ -3627,31 +3619,23 @@ private static Block candleCake(Tag tag, Texture candleTexture, Texture candleTe private static Block suspiciousSand(Tag tag) { Tag properties = tag.get("Properties"); String dusted = properties.get("dusted").stringValue("0"); - switch(dusted) { - case "1": - return new MinecraftBlock("suspicious_sand", Texture.suspiciousSandStage1); - case "2": - return new MinecraftBlock("suspicious_sand", Texture.suspiciousSandStage2); - case "3": - return new MinecraftBlock("suspicious_sand", Texture.suspiciousSandStage3); - default: - return new MinecraftBlock("suspicious_sand", Texture.suspiciousSandStage0); - } + return switch (dusted) { + case "1" -> new MinecraftBlock("suspicious_sand", Texture.suspiciousSandStage1); + case "2" -> new MinecraftBlock("suspicious_sand", Texture.suspiciousSandStage2); + case "3" -> new MinecraftBlock("suspicious_sand", Texture.suspiciousSandStage3); + default -> new MinecraftBlock("suspicious_sand", Texture.suspiciousSandStage0); + }; } 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); - } + return switch (dusted) { + case "1" -> new MinecraftBlock("suspicious_gravel", Texture.suspiciousGravelStage1); + case "2" -> new MinecraftBlock("suspicious_gravel", Texture.suspiciousGravelStage2); + case "3" -> new MinecraftBlock("suspicious_gravel", Texture.suspiciousGravelStage3); + default -> new MinecraftBlock("suspicious_gravel", Texture.suspiciousGravelStage0); + }; } private static Block decoratedPot(Tag tag) { diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/CreakingHeart.java b/chunky/src/java/se/llbit/chunky/block/minecraft/CreakingHeart.java index 3f8320339..3fd4f3fe2 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/CreakingHeart.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/CreakingHeart.java @@ -7,14 +7,14 @@ public class CreakingHeart extends AbstractModelBlock { private final String description; - public CreakingHeart(String name, String axis, String creaking) { + public CreakingHeart(String name, String axis, boolean active) { super(name, Texture.creakingHeartTop); this.model = new LogModel( axis, - creaking.equals("disabled") ? Texture.creakingHeart : Texture.creakingHeartActive, - creaking.equals("disabled") ? Texture.creakingHeartTop : Texture.creakingHeartTopActive + active ? Texture.creakingHeartActive : Texture.creakingHeart, + active ? Texture.creakingHeartTopActive : Texture.creakingHeartTop ); - this.description = String.format("axis=%s, creaking=%s", axis, creaking); + this.description = String.format("active=%s, axis=%s", active, axis); } @Override From 833780af90bb7fc8e6d997736c0048e26edc7f19 Mon Sep 17 00:00:00 2001 From: Maik Marschner Date: Mon, 16 Dec 2024 00:06:28 +0100 Subject: [PATCH 4/6] Add resin clump block. --- .../chunky/block/MinecraftBlockProvider.java | 7 ++ .../chunky/block/minecraft/ResinClump.java | 22 ++++++ .../model/minecraft/ResinClumpModel.java | 73 +++++++++++++++++++ .../se/llbit/chunky/resources/Texture.java | 2 + 4 files changed, 104 insertions(+) create mode 100644 chunky/src/java/se/llbit/chunky/block/minecraft/ResinClump.java create mode 100644 chunky/src/java/se/llbit/chunky/model/minecraft/ResinClumpModel.java diff --git a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java index 288268a10..195693a5d 100644 --- a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java +++ b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java @@ -1163,6 +1163,13 @@ private static void addBlocks(Texture texture, String... names) { addBlock("resin_brick_stairs", (name, tag) -> stairs(tag, Texture.resinBricks)); addBlock("resin_brick_slab", (name, tag) -> slab(tag, Texture.resinBricks)); addBlock("resin_brick_walls", (name, tag) -> wall(tag, Texture.resinBricks)); + addBlock("resin_clump", (name, tag) -> new ResinClump( + tag.get("Properties").get("north").stringValue("false").equals("true"), + tag.get("Properties").get("south").stringValue("false").equals("true"), + tag.get("Properties").get("east").stringValue("false").equals("true"), + tag.get("Properties").get("west").stringValue("false").equals("true"), + tag.get("Properties").get("up").stringValue("false").equals("true"), + tag.get("Properties").get("down").stringValue("false").equals("true"))); } @Override diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/ResinClump.java b/chunky/src/java/se/llbit/chunky/block/minecraft/ResinClump.java new file mode 100644 index 000000000..cda153b82 --- /dev/null +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/ResinClump.java @@ -0,0 +1,22 @@ +package se.llbit.chunky.block.minecraft; + +import se.llbit.chunky.block.AbstractModelBlock; +import se.llbit.chunky.model.minecraft.ResinClumpModel; +import se.llbit.chunky.resources.Texture; + +public class ResinClump extends AbstractModelBlock { + private final String description; + + public ResinClump(boolean north, boolean south, boolean east, boolean west, boolean up, + boolean down) { + super("resin_clump", Texture.resinClump); + this.description = String.format("north=%s, south=%s, east=%s, west=%s, up=%s, down=%s", + north, south, east, west, up, down); + this.model = new ResinClumpModel(north, south, east, west, up, down); + } + + @Override + public String description() { + return description; + } +} diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/ResinClumpModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/ResinClumpModel.java new file mode 100644 index 000000000..376d28a90 --- /dev/null +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/ResinClumpModel.java @@ -0,0 +1,73 @@ +package se.llbit.chunky.model.minecraft; + +import se.llbit.chunky.model.QuadModel; +import se.llbit.chunky.resources.Texture; +import se.llbit.math.Quad; +import se.llbit.math.Transform; +import se.llbit.math.Vector3; +import se.llbit.math.Vector4; + +import java.util.ArrayList; +import java.util.Arrays; + +public class ResinClumpModel extends QuadModel { + private static final Quad northQuad; + private static final Quad southQuad; + private static final Quad eastQuad; + private static final Quad westQuad; + private static final Quad upQuad; + private static final Quad downQuad; + + static { + northQuad = new Quad( + new Vector3(0 / 16.0, 16 / 16.0, 0.1 / 16.0), + new Vector3(16 / 16.0, 16 / 16.0, 0.1 / 16.0), + new Vector3(0 / 16.0, 0 / 16.0, 0.1 / 16.0), + new Vector4(0 / 16.0, 16 / 16.0, 16 / 16.0, 0 / 16.0), + true); + eastQuad = new Quad(northQuad, Transform.NONE.rotateY()); + southQuad = new Quad(eastQuad, Transform.NONE.rotateY()); + westQuad = new Quad(northQuad, Transform.NONE.rotateNegY()); + upQuad = new Quad(northQuad, Transform.NONE.rotateX()); + downQuad = new Quad(northQuad, Transform.NONE.rotateNegX()); + } + + private final Quad[] quads; + private final Texture[] textures; + + public ResinClumpModel(boolean north, boolean south, boolean east, boolean west, boolean up, boolean down) { + ArrayList quads = new ArrayList<>(); + boolean allSides = !north && !south && !east && !west && !up && !down; + if (north || allSides) { + quads.add(northQuad); + } + if (south || allSides) { + quads.add(southQuad); + } + if (east || allSides) { + quads.add(eastQuad); + } + if (west || allSides) { + quads.add(westQuad); + } + if (up || allSides) { + quads.add(upQuad); + } + if (down || allSides) { + quads.add(downQuad); + } + this.quads = quads.toArray(new Quad[0]); + this.textures = new Texture[this.quads.length]; + Arrays.fill(this.textures, Texture.resinClump); + } + + @Override + public Quad[] getQuads() { + return quads; + } + + @Override + public Texture[] getTextures() { + return textures; + } +} diff --git a/chunky/src/java/se/llbit/chunky/resources/Texture.java b/chunky/src/java/se/llbit/chunky/resources/Texture.java index 25c9464df..19923281f 100644 --- a/chunky/src/java/se/llbit/chunky/resources/Texture.java +++ b/chunky/src/java/se/llbit/chunky/resources/Texture.java @@ -1568,6 +1568,8 @@ public class Texture { public static final Texture resinBlock = new Texture(); @TexturePath("assets/minecraft/textures/block/resin_bricks") public static final Texture resinBricks = new Texture(); + @TexturePath("assets/minecraft/textures/block/resin_clump") + public static final Texture resinClump = new Texture(); /** Banner base texture. */ public static final Texture bannerBase = new Texture(); From a3af3a2130fe1dfaca1254e5026d35448c356c4f Mon Sep 17 00:00:00 2001 From: Maik Marschner Date: Mon, 16 Dec 2024 01:15:23 +0100 Subject: [PATCH 5/6] Add open eyeblossom and potted open eyeblossom. --- .../chunky/block/MinecraftBlockProvider.java | 11 ++-- .../chunky/block/minecraft/FlowerPot.java | 2 +- .../block/minecraft/OpenEyeBlossom.java | 29 ++++++++ .../model/minecraft/FlowerPotModel.java | 66 ++++++++++++++++++- .../se/llbit/chunky/world/ExtraMaterials.java | 5 ++ 5 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeBlossom.java diff --git a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java index 195693a5d..0e041ae92 100644 --- a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java +++ b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java @@ -7,7 +7,6 @@ import se.llbit.chunky.entity.BannerDesign; import se.llbit.chunky.entity.SkullEntity; import se.llbit.chunky.model.minecraft.FlowerPotModel; -import se.llbit.chunky.model.minecraft.FlowerPotModel.Kind; import se.llbit.chunky.resources.ShulkerTexture; import se.llbit.chunky.resources.Texture; import se.llbit.nbt.ListTag; @@ -977,7 +976,7 @@ private static void addBlocks(Texture texture, String... names) { addBlock("mangrove_propagule", (name, tag) -> new MangrovePropagule( BlockProvider.stringToInt(tag.get("Properties").get("age"), 0), tag.get("Properties").get("hanging").stringValue("false").equals("true"))); - addBlock("potted_mangrove_propagule", (name, tag) -> new FlowerPot(name, Kind.MANGROVE_PROPAGULE)); + addBlock("potted_mangrove_propagule", (name, tag) -> new FlowerPot(name, FlowerPotModel.Kind.MANGROVE_PROPAGULE)); addBlock("sculk_catalyst", (name, tag) -> new SculkCatalyst(tag.get("Properties").get("bloom").stringValue("false").equals("true"))); addBlock("sculk", Texture.sculk); addBlock("sculk_shrieker", (name, tag) -> new SculkShrieker(tag.get("Properties").get("can_summon").stringValue("false").equals("true"))); @@ -1023,10 +1022,10 @@ private static void addBlocks(Texture texture, String... names) { addBlock("cherry_wood", (name, tag) -> log(tag, Texture.cherryLog, Texture.cherryLog)); 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("potted_cherry_sapling", (name, tag) -> new FlowerPot(name, FlowerPotModel.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("potted_torchflower", (name, tag) -> new FlowerPot(name, FlowerPotModel.Kind.TORCHFLOWER)); addBlock("suspicious_sand", (name, tag) -> suspiciousSand(tag)); addBlock("suspicious_gravel", (name, tag) -> suspiciousGravel(tag)); addBlock("chiseled_bookshelf", (name, tag) -> new ChiseledBookshelf( @@ -1123,7 +1122,7 @@ private static void addBlocks(Texture texture, String... names) { addBlock("heavy_core", (name, tag) -> new HeavyCore()); addBlock("trial_spawner", (name, tag) -> new TrialSpawner(tag.get("Properties").get("ominous").stringValue().equals("true"), tag.get("Properties").get("trial_spawner_state").stringValue("active"))); - // Winter drop (1.22?) + //1.21.4 (Winter Drop) addBlock("pale_moss_block", Texture.paleMossBlock); addBlock("pale_oak_leaves", (name, tag) -> new UntintedLeaves(name, Texture.paleOakLeaves)); addBlock("pale_oak_log", (name, tag) -> log(tag, Texture.paleOakLog, Texture.paleOakLogTop)); @@ -1157,7 +1156,9 @@ private static void addBlocks(Texture texture, String... names) { tag.get("Properties").get("active").stringValue("false").equals("true"))); addBlock("chiseled_resin_bricks", Texture.chiseledResinBricks); addBlock("closed_eyeblossom", (name, tag) -> new SpriteBlock(name, Texture.closedEyeblossom)); + addBlock("open_eyeblossom", (name, tag) -> new OpenEyeBlossom()); addBlock("potted_closed_eyeblossom", (name, tag) -> new FlowerPot(name, FlowerPotModel.Kind.CLOSED_EYEBLOSSOM)); + addBlock("potted_open_eyeblossom", (name, tag) -> new FlowerPot(name, FlowerPotModel.Kind.OPEN_EYEBLOSSOM)); addBlock("resin_block", Texture.resinBlock); addBlock("resin_bricks", Texture.resinBricks); addBlock("resin_brick_stairs", (name, tag) -> stairs(tag, Texture.resinBricks)); diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/FlowerPot.java b/chunky/src/java/se/llbit/chunky/block/minecraft/FlowerPot.java index c30f09376..4289df54d 100644 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/FlowerPot.java +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/FlowerPot.java @@ -25,6 +25,6 @@ public class FlowerPot extends AbstractModelBlock { public FlowerPot(String name, FlowerPotModel.Kind kind) { super(name, Texture.flowerPot); - this.model = new FlowerPotModel(kind); + this.model = FlowerPotModel.forKind(kind); } } diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeBlossom.java b/chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeBlossom.java new file mode 100644 index 000000000..6dab78ea4 --- /dev/null +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeBlossom.java @@ -0,0 +1,29 @@ +package se.llbit.chunky.block.minecraft; + +import se.llbit.chunky.block.MinecraftBlockTranslucent; +import se.llbit.chunky.model.minecraft.SpriteModel; +import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.chunky.resources.Texture; +import se.llbit.chunky.world.Material; +import se.llbit.chunky.world.material.TextureMaterial; +import se.llbit.math.Ray; + +public class OpenEyeBlossom extends MinecraftBlockTranslucent { + public static final Material emissiveMaterial = new TextureMaterial(Texture.openEyeblossomEmissive); + private static final SpriteModel base = new SpriteModel(Texture.openEyeblossom, "up"); + private static final SpriteModel emissive = new SpriteModel(Texture.openEyeblossomEmissive, "up"); + + public OpenEyeBlossom() { + super("open_eyeblossom", Texture.openEyeblossom); + localIntersect = true; + } + + @Override + public boolean intersect(Ray ray, Scene scene) { + if (emissive.intersect(ray, scene)) { + ray.setCurrentMaterial(emissiveMaterial); + return true; + } + return base.intersect(ray, scene); + } +} diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java index 0be049186..56b91a04b 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java @@ -17,11 +17,15 @@ */ package se.llbit.chunky.model.minecraft; +import se.llbit.chunky.block.minecraft.OpenEyeBlossom; +import se.llbit.chunky.model.BlockModel; import se.llbit.chunky.model.Model; import se.llbit.chunky.model.QuadModel; import se.llbit.chunky.model.Tint; +import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.resources.Texture; import se.llbit.math.Quad; +import se.llbit.math.Ray; import se.llbit.math.Vector3; import se.llbit.math.Vector4; @@ -70,7 +74,8 @@ public enum Kind { TORCHFLOWER, CHERRY_SAPLING, PALE_OAK_SAPLING, - CLOSED_EYEBLOSSOM + CLOSED_EYEBLOSSOM, + OPEN_EYEBLOSSOM } private static final Texture flowerpot = Texture.flowerPot; @@ -481,7 +486,7 @@ public enum Kind { private final Texture[] textures; private final Tint[] tints; - public FlowerPotModel(Kind kind) { + private FlowerPotModel(Kind kind) { switch (kind) { case NONE: quads = flowerPot; @@ -528,6 +533,14 @@ public FlowerPotModel(Kind kind) { System.arraycopy(flowerPotTex, 0, textures, 0, flowerPotTex.length); Arrays.fill(textures, flowerPotTex.length, textures.length, Texture.mangrovePropagule); break; + case OPEN_EYEBLOSSOM: + quads = Model.join(flowerPot, flowerSmall, flowerSmall); + textures = new Texture[flowerPotTex.length + 2 * flowerSmall.length]; + tints = null; + System.arraycopy(flowerPotTex, 0, textures, 0, flowerPotTex.length); + Arrays.fill(textures, flowerPotTex.length, flowerPotTex.length + flowerSmall.length, Texture.openEyeblossom); + Arrays.fill(textures, flowerPotTex.length + flowerSmall.length, textures.length, Texture.openEyeblossomEmissive); + break; default: quads = Model.join(flowerPot, flowerSmall); textures = new Texture[flowerPotTex.length + flowerSmall.length]; @@ -643,4 +656,53 @@ public Texture[] getTextures() { public Tint[] getTints() { return tints; } + + public static BlockModel forKind(Kind kind) { + if (kind == Kind.OPEN_EYEBLOSSOM) { + return new FlowerPotModel(Kind.OPEN_EYEBLOSSOM) { + @Override + public boolean intersect(Ray ray, Scene scene) { + boolean hit = false; + ray.t = Double.POSITIVE_INFINITY; + + Quad[] quads = getQuads(); + Texture[] textures = getTextures(); + Tint[] tintedQuads = getTints(); + + float[] color = null; + Tint tint = Tint.NONE; + for (int i = 0; i < quads.length; ++i) { + Quad quad = quads[i]; + if (quad.intersect(ray)) { + float[] c = textures[i].getColor(ray.u, ray.v); + if (c[3] > Ray.EPSILON) { + tint = tintedQuads == null ? Tint.NONE : tintedQuads[i]; + color = c; + ray.t = ray.tNext; + if (quad.doubleSided) + ray.orientNormal(quad.n); + else + ray.setNormal(quad.n); + hit = true; + if (textures[i] == Texture.openEyeblossomEmissive) { + ray.setCurrentMaterial(OpenEyeBlossom.emissiveMaterial); + } + } + } + } + + if (hit) { + ray.color.set(color); + tint.tint(ray.color, ray, scene); + ray.distance += ray.t; + ray.o.scaleAdd(ray.t, ray.d); + } + return hit; + } + }; + } else { + return new FlowerPotModel(kind); + } + } + } diff --git a/chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java b/chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java index 560ca1137..814e374d8 100644 --- a/chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java +++ b/chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java @@ -17,6 +17,7 @@ package se.llbit.chunky.world; import se.llbit.chunky.block.minecraft.Candle; +import se.llbit.chunky.block.minecraft.OpenEyeBlossom; import se.llbit.chunky.entity.CalibratedSculkSensorAmethyst; import se.llbit.chunky.entity.Campfire; import se.llbit.chunky.entity.SporeBlossom; @@ -39,6 +40,7 @@ public class ExtraMaterials { idMap.put("calibrated_sculk_sensor_amethyst_inactive", CalibratedSculkSensorAmethyst.inactiveMaterial); idMap.put("spore_blossom (base)", SporeBlossom.baseMaterial); idMap.put("spore_blossom (blossom)", SporeBlossom.blossomMaterial); + idMap.put("open_eyeblossom (emissive)", OpenEyeBlossom.emissiveMaterial); } public static void loadDefaultMaterialProperties() { @@ -60,5 +62,8 @@ public static void loadDefaultMaterialProperties() { SporeBlossom.blossomMaterial.restoreDefaults(); SporeBlossom.baseMaterial.restoreDefaults(); + + OpenEyeBlossom.emissiveMaterial.restoreDefaults(); + OpenEyeBlossom.emissiveMaterial.emittance = 1.0f / 15; } } From e46f0d829710a8d0e562bc5f2b4458c4d4d318a8 Mon Sep 17 00:00:00 2001 From: Maik Marschner Date: Thu, 26 Dec 2024 20:08:09 +0100 Subject: [PATCH 6/6] Refactor open eyeblossom to be a quad model block and fix the casing in its name. --- .../chunky/block/MinecraftBlockProvider.java | 2 +- .../block/minecraft/OpenEyeBlossom.java | 29 ------- .../block/minecraft/OpenEyeblossom.java | 16 ++++ .../model/minecraft/FlowerPotModel.java | 4 +- .../model/minecraft/OpenEyeblossomModel.java | 76 +++++++++++++++++++ .../se/llbit/chunky/world/ExtraMaterials.java | 8 +- 6 files changed, 99 insertions(+), 36 deletions(-) delete mode 100644 chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeBlossom.java create mode 100644 chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeblossom.java create mode 100644 chunky/src/java/se/llbit/chunky/model/minecraft/OpenEyeblossomModel.java diff --git a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java index 0e041ae92..0bb51596b 100644 --- a/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java +++ b/chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java @@ -1156,7 +1156,7 @@ private static void addBlocks(Texture texture, String... names) { tag.get("Properties").get("active").stringValue("false").equals("true"))); addBlock("chiseled_resin_bricks", Texture.chiseledResinBricks); addBlock("closed_eyeblossom", (name, tag) -> new SpriteBlock(name, Texture.closedEyeblossom)); - addBlock("open_eyeblossom", (name, tag) -> new OpenEyeBlossom()); + addBlock("open_eyeblossom", (name, tag) -> new OpenEyeblossom()); addBlock("potted_closed_eyeblossom", (name, tag) -> new FlowerPot(name, FlowerPotModel.Kind.CLOSED_EYEBLOSSOM)); addBlock("potted_open_eyeblossom", (name, tag) -> new FlowerPot(name, FlowerPotModel.Kind.OPEN_EYEBLOSSOM)); addBlock("resin_block", Texture.resinBlock); diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeBlossom.java b/chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeBlossom.java deleted file mode 100644 index 6dab78ea4..000000000 --- a/chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeBlossom.java +++ /dev/null @@ -1,29 +0,0 @@ -package se.llbit.chunky.block.minecraft; - -import se.llbit.chunky.block.MinecraftBlockTranslucent; -import se.llbit.chunky.model.minecraft.SpriteModel; -import se.llbit.chunky.renderer.scene.Scene; -import se.llbit.chunky.resources.Texture; -import se.llbit.chunky.world.Material; -import se.llbit.chunky.world.material.TextureMaterial; -import se.llbit.math.Ray; - -public class OpenEyeBlossom extends MinecraftBlockTranslucent { - public static final Material emissiveMaterial = new TextureMaterial(Texture.openEyeblossomEmissive); - private static final SpriteModel base = new SpriteModel(Texture.openEyeblossom, "up"); - private static final SpriteModel emissive = new SpriteModel(Texture.openEyeblossomEmissive, "up"); - - public OpenEyeBlossom() { - super("open_eyeblossom", Texture.openEyeblossom); - localIntersect = true; - } - - @Override - public boolean intersect(Ray ray, Scene scene) { - if (emissive.intersect(ray, scene)) { - ray.setCurrentMaterial(emissiveMaterial); - return true; - } - return base.intersect(ray, scene); - } -} diff --git a/chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeblossom.java b/chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeblossom.java new file mode 100644 index 000000000..95a406bb5 --- /dev/null +++ b/chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeblossom.java @@ -0,0 +1,16 @@ +package se.llbit.chunky.block.minecraft; + +import se.llbit.chunky.block.AbstractModelBlock; +import se.llbit.chunky.model.minecraft.OpenEyeblossomModel; +import se.llbit.chunky.resources.Texture; +import se.llbit.chunky.world.Material; +import se.llbit.chunky.world.material.TextureMaterial; + +public class OpenEyeblossom extends AbstractModelBlock { + public static final Material emissiveMaterial = new TextureMaterial(Texture.openEyeblossomEmissive); + + public OpenEyeblossom() { + super("open_eyeblossom", Texture.openEyeblossom); + model = new OpenEyeblossomModel(); + } +} diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java index 56b91a04b..771d0bb91 100644 --- a/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/FlowerPotModel.java @@ -17,7 +17,7 @@ */ package se.llbit.chunky.model.minecraft; -import se.llbit.chunky.block.minecraft.OpenEyeBlossom; +import se.llbit.chunky.block.minecraft.OpenEyeblossom; import se.llbit.chunky.model.BlockModel; import se.llbit.chunky.model.Model; import se.llbit.chunky.model.QuadModel; @@ -685,7 +685,7 @@ public boolean intersect(Ray ray, Scene scene) { ray.setNormal(quad.n); hit = true; if (textures[i] == Texture.openEyeblossomEmissive) { - ray.setCurrentMaterial(OpenEyeBlossom.emissiveMaterial); + ray.setCurrentMaterial(OpenEyeblossom.emissiveMaterial); } } } diff --git a/chunky/src/java/se/llbit/chunky/model/minecraft/OpenEyeblossomModel.java b/chunky/src/java/se/llbit/chunky/model/minecraft/OpenEyeblossomModel.java new file mode 100644 index 000000000..0b430d818 --- /dev/null +++ b/chunky/src/java/se/llbit/chunky/model/minecraft/OpenEyeblossomModel.java @@ -0,0 +1,76 @@ +package se.llbit.chunky.model.minecraft; + +import se.llbit.chunky.block.minecraft.OpenEyeblossom; +import se.llbit.chunky.model.Model; +import se.llbit.chunky.model.QuadModel; +import se.llbit.chunky.model.Tint; +import se.llbit.chunky.renderer.scene.Scene; +import se.llbit.chunky.resources.Texture; +import se.llbit.math.Quad; +import se.llbit.math.Ray; + +import java.util.Arrays; + +public class OpenEyeblossomModel extends QuadModel { + private static final Quad[] quads; + private static final Texture[] textures; + + static { + SpriteModel base = new SpriteModel(Texture.openEyeblossom, "up"); + SpriteModel emissive = new SpriteModel(Texture.openEyeblossomEmissive, "up"); + + quads = Model.join(base.getQuads(), emissive.getQuads()); + textures = Arrays.copyOf(base.getTextures(), base.getTextures().length + emissive.getTextures().length); + System.arraycopy(emissive.getTextures(), 0, textures, base.getTextures().length, emissive.getTextures().length); + } + + @Override + public Quad[] getQuads() { + return quads; + } + + @Override + public Texture[] getTextures() { + return textures; + } + + @Override + public boolean intersect(Ray ray, Scene scene) { + boolean hit = false; + ray.t = Double.POSITIVE_INFINITY; + + Quad[] quads = getQuads(); + Texture[] textures = getTextures(); + Tint[] tintedQuads = getTints(); + + float[] color = null; + Tint tint = Tint.NONE; + for (int i = 0; i < quads.length; ++i) { + Quad quad = quads[i]; + if (quad.intersect(ray)) { + float[] c = textures[i].getColor(ray.u, ray.v); + if (c[3] > Ray.EPSILON) { + tint = tintedQuads == null ? Tint.NONE : tintedQuads[i]; + color = c; + ray.t = ray.tNext; + if (quad.doubleSided) + ray.orientNormal(quad.n); + else + ray.setNormal(quad.n); + hit = true; + if (textures[i] == Texture.openEyeblossomEmissive) { + ray.setCurrentMaterial(OpenEyeblossom.emissiveMaterial); + } + } + } + } + + if (hit) { + ray.color.set(color); + tint.tint(ray.color, ray, scene); + ray.distance += ray.t; + ray.o.scaleAdd(ray.t, ray.d); + } + return hit; + } +} diff --git a/chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java b/chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java index 814e374d8..8eda29367 100644 --- a/chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java +++ b/chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java @@ -17,7 +17,7 @@ package se.llbit.chunky.world; import se.llbit.chunky.block.minecraft.Candle; -import se.llbit.chunky.block.minecraft.OpenEyeBlossom; +import se.llbit.chunky.block.minecraft.OpenEyeblossom; import se.llbit.chunky.entity.CalibratedSculkSensorAmethyst; import se.llbit.chunky.entity.Campfire; import se.llbit.chunky.entity.SporeBlossom; @@ -40,7 +40,7 @@ public class ExtraMaterials { idMap.put("calibrated_sculk_sensor_amethyst_inactive", CalibratedSculkSensorAmethyst.inactiveMaterial); idMap.put("spore_blossom (base)", SporeBlossom.baseMaterial); idMap.put("spore_blossom (blossom)", SporeBlossom.blossomMaterial); - idMap.put("open_eyeblossom (emissive)", OpenEyeBlossom.emissiveMaterial); + idMap.put("open_eyeblossom (emissive)", OpenEyeblossom.emissiveMaterial); } public static void loadDefaultMaterialProperties() { @@ -63,7 +63,7 @@ public static void loadDefaultMaterialProperties() { SporeBlossom.blossomMaterial.restoreDefaults(); SporeBlossom.baseMaterial.restoreDefaults(); - OpenEyeBlossom.emissiveMaterial.restoreDefaults(); - OpenEyeBlossom.emissiveMaterial.emittance = 1.0f / 15; + OpenEyeblossom.emissiveMaterial.restoreDefaults(); + OpenEyeblossom.emissiveMaterial.emittance = 1.0f / 15; } }