Skip to content

Add spawn selector to variant registry entries #12711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import io.papermc.paper.registry.RegistryBuilder;
import io.papermc.paper.registry.data.client.ClientTextureAsset;
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
import java.util.List;
import org.bukkit.entity.Cat;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Unmodifiable;

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

/**
* Provides the spawn conditions of the cat type, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this type.
*
* @return the list of spawn condition priorities.
*/
@Unmodifiable List<SpawnConditionPriority> spawnConditions();

/**
* A mutable builder for the {@link CatTypeRegistryEntry} plugins may change in applicable registry events.
* <p>
Expand All @@ -41,5 +52,16 @@ interface Builder extends CatTypeRegistryEntry, RegistryBuilder<Cat.Type> {
*/
@Contract(value = "_ -> this", mutates = "this")
Builder clientTextureAsset(ClientTextureAsset clientTextureAsset);

/**
* Sets the spawn conditions of the cat type, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this type.
*
* @param spawnConditions the list of spawn condition priorities.
* @return this builder instance.
* @see CatTypeRegistryEntry#spawnConditions()
*/
@Contract(value = "_ -> this", mutates = "this")
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import io.papermc.paper.registry.RegistryBuilder;
import io.papermc.paper.registry.data.client.ClientTextureAsset;
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
import java.util.List;
import org.bukkit.entity.Chicken;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Unmodifiable;

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

/**
* Provides the spawn conditions of the chicken variant, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this variant.
*
* @return the list of spawn condition priorities.
*/
@Unmodifiable List<SpawnConditionPriority> spawnConditions();

/**
* A mutable builder for the {@link ChickenVariantRegistryEntry} plugins may change in applicable registry events.
* <p>
Expand Down Expand Up @@ -74,5 +85,16 @@ interface Builder extends ChickenVariantRegistryEntry, RegistryBuilder<Chicken.V
*/
@Contract(value = "_ -> this", mutates = "this")
Builder model(Model model);

/**
* Sets the spawn conditions of the chicken variant, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this variant.
*
* @param spawnConditions the list of spawn condition priorities.
* @return this builder instance.
* @see ChickenVariantRegistryEntry#spawnConditions()
*/
@Contract(value = "_ -> this", mutates = "this")
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import io.papermc.paper.registry.RegistryBuilder;
import io.papermc.paper.registry.data.client.ClientTextureAsset;
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
import java.util.List;
import org.bukkit.entity.Cow;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Unmodifiable;

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

/**
* Provides the spawn conditions of the cow variant, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this variant.
*
* @return the list of spawn condition priorities.
*/
@Unmodifiable List<SpawnConditionPriority> spawnConditions();

/**
* A mutable builder for the {@link CowVariantRegistryEntry} plugins may change in applicable registry events.
* <p>
Expand Down Expand Up @@ -79,5 +90,16 @@ interface Builder extends CowVariantRegistryEntry, RegistryBuilder<Cow.Variant>
*/
@Contract(value = "_ -> this", mutates = "this")
Builder model(Model model);

/**
* Sets the spawn conditions of the cow variant, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this variant.
*
* @param spawnConditions the list of spawn condition priorities.
* @return this builder instance.
* @see CowVariantRegistryEntry#spawnConditions()
*/
@Contract(value = "_ -> this", mutates = "this")
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import io.papermc.paper.registry.RegistryBuilder;
import io.papermc.paper.registry.data.client.ClientTextureAsset;
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
import java.util.List;
import org.bukkit.entity.Frog;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Unmodifiable;

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

/**
* Provides the spawn conditions of the frog variant, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this variant.
*
* @return the list of spawn condition priorities.
*/
@Unmodifiable List<SpawnConditionPriority> spawnConditions();

/**
* A mutable builder for the {@link FrogVariantRegistryEntry} plugins may change in applicable registry events.
* <p>
Expand All @@ -41,5 +52,16 @@ interface Builder extends FrogVariantRegistryEntry, RegistryBuilder<Frog.Variant
*/
@Contract(value = "_ -> this", mutates = "this")
Builder clientTextureAsset(ClientTextureAsset clientTextureAsset);

/**
* Sets the spawn conditions of the frog variant, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this variant.
*
* @param spawnConditions the list of spawn condition priorities.
* @return this builder instance.
* @see FrogVariantRegistryEntry#spawnConditions()
*/
@Contract(value = "_ -> this", mutates = "this")
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import io.papermc.paper.registry.RegistryBuilder;
import io.papermc.paper.registry.data.client.ClientTextureAsset;
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
import java.util.List;
import org.bukkit.entity.Pig;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Unmodifiable;

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

/**
* Provides the spawn conditions of the pig variant, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this variant.
*
* @return the list of spawn condition priorities.
*/
@Unmodifiable List<SpawnConditionPriority> spawnConditions();

/**
* A mutable builder for the {@link PigVariantRegistryEntry} plugins may change in applicable registry events.
* <p>
Expand Down Expand Up @@ -74,5 +85,16 @@ interface Builder extends PigVariantRegistryEntry, RegistryBuilder<Pig.Variant>
*/
@Contract(value = "_ -> this", mutates = "this")
Builder model(Model model);

/**
* Sets the spawn conditions of the pig variant, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this variant.
*
* @param spawnConditions the list of spawn condition priorities.
* @return this builder instance.
* @see PigVariantRegistryEntry#spawnConditions()
*/
@Contract(value = "_ -> this", mutates = "this")
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import io.papermc.paper.registry.RegistryBuilder;
import io.papermc.paper.registry.data.client.ClientTextureAsset;
import io.papermc.paper.registry.data.variant.SpawnConditionPriority;
import java.util.List;
import org.bukkit.entity.Wolf;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Unmodifiable;

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

/**
* Provides the spawn conditions of the wolf variant, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this variant.
*
* @return the list of spawn condition priorities.
*/
@Unmodifiable List<SpawnConditionPriority> spawnConditions();

/**
* A mutable builder for the {@link WolfVariantRegistryEntry} plugins may change in applicable registry events.
* <p>
Expand Down Expand Up @@ -77,5 +88,16 @@ interface Builder extends WolfVariantRegistryEntry, RegistryBuilder<Wolf.Variant
*/
@Contract(value = "_ -> this", mutates = "this")
Builder tameClientTextureAsset(ClientTextureAsset tameClientTextureAsset);

/**
* Sets the spawn conditions of the wolf variant, which is a list of {@link SpawnConditionPriority} that
* determine the priority of the spawn conditions for this variant.
*
* @param spawnConditions the list of spawn condition priorities.
* @return this builder instance.
* @see WolfVariantRegistryEntry#spawnConditions()
*/
@Contract(value = "_ -> this", mutates = "this")
Builder spawnConditions(List<SpawnConditionPriority> spawnConditions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static ClientTextureAsset clientTextureAsset(final Key identifier) {
* @return a new {@code ClientAsset} instance.
*/
@Contract("_ -> new")
static ClientTextureAsset clientTextureAsset(final @KeyPattern String identifier) {
static ClientTextureAsset clientTextureAsset(@KeyPattern final String identifier) {
return clientTextureAsset(Key.key(identifier));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import net.kyori.adventure.key.Key;
import org.intellij.lang.annotations.Subst;
import org.jspecify.annotations.NullMarked;

/**
* Package local implementation of the {@link ClientTextureAsset} type.
* Chosen over bridging into server internals as no internal types are required for this.
*/
@NullMarked
record ClientTextureAssetImpl(
Key identifier,
Key texturePath
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* This package contains client-side registry entry types.
*/
@NullMarked
package io.papermc.paper.registry.data.client;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.papermc.paper.registry.data.variant;

import io.papermc.paper.registry.set.RegistryKeySet;
import org.bukkit.block.Biome;

record BiomeCheckImpl(RegistryKeySet<Biome> requiredBiomes) implements SpawnCondition.BiomeCheck {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.papermc.paper.registry.data.variant;

import com.google.common.collect.Range;

record MoonBrightnessCheckImpl(Range<Double> range) implements SpawnCondition.MoonBrightnessCheck {
}
Loading
Loading