-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Movement #62
Comments
from minecraft.networking.connection import Connection
from minecraft.networking.packets import PositionAndLookPacket
conn = Connection(...)
conn.connect()
...
packet = PositionAndLookPacket(x=..., feet_y=..., z=..., yaw=..., pitch=..., on_ground=...)
conn.write_packet(packet) Is this what you mean? See also: http://wiki.vg/Protocol#Player_Position_And_Look_.28serverbound.29 |
yes that's what I mean thannks m8 |
I tried to write packets passes but my character does not move |
do you send the teleport response? http://wiki.vg/Protocol#Teleport_Confirm also this might still help even though a lot of it is outdated |
@BloodySenpai It would be better to keep discussions on this repository to issues with pyCraft itself, rather than Minecraft's protocol in general. For the latter, #mcdevs on irc.freenode.net is a better forum. However, insofar as your problem relates to pyCraft's API, post your code or a minimal test case, and I'll have a look at it. |
I'm sorry I'm new to this so I wouldn't know. I just did what you sent as code |
import threading
import time
import math
from minecraft.networking.connection import Connection
from minecraft.networking.packets import PlayerPositionAndLookPacket
from minecraft.networking.packets import PositionAndLookPacket
# Protect objects accessed by multiple threads with a lock.
lock = threading.Lock()
# The player's current position and look direction.
pos_look = PlayerPositionAndLookPacket.PositionAndLook()
# This conditions occurs when the server sets (or resets) pos_look.
pos_look_set = threading.Condition(lock)
conn = Connection('localhost', username='User')
def h_position_and_look(packet):
with lock:
packet.apply(pos_look)
pos_look_set.notify_all()
conn.register_packet_listener(h_position_and_look, PlayerPositionAndLookPacket)
conn.connect()
# Wait until our initial position is set by the server.
with lock:
pos_look_set.wait()
while True:
# Every 1 tick (50ms):
time.sleep(0.05)
with lock:
# Rotate 1 degree to the right.
pos_look.yaw = (pos_look.yaw + 1.0) % 360.0
# Move forward 0.1m.
pos_look.x -= 0.1 * math.sin(pos_look.yaw * math.pi / 180.0)
pos_look.z += 0.1 * math.cos(pos_look.yaw * math.pi / 180.0)
conn.write_packet(PositionAndLookPacket(
x = pos_look.x,
feet_y = pos_look.y,
z = pos_look.z,
yaw = pos_look.yaw,
pitch = pos_look.pitch,
on_ground = True)) |
I just don't know how to use both chat and position at the same time. |
@BloodySenpai You will have to be more specific than that. It is possible to use chat and position packets at the same time, of course, but there are many ways that could be done. Did you get that type error from the code I posted? If so, please post a full stack trace. If not, you should post the code that is causing it. |
Is there any other way I can contact you? Like email or stuff like that? |
I'm use the example that they gave with library |
connection.register_packet_listener(print_chat, ChatMessagePacket,PlayerPositionAndLookPacket) |
@BloodySenpai The code you have posted there appears to be incomplete (and not properly indented or formatted), so I can't say much about it. You should post the full code you are using so that I can run it myself if I need to. However, the error you are getting is probably from the fact that you're using the uninitialised value of We can continue this conversation by email. Email me at |
hi , i'd check this code and added to my bot. it looks like work |
@yunfan If you're referring to the code from this comment, the reason you are being kicked for "flying" is most likely because this example assumes the player is initially standing on a flat surface large enough for the player to walk around in a circle, but in your world it ends up walking off the edge of a block and into the air. This example (and pyCraft in general) does not implement the physics required to remain on the ground while walking around. |
@joodicator thanks for the replying, after some trying, i got the same conclution, i'll check that later. also i havnt saw any event emiting examples, would you recommand some sample code for it? i intent to make a bot which could move and dig |
@yunfan start.py contains some basic examples of sending packets, which is what I interpret you to mean by "event emitting", but as far as I know nobody has used pyCraft to implement anything as advanced as a bot that walks around and digs. If you do choose to do this yourself, your experience might be valuable for others, though. |
@joodicator thanks, i already read the code again and again, and learnt a lot, but i do remember there was a python library which is event based and could emit your own event just like the js implementation by rom1514. but that library has stopped since 1.7.2 |
I don't understand how to send the packet to move character
The text was updated successfully, but these errors were encountered: