Posted April 6, 20178 yr 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.
April 6, 20178 yr 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.
April 6, 20178 yr Author 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 April 6, 20178 yr by LeoCTH
April 6, 20178 yr 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.
April 6, 20178 yr Author 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?
April 6, 20178 yr 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.
April 6, 20178 yr 5 minutes ago, LeoCTH said: Still not understand what "static initializer" is. plz explain! A static initializer is a Java concept. https://docs.oracle.com/javase/tutorial/java/javaOO/initial.html
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.