diff options
author | jomo <github@jomo.tv> | 2014-06-10 00:20:02 +0200 |
---|---|---|
committer | jomo <github@jomo.tv> | 2014-06-10 00:20:02 +0200 |
commit | e639f302f05c4aaf607e4309256677d5442fd3fe (patch) | |
tree | d806f0ae4e3213d8022a6170f08a4f2bf76a2709 /tilehelper.py | |
parent | b55c485c7d2f7097b72f8deeee81a4c0d36624d3 (diff) |
firing event in defined directions
Diffstat (limited to 'tilehelper.py')
-rw-r--r-- | tilehelper.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/tilehelper.py b/tilehelper.py index 7d24c53..2371e4e 100644 --- a/tilehelper.py +++ b/tilehelper.py @@ -2,9 +2,18 @@ import org.bukkit as bukkit import org.bukkit.event.block.BlockPlaceEvent as BlockPlaceEvent from helpers import * -tilehelpers = [ # Front Right Back Left Down Up - {"owner": "ae795aa8-6327-408e-92ab-25c8a59f3ba1", "area": [[90, 95], [60, 90], [90, 95]], "world": "b0385345-4803-4522-a06a-75fbd692928d", "directions": [True, True, True, True, False, False]} +tilehelpers = [ + {"owner": "ae795aa8-6327-408e-92ab-25c8a59f3ba1", "area": [[90, 95], [60, 90], [90, 95]], "world": "b0385345-4803-4522-a06a-75fbd692928d", "directions": "neswud"} ] +dirmap = { + # [x, y, z] + "n": [0, 0, -1], + "e": [1, 0, 0], + "s": [0, 0, 1], + "w": [-1, 0, 0], + "u": [0, 1, 0], + "d": [0, -1, 0] +} @hook.event("block.BlockPlaceEvent", "high") def onPlaceBlock(event): @@ -18,6 +27,13 @@ def onPlaceBlock(event): # stack block in directions msg(player, "&ayus") - event = BlockPlaceEvent(block, block.getState(), event.getBlockAgainst(), event.getItemInHand(), player, event.canBuild()) + for direction in th.get("directions"): + directions = dirmap[direction] + size = [area[0][1] - area[0][0], area[1][1] - area[1][0], area[2][1] - area[2][0]] + oldplaced = event.getBlockAgainst() - # server.getPluginManager().callEvent(event); + newblock = block.getWorld().getBlockAt(block.getX() + size[0] * directions[0], block.getY() + size[1] * directions[1], block.getZ() + size[2] * directions[2]) + newplaced = oldplaced.getWorld().getBlockAt(oldplaced.getX() + size[0] * directions[0], oldplaced.getY() + size[1] * directions[1], oldplaced.getZ() + size[2] * directions[2]) + + event = BlockPlaceEvent(newblock, block.getState(), newplaced, event.getItemInHand(), player, event.canBuild()) + server.getPluginManager().callEvent(event)
\ No newline at end of file |