Guest User

Untitled

a guest
Jun 4th, 2024
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import net.minecraft.world.level.block.Block;
  2.  
  3. import net.minecraft.world.level.block.state.BlockState;
  4.  
  5. import net.minecraft.core.BlockPos;
  6.  
  7. import net.minecraft.world.level.Level;
  8.  
  9. import net.minecraft.world.entity.Entity;
  10.  
  11. import java.util.List;
  12.  
  13. public class MyCustomBlock extends Block {
  14.  
  15. public MyCustomBlock(Properties properties) {
  16.  
  17. super(properties);
  18.  
  19. }
  20.  
  21. @Override
  22.  
  23. public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) {
  24.  
  25. super.neighborChanged(state, world, pos, block, fromPos, isMoving);
  26.  
  27.  
  28.  
  29. if (!world.isClientSide) {
  30.  
  31. List<Entity> entities = EntityHelper.getEntitiesAroundBlock(world, pos, 10);
  32.  
  33. for (Entity entity : entities) {
  34.  
  35. // your logic for interacting with entities
  36.  
  37. // for example damaging entities
  38.  
  39. entity.hurt(DamageSource.GENERIC, 5.0F);
  40.  
  41. }
  42.  
  43. }
  44.  
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment