Skip to content

Commit efd21d8

Browse files
committed
simplification of code
1 parent a8ae338 commit efd21d8

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/main/java/dev/propulsionteam/propulsionsimulated/content/thruster/MeshedThrusterFlameUtils.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ public static void renderMeshFlame(AbstractThrusterBlockEntity be, float partial
103103
ms.translate(offsetX, offsetY, offsetZ);
104104

105105

106-
float r = random01( //Randomness of the flame to prevent flames next to each other from looking the same
107-
(pos.getX() + offsetX) * 73856093L ^ (pos.getY() + offsetY) * 19349663L ^ (pos.getZ() + offsetZ) * 83492791L);
106+
float r = random01(hash(pos.getX(), pos.getY(), pos.getZ())); //Randomness of the flame to prevent flames next to each other from looking the same
108107
float shaderTime = r + (be.getLevel().getGameTime() + partialTicks) * 0.1f;
109108
shader.getUniformSafe("FlameRenderTime").setFloat(shaderTime);
110109
shader.getUniformSafe("Intensity").setFloat(Mth.clamp(power * 2f - .35f, 0.25f, 1.5f));
@@ -142,8 +141,7 @@ public static void renderMeshVectorFlame(AbstractThrusterBlockEntity be, float p
142141
var widthMultiplier = snapToFlamePixel((power * 1.5f + 1));
143142

144143
ms.mulPose(Axis.YP.rotation(getBillboardAngleV2(be, pos, ms, partialTicks)));
145-
float r = random01( //Randomness of the flame to prevent flames next to each other from looking the same
146-
(pos.getX()) * 73856093L ^ (pos.getY()) * 19349663L ^ (pos.getZ()) * 83492791L);
144+
float r = random01(hash(pos.getX(), pos.getY(), pos.getZ()));
147145
float shaderTime = r + (be.getLevel().getGameTime() + partialTicks) * 0.1f;
148146
shader.getUniformSafe("FlameRenderTime").setFloat(shaderTime);
149147
shader.getUniformSafe("Intensity").setFloat(Mth.clamp(power * 2f - .35f, 0.25f, 1.5f));
@@ -156,7 +154,12 @@ public static void renderMeshVectorFlame(AbstractThrusterBlockEntity be, float p
156154
}
157155
}
158156

159-
private static float random01(long seed) {
157+
/**
158+
* return a random float between 0 and 1 based on the seed
159+
* @param seed
160+
* @return
161+
*/
162+
private static float random01(int seed) {
160163
long z = seed + 0x9E3779B97F4A7C15L;
161164
z = (z ^ (z >>> 30)) * 0xBF58476D1CE4E5B9L;
162165
z = (z ^ (z >>> 27)) * 0x94D049BB133111EBL;

0 commit comments

Comments
 (0)