Block redstone change.

Discussion in 'Plugin Development' started by WinSock, Feb 6, 2011.

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

    WinSock

    Is there any way to block a change in redstone state? I'm trying to block a door from being able to be opened by redstone.

    Here is what i'm trying but not working:

    Code:
    @Override
    	public void onBlockRedstoneChange(BlockFromToEvent event) {
    		Block changedBlock = event.getBlock();
    
    		if (changedBlock.getType() == Material.WOODEN_DOOR) {
    			World blockWorld = changedBlock.getWorld();
    			Block DoorBlock = blockWorld.getBlockAt(changedBlock.getX(),
    					changedBlock.getY() + 1, changedBlock.getZ());
    			// For when someone clicks the bottom of the door
    			if (DoorBlock.getType() != changedBlock.getType()) {
    				DoorBlock = blockWorld.getBlockAt(changedBlock.getX(),
    						changedBlock.getY(), changedBlock.getZ());
    			}
    
    			String loc = Messages.getString("DoorBlockListener.31"); //$NON-NLS-1$
    			loc += String.valueOf(DoorBlock.getX())
    					+ Messages.getString("DoorBlockListener.32"); //$NON-NLS-1$
    			loc += String.valueOf(DoorBlock.getY())
    					+ Messages.getString("DoorBlockListener.33"); //$NON-NLS-1$
    			loc += String.valueOf(DoorBlock.getZ());
    			DoorObject DoorObj = plugin.doorHandler.getDoorObject(loc);
    
    			if (DoorObj != null) {
    				event.setCancelled(true);
    			}
    		}
    	}
    
     
  2. Offline

    robhol

    For the door itself? No, I don't think so. The closest you can get is checking if the wire being changed, but... why would you do this?
     
Thread Status:
Not open for further replies.

Share This Page