diff options
author | jomo <github@jomo.tv> | 2014-06-10 06:01:59 +0200 |
---|---|---|
committer | jomo <github@jomo.tv> | 2014-06-10 06:01:59 +0200 |
commit | 0f44ad5c537dc775aaa055a31b5d9ac47fba01da (patch) | |
tree | 08dbe37e6074baf05eba369e82690ed4d7c7c0f7 /tilehelper.py | |
parent | 89d106967a8157628967d731e87cec833a052c8a (diff) |
handle right click
Diffstat (limited to 'tilehelper.py')
-rw-r--r-- | tilehelper.py | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/tilehelper.py b/tilehelper.py index fff30d1..98ee301 100644 --- a/tilehelper.py +++ b/tilehelper.py @@ -93,5 +93,31 @@ def onBreakBlockInRegion(event): @hook.event("player.PlayerInteractEvent", "low") def onClickBlockInRegion(event): - if not event.isCancelled(): - log("Interact: %s; %s" % (event.getClickedBlock(), event.getAction()))
\ No newline at end of file + action = event.getAction() + if not event.isCancelled() and str(action) == "RIGHT_CLICK_BLOCK": + player = event.getPlayer() + block = event.getClickedBlock() + for th in tilehelpers: + area = th.get("area") + if th.get("owner") == str(player.getUniqueId()) and str(block.getWorld().getUID()) == th.get("world") and block.getX() in range(area[0][0], area[0][1]+1) and block.getY() in range(area[1][0], area[1][1]+1) and block.getZ() in range(area[2][0], area[2][1]+1): + + # stack block in directions + for direction in th.get("directions"): + directions = dirmap[direction] + size = [ + 1 + abs(area[0][1] - area[0][0]), + 1 + abs(area[1][1] - area[1][0]), + 1 + abs(area[2][1] - area[2][0]) + ] + + newblock = block.getWorld().getBlockAt( + block.getX() + size[0] * directions[0], + block.getY() + size[1] * directions[1], + block.getZ() + size[2] * directions[2] + ) + + event = PlayerInteractEvent(event.getPlayer(), action, event.getItem(), newblock, event.getBlockFace()) + server.getPluginManager().callEvent(event) + if not event.isCancelled(): + newblock.setType(block.getType()) + newblock.setData(block.getData())
\ No newline at end of file |