Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.x][Question]fluid generators


Recommended Posts

I was trying to find some information and documentation about making a lava or water generator like i would do with ItemStack but with Fluids but unable to find much i been following tutorials in making basic items/tools/armor and excited i was able to figure but i started the process but got stuck after getting this far


package raziel23x.projectskyblock.utils;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import raziel23x.projectskyblock.ProjectSkyblock;
import raziel23x.projectskyblock.blocks.*;

public class RegistryHandler {

public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ProjectSkyblock.MOD_ID);
    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ProjectSkyblock.MOD_ID);
    private static final DeferredRegister<TileEntityType<?>> TILES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, ProjectSkyblock.MOD_ID);
  public static final RegistryObject<Block> LAVA_GENERATOR_BLOCK  = BLOCKS.register("lava_generator_block", LavaGeneratorBlock::new);
   public static final RegistryObject<Item> LAVA_GENERATOR_BLOCK_ITEM = ITEMS.register("lava_generator_block", () -> new BlockItemBaseLavaGenerator(LAVA_GENERATOR_BLOCK.get()));
  public static final RegistryObject<TileEntityType<LavaGeneratorTile>> LAVAGENERATOR_TILE = TILES.register("lava_generator_block", () -> TileEntityType.Builder.create(LavaGeneratorTile::new, LAVA_GENERATOR_BLOCK.get()).build(null));
  public static void init() {





package raziel23x.projectskyblock.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;

import javax.annotation.Nullable;

public class LavaGeneratorBlock extends Block {
    public LavaGeneratorBlock(){


    public boolean hasTileEntity(BlockState state) {
        return true;

    public TileEntity createTileEntity(BlockState state, IBlockReader world) {
        return new LavaGeneratorTile();



package raziel23x.projectskyblock.blocks;

import net.minecraft.fluid.Fluids;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.templates.FluidTank;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import static raziel23x.projectskyblock.utils.RegistryHandler.LAVAGENERATOR_TILE;

public class LavaGeneratorTile extends TileEntity implements ITickableTileEntity {
    private int tick;
    public LavaGeneratorTile() {

    public void tick() {
        if (tick == 10) {
            tick = 0;
            FluidStack stack = new FluidStack(Fluids.LAVA, Integer.MAX_VALUE);
         // CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY


    public LazyOptional<FluidTank> fluidHandler = LazyOptional.of(this::createFluidHandler);

    public FluidTank getFluidHandler() {
        return fluidHandler.orElseThrow(RuntimeException::new);

    public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
        if (!this.removed) {
            if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
                return this.fluidHandler.cast();
        return super.getCapability(cap, side);

    private FluidTank createFluidHandler() {
        return new FluidTank(FluidAttributes.BUCKET_VOLUME * 8) {
            protected void onContentsChanged() {



package raziel23x.projectskyblock.blocks;

import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import raziel23x.projectskyblock.ProjectSkyblock;

import java.util.List;

public class BlockItemBaseLavaGenerator extends BlockItem {
    public BlockItemBaseLavaGenerator(Block block) {
        super(block, new Properties().group(ProjectSkyblock.TAB).maxStackSize(1));
    public void addInformation(ItemStack stack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
        tooltip.add((new TranslationTextComponent("tip."+ProjectSkyblock.MOD_ID+".LavaGeneratorline1").mergeStyle(TextFormatting.GREEN)));
        tooltip.add((new TranslationTextComponent("tip."+ProjectSkyblock.MOD_ID+".LavaGeneratorline2").mergeStyle(TextFormatting.YELLOW)));
        super.addInformation(stack, worldIn, tooltip, flagIn);



out on my own about a simple cobblegen and though i would try my hand at doing one for water and lava just to see if i can pull it off but cant seem to find much information


i am just lost and maybe someone could point me in the right direction

Edited by raziel23x

Please Kill me i am married with 2 kids HELP!!!!!!!!

Link to comment
Share on other sites

If I remember correctliiy there are some nbt tags about how much an container is filled with fluids.

I wouldn't recommend doing the graphical interface yourself.

I am sure there are some libaries which could handle the graphics for you.


If you want to find out which blockdata to add to your block:

Download any mod which adds fluid containers

place one of them in your world 

then read out the blockdata of the block

/blockdata x y z 

x y and z can be retrieved by typing out / blockdata  and then pressing [Tab] for each coordinate whilst looking directly at the block of your destination


I hope I could help

I am going to research an fluid interface 


here is an topic discussion explaining how to do it

here you can find a list of libaries:



I hope I could help...

Dennis out!

Link to comment
Share on other sites

Vanilla buckets know nothing about a modded block whose tile entity offers a fluid capability.  You need to code the bucket-filling logic in your block's onBlockActivated() method.  Tip: don't just check for a bucket, check for any item which offers the CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, since that would also allow other mod fluids containers (tanks etc.) to be filled from your block.

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.

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 Privacy Policy.