From 13164223ebc60bbe76fcc43563e8149d7135e664 Mon Sep 17 00:00:00 2001 From: Tu Nombre Date: Thu, 14 Feb 2019 14:19:01 -0300 Subject: [PATCH] Added a dirty way to detect jumping (sprint-jumping does not work yet) --- __main__.py | 10 +++++++++- plugins/PlayerMove/__init__.py | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/__main__.py b/__main__.py index 46a2e5d..22f3684 100644 --- a/__main__.py +++ b/__main__.py @@ -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) @@ -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(): diff --git a/plugins/PlayerMove/__init__.py b/plugins/PlayerMove/__init__.py index 45f59c0..7047b3a 100644 --- a/plugins/PlayerMove/__init__.py +++ b/plugins/PlayerMove/__init__.py @@ -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)