[Ground] Item detection

Discussion in 'Plugin Development' started by jeffadkins51, Jul 6, 2011.

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

    jeffadkins51

    How can i detect if a item is on the ground? So say someone threw a sword on the ground And i wanted to detect the items in a certain radius?
     
  2. Offline

    Vynlar

    I have never worked with items like the little blocks on the ground, but I'm quite sure you have to set up a scan every few seconds, in the area you are looking for the items. It should look for entities because I believe that is what the items are and check to see of they are what it is scanning for. Sorry for being vague but that's is the general idea of what you need to do. Ill try and find time to look into the actual code tomorrow but no promises.
     
  3. Offline

    krinsdeath

    There's a few ways, I guess. It's going to be a combination of different events:

    Event.Type.ITEM_SPAWN (onItemSpawn(ItemSpawnEvent))
    Event.Type.PLAYER_DROP_ITEM (onPlayerDropItem(PlayerDropItemEvent))
    Event.Type.PLAYER_PICKUP_ITEM (onPlayerPickupItem(PlayerPickupItemEvent))
    Event.Type.PLAYER_MOVE (onPlayerMove(PlayerMoveEvent))

    You'll only need player move events if you want to track (and update) locations relative to the player (which may eat up resources)

    edit: What @Vynlar suggested may work as well. Setting up a timer to execute every so often and update locations relative to players (rather than every time a player moves), but this could cause even more lag if you handle the threads improperly.
     
  4. Offline

    jeffadkins51

    Well i dont want it to detect the items 'placed' by players, but by worldedit actually, so say i were to make a wall of mushrooms with worledit, then i want it to scan them items, that were generated
     
  5. Offline

    krinsdeath

    As far as hooking into WorldEdit, you're on your own. I've never done that, so I can't help. Best bet is to read sk89q's source code and check out how he builds the objects when he places them (it'll give you an idea of how to iterate over the object in code)

    Good luck!
     
  6. Offline

    Vynlar

    I don't think that world edit formally supports other plugins using its data, so it would get pretty complicated. Defiantly beyond me. >.>

    I hope you can get it working.

    Vynlar
     
Thread Status:
Not open for further replies.

Share This Page