Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

GyuGya_55

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by GyuGya_55

  1. You don't have to do a lot. Basically you just have to copy the text from any vanilla stair blocks files and change the name and add your modId. Thats all. I also insert some code if you have any problems doing it by yourself. This was you will have a fully funcional stair block. This is the registration. I had a lot of truble here. ModBlocks: Here is the Custom_Stone_Stairs class: And here are the assets files: Blockstate: Models : custom_stone_stairs.json custom_stone_stairs_inner.json custom_stone_stairs_outer.json I left our the icon and the lang jsons, but I think you can do that by yourself.
  2. I managed to figure it out but I had to redo the most of my project. I had to make a new block as well and I used it like this: new Custom_Stone_Stairs(custom_stone.getDefaultState(), Block.Properties.from(custom_stone)) custom_stone is the name I registered it on. Also thanks for trying to help me. <:
  3. I should give a BlockState type and it will use it after that. This is the code in the StairsBlock class, which I extended with my Custom_Stone_Stairs class. protected StairsBlock(BlockState state, Block.Properties properties) { super(properties); this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH).with(HALF, Half.BOTTOM).with(SHAPE, StairsShape.STRAIGHT).with(WATERLOGGED, Boolean.valueOf(false))); this.modelBlock = state.getBlock(); this.modelState = state; }
  4. I need a little help to regirster a custom Stair block. I have to put something to where the null is right now, but I'm not sure what I should put there... new Custom_Stone_Stairs(null, Block.Properties.create(Material.ROCK).hardnessAndResistance(2.0f, 3.0f).lightValue(0).sound(SoundType.STONE)) Just in case you need it, here is the Stair blocks code: package com.gyugya55.minecraftplus.blocks.buildingblocks; import net.minecraft.block.BlockState; import net.minecraft.block.StairsBlock; public class Custom_Stone_Stairs extends StairsBlock { public Custom_Stone_Stairs(BlockState state, Properties properties) { super(state, properties); setRegistryName("custom_stone_stairs"); } } I would really appreciate your help.
  5. Thank you guys very much. I'm so happy now. I was so dumb bcs I did VoxelShape.create instead of Block.makeCuboidShape... Thank Simon_kungen
  6. I tried to do it like this: public static final AxisAlignedBB AABB = new AxisAlignedBB( 0D, //x 0D, //y down 7D, //z 16D, //x 10.5D, //y up 9D //z ); @Override public VoxelShape getShape(BlockState state, IBlockReader reader, BlockPos position, ISelectionContext context) { return VoxelShapes.create(AABB); } But now I don't have any hitboxes.
  7. I edited the post with the pictures. My CollisionShape is working ony the BoundingBox not.
  8. Solution for the next gen who stumble upon this thread. Solution provided by Simon_kungen: public VoxelShape getShape(BlockState state, IBlockReader reader, BlockPos position, ISelectionContext context) { return Block.makeCuboidShape(xMin, yMin, zMin, xMax, yMax, zMax); //all decimals } The boundingbox of my block isn't what I set it. I'm a newby and after 2 days of trying I still couldn't find the problem. I would really appreciate if someone could halp me out a bit. Here is the blocks class. package com.gyugya55.mymod.blocks; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; public class Abacus extends Block { public Abacus() { super(Properties.create(Material.WOOD) .sound(SoundType.WOOD) .hardnessAndResistance(0.1f,0.5f) .lightValue(0) ); setRegistryName("abacus"); } @Override public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT_MIPPED; } @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) { if (entity != null) { world.setBlockState(pos, state.with(BlockStateProperties.FACING, getFacingFromEntity(pos, entity)), 2); } } public static Direction getFacingFromEntity(BlockPos clickedBlock, LivingEntity entity) { return Direction.getFacingFromVector((float) (entity.posX - clickedBlock.getX()), (float) (entity.posY - clickedBlock.getY()), (float) (entity.posZ - clickedBlock.getZ())); } @Override protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { builder.add(BlockStateProperties.FACING); } @Override public boolean isNormalCube(BlockState state, IBlockReader reader, BlockPos position) { return false; } public VoxelShape getCollisionShape(BlockState state, IBlockReader reader, BlockPos position, ISelectionContext context) { return Block.makeCuboidShape( 0D, //x 0D, //y down 7D, //z 16D, //x 10.5D, //y up 9D //z ); } public AxisAlignedBB getBoundingBox() { return new AxisAlignedBB( 0D, 0D, 7D, 16D, 10.5D, 9D ); } } So this is the current bounding box of my object. And this is what im trying to achive.
×
×
  • Create New...

Important Information

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