Skip to content

Commit 89a515d

Browse files
committed
Add spawn selector to variant registry entries
1 parent 6d0821d commit 89a515d

24 files changed

+545
-17
lines changed

paper-api/src/main/java/io/papermc/paper/registry/data/CatTypeRegistryEntry.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import io.papermc.paper.registry.RegistryBuilder;
44
import io.papermc.paper.registry.data.client.ClientTextureAsset;
5+
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
6+
import java.util.List;
57
import org.bukkit.entity.Cat;
68
import org.jetbrains.annotations.ApiStatus;
79
import org.jetbrains.annotations.Contract;
10+
import org.jetbrains.annotations.Unmodifiable;
811

912
/**
1013
* A data-centric version-specific registry entry for the {@link Cat.Type} type.
@@ -20,6 +23,14 @@ public interface CatTypeRegistryEntry {
2023
*/
2124
ClientTextureAsset clientTextureAsset();
2225

26+
/**
27+
* Provides the spawn conditions of the cat type, which is a list of {@link SpawnConditionPriority} that
28+
* determine the priority of the spawn conditions for this type.
29+
*
30+
* @return the list of spawn condition priorities.
31+
*/
32+
@Unmodifiable List<SpawnConditionPriority> spawnConditions();
33+
2334
/**
2435
* A mutable builder for the {@link CatTypeRegistryEntry} plugins may change in applicable registry events.
2536
* <p>
@@ -41,5 +52,16 @@ interface Builder extends CatTypeRegistryEntry, RegistryBuilder<Cat.Type> {
4152
*/
4253
@Contract(value = "_ -> this", mutates = "this")
4354
Builder clientTextureAsset(ClientTextureAsset clientTextureAsset);
55+
56+
/**
57+
* Sets the spawn conditions of the cat type, which is a list of {@link SpawnConditionPriority} that
58+
* determine the priority of the spawn conditions for this type.
59+
*
60+
* @param spawnConditions the list of spawn condition priorities.
61+
* @return this builder instance.
62+
* @see CatTypeRegistryEntry#spawnConditions()
63+
*/
64+
@Contract(value = "_ -> this", mutates = "this")
65+
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
4466
}
4567
}

paper-api/src/main/java/io/papermc/paper/registry/data/ChickenVariantRegistryEntry.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import io.papermc.paper.registry.RegistryBuilder;
44
import io.papermc.paper.registry.data.client.ClientTextureAsset;
5+
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
6+
import java.util.List;
57
import org.bukkit.entity.Chicken;
68
import org.jetbrains.annotations.ApiStatus;
79
import org.jetbrains.annotations.Contract;
10+
import org.jetbrains.annotations.Unmodifiable;
811

912
/**
1013
* A data-centric version-specific registry entry for the {@link Chicken.Variant} type.
@@ -42,6 +45,14 @@ enum Model {
4245
*/
4346
Model model();
4447

48+
/**
49+
* Provides the spawn conditions of the chicken variant, which is a list of {@link SpawnConditionPriority} that
50+
* determine the priority of the spawn conditions for this variant.
51+
*
52+
* @return the list of spawn condition priorities.
53+
*/
54+
@Unmodifiable List<SpawnConditionPriority> spawnConditions();
55+
4556
/**
4657
* A mutable builder for the {@link ChickenVariantRegistryEntry} plugins may change in applicable registry events.
4758
* <p>
@@ -74,5 +85,16 @@ interface Builder extends ChickenVariantRegistryEntry, RegistryBuilder<Chicken.V
7485
*/
7586
@Contract(value = "_ -> this", mutates = "this")
7687
Builder model(Model model);
88+
89+
/**
90+
* Sets the spawn conditions of the chicken variant, which is a list of {@link SpawnConditionPriority} that
91+
* determine the priority of the spawn conditions for this variant.
92+
*
93+
* @param spawnConditions the list of spawn condition priorities.
94+
* @return this builder instance.
95+
* @see ChickenVariantRegistryEntry#spawnConditions()
96+
*/
97+
@Contract(value = "_ -> this", mutates = "this")
98+
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
7799
}
78100
}

paper-api/src/main/java/io/papermc/paper/registry/data/CowVariantRegistryEntry.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import io.papermc.paper.registry.RegistryBuilder;
44
import io.papermc.paper.registry.data.client.ClientTextureAsset;
5+
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
6+
import java.util.List;
57
import org.bukkit.entity.Cow;
68
import org.jetbrains.annotations.ApiStatus;
79
import org.jetbrains.annotations.Contract;
10+
import org.jetbrains.annotations.Unmodifiable;
811

912
/**
1013
* A data-centric version-specific registry entry for the {@link Cow.Variant} type.
@@ -47,6 +50,14 @@ enum Model {
4750
*/
4851
Model model();
4952

53+
/**
54+
* Provides the spawn conditions of the cow variant, which is a list of {@link SpawnConditionPriority} that
55+
* determine the priority of the spawn conditions for this variant.
56+
*
57+
* @return the list of spawn condition priorities.
58+
*/
59+
@Unmodifiable List<SpawnConditionPriority> spawnConditions();
60+
5061
/**
5162
* A mutable builder for the {@link CowVariantRegistryEntry} plugins may change in applicable registry events.
5263
* <p>
@@ -79,5 +90,16 @@ interface Builder extends CowVariantRegistryEntry, RegistryBuilder<Cow.Variant>
7990
*/
8091
@Contract(value = "_ -> this", mutates = "this")
8192
Builder model(Model model);
93+
94+
/**
95+
* Sets the spawn conditions of the cow variant, which is a list of {@link SpawnConditionPriority} that
96+
* determine the priority of the spawn conditions for this variant.
97+
*
98+
* @param spawnConditions the list of spawn condition priorities.
99+
* @return this builder instance.
100+
* @see CowVariantRegistryEntry#spawnConditions()
101+
*/
102+
@Contract(value = "_ -> this", mutates = "this")
103+
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
82104
}
83105
}

paper-api/src/main/java/io/papermc/paper/registry/data/FrogVariantRegistryEntry.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import io.papermc.paper.registry.RegistryBuilder;
44
import io.papermc.paper.registry.data.client.ClientTextureAsset;
5+
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
6+
import java.util.List;
57
import org.bukkit.entity.Frog;
68
import org.jetbrains.annotations.ApiStatus;
79
import org.jetbrains.annotations.Contract;
10+
import org.jetbrains.annotations.Unmodifiable;
811

912
/**
1013
* A data-centric version-specific registry entry for the {@link Frog.Variant} type.
@@ -20,6 +23,14 @@ public interface FrogVariantRegistryEntry {
2023
*/
2124
ClientTextureAsset clientTextureAsset();
2225

26+
/**
27+
* Provides the spawn conditions of the frog variant, which is a list of {@link SpawnConditionPriority} that
28+
* determine the priority of the spawn conditions for this variant.
29+
*
30+
* @return the list of spawn condition priorities.
31+
*/
32+
@Unmodifiable List<SpawnConditionPriority> spawnConditions();
33+
2334
/**
2435
* A mutable builder for the {@link FrogVariantRegistryEntry} plugins may change in applicable registry events.
2536
* <p>
@@ -41,5 +52,16 @@ interface Builder extends FrogVariantRegistryEntry, RegistryBuilder<Frog.Variant
4152
*/
4253
@Contract(value = "_ -> this", mutates = "this")
4354
Builder clientTextureAsset(ClientTextureAsset clientTextureAsset);
55+
56+
/**
57+
* Sets the spawn conditions of the frog variant, which is a list of {@link SpawnConditionPriority} that
58+
* determine the priority of the spawn conditions for this variant.
59+
*
60+
* @param spawnConditions the list of spawn condition priorities.
61+
* @return this builder instance.
62+
* @see FrogVariantRegistryEntry#spawnConditions()
63+
*/
64+
@Contract(value = "_ -> this", mutates = "this")
65+
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
4466
}
4567
}

paper-api/src/main/java/io/papermc/paper/registry/data/PigVariantRegistryEntry.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import io.papermc.paper.registry.RegistryBuilder;
44
import io.papermc.paper.registry.data.client.ClientTextureAsset;
5+
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
6+
import java.util.List;
57
import org.bukkit.entity.Pig;
68
import org.jetbrains.annotations.ApiStatus;
79
import org.jetbrains.annotations.Contract;
10+
import org.jetbrains.annotations.Unmodifiable;
811

912
/**
1013
* A data-centric version-specific registry entry for the {@link Pig.Variant} type.
@@ -42,6 +45,14 @@ enum Model {
4245
*/
4346
Model model();
4447

48+
/**
49+
* Provides the spawn conditions of the pig variant, which is a list of {@link SpawnConditionPriority} that
50+
* determine the priority of the spawn conditions for this variant.
51+
*
52+
* @return the list of spawn condition priorities.
53+
*/
54+
@Unmodifiable List<SpawnConditionPriority> spawnConditions();
55+
4556
/**
4657
* A mutable builder for the {@link PigVariantRegistryEntry} plugins may change in applicable registry events.
4758
* <p>
@@ -74,5 +85,16 @@ interface Builder extends PigVariantRegistryEntry, RegistryBuilder<Pig.Variant>
7485
*/
7586
@Contract(value = "_ -> this", mutates = "this")
7687
Builder model(Model model);
88+
89+
/**
90+
* Sets the spawn conditions of the pig variant, which is a list of {@link SpawnConditionPriority} that
91+
* determine the priority of the spawn conditions for this variant.
92+
*
93+
* @param spawnConditions the list of spawn condition priorities.
94+
* @return this builder instance.
95+
* @see PigVariantRegistryEntry#spawnConditions()
96+
*/
97+
@Contract(value = "_ -> this", mutates = "this")
98+
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
7799
}
78100
}

paper-api/src/main/java/io/papermc/paper/registry/data/WolfVariantRegistryEntry.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import io.papermc.paper.registry.RegistryBuilder;
44
import io.papermc.paper.registry.data.client.ClientTextureAsset;
5+
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
6+
import java.util.List;
57
import org.bukkit.entity.Wolf;
68
import org.jetbrains.annotations.ApiStatus;
79
import org.jetbrains.annotations.Contract;
10+
import org.jetbrains.annotations.Unmodifiable;
811

912
/**
1013
* A data-centric version-specific registry entry for the {@link Wolf.Variant} type.
@@ -34,6 +37,14 @@ public interface WolfVariantRegistryEntry {
3437
*/
3538
ClientTextureAsset tameClientTextureAsset();
3639

40+
/**
41+
* Provides the spawn conditions of the wolf variant, which is a list of {@link SpawnConditionPriority} that
42+
* determine the priority of the spawn conditions for this variant.
43+
*
44+
* @return the list of spawn condition priorities.
45+
*/
46+
@Unmodifiable List<SpawnConditionPriority> spawnConditions();
47+
3748
/**
3849
* A mutable builder for the {@link WolfVariantRegistryEntry} plugins may change in applicable registry events.
3950
* <p>
@@ -77,5 +88,16 @@ interface Builder extends WolfVariantRegistryEntry, RegistryBuilder<Wolf.Variant
7788
*/
7889
@Contract(value = "_ -> this", mutates = "this")
7990
Builder tameClientTextureAsset(ClientTextureAsset tameClientTextureAsset);
91+
92+
/**
93+
* Sets the spawn conditions of the wolf variant, which is a list of {@link SpawnConditionPriority} that
94+
* determine the priority of the spawn conditions for this variant.
95+
*
96+
* @param spawnConditions the list of spawn condition priorities.
97+
* @return this builder instance.
98+
* @see WolfVariantRegistryEntry#spawnConditions()
99+
*/
100+
@Contract(value = "_ -> this", mutates = "this")
101+
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
80102
}
81103
}

paper-api/src/main/java/io/papermc/paper/registry/data/client/ClientTextureAsset.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static ClientTextureAsset clientTextureAsset(final Key identifier) {
6060
* @return a new {@code ClientAsset} instance.
6161
*/
6262
@Contract("_ -> new")
63-
static ClientTextureAsset clientTextureAsset(final @KeyPattern String identifier) {
63+
static ClientTextureAsset clientTextureAsset(@KeyPattern final String identifier) {
6464
return clientTextureAsset(Key.key(identifier));
6565
}
6666
}

paper-api/src/main/java/io/papermc/paper/registry/data/client/ClientTextureAssetImpl.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
import net.kyori.adventure.key.Key;
44
import org.intellij.lang.annotations.Subst;
5-
import org.jspecify.annotations.NullMarked;
65

76
/**
87
* Package local implementation of the {@link ClientTextureAsset} type.
98
* Chosen over bridging into server internals as no internal types are required for this.
109
*/
11-
@NullMarked
1210
record ClientTextureAssetImpl(
1311
Key identifier,
1412
Key texturePath
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* This package contains client-side registry entry types.
3+
*/
4+
@NullMarked
5+
package io.papermc.paper.registry.data.client;
6+
7+
import org.jspecify.annotations.NullMarked;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.papermc.paper.registry.data.variant;
2+
3+
import io.papermc.paper.registry.set.RegistryKeySet;
4+
import org.bukkit.block.Biome;
5+
6+
record BiomeCheckImpl(RegistryKeySet<Biome> requiredBiomes) implements SpawnCondition.BiomeCheck {
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.papermc.paper.registry.data.variant;
2+
3+
import com.google.common.collect.Range;
4+
5+
record MoonBrightnessCheckImpl(Range<Double> range) implements SpawnCondition.MoonBrightnessCheck {
6+
}

0 commit comments

Comments
 (0)