mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 00:23:42 -04:00
fix InFaceUV errors
This commit is contained in:
parent
76acaa5192
commit
8c47dedf3b
Binary file not shown.
@ -59,10 +59,10 @@ public class ModIdentifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean identifierEquals(ModIdentifier their) {
|
public boolean identifierEquals(ModIdentifier their) {
|
||||||
if (super.equals(their)) {
|
if (this == their) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (hashCode() != their.hashCode()) {
|
if (identifier.hashCode() != their.getIdentifier().hashCode()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return getIdentifier().equals(their.getIdentifier()) && getMod().equals(their.getMod());
|
return getIdentifier().equals(their.getIdentifier()) && getMod().equals(their.getMod());
|
||||||
|
@ -34,7 +34,7 @@ public final class LegacyBlockTransform {
|
|||||||
Block blockAbove = chunk.getBlock(block.getKey().getChunkLocation(section.getKey()).add(0, 1, 0));
|
Block blockAbove = chunk.getBlock(block.getKey().getChunkLocation(section.getKey()).add(0, 1, 0));
|
||||||
Block newBlock = null;
|
Block newBlock = null;
|
||||||
if (block.getValue().equals(GRASS_BLOCK)) {
|
if (block.getValue().equals(GRASS_BLOCK)) {
|
||||||
if (blockAbove == null || (!blockAbove.identifierEquals(SNOW_BLOCK) & !blockAbove.identifierEquals(SNOW_LAYER_BLOCK))) {
|
if (blockAbove == null || (!blockAbove.identifierEquals(SNOW_BLOCK) && !blockAbove.identifierEquals(SNOW_LAYER_BLOCK))) {
|
||||||
newBlock = GRASS_BLOCK_NOT_SNOWY;
|
newBlock = GRASS_BLOCK_NOT_SNOWY;
|
||||||
} else {
|
} else {
|
||||||
newBlock = GRASS_BLOCK_SNOWY;
|
newBlock = GRASS_BLOCK_SNOWY;
|
||||||
|
@ -48,10 +48,13 @@ public class SubBlock {
|
|||||||
JsonObject faces = json.getAsJsonObject("faces");
|
JsonObject faces = json.getAsJsonObject("faces");
|
||||||
for (FaceOrientation orientation : FaceOrientation.values()) {
|
for (FaceOrientation orientation : FaceOrientation.values()) {
|
||||||
if (faces.has(orientation.name().toLowerCase())) {
|
if (faces.has(orientation.name().toLowerCase())) {
|
||||||
putTexture(faces.getAsJsonObject(orientation.name().toLowerCase()), orientation, variables);
|
putTexture(faces.getAsJsonObject(orientation.name().toLowerCase()), orientation, variables, from, to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
full = createFull();
|
full = createFull();
|
||||||
|
if (textures.containsValue("block/cake_side")) {
|
||||||
|
int unused = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubBlock(SubBlock subBlock) {
|
public SubBlock(SubBlock subBlock) {
|
||||||
@ -94,14 +97,14 @@ public class SubBlock {
|
|||||||
uv.get(entry.getKey()).prepare(texture, loader);
|
uv.get(entry.getKey()).prepare(texture, loader);
|
||||||
}
|
}
|
||||||
// clean up
|
// clean up
|
||||||
textures.clear();
|
// textures.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putTexture(JsonObject faceJson, FaceOrientation orientation, HashMap<String, String> variables) {
|
private void putTexture(JsonObject faceJson, FaceOrientation orientation, HashMap<String, String> variables, SubBlockPosition from, SubBlockPosition to) {
|
||||||
if (faceJson.has("uv")) {
|
if (faceJson.has("uv")) {
|
||||||
uv.put(orientation, new InFaceUV(faceJson.getAsJsonArray("uv")));
|
uv.put(orientation, new InFaceUV(faceJson.getAsJsonArray("uv"), from, to, orientation));
|
||||||
} else {
|
} else {
|
||||||
uv.put(orientation, new InFaceUV());
|
uv.put(orientation, new InFaceUV(from, to, orientation));
|
||||||
}
|
}
|
||||||
if (faceJson.has("rotation")) {
|
if (faceJson.has("rotation")) {
|
||||||
int rotation = (360 - faceJson.get("rotation").getAsInt()) / 90;
|
int rotation = (360 - faceJson.get("rotation").getAsInt()) / 90;
|
||||||
|
@ -14,31 +14,52 @@
|
|||||||
package de.bixilon.minosoft.render.texture;
|
package de.bixilon.minosoft.render.texture;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
|
import de.bixilon.minosoft.render.blockModels.Face.FaceOrientation;
|
||||||
import de.bixilon.minosoft.render.blockModels.Face.RenderConstants;
|
import de.bixilon.minosoft.render.blockModels.Face.RenderConstants;
|
||||||
|
import de.bixilon.minosoft.render.blockModels.subBlocks.SubBlockPosition;
|
||||||
import org.apache.commons.collections.primitives.ArrayFloatList;
|
import org.apache.commons.collections.primitives.ArrayFloatList;
|
||||||
|
|
||||||
public class InFaceUV {
|
public class InFaceUV {
|
||||||
public final int u1, v1, u2, v2;
|
private final int u1;
|
||||||
|
private final int v1;
|
||||||
|
private final int u2;
|
||||||
|
private final int v2;
|
||||||
|
|
||||||
public float realU1 = -1, realV1, realU2, realV2;
|
private float realU1 = -1, realV1, realU2, realV2;
|
||||||
|
|
||||||
public InFaceUV(JsonArray json) {
|
public InFaceUV(JsonArray json, SubBlockPosition from, SubBlockPosition to, FaceOrientation orientation) {
|
||||||
u1 = json.get(0).getAsInt();
|
this(from, to, orientation);
|
||||||
v1 = json.get(1).getAsInt();
|
|
||||||
u2 = json.get(2).getAsInt();
|
|
||||||
v2 = json.get(3).getAsInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public InFaceUV() {
|
public InFaceUV(SubBlockPosition from, SubBlockPosition to, FaceOrientation orientation) {
|
||||||
u1 = v1 = 0;
|
switch (orientation) {
|
||||||
u2 = v2 = 16;
|
case EAST, WEST -> {
|
||||||
|
u1 = (int) from.getVector().getZ();
|
||||||
|
v1 = (int) (RenderConstants.TEXTURE_PACK_RESOLUTION - from.getVector().getY());
|
||||||
|
u2 = (int) to.getVector().getZ();
|
||||||
|
v2 = (int) (RenderConstants.TEXTURE_PACK_RESOLUTION - to.getVector().getY());
|
||||||
|
}
|
||||||
|
case UP, DOWN -> {
|
||||||
|
u1 = (int) from.getVector().getX();
|
||||||
|
v1 = (int) (RenderConstants.TEXTURE_PACK_RESOLUTION - from.getVector().getZ());
|
||||||
|
u2 = (int) to.getVector().getX();
|
||||||
|
v2 = (int) (RenderConstants.TEXTURE_PACK_RESOLUTION - to.getVector().getZ());
|
||||||
|
}
|
||||||
|
case SOUTH, NORTH -> {
|
||||||
|
u1 = (int) from.getVector().getX();
|
||||||
|
v1 = (int) (RenderConstants.TEXTURE_PACK_RESOLUTION - from.getVector().getY());
|
||||||
|
u2 = (int) to.getVector().getX();
|
||||||
|
v2 = (int) (RenderConstants.TEXTURE_PACK_RESOLUTION - to.getVector().getY());
|
||||||
|
}
|
||||||
|
default -> throw new RuntimeException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepare(float texture, TextureLoader textureLoader) {
|
public void prepare(float texture, TextureLoader textureLoader) {
|
||||||
realU1 = texture + u1 * textureLoader.getStep() / RenderConstants.TEXTURE_PACK_RESOLUTION;
|
realU1 = texture + textureLoader.getStep() * u1 / RenderConstants.TEXTURE_PACK_RESOLUTION;
|
||||||
realU2 = texture + u2 * textureLoader.getStep() / RenderConstants.TEXTURE_PACK_RESOLUTION;
|
realU2 = texture + textureLoader.getStep() * u2 / RenderConstants.TEXTURE_PACK_RESOLUTION;
|
||||||
realV1 = (float) v1 / RenderConstants.TEXTURE_PACK_RESOLUTION;
|
realV1 = (float) v2 / RenderConstants.TEXTURE_PACK_RESOLUTION;
|
||||||
realV2 = (float) v2 / RenderConstants.TEXTURE_PACK_RESOLUTION;
|
realV2 = (float) v1 / RenderConstants.TEXTURE_PACK_RESOLUTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayFloatList getFloats(int i) {
|
public ArrayFloatList getFloats(int i) {
|
||||||
|
@ -108,4 +108,16 @@ public class Vec3 {
|
|||||||
public void zero() {
|
public void zero() {
|
||||||
x = y = z = 0f;
|
x = y = z = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,17 +1,6 @@
|
|||||||
{
|
{
|
||||||
"block/grass_block_top": [
|
"block/grass_block_top": [0, 1, 0],
|
||||||
0,
|
"blocks/grass_top": [0, 1, 0],
|
||||||
1,
|
"block/grass": [0, 1, 0],
|
||||||
0
|
"block/water_still": [0, 0, 1]
|
||||||
],
|
|
||||||
"block/grass": [
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"block/water_still": [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user