Comments (14)
I guess you need to support lists? If not then you can type hint for a 3 element Tuple only.
That's actually a good idea. I'll keep the list support regarding the conversion to str, but will adjust the type hints to Tuple[int, int, int]
only.
from mcipc.
I just won't comment.
Well, you just did.
As there isn't even documentation at all
So what would you call the content of the README.md?
I am not saying that the current documentation isn't poor. But this is free software that I developed in my free time and give to you for free. If I find the time, I'll write some documentation on https://readthedocs.org/.
from mcipc.
Documentation is currently being developed on readthedocs.
You're welcome to contribute.
from mcipc.
@conqp this library is just what I've been looking for - it is great for educating kids on python since you have typed everything and IDE auto completion becomes very handy in exploring the possibilities.
Re documentation: I have as yet been unable to work out how to use data
and execute
from reading the code. Could you provide a couple of hints? I would contribute to your documentation on this subject if I could get it working.
Thanks.
from mcipc.
got data working
data = client.data.get(TargetType.ENTITY, "@p", "Pos")
(unfortunately the type hints can't autocomplete this)
from mcipc.
Thank you for the positive feedback.
The new methods introduced with mcipc-2.0 are a bit complex.
In general, I tried to preserve the structure from the official commands.
In cases where there is a signature like
command subcommand <value> [optional]
You'll need to run
client.command.subcommand(value, optional=optional)
A list of commands is available in the official Minecraft Wiki.
The execute
command is a bit special in the way, that it is self-recursive. I.e. you can chain execute commands.
So if you're done, you either invoke run(command, *args)
to execute another Minecraft command with the set environment or just run the chained command by calling it with ()
.
E.g. for the command /execute align xz
you'll run client.execute.align('xz')()
.
from mcipc.
Thanks, that is a helpful explanation. I've been having fun with this API today. When I have some nice working examples I could add them to your docs if you think that is useful.
By the way, I find I'm doing lots of vector math and that the built in Vec3 Tuple does not make this easy. Am I missing something? At present I keep converting back and forth to another type to do transformations etc.
from mcipc.
I'd appreciate any use case examples.
In all cases where the mcipc.rcon.types.Vec3
is expected within the RCON API, you can also use tuple
or list
objects of length 3 or any subclasses thereof: https://github.com/conqp/mcipc/blob/master/mcipc/rcon/functions.py#L72
You can also use instances of str
like "x y z"
, but this won't be useful for vector operations, I think.
In any case, the type hints I provided are no more than that: hints.
You can also always provide any other types that can be converted using str(value)
in a way so that the signature of the original Minecraft command is met.
from mcipc.
OK, again thanks. I've changed my vector math class to be a Named Tuple of 3 int and it works. BUT it grates on me because pylance (linter) complains I'm passing an incompatible type :-)
from mcipc.
I'll consider adjusting the type annotation to Union[tuple, list]
then. However, the original idea was to remind the user to pass in a tuple (or list) with length 3.
What type is vector
anyway? If it's a list or tuple like iterable, you can just convert it using Vec3(*start)
.
from mcipc.
I guess you need to support lists? If not then you can type hint for a 3 element Tuple only.
from mcipc.
Implemented in e9f663c.
from mcipc.
I see that you ended up hinting Vec3 as Union[Tuple[IntOrStr, IntOrStr, IntOrStr], str], allowing for coordinates of the form '~123'
I have also found myself using float coordinates, for example for exact positioning in the teleport command.
Is there merit in changing IntOrStr to NumOrStr = IntOrStr = Union[float, int, str] ?
EDIT: this does mean that Vec3 then needs to support floats and becomes a little complicated .
( I also see that Vec3 now has the functionality I needed anyway so I can use your class directly )
from mcipc.
I allowed floats for Vec2 and Vec3 in adcd02c.
from mcipc.
Related Issues (20)
- use of built in types for Type hints HOT 2
- Can not install via pip "No matching distribution found for mcipc" HOT 3
- I can't run the example program HOT 4
- TypeError: cannot convert 'NoneType' object to bytes HOT 3
- Linux Bug HOT 2
- Doesn't work anymore HOT 5
- Client.stats() (as depicted in readthedocs) refuses to work HOT 2
- Converting into dict() HOT 2
- Bedrock? HOT 3
- Python 3.8 HOT 1
- is async supporting? HOT 1
- TypeError: 'TypeVar' object is not callable HOT 2
- Long responses from commands are truncated and break the connection HOT 25
- Parsing NBT HOT 2
- Changes to behaviour of Item HOT 6
- I'm having problems creating the code HOT 1
- ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it HOT 1
- An existing connection was forcibly closed by the remote host HOT 3
- Error while attempting to run a command using RCON on a Minecraft Bedrock Server HOT 2
- Circular import error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mcipc.