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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • It's exciting to hear that MCC Island's open beta launch marks an exciting milestone in gaming. As a virtual world blending nostalgia with modern tech, it promises an immersive experience. 
    • Please read the FAQ on how to post your logs; embedding them in your post like that makes them very hard to read, which may make it harder for people to help you. I'd be interested to know if you run into the same problem(s) if you create a fresh world, vs loading into the one you've been playing.
    • Hi, I am trying to use a shadowed dependency in my mod for version 1.8.9, but I just can't get it fully working. I think the shadowing is working (at least a little) because I can use the dependency in my mod without getting a classdefnotfound, but if I actually try to use the dependency it just crashes with this error: The error: I have no idea if this is me using the dependency wrong, me shadowing the dependency wrong, or the dependency just being broken. Can someone maybe check if something obvious is wrong? Thanks in advance! I have provided everything I could think of, if something more is needed, please tell me. Dependency I am trying to shadow into my jar: https://github.com/NotEnoughUpdates/MoulConfig I have downloaded this dependency as "/libs/legacy-3.0.0-beta.13.jar" Example of how the dependency should work (their own example): https://github.com/NotEnoughUpdates/MoulConfig/blob/master/legacy/src/main/java/io/github/notenoughupdates/moulconfig/test/MoulConfigTest.java Example of how the dependency should work (another mod written in kotlin (see line 91)): https://github.com/hannibal002/SkyHanni/blob/beta/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt My ConfigManager.java (Where it breaks (see comment on line 16)):   My FMLInitializationEvent:   My build.gradle file (gradle 4.5): (I run the tasks: "build shadowJar copyJarToBin" to build my mod)  
    • Downgrade Better_Dogs_X_Doggy_Talents_Next
    • Hi, My mod has player capabilities tracking mana value, and the values will not save after death. (To be clear it does save when I exit and reenter the world) I looked at the documentation for capabilities but it says very little about saving after death, and what it does say I've already done. I did follow a tutorial from 1.19 so I'm guessing something changed between versions and I don't know how to fix it. ////////CODE/////////////// @SubscribeEvent public static void onPlayerCloned(PlayerEvent.Clone event){        if(event.isWasDeath()) {                event.getOriginal().getCapability(PlayerManaAmountProvider.PLAYER_MANAAMOUNT).ifPresent(oldStore -> { event.getOriginal().getCapability(PlayerManaAmountProvider.PLAYER_MANAAMOUNT).ifPresent(newStore -> {                                                   newStore.copyFrom(oldStore);              });          });        } }
×
×
  • Create New...

Important Information

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