Dispenser Event/Events

Discussion in 'Plugin Development' started by Kaimane, Apr 5, 2011.

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

    Kaimane

    Hi,

    are there dispenser events that allow you check if a dispenser did dispense an item? Or at least a possibility to check if the dispensers storage has changed through dispensing?
     
  2. Offline

    Zeroth

    I would also love to know about this.
    From what I've researched today, there's no easy way to even see if a Dispenser has redstone charge. Using BlockRedstoneChange event, you can check to see if adjacent blocks have a dispenser which is what I'm working on right now.
     
  3. Offline

    Carbunkulous

    Bump this up, I need a resolution to this too... :3 Anyone have any ideas? (Without linking to craftbukkit preferably)

    EDIT: Managed to get something that works... not entirely sure how efficient it is :S

    PHP:
        private BlockListener bl = new BlockListener() {
            public 
    void onBlockRedstoneChange(BlockRedstoneEvent event) {
                
    Block target event.getBlock();
                
    Location loc target.getLocation();
                for (
    int _x=-1;_x<=1;_x++){
                    for (
    int _y=-1;_y<1;_y++){
                        for (
    int _z=-1;_z<=1;_z++){
                        if (
    _z+_x == || _z+_x == -1)
                                        if (
    target.getWorld().getBlockAt(loc.getBlockX()+_x,loc.getBlockY()+_y,loc.getBlockZ()+_z).getState().getType() == Material.DISPENSER){
                                            
    Dispenser myDis = (Dispensertarget.getWorld().getBlockAt(loc.getBlockX()+_x,loc.getBlockY()+_y,loc.getBlockZ()+_z).getState();
    //myDis = the dispenser that is activated.
                                        
    }
                        }
                    }
                }

            }
        };
    It's not 100% accurate as far as edge-case scenerios, but that would make it even more heavy per redstone change. I'm afraid this is going to be very slow though :(
     
  4. Offline

    fullwall

    I think there are dispenser events now.
     
  5. Offline

    Zeroth

    Yeah, check the latest version. They recently added in the events.
     
Thread Status:
Not open for further replies.

Share This Page