onEntityCollision event?

Discussion in 'Plugin Development' started by sddddgjd, Sep 5, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    sddddgjd

    Not sure if something like this exists, probably not, but it would be VERY usefull!
    It would get fired when an entity touches another entity,or a solid block...
    I have a couple of plugins in development which could really use that... what do you guys think?
     
  2. They don't even register on entity move so I doubt it.
     
  3. Offline

    sddddgjd

    onPlayerCollision,then? :D
    Wouldn't be as good,but still usefull...
     
  4. Hmm yeah, I could probably write a custom event for it :p
     
    sddddgjd likes this.
  5. Offline

    bergerkiller

    It's so simple to add entity block collisions (I mean, this is in the ENTITY class....)
    Code:
                // CraftBukkit start
                if ((this.positionChanged) && (this.getBukkitEntity() instanceof Vehicle)) {
                    Vehicle vehicle = (Vehicle) this.getBukkitEntity();
                    org.bukkit.block.Block block = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height), MathHelper.floor(this.locZ));
    
                    if (d5 > d0) {
                        block = block.getRelative(BlockFace.SOUTH);
                    } else if (d5 < d0) {
                        block = block.getRelative(BlockFace.NORTH);
                    } else if (d7 > d2) {
                        block = block.getRelative(BlockFace.WEST);
                    } else if (d7 < d2) {
                        block = block.getRelative(BlockFace.EAST);
                    }
    
                    VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block);
                    this.world.getServer().getPluginManager().callEvent(event);
                }
                // CraftBukkit end
    Why did they even check if it was a vehicle and subdivide? Makes no sense to me -.-
     
  6. Offline

    sddddgjd

    It's for minecarts...there's a plugin that lets you create minecart trains,which uses this!
    They couldn't do it for all entities,because it would cause lag...
     
  7. Offline

    bergerkiller

    Unless they used a buggy event system with overhead delay, it would be a bad system. In theory calling another function should take 0.00 ms delay. If they used HashMaps in their events, yeah, then it would cause issues.
     
Thread Status:
Not open for further replies.

Share This Page