-
Notifications
You must be signed in to change notification settings - Fork 3
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
How to get available block types and set block orientation? #1
Comments
I used a Python script to open the minecraft.jar file and retrieve all the available blocks from the blockstates folder. I extracted the list of blocks and printed them to see what's available. However, even though I have the list, I haven't been able to orient blocks like stairs in any direction other than the default (north), and I'm struggling to change their orientation. After all that, I found this URL with all the block data values: https://minecraft.wiki/w/Java_Edition_data_values/Blocks, which had everything I was looking for that I somehow missed earlier! Haha. |
Hi there 👋 Regarding the block list: For example, on Ubuntu/Linux with the Prism Launcher, the blocks would be at: Or on Windows with the Legacy Minecraft Launcher, the blocks would be at: This does potentially not include blocks added with mods, which can be placed with their namespace and block id, e.g., I believe this would make a great feature to query all available blocks directly using mcpq, I'll add it to the next protocol version 👍 Regarding the block orientation: Block orientation is block states, which I would recommend to set with a command explicitly at the moment: pos = Vec3(<x>, <y>, <z>).floor()
mc.runCommand(f"setblock {pos.x} {pos.y} {pos.z} minecraft:spruce_stairs[facing=south]") This is somewhat unfortunate as it is much more complicated than it has to be, but you could put this into a new function like so: def build(world, block, pos, states: dict[str, str] | None = None):
pos = pos.floor()
if states is None:
world.setBlock(block, pos)
else:
states_list = ",".join(f"{key}={val}" for key,val in states.items())
world.runCommand(f"setblock {pos.x} {pos.y} {pos.z} {block}[{states_list}]")
build(mc, "spruce_stairs", pos)
build(mc, "spruce_stairs", pos, {"facing": "east", "waterlogged": "true"}) This way you could call it with a dict of property values and use it as a replacement for regular Most things that are currently missing can be simulated using /-commands in this way, until they are natively supported by the protocol. PS: For example, the same method is used to implement the |
Perfect, I'll be using runCommand() to build for now. |
Hello,
I have successfully placed blocks using the following command:
mc.setBlock("obsidian", pos)
I have two questions:
Is there any command or method available to get a list of all the block types that I can use with setBlock()? Because now I can't use numbers to guess.
How can I place blocks that need to face a specific direction, such as stairs? Is there a way to specify the orientation when placing these blocks?
Thank you for your help!
The text was updated successfully, but these errors were encountered: