censorthis Posted September 6, 2018 Share Posted September 6, 2018 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); } } Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 6, 2018 Share Posted September 6, 2018 (edited) 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 September 6, 2018 by Draco18s Quote 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 More sharing options...
censorthis Posted September 6, 2018 Author Share Posted September 6, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.