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

GyuGya_55

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by GyuGya_55

  1.  

    14 hours ago, MatsCraft1 said:

    Kind of off topic but do you know how to make the stairs become "corners"?

     

    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:

    Spoiler

     

    
    package com.gyugya55.mymod.init;
    
    import javax.annotation.Nullable;
    
    import com.gyugya55.mymod.MyMod;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.SoundType;
    import net.minecraft.block.StairsBlock;
    import net.minecraft.block.material.Material;
    import net.minecraft.item.BlockItem;
    import net.minecraft.item.Item;
    import net.minecraft.util.ResourceLocation;
    import net.minecraftforge.event.RegistryEvent;
    import net.minecraftforge.registries.ForgeRegistries;
    
    
    public final class ModBlocks {
        public static Block plastered_stone;
        public static StairsBlock plastered_stone_stairs;
    
        private ModBlocks() {}
        
        
        public static void registerAll(RegistryEvent.Register<Block> event) {
        	
        	//custom_blocks
        	custom_stone = register("custom_stone", new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(1.5f, 6f).sound(SoundType.STONE)));
            custom_stone_stairs = register("custom_stone_stairs", new Custom_Stone_Stairs(custom_stone.getDefaultState(), Block.Properties.from(custom_stone)))
    
        }
            
        private static <T extends Block> T register(String name, T block) {
            BlockItem item = new BlockItem(block, new Item.Properties().group(MyMod.ITEM_GROUP));
            return register(name, block, item);
        }
        
        
        
        private static <T extends Block> T register(String name, T block, @Nullable BlockItem item) {
            ResourceLocation id = MyMod.getId(name);
            block.setRegistryName(id);
            ForgeRegistries.BLOCKS.register(block);
            if (item != null) {
                ModItems.BLOCKS_TO_REGISTER.put(name, item);
            }
            return block;
        }
    }

     

    Here is the
    Custom_Stone_Stairs class:
     

    Spoiler
    
    package com.gyugya55.mymod.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);
    	}
    }

     

     

    And here are the assets files:

    Blockstate:

    Spoiler
    
    {
        "variants": {
            "facing=east,half=bottom,shape=straight":  { "model": "mymod:block/custom_stone_stairs" },
            "facing=west,half=bottom,shape=straight":  { "model": "mymod:block/custom_stone_stairs", "y": 180, "uvlock": true },
            "facing=south,half=bottom,shape=straight": { "model": "mymod:block/custom_stone_stairs", "y": 90, "uvlock": true },
            "facing=north,half=bottom,shape=straight": { "model": "mymod:block/custom_stone_stairs", "y": 270, "uvlock": true },
            "facing=east,half=bottom,shape=outer_right":  { "model": "mymod:block/custom_stone_stairs_outer" },
            "facing=west,half=bottom,shape=outer_right":  { "model": "mymod:block/custom_stone_stairs_outer", "y": 180, "uvlock": true },
            "facing=south,half=bottom,shape=outer_right": { "model": "mymod:block/custom_stone_stairs_outer", "y": 90, "uvlock": true },
            "facing=north,half=bottom,shape=outer_right": { "model": "mymod:block/custom_stone_stairs_outer", "y": 270, "uvlock": true },
            "facing=east,half=bottom,shape=outer_left":  { "model": "mymod:block/custom_stone_stairs_outer", "y": 270, "uvlock": true },
            "facing=west,half=bottom,shape=outer_left":  { "model": "mymod:block/custom_stone_stairs_outer", "y": 90, "uvlock": true },
            "facing=south,half=bottom,shape=outer_left": { "model": "mymod:block/custom_stone_stairs_outer" },
            "facing=north,half=bottom,shape=outer_left": { "model": "mymod:block/custom_stone_stairs_outer", "y": 180, "uvlock": true },
            "facing=east,half=bottom,shape=inner_right":  { "model": "mymod:block/custom_stone_stairs_inner" },
            "facing=west,half=bottom,shape=inner_right":  { "model": "mymod:block/custom_stone_stairs_inner", "y": 180, "uvlock": true },
            "facing=south,half=bottom,shape=inner_right": { "model": "mymod:block/custom_stone_stairs_inner", "y": 90, "uvlock": true },
            "facing=north,half=bottom,shape=inner_right": { "model": "mymod:block/custom_stone_stairs_inner", "y": 270, "uvlock": true },
            "facing=east,half=bottom,shape=inner_left":  { "model": "mymod:block/custom_stone_stairs_inner", "y": 270, "uvlock": true },
            "facing=west,half=bottom,shape=inner_left":  { "model": "mymod:block/custom_stone_stairs_inner", "y": 90, "uvlock": true },
            "facing=south,half=bottom,shape=inner_left": { "model": "mymod:block/custom_stone_stairs_inner" },
            "facing=north,half=bottom,shape=inner_left": { "model": "mymod:block/custom_stone_stairs_inner", "y": 180, "uvlock": true },
            "facing=east,half=top,shape=straight":  { "model": "mymod:block/custom_stone_stairs", "x": 180, "uvlock": true },
            "facing=west,half=top,shape=straight":  { "model": "mymod:block/custom_stone_stairs", "x": 180, "y": 180, "uvlock": true },
            "facing=south,half=top,shape=straight": { "model": "mymod:block/custom_stone_stairs", "x": 180, "y": 90, "uvlock": true },
            "facing=north,half=top,shape=straight": { "model": "mymod:block/custom_stone_stairs", "x": 180, "y": 270, "uvlock": true },
            "facing=east,half=top,shape=outer_right":  { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 90, "uvlock": true },
            "facing=west,half=top,shape=outer_right":  { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 270, "uvlock": true },
            "facing=south,half=top,shape=outer_right": { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 180, "uvlock": true },
            "facing=north,half=top,shape=outer_right": { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "uvlock": true },
            "facing=east,half=top,shape=outer_left":  { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "uvlock": true },
            "facing=west,half=top,shape=outer_left":  { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 180, "uvlock": true },
            "facing=south,half=top,shape=outer_left": { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 90, "uvlock": true },
            "facing=north,half=top,shape=outer_left": { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 270, "uvlock": true },
            "facing=east,half=top,shape=inner_right":  { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 90, "uvlock": true },
            "facing=west,half=top,shape=inner_right":  { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 270, "uvlock": true },
            "facing=south,half=top,shape=inner_right": { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 180, "uvlock": true },
            "facing=north,half=top,shape=inner_right": { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "uvlock": true },
            "facing=east,half=top,shape=inner_left":  { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "uvlock": true },
            "facing=west,half=top,shape=inner_left":  { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 180, "uvlock": true },
            "facing=south,half=top,shape=inner_left": { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 90, "uvlock": true },
            "facing=north,half=top,shape=inner_left": { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 270, "uvlock": true }
        }
    }

     

     

     

    Models :

    custom_stone_stairs.json

    Spoiler
    
    {
        "parent": "block/stairs",
        "textures": {
            "bottom": "mymod:block/custom_stone_bottom",
            "top": "mymod:block/custom_stone_top",
            "side": "mymod:block/custom_stone_side"
        }
    }

     

     

    custom_stone_stairs_inner.json

    Spoiler
    
    {
        "parent": "block/inner_stairs",
        "textures": {
            "bottom": "mymod:block/custom_stone_bottom",
            "top": "mymod:block/custom_stone_top",
            "side": "mymod:block/custom_stone_side"
        }
    }

     

     

    custom_stone_stairs_outer.json

    Spoiler
    
    {
        "parent": "block/outer_stairs",
        "textures": {
            "bottom": "mymod:block/custom_stone_bottom",
            "top": "mymod:block/custom_stone_top",
            "side": "mymod:block/custom_stone_side"
        }
    }

     

     

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

    getBoundingBox isn't a method in the Block class. Whenever you override a method in a super class put the @Override annotation above the method. It will tell you if you are actually overriding the method.

    Minecraft has three different methods for the bounding box that all call getShape. So just override getShape

     

    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. 798883727_Kpernyfelvtel(11).thumb.png.dba22b72c62b5ca4c0e971ff08da1239.png

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

    1689730787_Kpernyfelvtel(8).thumb.png.06b5ff50e75c974283480444b79ba363.png

     

     

    And this is what im trying to achive.1346043751_Kpernyfelvtel(9).thumb.png.665c6bb58e849f2af60bcec52ef595bd.png

×
×
  • Create New...

Important Information

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