Jump to content

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


Recommended Posts

Posted

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

Posted

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);

Posted

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());


	}

Posted

Example:

 

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

Come on dude, learn basic Java before modding.

Posted

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 )

Posted

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/

Posted

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();
}

Posted

Well I changed my bucket Handler code and that fixed the problem!

( I got some inspiration from the buildcraft code from the Minecraft forge wiki )

Everything is working now! Thanks for the help!

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Thank you so much Choonster! That's what i was missing! For now i added a folder assets/<mod_id>/items and put the model definition JSON file with the item name in it: { "model":{ "type": "minecraft:model", "model": "teleportpugmod:item/teleportpug" } }   Some log errors/warnings pointing me into the right direction would've been nice 😅 Haven't had much time to look into the DataGenerator and ModelProviders, because i'm still at work. But i guess these would would make more sense if have many custom items and want to generate these model definition files?
    • Minecraft 1.21.4 requires a new model definition file for each item, which you don't have. These can be created through Data Generation, specifically the ModelProvider, BlockModelGenerators and ItemModelGenerators classes.
    • Hi,  I'm using Forge 47.3.0 for Minecraft 1.20.1 I apologise if this is obvious I am very new to modding for Minecraft. I sucessfully made a mod that launched without errors or crashes (without it doing anything) but in order to add the features I need, I need to add "Custom Portal API [Forge]" as a dependency. However no matter the way I've tried to acheive this, it crashes. I am pretty sure it's not the way I'm putting it in the repositories, the dependencies or the way I'm refrencing it, as I've a hundred diffrent combinations and multiple Maven methods. And on all those diffrent variations I still get this crash: pastebin.com/UhumzZCZ Any tips would be invaluable as I've been loosing my mind over this!
    • Hi, i'm really having problems trying to set the texture to my custom item. I thought i'm doing everything correctly, but all i see is the missing texture block for my item. I am trying this for over a week now and getting really frustrated. The only time i could make the texture work, was when i used an older Forge version (52.0.1) for Minecraft (1.21.4). Was there a fundamental change for textures and models somewhere between versions that i'm missing? I started with Forge 54.1.0 and had this problem, so in my frustration i tried many things: Upgrading to Forge 54.1.1, created multiple new projects, workspaces, redownloaded everything and setting things up multiple times, as it was suggested in an older thread. Therea are no errors in the console logs, but maybe i'm blind, so i pasted the console logs to pastebin anyway: https://pastebin.com/zAM8RiUN The only time i see an error is when i change the models JSON file to an incorrect JSON which makes sense and that suggests to me it is actually reading the JSON file.   I set the github repository to public, i would be so thankful if anyone could take a look and tell me what i did wrong: https://github.com/xLorkin/teleport_pug_forge   As a note: i'm pretty new to modding, this is my first mod ever. But i'm used to programming. I had some up and downs, but through reading the documentation, using google and experimenting, i could solve all other problems. I only started modding for Minecraft because my son is such a big fan and wanted this mod.
    • Please read the FAQ (link in orange bar at top of page), and post logs as described there.
  • Topics

×
×
  • Create New...

Important Information

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