Jump to content

Custom Fluid not Visible [1.12.2]


Aelpecyem

Recommended Posts

I have tried to add a custom fluid, but it is not visible.

 

My Main class:

Spoiler

package aelpecyem.walkabouts;

import aelpecyem.walkabouts.handlers.GuiHandler;
import aelpecyem.walkabouts.handlers.ItemHandler;
import aelpecyem.walkabouts.init.blocks.BlockInit;
import aelpecyem.walkabouts.init.fluids.FluidInit;
import aelpecyem.walkabouts.init.items.ItemInit;
import aelpecyem.walkabouts.proxy.CommonProxy;
import aelpecyem.walkabouts.world.ore.OreGen;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialLiquid;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;

@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION)
public class Walkabouts {
        
        @Instance
        public static Walkabouts instance;
    
        @SidedProxy(clientSide = Reference.CLIENTPROXY, serverSide = Reference.COMMONPROXY)
        public static CommonProxy proxy;
        
        public static CreativeTabs Tab = new Tab();
        
        static
        {
            FluidRegistry.enableUniversalBucket();
        }

         public static final Material SLIME = new MaterialLiquid(
                    MapColor.GREEN_STAINED_HARDENED_CLAY);
        @EventHandler
        public static void preInit(FMLPreInitializationEvent event){
            
            
            
            
            GameRegistry.registerWorldGenerator(new OreGen(), 3);
            ItemHandler.handle();
             
            
        }
        @EventHandler
        public static void init(FMLInitializationEvent event){
        NetworkRegistry.INSTANCE.registerGuiHandler(Walkabouts.instance, new GuiHandler());
            
        OreDictionary.registerOre("food", ItemInit.TRAVEL_FOOD);
        GameRegistry.addSmelting(BlockInit.MOOVIUM_ORE, new ItemStack(ItemInit.MOOVIUM_INGOT), 10);
            
            
        }
        
        @EventHandler
        public static void postInit(FMLPostInitializationEvent event){
            
            
            
        }
            
        
}

 

My RegistryHandler class:

Spoiler

package aelpecyem.walkabouts.handlers;

import aelpecyem.walkabouts.init.blocks.BlockInit;
import aelpecyem.walkabouts.init.fluids.FluidInit;
import aelpecyem.walkabouts.init.items.ItemInit;
import aelpecyem.walkabouts.util.IHasModel;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

 

@EventBusSubscriber
public class RegistryHandler 
{
    @SubscribeEvent
    public static void onItemRegister(RegistryEvent.Register<Item> event)
    {
        event.getRegistry().registerAll(ItemInit.ITEMS.toArray(new Item[0]));
    }
    
    @SubscribeEvent
    public static void onBlockRegister(RegistryEvent.Register<Block> event)
    {    
        FluidRegistry.registerFluid(FluidInit.MOOVIUM_LIQUID);
        event.getRegistry().registerAll(BlockInit.BLOCKS.toArray(new Block[0]));
    }

    
    @SubscribeEvent
    public static void onModelRegister(ModelRegistryEvent event)
    {
        for(Item item : ItemInit.ITEMS)
        {
            if(item instanceof IHasModel)
            {
                ((IHasModel)item).registerModels();
            }
        }
        
        for(Block block : BlockInit.BLOCKS)
        {
            if(block instanceof IHasModel)
            {
                ((IHasModel)block).registerModels();
            }
        }
        
        

 

My BlockInit class:

Spoiler

package aelpecyem.walkabouts.init.blocks;

 

import java.util.ArrayList;

import java.util.List;

 

import aelpecyem.walkabouts.init.fluids.FluidInit;

import aelpecyem.walkabouts.objects.BlockBase;

import aelpecyem.walkabouts.objects.FluidBlockBase;

import aelpecyem.walkabouts.objects.OreBase;

import net.minecraft.block.Block;

import net.minecraft.block.SoundType;

import net.minecraft.block.material.Material;

import net.minecraftforge.fluids.BlockFluidClassic;

 

public class BlockInit 

{ 

public static final List<Block> BLOCKS = new ArrayList<Block>();

//basic blocks

public static final Block MOOVIUM_ORE = new OreBase("ore_moovium", Material.CLAY, 10.0F, 1.0F, "shovel", 2, SoundType.SAND);

public static final Block DEEPSTONE = new BlockBase("deepstone", Material.SAND, 10.0F, 1.0F);

 

public static final Block FLUIDBLOCK_MOOVIUM = new FluidBlockBase("liquid_moovium", FluidInit.MOOVIUM_LIQUID, ModMaterials.LIQUID_MOOVIUM);

 

 

}

 

 

My FluidInit class:

Spoiler

package aelpecyem.walkabouts.init.fluids;

 

 

import java.util.ArrayList;

import java.util.Set;

 

import com.google.common.collect.ImmutableSet;

 

import aelpecyem.walkabouts.Reference;

import aelpecyem.walkabouts.objects.FluidBase;

import net.minecraft.util.ResourceLocation;

import net.minecraftforge.fluids.FluidRegistry;

 

public class FluidInit {

 

public static ArrayList<FluidBase> FLUIDS = new ArrayList<FluidBase>();

 

public static final FluidBase MOOVIUM_LIQUID = (FluidBase) new FluidBase(

  "liquid_moovium", 

  new ResourceLocation(Reference.MODID,"liquid_moovium_still"), 

  new ResourceLocation(Reference.MODID, "liquid_moovium_flow")

  ) 

  .setHasBucket(true)

  .setDensity(100000)

  .setGaseous(false)

  .setLuminosity(1000)

  .setViscosity(25)

  .setTemperature(300);

   

 

public static final Set<FluidBase> SET_FLUIDS = ImmutableSet.of(

            MOOVIUM_LIQUID);

 

  public static void registerFluids()

    {

        // DEBUG

        System.out.println("Registering fluids");

        for (final FluidBase fluid : FLUIDS)

        {

            FluidRegistry.registerFluid(fluid);

            if (fluid.isBucketEnabled())

            {

                FluidRegistry.addBucketForFluid(fluid);

            }

            // DEBUG

            System.out.println("Registering fluid: " + fluid.getName()+" with bucket = "+fluid.isBucketEnabled());

        }

    }

}

 

My Fluid class:

Spoiler

package aelpecyem.walkabouts.objects;

import aelpecyem.walkabouts.Walkabouts;
import aelpecyem.walkabouts.init.fluids.FluidInit;
import aelpecyem.walkabouts.util.IHasModel;
import net.minecraft.block.material.Material;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fluids.Fluid;

 

public class FluidBase extends Fluid{

    private int mapColor_;
    private float overlayAlpha_;
    private SoundEvent emptySound = SoundEvents.ITEM_BUCKET_EMPTY;
    private Material material = Material.LAVA;
    private SoundEvent fillSound = SoundEvents.ITEM_BUCKET_FILL;
    private boolean bucketEnabled;

    

public FluidBase(String fluidName, ResourceLocation still, ResourceLocation flowing) {
        super(fluidName, still, flowing);
        FluidInit.FLUIDS.add(this);
        
        
        //overlayAlpha_ = overlayAlpha;
        //mapColor_ = mapColor;
    }

    @Override
    public int getColor() {
        
        return mapColor_;
    }
     public FluidBase setColor(int parColor)
        {
            mapColor_ = parColor;
            return this;
        }
     public float getAlpha()
        {
            return overlayAlpha_;
        }
     
        public FluidBase setAlpha(float parOverlayAlpha)
        {
            overlayAlpha_ = parOverlayAlpha;
            return this;
        }
     
        @Override
        public FluidBase setEmptySound(SoundEvent parSound)
        {
            emptySound = parSound;
            return this;
        }
     
        @Override
        public SoundEvent getEmptySound()
        {
            return emptySound;
        }
        @Override
        public FluidBase setFillSound(SoundEvent parSound)
        {
            fillSound = parSound;
            return this;
        }
     
        @Override
        public SoundEvent getFillSound()
        {
            return fillSound;

        }
        public FluidBase setHasBucket(boolean parEnableBucket)
        {
            bucketEnabled = parEnableBucket;
            return this;
        }
        
        public boolean isBucketEnabled()
        {
            return bucketEnabled;
        }

    
}
 

 

My FluidBlock class:

Spoiler

package aelpecyem.walkabouts.objects;

 

import java.awt.Color;

 

import javax.annotation.Nonnull;

 

import aelpecyem.walkabouts.Walkabouts;

import aelpecyem.walkabouts.init.blocks.BlockInit;

import aelpecyem.walkabouts.init.items.ItemInit;

import aelpecyem.walkabouts.util.IHasModel;

import net.minecraft.block.Block;

import net.minecraft.block.BlockStairs;

import net.minecraft.block.material.Material;

import net.minecraft.block.material.MaterialLiquid;

import net.minecraft.block.state.BlockFaceShape;

import net.minecraft.block.state.IBlockState;

import net.minecraft.entity.Entity;

import net.minecraft.item.Item;

import net.minecraft.item.ItemBlock;

import net.minecraft.util.EnumFacing;

import net.minecraft.util.math.BlockPos;

import net.minecraft.util.math.Vec3d;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import net.minecraftforge.fluids.BlockFluidClassic;

import net.minecraftforge.fluids.Fluid;

import net.minecraftforge.fluids.FluidStack;

import net.minecraftforge.fluids.FluidUtil;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

 

public class FluidBlockBase extends BlockFluidClassic implements IHasModel

{

public FluidBlockBase(String name, Fluid definedFluid, Material material) 

{

super(definedFluid, material);

setUnlocalizedName(name);

setRegistryName(name);

setCreativeTab(Walkabouts.Tab);

 

 

BlockInit.BLOCKS.add(this);

ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));

}

 

 

    @Override

    public int place(World world, BlockPos pos, @Nonnull FluidStack fluidStack, boolean doPlace)

    {

 

        if (doPlace)

        {

            FluidUtil.destroyBlockOnFluidPlacement(world, pos);

            world.setBlockState(pos, this.getDefaultState(), 11);

        }

        return fluidStack.amount;

    }

 

    @Override

    @SideOnly(Side.CLIENT)

    public Vec3d getFogColor(World world, BlockPos pos, IBlockState state, Entity entity, Vec3d originalColor, float partialTicks)

    {

        return new Vec3d(Color.CYAN.getRed(), Color.CYAN.getGreen(), Color.CYAN.getBlue());

    }

 

@Override

public void registerModels() 

{

Walkabouts.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");

}

}

 

.json file:

Spoiler

{
    "forge_marker": 1,
    "defaults": {
        "textures": {
            "particle": "walkabouts:liquid_moovium_still",
            "all": "walkabouts:liquid_moovium_flow"
        },
        "model": "forge:fluid",
      "custom": { "fluid": "liquid_moovium" },
      "uvlock": false
    },
    "variants": {
        "normal": [{

        }],
        "inventory": [{

        }],
        "level": {
            "0": { },
            "1": { },
            "2": { },
            "3": { },
            "4": { },
            "5": { },
            "6": { },
            "7": { },
            "8": { },
            "9": { },
            "10": { },
            "11": { },
            "12": { },
            "13": { },
            "14": { },
            "15": { }
        }
    }
}

 Can anybody help?

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.