Skip to content

Commit 0faab05

Browse files
authored
Merge pull request #1 from LumaLibre/feat/environment-api
Feat/environment api
2 parents a17890e + 11398df commit 0faab05

22 files changed

Lines changed: 1223 additions & 104 deletions

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
}
99

1010
val isSnapshot: Boolean = project.hasProperty("snapshot") || System.getProperty("snapshot")?.toBoolean() == true
11-
val stable = "1.0.2"
11+
val stable = "1.1.0"
1212

1313
allprojects {
1414
apply(plugin = "java")

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

Lines changed: 88 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
import com.google.common.base.Preconditions;
44
import me.outspending.biomesapi.wrapper.BiomeSettings;
5-
import me.outspending.biomesapi.wrapper.GrassColorModifier;
5+
import me.outspending.biomesapi.wrapper.environment.GrassColorModifier;
66
import me.outspending.biomesapi.annotations.AsOf;
77
import me.outspending.biomesapi.packet.data.BlockReplacement;
88
import me.outspending.biomesapi.registry.BiomeResourceKey;
99
import me.outspending.biomesapi.renderer.ParticleRenderer;
10+
import me.outspending.biomesapi.wrapper.environment.attribute.WrappedEnvironmentAttributeMap;
1011
import org.bukkit.Color;
1112
import org.bukkit.NamespacedKey;
1213
import org.bukkit.block.Biome;
@@ -16,11 +17,11 @@
1617
* This interface represents a custom biome in the BiomesAPI.
1718
* It provides methods to retrieve and modify the properties of the custom biome.
1819
*
19-
* @version 0.0.24
20+
* @version 1.1.0
2021
* @since 0.0.1
2122
* @author Outspending
2223
*/
23-
@AsOf("0.0.24")
24+
@AsOf("1.1.0")
2425
public interface CustomBiome {
2526

2627
/**
@@ -124,6 +125,15 @@ public interface CustomBiome {
124125
@AsOf("0.0.1")
125126
int getGrassColor();
126127

128+
/**
129+
* Returns the dry foliage color of the CustomBiome.
130+
*
131+
* @return the dry foliage color of the CustomBiome
132+
* @since 1.0.2
133+
*/
134+
@AsOf("1.0.2")
135+
int getDryFoliageColor();
136+
127137
/**
128138
* Returns the GrassColorModifier of the CustomBiome.
129139
*
@@ -151,6 +161,16 @@ public interface CustomBiome {
151161
@AsOf("0.0.6")
152162
@NotNull BlockReplacement[] getBlockReplacements();
153163

164+
165+
/**
166+
* Returns the WrappedEnvironmentAttributeMap of the CustomBiome.
167+
*
168+
* @return the WrappedEnvironmentAttributeMap of the CustomBiome
169+
* @since 1.1.0
170+
*/
171+
@AsOf("1.1.0")
172+
@NotNull WrappedEnvironmentAttributeMap getEnvironmentAttributeMap();
173+
154174
/**
155175
* Sets the fog color of the CustomBiome.
156176
*
@@ -205,6 +225,15 @@ public interface CustomBiome {
205225
@AsOf("0.0.5")
206226
void setGrassColor(int grassColor);
207227

228+
/**
229+
* Sets the dry foliage color of the CustomBiome.
230+
*
231+
* @param dryFoliageColor the dry foliage color of the CustomBiome
232+
* @since 1.0.2
233+
*/
234+
@AsOf("1.0.2")
235+
void setDryFoliageColor(int dryFoliageColor);
236+
208237
/**
209238
* Sets the GrassColorModifier of the CustomBiome.
210239
*
@@ -233,6 +262,16 @@ public interface CustomBiome {
233262
@AsOf("0.0.6")
234263
void setBlockReplacements(@NotNull BlockReplacement... blockReplacements);
235264

265+
266+
/**
267+
* Sets the WrappedEnvironmentAttributeMap of the CustomBiome.
268+
*
269+
* @param environmentAttributeMap the WrappedEnvironmentAttributeMap of the CustomBiome
270+
* @since 1.1.0
271+
*/
272+
@AsOf("1.1.0")
273+
void setEnvironmentAttributeMap(@NotNull WrappedEnvironmentAttributeMap environmentAttributeMap);
274+
236275
/**
237276
* Returns a new Builder instance with the properties of the CustomBiome.
238277
*
@@ -286,17 +325,20 @@ class Builder {
286325
private BiomeResourceKey resourceKey = null;
287326
private BiomeSettings settings = BiomeSettings.defaultSettings();
288327

289-
private int fogColor = 0;
290-
private int waterColor = 0;
291-
private int waterFogColor = 0;
292-
private int skyColor = 0;
328+
private int fogColor = -1;
329+
private int waterColor = -1;
330+
private int waterFogColor = -1;
331+
private int skyColor = -1;
293332

294-
private int foliageColor = 0;
295-
private int grassColor = 0;
333+
private int foliageColor = -1;
334+
private int grassColor = -1;
335+
private int dryFoliageColor = -1;
296336

297337
private GrassColorModifier grassColorModifier = GrassColorModifier.NONE;
298-
private ParticleRenderer particleRenderer = null;
338+
private ParticleRenderer particleRenderer = ParticleRenderer.EMPTY;
299339
private BlockReplacement[] blockReplacements = new BlockReplacement[0];
340+
private WrappedEnvironmentAttributeMap environmentAttributeMap = WrappedEnvironmentAttributeMap.EMPTY;
341+
300342

301343
/**
302344
* Formats a hexadecimal color string by removing the leading '#' if present.
@@ -349,9 +391,11 @@ public Builder(@NotNull CustomBiome biome) {
349391
this.skyColor = biome.getSkyColor();
350392
this.foliageColor = biome.getFoliageColor();
351393
this.grassColor = biome.getGrassColor();
394+
this.dryFoliageColor = biome.getDryFoliageColor();
395+
this.grassColorModifier = biome.getGrassColorModifier();
352396
this.particleRenderer = biome.getParticleRenderer();
353397
this.blockReplacements = biome.getBlockReplacements();
354-
this.grassColorModifier = biome.getGrassColorModifier();
398+
this.environmentAttributeMap = biome.getEnvironmentAttributeMap();
355399
}
356400

357401
/**
@@ -536,6 +580,20 @@ public Builder(@NotNull CustomBiome biome) {
536580
return this;
537581
}
538582

583+
584+
/**
585+
* This method sets the dry foliage color property of the CustomBiome.
586+
*
587+
* @param dryFoliageColor The dry foliage color of the custom biome.
588+
* @since 1.0.2
589+
* @return The Builder object, for chaining method calls.
590+
*/
591+
@AsOf("1.0.2")
592+
public @NotNull Builder dryFoliageColor(@NotNull String dryFoliageColor) {
593+
this.dryFoliageColor = Integer.parseInt(formatHex(dryFoliageColor), 16);
594+
return this;
595+
}
596+
539597
/**
540598
* This method sets the grass color modifier property of the CustomBiome.
541599
*
@@ -576,13 +634,27 @@ public Builder(@NotNull CustomBiome biome) {
576634
return this;
577635
}
578636

637+
638+
/**
639+
* This method sets the environment attribute map property of the CustomBiome.
640+
*
641+
* @param environmentAttributeMap The environment attribute map of the custom biome.
642+
* @since 1.1.0
643+
* @return The Builder object, for chaining method calls.
644+
*/
645+
@AsOf("1.1.0")
646+
public @NotNull Builder environmentAttributeMap(@NotNull WrappedEnvironmentAttributeMap environmentAttributeMap) {
647+
this.environmentAttributeMap = environmentAttributeMap;
648+
return this;
649+
}
650+
579651
/**
580652
* This method creates a new CustomBiome object with the properties set in the Builder.
581653
*
582-
* @version 0.0.1
654+
* @since 0.0.1
583655
* @return a new CustomBiome object.
584656
*/
585-
@AsOf("0.0.1")
657+
@AsOf("1.1.0")
586658
public @NotNull CustomBiome build() {
587659
Preconditions.checkArgument(resourceKey != null, "Resource key must be set");
588660
Preconditions.checkArgument(settings != null, "Settings must be set");
@@ -596,9 +668,11 @@ public Builder(@NotNull CustomBiome biome) {
596668
skyColor,
597669
foliageColor,
598670
grassColor,
671+
dryFoliageColor,
599672
grassColorModifier,
600673
particleRenderer,
601-
blockReplacements
674+
blockReplacements,
675+
environmentAttributeMap
602676
);
603677
}
604678

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

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import io.papermc.paper.registry.RegistryAccess;
44
import io.papermc.paper.registry.RegistryKey;
55
import me.outspending.biomesapi.wrapper.BiomeSettings;
6-
import me.outspending.biomesapi.wrapper.GrassColorModifier;
6+
import me.outspending.biomesapi.wrapper.environment.GrassColorModifier;
77
import me.outspending.biomesapi.annotations.AsOf;
88
import me.outspending.biomesapi.packet.data.BlockReplacement;
99
import me.outspending.biomesapi.registry.BiomeRegistry;
1010
import me.outspending.biomesapi.registry.BiomeResourceKey;
1111
import me.outspending.biomesapi.renderer.ParticleRenderer;
12+
import me.outspending.biomesapi.wrapper.environment.attribute.WrappedEnvironmentAttributeMap;
1213
import net.minecraft.resources.Identifier;
1314
import org.bukkit.NamespacedKey;
1415
import org.bukkit.block.Biome;
@@ -18,30 +19,33 @@
1819
* This class represents a custom biome implementation.
1920
*
2021
* @author Outspending
21-
* @version 0.0.24
22+
* @version 1.1.0
2223
* @since 0.0.2
2324
*/
24-
@AsOf("0.0.24")
25-
public class CustomBiomeImpl implements CustomBiome {
25+
@AsOf("1.1.0")
26+
public final class CustomBiomeImpl implements CustomBiome {
2627

2728
// Required Settings
2829
private final BiomeResourceKey resourceKey;
2930
private final BiomeSettings settings;
3031

3132
// Required Colors
32-
private int fogColor;
33-
private int waterColor;
34-
private int waterFogColor;
35-
private int skyColor;
33+
private int fogColor = -1;
34+
private int waterColor = -1;
35+
private int waterFogColor = -1;
36+
private int skyColor = -1;
3637

3738
// Optional Colors
38-
private int foliageColor = 0;
39-
private int grassColor = 0;
39+
private int foliageColor = -1;
40+
private int grassColor = -1;
41+
private int dryFoliageColor = -1;
4042

4143
// Optional Settings
4244
private GrassColorModifier grassColorModifier = GrassColorModifier.NONE;
43-
private ParticleRenderer particleRenderer;
44-
private BlockReplacement[] blockReplacements;
45+
private ParticleRenderer particleRenderer = ParticleRenderer.EMPTY;
46+
private BlockReplacement[] blockReplacements = new BlockReplacement[0];
47+
48+
private WrappedEnvironmentAttributeMap environmentAttributeMap = WrappedEnvironmentAttributeMap.EMPTY;
4549

4650
@AsOf("0.0.2")
4751
public CustomBiomeImpl(
@@ -86,7 +90,7 @@ public CustomBiomeImpl(
8690
this.blockReplacements = new BlockReplacement[0];
8791
}
8892

89-
@AsOf("0.0.24")
93+
@AsOf("1.0.2")
9094
public CustomBiomeImpl(
9195
@NotNull BiomeResourceKey resourceKey,
9296
@NotNull BiomeSettings settings,
@@ -97,16 +101,20 @@ public CustomBiomeImpl(
97101
int skyColor,
98102
int foliageColor,
99103
int grassColor,
104+
int dryFoliageColor,
100105

101106
@NotNull GrassColorModifier grassColorModifier,
102107
@NotNull ParticleRenderer particleRenderer,
103-
@NotNull BlockReplacement[] blockReplacements
108+
@NotNull BlockReplacement[] blockReplacements,
109+
@NotNull WrappedEnvironmentAttributeMap environmentAttributeMap
104110
) {
105111
this(resourceKey, settings, fogColor, waterColor, waterFogColor, skyColor, particleRenderer);
106112
this.foliageColor = foliageColor;
107113
this.grassColor = grassColor;
114+
this.dryFoliageColor = dryFoliageColor;
108115
this.grassColorModifier = grassColorModifier;
109116
this.blockReplacements = blockReplacements;
117+
this.environmentAttributeMap = environmentAttributeMap;
110118
}
111119

112120
@Override
@@ -160,6 +168,10 @@ public int getGrassColor() {
160168
return grassColor;
161169
}
162170

171+
public int getDryFoliageColor() {
172+
return dryFoliageColor;
173+
}
174+
163175
@Override
164176
public GrassColorModifier getGrassColorModifier() {
165177
return grassColorModifier;
@@ -175,6 +187,11 @@ public GrassColorModifier getGrassColorModifier() {
175187
return blockReplacements;
176188
}
177189

190+
@Override
191+
public @NotNull WrappedEnvironmentAttributeMap getEnvironmentAttributeMap() {
192+
return environmentAttributeMap;
193+
}
194+
178195
@Override
179196
public void setFogColor(int fogColor) {
180197
this.fogColor = fogColor;
@@ -205,6 +222,10 @@ public void setGrassColor(int grassColor) {
205222
this.grassColor = grassColor;
206223
}
207224

225+
public void setDryFoliageColor(int dryFoliageColor) {
226+
this.dryFoliageColor = dryFoliageColor;
227+
}
228+
208229
@Override
209230
public void setGrassColorModifier(@NotNull GrassColorModifier grassColorModifier) {
210231
this.grassColorModifier = grassColorModifier;
@@ -220,6 +241,11 @@ public void setBlockReplacements(@NotNull BlockReplacement[] blockReplacements)
220241
this.blockReplacements = blockReplacements;
221242
}
222243

244+
@Override
245+
public void setEnvironmentAttributeMap(@NotNull WrappedEnvironmentAttributeMap environmentAttributeMap) {
246+
this.environmentAttributeMap = environmentAttributeMap;
247+
}
248+
223249
@Override
224250
public Builder toBuilder() {
225251
return new Builder(this);
@@ -246,13 +272,15 @@ public boolean isSimilar(@NotNull CustomBiome otherBiome) {
246272
if (this.skyColor != otherBiome.getSkyColor()) return false;
247273
if (this.foliageColor != otherBiome.getFoliageColor()) return false;
248274
if (this.grassColor != otherBiome.getGrassColor()) return false;
275+
if (this.dryFoliageColor != otherBiome.getDryFoliageColor()) return false;
276+
if (!this.grassColorModifier.equals(otherBiome.getGrassColorModifier())) return false;
249277
if (!this.particleRenderer.equals(otherBiome.getParticleRenderer())) return false;
250278
if (this.blockReplacements.length != otherBiome.getBlockReplacements().length) return false;
251279
for (int i = 0; i < this.blockReplacements.length; i++) {
252280
if (!this.blockReplacements[i].equals(otherBiome.getBlockReplacements()[i])) {
253281
return false;
254282
}
255283
}
256-
return true;
284+
return this.environmentAttributeMap.equals(otherBiome.getEnvironmentAttributeMap());
257285
}
258286
}

0 commit comments

Comments
 (0)