Jump to content

Write a Float Array to NBT


teh_black_d00m

Recommended Posts

  • 5 years later...

this is a really old resurrected post 

anyway 

 

//values to nbt 

ListTag nbtblockpos = new ListTag();
nbtblockpos.add(IntTag.valueOf(blockPos.getX()));
nbtblockpos.add(IntTag.valueOf(blockPos.getY()));
nbtblockpos.add(IntTag.valueOf(blockPos.getZ()));
entitydata.put("blockPos", nbtblockpos);

ListTag nbtpos = new ListTag();
nbtpos.add(DoubleTag.valueOf(Pos.x));
nbtpos.add(DoubleTag.valueOf(Pos.y));
nbtpos.add(DoubleTag.valueOf(Pos.z));

entitydata.put("pos", nbtpos);
 

//getting things back

if(entitydata.contains("blockPos")) {
nbtpos = entitydata.getList("blockPos", Tag.TAG_INT);// blockdata contains pos
this.blockPos = new BlockPos(
nbtpos.getInt(0),
nbtpos.getInt(1),
nbtpos.getInt(2) );
}

this.pos = null;
if(entitydata.contains("pos")) {
nbtpos = entitydata.getList("pos", Tag.TAG_DOUBLE);// blockdata contains pos
this.Pos = new Vec3(
nbtpos.getDouble(0),
nbtpos.getDouble(1),
nbtpos.getDouble(2) );
}

 

 

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



×
×
  • Create New...

Important Information

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