Jump to content

Variable Fluid Textures


STEENBRINK

Recommended Posts

So I am updating my mod from 1.7.2 (haven't had time for a while). 
In that mod I used a crafting fluid for a crafting part of my mod. 

I rendered the crafting fluid with the mbt tags of the fluids that went in like this:
 

Spoiler
@Override
  public IIcon getIcon(FluidStack stack) {
  NBTTagCompound nbtTagCompound = stack.tag;
  if (nbtTagCompound.hasKey("FluidPrimary")) {
  FluidStack primaryFluid = FluidStack.loadFluidStackFromNBT(nbtTagCompound.getCompoundTag("FluidPrimary"));
  if (primaryFluid == null) return null;
  return primaryFluid.getFluid().getIcon(primaryFluid);
  }
  return null;
  }

That is not working anymore, obviously, but I can not figure out a way to do this now, since the resourcelocations are set in the constructor and cannot be eddited in any way, as far as I know.

 

Is there a way to accomplish this now?

Link to comment
Share on other sites

IIcon doesn’t exist anymore, it was replaced by the baked model system in 1.8

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

22 hours ago, V0idWa1k3r said:

What are you trying to accomplish exactly? Where do you want to render the fluid? In the item's model? In your GUI? In the world?

 

I have a barrel TileEntity, the idea is that you mix two fluids in there and it makes a third.
The way that is done, is by having a intermediate fluid, the so called CraftingFluid.


Here is the recepe handler for that (from 1.7.10):
https://github.com/STEENBRINK/Kaasmod-2-1.7.10/blob/master/src/main/java/nl/steenbrink/kaasmod/init/RecipesBarrel.java 

 

The way I render this CraftingFluid in the barrel is by taking the texture from the first added fluid (or primary fluid) by using nbt on the fluidstack.

Now there used to be a way to get the IIcon from the FluidStack.
 

Spoiler
@Override
  public IIcon getIcon(FluidStack stack) {
  NBTTagCompound nbtTagCompound = stack.tag;
  if (nbtTagCompound.hasKey("FluidPrimary")) {
  FluidStack primaryFluid = FluidStack.loadFluidStackFromNBT(nbtTagCompound.getCompoundTag("FluidPrimary"));
  if (primaryFluid == null) return null;
  return primaryFluid.getFluid().getIcon(primaryFluid);
  }
  return null;
  }

(full code here: https://github.com/STEENBRINK/Kaasmod-2-1.7.10/blob/master/src/main/java/nl/steenbrink/kaasmod/fluid/FluidCrafting.java)

My question is if there is a way to "set" the texture outside the constructor, because it changes every time I make a new craftingfluid.

Otherwise I will have to rewrite the whole crafting thingamagic.

I hope this clears it up a bit.

Link to comment
Share on other sites

44 minutes ago, STEENBRINK said:

The way I render this CraftingFluid in the barrel is by taking the texture from the first added fluid (or primary fluid) by using nbt on the fluidstack.

Why do you need this "crafting fluid" in the first place? Why not just store the first/primary fluid and display it's texture?

 

44 minutes ago, STEENBRINK said:

My question is if there is a way to "set" the texture outside the constructor, because it changes every time I make a new craftingfluid.

...Change what the getter returns? All FluidStack calls route back to the Fluid that it is't, well, fluid.

 

45 minutes ago, STEENBRINK said:

Otherwise I will have to rewrite the whole crafting thingamagic.

You have to do it regardless since IIcon no longer exists though.

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.