Jump to content

Recommended Posts

Posted

You need to use the forge:fluid model. Use Forge's blockstates format to set the "fluid" custom property to the name of your Fluid.

 

I use this blockstates file to define the models for my mod's fluid Blocks/ItemBlocks and these methods to register them.

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.

Posted
6 hours ago, meee39 said:

What is MeshDefenitionFix? I can't import it.

 

It's a class added by my mod to allow the use of lambdas as ItemMeshDefinitions.

 

I'm pretty sure the ForgeGradle reobfuscation bug that prevented that was fixed a while ago, so it's probably not needed anymore. 

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.

Posted
package com.leo.occultcraft.fluids;

import com.leo.occultcraft.Occultcraft;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;

@Mod.EventBusSubscriber(value = Side.CLIENT, modid = Occultcraft.modid)
public class FluidRenderer {
	public static final FluidRenderer INSTANCE = new FluidRenderer();
	private static final String FLUID_MODEL_PATH =  Occultcraft.modid + ":fluid";
	
	@SubscribeEvent
	public static void registerAllModels(final ModelRegistryEvent event) {
		
	}
	
	private void registerFluidModel(final IFluidBlock fluidBlock) {
		final Item item = Item.getItemFromBlock((Block) fluidBlock);
		assert item != Items.AIR;

		ModelBakery.registerItemVariants(item);

		final ModelResourceLocation modelResourceLocation = new ModelResourceLocation(FLUID_MODEL_PATH, fluidBlock.getFluid().getName());

		//ModelLoader.setCustomMeshDefinition(item, ItemMeshDefenition.create(stack -> modelResourceLocation));

		ModelLoader.setCustomStateMapper((Block) fluidBlock, new StateMapperBase() {
			@Override
			protected ModelResourceLocation getModelResourceLocation(final IBlockState p_178132_1_) {
				return modelResourceLocation;
			}
		});
	}
	
}

 

Posted (edited)

I don't think you really need to make your own renderer unless you're doing something fancy. Since you said you wanted to have them show up like "normal" liquids you might just want to check my custom fluid tutorial to see what you're doing wrong. http://jabelarminecraft.blogspot.com/p/minecraft-modding-fluids_18.html . 

 

Also, you probably have an indication in the console log. It may complain about not finding the blockstate file, or having a bad blockstate file, or missing variant, or missing texture, and so forth. So most likely related to your JSONs or else related to your registry names not matching your JSON file names. So either post your log or debug it yourself.

Edited by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.