Monster teleport on pressureplate

Discussion in 'Archived: Plugin Requests' started by Dimpan, Apr 27, 2013.

  1. Offline

    Dimpan

    Plugin category: Teleportation

    Suggested name: MonsterTeleporter(?)

    What I want: I'd like to know if there is (or possibly can be created) a plugin that teleports monsters when they walk on a pressureplate.

    Much like other teleportation mods out there that has the option to tele through pressureplates except that it should work for monsters.

    Zombie walks on pressure plate and gets teleported to an area linked to that pressure plate.

    Ideas for commands:
    /mt create name (makes the position you stand on the one you will be teleported to)
    /mt link name (while looking at the pressure plate)
    As I said, much like other teleportation plugins except that this will work for monsters and not players :)

    Ideas for permissions: monsterTeleporter.create: true

    When I'd like it by: ASAP, if there is already one like this out there please link me to it.
    I have been searching for one but have not been able to find it
     
  2. Offline

    Celeo

    The main reason I can think of barring such a plugin from working well is that there is no move event for mobs, only players. To do this, the plugin would have to run a check every so often, looping through all mobs on the server, to see if any are atop a pressure plate. It would not be a smooth as when a player walks over a pressure plate.
     
  3. Offline

    Dimpan

    Okey I see, well thank you for the fast answer! :)
     
  4. Online

    timtower Administrator Administrator Moderator

    Celeo Isn't there an redstone update event for the pressure plate?
     
  5. Offline

    Celeo

    Yes, and then the plugin would have to loop through the entities in that world and determine which was the closest to the plate.
     
  6. Online

    timtower Administrator Administrator Moderator

    Celeo There is an entity in range check you know that?
     
  7. Offline

    Celeo

    Show me.
     
  8. Online

    timtower Administrator Administrator Moderator

    Celeo You are right, was confused with this one :
    Code:
    List<org.bukkit.entity.Entity> org.bukkit.entity.Entity.getNearbyEntities    (    double      x,
            double      y,
            double      z
        )       
     
    Returns a list of entities within a bounding box centered around this entity.
     
    Parameters
        x    1/2 the size of the box along x axis
        y    1/2 the size of the box along y axis
        z    1/2 the size of the box along z axis
     
    Returns
        List<Entity> List of entities nearby
    
     
  9. Offline

    SeiZon

    Is it not possible to get the coordinates of the redstone event, and then simply crosscheck with a list of known teleporting pressure pads, and then access the pressure pad object that way?
     
  10. Online

    timtower Administrator Administrator Moderator

    SeiZon You also need the entity that is on the pressure plate, that is the hard part
     
  11. Offline

    SeiZon

    Meh, wasn't that hard really. I have made a quick and dirty test, which works just fine.
    Procedure: Log location of pressure plate.
    On redstone event, check which location it's coming from and crosscheck with list of telepads.
    Then get all entities in the current chunk, and find the ones near the telepad that is an instance of a Monster entity, then teleport it.
    Code:
    ArrayList<Entity> entities = (ArrayList<Entity>) telepad.getLocation().getWorld().getEntities();
            for (Entity en : entities) {
                if (en.getLocation().distance(telepad.getLocation()) <= 2 && en instanceof Monster) {
                    getLogger().info("" + en.getClass().toString());
                    en.teleport(telepad.getTeleportLocation());
                }
            }
    Things to fix, which I didn't bother with, as this was only a test, is to strangle the next redstone event which comes from that telepad, as a pressure plate fires two events. Also to round the radius out, as it checks from the corner of the plate.

    If you want, I can polish this off and release it at some point when I get time.
     

Share This Page