Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi.

I have got an issue with a custom fluid block, that I have been trying to fix for a whole night.

The issue is that I am not able to get my custom fluid texture to render. The Forge bucket texture works, but the actual block texture doesn't. No matter what I do I always get one of these results:

  1. The block is not rendered at all (there you can see through, but the block is obviously here as it still affects entities, make particles, etc...)
  2. The block is rendered as the missing model placeholder
  3. The block is rendered as a vanilla fluid 

 

My code:

ModFluids.java - Here I initialize the Fluid

https://pastebin.com/sxUHCSXc

 

The fluid is registered from a static block in my main class:

static {
		FluidRegistry.enableUniversalBucket();
		
		FluidRegistry.registerFluid(ModFluids.GASOLINE);
		FluidRegistry.addBucketForFluid(ModFluids.GASOLINE);
	}

 

BlockGasoline.java - The block that uses the Fluid

https://pastebin.com/eVDV90vr

 

The block is initialized like this:

public static final Block GASOLINE = new BlockGasoline(ModFluids.GASOLINE,Material.WATER).setRegistryName("gasoline").setUnlocalizedName("gasoline");
	

 

And registered using RegistryEvent.Register<Block>

@SubscribeEvent
	public static void registerBlocks(final RegistryEvent.Register<Block> event) {
		final IForgeRegistry<Block> registry = event.getRegistry();
		for (Block block : SevenDaysToMine.BLOCKS) {
			registry.register(block);
		}

	}

 

And this is how I register the models

@SubscribeEvent
	@SideOnly(Side.CLIENT)
	public static void onModelEvent(final ModelRegistryEvent event) {
		for (Block block : SevenDaysToMine.BLOCKS) {
			registerBlockModel(block);
		}
		registerItemBlockModels();
		registerItemModels();
	}

	@SideOnly(Side.CLIENT)
	public static void registerBlockModel(Block block) {
		if (block instanceof IBlockBase) {
			IBlockBase iblockbase = (IBlockBase) block;
			if (iblockbase.hasCustomStateMapper()) {
				if (iblockbase.getStateMapper() != null) {
					ModelLoader.setCustomStateMapper(block, iblockbase.getStateMapper());
					return;
				} else {
					Utils.getLogger().warn("Trying to add a null IStateMapper to " + block.getRegistryName()
							+ " . That is a bad thing!");
				}
			}

		}
		
		registerBlockModel(block, 0);
	}

 

 

The .json blockstate file is correctly located in the blockstates folder and looks like this:

{
    "forge_marker": 1,
    "variants": {
        "fluid": {
            "model": "forge:fluid",
            "custom": { "fluid": "gasoline" }
        },
        "inventory": {
            "model": "forge:forgebucket",
            "transform": "forge:default-item",
            "custom": {
                "fluid": "gasoline"
            }
        }
    }
}

 

If I change in the file "gasoline" to some random word, it renders the vanilla water texture (which I suppose is a placeholder), however, if I change it to "lava", it correctly renders vanilla lava.

 

EDIT: Solved, caused by Fluid#setColor()

Edited by Nuparu00
Solved

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.