I’ve just started my first plugin development, the plugin is supposed to change how frequent mobs spawn and what attributes they spawn with (for example 5x spawn rates of zombies, and a chace of gaining double health).
Reference: Is it possible to change the spawn rates of mobs with sponge and would anyone be willing to create a simple plugin for it?
So far i have made a working plugin (super early stage) and at this point the plugin can check for which mob spawned and if it’s a zombie then there is a chance of it having it’s name changed.
public void onEntitySpanw(EntitySpawnEvent event)
int roll = randInt(0,100);
if (roll > 90)
logger.info(“A super zombie just spawned!”);
event.getEntity().offer(Keys.DISPLAY_NAME, Texts.of(“Super Zombie”));
logger.info(“A regular zombie just spawned!”);
This code works just fine and once in a while a “super zombie” will spawn with the text above it’s head.
I use the .offer() to set the key DISPLAY_NAME, i can se that other keys like ATTACK_DAMAGE and HEALTH is available but these dosen’t work?
Q1: How can i make a certain type of mobs (zombies in this case) spawn more frequently?
Q2: How can i increase the monster cap? (if this is necessary)
Q3: How can i give other attributes to a mob other than name (damage, health other stuff)?
Edit1: Is it possible to check if a mob that spawned is naturally generated or spawned with https://docs.spongepowered.org/en/plugin/entities/spawning.html
Edit2: It would seem that it can be done with DataManipulators and the MobSpawnerData class… but im still having problems figuring out how to do this? does anyone have an example of how to use http://spongepowered.github.io/SpongeAPI/org/spongepowered/api/data/manipulators/MobSpawnerData.html
Might be tricky. But you could schedule a task. That could spawn mobs for you. But the logic that you will have to use to determine the mobs location might be a pain. I would try to use the player as reference.
Same thing as with spawning an entity.
Only you need to use the data api. Only use something like:
Here you can find a list of all the keys. Although autocompletion in your ide should show these to (ctrl + space).
I don’t think so. Might change in the future tho.
This manipulator is for the mob spawner only I think.
There isn’t any exposed API system for mob spawning, so while you can technically cancel all natural spawning and you could implement your own spawning system, it’s not likely to be optimal compared to an API that actually allows manipulation of spawning systems from the game.
Refer to Answer 1.
You can generally apply all sorts of “data” to an
Entity by using the Data API, either in
Key form or
DataManipulator form. You can refer to this thread on using the Data API as there have been many questions asked and answered.
There is work being done on this in the refactor/event-names branch that will refine not only events themselves, but also causes for events.
You generally can only use
MobSpawnerData with either a
MobSpawner tile entity or a
MobSpawnerMinecart entity. As answer 1 mentions, there is no API exposed system for natural spawning manipulation.
Thanks for the clairification, guess i’ll have to wait for the API implementation of these topics before i can move on with this (making my own spawning system dosen’t seem like the right solution).