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

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? 

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.

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

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.