Skip to content
Shane Bee edited this page May 3, 2026 · 1 revision

Setting up a new Type (ClassInfo) is really simple and straight forward.
In this example, I'm going to use a ClassInfo already registered, just to show how it's done.

public class Types {

    private static final Map<Identifier, EnvironmentAttribute> ATTRIBUTE_MAP = new TreeMap<>();

    public static void register(Registration reg) {

        // It's a good habit to make sure this type isn't already registered by another Addon/Skript
        // This example is copied from SkBee and uses a Registry type
        if (Classes.getExactClassInfo(EntityType.class) == null) {
            reg.newRegistryType(Registry.ENTITY_TYPE, EntityType.class, "minecraftentitytype")
                .user("minecraft ?entity ?types?")
                .name("Minecraft - EntityType")
                .description("Represents a Minecraft entity.",
                    "These differ slightly from Skript's EntityType as the names match Minecraft namespaces.",
                    "These also support the use of the Minecraft namespace as well as underscores.", Util.AUTO_GEN_NOTE)
                .examples("mc spawn sheep at player",
                    "mc spawn minecraft:sheep at player",
                    "mc spawn minecraft:armor_stand at player")
                .after("entitydata", "entitydata")
                .since("1.0.0")
                .register();
        } else {
            Utils.error("It looks like another addon registered 'minecraftEntityType' already.");
            Utils.error("You may have to use their Minecraft EntityType in MyAddon's syntaxes.");
        }

        // This example is copied from SkBee and uses an Enum type
        if (Classes.getExactClassInfo(Pose.class) == null) {
            reg.newEnumType(Pose.class, "pose", null, "pose")
                .user("poses?")
                .name("Entity Pose")
                .description("Represents the pose of an entity.")
                .since("1.0.0")
                .register();
        } else {
            Utils.error("It looks like another addon registered 'pose' already.");
            Utils.error("You may have to use their Pose in MyAddon's syntaxes.");
        }

        // This example is copied from SkBee and uses a regular type
        if (Classes.getExactClassInfo(NamespacedKey.class) == null) {
            reg.newType(NamespacedKey.class, "namespacedkey")
                .user("namespacedkeys?")
                .name("NamespacedKey")
                .description("NamespacedKeys are a way to declare and specify game objects in Minecraft,",
                    "which can identify built-in and user-defined objects without potential ambiguity or conflicts.",
                    "For more information see [**Resource Location**](https://minecraft.wiki/w/Resource_location) on McWiki.")
                .since("1.0.0")
                .serializer(new Serializer<>() {
                    @Override
                    public @NotNull Fields serialize(NamespacedKey namespacedKey) {
                        Fields fields = new Fields();
                        fields.putObject("key", namespacedKey.toString());
                        return fields;
                    }

                    @Override
                    public void deserialize(NamespacedKey o, Fields f) {
                    }

                    @Override
                    protected NamespacedKey deserialize(Fields fields) throws StreamCorruptedException {
                        String key = fields.getObject("key", String.class);
                        if (key == null) {
                            throw new StreamCorruptedException("NamespacedKey string is null");
                        }
                        return NamespacedKey.fromString(key);
                    }

                    @Override
                    public boolean mustSyncDeserialization() {
                        return true;
                    }

                    @Override
                    protected boolean canBeInstantiated() {
                        return false;
                    }
                })
                .register();
        } else {
            Util.logLoading("It looks like another addon registered 'namespaced key' already.");
            Util.logLoading("You may have to use their NamespacedKeys in SkBee's synaxes.");
        }
    }

}

Clone this wiki locally