Skip to content

Commit

Permalink
Major Class Changes for 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Outspending committed Dec 29, 2023
1 parent 7a6da81 commit cce63e7
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 127 deletions.
1 change: 1 addition & 0 deletions src/main/java/me/outspending/biomesapi/BiomeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/me/outspending/biomesapi/BiomeRegistry.java
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 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
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
124 changes: 124 additions & 0 deletions src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package me.outspending.biomesapi.biome;

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.NamespacedKey;
import org.jetbrains.annotations.NotNull;

@AsOf("0.0.2")
public final class CustomBiomeImpl implements 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;

@AsOf("0.0.2")
public CustomBiomeImpl(
@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 CustomBiomeImpl(
@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;
}

@Override
public @NotNull NamespacedKey toNamespacedKey() {
ResourceLocation resourceLocation = resourceKey.resourceLocation();
return new NamespacedKey(resourceLocation.getNamespace(), resourceLocation.getPath());
}

@Override
public @NotNull BiomeResourceKey getResourceKey() {
return this.resourceKey;
}

@Override
public @NotNull BiomeSettings getSettings() {
return this.settings;
}

@Override
public int getFogColor() {
return fogColor;
}

@Override
public int getWaterColor() {
return waterColor;
}

@Override
public int getWaterFogColor() {
return waterFogColor;
}

@Override
public int getSkyColor() {
return skyColor;
}

@Override
public int getFoliageColor() {
return foliageColor;
}

@Override
public int getGrassColor() {
return grassColor;
}

@NotNull
@Override
public ParticleRenderer getParticleRenderer() {
return particleRenderer;
}

}

0 comments on commit cce63e7

Please sign in to comment.