Jump to content

[1.19] Blockstates, setblock


scaroyder

Recommended Posts

I've got a problem with schematics generation. So actually after reading .schematic file I'm getting two arrays of bytes (blockid and blockdata).

The problem is I dont know how to obtain a BlockState for Level#setBlock (2nd parameter), because I dont know what kind of block I'm going to place, just id and data, and I see no static plug for this parameter (Like BlockState.WHATEVER). 

So how can I deal with it? 

Link to comment
Share on other sites

17 minutes ago, scaroyder said:

I just read it with NbtIo without any problems...

how did you write them?

Could you please provide more info to NbtIo, i could not find anything about it in www

Edited by Luis_ST
Link to comment
Share on other sites

net.minecraft.nbt.NbtIo - utilities for file <-> nbt

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

2 minutes ago, Luis_ST said:

how did you write them?

Could you please provide more info to NbtIo, i could not find anything about it in www

have a look at

net.minecraft.nbt.NbtIo

Im using it to load schematics from files or to send NBT data via packets between server/client.

Well, I used to do so in 1.6.4, lol. In those times it was named CompressedStreamTools.

The goal im trying to achive is to make schematics import much easier at the server side. I will be able to dl some schematic, put it into server subfolder, and then manipulate with it as I want (dynamically spawn the schematic for some event, or add it to custom worldgen, etc etc etc)

Link to comment
Share on other sites

49 minutes ago, scaroyder said:

have a look at

I kind of thought it was a library

1 hour ago, scaroyder said:

actually  .schematic file just contains a nbt compound, so why not? I just read it with NbtIo without any problems...

how did you write the data into the NBT?

Link to comment
Share on other sites

48 minutes ago, Luis_ST said:

how did you write the data into the NBT?

 public static Schematic get(File f) {
            CompoundTag nbtdata = NbtIo.readCompressed(f);
            short width = nbtdata.getShort("Width");
            short height = nbtdata.getShort("Height");
            short length = nbtdata.getShort("Length");
            byte[] blocks = nbtdata.getByteArray("Blocks");
            byte[] data = nbtdata.getByteArray("Data");
            return new Schematic(width, height, length, blocks, data);
        }
public Schematic(short width, short height, short length, byte[] blocks, byte[] data) {
        this.width = width;
        this.height = height;
        this.length = length;
        this.blocks = blocks;
        this.data = data;
    }

and then I'm using Schematic instance to build schematic in world by calling Level#setBlock.

Well, I supposed to be doing that, but I can't because I dont know where should I get BlockState. 

In 1.6.4 I were able to place a block in world just with coords, blockID and blockdata. 

Link to comment
Share on other sites

ServerLevel.setBlockAndUpdate(). You need the BlockState not the block.

If it is standard minecraft format you can use NbtUtils.readBlockState(CompoundTag)

If it is a BlockEntity then you also need to do Level.setBlockEntity()

again if it is standard nbt you can use BlockEntity.loadStatic()

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.