| 1 | package net.minecraft.world.gen.structure;
|
| 2 |
|
| 3 | import com.google.common.collect.Lists;
|
| 4 | import java.util.Arrays;
|
| 5 | import java.util.List;
|
| 6 | import java.util.Map;
|
| 7 | import java.util.Random;
|
| 8 | import java.util.Map.Entry;
|
| 9 | import net.minecraft.entity.monster.EntityWitch;
|
| 10 | import net.minecraft.util.BlockPos;
|
| 11 | import net.minecraft.util.MathHelper;
|
| 12 | import net.minecraft.world.World;
|
| 13 | import net.minecraft.world.biome.BiomeGenBase;
|
| 14 |
|
| 15 | public class MapGenScatteredFeature extends MapGenStructure
|
| 16 | {
|
| 17 | private static final List<BiomeGenBase> biomelist = Arrays.<BiomeGenBase>asList(new BiomeGenBase[] {BiomeGenBase.desert, BiomeGenBase.desertHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills, BiomeGenBase.swampland});
|
| 18 | private List<BiomeGenBase.SpawnListEntry> scatteredFeatureSpawnList;
|
| 19 |
|
| 20 | /** the maximum distance between scattered features */
|
| 21 | private int maxDistanceBetweenScatteredFeatures;
|
| 22 |
|
| 23 | /** the minimum distance between scattered features */
|
| 24 | private int minDistanceBetweenScatteredFeatures;
|
| 25 |
|
| 26 | public MapGenScatteredFeature()
|
| 27 | {
|
| 28 | this.scatteredFeatureSpawnList = Lists.<BiomeGenBase.SpawnListEntry>newArrayList();
|
| 29 | this.maxDistanceBetweenScatteredFeatures = 32;
|
| 30 | this.minDistanceBetweenScatteredFeatures = 8;
|
| 31 | this.scatteredFeatureSpawnList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 1, 1, 1));
|
| 32 | }
|
| 33 |
|
| 34 | public MapGenScatteredFeature(Map<String, String> p_i2061_1_)
|
| 35 | {
|
| 36 | this();
|
| 37 |
|
| 38 | for (Entry<String, String> entry : p_i2061_1_.entrySet())
|
| 39 | {
|
| 40 | if (((String)entry.getKey()).equals("distance"))
|
| 41 | {
|
| 42 | this.maxDistanceBetweenScatteredFeatures = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.maxDistanceBetweenScatteredFeatures, this.minDistanceBetweenScatteredFeatures + 1);
|
| 43 | }
|
| 44 | }
|
| 45 | }
|
| 46 |
|
| 47 | public String getStructureName()
|
| 48 | {
|
| 49 | return "Temple";
|
| 50 | }
|
| 51 |
|
| 52 | protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ)
|
| 53 | {
|
| 54 | int i = chunkX;
|
| 55 | int j = chunkZ;
|
| 56 |
|
| 57 | if (chunkX < 0)
|
| 58 | {
|
| 59 | chunkX -= this.maxDistanceBetweenScatteredFeatures - 1;
|
| 60 | }
|
| 61 |
|
| 62 | if (chunkZ < 0)
|
| 63 | {
|
| 64 | chunkZ -= this.maxDistanceBetweenScatteredFeatures - 1;
|
| 65 | }
|
| 66 |
|
| 67 | int k = chunkX / this.maxDistanceBetweenScatteredFeatures;
|
| 68 | int l = chunkZ / this.maxDistanceBetweenScatteredFeatures;
|
| 69 | Random random = this.worldObj.setRandomSeed(k, l, 14357617);
|
| 70 | k = k * this.maxDistanceBetweenScatteredFeatures;
|
| 71 | l = l * this.maxDistanceBetweenScatteredFeatures;
|
| 72 | k = k + random.nextInt(this.maxDistanceBetweenScatteredFeatures - this.minDistanceBetweenScatteredFeatures);
|
| 73 | l = l + random.nextInt(this.maxDistanceBetweenScatteredFeatures - this.minDistanceBetweenScatteredFeatures);
|
| 74 |
|
| 75 | if (i == k && j == l)
|
| 76 | {
|
| 77 | BiomeGenBase biomegenbase = this.worldObj.getWorldChunkManager().getBiomeGenerator(new BlockPos(i * 16 + 8, 0, j * 16 + 8));
|
| 78 |
|
| 79 | if (biomegenbase == null)
|
| 80 | {
|
| 81 | return false;
|
| 82 | }
|
| 83 |
|
| 84 | for (BiomeGenBase biomegenbase1 : biomelist)
|
| 85 | {
|
| 86 | if (biomegenbase == biomegenbase1)
|
| 87 | {
|
| 88 | return true;
|
| 89 | }
|
| 90 | }
|
| 91 | }
|
| 92 |
|
| 93 | return false;
|
| 94 | }
|
| 95 |
|
| 96 | protected StructureStart getStructureStart(int chunkX, int chunkZ)
|
| 97 | {
|
| 98 | return new MapGenScatteredFeature.Start(this.worldObj, this.rand, chunkX, chunkZ);
|
| 99 | }
|
| 100 |
|
| 101 | public boolean func_175798_a(BlockPos p_175798_1_)
|
| 102 | {
|
| 103 | StructureStart structurestart = this.func_175797_c(p_175798_1_);
|
| 104 |
|
| 105 | if (structurestart != null && structurestart instanceof MapGenScatteredFeature.Start && !structurestart.components.isEmpty())
|
| 106 | {
|
| 107 | StructureComponent structurecomponent = (StructureComponent)structurestart.components.getFirst();
|
| 108 | return structurecomponent instanceof ComponentScatteredFeaturePieces.SwampHut;
|
| 109 | }
|
| 110 | else
|
| 111 | {
|
| 112 | return false;
|
| 113 | }
|
| 114 | }
|
| 115 |
|
| 116 | public List<BiomeGenBase.SpawnListEntry> getScatteredFeatureSpawnList()
|
| 117 | {
|
| 118 | return this.scatteredFeatureSpawnList;
|
| 119 | }
|
| 120 |
|
| 121 | public static class Start extends StructureStart
|
| 122 | {
|
| 123 | public Start()
|
| 124 | {
|
| 125 | }
|
| 126 |
|
| 127 | public Start(World worldIn, Random p_i2060_2_, int p_i2060_3_, int p_i2060_4_)
|
| 128 | {
|
| 129 | super(p_i2060_3_, p_i2060_4_);
|
| 130 | BiomeGenBase biomegenbase = worldIn.getBiomeGenForCoords(new BlockPos(p_i2060_3_ * 16 + 8, 0, p_i2060_4_ * 16 + 8));
|
| 131 |
|
| 132 | if (biomegenbase != BiomeGenBase.jungle && biomegenbase != BiomeGenBase.jungleHills)
|
| 133 | {
|
| 134 | if (biomegenbase == BiomeGenBase.swampland)
|
| 135 | {
|
| 136 | ComponentScatteredFeaturePieces.SwampHut componentscatteredfeaturepieces$swamphut = new ComponentScatteredFeaturePieces.SwampHut(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16);
|
| 137 | this.components.add(componentscatteredfeaturepieces$swamphut);
|
| 138 | }
|
| 139 | else if (biomegenbase == BiomeGenBase.desert || biomegenbase == BiomeGenBase.desertHills)
|
| 140 | {
|
| 141 | ComponentScatteredFeaturePieces.DesertPyramid componentscatteredfeaturepieces$desertpyramid = new ComponentScatteredFeaturePieces.DesertPyramid(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16);
|
| 142 | this.components.add(componentscatteredfeaturepieces$desertpyramid);
|
| 143 | }
|
| 144 | }
|
| 145 | else
|
| 146 | {
|
| 147 | ComponentScatteredFeaturePieces.JunglePyramid componentscatteredfeaturepieces$junglepyramid = new ComponentScatteredFeaturePieces.JunglePyramid(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16);
|
| 148 | this.components.add(componentscatteredfeaturepieces$junglepyramid);
|
| 149 | }
|
| 150 |
|
| 151 | this.updateBoundingBox();
|
| 152 | }
|
| 153 | }
|
| 154 | }
|
| 155 |
|