-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
chunky/src/java/se/llbit/chunky/block/minecraft/PaleMossCarpet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
chunky/src/java/se/llbit/chunky/model/minecraft/PaleMossCarpetModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters