Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Teleporter:
- -------------
- public class TeleporterEthia extends Teleporter
- {
- private final WorldServer worldServerInstance;
- public TeleporterEthia(WorldServer worldserver)
- {
- super(worldserver);
- this.worldServerInstance = worldserver;
- }
- public void placeInPortal(Entity entity, float rotationYaw)
- {
- int i = MathHelper.floor_double(entity.posX);
- int j = MathHelper.floor_double(entity.posY) - 1;
- int k = MathHelper.floor_double(entity.posZ);
- byte b0 = 1;
- byte b1 = 0;
- for (int l = -2; l <= 2; ++l)
- {
- for (int i1 = -2; i1 <= 2; ++i1)
- {
- for (int j1 = -1; j1 < 3; ++j1)
- {
- int k1 = i + i1 * b0 + l * b1;
- int l1 = j + j1;
- int i2 = k + i1 * b1 - l * b0;
- boolean flag = j1 < 0;
- this.worldServerInstance.setBlockState(new BlockPos(k1, l1, i2), flag ? Blocks.stonebrick.getDefaultState() :
- Blocks.air.getDefaultState());
- }
- }
- }
- entity.setLocationAndAngles((double) i, (double) j, (double) k, entity.rotationYaw, 0.0F);
- entity.motionX = entity.motionY = entity.motionZ = 0.0D;
- }
- }
- World Provider:
- ---------------
- public class WorldProviderEthia extends WorldProvider
- {
- public void registerWorldChunkManager()
- {
- this.worldChunkMgr = new WorldChunkManagerEthia(Ethia.skyWorld, 0.0F);
- this.dimensionId = Ethia.getEthiaDimensionId();
- }
- public IChunkProvider createChunkGenerator()
- {
- return new ChunkProviderEthia(this.worldObj, this.worldObj.getSeed());
- }
- public boolean isSurfaceWorld()
- {
- return false;
- }
- @SideOnly(Side.CLIENT)
- public float getCloudHeight()
- {
- return 8.0F;
- }
- public boolean canCoordinateBeSpawn(int x, int z)
- {
- return this.worldObj.getGroundAboveSeaLevel(new BlockPos(x, 0, z)).getMaterial().blocksMovement();
- }
- public BlockPos getSpawnCoordinate()
- {
- return new BlockPos(100, 50, 0);
- }
- public int getAverageGroundLevel()
- {
- return 40;
- }
- public boolean doesXZShowFog(int x, int z)
- {
- return true;
- }
- public String getDimensionName()
- {
- return "Ethia";
- }
- public String getInternalNameSuffix()
- {
- return "_ethia";
- }
- }
- Biome Decorator:
- ----------------
- public class BiomeEthiaDecorator extends BiomeDecorator
- {
- protected void genDecorations(BiomeGenBase biomegenbase)
- {
- WorldHelper.genOre(this.currentWorld, EthiaBlocks.floiar_ore, this.randomGenerator, 10, 0, 128);
- WorldHelper.genOre(this.currentWorld, EthiaBlocks.xantinum_ore, this.randomGenerator, 6, 0, 32);
- int i = this.treesPerChunk;
- if (this.randomGenerator.nextInt(10) == 0)
- {
- ++i;
- }
- for (int j = 0; j < i; ++j)
- {
- int chunkX = this.randomGenerator.nextInt(16) + 8;
- int chunkZ = this.randomGenerator.nextInt(16) + 8;
- WorldGenAbstractTree worldgenabstracttree = biomegenbase.genBigTreeChance(this.randomGenerator);
- worldgenabstracttree.func_175904_e();
- BlockPos blockpos = this.currentWorld.getHorizon(this.field_180294_c.add(chunkX, 0, chunkZ));
- if (worldgenabstracttree.generate(this.currentWorld, this.randomGenerator, blockpos))
- {
- worldgenabstracttree.func_180711_a(this.currentWorld, this.randomGenerator, blockpos);
- }
- }
- }
- }
- Biome Gen Base:
- ---------------
- public class BiomeGenEthia extends BiomeGenBase
- {
- public BiomeGenEthia(int id)
- {
- super(id);
- this.spawnableMonsterList.clear();
- this.spawnableCreatureList.clear();
- this.spawnableWaterCreatureList.clear();
- this.spawnableCaveCreatureList.clear();
- this.topBlock = Blocks.grass.getDefaultState();
- this.fillerBlock = Blocks.dirt.getDefaultState();
- this.theBiomeDecorator = new BiomeEthiaDecorator();
- }
- public WorldGenAbstractTree genBigTreeChance(Random rand)
- {
- return new WorldGenEthiaTree();
- }
- }
- World Chunk Manager:
- --------------------
- public class WorldChunkManagerEthia extends WorldChunkManager
- {
- private BiomeGenBase biomeGenerator;
- private float rainfall;
- public WorldChunkManagerEthia(BiomeGenBase biomeGen, float rainfall)
- {
- this.biomeGenerator = biomeGen;
- this.rainfall = rainfall;
- }
- public BiomeGenBase getBiomeGenerator(BlockPos blockpos)
- {
- return this.biomeGenerator;
- }
- public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase[] abiomegenbase, int x, int z, int width, int height)
- {
- if (abiomegenbase == null || abiomegenbase.length < width * height)
- {
- abiomegenbase = new BiomeGenBase[width * height];
- }
- Arrays.fill(abiomegenbase, 0, width * height, this.biomeGenerator);
- return abiomegenbase;
- }
- public float[] getRainfall(float[] listToReuse, int x, int z, int width, int length)
- {
- if (listToReuse == null || listToReuse.length < width * length)
- {
- listToReuse = new float[width * length];
- }
- Arrays.fill(listToReuse, 0, width * length, this.rainfall);
- return listToReuse;
- }
- public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] oldBiomeList, int x, int z, int width, int depth)
- {
- if (oldBiomeList == null || oldBiomeList.length < width * depth)
- {
- oldBiomeList = new BiomeGenBase[width * depth];
- }
- Arrays.fill(oldBiomeList, 0, width * depth, this.biomeGenerator);
- return oldBiomeList;
- }
- public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] listToReuse, int x, int z, int width, int length, boolean cacheFlag)
- {
- return this.loadBlockGeneratorData(listToReuse, x, z, width, length);
- }
- public BlockPos findBiomePosition(int x, int z, int range, List biomes, Random random)
- {
- return biomes.contains(this.biomeGenerator) ? new BlockPos(x - range + random.nextInt(range * 2 + 1), 0, z - range +
- random.nextInt(range * 2 + 1)) : null;
- }
- public boolean areBiomesViable(int x, int z, int range, List biomes)
- {
- return biomes.contains(this.biomeGenerator);
- }
- }
- Chunk Provider:
- ---------------
- public class ChunkProviderEthia implements IChunkProvider
- {
- private Random ethiaRNG;
- private NoiseGeneratorOctaves noiseGen1;
- private NoiseGeneratorOctaves noiseGen2;
- private NoiseGeneratorOctaves noiseGen3;
- public NoiseGeneratorOctaves noiseGen4;
- public NoiseGeneratorOctaves noiseGen5;
- private World ethiaWorld;
- private double[] densities;
- private BiomeGenBase[] biomesForGeneration;
- double[] noiseData1;
- double[] noiseData2;
- double[] noiseData3;
- double[] noiseData4;
- double[] noiseData5;
- public ChunkProviderEthia(World world, long seed)
- {
- this.ethiaWorld = world;
- this.ethiaRNG = new Random(seed);
- this.noiseGen1 = new NoiseGeneratorOctaves(this.ethiaRNG, 16);
- this.noiseGen2 = new NoiseGeneratorOctaves(this.ethiaRNG, 16);
- this.noiseGen3 = new NoiseGeneratorOctaves(this.ethiaRNG, 8);
- this.noiseGen4 = new NoiseGeneratorOctaves(this.ethiaRNG, 10);
- this.noiseGen5 = new NoiseGeneratorOctaves(this.ethiaRNG, 16);
- }
- public void func_180520_a(int x, int z, ChunkPrimer chunkprimer)
- {
- byte b0 = 2;
- int k = b0 + 1;
- byte b1 = 33;
- int l = b0 + 1;
- this.densities = this.initializeNoiseField(this.densities, x * b0, 0, z * b0, k, b1, l);
- for (int i1 = 0; i1 < b0; ++i1)
- {
- for (int j1 = 0; j1 < b0; ++j1)
- {
- for (int k1 = 0; k1 < 32; ++k1)
- {
- double d0 = 0.25D;
- double d1 = this.densities[((i1 + 0) * l + j1 + 0) * b1 + k1 + 0];
- double d2 = this.densities[((i1 + 0) * l + j1 + 1) * b1 + k1 + 0];
- double d3 = this.densities[((i1 + 1) * l + j1 + 0) * b1 + k1 + 0];
- double d4 = this.densities[((i1 + 1) * l + j1 + 1) * b1 + k1 + 0];
- double d5 = (this.densities[((i1 + 0) * l + j1 + 0) * b1 + k1 + 1] - d1) * d0;
- double d6 = (this.densities[((i1 + 0) * l + j1 + 1) * b1 + k1 + 1] - d2) * d0;
- double d7 = (this.densities[((i1 + 1) * l + j1 + 0) * b1 + k1 + 1] - d3) * d0;
- double d8 = (this.densities[((i1 + 1) * l + j1 + 1) * b1 + k1 + 1] - d4) * d0;
- for (int l1 = 0; l1 < 4; ++l1)
- {
- double d9 = 0.125D;
- double d10 = d1;
- double d11 = d2;
- double d12 = (d3 - d1) * d9;
- double d13 = (d4 - d2) * d9;
- for (int i2 = 0; i2 < 8; ++i2)
- {
- double d14 = 0.125D;
- double d15 = d10;
- double d16 = (d11 - d10) * d14;
- for (int j2 = 0; j2 < 8; ++j2)
- {
- IBlockState iblockstate = null;
- if (d15 > 0.0D)
- {
- iblockstate = Blocks.grass.getDefaultState();
- }
- int k2 = i2 + i1 * 8;
- int l2 = l1 + k1 * 4;
- int i3 = j2 + j1 * 8;
- chunkprimer.setBlockState(k2, l2, i3, iblockstate);
- }
- d10 += d12;
- d11 += d13;
- }
- d1 += d5;
- d2 += d6;
- d3 += d7;
- d4 += d8;
- }
- }
- }
- }
- }
- public void func_180519_a(ChunkPrimer chunkprimer)
- {
- for (int i = 0; i < 16; ++i)
- {
- for (int j = 0; j < 16; ++j)
- {
- byte b0 = 1;
- int k = -1;
- IBlockState iblockstate = Blocks.grass.getDefaultState();
- IBlockState iblockstate1 = Blocks.dirt.getDefaultState();
- for (int l = 127; l >= 0; --l)
- {
- IBlockState iblockstate2 = chunkprimer.getBlockState(i, l, j);
- if (iblockstate2.getBlock().getMaterial() == Material.air)
- {
- k = -1;
- }
- else if (iblockstate2.getBlock() == Blocks.stone)
- {
- if (k == -1)
- {
- if (b0 <= 0)
- {
- iblockstate = Blocks.air.getDefaultState();
- iblockstate1 = Blocks.grass.getDefaultState();
- }
- k = b0;
- if (l >= 0)
- {
- chunkprimer.setBlockState(i, l, j, iblockstate);
- }
- else
- {
- chunkprimer.setBlockState(i, l, j, iblockstate1);
- }
- }
- else if (k > 0)
- {
- --k;
- chunkprimer.setBlockState(i, l, j, iblockstate1);
- }
- }
- }
- }
- }
- }
- public Chunk provideChunk(int x, int z)
- {
- this.ethiaRNG.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
- ChunkPrimer chunkprimer = new ChunkPrimer();
- this.biomesForGeneration = this.ethiaWorld.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z *
- 16, 16, 16);
- this.func_180520_a(x, z, chunkprimer);
- this.func_180519_a(chunkprimer);
- Chunk chunk = new Chunk(this.ethiaWorld, chunkprimer, x, z);
- byte[] abyte = chunk.getBiomeArray();
- for (int k = 0; k < abyte.length; ++k)
- {
- abyte[k] = (byte) this.biomesForGeneration[k].biomeID;
- }
- chunk.generateSkylightMap();
- return chunk;
- }
- private double[] initializeNoiseField(double[] densities, int x, int y, int z, int xSize, int ySize, int zSize)
- {
- if (densities == null)
- {
- densities = new double[xSize * ySize * zSize];
- }
- double d0 = 684.412D;
- double d1 = 684.412D;
- this.noiseData4 = this.noiseGen4.generateNoiseOctaves(this.noiseData4, x, z, xSize, zSize, 1.121D, 1.121D, 0.5D);
- this.noiseData5 = this.noiseGen5.generateNoiseOctaves(this.noiseData5, x, z, xSize, zSize, 200.0D, 200.0D, 0.5D);
- d0 *= 2.0D;
- this.noiseData1 = this.noiseGen3.generateNoiseOctaves(this.noiseData1, x, y, z, xSize, ySize, zSize, d0 / 80.0D, d1 / 160.0D,
- d0 / 80.0D);
- this.noiseData2 = this.noiseGen1.generateNoiseOctaves(this.noiseData2, x, y, z, xSize, ySize, zSize, d0, d1, d0);
- this.noiseData3 = this.noiseGen2.generateNoiseOctaves(this.noiseData3, x, y, z, xSize, ySize, zSize, d0, d1, d0);
- int k1 = 0;
- for (int l1 = 0; l1 < xSize; ++l1)
- {
- for (int i2 = 0; i2 < zSize; ++i2)
- {
- float f = (float) (l1 + xSize) / 1.0F;
- float f1 = (float) (i2 + zSize) / 1.0F;
- float f2 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * 8.0F;
- if (f2 > 80.0F)
- {
- f2 = 80.0F;
- }
- if (f2 < -100.0F)
- {
- f2 = -100.0F;
- }
- for (int j2 = 0; j2 < ySize; ++j2)
- {
- double d2 = 0.0D;
- double d3 = this.noiseData2[k1] / 512.0D;
- double d4 = this.noiseData3[k1] / 512.0D;
- double d5 = (this.noiseData1[k1] / 10.0D + 1.0D) / 2.0D;
- if (d5 < 0.0D)
- {
- d2 = d3;
- }
- else if (d5 > 1.0D)
- {
- d2 = d4;
- }
- else
- {
- d2 = d3 + (d4 - d3) * d5;
- }
- d2 -= 8.0D;
- d2 += (double) f2;
- byte b0 = 2;
- double d6;
- if (j2 > ySize / 2 - b0)
- {
- d6 = (double) ((float) (j2 - (ySize / 2 - b0)) / 64.0F);
- d6 = MathHelper.clamp_double(d6, 0.0D, 1.0D);
- d2 = d2 * (1.0D - d6) + -3000.0D * d6;
- }
- b0 = 8;
- if (j2 < b0)
- {
- d6 = (double) ((float) (b0 - j2) / ((float) b0 - 1.0F));
- d2 = d2 * (1.0D - d6) + -30.0D * d6;
- }
- densities[k1] = d2;
- ++k1;
- }
- }
- }
- return densities;
- }
- public boolean chunkExists(int x, int z)
- {
- return true;
- }
- public void populate(IChunkProvider ichunkprovider, int x, int z)
- {
- BlockFalling.fallInstantly = true;
- BlockPos blockpos = new BlockPos(x * 16, 0, z * 16);
- this.ethiaWorld.getBiomeGenForCoords(blockpos.add(16, 0, 16)).decorate(this.ethiaWorld, this.ethiaRNG, blockpos);
- BlockFalling.fallInstantly = false;
- }
- public boolean func_177460_a(IChunkProvider ichunkprovider, Chunk chunk, int x, int z)
- {
- return false;
- }
- public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate)
- {
- return true;
- }
- public void saveExtraData() {}
- public boolean unloadQueuedChunks()
- {
- return false;
- }
- public boolean canSave()
- {
- return true;
- }
- public String makeString()
- {
- return "RandomLevelSource";
- }
- public List func_177458_a(EnumCreatureType enumcreaturetype, BlockPos blockpos)
- {
- return this.ethiaWorld.getBiomeGenForCoords(blockpos).getSpawnableList(enumcreaturetype);
- }
- public BlockPos getStrongholdGen(World world, String s, BlockPos blockpos)
- {
- return null;
- }
- public int getLoadedChunkCount()
- {
- return 0;
- }
- public void recreateStructures(Chunk chunk, int x, int z) {}
- public Chunk provideChunk(BlockPos blockpos)
- {
- return this.provideChunk(blockpos.getX() >> 4, blockpos.getZ() >> 4);
- }
- }
- World Gen Tree:
- ---------------
- public class WorldGenEthiaTree extends WorldGenAbstractTree
- {
- public WorldGenEthiaTree()
- {
- super(false);
- }
- public boolean generate(World world, Random rand, BlockPos pos)
- {
- Block block = world.getBlockState(pos).getBlock();
- int branches = 3 + rand.nextInt(6);
- int h = 1;
- block.onPlantGrow(world, new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()), pos);
- for (int i = 0; i < branches; ++i)
- {
- for (int x1 = pos.getX() - 1; x1 <= pos.getX() + 1; ++x1)
- {
- int x2 = pos.getX() - x1;
- for (int z1 = pos.getZ() - 1; z1 <= pos.getZ() + 1; ++z1)
- {
- this.setBlock(world, new BlockPos(x1, pos.getY() + h + 1, z1), EthiaBlocks.ethiroot_leaves, 0);
- }
- }
- for (int x1 = pos.getX() - 2; x1 <= pos.getX() + 2; ++x1)
- {
- int x2 = pos.getX() - x1;
- for (int z1 = pos.getZ() - 2; z1 <= pos.getZ() + 2; ++z1)
- {
- int z2 = pos.getZ() - z1;
- if (!(Math.abs(x2) == 2 && Math.abs(z2) == 2) && !(Math.abs(x2) == 2 && Math.abs(z2) == 1) && !(Math.abs(x2) == 1
- && Math.abs(z2) == 2) && !(Math.abs(x2) == 1 && Math.abs(z2) == 1))
- {
- this.setBlock(world, new BlockPos(x1, pos.getY() + h, z1), EthiaBlocks.ethiroot_leaves, world.rand.nextInt(10)
- == 0 ? 1 : 0);
- }
- }
- }
- h += 2;
- }
- for (int x = pos.getX() - 2; x <= pos.getX() + 2; ++x)
- {
- int x1 = pos.getX() - x;
- for (int y = pos.getY() + h; y <= pos.getY() + h + 2; ++y)
- {
- int y1 = pos.getY() + h - y;
- for (int z = pos.getZ() - 2; z <= pos.getZ() + 2; ++z)
- {
- int z1 = pos.getZ() - z;
- if (y1 == 0)
- {
- if (!(Math.abs(x1) == 2 && Math.abs(z1) == 2) && !(Math.abs(x1) == 2 && Math.abs(z1) == 1) && !(Math.abs(x1) ==
- 1 && Math.abs(z1) == 2) && !(Math.abs(x1) == 1 && Math.abs(z1) == 1))
- {
- this.setBlock(world, new BlockPos(x, y, z), EthiaBlocks.ethiroot_leaves, world.rand.nextInt(10) == 0 ? 1 :
- 0);
- }
- }
- else
- {
- if (x1 == 0 && z1 == 0)
- {
- this.setBlock(world, new BlockPos(x, y, z), EthiaBlocks.ethiroot_leaves, 0);
- }
- }
- }
- }
- }
- for (int y1 = 0; y1 <= h; ++ y1)
- {
- this.setBlock(world, new BlockPos(pos.getX(), pos.getY() + y1, pos.getZ()), EthiaBlocks.ethiroot_log, 0);
- }
- return true;
- }
- private void setBlock(World world, BlockPos pos, Block block, int meta)
- {
- this.func_175905_a(world, pos, block, meta);
- }
- }
- Main Class Methods:
- -------------------
- public static final BiomeGenBase skyWorld = (new BiomeGenEthia(120)).setColor(318792131).setBiomeName("Ethia").setDisableRain();
- @EventHandler
- public void init(FMLInitializationEvent event)
- {
- DimensionManager.registerProviderType(getEthiaDimensionId(), WorldProviderEthia.class, false);
- DimensionManager.registerDimension(getEthiaDimensionId(), getEthiaDimensionId());
- }
- public static int getEthiaDimensionId()
- {
- return 2;
- }
Add Comment
Please, Sign In to add comment