Jump to content

Metadata for Fluids?


Gwafu

Recommended Posts

As of now, there's the NBT for fluids. Is it safe to use the NBT? I mean, will the NBT be carried from mod_A tank, through Buildcraft pipes, then to mod_B tank?

 

Or is it better to just create separate Fluids (with separate IDs)?

 

Need some insight on this. Thank you!

 

-saus

Link to comment
Share on other sites

//Loop iterates four times.
for (int i = 0; i < CellarRegistryUtils.getBoozeMeta(appleCider_booze); ++i)
	{
		FluidStack stack = new FluidStack(appleCider_booze.getID(), FluidContainerRegistry.BUCKET_VOLUME);
		Utils.setMeta(stack, i);
		FluidContainerRegistry.registerFluidContainer(stack, new ItemStack(appleCider_bucket, 1, i), FluidContainerRegistry.EMPTY_BUCKET);
	}

(Loops four times to register a bucket with four subitems with fluids that contains the nbt (set by Utils.setMeta(param))

 

Apparently, FluidContainerRegistry doesn't accept NBTs because:

 

Utils.getMeta(FluidContainerRegistry.getFluidForFilledItem(filledC);

 

Will always return 3 no matter what.

 

 

Util functions (pretty fugly ItemStack displayName ripoff):

public static boolean hasMeta(FluidStack fluidstack)
{
	if (fluidstack != null)
	{
		return fluidstack.tag == null ? false : (!fluidstack.tag.hasKey("meta") ? false : true);
	}
	return false;
}

public static int getMeta(FluidStack fluidstack)
{
	int ret = 0;

	if (hasMeta(fluidstack))
	{
		if (fluidstack.tag != null && fluidstack.tag.hasKey("meta"))
		{
			ret = fluidstack.tag.getInteger("meta");
		}
	}

	return ret;
}

public static void setMeta(FluidStack fluidstack, int value)
{
	if (fluidstack.tag == null)
	{
		fluidstack.tag = new NBTTagCompound("tag");
	}

	fluidstack.tag.setInteger("meta", value);
}

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.