-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathevent.py
More file actions
69 lines (52 loc) · 1.97 KB
/
event.py
File metadata and controls
69 lines (52 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from .vec3 import Vec3
class BlockEvent:
"""An Event related to blocks (e.g. placed, removed, hit)"""
HIT = 0
def __init__(self, type, x, y, z, face, entityId):
self.type = type
self.pos = Vec3(int(x), int(y), int(z))
self.face = face
self.entityId = entityId
def __repr__(self):
sType = {
BlockEvent.HIT: "BlockEvent.HIT"
}.get(self.type, "???")
return "BlockEvent(%s, %d, %d, %d, %s, %s)"%(
sType, self.pos.x, self.pos.y, self.pos.z, self.face, self.entityId)
@staticmethod
def Hit(x, y, z, face, entityId):
return BlockEvent(BlockEvent.HIT, x, y, z, face, entityId)
class ChatEvent:
"""An Event related to chat (e.g. posts)"""
POST = 0
def __init__(self, type, entityId, message):
self.type = type
self.entityId = entityId
self.message = message
def __repr__(self):
sType = {
ChatEvent.POST: "ChatEvent.POST"
}.get(self.type, "???")
return "ChatEvent(%s, %d, %s)" % (
sType, self.entityId, self.message)
@staticmethod
def Post(entityId, message):
return ChatEvent(ChatEvent.POST, entityId, message)
class ProjectileEvent:
"""An Event related to projectiles (e.g. placed, removed, hit)"""
HIT = 0
def __init__(self, type, x, y, z, face, shooterName,victimName):
self.type = type
self.pos = Vec3(int(x), int(y), int(z))
self.face = face
self.shooterName = shooterName
self.victimName = victimName
def __repr__(self):
sType = {
ProjectileEvent.HIT: "ProjectileEvent.HIT"
}.get(self.type, "???")
return "ProjectileEvent(%s, %d, %d, %d, %s, %s)" % (
sType, self.pos.x, self.pos.y, self.pos.z, self.shooterName, self.victimName)
@staticmethod
def Hit(x, y, z, face, shooterName,victimName):
return ProjectileEvent(BlockEvent.HIT, x, y, z, face, shooterName,victimName)