Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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);
    }
    
    
}
 

 

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.

  • Author
47 minutes ago, Draco18s said:

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

Omg... im a moron. Thank you. 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.