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

    • I made a custom pack, but i can't even load it, it just crashes at launcher, giving me Error 1. I looked at the log, and it just doesn't seem to tell me what the issue actually is. Here's the report.   Edit- Trying to get report, but copy paste being weird [22:59:59] [main/ERROR]:Error replacing mixin module source java.lang.ClassNotFoundException: cpw.mods.cl.JarModuleFinder$JarModuleReference at java.base/jdk.internal.loader.Loader.loadClass(Loader.java:571) ~[?:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] at cpw.mods.securejarhandler/net.minecraftforge.securemodules.SecureModuleClassLoader.loadClass(SecureModuleClassLoader.java:429) ~[securemodules-2.2.21.jar!/:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] at java.base/java.lang.Class.forName0(Native Method) ~[?:?] at java.base/java.lang.Class.forName(Class.java:421) ~[?:?] at java.base/java.lang.Class.forName(Class.java:412) ~[?:?] at LAYER SERVICE/[email protected]+1.20.1/io.github.steelwoolmc.mixintransmog.InstrumentationHack.inject(InstrumentationHack.java:46) ~[?:?] at LAYER SERVICE/[email protected]+1.20.1/io.github.steelwoolmc.mixintransmog.MixinTransformationService.<init>(MixinTransformationService.java:59) ~[?:?] at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) [?:?] at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) [?:?] at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) [?:?] at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789) [?:?] at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729) [?:?] at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403) [?:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.TransformationServicesHandler.discoverServices(TransformationServicesHandler.java:156) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:84) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:75) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapEntry.main(BootstrapEntry.java:17) [modlauncher-10.2.4.jar!/:?] at [email protected]/net.minecraftforge.bootstrap.Bootstrap.moduleMain(Bootstrap.java:188) [bootstrap-2.1.8.jar!/:?] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?] at net.minecraftforge.bootstrap.Bootstrap.bootstrapMain(Bootstrap.java:133) [bootstrap-2.1.8.jar:2.1.8] at net.minecraftforge.bootstrap.Bootstrap.start(Bootstrap.java:53) [bootstrap-2.1.8.jar:2.1.8] at net.minecraftforge.bootstrap.ForgeBootstrap.main(ForgeBootstrap.java:19) [bootstrap-2.1.8.jar:2.1.8] [22:59:59] [main/FATAL]:Encountered serious error loading transformation service, expect problems java.util.ServiceConfigurationError: cpw.mods.modlauncher.api.ITransformationService: Provider io.github.steelwoolmc.mixintransmog.MixinTransformationService could not be instantiated at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586) ~[?:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.TransformationServicesHandler.discoverServices(TransformationServicesHandler.java:156) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:84) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:75) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapEntry.main(BootstrapEntry.java:17) [modlauncher-10.2.4.jar!/:?] at [email protected]/net.minecraftforge.bootstrap.Bootstrap.moduleMain(Bootstrap.java:188) [bootstrap-2.1.8.jar!/:?] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?] at net.minecraftforge.bootstrap.Bootstrap.bootstrapMain(Bootstrap.java:133) [bootstrap-2.1.8.jar:2.1.8] at net.minecraftforge.bootstrap.Bootstrap.start(Bootstrap.java:53) [bootstrap-2.1.8.jar:2.1.8] at net.minecraftforge.bootstrap.ForgeBootstrap.main(ForgeBootstrap.java:19) [bootstrap-2.1.8.jar:2.1.8] Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: cpw.mods.cl.JarModuleFinder$JarModuleReference at LAYER SERVICE/[email protected]+1.20.1/io.github.steelwoolmc.mixintransmog.MixinTransformationService.<init>(MixinTransformationService.java:62) ~[?:?] at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[?:?] at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?] at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[?:?] at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789) ~[?:?] ... 12 more Caused by: java.lang.ClassNotFoundException: cpw.mods.cl.JarModuleFinder$JarModuleReference at java.base/jdk.internal.loader.Loader.loadClass(Loader.java:571) ~[?:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] at cpw.mods.securejarhandler/net.minecraftforge.securemodules.SecureModuleClassLoader.loadClass(SecureModuleClassLoader.java:429) ~[securemodules-2.2.21.jar!/:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] at java.base/java.lang.Class.forName0(Native Method) ~[?:?] at java.base/java.lang.Class.forName(Class.java:421) ~[?:?] at java.base/java.lang.Class.forName(Class.java:412) ~[?:?] at LAYER SERVICE/[email protected]+1.20.1/io.github.steelwoolmc.mixintransmog.InstrumentationHack.inject(InstrumentationHack.java:46) ~[?:?] at LAYER SERVICE/[email protected]+1.20.1/io.github.steelwoolmc.mixintransmog.MixinTransformationService.<init>(MixinTransformationService.java:59) ~[?:?] at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[?:?] at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?] at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[?:?] at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789) ~[?:?] ... 12 more [22:59:59] [main/INFO]:SpongePowered MIXIN Subsystem Version=0.8.7 Source=jar:file:///C:/Users/mxz/curseforge/minecraft/Install/libraries/org/spongepowered/mixin/0.8.7/mixin-0.8.7.jar!/ Service=ModLauncher Env=CLIENT at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813) ~[?:?] at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729) ~[?:?] at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403) ~[?:?]
    • here is a different world https://ibb.co/Q3VWj9gW and the server console https://ibb.co/dwQf0qrR
    • Mods: Securitycraft Appleskin Architectury betterarchiology betterburning betterchunkloading borderlesswindow botarium cebonsapi cebonsbetterbeacons charmofundying chunkloaders clothconfig cofhcore connectivity coroutil create enchant industry create misc and things create create confectionery create new age forge create stuff additions creative core cupboard curios custom player models drinkbeer drippy loading screen durability tooltip easyanvils embeddium enderitemod entityculling fancymenufarmers delight ferrite core flux networks framed blocks fusion gecolib gravestone mod iceberg inventory profiles next jade jade addons jei journeymap jer konkrete kotlin libIPN lootintegrations lootr melody mes mns mss mvs nethersdelight nullscape nyfsquiver puzzleslib recipeessentials It seems the problem is with mods that place features as different worlds give different errors after the start part  
    • I get this error when joining my 1.20.1 forge 47.4.0 / also tested on 47.3.39. It then shows a long list of mods and errors (see image). No crash occurs. https://cdn.discordapp.com/attachments/324493105313349644/1354950353665265824/image.png?ex=67e7275a&is=67e5d5da&hm=4006cb062aa548c3aff108082bf4ea5e44d6ead972da3b23102b74ea95f54c7c&
    • in fact, after removing the lootr, the situation only got worse
  • Topics

×
×
  • Create New...

Important Information

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