-
Notifications
You must be signed in to change notification settings - Fork 243
Directional Support for turtle.place #2265
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
base: mc-1.20.x
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for PR! Especially all the tests — it's relaly, really appreciated! Apologies for taking so long to look at this — laptop died on me, so haven't been able to run Minecraft for the past few weeks :/.
When this was first discussed in #204, I did have some worries about how many edges cases we'd have to handle here. I think this is definitely better than I was expecting, but there are always going to be edge cases. I wonder if there should be an API method to register the block-state transforms (e.g. ComputerCraftAPI.registerOrientationProvider(Block, BiFunction<BlockState, OrientationParameters, BlockState>
).
A couple of other smaller thoughts:
-
I'm in mixed minds about the cardinal direction specifiers (
north
,south
, etc...). CC:T generally tries to avoid using any absolute positions. However, block states are a bit of a special case, as they're available withturtle.inspect()
.My instinct is to remove them, but happy to discuss further!
-
The relative directions are sometimes flipped. Doing
turtle.place("left")
with a monitor, turtle or dispenser ends up placing a block facing to the right. Wired modems do face the right way, so I suspect they're inconsistent in some annoying way :/. -
I wonder if we could merge some of the other specifiers? e.g.
upside_down
andup
;bottom
andground
. -
There's some ambiguity here whether
turtle.place("left")
on a sign should place a sign with the text "left", or place a sign facing to the left. I wonder if it we should instead haveturtle.place
accept a table, so you doturtle.place { facing = { "left" }
(also accepting asign_place
argument, so you can doturtle.place { facing = { "left", "ground" }, text = "hello!" }
).As part of this, it probably makes sense to do the parsing when the
TurtleAPI
function is called, and just pass the orientation/text parameters to the place command.
projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java
Outdated
Show resolved
Hide resolved
projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java
Outdated
Show resolved
Hide resolved
projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java
Outdated
Show resolved
Hide resolved
Hey thanks for the review!
|
…d Orientation Provider for mod specific behavior overrides, Consolidated Parameters, Moved Parsing to API level.
Added support for the following parameters in the turtle.place function.
north, south, east, west these are self explanatory.
face_up, and face_down are for things like dispensers, though you can also use it for something like a modem for example.
left, right, up, down just calculate the cardinal direction relative to the turtles facing direction.
top, bottom for things like slabs
ground for things like torches when you don't want to place them against a wall
upside_down for stairs
you can pass multiple for example turtle.place("upside_down", "north")
if it cant resolve the orientation, cant apply them to a block, or no parameters are passed it falls back to the previous placement logic so nothing should change for existing programs.
Directionality seems to be handled differently by different sets of blocks for some reason.
logs use axis, shulkers use facing, furnaces use horizontal facing, modems use their own enum, stairs use half, slabs use type
tried to account for all the variation, there may be a better way feel free to discuss.
Happy to accept criticism or pointers! Thanks!