Pow3rCut Posted July 13, 2013 Posted July 13, 2013 Hi, I am trying to update my mod to 1.6.2, all is going well apart from the liquid system, previously I had used ILiquid and extended BlockFlowing/BlockStill. This system is now gone, and I was wondering if anyone has an example (or can just point me in the right direction, at the moment I am running around like a headless chicken) for how to implement the new system using BlockFluidBase/Finite From what I can see you need: A fluid Two blocks as usual - Source and Flowing To Register the fluid in the FluidRegistery What else do you need to add? Thanks in advance, - Pow3rCut Quote If I helped you click the Thank You button
Mazetar Posted July 13, 2013 Posted July 13, 2013 Some container item to pick it up with? you can check the files for that one and the block files etc. There are reference files for the Tank and Containers as well Quote Quote If you guys dont get it.. then well ya.. try harder...
Pow3rCut Posted July 14, 2013 Author Posted July 14, 2013 Not sure if I'll need a tank for this, but I'll keep working on trying to figure this out. Thanks for the suggestions though Quote If I helped you click the Thank You button
Flenix Posted July 14, 2013 Posted July 14, 2013 Have you got as far as a flowable, animated liquid yet? I've got that bit working. I can't get the bucket working though, let me know if you find anything Quote http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
Pow3rCut Posted July 14, 2013 Author Posted July 14, 2013 My Liquid is still a little buggy, if you could pass on your solution I would be grateful - Pow3rCut Quote If I helped you click the Thank You button
Homletmoo Posted July 14, 2013 Posted July 14, 2013 Going through the same process, and I think I just about have it working. What you need: Class extending Fluid for the registry Class extending BlockFluidClassic (flowing and still are rolled into one) for the in-world block Class extending ItemBucket if you want a custom container @ForgeSubscribe'd FillBucketEvent handler function (can have its own class if you use MinecraftForge.EVENT_BUS.register()) The Fluid class is very simple. All you need is a constructor to set a couple of values. You can even register it within its constructor: public FluidExample( int id ) { super( "example" ); setDensity( 8 ); // used by the block to work out how much it slows entities setViscosity( 4000 ); // used by the block to work out how fast it flows FluidRegistry.registerFluid( this ); } The BlockFluidClassic class is more similar to the old LiquidFlowing and Liquid Still classes. The main difference is that you give it a reference to the fluid, and it draws some information from that. Also, the textures are slightly different. Define private still and flowing icons in the class, and register them in your override of registerIcons( IconRegister ) . Also, pass them to getFluid().setIcons( Icon, Icon ) , since it's impossible to get a reference to the IconRegister elsewhere. Then, in your getIcon override, put this: @Override @SideOnly(Side.CLIENT) public Icon getIcon( int side, int meta ) { if ( side <= 1 ) return iconStill; else return iconFlowing; } This is getting quite long, so I'll put the bucket code in another comment. Quote
Homletmoo Posted July 14, 2013 Posted July 14, 2013 Before I get onto the bucket code, I almost forgot - register your BlockFluidClassic instance in your proxy like you would for any other block. For the ItemBucket class, the only difference from a normal Item is that you pass the super constructor a second value: the id of your BlockFluidClassic class, which will be automatically placed when you right click. Then, somewhere in initialisation, use the FluidContainerRegistry to register this item as a container holding one bucket's worth of that fluid: FluidContainerRegistry.registerFluidContainer( new FluidContainerData( FluidRegistry.getFluidStack( ModExample.fluidExample.getName(), FluidContainerRegistry.BUCKET_VOLUME ), new ItemStack( ModExample.bucketExample ), new ItemStack( Item.bucketEmpty ) ) ); Finally, we need to tell minecraft to fill a bucket with this fluid whenever it is right clicked on with a bucket in hand. Fortunately, Forge provides an event listener that fires when you right click with a bucket. @ForgeSubscribe public void onBucketFill( FillBucketEvent event ) { ItemStack result = attemptFill( event.world, event.target ); if ( result != null ) { event.result = result; event.setResult( Result.ALLOW ); } } where attemptFill( World, MovingObjectPosition ) is a function that checks what the picked block is, and returns an ItemStack of the relevant filled container if applicable: private ItemStack attemptFill( World world, MovingObjectPosition p ) { int id = world.getBlockId( p.blockX, p.blockY, p.blockZ ); if ( id == ModExample.blockFluidExample.blockID ) { if ( world.getBlockMetadata( p.blockX, p.blockY, p.blockZ ) == 0 ) // Check that it is a source block { world.setBlock( p.blockX, p.blockY, p.blockZ, 0 ); // Remove the fluid block return new ItemStack( ModExample.bucketExample ); } } return null; } Phew. I think that's all, though. If it doesn't work, I'll check to see if I've missed anything. Quote
mardiff Posted July 16, 2013 Posted July 16, 2013 I'm not sure what I did wrong, but the texture on the liquid in game doesn't work. All I know is that the error is unhappy with the this.getFluid().setIcons(this.theIcon[0], this.theIcon[1]); Here's the whole class: package mardiff.ethanol.fluids; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockStationary; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.util.DamageSource; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.BlockFluidClassic; public class BlockEthanolLiquid extends BlockFluidClassic { protected Icon[] theIcon; public BlockEthanolLiquid(int i) { super(i, ModFluids.ethanol, Material.water); this.setCreativeTab(CreativeTabs.tabMisc); ModFluids.ethanol.setBlockID(this); this.getFluid().setIcons(this.theIcon[0], this.theIcon[1]); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { this.theIcon = new Icon[]{iconRegister.registerIcon("ethanol:ethanol_still"), iconRegister.registerIcon("ethanol:ethanol_flow")}; } @Override @SideOnly(Side.CLIENT) public Icon getIcon(int side, int meta) { if ( side <= 1 ) { return this.theIcon[0]; } else { return this.theIcon[1]; } } } Edit: *facepalm* It wasn't the code, it was that I was using my 1.5 textures.... Everything works fine! Quote If you really want help, give that modder a thank you. Modders LOVE thank yous.
Kakarotvg Posted August 13, 2013 Posted August 13, 2013 Homietoo could you post the entire source code for the liquid, because some of what you said I couldn't understand. Quote if (You.likescoding == false){ You.goaway; }
Mazetar Posted August 13, 2013 Posted August 13, 2013 On 8/13/2013 at 5:39 AM, Kakarotvg said: Homietoo could you post the entire source code for the liquid, because some of what you said I couldn't understand. http://www.minecraftforum.net/topic/1886370-forge16x-mazs-tutorials-working-custom-sounds-w-random-sound-from-soundpool-190713/ Quote Quote If you guys dont get it.. then well ya.. try harder...
Kakarotvg Posted August 14, 2013 Posted August 14, 2013 I finally got the bucket to place the liquid but I can't get the the bucket to pick up the liquid, it keeps giving water bucket instead of darkness bucket. this is my bucket code please help. Reveal hidden contents package kakarotvg.omega.items; import kakarotvg.omega.ItemHandler; import kakarotvg.omega.LiquidHandler; import kakarotvg.omega.Reference; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.item.ItemBucket; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.event.Event.Result; import net.minecraftforge.event.EventPriority; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.player.FillBucketEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class VgBucket extends ItemBucket { private String itemName; @SideOnly(Side.CLIENT) @Override public void registerIcons(IconRegister register) { this.itemIcon = register.registerIcon(Reference.MOD_ID + ":" + (this.getUnlocalizedName().substring(5))); } public VgBucket(int id, int par1, String name) { super(id, par1); this.itemName = name; this.setUnlocalizedName(name); } @ForgeSubscribe public void onBucketFill(FillBucketEvent event) { ItemStack result = attemptFill(event.world, event.target); if (result != null) { event.result = result; event.setResult(Result.ALLOW); } } private ItemStack attemptFill(World world, MovingObjectPosition p) { int id = world.getBlockId(p.blockX, p.blockY, p.blockZ); if (id == LiquidHandler.Darknessliquid.blockID) { if (world.getBlockMetadata(p.blockX, p.blockY, p.blockZ) == 0) // Check that it is a source block { world.setBlock(p.blockX, p.blockY, p.blockZ, 0); // Remove the fluid block return new ItemStack(ItemHandler.darknessbucket); // Return the filled bucked item here. } } return null; } } Quote if (You.likescoding == false){ You.goaway; }
patrick96 Posted October 17, 2013 Posted October 17, 2013 @Kakarotvg you need to add this line: MinecraftForge.EVENT_BUS.register(this); to the constructor of the VgBucket: public VgBucket(int id, int par1, String name) { super(id, par1); this.itemName = name; this.setUnlocalizedName(name); MinecraftForge.EVENT_BUS.register(this); } Quote http://i.imgur.com/iacT01q.png[/img]
Kakarotvg Posted October 18, 2013 Posted October 18, 2013 First of all I acutally solved this a while back, but I put the event itself in a different class, and the event register in a different class. Quote if (You.likescoding == false){ You.goaway; }
patrick96 Posted October 18, 2013 Posted October 18, 2013 Sorry I didn't notice the Solved-tag in the title Quote http://i.imgur.com/iacT01q.png[/img]
Kakarotvg Posted October 19, 2013 Posted October 19, 2013 its ok Quote if (You.likescoding == false){ You.goaway; }
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.