mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
added support for vertically flipped blocks
This commit is contained in:
parent
54cfc33eca
commit
ac8e57c3d4
@ -23,6 +23,7 @@ public class BlockConfiguration {
|
||||
BlockRotation rotation;
|
||||
HashSet<BlockProperties> blockProperties;
|
||||
|
||||
|
||||
public BlockConfiguration(String config) {
|
||||
blockProperties = new HashSet<>();
|
||||
for (String configuration : config.split(",")) {
|
||||
|
@ -14,7 +14,6 @@
|
||||
package de.bixilon.minosoft.render.blockModels.Face;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
|
||||
import de.bixilon.minosoft.render.blockModels.subBlocks.Cuboid;
|
||||
import de.bixilon.minosoft.render.blockModels.subBlocks.SubBlockPosition;
|
||||
import de.bixilon.minosoft.render.texture.InFaceUV;
|
||||
import javafx.util.Pair;
|
||||
@ -23,14 +22,18 @@ public class Face {
|
||||
SubBlockPosition[] positions;
|
||||
InFaceUV uv;
|
||||
|
||||
public Face(FaceOrientation orientation, Pair<Float, Float> texture, InFaceUV uv, Cuboid cuboid) {
|
||||
positions = cuboid.getFacePositions(orientation);
|
||||
public Face(Pair<Float, Float> texture, InFaceUV uv, SubBlockPosition[] facePositions) {
|
||||
positions = facePositions;
|
||||
this.uv = uv;
|
||||
this.uv.prepare(texture);
|
||||
}
|
||||
|
||||
public Face() {
|
||||
positions = new SubBlockPosition[]{};
|
||||
}
|
||||
|
||||
public void draw(BlockPosition pos) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int i = 0; i < positions.length; i++) {
|
||||
uv.draw(i);
|
||||
positions[i].draw(pos);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.render.blockModels.subBlocks;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Block;
|
||||
import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.BlockRotation;
|
||||
import de.bixilon.minosoft.render.blockModels.Face.Face;
|
||||
import de.bixilon.minosoft.render.blockModels.Face.FaceOrientation;
|
||||
import de.bixilon.minosoft.render.texture.InFaceUV;
|
||||
@ -110,14 +111,33 @@ public class SubBlock {
|
||||
if (!textureCoordinates.containsKey(orientation)) {
|
||||
continue;
|
||||
}
|
||||
if (!(adjacentBlocks.get(orientation) && cullFaceTextures.get(orientation))) {
|
||||
result.add(new Face(orientation, textureCoordinates.get(orientation),
|
||||
uv.get(orientation), cuboid));
|
||||
if (block.getRotation().equals(BlockRotation.DOWN)) {
|
||||
if (orientation.equals(FaceOrientation.DOWN)) {
|
||||
result.add(prepareFace(FaceOrientation.DOWN, FaceOrientation.UP,
|
||||
adjacentBlocks));
|
||||
continue;
|
||||
}
|
||||
if (orientation.equals(FaceOrientation.UP)) {
|
||||
result.add(prepareFace(FaceOrientation.UP, FaceOrientation.DOWN,
|
||||
adjacentBlocks));
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
result.add(prepareFace(orientation, orientation, adjacentBlocks));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Face prepareFace(FaceOrientation textureDirection, FaceOrientation faceDirection,
|
||||
HashMap<FaceOrientation, Boolean> adjacentBlocks) {
|
||||
if (adjacentBlocks.get(faceDirection) && !cullFaceTextures.get(faceDirection)) {
|
||||
return new Face();
|
||||
}
|
||||
return new Face(textureCoordinates.get(textureDirection), uv.get(textureDirection),
|
||||
cuboid.getFacePositions(faceDirection));
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
return isFull;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user