Jump to content

[1.9/SOLVED] Problem with fluids


JimiIT92

Recommended Posts

I'm updating my mod to 1.9, but i've soon noticed an issue with fluids. They are considered as solid blocks, therefore i cannot "dive" in them, i can literaly walk on water

gN2odtq.png

This is the code for my fluids (i have 4 of them in the same class)

package com.mineworld.fluids;

import com.mineworld.MW;

import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class MWFluids
{
    private static ModelResourceLocation corruptedfluidLocation = new ModelResourceLocation(MW.MODID + ":" + CorruptedFluidBlock.name, "fluid");
    private static ModelResourceLocation sacredfluidLocation = new ModelResourceLocation(MW.MODID + ":" + SacredFluidBlock.name, "fluid");
    private static ModelResourceLocation shadowfluidLocation = new ModelResourceLocation(MW.MODID + ":" + ShadowFluidBlock.name, "fluid");
    private static ModelResourceLocation crazyfluidLocation = new ModelResourceLocation(MW.MODID + ":" + CrazyFluidBlock.name, "fluid");
   
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) { 
    FluidRegistry.registerFluid(CorruptedFluid.instance);
    FluidRegistry.registerFluid(SacredFluid.instance);
    FluidRegistry.registerFluid(ShadowFluid.instance);
    FluidRegistry.registerFluid(CrazyFluid.instance);
    
    GameRegistry.registerBlock(CorruptedFluidBlock.instance, CorruptedFluidBlock.name);
    GameRegistry.registerBlock(SacredFluidBlock.instance, SacredFluidBlock.name);
    GameRegistry.registerBlock(ShadowFluidBlock.instance, ShadowFluidBlock.name);
    GameRegistry.registerBlock(CrazyFluidBlock.instance, CrazyFluidBlock.name);
    
    Item corrupted_fluid = Item.getItemFromBlock(CorruptedFluidBlock.instance);
    Item sacred_fluid = Item.getItemFromBlock(SacredFluidBlock.instance);
    Item shadow_fluid = Item.getItemFromBlock(ShadowFluidBlock.instance);
    Item crazy_fluid = Item.getItemFromBlock(CrazyFluidBlock.instance);
    
    
    ModelLoader.setCustomMeshDefinition(corrupted_fluid, new ItemMeshDefinition()
    {
        public ModelResourceLocation getModelLocation(ItemStack stack)
        {
            return corruptedfluidLocation;
        }
    });
    ModelLoader.setCustomMeshDefinition(sacred_fluid, new ItemMeshDefinition()
    {
        public ModelResourceLocation getModelLocation(ItemStack stack)
        {
            return sacredfluidLocation;
        }
    });
    ModelLoader.setCustomMeshDefinition(shadow_fluid, new ItemMeshDefinition()
    {
        public ModelResourceLocation getModelLocation(ItemStack stack)
        {
            return shadowfluidLocation;
        }
    });
    ModelLoader.setCustomMeshDefinition(crazy_fluid, new ItemMeshDefinition()
    {
        public ModelResourceLocation getModelLocation(ItemStack stack)
        {
            return crazyfluidLocation;
        }
    });

    
    ModelLoader.setCustomStateMapper(CorruptedFluidBlock.instance, new StateMapperBase()
    {
        protected ModelResourceLocation getModelResourceLocation(IBlockState state)
        {
            return corruptedfluidLocation;
        }
    });
    ModelLoader.setCustomStateMapper(SacredFluidBlock.instance, new StateMapperBase()
    {
        protected ModelResourceLocation getModelResourceLocation(IBlockState state)
        {
            return sacredfluidLocation;
        }
    });
    ModelLoader.setCustomStateMapper(ShadowFluidBlock.instance, new StateMapperBase()
    {
        protected ModelResourceLocation getModelResourceLocation(IBlockState state)
        {
            return shadowfluidLocation;
        }
    });
    ModelLoader.setCustomStateMapper(CrazyFluidBlock.instance, new StateMapperBase()
    {
        protected ModelResourceLocation getModelResourceLocation(IBlockState state)
        {
            return crazyfluidLocation;
        }
    });
    }

    public static final class CorruptedFluid extends Fluid
    {
        public static final String name = "corrupted_water";
        public static final CorruptedFluid instance = new CorruptedFluid();

        private CorruptedFluid()
        {
        	super(name, new ResourceLocation(MW.MODID + ":" + "blocks/" + name + "_still"), new ResourceLocation(MW.MODID + ":" + "blocks/" + name + "_flow"));
        }
    }
    
    public static final class SacredFluid extends Fluid
    {
        public static final String name = "sacred_water";
        public static final SacredFluid instance = new SacredFluid();

        private SacredFluid()
        {
        	super(name, new ResourceLocation(MW.MODID + ":" + "blocks/" + name + "_still"), new ResourceLocation(MW.MODID + ":" + "blocks/" + name + "_flow"));
        }
    }
    
    public static final class ShadowFluid extends Fluid
    {
        public static final String name = "shadow_water";
        public static final ShadowFluid instance = new ShadowFluid();

        private ShadowFluid()
        {
        	super(name, new ResourceLocation(MW.MODID + ":" + "blocks/" + "dark_water" + "_still"), new ResourceLocation(MW.MODID + ":" + "blocks/" + "dark_water" + "_flow"));
        }
    }
    
    public static final class CrazyFluid extends Fluid
    {
        public static final String name = "crazy_water";
        public static final CrazyFluid instance = new CrazyFluid();

        private CrazyFluid()
        {
        	super(name, new ResourceLocation(MW.MODID + ":" + "blocks/" + name + "_still"), new ResourceLocation(MW.MODID + ":" + "blocks/" + name + "_flow"));
        }
    }

    public static final class CorruptedFluidBlock extends BlockFluidClassic
    {
        public static final CorruptedFluidBlock instance = new CorruptedFluidBlock();
        public static final String name = "corrupted_water";

        private CorruptedFluidBlock()
        {
            super(CorruptedFluid.instance, Material.water);
            setUnlocalizedName(name);
        }
        
        @Override
        public EnumBlockRenderType getRenderType(IBlockState state)
        {
        	return EnumBlockRenderType.MODEL;
        }
    }
    
    public static final class SacredFluidBlock extends BlockFluidClassic
    {
        public static final SacredFluidBlock instance = new SacredFluidBlock();
        public static final String name = "sacred_water";

        private SacredFluidBlock()
        {
            super(SacredFluid.instance, Material.water);
            setUnlocalizedName(name);
        }
        
        @Override
        public EnumBlockRenderType getRenderType(IBlockState state)
        {
        	return EnumBlockRenderType.MODEL;
        }
    }
    
    public static final class ShadowFluidBlock extends BlockFluidClassic
    {
        public static final ShadowFluidBlock instance = new ShadowFluidBlock();
        public static final String name = "shadow_water";

        private ShadowFluidBlock()
        {
            super(ShadowFluid.instance, Material.water);
            setUnlocalizedName(name);
        }
        
        @Override
        public EnumBlockRenderType getRenderType(IBlockState state)
        {
        	return EnumBlockRenderType.MODEL;
        }
    }
    
    public static final class CrazyFluidBlock extends BlockFluidClassic
    {
        public static final CrazyFluidBlock instance = new CrazyFluidBlock();
        public static final String name = "crazy_water";

        private CrazyFluidBlock()
        {
            super(CrazyFluid.instance, Material.water);
            setUnlocalizedName(name);
        }
        
        @Override
        public EnumBlockRenderType getRenderType(IBlockState state)
        {
        	return EnumBlockRenderType.MODEL;
        }
    }
}

 

It is a bug due to the fact that Forge for 1.9 is still a beta or am i missing something? (This is almost the same code from 1.8, where fluids works as intended)

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

The vanilla fluid block override the method

AxisAlignedBB getSelectedBoundingBox(IBlockState, World, BlockPos)

, which if I'm right, also controls the collision box. Override that to return

null

should fix it.

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

This should probably be in Forge itself, so I'm going to make a pull request when I have reasonable internet again.

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

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.



×
×
  • Create New...

Important Information

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