Posted July 7, 20205 yr I tried to make this block deal damage to the player when they walk on it and is not working I think because of the custom hit box. here is my block class: package com.ModdingMinecraft.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.util.DamageSource; 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 BlockBanana_Peel extends Block { private static final VoxelShape SHAPE = Block.makeCuboidShape(3.0d, 0.0d, 3.0d, 14.0d, 1.0d, 13.0d); public BlockBanana_Peel() { super(Block.Properties.create(Material.ORGANIC) .speedFactor(10) .notSolid() .lightValue(1) .slipperiness(10) .harvestLevel(0) ); } @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { return SHAPE; } public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) { if (!entityIn.isSneaking()) { entityIn.attackEntityFrom(DamageSource.FALLING_BLOCK, 10.0F); } super.onEntityWalk(worldIn, pos, entityIn); } } What am I doing wrong?
July 7, 20205 yr Well it definitely doesn't help if you can just walk right through the block. How am I supposed to walk on a block that I can't even touch? You might want to check Block::onEntityCollision since you would be inside the VoxelShape of the block.
July 7, 20205 yr Author 16 minutes ago, ChampionAsh5357 said: Well it definitely doesn't help if you can just walk right through the block. How am I supposed to walk on a block that I can't even touch? You might want to check Block::onEntityCollision since you would be inside the VoxelShape of the block. Thank you so much! It worked!
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.