Fix side indexing

This commit is contained in:
raoulvdberge
2020-01-14 12:39:25 +01:00
parent 06b8d65134
commit 77fb3b0fa4

View File

@@ -22,6 +22,7 @@ import java.util.Random;
public class TRSRBakedModel implements IBakedModel {
protected final IBakedModel original;
protected TransformationMatrix transformation;
private final int faceOffset;
public TRSRBakedModel(IBakedModel original, float x, float y, float z, float scale) {
this(original, x, y, z, 0, 0, 0, scale, scale, scale);
@@ -38,6 +39,7 @@ public class TRSRBakedModel implements IBakedModel {
public TRSRBakedModel(IBakedModel original, TransformationMatrix transform) {
this.original = original;
this.transformation = transform;
this.faceOffset = 0;
}
public TRSRBakedModel(IBakedModel original, Direction facing) {
@@ -50,6 +52,7 @@ public class TRSRBakedModel implements IBakedModel {
double r = Math.PI * (360 - facing.getOpposite().getHorizontalIndex() * 90) / 180d;
this.transformation = new TransformationMatrix(translation, TransformationHelper.quatFromXYZ(new Vector3f(0, (float) r, 0), false), null, null);
this.faceOffset = 4 + Direction.NORTH.getHorizontalIndex() - facing.getHorizontalIndex();
}
@Nonnull
@@ -58,6 +61,10 @@ public class TRSRBakedModel implements IBakedModel {
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand) {
ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
if (side != null && side.getHorizontalIndex() > -1) {
side = Direction.byHorizontalIndex((side.getHorizontalIndex() + this.faceOffset) % 4);
}
for (BakedQuad quad : original.getQuads(state, side, rand)) {
BakedQuadBuilder builder = new BakedQuadBuilder(quad.getSprite());
TRSRTransformer transformer = new TRSRTransformer(builder, transformation.blockCenterToCorner());