Skip to content

Commit e0aaa31

Browse files
committed
fix: prevent nextInt when soundInterval = 0
fixes #80 | This was actually fixed upstream with micdoodle8#3639 in 2019
1 parent ba90ca6 commit e0aaa31

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

src/main/java/micdoodle8/mods/galacticraft/core/TransformerHooks.java

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,19 @@
7474
import org.lwjgl.opengl.GL11;
7575

7676
/**
77-
* These methods are called from vanilla minecraft through bytecode injection
78-
* done in MicdoodleCore
79-
*
80-
* See https://github.com/micdoodle8/MicdoodleCore
77+
* These methods are called from vanilla minecraft through bytecode injection done in MicdoodleCore See https://github.com/micdoodle8/MicdoodleCore
8178
*/
8279
public class TransformerHooks
8380
{
8481

85-
private static List<IWorldGenerator> otherModGeneratorsWhitelist = new LinkedList<>();
86-
private static IWorldGenerator generatorTCAuraNodes = null;
87-
private static Method generateTCAuraNodes = null;
88-
private static boolean generatorsInitialised = false;
89-
public static List<Block> spawnListAE2_GC = new LinkedList<>();
90-
public static ThreadLocal<BufferBuilder> renderBuilder = new ThreadLocal<>();
91-
private static int rainSoundCounter = 0;
92-
private static Random random = new Random();
82+
private static List<IWorldGenerator> otherModGeneratorsWhitelist = new LinkedList<>();
83+
private static IWorldGenerator generatorTCAuraNodes = null;
84+
private static Method generateTCAuraNodes = null;
85+
private static boolean generatorsInitialised = false;
86+
public static List<Block> spawnListAE2_GC = new LinkedList<>();
87+
public static ThreadLocal<BufferBuilder> renderBuilder = new ThreadLocal<>();
88+
private static int rainSoundCounter = 0;
89+
private static Random random = new Random();
9390

9491
public static double getGravityForEntity(Entity entity)
9592
{
@@ -299,8 +296,7 @@ private static void addWorldGenForName(String logString, String name)
299296
}
300297

301298
/*
302-
* Used to supplement the hard-coded blocklist in AE2's MeteoritePlacer
303-
* class
299+
* Used to supplement the hard-coded blocklist in AE2's MeteoritePlacer class
304300
*/
305301
public static boolean addAE2MeteorSpawn(Object o, Block b)
306302
{
@@ -378,8 +374,7 @@ public static Vec3d getFogColorHook(World world)
378374
public static Vec3d getSkyColorHook(World world)
379375
{
380376
EntityPlayerSP player = FMLClientHandler.instance().getClient().player;
381-
if (world.provider.getSkyRenderer() instanceof SkyProviderOverworld
382-
|| (player != null && player.posY > Constants.OVERWORLD_CLOUD_HEIGHT && player.getRidingEntity() instanceof EntitySpaceshipBase))
377+
if (world.provider.getSkyRenderer() instanceof SkyProviderOverworld || (player != null && player.posY > Constants.OVERWORLD_CLOUD_HEIGHT && player.getRidingEntity() instanceof EntitySpaceshipBase))
383378
{
384379
float f1 = world.getCelestialAngle(1.0F);
385380
float f2 = MathHelper.cos(f1 * Constants.twoPI) * 2.0F + 0.5F;
@@ -399,9 +394,9 @@ public static Vec3d getSkyColorHook(World world)
399394
int k = MathHelper.floor(player.posZ);
400395
BlockPos pos = new BlockPos(i, j, k);
401396
int l = ForgeHooksClient.getSkyBlendColour(world, pos);
402-
float f4 = (float) (l >> 16 & 255) / 255.0F;
403-
float f5 = (float) (l >> 8 & 255) / 255.0F;
404-
float f6 = (float) (l & 255) / 255.0F;
397+
float f4 = (l >> 16 & 255) / 255.0F;
398+
float f5 = (l >> 8 & 255) / 255.0F;
399+
float f6 = (l & 255) / 255.0F;
405400
f4 *= f2;
406401
f5 *= f2;
407402
f6 *= f2;
@@ -508,13 +503,11 @@ public static void orientCamera(float partialTicks)
508503
GL11.glRotatef(yaw * gDir.getYawGravityY(), 0.0F, 1.0F, 0.0F);
509504
GL11.glRotatef(yaw * gDir.getYawGravityZ(), 0.0F, 0.0F, 1.0F);
510505

511-
512506
GL11.glTranslatef(eyeHeightChange * gDir.getEyeVecX(), eyeHeightChange * gDir.getEyeVecY(), eyeHeightChange * gDir.getEyeVecZ());
513507

514508
if (stats.getGravityTurnRate() < 1.0F)
515509
{
516-
GL11.glRotatef(90.0F * (stats.getGravityTurnRatePrev() + (stats.getGravityTurnRate() - stats.getGravityTurnRatePrev()) * partialTicks), stats.getGravityTurnVecX(),
517-
stats.getGravityTurnVecY(), stats.getGravityTurnVecZ());
510+
GL11.glRotatef(90.0F * (stats.getGravityTurnRatePrev() + (stats.getGravityTurnRate() - stats.getGravityTurnRatePrev()) * partialTicks), stats.getGravityTurnVecX(), stats.getGravityTurnVecY(), stats.getGravityTurnVecZ());
518511
}
519512
}
520513
}
@@ -633,7 +626,7 @@ public static int addRainParticles(int result, int rendererUpdateCount, float f)
633626
}
634627
IWeatherProvider moddedProvider = ((IWeatherProvider) world.provider);
635628

636-
random.setSeed((long) rendererUpdateCount * 312987231L);
629+
random.setSeed(rendererUpdateCount * 312987231L);
637630
Entity entity = mc.getRenderViewEntity();
638631
BlockPos blockpos = new BlockPos(entity);
639632
int i = 10;
@@ -692,7 +685,15 @@ public static int addRainParticles(int result, int rendererUpdateCount, float f)
692685
}
693686
}
694687

695-
if (j > 0 && random.nextInt(moddedProvider.getSoundInterval(f)) < rainSoundCounter++)
688+
if (moddedProvider.getSoundInterval(f) > 0)
689+
{
690+
if (j > 0 && random.nextInt(moddedProvider.getSoundInterval(f)) < rainSoundCounter++)
691+
{
692+
rainSoundCounter = 0;
693+
694+
moddedProvider.weatherSounds(j, mc, world, blockpos, xx, yy, zz, random);
695+
}
696+
} else if (j > 0 && 0 < rainSoundCounter++)
696697
{
697698
rainSoundCounter = 0;
698699

0 commit comments

Comments
 (0)