Jump to content

[1.16.5] Detect Player stepping off a block.


Lxs_

Recommended Posts

So, I’m making a 1.16.5 mod and I want to detect when the player steps off a custom block that I made. How could I do that? Here is my code.

 

package com.lxs.randomshit.block.custom;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class WeakBlock extends Block {
    public WeakBlock(Properties properties) {
        super(properties);
    }

    @Override
    public void onEntityWalk(World world, BlockPos blockPos, Entity entity) {
        world.destroyBlock(blockPos, true, entity);
        super.onEntityWalk(world, blockPos, entity);
    }
}

 

Edited by Lxs_
Link to comment
Share on other sites

  • 2 weeks later...
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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