Java Code Examples for org.bukkit.World#getSeed()

The following examples show how to use org.bukkit.World#getSeed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BukkitQueue_1_10.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
    if (biome != null) {
        try {
            if (seed == null) {
                seed = world.getSeed();
            }
            nmsWorld.worldData.getSeed();
            boolean result;
            ChunkProviderGenerate generator = new ChunkProviderGenerate(nmsWorld, seed, false, "");
            Biome bukkitBiome = getAdapter().getBiome(biome.getId());
            BiomeBase base = BiomeBase.getBiome(biome.getId());
            fieldBiomes.set(generator, new BiomeBase[]{base});
            boolean cold = base.getTemperature() <= 1;
            net.minecraft.server.v1_10_R1.ChunkGenerator existingGenerator = nmsWorld.getChunkProviderServer().chunkGenerator;
            long existingSeed = world.getSeed();
            {
                if (genLayer == null) genLayer = new MutableGenLayer(seed);
                genLayer.set(biome.getId());
                Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager());
                Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager());
                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer);

                fieldSeed.set(nmsWorld.worldData, seed);

                ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new BiomeCache(this.nmsWorld.getWorldChunkManager()));

                ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), generator);

                keepLoaded.remove(MathMan.pairInt(x, z));
                result = getWorld().regenerateChunk(x, z);

                ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), existingGenerator);

                fieldSeed.set(nmsWorld.worldData, existingSeed);

                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2);
            }
            return result;
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return super.regenerateChunk(world, x, z, biome, seed);
}
 
Example 2
Source File: BukkitQueue17.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
    if (biome != null) {
        try {
            if (seed == null) {
                seed = world.getSeed();
            }
            nmsWorld.worldData.getSeed();
            boolean result;
            net.minecraft.server.v1_7_R4.ChunkProviderGenerate generator = new net.minecraft.server.v1_7_R4.ChunkProviderGenerate(nmsWorld, seed, false);
            Biome bukkitBiome = getAdapter().getBiome(biome.getId());
            net.minecraft.server.v1_7_R4.BiomeBase base = net.minecraft.server.v1_7_R4.BiomeBase.getBiome(biome.getId());
            fieldBiomes.set(generator, new net.minecraft.server.v1_7_R4.BiomeBase[]{base});
            net.minecraft.server.v1_7_R4.IChunkProvider existingGenerator = nmsWorld.chunkProviderServer.chunkProvider;
            long existingSeed = world.getSeed();
            {
                if (genLayer == null) genLayer = new com.boydti.fawe.bukkit.v1_7.MutableGenLayer(seed);
                genLayer.set(biome.getId());
                Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager());
                Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager());
                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer);

                fieldSeed.set(nmsWorld.worldData, seed);

                ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new net.minecraft.server.v1_7_R4.BiomeCache(this.nmsWorld.getWorldChunkManager()));

                nmsWorld.chunkProviderServer.chunkProvider = generator;

                keepLoaded.remove(MathMan.pairInt(x, z));
                result = getWorld().regenerateChunk(x, z);

                nmsWorld.chunkProviderServer.chunkProvider = existingGenerator;

                fieldSeed.set(nmsWorld.worldData, existingSeed);

                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2);
            }
            return result;
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return super.regenerateChunk(world, x, z, biome, seed);
}
 
Example 3
Source File: BukkitQueue18R3.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
    if (biome != null) {
        try {
            if (seed == null) {
                seed = world.getSeed();
            }
            nmsWorld.worldData.getSeed();
            boolean result;
            net.minecraft.server.v1_8_R3.ChunkProviderGenerate generator = new net.minecraft.server.v1_8_R3.ChunkProviderGenerate(nmsWorld, seed, false, "");
            Biome bukkitBiome = getAdapter().getBiome(biome.getId());
            net.minecraft.server.v1_8_R3.BiomeBase base = net.minecraft.server.v1_8_R3.BiomeBase.getBiome(biome.getId());
            fieldBiomes.set(generator, new net.minecraft.server.v1_8_R3.BiomeBase[]{base});
            IChunkProvider existingGenerator = nmsWorld.chunkProviderServer.chunkProvider;
            long existingSeed = world.getSeed();
            {
                if (genLayer == null) genLayer = new MutableGenLayer(seed);
                genLayer.set(biome.getId());
                Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager());
                Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager());
                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer);

                fieldSeed.set(nmsWorld.worldData, seed);

                ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new net.minecraft.server.v1_8_R3.BiomeCache(this.nmsWorld.getWorldChunkManager()));

                nmsWorld.chunkProviderServer.chunkProvider = generator;

                keepLoaded.remove(MathMan.pairInt(x, z));
                result = getWorld().regenerateChunk(x, z);

                nmsWorld.chunkProviderServer.chunkProvider = existingGenerator;

                fieldSeed.set(nmsWorld.worldData, existingSeed);

                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2);
            }
            return result;
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return super.regenerateChunk(world, x, z, biome, seed);
}
 
Example 4
Source File: BukkitQueue_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
    if (biome != null) {
        try {
            if (seed == null) {
                seed = world.getSeed();
            }
            nmsWorld.worldData.getSeed();
            boolean result;
            ChunkProviderGenerate generator = new ChunkProviderGenerate(nmsWorld, seed, false, "");
            Biome bukkitBiome = getAdapter().getBiome(biome.getId());
            BiomeBase base = BiomeBase.getBiome(biome.getId());
            fieldBiomes.set(generator, new BiomeBase[]{base});
            boolean cold = base.getTemperature() <= 1;
            net.minecraft.server.v1_12_R1.ChunkGenerator existingGenerator = nmsWorld.getChunkProviderServer().chunkGenerator;
            long existingSeed = world.getSeed();
            {
                if (genLayer == null) genLayer = new MutableGenLayer(seed);
                genLayer.set(biome.getId());
                Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager());
                Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager());
                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer);

                fieldSeed.set(nmsWorld.worldData, seed);

                ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new BiomeCache(this.nmsWorld.getWorldChunkManager()));

                ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), generator);

                keepLoaded.remove(MathMan.pairInt(x, z));
                result = getWorld().regenerateChunk(x, z);
                net.minecraft.server.v1_12_R1.Chunk nmsChunk = getCachedChunk(world, x, z);
                if (nmsChunk != null) {
                    nmsChunk.f(true); // Set Modified
                    nmsChunk.mustSave = true;
                }

                ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), existingGenerator);

                fieldSeed.set(nmsWorld.worldData, existingSeed);

                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2);
            }
            return result;
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return super.regenerateChunk(world, x, z, biome, seed);
}
 
Example 5
Source File: BukkitQueue_1_9_R1.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
    if (biome != null) {
        try {
            if (seed == null) {
                seed = world.getSeed();
            }
            nmsWorld.worldData.getSeed();
            boolean result;
            net.minecraft.server.v1_9_R2.ChunkProviderGenerate generator = new net.minecraft.server.v1_9_R2.ChunkProviderGenerate(nmsWorld, seed, false, "");
            Biome bukkitBiome = getAdapter().getBiome(biome.getId());
            net.minecraft.server.v1_9_R2.BiomeBase base = net.minecraft.server.v1_9_R2.BiomeBase.getBiome(biome.getId());
            fieldBiomes.set(generator, new net.minecraft.server.v1_9_R2.BiomeBase[]{base});
            net.minecraft.server.v1_9_R2.ChunkGenerator existingGenerator = nmsWorld.getChunkProviderServer().chunkGenerator;
            long existingSeed = world.getSeed();
            {
                if (genLayer == null) genLayer = new MutableGenLayer(seed);
                genLayer.set(biome.getId());
                Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager());
                Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager());
                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer);

                fieldSeed.set(nmsWorld.worldData, seed);

                ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new net.minecraft.server.v1_9_R2.BiomeCache(this.nmsWorld.getWorldChunkManager()));

                ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), generator);

                keepLoaded.remove(MathMan.pairInt(x, z));
                result = getWorld().regenerateChunk(x, z);

                ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), existingGenerator);

                fieldSeed.set(nmsWorld.worldData, existingSeed);

                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2);
            }
            return result;
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return super.regenerateChunk(world, x, z, biome, seed);
}
 
Example 6
Source File: BukkitQueue_1_11.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
    if (biome != null) {
        try {
            if (seed == null) {
                seed = world.getSeed();
            }
            nmsWorld.worldData.getSeed();
            boolean result;
            ChunkProviderGenerate generator = new ChunkProviderGenerate(nmsWorld, seed, false, "");
            Biome bukkitBiome = getAdapter().getBiome(biome.getId());
            BiomeBase base = BiomeBase.getBiome(biome.getId());
            fieldBiomes.set(generator, new BiomeBase[]{base});
            boolean cold = base.getTemperature() <= 1;
            net.minecraft.server.v1_11_R1.ChunkGenerator existingGenerator = nmsWorld.getChunkProviderServer().chunkGenerator;
            long existingSeed = world.getSeed();
            {
                if (genLayer == null) genLayer = new MutableGenLayer(seed);
                genLayer.set(biome.getId());
                Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager());
                Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager());
                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer);

                fieldSeed.set(nmsWorld.worldData, seed);

                ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new BiomeCache(this.nmsWorld.getWorldChunkManager()));

                ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), generator);

                keepLoaded.remove(MathMan.pairInt(x, z));
                result = getWorld().regenerateChunk(x, z);

                ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), existingGenerator);

                fieldSeed.set(nmsWorld.worldData, existingSeed);

                fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1);
                fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2);
            }
            return result;
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return super.regenerateChunk(world, x, z, biome, seed);
}
 
Example 7
Source File: StoneVariantPopulator.java    From Carbon with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public void createVein(World world, int size, int x, int y, int z) {
       Random random = new Random(world.getSeed());
       float f = random.nextFloat() * 3.141593F;
       double d1 = x + 8 + Math.sin(f) * size / 8.0F;
       double d2 = x + 8 - Math.sin(f) * size / 8.0F;
       double d3 = z + 8 + Math.cos(f) * size / 8.0F;
       double d4 = z + 8 - Math.cos(f) * size / 8.0F;
       double d5 = y + random.nextInt(3) - 2;
       double d6 = y + random.nextInt(3) - 2;
       for (int i = 0; i <= size; i++) {
           double d7 = d1 + (d2 - d1) * i / size;
           double d8 = d5 + (d6 - d5) * i / size;
           double d9 = d3 + (d4 - d3) * i / size;
           double d10 = random.nextDouble() * size / 16.0D;
           double d11 = (Math.sin(i * 3.141593F / size) + 1.0F) * d10 + 1.0D;
           double d12 = (Math.sin(i * 3.141593F / size) + 1.0F) * d10 + 1.0D;
           int j = (int) Math.floor(d7 - d11 / 2.0D);
           int k = (int) Math.floor(d8 - d12 / 2.0D);
           int m = (int) Math.floor(d9 - d11 / 2.0D);
           int n = (int) Math.floor(d7 + d11 / 2.0D);
           int i1 = (int) Math.floor(d8 + d12 / 2.0D);
           int i2 = (int) Math.floor(d9 + d11 / 2.0D);
           for (int i3 = j; i3 <= n; i3++) {
               double d13 = (i3 + 0.5D - d7) / (d11 / 2.0D);
               if (d13 * d13 < 1.0D) {
                   for (int i4 = k; i4 <= i1; i4++) {
                       double d14 = (i4 + 0.5D - d8) / (d12 / 2.0D);
                       if (d13 * d13 + d14 * d14 < 1.0D) {
                           for (int i5 = m; i5 <= i2; i5++) {
                               double d15 = (i5 + 0.5D - d9) / (d11 / 2.0D);
                               if ((d13 * d13 + d14 * d14 + d15 * d15 >= 1.0D) || (world.getBlockAt(i3, i4, i5).getType() != Material.STONE)) {
                                   continue;
                               }
                               world.getBlockAt(i3, i4, i5).setTypeIdAndData(blockType.getId(), data, true);
                           }
                       }
                   }
               }
           }
       }
   }
 
Example 8
Source File: CreateTreeCommand.java    From GiantTrees with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onCommand(final CommandSender sender, final Command command,
                         final String label, final String[] arg) {
  if (sender instanceof ConsoleCommandSender) {
    sender.sendMessage("Cannot create giant trees from the console");
    return true;
  }

  if (arg.length != 1) {
    // incorrect number of arguments
    return false;
  }

  final Player player = (Player) sender;
  if (player.hasPermission("gianttrees.create")) {
    final Chunk chunk = player.getLocation().getChunk();
    final World world = chunk.getWorld();
    final Random seed = new Random(world.getSeed());

    final String species = arg[0];
    final File treeFile = new File(this.plugin.getDataFolder(), species
                                                                + ".xml");
    final File rootFile = new File(this.plugin.getDataFolder(), species
                                                                + ".root.xml");

    if (!treeFile.exists()) {
      sender.sendMessage(ChatColor.RED + "Tree " + species
                         + " does not exist.");
      sender.sendMessage("Use \"/tree-edit " + species
                         + "\" from the server console to create it.");
      return true;
    }

    final Block highestSoil = this.getHighestSoil(player.getWorld()
                                                        .getHighestBlockAt(player.getLocation()));

    final Location base = highestSoil.getLocation();
    this.popup.sendPopup(player, "Stand back!");
    this.renderer.renderTreeWithHistory(base, treeFile, rootFile,
                                        seed.nextInt(), player, true);
  }
  return true;
}
 
Example 9
Source File: SimplexNoiseGenerator.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a seeded simplex noise generator for the given world
 *
 * @param world World to construct this generator for
 */
public SimplexNoiseGenerator(World world) {
    this(new Random(world.getSeed()));
}
 
Example 10
Source File: PerlinOctaveGenerator.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a perlin octave generator for the given world
 *
 * @param world   World to construct this generator for
 * @param octaves Amount of octaves to create
 */
public PerlinOctaveGenerator(World world, int octaves) {
    this(new Random(world.getSeed()), octaves);
}
 
Example 11
Source File: PerlinNoiseGenerator.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a seeded perlin noise generator for the given world
 *
 * @param world World to construct this generator for
 */
public PerlinNoiseGenerator(World world) {
    this(new Random(world.getSeed()));
}
 
Example 12
Source File: SimplexOctaveGenerator.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a simplex octave generator for the given world
 *
 * @param world   World to construct this generator for
 * @param octaves Amount of octaves to create
 */
public SimplexOctaveGenerator(World world, int octaves) {
    this(new Random(world.getSeed()), octaves);
}