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.

[1.12.2] How to make a normal bucket turn to a custom bucket after collecting a custom fluid?

Featured Replies

Posted

.....

some of you might say "use universal bucket"

.....

But if I use universal bucket, it's pretty useless.

So I made a custom bucket that can DRAIN, after that, it returns a normal vanilla bucket.

Then, how to let the vanilla bucket accept my new fluid and return my CUSTOM bucket?

 

 

 

PS. FillBucketEvent is not working, so maybe I need a help at this too.

 

PPS. This is my bucket codecode.thumb.png.3233389471ee10a61da156dac3de2fdf.png

 

Edited by LeoCTH
add picture code

Use Event hooks from Forge.

So create an EventHandler, make sure it's registered and subscribe an event like so:

public static void onBucketUsed(FillBucketEvent event) {
    World eventWorld = event.getWorld();
    BlockPos hitPos = new BlockPos(event.getTarget().hitVec);
    if(eventWorld.getBlockState(hitPos) == yourBlockRegistry.theliquidVariable) {
        event.setFilledBucket(new ItemStack(yourItemRegistry.theBucketVariable, 1));
    }
}
	

Edited by hiotewdew
Fix formatting

If you want to drain it just add a check to see if the item held is your full bucket and run eventWorld.setBlockState to set the block at hitVec to your liquid.

Edited by hiotewdew
grammar

  • Author

..................

I think I've said

it can drain....

no matter what thx!

  • Author
3 hours ago, hiotewdew said:

If you want to drain it just add a check to see if the item held is your full bucket and run eventWorld.setBlockState to set the block at hitVec to your liquid.

....

My problem is my REGISTERING process having problem...

It's not working

Why don't you want to use the universal bucket? It's added for a reason...

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

You never said it wasn't working for you. Only that it's useless. You should use the universal bucket and if you run into issues, post them here.

 

Only if you need your bucket to have custom functionality, would it make sense to make custom buckets.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

15 hours ago, LeoCTH said:

....

My problem is my REGISTERING process having problem...

It's not working

Can I have more context than this? Or are you good and used a universal bucket?

  • Author
1 hour ago, hiotewdew said:

Can I have more context than this? Or are you good and used a universal bucket?

I tried FluidRegistry.enableUniversalBucket in a static initializer

and  FluidRegistry.addBucketForFluid(myFluid)

It doesn't work

Show me the class you register your fluid in.

  • Author
9 hours ago, larsgerrits said:

You never said it wasn't working for you. Only that it's useless. You should use the universal bucket and if you run into issues, post them here.

 

Only if you need your bucket to have custom functionality, would it make sense to make custom buckets.

I said "use" + "less" = "useless"

or my grammar have some problem I mean cannot (less) use

....

You misunderstanding my point.

You have to call enableUniversalBucket before the pre-initialization stage.

Here's a solved thread with an explanation.

While you do attempt to do the above it is not correct.

	static {
		FluidRegistry.enableUniversalBucket();
	}

	public static final String MODID = "mff";
	public static final String NAME = "My Food Factory";
	public static final String VERSION = "1.0.0";
	public static Logger LOGGER;
	@Mod.Instance(MyFoodFactory.MODID)
	public static MyFoodFactory instance;

Should be changed to this:

	public static final String MODID = "mff";
	public static final String NAME = "My Food Factory";
	public static final String VERSION = "1.0.0";
	public static Logger LOGGER;
	@Mod.Instance(MyFoodFactory.MODID)
	public static MyFoodFactory instance = createInstance();
	static MyFoodFactory createInstance() {
		FluidRegistry.enableUniversalBucket();
	}

 

Edited by hiotewdew
fix error

  • Author
4 hours ago, hiotewdew said:

While you do attempt to do the above it is not correct.


	static {
		FluidRegistry.enableUniversalBucket();
	}

	public static final String MODID = "mff";
	public static final String NAME = "My Food Factory";
	public static final String VERSION = "1.0.0";
	public static Logger LOGGER;
	@Mod.Instance(MyFoodFactory.MODID)
	public static MyFoodFactory instance;

Should be changed to this:


	public static final String MODID = "mff";
	public static final String NAME = "My Food Factory";
	public static final String VERSION = "1.0.0";
	public static Logger LOGGER;
	@Mod.Instance(MyFoodFactory.MODID)
	public static MyFoodFactory instance = createInstance();
	static MyFoodFactory createInstance() {
		FluidRegistry.enableUniversalBucket();
	}

 

....

the "static initializer block" it SUPPOSED to be like

static {
	// TODO
}

in Oracle's Docs and this thread.

but it's totally NOT working (the bucket can be registered with no functionality)

Edited by LeoCTH
grammar

The way he does the static initializer block should be fine. 

 

Universal bucket works for me and I enable it the same way. You can try by looking/using/copying my example mod here: https://github.com/jabelar/ExampleMod-1.12

 

Perhaps the problem has to do with the fluid, or the order in which the fluid and bucket are instantiated or registered. But your code looks like it should work. The only thing you do that is kinda weird/different than most is that you instantiate an anonymous instance of your loader classes whereas I would normally make the loader methods static. I don't think that's really a problem, but maybe it is causing trouble.

 

 

 

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

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.