Hello, i want to create a Command where you can Spawn All Entitys and you can enter an amount. Example: /sm list -> Shows a List of all Entitys /sm <EntityName> <Amount> -> Spawns Entitys /sm remove <Radius> -> Removes all Entitys in the Following Radius The thing is i dont know How to send the Player a list of all Entitys (Example Viedeo (4:47)) and i dont know how to make that the player really removes the Entitys in this Radius. Thanks to all Helps.
1) get a List of Entities: Code (Java): Player#getNearbyEntities(x, y, z); 2) remove entities: Code (Java): nearbyEntities.forEach(Entity::remove);
I dont want to get Nearby Entitys i want to get a list of all aviable entitys in minecraft like in the example viedeo
In this viedeo he uses this: Code (Java): String text = ""; byte b; int i; EnumParticle[] arrayOfEnumParticle; for (i = (arrayOfEnumParticle = EnumParticle.values()).length, b = 0; b < i; ) { EnumParticle pa = arrayOfEnumParticle[b]; if (text.equals("")) { text = pa.name(); } else { text = String.valueOf(text) + ", " + pa.name(); } b++; } And i want to use it like this but instead of Particle names Entity Names
When i make p.sendMessage("Entity Liste: " + EntityType.values()); it shows me this in chat: http://prntscr.com/qshp96
You need to wrap it using Arrays#toString to print a readable String: Code (Java): p.sendMessage("Entity Liste: " + Arrays.toString(EntityType.values()));
I got it, but i have thinked i know how to spawn the Entity that i Type in the chat but i dont know it makes an error and how does i set the amount ? I have used this: p.getWorld().spawnEntity(p.getLocation(), args[0]);
To the best of my knowledge you need to loop however many times you'd like to spawn entities. Also you need to cast args[0] to an EntityType (or Entity, forget which offhand)
EntityType entity = args[0]; p.getWorld().spawnEntity(p.getLocation(), entity); Eclipse tell me: Type mismatch: cannot convert from String to EntityType
You need to cast it to an EntityType (or Entity, again forget which offhand). You cannot set an EntityType = to a string. I recommend you take a basic Java course and look through this thread too
*Sigh* there's everything you need already here... Code (Java): p.getWorld().spawnEntity(p.getLocation(), EntityType.valueOf(args[0]));
Ok a BIG thanks for that! Now i have a problem. I looked over the Javadoc and im not able to find a way to define the amount of entitys that be spawn.