minecraft-src/net/minecraft/core/component/DataComponentGetter.java
2025-07-04 03:45:38 +03:00

19 lines
569 B
Java

package net.minecraft.core.component;
import org.jetbrains.annotations.Nullable;
public interface DataComponentGetter {
@Nullable
<T> T get(DataComponentType<? extends T> component);
default <T> T getOrDefault(DataComponentType<? extends T> component, T defaultValue) {
T object = this.get(component);
return object != null ? object : defaultValue;
}
@Nullable
default <T> TypedDataComponent<T> getTyped(DataComponentType<T> component) {
T object = this.get(component);
return object != null ? new TypedDataComponent<>(component, object) : null;
}
}