2

Is it possible to IMPORT DATA from text file to redstone memory/minecraft world?build

Covax256's Avatar Covax2566/23/21 11:59 am
2 emeralds 228 6
8/5/2021 12:53 am
SUPERIONtheKnight's Avatar SUPERIONtheKnight

Hey! I'm new here, so excuse my mistakes :)
I am trying to write data to a quite large block of redstone memory (2 x 512 bits, to be exact).


Is it possible in some way to import data to a minecraft world in order to save it as a binary (or hexadecimal) value? My goal would be to have a text file with data to represent 1024 bits. This could be in any form: binary, hex, decimal, etc. So this data can be 'translated to Minecraft' in some form (this could be redstone signal strength, a line of blocks or anything I can turn into a number with redstone). It doesn't have to be fast, easy or pretty.

I am trying to look into command blocks and find a solution that way, but couldn't get far yet.

I know this may sound silly, but it would mean a lot to me if this would be possible.
Does anyone have any ideas how to solve this problem (or should I begin to manually set the registers 😅)?

Thanks for your time, have a nice day :)

Covax

Posted by Covax256's Avatar
Covax256
Level 1 : New Miner
0

Create an account or sign in to comment.

6

SUPERIONtheKnight
08/05/2021 12:53 am
Level 29 : Expert Engineer
history
SUPERIONtheKnight's Avatar
I have actually been needing something rather similar for ages now.

You see, I have always needed the ability to run more complex mathematical computations in-game like square roots, sine, cosine, etc(this is related I promise). Unfortunately, the most the game provides is addition, subtraction, multiplication, division, and modulo operations(see here). To make things worse, I am not allowed to work with any number that isn't a 32-bit integer as scoreboards are restricted to work with those. This makes it much more difficult to work with almost any kind of rational/irrational numbers, as well as really big/small numbers.

So I set out to develop my own solutions. I started with trying to get a square root algorithm working in game, and I succeeded. However there was a problem. It could correctly compute roots for perfect squares/cubes/etc, but it gave incorrect results when dealing with imperfect squares/cubes/etc. Now I believe I used the Babylonian method for computation, and from what I could tell, what I wrote should have worked. This was up until I noticed that when the game does division, it rounds the output down to an integer. This meant that every time I ran my square root algorithm, it was rounding stuff it shouldn't have been rounding, and thus gave an incorrect result.

Irritated, I decided to drop the project for a while. I later came back and decided I was doing this all wrong. I needed to ditch Minecrafts way of doing it and start from scratch. So I started developing my own binary system inside of a datapack, and am currently planning to work my way back up to more advanced calculations.

So far, I unfortunately haven't made much progress, although I have made some. I am currently using the scoreboard and a bunch of marker entities to store each binary number into a bunch of bytes. From here, I can bit shift my numbers left/right, and can add them together. In theory, this system can work with numbers up to 2^(8*(2^31-1)), or 2^17179869176 to be more precise. There's no way the game is going to be able to work with a number like that with how massive it is, but it's still fun to think that it could in theory if given enough time/resources. :)

The way I got the above number is simple: I am dividing our binary number into groups of 8 bits, and storing them into their own markers(AKA: each marker represents a byte). Each marker/byte is also given a score from 1, up to 2^31-1 to distinguish the byte from the rest, depending on how many bytes we need(8 * (2^31-1)). From here, I just take 2, and raise it to the power I just calculated for our total number: 2^(8*(2^31-1)).

Currently I am trying to figure out how to simplify the code as it's a mess. I'm also trying to make it capable of displaying numbers as a float/decimal/integer/etc. No idea what approach I'm going to take yet, or if I even should go for a float as it might be more performance hungry.

All of that aside, if you wanted to load a binary number from a .mcfunction file, you could do that. Could be as simple as setting all of the bytes in the .mcfunction file for each number, then bit shifting in game to read the number. :)

If you want to give the datapack a try, let me know and I can give a download link. Please understand though that this is far from complete, is very messy, and likely full of bugs.
1
One_Nose
07/22/2021 10:36 am
Level 58 : Grandmaster Hero
history
One_Nose's Avatar
I am not sure what you mean. Redstone is just a bunch of blocks placed in the same area to create mechanics. Can you give an example of a simple redstone machine and how do you want it to be translated? And what exactly do you need it for? Perhaps there is an alternate solution.
1
Covax256
07/24/2021 11:45 am
Level 1 : New Miner
Covax256's Avatar
Hey!

The exact application that I would need this for is a 'machine' that could perform the SHA-256 algorithm on a given amount of data. (1024 bits in my case) Basically a simplified bitcoin miner in minecraft. It would mostly do bitwise shifts, rotations combined with XORing.

The uncomfortable part is what the question is about: I would need data to perform the operations on, which I already have enough storage for. What I want to achieve is to load my storage (let's call it RAM) with 1024 bits of data. This data would be from outside minecraft, for example in a 'data.txt' file. And I am curious if there is any way how I could 'translate' this data into minecraft. What I mean by "translated" is blocks being placed or pushed, wires set from low to high, etc. (as you said, blocks placed in the same area). But it can be in any way how it could be saved into RAM. The one I used is signal strength based (so basically HEX), but binary based data would do fine as well.

I hope I could clear things up a little bit more. I just didn't want to bore you with unnecessary information :)
2
One_Nose
07/24/2021 3:20 pm
Level 58 : Grandmaster Hero
One_Nose's Avatar
How exactly do you want to translate it? Minecraft itself cannot read external files. You could write a program to translate the data for you. If you want to translate it manually, i don't see the problem.

If you just need a way to represent data and perform methods on it using Redstone, you could simply use 1024 levers for binary representation, or some combination of comparator and a comparable block for hexadecimal representation.

If you want to write a program to translate it, you could translate the data into a structure NBT file and load it via a structure block. I am sure you could find libraries for various programming languages for NBT manipulation.
2
Covax256
07/25/2021 9:58 am
Level 1 : New Miner
Covax256's Avatar
This would be my question. I would like to know if there is any way minecraft could read external files and translate them into a world. Now I know it cannot. I don't know how the NBT files work, neither the so mentioned 'structure block', so I think I will just start reading about those :D
My other idea is a python script which would create an in-game function based on the data in the first one. This could be filled with setblock commands or something of that sort. :)
2
One_Nose
07/25/2021 10:26 am
Level 58 : Grandmaster Hero
One_Nose's Avatar
The function script thing sounds to me like the simplest solution.
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome