Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Outspending committed Dec 29, 2023
2 parents 47b5844 + cce63e7 commit dff016d
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 145 deletions.
9 changes: 9 additions & 0 deletions src/main/java/me/outspending/biomesapi/BiomeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import lombok.Getter;
import lombok.experimental.UtilityClass;
import me.outspending.biomesapi.annotations.AsOf;
import me.outspending.biomesapi.biome.CustomBiome;
import me.outspending.biomesapi.exceptions.UnknownBiomeException;
import net.minecraft.world.level.biome.Biome;
import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -59,4 +62,10 @@ public static boolean isBiome(@NotNull BiomeResourceKey resourceKey) {
return getBiome(resourceKey) != null;
}

// TODO: Add a method to get a biome from a location
@AsOf("0.0.2")
public static @Nullable CustomBiome getBiome(@NotNull Location location) {
return null;
}

}
3 changes: 2 additions & 1 deletion src/main/java/me/outspending/biomesapi/BiomeRegistry.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package me.outspending.biomesapi;

import me.outspending.biomesapi.annotations.AsOf;
import me.outspending.biomesapi.annotations.Experimental;
import me.outspending.biomesapi.biome.CustomBiome;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/me/outspending/biomesapi/BiomeSetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.experimental.UtilityClass;
import me.outspending.biomesapi.annotations.AsOf;
import me.outspending.biomesapi.biome.CustomBiome;
import me.outspending.biomesapi.misc.PointRange3D;
import me.outspending.biomesapi.nms.NMS;
import me.outspending.biomesapi.nms.NMSHandler;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/me/outspending/biomesapi/BiomeSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static final class Builder {
* @return The Builder object, for chaining method calls.
*/
@AsOf("0.0.1")
public @NotNull Builder depth(float depth) {
public @NotNull Builder depth(@Range(from = 0, to = 25) float depth) {
this.depth = depth;
return this;
}
Expand All @@ -80,7 +80,7 @@ public static final class Builder {
* @return The Builder object, for chaining method calls.
*/
@AsOf("0.0.1")
public @NotNull Builder scale(float scale) {
public @NotNull Builder scale(@Range(from = 0, to = 25) float scale) {
this.scale = scale;
return this;
}
Expand All @@ -93,7 +93,7 @@ public static final class Builder {
* @return The Builder object, for chaining method calls.
*/
@AsOf("0.0.1")
public @NotNull Builder temperature(float temperature) {
public @NotNull Builder temperature(@Range(from = 0, to = 25) float temperature) {
this.temperature = temperature;
return this;
}
Expand All @@ -106,7 +106,7 @@ public static final class Builder {
* @return The Builder object, for chaining method calls.
*/
@AsOf("0.0.1")
public @NotNull Builder downfall(float downfall) {
public @NotNull Builder downfall(@Range(from = 0, to = 25) float downfall) {
this.downfall = downfall;
return this;
}
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/me/outspending/biomesapi/BiomeUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,6 @@ public static void updateChunk(@NotNull Chunk chunk) {
updateChunks(List.of(chunk));
}

/**
* Updates the biome of a chunk within a certain distance.
* This method is a convenience method that calls the updateChunks method with a list containing the chunk and the specified distance.
*
* @param chunk The chunk to update.
* @param distance The distance.
* @version 0.0.1
*/
@AsOf("0.0.1")
public static void updateChunk(@NotNull Chunk chunk, int distance) {
updateChunks(List.of(chunk));
}

/**
* Updates the biomes of the chunks between two locations.
* This method is a convenience method that calls the updateChunks method with the chunks between the 'from' and 'to' locations.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.outspending.biomesapi;

import me.outspending.biomesapi.annotations.AsOf;
import me.outspending.biomesapi.biome.CustomBiome;
import me.outspending.biomesapi.exceptions.UnknownNMSVersionException;
import me.outspending.biomesapi.nms.NMS;
import me.outspending.biomesapi.nms.NMSHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,141 +1,54 @@
package me.outspending.biomesapi;
package me.outspending.biomesapi.biome;

import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.Setter;
import me.outspending.biomesapi.BiomeResourceKey;
import me.outspending.biomesapi.BiomeSettings;
import me.outspending.biomesapi.ParticleRenderer;
import me.outspending.biomesapi.annotations.AsOf;
import net.minecraft.resources.ResourceLocation;
import org.bukkit.Color;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;

/**
* This class represents a custom biome in Minecraft.
* It includes properties such as a BiomeResourceKey, BiomeSettings, and various color settings.
* It also includes a nested Builder class for creating instances of CustomBiome.
*
* @version 0.0.1
*/
@AsOf("0.0.1")
@Getter @Setter
public final class CustomBiome {

// Required Settings
private final BiomeResourceKey resourceKey;
private final BiomeSettings settings;

// Required Colors
private final int fogColor;
private final int waterColor;
private final int waterFogColor;
private final int skyColor;

// Optional Colors
private int foliageColor = 0;
private int grassColor = 0;

// Optional Settings
private ParticleRenderer particleRenderer;

/**
* This constructor creates a new CustomBiome object with the required settings and colors.
*
* @param resourceKey The BiomeResourceKey for the custom biome.
* @param settings The BiomeSettings for the custom biome.
* @param fogColor The fog color for the custom biome.
* @param waterColor The water color for the custom biome.
* @param waterFogColor The water fog color for the custom biome.
* @param skyColor The sky color for the custom biome.
*
* @version 0.0.1
*/
@AsOf("0.0.1")
public CustomBiome(
@NotNull BiomeResourceKey resourceKey,
@NotNull BiomeSettings settings,

int fogColor,
int waterColor,
int waterFogColor,
int skyColor,

@NotNull ParticleRenderer particleRenderer
) {
this.resourceKey = resourceKey;
this.settings = settings;
this.particleRenderer = particleRenderer;

this.fogColor = fogColor;
this.waterColor = waterColor;
this.waterFogColor = waterFogColor;
this.skyColor = skyColor;
}
@AsOf("0.0.2")
public interface CustomBiome {

/**
* This constructor creates a new CustomBiome object with the required settings and colors, as well as optional foliage and grass colors.
*
* @param resourceKey The BiomeResourceKey for the custom biome.
* @param settings The BiomeSettings for the custom biome.
* @param fogColor The fog color for the custom biome.
* @param waterColor The water color for the custom biome.
* @param waterFogColor The water fog color for the custom biome.
* @param skyColor The sky color for the custom biome.
* @param foliageColor The foliage color for the custom biome.
* @param grassColor The grass color for the custom biome.
*
* @version 0.0.1
*/
@AsOf("0.0.1")
public CustomBiome(
@NotNull BiomeResourceKey resourceKey,
@NotNull BiomeSettings settings,

int fogColor,
int waterColor,
int waterFogColor,
int skyColor,
int foliageColor,
int grassColor,

@NotNull ParticleRenderer particleRenderer
) {
this(resourceKey, settings, fogColor, waterColor, waterFogColor, skyColor, particleRenderer);
this.foliageColor = foliageColor;
this.grassColor = grassColor;
@AsOf("0.0.2")
static @NotNull Builder builder() {
return new Builder();
}

/**
* This method converts the BiomeResourceKey of the custom biome to a NamespacedKey.
*
* @version 0.0.1
* @return The NamespacedKey corresponding to the BiomeResourceKey of the custom biome.
*/
@AsOf("0.0.1")
public NamespacedKey toNamespacedKey() {
ResourceLocation location = resourceKey.resourceLocation();
return new NamespacedKey(location.getNamespace(), location.getPath());
}
@AsOf("0.0.2")
@NotNull NamespacedKey toNamespacedKey();

/**
* This method creates a new Builder object for creating instances of CustomBiome.
*
* @version 0.0.1
* @return a new Builder object.
*/
@AsOf("0.0.1")
public static @NotNull Builder builder() {
return new Builder();
}
@AsOf("0.0.2")
@NotNull BiomeResourceKey getResourceKey();

@AsOf("0.0.2")
@NotNull BiomeSettings getSettings();

@AsOf("0.0.2")
int getFogColor();

@AsOf("0.0.2")
int getWaterColor();

@AsOf("0.0.2")
int getWaterFogColor();

@AsOf("0.0.2")
int getSkyColor();

@AsOf("0.0.2")
int getFoliageColor();

@AsOf("0.0.2")
int getGrassColor();

@AsOf("0.0.2")
@NotNull ParticleRenderer getParticleRenderer();

/**
* This is a nested Builder class for creating instances of CustomBiome.
* It uses the Builder pattern, where you call a chain of methods to set the properties,
* and then call build() to create the object.
*
* @version 0.0.1
*/
@AsOf("0.0.1")
public static final class Builder {
@AsOf("0.0.2")
class Builder {

private BiomeResourceKey resourceKey;
private BiomeSettings settings;
Expand Down Expand Up @@ -370,7 +283,7 @@ private String formatHex(@NotNull String color) {
Preconditions.checkArgument(resourceKey != null, "Resource key must be set");
Preconditions.checkArgument(settings != null, "Settings must be set");

return new CustomBiome(
return new CustomBiomeImpl(
resourceKey,
settings,
fogColor,
Expand Down
Loading

0 comments on commit dff016d

Please sign in to comment.