-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add chiseled resin bricks and closed eyeblossom. * Add resin block and resin bricks blocks. * Replace creaking heart creaking property with active. * Add resin clump block. * Add open eyeblossom and potted open eyeblossom. * Refactor open eyeblossom to be a quad model block and fix the casing in its name.
- Loading branch information
Showing
10 changed files
with
320 additions
and
49 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
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
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
16 changes: 16 additions & 0 deletions
16
chunky/src/java/se/llbit/chunky/block/minecraft/OpenEyeblossom.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,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(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
chunky/src/java/se/llbit/chunky/block/minecraft/ResinClump.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,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; | ||
} | ||
} |
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
76 changes: 76 additions & 0 deletions
76
chunky/src/java/se/llbit/chunky/model/minecraft/OpenEyeblossomModel.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,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; | ||
} | ||
} |
Oops, something went wrong.