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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • my bad i finally found the way to find the support forums. Ill try this out     
    • There are a few Forge specific mods that I would dearly love to use on my new server, but my friend whom I'm setting up the new server with has expressed concerns that Forge may break or change some core mechanics that might make some farms/contraptions/Redstone devices that work in Vanilla or Fabric not work in Forge. They have sent me a few links to some Twitch minecrafters that have commented that "Forge changes Redstone behavior" or "Certain farms are broken on Forge but not Vanilla", however, I've never experienced this myself, and haven't found or seen any actual examples of this being the case.  I've scoured Youtube and can't find anyone saying "This contraption doesn't work on Forge Ole777".  I spoke to a mod developer who mentioned that there may have been small bugs where this might have been the case in extremely complicated builds, but he is not of aware of this still being an issue or concern. And he mentioned that any instance where something might break would definitely be considered a bug and should be reported and it would/could be fixed, as Forge explicitly doesn't intend to change any vanilla behavior. It just seems much more rumor than fact that Forge might break things, and just wanted to see if anyone had any input. Thank you!
    • This is a costume block whit the shape of a zombie is not a full block its flamable when ignited  the flames just burn on top or by a aside  that dint seems right  // ########## ########## ########## ########## @Override public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {     return 300;//((FireBlock)Blocks.FIRE).getBurnOdds(state); //300 } it just seems like check to know if a fire block could despawn mi block    ########### i want mi block to look more like this      what could i use  i was thinking on something like onNeigbourgChange() check for nearby fire or lava blocks   then using the falling block entity spawn a fire block in the same position than mi dead body block  thanks for your readings             
    • LINK DAFTAR AKUN GACOR VVIP BAMBUHOKI88 LINK LOGIN RESMI BAMBUHOKI88 LINK KLAIM BONUS 100% BAMBUHOKI88 Bambuhoki88 Merupakan kumpulan pilihan link situs rekomendasi slot bank bri di tahun 2024 di rekomendasi oleh para slotter deposit bank bri di indonesia dengan tingkat peluang kemenangan tinggi untuk setiap bet mudah menang maxwin.
    • LINK DAFTAR AKUN GACOR VVIP BAMBUHOKI88 LINK LOGIN RESMI BAMBUHOKI88   LINK KLAIM BONUS 100% BAMBUHOKI88 BAMBUHOKI88 Merupakan Pilihan Terbaik Situs Slot Bank Bca Yang Gampang Menang Maxwin Dan Jackpot Besar Dengan Deposit Bank Bca Yang Online 24Jam Auto Dapat Wd Gede.  
×
×
  • Create New...

Important Information

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