Solved How does one convert entity types to/from Skript

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

jaylawl

Active Member
Jan 29, 2017
173
31
0
33
So i'm trying to get the entity type that is being spawned by a mob spawner tile entity.

Using this will return the Bukkit entity type just fine:
Java:
BlockState state = block.getState();
CreatureSpawner spawner = (CreatureSpawner) state;
return spawner.getSpawnedType();

However i'm unsuccessful with converting it to a skript entity type.
I have found this "method" (which doesn't feel like the right way), which returns the correct Skript entity type IF the name of the entity consists of only one word, otherwise it returns null:
Java:
import ch.njol.skript.entity.EntityType;

BlockState state = block.getState();
CreatureSpawner spawner = (CreatureSpawner) state;
return EntityType.parse(spawner.getSpawnedType().toString());

So i'm wondering, what's the correct method to convert skript entity type to/from bukkit entity type?

Cheers

/edit:
Doing some messing around, this works, but it feels even more hacky and incorrect:
Java:
return EntityType.parse(spawner.getSpawnedType().toString().replace("_", " "));
 
Last edited:
The real question is: why are you trying to convert it to a skript entity?
Because i'm trying to make an expression for the mob spawned by mob spawner tile entities. The return must be a skript entity type, and the input must be a bukkit entity type (enum).
 
Because i'm trying to make an expression for the mob spawned by mob spawner tile entities. The return must be a skript entity type, and the input must be a bukkit entity type (enum).
Java:
return EntityData.fromClass(entityType.getEntityClass());
The return type must be an EntityData by the way.
 
Java:
return EntityData.fromClass(entityType.getEntityClass());
The return type must be an EntityData by the way.
What will this do? So the entire thing has to be EntityData instead of EntityType?

nevermind the topic