Jump to content

Modded 1.16 fluid has no physics


NullDev

Recommended Posts

I have modded a fluid into the game, but it does not push entities like water does, nor does it allow the player to float in it. I have tried adding .density(1) and .viscosity(1) in the fluid attributes builder, but it did nothing. There is also nothing in the water class that shows how the player can float in it.

My Class:

package com.nulldev.modbase.blocks;

import com.nulldev.modbase.ModBase;
import com.nulldev.modbase.util.CustomFluids;
import com.nulldev.modbase.util.RegistryHandler;
import net.minecraft.block.BlockState;
import net.minecraft.block.FlowingFluidBlock;
import net.minecraft.fluid.FlowingFluid;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.WaterFluid;
import net.minecraft.item.Item;
import net.minecraft.state.StateContainer;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fml.RegistryObject;

public abstract class RedWater extends FlowingFluid {

    @Override
    public Fluid getFlowingFluid() {
        return CustomFluids.flowingRedWater;
    }

    @Override
    public Fluid getStillFluid() {
        return CustomFluids.redWater;
    }

    @Override
    protected boolean canSourcesMultiply() {
        return false;
    }

    @Override
    protected void beforeReplacingBlock(IWorld worldIn, BlockPos pos, BlockState state) {

    }

    @Override
    protected int getSlopeFindDistance(IWorldReader worldIn) {
        return 1;
    }

    @Override
    protected int getLevelDecreasePerBlock(IWorldReader worldIn) {
        return 1;
    }

    @Override
    public Item getFilledBucket() {
        return RegistryHandler.RED_WATER_BUCKET.get();
    }

    @Override
    protected boolean canDisplace(FluidState p_215665_1_, IBlockReader p_215665_2_, BlockPos p_215665_3_, Fluid p_215665_4_, Direction p_215665_5_) {
        return true;
    }

    @Override
    public int getTickRate(IWorldReader p_205569_1_) {
        return 5;
    }

    @Override
    protected float getExplosionResistance() {
        return 100;
    }

    @Override
    protected BlockState getBlockState(FluidState state) {
        return RegistryHandler.RED_WATER.get().getDefaultState().with(FlowingFluidBlock.LEVEL, Integer.valueOf(getLevelFromState(state)));
    }

    @Override
    public boolean isEquivalentTo(Fluid fluidIn) {
        return fluidIn == CustomFluids.redWater || fluidIn == CustomFluids.flowingRedWater;
    }

    @Override
    protected FluidAttributes createAttributes() {
        return FluidAttributes.builder(RegistryHandler.location("blocks/red_water_still"), RegistryHandler.location("blocks/red_water_flowing"))
                .translationKey("block." + ModBase.MODID + ".red_water")
                .density(1)
                .viscosity(2)
                .build(this);
    }

    public static class Flowing extends RedWater {

        @Override
        protected void fillStateContainer(StateContainer.Builder<Fluid, FluidState> builder) {
            super.fillStateContainer(builder);
            builder.add(LEVEL_1_8);
        }

        @Override
        public boolean isSource(FluidState state) {
            return false;
        }

        @Override
        public int getLevel(FluidState state) {
            return state.get(RedWater.LEVEL_1_8);
        }
    }

    public static class Source extends RedWater {

        @Override
        public boolean isSource(FluidState state) {
            return true;
        }

        @Override
        public int getLevel(FluidState state) {
            return 8;
        }
    }
}

I had seen another post that said to put this in data/minecraft/tags/fluids:

{
  "replace": false,
  "values": [
    "tso_blocksdrawing:still_red_water",
    "tso_blocksdrawing:flowing_red_water"
  ]
}

but that produced this error when I tried loading the world:

Couldn't load fluid tag minecraft:water as it is missing following references: tso_blocksdrawing:still_red_water (from main),tso_blocksdrawing:flowing_red_water (from main)

 

Link to comment
Share on other sites

Well, you should have it, since that's why you get the error, the .png files and the .mcmeta files since the .mcmeta files are for animation if I'm not mistaken.

This is what the .mcmeta have.

{
    "animation":
    {
        "frametime": 4
    }
}
Edited by brok4d
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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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