Another spawnrate related test.

This commit is contained in:
bconlon 2020-07-19 14:06:25 -07:00
parent 7c864ee5b7
commit ae4025a6f0
4 changed files with 40 additions and 6 deletions

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
import com.legacy.aether.world.util.RandomTracker;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@ -45,9 +46,11 @@ public class BronzeDungeon extends AetherDungeon {
return false;
}
if (random.nextInt(40) != 0)
RandomTracker randomTracker = new RandomTracker();
if (randomTracker.testRandom(random,40) != 0)
{
if (random.nextInt(60) != 0)
if (randomTracker.testRandom(random,60) != 0)
{
return false;
}

View file

@ -2,6 +2,7 @@ package com.legacy.aether.world.gen;
import java.util.Random;
import com.legacy.aether.world.util.RandomTracker;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
@ -24,9 +25,11 @@ public class MapGenGoldenDungeon extends MapGenStructure {
@Override
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
if (this.rand.nextInt(140) != 0)
RandomTracker randomTracker = new RandomTracker();
if (randomTracker.testRandom(this.rand,140) != 0)
{
if (this.rand.nextInt(180) != 0)
if (randomTracker.testRandom(this.rand,180) != 0)
{
return false;
}

View file

@ -2,6 +2,7 @@ package com.legacy.aether.world.gen;
import java.util.Random;
import com.legacy.aether.world.util.RandomTracker;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.MapGenStructure;
@ -21,9 +22,11 @@ public class MapGenSilverDungeon extends MapGenStructure {
@Override
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
if (this.rand.nextInt(80) != 0)
RandomTracker randomTracker = new RandomTracker();
if (randomTracker.testRandom(this.rand, 80) != 0)
{
if (this.rand.nextInt(120) != 0)
if (randomTracker.testRandom(this.rand, 120) != 0)
{
return false;
}

View file

@ -0,0 +1,25 @@
package com.legacy.aether.world.util;
import java.util.Random;
public class RandomTracker
{
public int lastRand = -1;
public int testRandom(Random random, int bound)
{
int inputRandom = random.nextInt(bound);
if (inputRandom != this.lastRand)
{
this.lastRand = inputRandom;
return inputRandom;
}
else
{
testRandom(random, bound);
}
return -1;
}
}