summaryrefslogtreecommitdiff
path: root/tilehelper.py
diff options
context:
space:
mode:
authorjomo <github@jomo.tv>2014-06-10 03:10:10 +0200
committerjomo <github@jomo.tv>2014-06-10 03:10:10 +0200
commit36e8b490904bf6f348f5b4756676f2077b2c642c (patch)
tree01d8a487cf23ff0765c35a0229af507bd6dcb746 /tilehelper.py
parenta32ced6fd55a384f70dd6eb9bc51847e5e248292 (diff)
changing blockstate
Diffstat (limited to 'tilehelper.py')
-rw-r--r--tilehelper.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/tilehelper.py b/tilehelper.py
index 10b6a88..6701ed2 100644
--- a/tilehelper.py
+++ b/tilehelper.py
@@ -7,19 +7,19 @@ tilehelpers = [
]
dirmap = {
# [x, y, z]
- "n": [0, 0, -2],
- "e": [1, 0, 0],
- "s": [0, 0, 1],
- "w": [-2, 0, 0],
- "u": [0, 1, 0],
- "d": [0, -2, 0]
+ "n": [0, 0, -1],
+ "e": [+1, 0, 0],
+ "s": [0, 0, +1],
+ "w": [-1, 0, 0],
+ "u": [0, +1, 0],
+ "d": [0, -1, 0]
}
# FIXME: disallow multiple regions by single person.
# FIXME: could lead to two regions updating each other forever -> server freezes
@hook.event("block.BlockPlaceEvent", "high")
-def onPlaceBlock(event):
+def onPlaceBlockInRegion(event):
if not event.isCancelled():
player = event.getPlayer()
block = event.getBlockPlaced()
@@ -28,17 +28,20 @@ def onPlaceBlock(event):
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) and event.canBuild():
# stack block in directions
- msg(player, "&ayus")
+ msg(player, "&aplaced block in region")
for direction in th.get("directions"):
directions = dirmap[direction]
- size = [1 + area[0][1] - area[0][0], 1 + area[1][1] - area[1][0], 1 + area[2][1] - area[2][0]]
+ 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])]
oldplaced = event.getBlockAgainst()
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])
+ newstate = newblock.getState()
+ newstate.setType(block.getType())
event = BlockPlaceEvent(newblock, block.getState(), newplaced, event.getItemInHand(), player, event.canBuild())
server.getPluginManager().callEvent(event)
+ msg(player, "Direction %s: %s" % (direction, event.isCancelled()))
if not event.isCancelled():
newplaced.setType(block.getType()) \ No newline at end of file