2021-07-27 09:40:57 +02:00
|
|
|
package net.minestom.server.item;
|
|
|
|
|
|
|
|
import net.minestom.server.instance.block.Block;
|
|
|
|
import net.minestom.server.registry.ProtocolObject;
|
|
|
|
import net.minestom.server.registry.Registry;
|
|
|
|
import net.minestom.server.utils.NamespaceID;
|
2021-07-27 10:28:06 +02:00
|
|
|
import org.jetbrains.annotations.ApiStatus;
|
2021-07-27 09:40:57 +02:00
|
|
|
import org.jetbrains.annotations.Contract;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
2021-07-27 10:28:06 +02:00
|
|
|
@ApiStatus.NonExtendable
|
2021-07-27 09:40:57 +02:00
|
|
|
public interface Material extends ProtocolObject, MaterialConstants {
|
2021-07-28 14:29:28 +02:00
|
|
|
|
2021-07-27 09:40:57 +02:00
|
|
|
/**
|
|
|
|
* Returns the material registry.
|
|
|
|
*
|
|
|
|
* @return the material registry
|
|
|
|
*/
|
|
|
|
@Contract(pure = true)
|
|
|
|
@NotNull Registry.MaterialEntry registry();
|
|
|
|
|
|
|
|
@Override
|
|
|
|
default @NotNull NamespaceID namespace() {
|
|
|
|
return registry().namespace();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
default int id() {
|
|
|
|
return registry().id();
|
|
|
|
}
|
|
|
|
|
|
|
|
default int maxStackSize() {
|
|
|
|
return registry().maxStackSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
default boolean isFood() {
|
|
|
|
return registry().isFood();
|
|
|
|
}
|
|
|
|
|
|
|
|
default boolean isBlock() {
|
|
|
|
return registry().block() != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
default Block block() {
|
|
|
|
return registry().block();
|
|
|
|
}
|
|
|
|
|
|
|
|
default boolean isArmor() {
|
|
|
|
return registry().isArmor();
|
|
|
|
}
|
|
|
|
|
|
|
|
default boolean hasState() {
|
|
|
|
if (this == BOW || this == TRIDENT || this == CROSSBOW || this == SHIELD) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return isFood();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static @NotNull Collection<@NotNull Material> values() {
|
2021-07-30 15:08:06 +02:00
|
|
|
return MaterialImpl.values();
|
2021-07-27 09:40:57 +02:00
|
|
|
}
|
|
|
|
|
2021-07-28 14:29:28 +02:00
|
|
|
static @Nullable Material fromNamespaceId(@NotNull String namespaceID) {
|
2021-07-30 15:08:06 +02:00
|
|
|
return MaterialImpl.get(namespaceID);
|
2021-07-27 09:40:57 +02:00
|
|
|
}
|
|
|
|
|
2021-07-28 14:29:28 +02:00
|
|
|
static @Nullable Material fromNamespaceId(@NotNull NamespaceID namespaceID) {
|
2021-07-27 09:40:57 +02:00
|
|
|
return fromNamespaceId(namespaceID.asString());
|
|
|
|
}
|
|
|
|
|
|
|
|
static @Nullable Material fromId(int id) {
|
2021-07-30 15:08:06 +02:00
|
|
|
return MaterialImpl.getId(id);
|
2021-07-27 09:40:57 +02:00
|
|
|
}
|
|
|
|
}
|