Jump to content

[1.7.2] Empty bucket + Custom Fluid returns a bucket of water?


poonkje112

Recommended Posts

Hello everyone!

 

I'm trying to make bucket in forge it works except if I right click with a empty bucket it returns a water bucket but I didn't define to return a water bucket so what is the problem?

 

Edit:

Beter explanation I created a fluid but when I right click with an empty vanilla minecraft bucket it just returns water?

So i don't understand why it's returning water??

( I set the material of the fluid to Material.water to give the ability to swim. )

 

Code:

 

 

MainClass:

public Fluid CrystalFluid = new Fluid("CrystalFluid");

//Fluids TODO
	public static final int FluidCrystalID = 3003;
	public static Block blockCrystalFluid;
	public static Fluid fluidCrystal;
	public static Material Crystal;
	public static Item BucketHotSpring = new BucketHotSpring(blockCrystalFluid, FluidCrystalID);


	@EventHandler
	public void preInit(FMLPreInitializationEvent  e) throws IOException {

		//FLUIDS TODO
        fluidCrystal = new Fluid("fluid");
        FluidRegistry.registerFluid(fluidCrystal);
        FluidRegistry.registerFluid(CrystalFluid);
        
        Crystal = new MaterialLiquid(MapColor.iceColor);
        
        blockCrystalFluid = new blockCrystalFluid(FluidCrystalID).setBlockTextureName("optical:HotSpring").setBlockName("CrystalFluid");

		FluidRegistry.registerFluid(CrystalFluid);

		//Item BucketHotSpring = new BucketHotSpring(blockCrystalFluid, 250);
		GameRegistry.registerBlock(blockCrystalFluid, "Fluid Iron");
		GameRegistry.registerItem(BucketHotSpring, BucketHotSpring.getUnlocalizedName());
		MinecraftForge.EVENT_BUS.register(new ScratchFillBucketIEvent());


	}

public MainClass() {


}

 

BucketHotSpring:

package com.poonkje.optical.event;

import com.poonkje.optical.common.MainClass;

import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.FillBucketEvent;

public class ScratchFillBucketIEvent {

public class BreakingBadFillBucketEvent {
    public ItemStack fullBucket;

    @SubscribeEvent
    public void whenITryToFillMyBucket(FillBucketEvent event) {
        if (event.current.getItem() != MainClass.BucketHotSpring) return;

        fullBucket = getLiquid(event.world, event.target);

        if (fullBucket == null) return;

        event.world.setBlockToAir(event.target.blockX, event.target.blockY, event.target.blockZ);
        event.result = fullBucket;
        event.setResult(Event.Result.ALLOW);
    }


    public ItemStack getLiquid(World world, MovingObjectPosition pos) {
        Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);

        if (MainClass.blockCrystalFluid == block) {
            return new ItemStack(MainClass.BucketHotSpring);
        }

        return null;
    }
}
}

 

FillBucketEvent:

package com.poonkje.optical.common;

import net.minecraft.block.Block;
import net.minecraft.item.ItemBucket;
import net.minecraft.world.World;

public class BucketHotSpring extends ItemBucket {
    private int liquidID;

    public BucketHotSpring(Block p_i45331_1_, int liquidID) {
        super(p_i45331_1_);
        this.setCreativeTab(MainClass.Opticaltab);
        this.setUnlocalizedName("Hydrofluoric Acid");
        this.setTextureName("breakingbad:FullPlasticContainer");
        this.setMaxStackSize(1);
        this.setContainerItem(MainClass.BucketHotSpring);
        this.liquidID = liquidID;
    }

    @Override
    public boolean tryPlaceContainedLiquid(World par1World, int par2, int par3, int par4) {
        if (liquidID <= 0) {
            return false;
        }
        else if (!par1World.isAirBlock(par2, par3, par4) && par1World.getBlock(par2, par3, par4).getMaterial().isSolid()) {
            return false;
        }
        else {
            par1World.setBlock(par2, par3, par4, MainClass.blockCrystalFluid, 0, 3);
            return true;
        }
    }
}

Allready thanks for the help!

 

Regards,

poonkje112

Link to comment
Share on other sites

How did you do - and expect it to load?

Forge doesn't read it in class construction - only in the preInit method.

public static Item BucketHotSpring = new BucketHotSpring(blockCrystalFluid, FluidCrystalID);

 

Well first thing first i edited my first post for an better explanation about my problem.

But when i put the code:

public static Item BucketHotSpring = new BucketHotSpring(blockCrystalFluid, FluidCrystalID);

In FMLPreInitializationEvent it doesn't want me to say public static and the other classes ( BucketHotSpring and ScratchFillBucketEvent ) Giving me an error.

So how do i fix that?

PreInit:

		@EventHandler
	public void preInit(FMLPreInitializationEvent  e) throws IOException {

		//FLUIDS TODO
        fluidCrystal = new Fluid("fluid");
        FluidRegistry.registerFluid(fluidCrystal);
        FluidRegistry.registerFluid(CrystalFluid);
        
        Crystal = new MaterialLiquid(MapColor.iceColor);
        
        blockCrystalFluid = new blockCrystalFluid(FluidCrystalID).setBlockTextureName("optical:HotSpring").setBlockName("CrystalFluid");

		FluidRegistry.registerFluid(CrystalFluid);

		//final Item BucketHotSpring = new BucketHotSpring(blockCrystalFluid, FluidCrystalID);

		//Item BucketHotSpring = new BucketHotSpring(blockCrystalFluid, 250);
		GameRegistry.registerBlock(blockCrystalFluid, "Fluid Iron");
		GameRegistry.registerItem(BucketHotSpring, BucketHotSpring.getUnlocalizedName());
		MinecraftForge.EVENT_BUS.register(new ScratchFillBucketIEvent());


	}

Link to comment
Share on other sites

Example:

 

public static Item example;
@EventHandler
public void preInit(FMLPreInitializationEvent  e)  {
example = new ExampleItem().setUnlocalizedName("exampleItem");
}

Come on dude, learn basic Java before modding.

 

Well yes i learned java but sometimes I forget some stuff.

And now I putted the item in the preInit but the fluid is still returning water with an empty bucket so I don't Know what the problem is i didn't call a method to return water? Only with the Material?

(Fluid Code With the material )

package com.poonkje.optical.common; 

import java.util.Random;

import net.minecraft.block.material.Material;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class blockCrystalFluid extends BlockFluidClassic {

public blockCrystalFluid(int id) {
	super(MainClass.fluidCrystal, /**MainClass.Crystal*/ Material.water);

	this.setCreativeTab(MainClass.Opticaltab);
}
//Add particles
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
	float f1 = (float)x + 0.5F;
	float f2 = (float)y + 1.1F;
	float f3 =(float)z + 0.5F;
	float f4 = random.nextFloat() * 0.3F;
	float f5 = random.nextFloat() * -0.6F - -0.3F;

	world.spawnParticle("smoke", (double)(f1+f4), (double)f2, (double)(f3+f5), 0.0D, 0.0D, 0.0D);
}
}
  

 

Edit:

Well i changed the material to my own material and now it's returning nothing so i'm pretty sure i did something wrong with the material.

Crystal = new MaterialLiquid(MapColor.iceColor);

( I know i didn't add a method for isLiquid or something )

Link to comment
Share on other sites

When you right click with a bucket, it check for the material of the block you clicked on, and if that's Material.water, i return a water bucket, and the same for lava.

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/

Link to comment
Share on other sites

When you right click with a bucket, it check for the material of the block you clicked on, and if that's Material.water, i return a water bucket, and the same for lava.

Well what do I have to change/add to my material line?

public static Material Crystal;

@EventHandler
public void preInit(FMLPreInitializationEvent  e) throws IOException {
Crystal = new MaterialLiquid(MapColor.iceColor).setReplaceable();
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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