Jump to content

[1.7.10] Custom bucket gives infinite water sources + Tank problem [Solved]


Iceminecrafter

Recommended Posts

After creating two oil buckets, custom fluid, then when testing it created infinite from the bucket, so i obviously did something wrong, and when trying to add the liquids into tanks it doesn't show a texture, or in portable tanks it shows lava, I'll add in my fluid classes and the bucket, ask if anything else is needed

 

Filled bucket

 

 

 

package com.iceminecrafter.IME.items;

 

import com.iceminecrafter.IME.IcesMinecraftExpansion;

 

import net.minecraft.block.Block;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemBucket;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

public class MFCOilBucket extends ItemBucket {

 

 

public MFCOilBucket(Block block) {

super(block);

 

this.setCreativeTab(IcesMinecraftExpansion.MFC);

 

 

 

}

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, int x, int y, int z, EntityPlayer par3EntityPlayer)

    {

if (this.tryPlaceContainedLiquid(par2World, x, y, z) && !par3EntityPlayer.capabilities.isCreativeMode)

{

return new ItemStack(Items.bucket);

}

else{

return par1ItemStack;

}

    }

   

 

public boolean tryPlaceContainedLiquid(World world, int x, int y, int z){

if(!world.isAirBlock(x,y,z)){

return false;

}else {

world.setBlock(x, y, z, IcesMinecraftExpansion.MFCCrudeOil, 0, 3);

}

 

return false;

}

 

}

 

 

 

Fluid class

 

 

package com.iceminecrafter.IME.blocks;

 

import com.iceminecrafter.IME.IcesMinecraftExpansion;

 

import net.minecraft.block.material.Material;

import net.minecraftforge.fluids.BlockFluidClassic;

import net.minecraftforge.fluids.Fluid;

 

public class MFCCrudeOil extends BlockFluidClassic{

 

public MFCCrudeOil(Fluid fluid, Material material) {

super(IcesMinecraftExpansion.CrudeOil, Material.water);

 

 

}

 

}

 

 

 

 

Fluid block class

 

 

package com.iceminecrafter.IME.blocks;

 

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.util.IIcon;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import net.minecraftforge.fluids.BlockFluidClassic;

import net.minecraftforge.fluids.Fluid;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class MFCBlockCrudeOil extends BlockFluidClassic{

@SideOnly(Side.CLIENT)

    protected IIcon stillIcon;

    @SideOnly(Side.CLIENT)

    protected IIcon flowingIcon;

   

    public MFCBlockCrudeOil(Fluid fluid, Material material) {

            super(fluid, material);

            setCreativeTab(CreativeTabs.tabMisc);

    }

   

    @Override

    public IIcon getIcon(int side, int meta) {

            return (side == 0 || side == 1)? stillIcon : flowingIcon;

    }

   

    @SideOnly(Side.CLIENT)

    @Override

    public void registerBlockIcons(IIconRegister register) {

            stillIcon = register.registerIcon("metalforgecraft:CrudeOilStill");

            flowingIcon = register.registerIcon("metalforgecraft:CrudeOilFlowing");

    }

   

    @Override

    public boolean canDisplace(IBlockAccess world, int x, int y, int z) {

            if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;

            return super.canDisplace(world, x, y, z);

    }

   

    @Override

    public boolean displaceIfPossible(World world, int x, int y, int z) {

            if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;

            return super.displaceIfPossible(world, x, y, z);

    }

}

 

 

 

 

Main class fluid stuff

 

 

CrudeOil = new Fluid("CrudeOil").setDensity(2000);

FluidRegistry.registerFluid(CrudeOil);

materialOil = new MaterialLiquid(MapColor.obsidianColor);

MFCCrudeOil = new MFCCrudeOil(CrudeOil, materialOil).setBlockName("MFCCrudeOil").setCreativeTab(MFC).setBlockTextureName("metalforgecraft" + ":CrudeOilStill");

 

 

MFCOilBucket = new MFCOilBucket(MFCCrudeOil).setUnlocalizedName("MFCOilBucket").setMaxStackSize(1).setContainerItem(Items.bucket).setTextureName("metalforgecraft" + ":OilBucket");

 

 

MFCSolidCrudeOil = new MFCSolidCrudeOil().setBlockName("MFCSolidCrudeOil").setCreativeTab(MFC).setBlockTextureName("metalforgecraft" + ":CrudeOilStill");

 

MFCOilShale = new com.iceminecrafter.IME.blocks.MFCOilShale().setBlockName("MFCOilShale").setCreativeTab(MFC).setBlockTextureName("metalforgecraft" + ":OilShale");

 

 

 

ShaleOil = new Fluid("ShaleOil").setDensity(2000);

FluidRegistry.registerFluid(ShaleOil);

MFCShaleOil = new MFCShaleOil(ShaleOil, materialOil).setBlockName("MFCShaleOil").setCreativeTab(MFC).setBlockTextureName("metalforgecraft" + ":CrudeOilStill");

 

 

MFCShaleOilBucket = new MFCShaleOilBucket(MFCShaleOil).setUnlocalizedName("MFCShaleOilBucket").setMaxStackSize(1).setContainerItem(Items.bucket).setTextureName("metalforgecraft" + ":OilBucket");

 

 

 

 

 

 

Help is much appreciated. And if your just gonna say words to the effect of "Go do it yourself / find it out" don't even bother as I've looked and tried

Link to comment
Share on other sites

You are not setting the block to your fluid ... so it goes water as default + it should be onItemUse method + you need to override

 

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

Thanks, fixed afew things, yet buckets are still infinite, and It wont accept the @Override notation above the onItemUse

 

 

 

package com.iceminecrafter.IME.items;

 

import com.iceminecrafter.IME.IcesMinecraftExpansion;

 

import net.minecraft.block.Block;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemBucket;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

public class MFCOilBucket extends ItemBucket {

 

 

public MFCOilBucket(Block block) {

super(block);

 

this.setCreativeTab(IcesMinecraftExpansion.MFC);

 

 

 

}

public ItemStack onItemUse(ItemStack par1ItemStack, World par2World, int x, int y, int z, EntityPlayer par3EntityPlayer)

    {

if (this.tryPlaceContainedLiquid(par2World, x, y, z) && !par3EntityPlayer.capabilities.isCreativeMode)

{

return new ItemStack(Items.bucket);

}

else{

return par1ItemStack;

}

    }

   

 

public boolean tryPlaceContainedLiquid(World world, int x, int y, int z){

if(!world.isAirBlock(x,y,z)){

return false;

}else {

world.setBlock(x, y, z, IcesMinecraftExpansion.MFCCrudeOil, 0, 3);

}

 

return false;

}

 

}

 

 

 

Link to comment
Share on other sites

maybe its because you dont have correct parameters ? you should look to item.class to see

 

theses are the correct parameters

ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_

 

+ its public boolean onItemUse

 

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

Ok, I can place it down now, yet I can't pick it back up...

 

Call super.onItemUse instead of returning (in else block)... Please update your code, if you are wondering where is else block...

 

Also, it could be better idea to use item fluid containers, but oh well...

Link to comment
Share on other sites

Filled bucket

 

 

package com.iceminecrafter.IME.items;

 

import com.iceminecrafter.IME.IcesMinecraftExpansion;

 

import net.minecraft.block.Block;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemBucket;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

public class MFCOilBucket extends ItemBucket {

 

 

public MFCOilBucket(Block block) {

super(block);

 

this.setCreativeTab(IcesMinecraftExpansion.MFC);

 

 

 

}

public ItemStack onItemUse(ItemStack par1ItemStack, World par2World, int x, int y, int z, EntityPlayer par3EntityPlayer)

    {

if (this.tryPlaceContainedLiquid(par2World, x, y, z) && !par3EntityPlayer.capabilities.isCreativeMode)

{

return new ItemStack(Items.bucket);

}

else{

return par1ItemStack;

}

    }

   

@Override

public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_){

if(!p_77648_3_.isAirBlock(p_77648_4_,p_77648_5_,p_77648_6_)){

return false;

}else {

p_77648_3_.setBlock(p_77648_4_,p_77648_5_,p_77648_6_, IcesMinecraftExpansion.MFCCrudeOil, 0, 3);

}

 

return false;

}

 

}

 

 

 

 

Liquids

 

 

package com.iceminecrafter.IME.blocks;

 

import com.iceminecrafter.IME.IcesMinecraftExpansion;

 

import net.minecraft.block.material.Material;

import net.minecraftforge.fluids.BlockFluidClassic;

import net.minecraftforge.fluids.Fluid;

 

public class MFCCrudeOil extends BlockFluidClassic{

 

public MFCCrudeOil(Fluid fluid, Material material) {

super(IcesMinecraftExpansion.CrudeOil, IcesMinecraftExpansion.materialOil);

 

 

}

 

}

 

 

 

 

Liquid Blocks

 

 

package com.iceminecrafter.IME.blocks;

 

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.util.IIcon;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import net.minecraftforge.fluids.BlockFluidClassic;

import net.minecraftforge.fluids.Fluid;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class MFCBlockCrudeOil extends BlockFluidClassic{

@SideOnly(Side.CLIENT)

    protected IIcon stillIcon;

    @SideOnly(Side.CLIENT)

    protected IIcon flowingIcon;

   

    public MFCBlockCrudeOil(Fluid fluid, Material material) {

            super(fluid, material);

            setCreativeTab(CreativeTabs.tabMisc);

    }

   

    @Override

    public IIcon getIcon(int side, int meta) {

            return (side == 0 || side == 1)? stillIcon : flowingIcon;

    }

   

    @SideOnly(Side.CLIENT)

    @Override

    public void registerBlockIcons(IIconRegister register) {

            stillIcon = register.registerIcon("metalforgecraft:CrudeOilStill");

            flowingIcon = register.registerIcon("metalforgecraft:CrudeOilFlowing");

    }

   

    @Override

    public boolean canDisplace(IBlockAccess world, int x, int y, int z) {

            if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;

            return super.canDisplace(world, x, y, z);

    }

   

    @Override

    public boolean displaceIfPossible(World world, int x, int y, int z) {

            if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;

            return super.displaceIfPossible(world, x, y, z);

    }

}

 

 

 

 

Main Class

 

 

//Fluid related (Do in order)

CrudeOil = new Fluid("CrudeOil").setDensity(2000);

FluidRegistry.registerFluid(CrudeOil);

materialOil = new MaterialLiquid(MapColor.obsidianColor);

MFCCrudeOil = new MFCCrudeOil(CrudeOil, materialOil).setBlockName("MFCCrudeOil").setCreativeTab(MFC).setBlockTextureName("metalforgecraft" + ":CrudeOilStill");

 

 

MFCOilBucket = new MFCOilBucket(MFCCrudeOil).setUnlocalizedName("MFCOilBucket").setMaxStackSize(1).setContainerItem(Items.bucket).setTextureName("metalforgecraft" + ":OilBucket");

 

 

MFCSolidCrudeOil = new MFCSolidCrudeOil().setBlockName("MFCSolidCrudeOil").setCreativeTab(MFC).setBlockTextureName("metalforgecraft" + ":CrudeOilStill");

 

MFCOilShale = new com.iceminecrafter.IME.blocks.MFCOilShale().setBlockName("MFCOilShale").setCreativeTab(MFC).setBlockTextureName("metalforgecraft" + ":OilShale");

 

 

 

ShaleOil = new Fluid("ShaleOil").setDensity(2000);

FluidRegistry.registerFluid(ShaleOil);

MFCShaleOil = new MFCShaleOil(ShaleOil, materialOil).setBlockName("MFCShaleOil").setCreativeTab(MFC).setBlockTextureName("metalforgecraft" + ":CrudeOilStill");

 

 

MFCShaleOilBucket = new MFCShaleOilBucket(MFCShaleOil).setUnlocalizedName("MFCShaleOilBucket").setMaxStackSize(1).setContainerItem(Items.bucket).setTextureName("metalforgecraft" + ":OilBucket");

 

 

 

Link to comment
Share on other sites

Ok, I can place it down now, yet I can't pick it back up...

 

Call super.onItemUse instead of returning (in else block)... Please update your code, if you are wondering where is else block...

 

Also, it could be better idea to use item fluid containers, but oh well...

 

I have no idea what you mean by any of this, and by update do you mean to 1.8? or just to a newer version of forge, as Im not planning on updating my mod for awhile due to it being in a custom modpack

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.