Skip to content

Commit

Permalink
Use deterministic random for feedthrough model
Browse files Browse the repository at this point in the history
This should make the icon generation stable again.
  • Loading branch information
malte0811 committed Sep 15, 2024
1 parent 756902c commit bf4b471
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ public SpecificFeedthroughModel(FeedthroughCacheKey key, Int2IntFunction colorMu

private void init(FeedthroughCacheKey k, Int2IntFunction colorMultiplierBasic)
{
RandomSource random = RandomSource.create(0);
BakedModel model = mc().getBlockRenderer().getBlockModelShaper()
.getBlockModel(k.baseState);
if(colorMultiplierBasic==null)
Expand All @@ -345,7 +346,7 @@ private void init(FeedthroughCacheKey k, Int2IntFunction colorMultiplierBasic)
k.specificColorMultipliers.put(i, ret);
return ret;
};
boolean renderBlockInLayer = k.layer==null||model.getRenderTypes(k.baseState, RANDOM_SOURCE, ModelData.EMPTY).contains(k.layer);
boolean renderBlockInLayer = k.layer==null||model.getRenderTypes(k.baseState, random, ModelData.EMPTY).contains(k.layer);
for(int j = 0; j < 7; j++)
{
Direction side = j < 6?DirectionUtils.VALUES[j]: null;
Expand All @@ -356,7 +357,7 @@ private void init(FeedthroughCacheKey k, Int2IntFunction colorMultiplierBasic)
if(renderBlockInLayer)
{
List<BakedQuad> modelQuads = model.getQuads(
k.baseState, side, RANDOM_SOURCE, ModelData.EMPTY, k.layer
k.baseState, side, random, ModelData.EMPTY, k.layer
);
quads.add(QuadTransformer.color(colorMultiplier).process(modelQuads));
}
Expand All @@ -365,20 +366,20 @@ private void init(FeedthroughCacheKey k, Int2IntFunction colorMultiplierBasic)
facing = facing.getOpposite();
case -1:
if(k.layer==RenderType.solid())
quads.add(getConnQuads(facing, side, k.type, new Matrix4(), k.layer));
quads.add(getConnQuads(facing, side, k.type, new Matrix4(), k.layer, random));
break;
case Integer.MAX_VALUE:
Matrix4 mat = new Matrix4();
mat.translate(0, 0, 1);
List<BakedQuad> all = new ArrayList<>(getConnQuads(facing, side, k.type, mat, k.layer));
List<BakedQuad> all = new ArrayList<>(getConnQuads(facing, side, k.type, mat, k.layer, random));
mat = new Matrix4();
mat.translate(0, 0, -1);
all.addAll(getConnQuads(facing.getOpposite(), side, k.type, mat, k.layer));
all.addAll(getConnQuads(facing.getOpposite(), side, k.type, mat, k.layer, random));
if(renderBlockInLayer)
{
var tintTransformer = QuadTransformer.color(colorMultiplier);
all.addAll(tintTransformer.process(
model.getQuads(k.baseState, side, RANDOM_SOURCE, ModelData.EMPTY, k.layer)
model.getQuads(k.baseState, side, random, ModelData.EMPTY, k.layer)
));
}
quads.add(all);
Expand All @@ -390,7 +391,7 @@ private void init(FeedthroughCacheKey k, Int2IntFunction colorMultiplierBasic)
}

private List<BakedQuad> getConnQuads(
Direction facing, Direction side, WireType type, Matrix4 mat, RenderType layer
Direction facing, Direction side, WireType type, Matrix4 mat, RenderType layer, RandomSource source
)
{
//connector model+feedthrough border
Expand All @@ -410,7 +411,7 @@ private List<BakedQuad> getConnQuads(
mat.translate(-.5, -.5, -.5);
BakedModel model = mc().getBlockRenderer().getBlockModelShaper()
.getBlockModel(info.connector().setValue(IEProperties.FACING_ALL, Direction.DOWN));
List<BakedQuad> conn = new ArrayList<>(model.getQuads(null, side, RANDOM_SOURCE, ModelData.EMPTY, layer));
List<BakedQuad> conn = new ArrayList<>(model.getQuads(null, side, source, ModelData.EMPTY, layer));
if(side==facing)
conn.add(ModelUtils.createBakedQuad(
vertices, Direction.UP, getTexture(info), info.uvs(), WHITE, false
Expand Down

0 comments on commit bf4b471

Please sign in to comment.