mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Total Recull
- Set cullfaces to correct sides; made model implementation less brittle (?)
This commit is contained in:
parent
2d37efe5bd
commit
7ef487fa46
3 changed files with 48 additions and 42 deletions
|
@ -44,7 +44,7 @@ public class DisplayClothModel extends BakedModelWrapperWithData {
|
|||
public static void reload() {
|
||||
CORNERS.clear();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean useAmbientOcclusion() {
|
||||
return false;
|
||||
|
@ -52,34 +52,40 @@ public class DisplayClothModel extends BakedModelWrapperWithData {
|
|||
|
||||
private List<BakedQuad> getCorner(DisplayClothBlock block, int corner, @NotNull RandomSource rand,
|
||||
@Nullable RenderType renderType) {
|
||||
|
||||
List<List<BakedQuad>> corners = CORNERS.computeIfAbsent(block, b -> {
|
||||
if (!CORNERS.containsKey(block)) {
|
||||
TextureAtlasSprite targetSprite = getParticleIcon(ModelData.EMPTY);
|
||||
List<List<BakedQuad>> list = new ArrayList<>();
|
||||
|
||||
for (PartialModel pm : List.of(AllPartialModels.DISPLAY_CLOTH_SW, AllPartialModels.DISPLAY_CLOTH_NW,
|
||||
AllPartialModels.DISPLAY_CLOTH_NE, AllPartialModels.DISPLAY_CLOTH_SE)) {
|
||||
List<BakedQuad> quads = new ArrayList<>();
|
||||
AllPartialModels.DISPLAY_CLOTH_NE, AllPartialModels.DISPLAY_CLOTH_SE))
|
||||
list.add(getCornerQuads(rand, renderType, targetSprite, pm));
|
||||
|
||||
for (BakedQuad quad : pm.get()
|
||||
.getQuads(null, null, rand, ModelData.EMPTY, renderType)) {
|
||||
TextureAtlasSprite original = quad.getSprite();
|
||||
BakedQuad newQuad = BakedQuadHelper.clone(quad);
|
||||
int[] vertexData = newQuad.getVertices();
|
||||
for (int vertex = 0; vertex < 4; vertex++) {
|
||||
BakedQuadHelper.setU(vertexData, vertex, targetSprite.getU(
|
||||
SpriteShiftEntry.getUnInterpolatedU(original, BakedQuadHelper.getU(vertexData, vertex))));
|
||||
BakedQuadHelper.setV(vertexData, vertex, targetSprite.getV(
|
||||
SpriteShiftEntry.getUnInterpolatedV(original, BakedQuadHelper.getV(vertexData, vertex))));
|
||||
}
|
||||
quads.add(newQuad);
|
||||
}
|
||||
list.add(quads);
|
||||
CORNERS.put(block, list);
|
||||
}
|
||||
|
||||
return CORNERS.get(block)
|
||||
.get(corner);
|
||||
}
|
||||
|
||||
private List<BakedQuad> getCornerQuads(RandomSource rand, RenderType renderType, TextureAtlasSprite targetSprite,
|
||||
PartialModel pm) {
|
||||
List<BakedQuad> quads = new ArrayList<>();
|
||||
|
||||
for (BakedQuad quad : pm.get()
|
||||
.getQuads(null, null, rand, ModelData.EMPTY, renderType)) {
|
||||
TextureAtlasSprite original = quad.getSprite();
|
||||
BakedQuad newQuad = BakedQuadHelper.clone(quad);
|
||||
int[] vertexData = newQuad.getVertices();
|
||||
for (int vertex = 0; vertex < 4; vertex++) {
|
||||
BakedQuadHelper.setU(vertexData, vertex, targetSprite
|
||||
.getU(SpriteShiftEntry.getUnInterpolatedU(original, BakedQuadHelper.getU(vertexData, vertex))));
|
||||
BakedQuadHelper.setV(vertexData, vertex, targetSprite
|
||||
.getV(SpriteShiftEntry.getUnInterpolatedV(original, BakedQuadHelper.getV(vertexData, vertex))));
|
||||
}
|
||||
return list;
|
||||
});
|
||||
quads.add(newQuad);
|
||||
}
|
||||
|
||||
return corners.get(corner);
|
||||
return quads;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"parent": "block/block",
|
||||
"textures": {
|
||||
"0": "create:block/display_cloth/red",
|
||||
"particle": "create:block/display_cloth/red"
|
||||
"particle": "#0"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
|
@ -43,11 +43,11 @@
|
|||
"to": [16, 1, 0.1],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"east": {"uv": [11.45, 9, 12, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"south": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"west": {"uv": [12, 9, 11.45, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"up": {"uv": [0, 8.45, 8, 9], "rotation": 180, "texture": "#0", "cullface": "west"}
|
||||
"north": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "north"},
|
||||
"east": {"uv": [11.45, 9, 12, 14.5], "texture": "#0", "cullface": "north"},
|
||||
"south": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "north"},
|
||||
"west": {"uv": [12, 9, 11.45, 14.5], "texture": "#0", "cullface": "north"},
|
||||
"up": {"uv": [0, 8.45, 8, 9], "rotation": 180, "texture": "#0", "cullface": "north"}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -55,7 +55,7 @@
|
|||
"to": [16, -8, 0.1],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"down": {"uv": [0, 15.5, 8, 16], "texture": "#0", "cullface": "west"}
|
||||
"down": {"uv": [0, 15.5, 8, 16], "texture": "#0", "cullface": "north"}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -63,11 +63,11 @@
|
|||
"to": [17, 1, 16],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"north": {"uv": [12, 9, 11.45, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"east": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"south": {"uv": [11.45, 9, 12, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"west": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"up": {"uv": [0, 8.45, 8, 9], "rotation": 270, "texture": "#0", "cullface": "west"}
|
||||
"north": {"uv": [12, 9, 11.45, 14.5], "texture": "#0", "cullface": "east"},
|
||||
"east": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "east"},
|
||||
"south": {"uv": [11.45, 9, 12, 14.5], "texture": "#0", "cullface": "east"},
|
||||
"west": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "east"},
|
||||
"up": {"uv": [0, 8.45, 8, 9], "rotation": 270, "texture": "#0", "cullface": "east"}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -75,7 +75,7 @@
|
|||
"to": [17, -8, 16],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"down": {"uv": [0, 15.5, 8, 16], "rotation": 270, "texture": "#0", "cullface": "west"}
|
||||
"down": {"uv": [0, 15.5, 8, 16], "rotation": 270, "texture": "#0", "cullface": "east"}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -83,11 +83,11 @@
|
|||
"to": [16, 1, 17],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"east": {"uv": [12, 9, 11.45, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"south": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"west": {"uv": [11.45, 9, 12, 14.5], "texture": "#0", "cullface": "west"},
|
||||
"up": {"uv": [0, 8.45, 8, 9], "texture": "#0", "cullface": "west"}
|
||||
"north": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "south"},
|
||||
"east": {"uv": [12, 9, 11.45, 14.5], "texture": "#0", "cullface": "south"},
|
||||
"south": {"uv": [0, 9, 8, 14.5], "texture": "#0", "cullface": "south"},
|
||||
"west": {"uv": [11.45, 9, 12, 14.5], "texture": "#0", "cullface": "south"},
|
||||
"up": {"uv": [0, 8.45, 8, 9], "texture": "#0", "cullface": "south"}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -95,7 +95,7 @@
|
|||
"to": [16, -8, 17],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"down": {"uv": [0, 15.5, 8, 16], "rotation": 180, "texture": "#0", "cullface": "west"}
|
||||
"down": {"uv": [0, 15.5, 8, 16], "rotation": 180, "texture": "#0", "cullface": "south"}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"parent": "block/block",
|
||||
"textures": {
|
||||
"0": "create:block/display_cloth/red",
|
||||
"particle": "create:block/display_cloth/red"
|
||||
"particle": "#0"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue