Skip to content

Commit 3b20f9b

Browse files
committed
API methods CustomBiome#modify, CustomBiome#isSimilar
1 parent 5c0a9c4 commit 3b20f9b

File tree

5 files changed

+66
-3
lines changed

5 files changed

+66
-3
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ allprojects {
1212
apply(plugin = "com.gradleup.shadow")
1313

1414
group = "me.outspending.biomesapi"
15-
version = "0.0.16"
15+
version = "0.0.17"
1616

1717
tasks.withType<JavaCompile> {
1818
options.encoding = "UTF-8"

main/src/main/java/me/outspending/biomesapi/biome/CustomBiome.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
* This interface represents a custom biome in the BiomesAPI.
1616
* It provides methods to retrieve and modify the properties of the custom biome.
1717
*
18-
* @version 0.0.6
18+
* @version 0.0.17
1919
* @since 0.0.1
2020
* @author Outspending
2121
*/
22-
@AsOf("0.0.6")
22+
@AsOf("0.0.17")
2323
public interface CustomBiome {
2424

2525
/**
@@ -230,6 +230,30 @@ public interface CustomBiome {
230230
@AsOf("0.0.2")
231231
void register();
232232

233+
234+
/**
235+
* Modifies the existing biome in the biome registry with the properties of this CustomBiome.
236+
*
237+
* @throws IllegalArgumentException if the biome does not already exist in the registry.
238+
* @apiNote This method can only change the properties of an existing biome on the <b>server</b>.
239+
* Clients which have already received the biome will not see any changes until they enter the reconfiguration phase
240+
* (e.g., by rejoining the server.)
241+
* @since 0.0.17
242+
*/
243+
@AsOf("0.0.17")
244+
void modify();
245+
246+
/**
247+
* Compares this CustomBiome to another CustomBiome to determine if they are similar.
248+
* Two CustomBiomes are considered similar if they have the same properties.
249+
*
250+
* @param otherBiome The other CustomBiome to compare to.
251+
* @return true if the CustomBiomes are similar, false otherwise.
252+
* @since 0.0.17
253+
*/
254+
@AsOf("0.0.17")
255+
boolean isSimilar(@NotNull CustomBiome otherBiome);
256+
233257
/**
234258
* This class is used to create a new CustomBiome object.
235259
* It provides methods to set the properties of the CustomBiome.

main/src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,29 @@ public void register() {
216216
BiomeRegistry.newRegistry().register(this);
217217
}
218218

219+
@Override
220+
public void modify() {
221+
BiomeRegistry.newRegistry().modify(this);
222+
}
223+
224+
@Override
225+
public boolean isSimilar(@NotNull CustomBiome otherBiome) {
226+
if (this == otherBiome) return true;
227+
if (!this.resourceKey.equals(otherBiome.getResourceKey())) return false;
228+
if (!this.settings.equals(otherBiome.getSettings())) return false;
229+
if (this.fogColor != otherBiome.getFogColor()) return false;
230+
if (this.waterColor != otherBiome.getWaterColor()) return false;
231+
if (this.waterFogColor != otherBiome.getWaterFogColor()) return false;
232+
if (this.skyColor != otherBiome.getSkyColor()) return false;
233+
if (this.foliageColor != otherBiome.getFoliageColor()) return false;
234+
if (this.grassColor != otherBiome.getGrassColor()) return false;
235+
if (!this.particleRenderer.equals(otherBiome.getParticleRenderer())) return false;
236+
if (this.blockReplacements.length != otherBiome.getBlockReplacements().length) return false;
237+
for (int i = 0; i < this.blockReplacements.length; i++) {
238+
if (!this.blockReplacements[i].equals(otherBiome.getBlockReplacements()[i])) {
239+
return false;
240+
}
241+
}
242+
return true;
243+
}
219244
}

main/src/main/java/me/outspending/biomesapi/registry/BiomeRegistry.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static BiomeRegistry newRegistry() {
4545
* Another biome must already exist with the same ResourceKey.
4646
* It takes a CustomBiome object as an argument.
4747
*
48+
* @throws IllegalArgumentException if the biome does not already exist in the registry.
4849
* @apiNote This method can only change the properties of an existing biome on the <b>server</b>.
4950
* Clients which have already received the biome will not see any changes until they enter the reconfiguration phase
5051
* (e.g., by rejoining the server.)

main/src/main/java/me/outspending/biomesapi/renderer/ParticleRenderer.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ public record ParticleRenderer(@NotNull Map<@NotNull AmbientParticle, @NotNull F
7171
}
7272

7373

74+
@Override
75+
public boolean equals(Object obj) {
76+
if (this == obj) return true;
77+
if (obj == null || getClass() != obj.getClass()) return false;
78+
ParticleRenderer that = (ParticleRenderer) obj;
79+
return ambientParticles.equals(that.ambientParticles);
80+
}
81+
82+
@Override
83+
public int hashCode() {
84+
return ambientParticles.hashCode();
85+
}
86+
7487
/**
7588
* Builder class for constructing ParticleRenderer instances.
7689
*

0 commit comments

Comments
 (0)