Jump to content

Custom Block Identified as Rail Help :(


censorthis

Recommended Posts

Trying to make minecarts recognize custom block as a rail. 
Tried extending class of block to BlockRail or BlockRailBase which did not work because i use Extends BlockBase to add the block to my game.

Also tried adding Override boolean of isRailBlock which didnt seem to work. Following code bellow is working placeable block with custom model, but has no function to accept minecarts or function as a rail.



Custom Block

Spoiler

package SimplyRails.Blocks;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.BlockRail;
import net.minecraft.block.BlockRailBase;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;


public class FrBlock extends BlockBase  {
    


    private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0, 0, 0, 1, 0.0625, 1);
    
    public FrBlock(String name, Material material) {
        super(name, material);
        setSoundType(SoundType.METAL);
        setHardness(0.5F);
        setResistance(3.5F);
        setHarvestLevel("pickaxe", 2);
        setLightLevel(0f);
        setLightOpacity(1);
        //setBlockUnbreakable();
    
        

    }
    

    
    @Override
    public boolean isFullCube(IBlockState state) {
        return false;
        
    }

    
    @Override
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }
    
    
    
    @Override
    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
        return BOUNDING_BOX;
    }
    
    @Override
    public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox,
            List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean p_185477_7_) {
        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, BOUNDING_BOX);
    }
    
    
}
 

 

Link to comment
Share on other sites

17 minutes ago, censorthis said:

did not work because i use Extends BlockBase

You don't need BlockBase. Using inheritance as a means for code-reuse is an antipattern.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.