Skip to content

Commit

Permalink
Render update count from EntityRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
OreCruncher committed Oct 27, 2019
1 parent 88de8c9 commit 23ea78d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Expand Up @@ -29,6 +29,7 @@
import org.orecruncher.dsurround.ModBase;
import org.orecruncher.dsurround.ModOptions;
import org.orecruncher.dsurround.client.handlers.EnvironStateHandler.EnvironState;
import org.orecruncher.lib.ReflectedField.IntegerField;

import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
Expand All @@ -45,10 +46,19 @@
@SideOnly(Side.CLIENT)
public final class RenderWeather extends IRenderHandler {


private static final IntegerField<EntityRenderer> rendererUpdateCount = new IntegerField<>(
EntityRenderer.class,
"rendererUpdateCount",
"field_78529_t"
);

public static int getRendererUpdateCount() {
return rendererUpdateCount.get(Minecraft.getMinecraft().entityRenderer);
}

private final StormRenderer stormRenderer;

public static int rendererUpdateCount = 0;

protected RenderWeather() {
this.stormRenderer = new StormRenderer();
}
Expand All @@ -60,7 +70,6 @@ protected RenderWeather() {
public static boolean addRainParticles(@Nonnull final EntityRenderer theThis) {
final World world = EnvironState.getWorld();
if (world != null && world.provider.getWeatherRenderer() instanceof RenderWeather) {
rendererUpdateCount++;
StormSplashRenderer.renderStormSplashes(EnvironState.getDimensionId(), theThis);
return true;
}
Expand Down
Expand Up @@ -140,7 +140,8 @@ public void render(@Nonnull final EntityRenderer renderer, final float partialTi
GlStateManager.alphaFunc(516, 0.1F);

final int range = mc.gameSettings.fancyGraphics ? 10 : 5;
final float f1 = RenderWeather.rendererUpdateCount + partialTicks;
final int renderCount = RenderWeather.getRendererUpdateCount();
final float f1 = renderCount + partialTicks;

GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

Expand Down Expand Up @@ -193,7 +194,7 @@ public void render(@Nonnull final EntityRenderer renderer, final float partialTi
setupForRender(props.getRainTexture());

// d8 makes the rain fall down. Assumes texture height of 512 pixels.
final double d5 = ((double) (RenderWeather.rendererUpdateCount + seed & 31) + (double) partialTicks)
final double d5 = ((double) (renderCount + seed & 31) + (double) partialTicks)
/ 32.0D * (3.0D + this.random.nextDouble());

final float alpha = ((1.0F - f3 * f3) * 0.5F + 0.5F) * alphaRatio;
Expand Down Expand Up @@ -224,7 +225,7 @@ public void render(@Nonnull final EntityRenderer renderer, final float partialTi
setupForRender(texture);

// d8 makes the snow fall down. Assumes texture height of 512 pixels.
final double d8 = ((RenderWeather.rendererUpdateCount & 511) + partialTicks) / 512.0F;
final double d8 = ((renderCount & 511) + partialTicks) / 512.0F;
// The 0.2F factor was originally 0.01F. It
// affects the horizontal movement of particles,
// which works well for dust.
Expand Down
Expand Up @@ -170,7 +170,7 @@ public void addRainParticles(final EntityRenderer theThis) {
if (rainStrengthFactor <= 0.0F)
return;

this.RANDOM.setSeed(RenderWeather.rendererUpdateCount * 312987231L);
this.RANDOM.setSeed(RenderWeather.getRendererUpdateCount() * 312987231L);
final Entity entity = mc.getRenderViewEntity();
final int playerX = MathHelper.floor(entity.posX);
final int playerY = MathHelper.floor(entity.posY);
Expand Down

0 comments on commit 23ea78d

Please sign in to comment.