| 1 | package net.minecraft.world.attribute;
|
| 2 |
|
| 3 | import com.mojang.serialization.Codec;
|
| 4 | import java.util.List;
|
| 5 | import net.minecraft.core.Registry;
|
| 6 | import net.minecraft.core.particles.ParticleOptions;
|
| 7 | import net.minecraft.core.particles.ParticleTypes;
|
| 8 | import net.minecraft.core.registries.BuiltInRegistries;
|
| 9 | import net.minecraft.resources.Identifier;
|
| 10 | import net.minecraft.util.ExtraCodecs;
|
| 11 | import net.minecraft.util.TriState;
|
| 12 | import net.minecraft.world.attribute.modifier.AttributeModifier;
|
| 13 | import net.minecraft.world.entity.schedule.Activity;
|
| 14 | import net.minecraft.world.level.MoonPhase;
|
| 15 | import net.minecraft.world.level.biome.MobSpawnSettings;
|
| 16 | import org.joml.Vector3fc;
|
| 17 | import org.joml.Vector4fc;
|
| 18 |
|
| 19 | public interface AttributeTypes {
|
| 20 | AttributeType<Boolean> BOOLEAN = register("boolean", AttributeType.ofNotInterpolated(Codec.BOOL, AttributeModifier.BOOLEAN_LIBRARY));
|
| 21 | AttributeType<TriState> TRI_STATE = register("tri_state", AttributeType.ofNotInterpolated(TriState.CODEC));
|
| 22 | AttributeType<Float> FLOAT = register(
|
| 23 | "float", AttributeType.ofInterpolated(Codec.FLOAT, AttributeModifier.FLOAT_LIBRARY, LerpFunction.ofFloat(), LerpFunction.ofFloat(), value -> value, null)
|
| 24 | );
|
| 25 | AttributeType<Float> ANGLE_DEGREES = register(
|
| 26 | "angle_degrees",
|
| 27 | AttributeType.ofInterpolated(Codec.FLOAT, AttributeModifier.FLOAT_LIBRARY, LerpFunction.ofFloat(), LerpFunction.ofDegrees(90.0F), value -> value, null)
|
| 28 | );
|
| 29 | AttributeType<Vector3fc> RGB_COLOR = register(
|
| 30 | "rgb_color", AttributeType.ofInterpolated(ExtraCodecs.STRING_RGB_VEC3_COLOR, AttributeModifier.RGB_COLOR_LIBRARY, LerpFunction.ofColorVec3())
|
| 31 | );
|
| 32 | AttributeType<Vector4fc> ARGB_COLOR = register(
|
| 33 | "argb_color", AttributeType.ofInterpolated(ExtraCodecs.STRING_ARGB_VEC4_COLOR, AttributeModifier.ARGB_COLOR_LIBRARY, LerpFunction.ofColorVec4())
|
| 34 | );
|
| 35 | AttributeType<Integer> INTEGER = register(
|
| 36 | "integer",
|
| 37 | AttributeType.ofInterpolated(
|
| 38 | Codec.INT, AttributeModifier.INTEGER_LIBRARY, LerpFunction.ofInteger(), LerpFunction.ofInteger(), value -> value.intValue(), value -> value
|
| 39 | )
|
| 40 | );
|
| 41 | AttributeType<MoonPhase> MOON_PHASE = register("moon_phase", AttributeType.ofNotInterpolated(MoonPhase.CODEC));
|
| 42 | AttributeType<Activity> ACTIVITY = register("activity", AttributeType.ofNotInterpolated(BuiltInRegistries.ACTIVITY.byNameCodec()));
|
| 43 | AttributeType<BedRule> BED_RULE = register("bed_rule", AttributeType.ofNotInterpolated(BedRule.CODEC));
|
| 44 | AttributeType<ParticleOptions> PARTICLE = register("particle", AttributeType.ofNotInterpolated(ParticleTypes.CODEC));
|
| 45 | AttributeType<List<AmbientParticle>> AMBIENT_PARTICLES = register(
|
| 46 | "ambient_particles",
|
| 47 | AttributeType.ofInterpolated(
|
| 48 | AmbientParticle.CODEC.listOf(),
|
| 49 | AttributeModifier.listLibrary(),
|
| 50 | LerpFunction.ofListCrossFade((p, alpha) -> new AmbientParticle(p.particle(), p.probability() * alpha))
|
| 51 | )
|
| 52 | );
|
| 53 | AttributeType<BackgroundMusic> BACKGROUND_MUSIC = register("background_music", AttributeType.ofNotInterpolated(BackgroundMusic.CODEC));
|
| 54 | AttributeType<AmbientSounds> AMBIENT_SOUNDS = register("ambient_sounds", AttributeType.ofNotInterpolated(AmbientSounds.CODEC));
|
| 55 | AttributeType<MobSpawnSettings> MOB_SPAWN_SETTINGS = register(
|
| 56 | "mob_spawn_settings", AttributeType.ofNotInterpolated(MobSpawnSettings.CODEC, AttributeModifier.MOB_SPAWN_SETTINGS_LIBRARY)
|
| 57 | );
|
| 58 | Codec<AttributeType<?>> CODEC = BuiltInRegistries.ATTRIBUTE_TYPE.byNameCodec();
|
| 59 |
|
| 60 | static AttributeType<?> bootstrap(final Registry<AttributeType<?>> registry) {
|
| 61 | return BOOLEAN;
|
| 62 | }
|
| 63 |
|
| 64 | static <Value> AttributeType<Value> register(final String name, final AttributeType<Value> type) {
|
| 65 | Registry.register(BuiltInRegistries.ATTRIBUTE_TYPE, Identifier.withDefaultNamespace(name), type);
|
| 66 | return type;
|
| 67 | }
|
| 68 | }
|
| 69 |
|