3

I'm trying to create a function that will generate a door, with random material, orientation and hinge placement. I have tackled the RNG part already, but cannot find a way to incrementally build the door so that I don't have to manually write down all of the possible combinations (aka 96 carefully-written commands).

I'm currently trying to achieve the following sequence:

  • Roll the RNG to select the material for the next command
  • fill ~ ~ ~ ~ ~1 ~ minecraft:<?>_door replace
  • <set half = upper at ~ ~1 ~>
  • Roll for orientation
  • <set facing = <?> at ~ ~ ~>, <set facing = <?> at ~ ~1 ~>
  • Roll for hinge placement
  • <set hinge = <?> at ~ ~ ~>, <set hinge = <?> at ~ ~1 ~>

What I'm missing is the imaginary <set state at> command. I've gathered that setblock has some ability to update existing blocks but this seems to be both unreliable and restricted to tile entities, and requires to know what block exactly I'm replacing. data is also explicitly restricted to tile entities.

How can I change the block state of an existing, unknown block?

1 Answer 1

1

Sadly this is not possible. You need to write at least one command per possible state. Luckily, SethBling recently did something very similar, so you can use his commands and modify them to your needs: https://sethbling.s3-us-west-2.amazonaws.com/Downloads/DataPacks/minecraft_earth.zip

I recommend for example Notepad++, which can use search+replace for all files in a folder at once.

1
  • Holy moly that's a lot of generated code. Welp... I'm baffled that such an essential command has been left out of the great commands overhaul, but so be it.
    – Quentin
    Commented Jul 23, 2019 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.