Skip to content

Commit

Permalink
Add pale moss carpet.
Browse files Browse the repository at this point in the history
  • Loading branch information
leMaik committed Oct 27, 2024
1 parent 6b00290 commit a6d65f3
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;
Expand Down Expand Up @@ -1146,6 +1147,12 @@ private static void addBlocks(Texture texture, String... names) {
addBlock("pale_oak_wall_sign", (name, tag) -> wallSign(tag, "pale_oak"));
addBlock("pale_oak_hanging_sign", (name, tag) -> hangingSign(tag, "pale_oak"));
addBlock("pale_oak_wall_hanging_sign", (name, tag) -> wallHangingSign(tag, "pale_oak"));
addBlock("pale_moss_carpet", (name, tag) -> new PaleMossCarpet(name,
tag.get("Properties").get("bottom").stringValue("false").equals("true"),
tag.get("Properties").get("north").stringValue("none"),
tag.get("Properties").get("east").stringValue("none"),
tag.get("Properties").get("south").stringValue("none"),
tag.get("Properties").get("west").stringValue("none")));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package se.llbit.chunky.block.minecraft;

import se.llbit.chunky.block.AbstractModelBlock;
import se.llbit.chunky.model.minecraft.PaleMossCarpetModel;
import se.llbit.chunky.resources.Texture;

public class PaleMossCarpet extends AbstractModelBlock {
private final String description;

public PaleMossCarpet(String name, boolean bottom, String north, String east, String south, String west) {
super(name, Texture.paleMossCarpet);
this.model = new PaleMossCarpetModel(bottom, north, east, south, west);
this.description = String.format("bottom=%s, north=%s, east=%s, south=%s, west=%s", bottom, north, east, south, west);
}

@Override
public String description() {
return description;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package se.llbit.chunky.model.minecraft;

import se.llbit.chunky.model.Model;
import se.llbit.chunky.model.QuadModel;
import se.llbit.chunky.resources.Texture;
import se.llbit.math.Quad;
import se.llbit.math.Vector3;
import se.llbit.math.Vector4;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class PaleMossCarpetModel extends QuadModel {
private static final Quad[] carpet = new Quad[]{
new Quad(
new Vector3(0 / 16.0, 1 / 16.0, 16 / 16.0),
new Vector3(16 / 16.0, 1 / 16.0, 16 / 16.0),
new Vector3(0 / 16.0, 1 / 16.0, 0 / 16.0),
new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0)
),
new Quad(
new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0),
new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0),
new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0),
new Vector4(0 / 16.0, 16 / 16.0, 0 / 16.0, 16 / 16.0)
),
new Quad(
new Vector3(0 / 16.0, 1 / 16.0, 16 / 16.0),
new Vector3(0 / 16.0, 1 / 16.0, 0 / 16.0),
new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0),
new Vector4(16 / 16.0, 0 / 16.0, 1 / 16.0, 0 / 16.0)
),
new Quad(
new Vector3(16 / 16.0, 1 / 16.0, 0 / 16.0),
new Vector3(16 / 16.0, 1 / 16.0, 16 / 16.0),
new Vector3(16 / 16.0, 0 / 16.0, 0 / 16.0),
new Vector4(16 / 16.0, 0 / 16.0, 1 / 16.0, 0 / 16.0)
),
new Quad(
new Vector3(0 / 16.0, 1 / 16.0, 0 / 16.0),
new Vector3(16 / 16.0, 1 / 16.0, 0 / 16.0),
new Vector3(0 / 16.0, 0 / 16.0, 0 / 16.0),
new Vector4(16 / 16.0, 0 / 16.0, 1 / 16.0, 0 / 16.0)
),
new Quad(
new Vector3(16 / 16.0, 1 / 16.0, 16 / 16.0),
new Vector3(0 / 16.0, 1 / 16.0, 16 / 16.0),
new Vector3(16 / 16.0, 0 / 16.0, 16 / 16.0),
new Vector4(16 / 16.0, 0 / 16.0, 1 / 16.0, 0 / 16.0)
)
};

private static final Quad[] carpetSide = new Quad[]{
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
)
};

private final Quad[] quads;
private final Texture[] textures;

public PaleMossCarpetModel(boolean bottom, String north, String east, String south, String west) {
List<Quad> quads = new ArrayList<>();
List<Texture> textures = new ArrayList<>();

boolean noSides = !bottom && north.equals("none") && east.equals("none") && south.equals("none") && west.equals("none");

// bottom
if (bottom || noSides) {
quads.addAll(Arrays.asList(carpet));
for (Quad quad : quads) {
textures.add(Texture.paleMossCarpet);
}
}

// north side
if (!north.equals("none") || noSides) {
quads.addAll(Arrays.asList(carpetSide));
textures.add(north.equals("tall") || noSides ? Texture.paleMossCarpetSideTall : Texture.paleMossCarpetSideSmall);
}

// east side
if (!east.equals("none") || noSides) {
quads.addAll(Arrays.asList(Model.rotateY(carpetSide)));
textures.add(east.equals("tall") || noSides ? Texture.paleMossCarpetSideTall : Texture.paleMossCarpetSideSmall);
}

// east side
if (!south.equals("none") || noSides) {
quads.addAll(Arrays.asList(Model.rotateY(carpetSide, Math.toRadians(180))));
textures.add(south.equals("tall") || noSides ? Texture.paleMossCarpetSideTall : Texture.paleMossCarpetSideSmall);
}

// east side
if (!west.equals("none") || noSides) {
quads.addAll(Arrays.asList(Model.rotateNegY(carpetSide)));
textures.add(west.equals("tall") || noSides ? Texture.paleMossCarpetSideTall : Texture.paleMossCarpetSideSmall);
}

this.quads = quads.toArray(new Quad[0]);
this.textures = textures.toArray(new Texture[0]);
}

@Override
public Quad[] getQuads() {
return quads;
}

@Override
public Texture[] getTextures() {
return textures;
}
}
6 changes: 6 additions & 0 deletions chunky/src/java/se/llbit/chunky/resources/Texture.java
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,12 @@ public class Texture {
public static final Texture paleOakSignPost = new Texture();
@TexturePath("assets/minecraft/textures/entity/signs/hanging/pale_oak")
public static final Texture paleOakHangingSign = new Texture();
@TexturePath("assets/minecraft/textures/block/pale_moss_carpet")
public static final Texture paleMossCarpet = new Texture();
@TexturePath("assets/minecraft/textures/block/pale_moss_carpet_side_small")
public static final Texture paleMossCarpetSideSmall = new Texture();
@TexturePath("assets/minecraft/textures/block/pale_moss_carpet_side_tall")
public static final Texture paleMossCarpetSideTall = new Texture();

/** Banner base texture. */
public static final Texture bannerBase = new Texture();
Expand Down

0 comments on commit a6d65f3

Please sign in to comment.