Missing features needed for the competition

I’m working on a plugin for the competition and I’m running into a lot of missing features that I need. I know that part of the objective is to identify areas that are needed or not working. Are these something that I should submit as defects in git or post somewhere on the forums?

Currently I need these features:

  • Delete a world. Looks like currently folks are only disabling the world, not removing it. I need to be able to recreate it as a new arena from time to time.
  • Customization of world generation. Specifically, I need to be able to change the biome size for the world I create.
  • Sub-command help text. I’m just getting the top-level command help repeated.
  • Event handling for when mobs target and damage players and other entities.

-R

Server.deleteWorld(WorldProperties)

WorldBuilder.generatorModifiers(WorldGeneratorModifier...)

DamageEntityEvent

Tried this. I don’t think it’s implemented yet because I get a:

java.lang.AbstractMethodError: net.minecraft.server.dedicated.DedicatedServer.deleteWorld(…)

Other plugins seem to only be disabling worlds right now, not deleting them.

Yeah. I’ve been poking around in there for a while now. I’ll need a bit more assistance on a concrete example.

I’ll try this event out again. Last time I did it didn’t work, but that may have recently changed.


Ok, I tried using this event. It is not a cancellable event so I tried reducing the damage to 0 instead. I did this by inverting the damage because from reading the docs it sounds like each of these is added to the base damage. It didn’t seem to even be called as I didn’t see any log messages at all. Here is what my handler method looks like:
method snippet

Thanks for your help!

Ah yes, DamageEntityEvent is not implemented yet, but is being worked on as we speak - see https://github.com/SpongePowered/SpongeAPI/compare/feature/damage-events and https://github.com/SpongePowered/SpongeCommon/compare/feature/damage-events

But until it’s ready, if the damage is caused by an interaction you can cancel the InteractEntityEvent

Yeah looks like deleteWorld is not implemented yet, I’ll get onto this soon.

You need to implement WorldGeneratorModifier, the modifyWorldGenerator is invoked when the world is generating. See the javadocs for more details.
Then register your implementation using GameRegistry.registerWorldGeneratorModifier
@Deamon worked on most of this system so he may be able to help more.
It could also be useful to read this description: Expand Populator System by Deamon5550 · Pull Request #544 · SpongePowered/SpongeAPI · GitHub

Thanks for the response. I’ve tried using the InteractEntityEvent, which is what I would prefer to use since it’s cancellable, but it’s not firing yet for mob interactions against the player.

I’ll take a look at the WorldGeneratorModifier and see if I can figure that out. I’m assuming that I would provide a custom implementation of a BiomeGenerator, is that correct?

In general, what is the preferred way for us plugin developers to indicate the problems we’re running into, through the forums or as github issues?

Thanks again!

I think so, though I have not looked at the generator things in detail
This thread has some relevant help -

It also looks like @Deamon has wrote some draft documentation

I suggest searching both, in case your issue has already been discussed and a solution was found.
If you’re not sure if your code is correct it’s common for people to ask on the forums or IRC and if there seems to be a problem with the implementation or something is missing from the API, a GitHub issue is best so it doesn’t get forgotten about.

1 Like

Here’s the implementation for deleteWorld you needed. Next time SpongeForge bumps the SpongeCommon reference it will be included in the server.

Thanks simon! I really appreciate your assistance.

Earlier when I asked about reporting issues, my main concern was how to communicate what things we need for the plugin competition, not necessarily general bugs and the like. Is the forum the best place for those kind of issues?

TBH just report it anywhere, we have enough eagle eyes watching over the forums/IRC/github that the message will be sent to the relevant people.
If it’s something missing then I’d suggest using github but it doesn’t really matter.

Ok, made some additional progress on the plugin today. Here are some of the features that don’t seem to work:

  • InteractEntityEvent on a monster when it attacks
  • SpawnEntityEvent on a monster or passive works at startup, but then over time they can spawn in
  • DisplaceEntityEvent for monster and passive movement
  • SpawnEntityEvent does not register spawn eggs (maybe, I’m not sure on this yet. is the player a cause when using spawn eggs?)
  • Had a weird instance where one creeper explosion was cancelled, but another happening right afterward still happened
  • When I despawned villagers, the zombies still think they’re there (removed by SpawnEntityEvent cancel). See the photo for humor.

  • InteractEntityEvent is currently only used when a player interacts with an entity. If you want non-player attacks then you will need to wait for DamageEntityEvent to be finished. However, there are definitely some cases where I can fire this event for non-players, I’ll have to look at it some more.
  • SpawnEntityEvent only working in some cases sounds strange. You need to provide your listener code.
  • DisplaceEntityEvent can do.
  • SpawnEntityEvent definitely works with spawn eggs. Again paste your listener code.
  • Cancelling explosion for a creeper only working the first time doesn’t make much sense. Paste your listener code.
  • Zombie villager issue i’ll have to look into.

Thanks blood. Btw, I really like the cause and event system so far. It has made handling a lot of these common events much easier (and less verbose) than it was in canary. My source code for the listeners can be found here:

To follow up on your comments:

  • I’d prefer to use InteractEntityEvent because I can just cancel it, but if I have to I suppose I could make the damage 0 using DamageEntityEvent. I’m assuming that one cannot be cancellable. Is there going to be an event that I can use to cancel mobs from targeting the player or other entities as well?
  • I think that there may be a conflict in my permissions checking on spawn eggs. I marked it in the source code with a comment. I think one of my other listeners is capturing it instead. I’ll do some testing.
  • On the creeper explosion, it was very strange. Several got cancelled in a row, but a third one happened in the same spot. I’m wondering if it is because of the closeness of the events and the like that one may not get registered.

Thanks!

Are your SpawnEntityEvent listeners supposed to stop those entities from spawning?
If so then doing final Optional<Monster> monster = event.getCause().first(Monster.class); is wrong: the cause is not the entity being spawned, rather, the cause is what made it spawn.
Instead, the actual entities being spawned are obtained using event.getEntities()

For spawn eggs, when the entity is spawned, the cause contains the player
i.e

@Listener
public void onEntitySpawn(SpawnEntityEvent event) {
    Optional<Player> optPlayer = event.getCause().first(Player.class);
    if (optPlayer.isPresent()) {
        System.out.println(optPlayer.get().getName() + " spawned " + event.getEntities());
    }
}

Printed simon8162 spawned [EntityCreeper['Creeper'/751024, l='world', x=-1292.50, y=4.00, z=1244.50]]
when I used a creeper egg

Next, I was rapidly spawning creepers with a dispenser and was able to cancel all explosions using the following code:


@Listener
public void onCreeperExplode(ExplosionEvent.Pre event) {
    if (event.getCause().first(Creeper.class).isPresent()) {
        event.setCancelled(true);
    }
}

I was not able to reproduce your issue with Zombies and Villagers.
I set up a setup like you’ve shown, used the following code:

    @Listener
    public void onEntitySpawn(SpawnEntityEvent event) {
        for (Entity entity : event.getEntities()) {
            if (entity instanceof Villager) {
                event.setCancelled(true);
                return;
            }
        }
    }

Tried to spawn a villager in the cradle - it didn’t spawn and the zombies bellow didn’t react