Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import se.llbit.chunky.model.minecraft.FlowerPotModel;
import se.llbit.chunky.resources.ShulkerTexture;
import se.llbit.chunky.resources.Texture;
import se.llbit.chunky.resources.texturepack.BedTexture;
import se.llbit.nbt.ListTag;
import se.llbit.nbt.Tag;

Expand Down Expand Up @@ -1266,6 +1267,9 @@ private static void addBlock(String name, Texture texture) {
addBlock("polished_sulfur_slab", (name, tag) -> slab(tag, Texture.polishedSulfur));
addBlock("polished_sulfur_stairs", (name, tag) -> stairs(tag, Texture.polishedSulfur));
addBlock("polished_sulfur_wall", (name, tag) -> wall(tag, Texture.polishedSulfur));
addBlock("sulfur_spike", (name, tag) -> new SulfurSpike(
tag.get("Properties").get("thickness").stringValue("tip"),
tag.get("Properties").get("vertical_direction").stringValue("up")));
}

@Override
Expand Down Expand Up @@ -2482,7 +2486,7 @@ public Block getBlockByTag(String namespacedName, Tag tag) {
case "gray_bed":
return bed(tag, Texture.bedGray);
case "light_gray_bed":
return bed(tag, Texture.bedSilver);
return bed(tag, Texture.bedLightGray);
case "cyan_bed":
return bed(tag, Texture.bedCyan);
case "purple_bed":
Expand Down Expand Up @@ -3280,7 +3284,7 @@ private static Block glazedTerracotta(Tag tag, Texture texture) {
return new GlazedTerracotta(name, texture, facing);
}

private static Block bed(Tag tag, Texture texture) {
private static Block bed(Tag tag, BedTexture.Textures texture) {
String name = BlockProvider.blockName(tag);
String part = tag.get("Properties").get("part").stringValue("head");
String facing = BlockProvider.facing(tag, "south");
Expand Down
21 changes: 12 additions & 9 deletions chunky/src/java/se/llbit/chunky/block/minecraft/Bed.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,37 @@
package se.llbit.chunky.block.minecraft;

import se.llbit.chunky.block.AbstractModelBlock;
import se.llbit.chunky.model.minecraft.BedModel;
import se.llbit.chunky.resources.Texture;
import se.llbit.chunky.model.minecraft.BedFootModel;
import se.llbit.chunky.model.minecraft.BedHeadModel;
import se.llbit.chunky.resources.texturepack.BedTexture;

public class Bed extends AbstractModelBlock {

private final String description;

public Bed(String name, Texture texture, String part, String facing) {
super(name, texture);
public Bed(String name, BedTexture.Textures texture, String part, String facing) {
super(name, part.equals("head") ? texture.headUp : texture.footUp);
this.description = String.format("part=%s, facing=%s", part, facing);
boolean head = part.equals("head");
int direction;
switch (facing) {
default:
case "north":
direction = 2;
direction = 0;
break;
case "east":
direction = 3;
direction = 1;
break;
case "south":
direction = 0;
direction = 2;
break;
case "west":
direction = 1;
direction = 3;
break;
}
model = new BedModel(head, direction, texture);
model = head
? new BedHeadModel(direction, texture)
: new BedFootModel(direction, texture);
solid = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,21 @@ public PointedDripstone(String thickness, String verticalDirection) {

private static Texture getTexture(String thickness, String verticalDirection) {
if (verticalDirection.equals("down")) {
switch (thickness) {
case "tip_merge":
return Texture.pointedDripstoneDownTipMerge;
case "frustum":
return Texture.pointedDripstoneDownFrustum;
case "middle":
return Texture.pointedDripstoneDownMiddle;
case "base":
return Texture.pointedDripstoneDownBase;
default:
case "tip":
return Texture.pointedDripstoneDownTip;
}
return switch (thickness) {
case "tip_merge" -> Texture.pointedDripstoneDownTipMerge;
case "frustum" -> Texture.pointedDripstoneDownFrustum;
case "middle" -> Texture.pointedDripstoneDownMiddle;
case "base" -> Texture.pointedDripstoneDownBase;
default -> Texture.pointedDripstoneDownTip; // tip
};
} else {
switch (thickness) {
case "tip_merge":
return Texture.pointedDripstoneUpTipMerge;
case "frustum":
return Texture.pointedDripstoneUpFrustum;
case "middle":
return Texture.pointedDripstoneUpMiddle;
case "base":
return Texture.pointedDripstoneUpBase;
default:
case "tip":
return Texture.pointedDripstoneUpTip;
}
return switch (thickness) {
case "tip_merge" -> Texture.pointedDripstoneUpTipMerge;
case "frustum" -> Texture.pointedDripstoneUpFrustum;
case "middle" -> Texture.pointedDripstoneUpMiddle;
case "base" -> Texture.pointedDripstoneUpBase;
default -> Texture.pointedDripstoneUpTip; // tip
};
}
}

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

import se.llbit.chunky.resources.Texture;

public class SulfurSpike extends SpriteBlock {
private final String description;

public SulfurSpike(String thickness, String verticalDirection) {
super("sulfur_spike", getTexture(thickness, verticalDirection));
description = "thickness=" + thickness + ", vertical_direction=" + verticalDirection;
}

private static Texture getTexture(String thickness, String verticalDirection) {
if (verticalDirection.equals("down")) {
return switch (thickness) {
case "tip_merge" -> Texture.sulfurSpikeDownTipMerge;
case "frustum" -> Texture.sulfurSpikeDownFrustum;
case "middle" -> Texture.sulfurSpikeDownMiddle;
case "base" -> Texture.sulfurSpikeDownBase;
default -> Texture.sulfurSpikeDownTip; // tip
};
} else {
return switch (thickness) {
case "tip_merge" -> Texture.sulfurSpikeUpTipMerge;
case "frustum" -> Texture.sulfurSpikeUpFrustum;
case "middle" -> Texture.sulfurSpikeUpMiddle;
case "base" -> Texture.sulfurSpikeUpBase;
default -> Texture.sulfurSpikeUpTip; // tip
};
}
}

@Override
public String description() {
return description;
}
}
126 changes: 126 additions & 0 deletions chunky/src/java/se/llbit/chunky/model/minecraft/BedFootModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
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.chunky.resources.texturepack.BedTexture;
import se.llbit.math.Quad;
import se.llbit.math.Vector3;
import se.llbit.math.Vector4;

public class BedFootModel extends QuadModel {
private static final Quad[] quadsNorth = new Quad[]{
new Quad(
new Vector3(0 / 16.0, 9 / 16.0, 16 / 16.0),
new Vector3(16 / 16.0, 9 / 16.0, 16 / 16.0),
new Vector3(0 / 16.0, 9 / 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, 3 / 16.0, 0 / 16.0),
new Vector3(16 / 16.0, 3 / 16.0, 0 / 16.0),
new Vector3(0 / 16.0, 3 / 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, 9 / 16.0, 16 / 16.0),
new Vector3(0 / 16.0, 9 / 16.0, 0 / 16.0),
new Vector3(0 / 16.0, 3 / 16.0, 16 / 16.0),
new Vector4(16 / 16.0, 0 / 16.0, 9 / 16.0, 3 / 16.0)
),
new Quad(
new Vector3(16 / 16.0, 9 / 16.0, 0 / 16.0),
new Vector3(16 / 16.0, 9 / 16.0, 16 / 16.0),
new Vector3(16 / 16.0, 3 / 16.0, 0 / 16.0),
new Vector4(16 / 16.0, 0 / 16.0, 9 / 16.0, 3 / 16.0)
),
new Quad(
new Vector3(16 / 16.0, 9 / 16.0, 16 / 16.0),
new Vector3(0 / 16.0, 9 / 16.0, 16 / 16.0),
new Vector3(16 / 16.0, 3 / 16.0, 16 / 16.0),
new Vector4(16 / 16.0, 0 / 16.0, 9 / 16.0, 3 / 16.0)
),
new Quad(
new Vector3(0 / 16.0, 0 / 16.0, 13 / 16.0),
new Vector3(3 / 16.0, 0 / 16.0, 13 / 16.0),
new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0),
new Vector4(7 / 16.0, 10 / 16.0, 0 / 16.0, 3 / 16.0)
),
new Quad(
new Vector3(0 / 16.0, 3 / 16.0, 16 / 16.0),
new Vector3(0 / 16.0, 3 / 16.0, 13 / 16.0),
new Vector3(0 / 16.0, 0 / 16.0, 16 / 16.0),
new Vector4(16 / 16.0, 13 / 16.0, 3 / 16.0, 0 / 16.0)
),
new Quad(
new Vector3(3 / 16.0, 3 / 16.0, 13 / 16.0),
new Vector3(3 / 16.0, 3 / 16.0, 16 / 16.0),
new Vector3(3 / 16.0, 0 / 16.0, 13 / 16.0),
new Vector4(6 / 16.0, 3 / 16.0, 3 / 16.0, 0 / 16.0)
),
new Quad(
new Vector3(0 / 16.0, 3 / 16.0, 13 / 16.0),
new Vector3(3 / 16.0, 3 / 16.0, 13 / 16.0),
new Vector3(0 / 16.0, 0 / 16.0, 13 / 16.0),
new Vector4(13 / 16.0, 10 / 16.0, 3 / 16.0, 0 / 16.0)
),
new Quad(
new Vector3(3 / 16.0, 3 / 16.0, 16 / 16.0),
new Vector3(0 / 16.0, 3 / 16.0, 16 / 16.0),
new Vector3(3 / 16.0, 0 / 16.0, 16 / 16.0),
new Vector4(3 / 16.0, 0 / 16.0, 3 / 16.0, 0 / 16.0)
),
new Quad(
new Vector3(13 / 16.0, 0 / 16.0, 13 / 16.0),
new Vector3(16 / 16.0, 0 / 16.0, 13 / 16.0),
new Vector3(13 / 16.0, 0 / 16.0, 16 / 16.0),
new Vector4(6 / 16.0, 9 / 16.0, 0 / 16.0, 3 / 16.0)
),
new Quad(
new Vector3(13 / 16.0, 3 / 16.0, 16 / 16.0),
new Vector3(13 / 16.0, 3 / 16.0, 13 / 16.0),
new Vector3(13 / 16.0, 0 / 16.0, 16 / 16.0),
new Vector4(13 / 16.0, 10 / 16.0, 3 / 16.0, 0 / 16.0)
),
new Quad(
new Vector3(16 / 16.0, 3 / 16.0, 13 / 16.0),
new Vector3(16 / 16.0, 3 / 16.0, 16 / 16.0),
new Vector3(16 / 16.0, 0 / 16.0, 13 / 16.0),
new Vector4(3 / 16.0, 0 / 16.0, 3 / 16.0, 0 / 16.0)
),
new Quad(
new Vector3(13 / 16.0, 3 / 16.0, 13 / 16.0),
new Vector3(16 / 16.0, 3 / 16.0, 13 / 16.0),
new Vector3(13 / 16.0, 0 / 16.0, 13 / 16.0),
new Vector4(6 / 16.0, 3 / 16.0, 3 / 16.0, 0 / 16.0)
),
new Quad(
new Vector3(16 / 16.0, 3 / 16.0, 16 / 16.0),
new Vector3(13 / 16.0, 3 / 16.0, 16 / 16.0),
new Vector3(16 / 16.0, 0 / 16.0, 16 / 16.0),
new Vector4(16 / 16.0, 13 / 16.0, 3 / 16.0, 0 / 16.0)
)
};

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

public BedFootModel(int facing, BedTexture.Textures textures) {
this.textures = new Texture[]{
textures.footUp, textures.footDown, textures.footWest, textures.footEast,
textures.footSouth, textures.footWest, textures.footWest, textures.footSouth,
textures.footWest, textures.footSouth, textures.footEast, textures.footSouth,
textures.footEast, textures.footEast, textures.footSouth};
quads = Model.rotateY(quadsNorth, -Math.toRadians(90 * facing));
}

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

@Override
public Texture[] getTextures() {
return textures;
}
}
Loading
Loading