Skip to content

Commit

Permalink
Added a dirty way to detect jumping
Browse files Browse the repository at this point in the history
(sprint-jumping does not work yet)
  • Loading branch information
FranchuFranchu committed Feb 14, 2019
1 parent d6e30fc commit 1316422
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def player_joined(self):
self.send_empty_chunk(i,j)

# make a small parkour
self.x,self.y,self.z = (0,101,0)
self.send_block_change(0,100,0,1)
self.send_block_change(2,101,0,2)
self.send_block_change(5,101,-1,3)
Expand All @@ -128,11 +129,18 @@ def handle_command(self, command_string):
command, arguments = command_list[0], command_string.split(" ")[1:] # Get command and arguments
self.plugin_event("player_command", command, arguments)
def packet_player_look(self,buff):
self.xr,self.yr,_ = buff.unpack('ffb')
self.xr,self.yr,self.on_ground = buff.unpack('ffb')
def packet_player_position(self, buff):
self.pon_ground = True

x, y, z, self.on_ground = buff.unpack('dddb') # X Y Z - coordinates, on ground - boolean
print(self.y-y)
self.x,self.y,self.z = (x,y,z)


#print(x,y,z,on_ground)
self.plugin_event("player_move", x, y, z,self.on_ground)

#self.position.set(x, y, z)
# Currently don't work
'''for eid,player in players.iteritems():
Expand Down
7 changes: 7 additions & 0 deletions plugins/PlayerMove/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

def player_move(p,x=0,y=0,z=0,xr=0,yr=90,on_ground=None,player=None):
#print(p.y-y,p.on_ground)
if p.on_ground:
p.set_position(x,y,z)
else: # if the player is not on ground
if not p.flying: # and is not flying
if p.y-y < 0 and p.y-y > -1: # and before this packet was sent he was 0 to 1 blocks higher
self.falling_time=p.y-y/0.02 #0.02 seems to be the proportion between the initial height distance and the ticks the player will continue falling
p.x,p.y,p.z,p.on_ground = (x,y,z,on_ground)

0 comments on commit 1316422

Please sign in to comment.