mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Fixed some structure gen bugs
This commit is contained in:
parent
f72a80be54
commit
11076b2d38
4 changed files with 133 additions and 23 deletions
|
@ -19,7 +19,7 @@ public class GroundDungeon extends TemplateBasedFeature {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GroundDungeon(Random rand, int x, int z) {
|
public GroundDungeon(Random rand, int x, int z) {
|
||||||
super(rand, x, 0, z, 7, 5, 8);
|
super(rand, x, 64, z, 7, 5, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.minelittlepony.unicopia.world;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
import net.minecraft.world.gen.structure.MapGenStructure;
|
||||||
|
|
||||||
|
public abstract class AbstractFeaturesGen extends MapGenStructure {
|
||||||
|
|
||||||
|
protected int maxDistance;
|
||||||
|
|
||||||
|
protected int minDistance;
|
||||||
|
|
||||||
|
public AbstractFeaturesGen(int min, int max) {
|
||||||
|
maxDistance = max;
|
||||||
|
minDistance = min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractFeaturesGen(Map<String, String> properties) {
|
||||||
|
for (Entry<String, String> entry : properties.entrySet()) {
|
||||||
|
if (entry.getKey().equals("distance")) {
|
||||||
|
maxDistance = MathHelper.getInt(entry.getValue(), maxDistance, 9);
|
||||||
|
}
|
||||||
|
if (entry.getKey().equals("MinDistance")) {
|
||||||
|
minDistance = MathHelper.getInt(entry.getValue(), minDistance, 9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract int getRandomSeed();
|
||||||
|
|
||||||
|
protected abstract boolean canSpawnInBiome(@Nonnull Biome biome);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
|
||||||
|
int i = chunkX;
|
||||||
|
int j = chunkZ;
|
||||||
|
|
||||||
|
if (chunkX < 0) {
|
||||||
|
chunkX -= maxDistance - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chunkZ < 0) {
|
||||||
|
chunkZ -= maxDistance - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int k = chunkX / maxDistance;
|
||||||
|
int l = chunkZ / maxDistance;
|
||||||
|
Random random = world.setRandomSeed(k, l, getRandomSeed());
|
||||||
|
|
||||||
|
k = k * maxDistance;
|
||||||
|
l = l * maxDistance;
|
||||||
|
k = k + random.nextInt(maxDistance - 8);
|
||||||
|
l = l + random.nextInt(maxDistance - 8);
|
||||||
|
|
||||||
|
if (i == k && j == l) {
|
||||||
|
Biome biome = world.getBiomeProvider().getBiome(new BlockPos(i * 16 + 8, 0, j * 16 + 8));
|
||||||
|
|
||||||
|
return biome != null && canSpawnInBiome(biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPos getNearestStructurePos(World world, BlockPos pos, boolean findUnexplored) {
|
||||||
|
this.world = world;
|
||||||
|
return findNearestStructurePosBySpacing(world, this, pos, maxDistance, 8, getRandomSeed(), false, 100, findUnexplored);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,27 +1,48 @@
|
||||||
package com.minelittlepony.unicopia.world;
|
package com.minelittlepony.unicopia.world;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.structure.AbstractFeature;
|
import com.minelittlepony.unicopia.structure.AbstractFeature;
|
||||||
import com.minelittlepony.unicopia.structure.CloudDungeon;
|
import com.minelittlepony.unicopia.structure.CloudDungeon;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.init.Biomes;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.gen.structure.MapGenScatteredFeature;
|
|
||||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
|
||||||
import net.minecraft.world.gen.structure.StructureStart;
|
import net.minecraft.world.gen.structure.StructureStart;
|
||||||
|
|
||||||
public class CloudGen extends MapGenScatteredFeature {
|
public class CloudGen extends AbstractFeaturesGen {
|
||||||
|
|
||||||
|
private static final List<Biome> BIOMELIST = Arrays.<Biome>asList(
|
||||||
|
Biomes.OCEAN,
|
||||||
|
Biomes.MESA,
|
||||||
|
Biomes.DESERT, Biomes.DESERT_HILLS,
|
||||||
|
Biomes.JUNGLE, Biomes.JUNGLE_HILLS,
|
||||||
|
Biomes.SWAMPLAND,
|
||||||
|
Biomes.ICE_PLAINS, Biomes.COLD_TAIGA
|
||||||
|
);
|
||||||
|
|
||||||
|
public CloudGen() {
|
||||||
|
super(8, 32);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStructureName() {
|
public String getStructureName() {
|
||||||
return "unicopia:clouds";
|
return "unicopia:clouds";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSwampHut(BlockPos pos) {
|
protected int getRandomSeed() {
|
||||||
return false;
|
return 143592;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canSpawnInBiome(@Nonnull Biome biome) {
|
||||||
|
return BIOMELIST.contains(biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,10 +68,6 @@ public class CloudGen extends MapGenScatteredFeature {
|
||||||
protected void addComponents(World world, Random rand, int x, int z, Biome biome) {
|
protected void addComponents(World world, Random rand, int x, int z, Biome biome) {
|
||||||
components.add(new CloudDungeon(rand, x * 16, z * 16));
|
components.add(new CloudDungeon(rand, x * 16, z * 16));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStructure(World world, Random rand, StructureBoundingBox bounds) {
|
|
||||||
super.generateStructure(world, rand, bounds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,34 @@
|
||||||
package com.minelittlepony.unicopia.world;
|
package com.minelittlepony.unicopia.world;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.structure.AbstractFeature;
|
import com.minelittlepony.unicopia.structure.AbstractFeature;
|
||||||
import com.minelittlepony.unicopia.structure.GroundDungeon;
|
import com.minelittlepony.unicopia.structure.GroundDungeon;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.init.Biomes;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.gen.structure.MapGenScatteredFeature;
|
|
||||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
|
||||||
import net.minecraft.world.gen.structure.StructureStart;
|
import net.minecraft.world.gen.structure.StructureStart;
|
||||||
|
|
||||||
public class StructuresGen extends MapGenScatteredFeature {
|
public class StructuresGen extends AbstractFeaturesGen {
|
||||||
|
|
||||||
|
private static final List<Biome> BIOMELIST = Arrays.<Biome>asList(
|
||||||
|
Biomes.TAIGA,
|
||||||
|
Biomes.TAIGA_HILLS,
|
||||||
|
Biomes.EXTREME_HILLS_WITH_TREES,
|
||||||
|
Biomes.COLD_TAIGA,
|
||||||
|
Biomes.COLD_TAIGA_HILLS,
|
||||||
|
Biomes.MUTATED_TAIGA,
|
||||||
|
Biomes.MUTATED_TAIGA_COLD,
|
||||||
|
Biomes.MUTATED_EXTREME_HILLS_WITH_TREES,
|
||||||
|
Biomes.ROOFED_FOREST
|
||||||
|
);
|
||||||
|
|
||||||
|
public StructuresGen() {
|
||||||
|
super(8, 16);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStructureName() {
|
public String getStructureName() {
|
||||||
|
@ -20,8 +36,13 @@ public class StructuresGen extends MapGenScatteredFeature {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSwampHut(BlockPos pos) {
|
protected int getRandomSeed() {
|
||||||
return false;
|
return 39548;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canSpawnInBiome(Biome biome) {
|
||||||
|
return BIOMELIST.contains(biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,10 +63,5 @@ public class StructuresGen extends MapGenScatteredFeature {
|
||||||
protected void addComponents(World world, Random rand, int x, int z, Biome biome) {
|
protected void addComponents(World world, Random rand, int x, int z, Biome biome) {
|
||||||
components.add(new GroundDungeon(rand, x * 16, z * 16));
|
components.add(new GroundDungeon(rand, x * 16, z * 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStructure(World world, Random rand, StructureBoundingBox bounds) {
|
|
||||||
super.generateStructure(world, rand, bounds);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue