Skip to content

Commit d353605

Browse files
committed
update WorldGen API
1 parent 36a33f3 commit d353605

17 files changed

+720
-251
lines changed

src/main/java/org/spongepowered/api/world/WorldType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.spongepowered.api.service.context.ContextSource;
4040
import org.spongepowered.api.util.MinecraftDayTime;
4141
import org.spongepowered.api.util.annotation.CatalogedBy;
42-
import org.spongepowered.api.world.biome.BiomeSampler;
4342
import org.spongepowered.api.world.portal.PortalType;
4443
import org.spongepowered.api.world.portal.PortalTypes;
4544
import org.spongepowered.api.world.server.ServerLocation;

src/main/java/org/spongepowered/api/world/WorldTypeTemplate.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.spongepowered.api.util.CopyableBuilder;
3131
import org.spongepowered.api.util.MinecraftDayTime;
3232
import org.spongepowered.api.util.ResourceKeyedBuilder;
33-
import org.spongepowered.api.world.biome.BiomeSampler;
3433

3534
import java.util.Optional;
3635

src/main/java/org/spongepowered/api/world/biome/BiomeAttributes.java

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,57 @@
2525
package org.spongepowered.api.world.biome;
2626

2727
import org.spongepowered.api.Sponge;
28+
import org.spongepowered.api.util.Range;
2829

30+
/**
31+
* Attributes with which biomes are picked for during world generation.
32+
*/
2933
public interface BiomeAttributes {
3034

31-
static BiomeAttributes of(final float temperature, final float humidity, final float altitude, final float weirdness, final float offset) {
32-
return Sponge.game().factoryProvider().provide(Factory.class).of(temperature, humidity, altitude, weirdness, offset);
35+
static BiomeAttributes of(final float temperature, final float humidity, final float continentalness, final float erosion, final float depth, final float weirdness, final float offset) {
36+
return Sponge.game().factoryProvider().provide(Factory.class).of(temperature, humidity, continentalness, erosion, depth, weirdness, offset);
3337
}
3438

3539
/**
36-
* Gets the temperature.
40+
* The temperature range.
3741
*
3842
* <p>In Vanilla Minecraft, this is capped between {@code -2} to {@code 2}.</p>
3943
*
4044
* @return temperature
4145
*/
42-
float temperature();
46+
Range<Float> temperature();
4347

4448
/**
45-
* Get the humidity.
49+
* The humidity range.
4650
*
4751
* <p>In Vanilla Minecraft, this is capped between {@code -2} to {@code 2}.</p>
4852
*
4953
* @return humidity
5054
*/
51-
float humidity();
55+
Range<Float> humidity();
5256

5357
/**
54-
* Gets the altitude.
58+
* The continentalness.
59+
* <p>Higher value when more inland. For low values oceans may generate.</p>
5560
*
56-
* <p>In Vanilla Minecraft, this is capped between {@code -2} to {@code 2}.</p>
61+
* @return continentalness
62+
*/
63+
Range<Float> continentalness();
64+
65+
/**
66+
* The erosion.
67+
* <p>Higher values result in flatter areas, low values result in mountainous areas.</p>
68+
*
69+
* @return erosion
70+
*/
71+
Range<Float> erosion();
72+
73+
/**
74+
* The depth.
5775
*
58-
* @return altitude
76+
* @return the depth.
5977
*/
60-
float altitude();
78+
Range<Float> depth();
6179

6280
/**
6381
* Gets the weirdness.
@@ -66,10 +84,10 @@ static BiomeAttributes of(final float temperature, final float humidity, final f
6684
*
6785
* @return weirdness
6886
*/
69-
float weirdness();
87+
Range<Float> weirdness();
7088

7189
/**
72-
* Gets the offset.
90+
* The offset.
7391
*
7492
* <p>In Vanilla Minecraft, this is capped between {@code 0} to {@code 1}.</p>
7593
*
@@ -79,6 +97,6 @@ static BiomeAttributes of(final float temperature, final float humidity, final f
7997

8098
interface Factory {
8199

82-
BiomeAttributes of(float temperature, float humidity, float altitude, float weirdness, float offset);
100+
BiomeAttributes of(float temperature, float humidity, float continentalness, float erosion, float depth, float weirdness, float offset);
83101
}
84102
}

src/main/java/org/spongepowered/api/world/biome/BiomeSampler.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/main/java/org/spongepowered/api/world/biome/provider/BiomeProvider.java

Lines changed: 111 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,60 +33,162 @@
3333
import java.util.Objects;
3434
import java.util.Set;
3535

36+
/**
37+
* Provides available Biomes for world generation.
38+
*/
3639
public interface BiomeProvider extends BiomeFinder {
3740

38-
static <T extends LayeredBiomeConfig> ConfigurableBiomeProvider<T> layered(final T config) {
39-
return Sponge.game().factoryProvider().provide(Factory.class).layered(config);
40-
}
41-
42-
static ConfigurableBiomeProvider<LayeredBiomeConfig> overworld() {
41+
/**
42+
* Returns the vanilla overworld biome provider.
43+
*
44+
* @return the vanilla overworld biome provider.
45+
*/
46+
static ConfigurableBiomeProvider<MultiNoiseBiomeConfig> overworld() {
4347
return Sponge.game().factoryProvider().provide(Factory.class).overworld();
4448
}
4549

50+
/**
51+
* Returns a multi-noise biome provider based on a {@link MultiNoiseBiomeConfig}.
52+
* @param config the configuration
53+
* @param <T> the configuration type
54+
*
55+
* @return the configured BiomeProvider
56+
*/
4657
static <T extends MultiNoiseBiomeConfig> ConfigurableBiomeProvider<T> multiNoise(final T config) {
4758
return Sponge.game().factoryProvider().provide(Factory.class).multiNoise(config);
4859
}
4960

61+
/**
62+
* Returns the vanilla nether biome provider.
63+
*
64+
* @return the vanilla nether biome provider.
65+
*/
5066
static ConfigurableBiomeProvider<MultiNoiseBiomeConfig> nether() {
5167
return Sponge.game().factoryProvider().provide(Factory.class).nether();
5268
}
5369

70+
/**
71+
* Returns a vanilla end-style biome provider based on a {@link EndStyleBiomeConfig}.
72+
*
73+
* @param config the configuration
74+
* @param <T> the configuration type
75+
*
76+
* @return the configured BiomeProvider
77+
*/
5478
static <T extends EndStyleBiomeConfig> ConfigurableBiomeProvider<T> endStyle(final T config) {
5579
return Sponge.game().factoryProvider().provide(Factory.class).endStyle(config);
5680
}
5781

82+
/**
83+
* Returns the vanilla end biome provider.
84+
*
85+
* @return the vanilla end biome provider.
86+
*/
5887
static ConfigurableBiomeProvider<EndStyleBiomeConfig> end() {
5988
return Sponge.game().factoryProvider().provide(Factory.class).end();
6089
}
6190

91+
/**
92+
* Returns a checkerboard-style biome provider based on a {@link CheckerboardBiomeConfig}
93+
*
94+
* @param config the configuration
95+
* @param <T> the configuration type
96+
*
97+
* @return the configured BiomeProvider
98+
*/
6299
static <T extends CheckerboardBiomeConfig> ConfigurableBiomeProvider<T> checkerboard(final T config) {
63100
return Sponge.game().factoryProvider().provide(Factory.class).checkerboard(config);
64101
}
65102

103+
/**
104+
* Returns a fixed biome provider base on a single {@link Biome}
105+
*
106+
* @param biome the biome
107+
*
108+
* @return the configured BiomeProvider
109+
*/
66110
static BiomeProvider fixed(final RegistryReference<Biome> biome) {
67111
return Sponge.game().factoryProvider().provide(Factory.class).fixed(Objects.requireNonNull(biome, "biome"));
68112
}
69113

114+
/**
115+
* The list of biomes possible.
116+
*
117+
* @return the list of biomes possible.
118+
*/
70119
List<Biome> choices();
71120

121+
/**
122+
* The set of biomes within an area.
123+
*
124+
* @param x the center x coordinate
125+
* @param y the center y coordinate
126+
* @param z the center z coordinate
127+
* @param size the square area radius
128+
*
129+
* @return the set of biomes.
130+
*/
72131
Set<Biome> within(int x, int y, int z, int size);
73132

74133
interface Factory {
75134

76-
<T extends LayeredBiomeConfig> ConfigurableBiomeProvider<T> layered(T config);
77-
78-
ConfigurableBiomeProvider<LayeredBiomeConfig> overworld();
79-
135+
/**
136+
* Returns the vanilla overworld biome provider.
137+
*
138+
* @return the vanilla overworld biome provider.
139+
*/
140+
ConfigurableBiomeProvider<MultiNoiseBiomeConfig> overworld();
141+
142+
/**
143+
* Returns a multi-noise biome provider based on a {@link MultiNoiseBiomeConfig}.
144+
* @param config the configuration
145+
* @param <T> the configuration type
146+
*
147+
* @return the configured BiomeProvider
148+
*/
80149
<T extends MultiNoiseBiomeConfig> ConfigurableBiomeProvider<T> multiNoise(T config);
81150

151+
/**
152+
* Returns the vanilla nether biome provider.
153+
*
154+
* @return the vanilla nether biome provider.
155+
*/
82156
ConfigurableBiomeProvider<MultiNoiseBiomeConfig> nether();
83157

158+
/**
159+
* Returns a vanilla end-style biome provider based on a {@link EndStyleBiomeConfig}.
160+
*
161+
* @param config the configuration
162+
* @param <T> the configuration type
163+
*
164+
* @return the configured BiomeProvider
165+
*/
84166
<T extends EndStyleBiomeConfig> ConfigurableBiomeProvider<T> endStyle(T config);
85167

168+
/**
169+
* Returns the vanilla end biome provider.
170+
*
171+
* @return the vanilla end biome provider.
172+
*/
86173
ConfigurableBiomeProvider<EndStyleBiomeConfig> end();
87174

175+
/**
176+
* Returns a checkerboard-style biome provider based on a {@link CheckerboardBiomeConfig}
177+
*
178+
* @param config the configuration
179+
* @param <T> the configuration type
180+
*
181+
* @return the configured BiomeProvider
182+
*/
88183
<T extends CheckerboardBiomeConfig> ConfigurableBiomeProvider<T> checkerboard(T config);
89184

185+
/**
186+
* Returns a fixed biome provider base on a single {@link Biome}
187+
*
188+
* @param biome the biome
189+
*
190+
* @return the configured BiomeProvider
191+
*/
90192
BiomeProvider fixed(RegistryReference<Biome> biome);
91193
}
92194
}

src/main/java/org/spongepowered/api/world/biome/provider/BiomeProviderConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
import java.util.List;
3131

32+
/**
33+
* Base Interface for configurations of {@link BiomeProvider}.
34+
*/
3235
public interface BiomeProviderConfig {
3336

3437
List<RegistryReference<Biome>> biomes();

src/main/java/org/spongepowered/api/world/biome/BiomeSamplers.java renamed to src/main/java/org/spongepowered/api/world/biome/provider/FixedBiomeConfig.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,25 @@
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
* THE SOFTWARE.
2424
*/
25-
package org.spongepowered.api.world.biome;
25+
package org.spongepowered.api.world.biome.provider;
2626

2727
import org.spongepowered.api.Sponge;
28+
import org.spongepowered.api.registry.RegistryReference;
29+
import org.spongepowered.api.world.biome.Biome;
2830

29-
public final class BiomeSamplers {
30-
31-
// @formatter:off
32-
33-
// SORTFIELDS:ON
34-
35-
public static final BiomeSampler COLUMN_FUZZED = Sponge.game().factoryProvider().provide(BiomeSampler.Factory.class).columnFuzzed();
36-
37-
public static final BiomeSampler FUZZY = Sponge.game().factoryProvider().provide(BiomeSampler.Factory.class).fuzzy();
31+
/**
32+
* The configuration for a {@link BiomeProvider} with a single {@link Biome}.
33+
*/
34+
public interface FixedBiomeConfig extends BiomeProviderConfig {
3835

39-
public static final BiomeSampler DEFAULT = Sponge.game().factoryProvider().provide(BiomeSampler.Factory.class).defaultFinder();
36+
static FixedBiomeConfig of(RegistryReference<Biome> biome) {
37+
return Sponge.game().factoryProvider().provide(Factory.class).biome(biome);
38+
}
4039

41-
// SORTFIELDS:OFF
40+
RegistryReference<Biome> biome();
4241

43-
// @formatter:on
42+
interface Factory {
4443

45-
private BiomeSamplers() {
44+
FixedBiomeConfig biome(RegistryReference<Biome> biome);
4645
}
47-
4846
}

0 commit comments

Comments
 (0)