Jump to content

[1.11.2] Is there any alternate way of FluidContainerRegistry?


Recommended Posts

Posted

I'm trying to make a fluid, the bucket was okay, but when you pick it up with bucket,  it's turns to a water bucket. Then I try to listen to FillBucketEvent, and using event's result to do the custom bucket. But, I found

FluidContainerRegistry.fillFluidContainer();

is not there, even FluidContainerRegistry is not exist. The changelog is not mentioned the class is removed. So I wonder how to solve it.

Posted

Enable the Universal Bucket by calling FluidRegistry.enableUniversalBucket before preInit (e.g. in a static initialiser of your @Mod class), then add your Fluid to the Universal Bucket by calling FluidRegistry.addBucketForFluid in preInit. There's no need to create your own bucket or handle any events, the Universal Bucket does it all for you.

 

You can use UniversalBucket.getFilledBucket to get a Universal Bucket filled with a Fluid (ForgeModContainer#universalBucket stores Forge's UniversalBucket instance) or create an ItemStack of a fluid container, get its IFluidHandlerItem capability and fill it with IFluidHandler#fill.

 

The FluidUtil class contains several methods for dealing with IFluidHandlers, including player interaction.

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 (edited)

So you mean like this?

ObjList.java
public static void register() {
  GameRegistry.register(BucketMoltenFe50C);
  FluidRegistry.addBucketForFluid(FluidLoader.fluidMoltenFe50C);
  FluidRegistry.enableUniversalBucket();
  GameRegistry.register(BlockFluidMoltenFe50C);
 }
EventHandler.java
@SubscribeEvent
 public void onFillBucket(FillBucketEvent event) {
  System.out.println("[DEBUG] SteamTech >> Listening to FillBucketEvent. If the error is cleared, disable the debug.");
  BlockPos blockpos = event.getTarget().getBlockPos();
        IBlockState blockState = event.getWorld().getBlockState(blockpos);
        Fluid fluid = FluidRegistry.lookupFluidForBlock(blockState.getBlock());
        if (fluid != null && new Integer(0).equals(blockState.getValue(BlockFluidBase.LEVEL)))
        {
            FluidStack fluidStack = new FluidStack(fluid, 1000);
            event.getWorld().setBlockToAir(blockpos);
            UniversalBucket.getFilledBucket(item, fluid);
            event.setResult(Result.ALLOW);
        }
       
 }

btw what is the "item" in EventHandler.java line 11

I think the FluidContainerRegistry is deprecated/removed, right?

PS. Don't mind the names. It's steel.

 

Edited by LeoCTH
Posted
9 minutes ago, LeoCTH said:

So you mean like this?

public static void register() {
  GameRegistry.register(BucketMoltenFe50C);
  FluidRegistry.addBucketForFluid(FluidLoader.fluidMoltenFe50C);
  FluidRegistry.enableUniversalBucket();
  GameRegistry.register(BlockFluidMoltenFe50C);
 }

I think the FluidContainerRegistry is deprecated/removed, right?

PS. Don't mind the names. It's steel.

 

 

FluidRegistry.enableUniversalBucket must be called before preInit, like I said in my post. You also don't need to create or register your own bucket Item if you're using the Universal Bucket.

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
12 minutes ago, Choonster said:

 

FluidRegistry.enableUniversalBucket must be called before preInit, like I said in my post. You also don't need to create or register your own bucket Item if you're using the Universal Bucket.

Oh okay, before? How?

 

Posted
1 minute ago, LeoCTH said:

Oh okay, before? How?

 

38 minutes ago, Choonster said:

Enable the Universal Bucket by calling FluidRegistry.enableUniversalBucket before preInit (e.g. in a static initialiser of your @Mod class)

 

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.

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.