mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 02:45:13 -04:00
model rendering: make random seed on demand
This commit is contained in:
parent
b545d930f4
commit
4a469a9394
@ -30,8 +30,9 @@ class WeightedBlockRender(
|
||||
) : BlockRender {
|
||||
|
||||
|
||||
private fun getModel(random: Random?): BlockRender {
|
||||
private fun getModel(random: Random?, position: BlockPosition): BlockRender {
|
||||
if (random == null) return models.first().model
|
||||
random.setSeed(position.positionHash)
|
||||
|
||||
var weightLeft = abs(random.nextLong() % totalWeight)
|
||||
|
||||
@ -46,12 +47,11 @@ class WeightedBlockRender(
|
||||
}
|
||||
|
||||
override fun getParticleTexture(random: Random?, position: Vec3i): AbstractTexture? {
|
||||
random?.setSeed(position.positionHash)
|
||||
return getModel(random).getParticleTexture(random, position)
|
||||
return getModel(random, position).getParticleTexture(random, position)
|
||||
}
|
||||
|
||||
override fun render(position: BlockPosition, mesh: WorldMesh, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?): Boolean {
|
||||
return getModel(random).render(position, mesh, random, state, neighbours, light, tints)
|
||||
return getModel(random, position).render(position, mesh, random, state, neighbours, light, tints)
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,7 +32,6 @@ import de.bixilon.minosoft.data.world.chunk.chunk.Chunk
|
||||
import de.bixilon.minosoft.data.world.chunk.light.SectionLight
|
||||
import de.bixilon.minosoft.data.world.chunk.neighbours.ChunkNeighbours
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPositionUtil.positionHash
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender
|
||||
import de.bixilon.minosoft.gui.rendering.world.entities.BlockEntityRenderer
|
||||
@ -131,8 +130,6 @@ class SolidCullSectionPreparer(
|
||||
light[O_UP] = (light[O_UP].toInt() or 0xF0).toByte()
|
||||
}
|
||||
|
||||
random?.setSeed(position.positionHash)
|
||||
|
||||
val tints = tintColorCalculator.getAverageBlockTint(chunk, neighbourChunks, state, x, y, z)
|
||||
var rendered = model.render(position, mesh, random, state, neighbourBlocks, light, tints)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user