LeoCTH Posted January 4, 2018 Posted January 4, 2018 (edited) ..... 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 code Edited January 4, 2018 by LeoCTH add picture code Quote
hiotewdew Posted January 4, 2018 Posted January 4, 2018 (edited) 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 January 4, 2018 by hiotewdew Fix formatting Quote All Projects found here: Website Main Programmer for: Better Animals Plus, Better Animal Models Created independently: QuickHomes, ClaimIt, ClaimIt API, CloneLand, DerpCats, QuickTeleports, QuickSpawns, MCMusicPlayer, MCDevDate, [SBM] Fluid Gun, OpenScreens Work on/Contribute to: Bewitchment Commissioned for: [SBM] Breadstone, [SBM] Infinite Falling, [SBM] Dead Man's Satchel, [SBM] Handheld Piston
hiotewdew Posted January 4, 2018 Posted January 4, 2018 (edited) 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 January 4, 2018 by hiotewdew grammar Quote All Projects found here: Website Main Programmer for: Better Animals Plus, Better Animal Models Created independently: QuickHomes, ClaimIt, ClaimIt API, CloneLand, DerpCats, QuickTeleports, QuickSpawns, MCMusicPlayer, MCDevDate, [SBM] Fluid Gun, OpenScreens Work on/Contribute to: Bewitchment Commissioned for: [SBM] Breadstone, [SBM] Infinite Falling, [SBM] Dead Man's Satchel, [SBM] Handheld Piston
LeoCTH Posted January 4, 2018 Author Posted January 4, 2018 .................. I think I've said it can drain.... no matter what thx! Quote
LeoCTH Posted January 4, 2018 Author Posted January 4, 2018 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 Quote
larsgerrits Posted January 4, 2018 Posted January 4, 2018 Why don't you want to use the universal bucket? It's added for a reason... Quote 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/
LeoCTH Posted January 4, 2018 Author Posted January 4, 2018 .... If the Universal Bucket is working why I'm posting this? Quote
larsgerrits Posted January 4, 2018 Posted January 4, 2018 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. Quote 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/
hiotewdew Posted January 4, 2018 Posted January 4, 2018 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? Quote All Projects found here: Website Main Programmer for: Better Animals Plus, Better Animal Models Created independently: QuickHomes, ClaimIt, ClaimIt API, CloneLand, DerpCats, QuickTeleports, QuickSpawns, MCMusicPlayer, MCDevDate, [SBM] Fluid Gun, OpenScreens Work on/Contribute to: Bewitchment Commissioned for: [SBM] Breadstone, [SBM] Infinite Falling, [SBM] Dead Man's Satchel, [SBM] Handheld Piston
LeoCTH Posted January 5, 2018 Author Posted January 5, 2018 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 Quote
hiotewdew Posted January 5, 2018 Posted January 5, 2018 Show me the class you register your fluid in. Quote All Projects found here: Website Main Programmer for: Better Animals Plus, Better Animal Models Created independently: QuickHomes, ClaimIt, ClaimIt API, CloneLand, DerpCats, QuickTeleports, QuickSpawns, MCMusicPlayer, MCDevDate, [SBM] Fluid Gun, OpenScreens Work on/Contribute to: Bewitchment Commissioned for: [SBM] Breadstone, [SBM] Infinite Falling, [SBM] Dead Man's Satchel, [SBM] Handheld Piston
LeoCTH Posted January 5, 2018 Author Posted January 5, 2018 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. Quote
LeoCTH Posted January 5, 2018 Author Posted January 5, 2018 1 minute ago, hiotewdew said: Show me the class you register your fluid in. https://github.com/LeoCTH/MFF/blob/alpha/src/main/java/com/leocthmods/mff/fluids/FluidLoader.java Quote
hiotewdew Posted January 5, 2018 Posted January 5, 2018 You have to call enableUniversalBucket before the pre-initialization stage. Here's a solved thread with an explanation. Quote All Projects found here: Website Main Programmer for: Better Animals Plus, Better Animal Models Created independently: QuickHomes, ClaimIt, ClaimIt API, CloneLand, DerpCats, QuickTeleports, QuickSpawns, MCMusicPlayer, MCDevDate, [SBM] Fluid Gun, OpenScreens Work on/Contribute to: Bewitchment Commissioned for: [SBM] Breadstone, [SBM] Infinite Falling, [SBM] Dead Man's Satchel, [SBM] Handheld Piston
hiotewdew Posted January 5, 2018 Posted January 5, 2018 (edited) 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 January 5, 2018 by hiotewdew fix error Quote All Projects found here: Website Main Programmer for: Better Animals Plus, Better Animal Models Created independently: QuickHomes, ClaimIt, ClaimIt API, CloneLand, DerpCats, QuickTeleports, QuickSpawns, MCMusicPlayer, MCDevDate, [SBM] Fluid Gun, OpenScreens Work on/Contribute to: Bewitchment Commissioned for: [SBM] Breadstone, [SBM] Infinite Falling, [SBM] Dead Man's Satchel, [SBM] Handheld Piston
LeoCTH Posted January 5, 2018 Author Posted January 5, 2018 (edited) 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 January 5, 2018 by LeoCTH grammar Quote
jabelar Posted January 5, 2018 Posted January 5, 2018 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. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Recommended Posts
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.