Skip to content

Commit

Permalink
Update to Minecraft 1.17 world gen.
Browse files Browse the repository at this point in the history
Biomes are made by default now.
  • Loading branch information
tastybento committed Dec 14, 2021
1 parent f0dd4ee commit f9189e6
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 227 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
<!-- Non-minecraft related dependencies -->
<powermock.version>2.0.2</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.17.1-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.17.1</bentobox.version>
<spigot.version>1.18.1-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.18.0-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.17.0</build.version>
<build.version>1.18.0</build.version>
<!-- SonarCloud -->
<sonar.projectKey>BentoBoxWorld_SkyGrid</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down
18 changes: 0 additions & 18 deletions src/main/java/world/bentobox/skygrid/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ public class Settings implements WorldSettings {
private boolean makeEndPortals = false;

/* SkyGrid */
@ConfigComment("Biomes - this will affect some block types and tree types.")
@ConfigEntry(path = "world.create-biomes")
private boolean createBiomes = true;

@ConfigComment("The probability of a frame being created in a chunk. Frames are always at y=0.")
@ConfigEntry(path = "world.end-frame-probability")
private double endFrameProb = 0.1;
Expand Down Expand Up @@ -479,20 +475,6 @@ public void setEndBlocks(Map<Material, Integer> endBlocks) {
this.endBlocks = endBlocks;
}

/**
* @return the createBiomes
*/
public boolean isCreateBiomes() {
return createBiomes;
}

/**
* @param createBiomes the createBiomes to set
*/
public void setCreateBiomes(boolean createBiomes) {
this.createBiomes = createBiomes;
}

/**
* @return the endFrameProb
*/
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/world/bentobox/skygrid/SkyGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.generator.ChunkGenerator;
import org.eclipse.jdt.annotation.NonNull;

Expand Down Expand Up @@ -90,24 +89,21 @@ public void createWorlds() {
getLogger().info("Creating SkyGrid world ...");
}
// Create the world if it does not exist
islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(gen)
.createWorld();
islandWorld = WorldCreator.name(worldName).environment(World.Environment.NORMAL).generator(gen).createWorld();

// Make the nether if it does not exist
if (settings.isNetherGenerate()) {
if (getServer().getWorld(worldName + NETHER) == null) {
log("Creating SkyGrid's Nether...");
}
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(gen)
.environment(World.Environment.NETHER).createWorld();
netherWorld = WorldCreator.name(worldName + NETHER).generator(gen).environment(World.Environment.NETHER).createWorld();
}
// Make the end if it does not exist
if (settings.isEndGenerate()) {
if (getServer().getWorld(worldName + THE_END) == null) {
log("Creating SkyGrid's End World...");
}
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(gen)
.environment(World.Environment.THE_END).createWorld();
endWorld = WorldCreator.name(worldName + THE_END).generator(gen).environment(World.Environment.THE_END).createWorld();
}
}

Expand Down

This file was deleted.

116 changes: 0 additions & 116 deletions src/main/java/world/bentobox/skygrid/generators/Biomes.java

This file was deleted.

33 changes: 6 additions & 27 deletions src/main/java/world/bentobox/skygrid/generators/SkyGridGen.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
package world.bentobox.skygrid.generators;

import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.generator.WorldInfo;

import world.bentobox.skygrid.SkyGrid;

public class SkyGridGen extends ChunkGenerator {

private final SkyGrid addon;

private final Map<Environment, BiomeGenerator> biomeGenerator;

private final BlockPopulator populator;

private final SkyGridChunks preMade;
Expand All @@ -32,30 +28,14 @@ public SkyGridGen(SkyGrid addon) {
this.addon = addon;
this.populator = new SkyGridPop(addon);
preMade = new SkyGridChunks(addon);
biomeGenerator = new EnumMap<>(Environment.class);
}

@Override
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, ChunkGenerator.BiomeGrid biomeGrid) {
// The chunk we are making
ChunkData result = createChunkData(world);
preMade.getSkyGridChunk(world.getEnvironment()).forEach(b -> result.setBlock(b.getX(), b.getY(), b.getZ(), b.getBd()));
// Set biome
if (addon.getSettings().isCreateBiomes()) {
for (int x = 0; x < 16; x +=4) {
for (int z = 0; z < 16; z +=4) {
int realX = x + chunkX * 16; //used so that the noise function gives us
int realZ = z + chunkZ * 16; //different values each chunk
Biome b = biomeGenerator.computeIfAbsent(world.getEnvironment(), k -> new BiomeGenerator(world)).getDominantBiome(realX, realZ);
for (int y = 0; y < world.getMaxHeight(); y+=4) {
biomeGrid.setBiome(x, y, z, b);
}
}
}
}
return result;
}
public void generateNoise(WorldInfo worldInfo, Random r, int x, int z, ChunkData result) {
result.setRegion(0, worldInfo.getMinHeight(), 0, 16, worldInfo.getMaxHeight(), 16, Material.AIR);
preMade.getSkyGridChunk(worldInfo.getEnvironment()).forEach(b -> result.setBlock(b.getX(), b.getY(), b.getZ(), b.getBd()));

}

@Override
public List<BlockPopulator> getDefaultPopulators(World world) {
Expand All @@ -68,5 +48,4 @@ public Location getFixedSpawnLocation(World world, Random random) {
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ private void setSaplingType(Block b) {
break;
case SWAMP:
break;
case DESERT, DESERT_HILLS:
case DESERT:
b.setType(Material.DEAD_BUSH, false);
break;
break;
case SAVANNA:
b.setType(Material.ACACIA_SAPLING, false); // Acacia
break;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: ${version}${build.number}
metrics: true
repository: "BentoBoxWorld/SkyGrid"
icon: "COBWEB"
api-version: 1.14
api-version: 1.17

authors: tastybento

Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,6 @@ world:
# when player enters the end world.
# Added since 1.16.
create-obsidian-platform: false
# Biomes - this will affect some block types and tree types.
create-biomes: true
# The probability of a frame being created in a chunk. Frames are always at y=0.
end-frame-probability: 0.1
# Friendly name for this world. Used in admin commands. Must be a single word
Expand Down

0 comments on commit f9189e6

Please sign in to comment.