1

The goal here is to implement memory by using block.

I want to give command blocks index-able memory. I figured using blocks would be the most logical thing to do since they're... everywhere. I see they each have block ID's as shown here:

https://minecraft.gamepedia.com/Data_values/Block_IDs

I know the scoreboard can do some kinds of arithmetic operations. Possibly enough to serve as a naive "processor" to go hand in hand with the "memory". Naturally then I need to somehow get the block id of some block at an arbitrary position into the scoreboard. I know that theoretically one could just use this function (https://minecraft.gamepedia.com/Commands#testforblock) and just use that. However, the only problem with that is that checking 256 blocks is bridging from being inefficient to downright absurd. There has to be a better way. Is there a command to look up a block ID at some position and then move it to the scoreboard?

  • 2
    I believe it's worth mentioning here that Mojang has been moving away numerical id's in the past couple of updates. As such, almost no vanilla commands accept numerical id's anymore, instead they use a string id "minecraft:stone". If you choose to go with the "brute force" method of scanning for each block, you may wish to assign your own id for them. – SB32 Aug 30 '17 at 11:49
  • I think you can still use numeric IDs in most, if not all commands, but yes, they have been deprecated for a number of years. More importantly, though, is that in the next release they will be completely removed from commands. 1.13 hasn't even made it into snapshots yet, so there is still some time before numeric IDs are completely broken, but it's always best to stay away from deprecated stuff to begin with. – MBraedley Aug 31 '17 at 13:49
  • 1.13 is now out, and numeric IDs no longer exist at all. – pppery Aug 19 '18 at 22:03
  • @ppperry and the older versions ceased to exist? – user64742 Aug 21 '18 at 0:13
  • No, versions 1.12 and under are still available for download, but 1.13 has no concept of numeric block ID. – pppery Aug 21 '18 at 0:19
2

There is no better way.

Commands are very limited when it comes to dynamically reading and writing data to and from scoreboard - or anything else for that matter.

Without knowing your specific requirements, all I can say is that you're going to have to hardcode each individual block. If you can add some details to the OP we might be able to come up with a work-around that isn't so absurd.


Allow me to elaborate in an attempt to assert my credibility on the subject.

The scoreboard command is relatively large but its functionality is still quite limited. It can write only to the scores of entities and so-called "fake players" (static names on the scoreboard). It can read values from the same places, naturally, however it is also possible to read in values from various other sources using the stats command. Even so, there is no such stat or query that can extract the id of a block and place it into a score.

I should also note that selectors and scores can be used in several other places (such as with the tellraw command, signs, books, and text components in general), though not in any way that will allow for dynamic manipulation of data.

  • 1
    I would suggest removing the "add more details" part of your answer. This should be put in the comments, as it doesn't provide an answer to the question. – Ben Aug 30 '17 at 6:16
  • Just for the record I didn't downvote. And we'll there is no particular use for this other than trying to grant command blocks any form of indexible memory... and all the things which naturally follow sort from that augmentation. In particular the end game is the construction of dynamic memory allocation and thereby arbitrary struct based programming. However that's at least 10 or 12 steps beyond having just... memory. If you need to know why I need that, the answer is quite simple: because it makes things easier. – user64742 Aug 30 '17 at 6:19
  • @Ben It is part of the answer. It's not a comment. – user64742 Aug 30 '17 at 6:20
1

Sadly you will have to test for every single possible block.

Blocks have IDs, but they are only used for the save files. In the game, they are only referred to with their ID name ("minecraft:stone", "minecraft:dirt", "minecraft:beacon" and so on).

Also, as Arcensoth said, there is no way to get data into and out of scoreboards dynamically (except /stats, but that's also limited). But that doesn't mean that your relative coordinates based on scoreboards are impossible, it just means that you will have to e.g. move an armor stand one block per scoreboard count etc.

For this project, I recommend you to use functions instead of command blocks. You can edit them in a text editor, you can easily copy commands (whenever you need 256 of a kind) and you can use recursion for the armor stand teleportation so that it can happen in one tick.

  • So... use an armor stand like a program counter or pointer? en.m.wikipedia.org/wiki/Program_counter – user64742 Aug 30 '17 at 6:24
  • 1
    Yes, sort of. If you want to use fixed or variable numbers, you would have to move him to the start again and start counting from there. But commands like "increase index by 1" or "decrease index by 3" would be easier. – Fabian Röling Aug 30 '17 at 6:27
  • Hmm. Sounds like this would get sufficiently complicated. TBH though, I think compiled code does the exact same thing anyways... for stupid reasons. Thanks! – user64742 Aug 30 '17 at 6:31
  • There are no stupid reasons for anything compiled code does. Computers are incredibly optimized. Just look at this: stackoverflow.com/questions/11227809 – Fabian Röling Aug 30 '17 at 7:19
  • 1
    I just looked back in the comments and you asked if you could "index" armor stands: You could at least give each of them a unique ID (e.g. youtu.be/bI4nJCjPWtE) and then use that to target them (@e[score_test_min=<x>,score_test=<x>]). That could also be set to arbitrary values, increased, decreased, even multiplied. – Fabian Röling Sep 2 '17 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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