Jump to content

[1.10.2] Issues with Custom Fluids


Malkierian

Recommended Posts

Quite frankly, I'm surprised this hasn't been added as default behavior into Forge (being able to handle fluid interactions independent of it being water).  I have 8 custom fluids I've added right now, but because they don't have Material.WATER (thus failing the Entity.isInWater() method), entities don't interact with them as liquids.  Is there a way to keep custom map colors and such and still make entities interact with my fluids properly, or am I going to have to suck it up and keep them water?  I'd like to easily be able to set the "underwater" fog color, too, to mach the liquid color.

 

Also, I'm having visual glitches like this gap between side textures:
iVQIcWy.png
I'm using BlockFluidClassic.  Is this a problem with my fluid textures, or perhaps a model or is there something wrong with the renderer?  Also, I have a blockstate JSON file, but I keep getting errors like this, too:

Spoiler

[11:00:22] [Client thread/ERROR] [FML]: Exception loading model for variant plasmacraft:blocks/fluid/plutonium#inventory for item "plasmacraft:blocks/fluid/plutonium", normal location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model plasmacraft:item/blocks/fluid/plutonium with loader VanillaLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:317) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:170) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:147) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:132) [SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:113) [SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:799) [Minecraft.class:?]
    at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:340) [FMLClientHandler.class:?]
    at net.minecraft.client.Minecraft.startGame(Minecraft.java:561) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:386) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_74]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_74]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_74]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_74]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_74]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_74]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_74]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_74]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.io.FileNotFoundException: plasmacraft:models/item/blocks/fluid/plutonium.json
    at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:68) ~[FallbackResourceManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:65) ~[SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:311) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.access$1100(ModelLoader.java:118) ~[ModelLoader.class:?]
    at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:868) ~[ModelLoader$VanillaLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 23 more

 

Does this have anything to do with it?  I was under the impression that I would only need a blockstate, not a model, and I can't find anything on a water block model anyway.  Perhaps something is wrong with my blockstate?

Spoiler

{
  "forge_marker": 1,
  "variants": {
    "fluid": {
      "model": "forge:fluid",
      "custom": {
        "fluid": "plutonium"
      }
    },
    "inventory": {
      "model": "forge:forge_bucket",
      "textures": {
        "base": "forge:items/bucket_base",
        "fluid": "sw:items/bucket_fluid",
        "cover": "forge:items/bucket_cover"
      },
      "transform": "forge:default-item",
      "custom": {
        "fluid": "plutonium",
        "flipGas": true
      }
    }
  }
}

 

And, I don't plan on having buckets able to interact with these.  Is all of that necessary if that's the case?

Edited by Malkierian
Minor code change
Link to comment
Share on other sites

Fluid models rendering with gaps was a known issue that was fixed in Forge 1.11.2-13.20.0.2279. It's very unlikely that this will be backported to 1.10.2.

 

The model loading for the inventory variant not being loaded is probably due to you adding a blocks/ prefix to the model path. I'm guessing your blockstates file is assets/sw/blockstates/fluid/plutonium.json, not assets/sw/blockstates/blocks/fluid/plutonium.json.

 

You can use forge:fluid as the item model if you want the item form to render as a 2D-style square with the fluid's texture. Having the item form look like a bucket may be confusing, since it wouldn't actually be a bucket.

Edited by Choonster
  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Cool, thanks for that info.

 

As a matter of fact, the blocks/ prefix being there or not had no impact on where the game looked to find the blockstate files, which was merely assets/plasmacraft/blockstates.  If I moved them from there, the textures for the blocks didn't even load.

 

However, I tried just replacing the model for the inventory variant, I tried removing different portions of the inventory variant, and I tried removing the inventory variant altogether, and it still keeps failing (with that exact same error) and trying to find the item model json file separately (which, of course, I don't have).  I can't find any info on what a fluid blockstate file is SUPPOSED to look like.

 

EDIT: Just realized how the blockstate files are found, and no, they were in the right place and being loaded.  I just can't figure out how to get it to load the inventory variant properly.

Edited by Malkierian
Link to comment
Share on other sites

8 hours ago, Malkierian said:

As a matter of fact, the blocks/ prefix being there or not had no impact on where the game looked to find the blockstate files, which was merely assets/plasmacraft/blockstates.  If I moved them from there, the textures for the blocks didn't even load.

 

However, I tried just replacing the model for the inventory variant, I tried removing different portions of the inventory variant, and I tried removing the inventory variant altogether, and it still keeps failing (with that exact same error) and trying to find the item model json file separately (which, of course, I don't have).  I can't find any info on what a fluid blockstate file is SUPPOSED to look like.

 

EDIT: Just realized how the blockstate files are found, and no, they were in the right place and being loaded.  I just can't figure out how to get it to load the inventory variant properly.

 

Minecraft will always use assets/<modid>/blockstates/<registry_name>.json for the Block's models (unless you register a custom IStateMapper), but the blockstates file used for the Item models depends on the ModelResourceLocation you pass to ModelLoader.setCustomModelResourceLocation or return from the ItemMeshDefinition you pass to ModelLoader#setCustomMeshDefinition.

 

To use the inventory variant of the assets/<modid>/blockstates/<path>.json blockstates file for an Item model, use a ModelResourceLocation with <modid> as the domain, <path> as the path and inventory as the variant.

 

If a MissingVariantException is logged for the inventory variant of this blockstates file, you may be running into this issue where Forge is treating your inventory variant as partially-defined instead of fully-defined.

 

If you still need help, post the code where you register the Item model, the latest blockstates file (including its path) and the full FML log.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Well, thanks you to talking about the customMeshDefinition, I remembered the place where that was called, and realized that it was registering a new ItemBlock in the code, and was then trying to set the customMeshDefinition to a block model that didn't exist.  Guess that's what I get for blindly following tutorials...  But, I removed the ItemBlock registration and removed the one line trying to set the customMeshDefinition and everything's back to normal.  I never wanted to have a liquid block available in the creative tabs anyway, I have other items for placing these things.  Hopefully now the inventory variants in the blockstates will work (if I decide I even want them).

 

However, I've still had no answer about the water-like entity interactions for my fluids.

Edited by Malkierian
Link to comment
Share on other sites

Just now, Malkierian said:

Well, thatnks you to talking about the customMeshDefinition, I remembered the place where that was called, and realized that it was registering a new ItemBlock in the code, and was then trying to set the customMeshDefinition to a block model that didn't exist.  Guess that's what I get for blindly following tutorials...  But, I removed the ItemBlock registration and removed the one line trying to set the customMeshDefinition and everything's back to normal.  I never wanted to have a liquid block available in the creative tabs anyway, I have other items for placing these things.  Hopefully now the inventory variants in the blockstates will work (if I decide I even want them).

 

I'm glad you figured that out.

 

 

Just now, Malkierian said:

However, I've still had no answer about the water-like entity interactions for my fluids.

 

I haven't done this myself, but it may be possible to implement it yourself with Block#onEntityCollidedWithBlock. I can't really help you any further with this, though there may be existing mods that have done this.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I am not sure about 1.10.x but 1.11 has Block::getMapColor that you can override to have custom map colors that are material-independent. 

The overlay can be rendered in any of RenderGameOverlayEvent's subevents however you please.

Yet again, unsure about 1.10 but 1.11 has a Block::isEntityInsideMaterial (and Block::isAABBInsideMaterial) method to check if the specified entity is in specified material.

Apart from that it seems that Forge checks if an entity is inside of fluid by checking the fluid fill level and it will check the level if a block is an instance of either IFluidBlock or BlockLiquid. 

Motion can be handled in Block::modifyAcceleration.

fire/damage you will have to implement in Block::onEntityCollidedWithBlock as @Choonster said.

Unfortuately apart from that a lot of things are hardcoded to work with Material.WATER/LAVA and you will either have to find a workaround with forge's events or just accept that it is not currently possible (if you really need something you could make a PR though).

Link to comment
Share on other sites

As far as I can tell, RenderGameOverlayEvent doesn't have anything on the color an overlay has from being in a liquid.  If I'm looking at it wrong, then I need better documentation.

 

Thankfully, though, Block::isEntityInsideMaterial did most of what I was wanting (as far as interacting with the liquid, being pushed by flow, swimming instead of jumping, etc).  It's unfortunate that going under the surface of the liquid can only turn the screen bluish for now, but it's not like I haven't been dealing with that since I started handling the mod anyway.  Hopefully SOMETHING will crop up somewhere.

Link to comment
Share on other sites

I think I might have found what you are looking for. RenderBlockOverlayEvent is a cancelable event that renders a texture of a block the player is currently in. It also catches water overlay if the player is in water and fire overlay when player is on fire.

Link to comment
Share on other sites

Yes, that almost could do it, except that there's no way to change how the water texture is rendered.  I managed to cancel the event for rendering the water overlay, but I can't seem to get it to use my own fluid blocks to overlay.  Even posting a new event with the OverlayType.BLOCK, with one of my other blocks, it still only cancels.  It doesn't do another overlay.  And there's no way to change the block used in the same event that was fired.  And since I can't follow the code in the normal way, I don't know how to find out how it processes the overlay events to make my fluids compatible.

Link to comment
Share on other sites

Just render your fluid texture using Tessellator in your event handler, then cancel the event. You can do this the same way vanilla does it in ItemRenderer::renderWaterOverlayTexture, just bind your overlay texture instead of the water one

Edited by V0idWa1k3r
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.