Potential method to stop silver or gold dungeons from spawning next to each other?
This commit is contained in:
parent
178abaf1cd
commit
706bf2f132
|
@ -2,6 +2,7 @@ package com.legacy.aether.world.gen;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import com.legacy.aether.world.util.AetherRandomTracker;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -25,7 +26,8 @@ public class MapGenGoldenDungeon extends MapGenStructure {
|
|||
|
||||
@Override
|
||||
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
|
||||
int rand = this.rand.nextInt(180);
|
||||
AetherRandomTracker tracker = AetherRandomTracker.INSTANCE;
|
||||
int rand = tracker.testRandom(this.rand, 180);
|
||||
|
||||
if (rand != 0)
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.legacy.aether.world.gen;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import com.legacy.aether.world.util.AetherRandomTracker;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.MapGenStructure;
|
||||
|
@ -21,7 +22,8 @@ public class MapGenSilverDungeon extends MapGenStructure {
|
|||
|
||||
@Override
|
||||
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
|
||||
int rand = this.rand.nextInt(60);
|
||||
AetherRandomTracker tracker = AetherRandomTracker.INSTANCE;
|
||||
int rand = tracker.testRandom(this.rand, 60);
|
||||
|
||||
if (rand != 0)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.legacy.aether.world.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class AetherRandomTracker
|
||||
{
|
||||
public static AetherRandomTracker INSTANCE = new AetherRandomTracker();
|
||||
public int lastRand = -1;
|
||||
|
||||
public int testRandom(Random random, int bound)
|
||||
{
|
||||
int inputRandom = random.nextInt(bound);
|
||||
|
||||
if (inputRandom != this.lastRand)
|
||||
{
|
||||
return inputRandom;
|
||||
}
|
||||
else
|
||||
{
|
||||
testRandom(random, bound);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue