Как сделать так, чтобы мобы обходили блок? (Как куст сладких ягод, например) Fabric 1.21.1

Версия Minecraft
1.21.1
API
Fabric
Все знают, как мобы обходят кусты сладких ягод. Итак, у меня есть блок куста ягод, который расширяет SweetBerryBushBlock, НО мобы всё равно проходят через него и застревают в нем, вращаясь на одном месте. Даже canPathfindThrough (который я достал из класса блока кактуса) не помогает. Я перебрал все классы, но ничего подобного не нашёл.
Вот код:

Java:
package ru.ratontheraccoon.block;

import net.minecraft.block.BlockState;
import net.minecraft.block.SweetBerryBushBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.pathing.NavigationType;
import net.minecraft.entity.ai.pathing.PathNodeType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import net.minecraft.world.event.GameEvent;
import ru.ratontheraccoon.entity.ModEntities;
import ru.ratontheraccoon.entity.custom.RatonEntity;
import ru.ratontheraccoon.items.ModItems;

public class BlueBerryBushBlock extends SweetBerryBushBlock {
    public BlueBerryBushBlock(Settings settings) {
        super(settings);
    }

    
    public ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state) {
        return new ItemStack(ModItems.BLUE_BERRIES);
    }

    
    protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
        int age = state.get(AGE);
        boolean mature = age == 3;
        return !mature && stack.isOf(Items.BONE_MEAL) ? ItemActionResult.SKIP_DEFAULT_BLOCK_INTERACTION : super.onUseWithItem(stack, state, world, pos, player, hand, hit);
    }

    
    protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
        int age = state.get(AGE);
        boolean stage3 = age == 3;

        if (age > 1) {
            int count = 1 + world.random.nextInt(2);
            dropStack(world, pos, new ItemStack(ModItems.BLUE_BERRIES, count + (stage3 ? 1 : 0)));

            world.playSound(null, pos, SoundEvents.BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F);

            BlockState newState = state.with(AGE, 1);
            world.setBlockState(pos, newState, 2);
            world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(player, newState));

            return ActionResult.success(world.isClient);
        }

        return super.onUse(state, world, pos, player, hit);
    }

    
    protected void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
        if (entity instanceof LivingEntity && entity.getType() != EntityType.FOX && entity.getType() != EntityType.BEE && entity.getType() != ModEntities.RATON) {
            entity.slowMovement(state, new Vec3d((double)0.8F, (double)0.75F, (double)0.8F));
            if (!world.isClient && (Integer)state.get(AGE) > 0 && (entity.lastRenderX != entity.getX() || entity.lastRenderZ != entity.getZ())) {
                double d = Math.abs(entity.getX() - entity.lastRenderX);
                double e = Math.abs(entity.getZ() - entity.lastRenderZ);
                if (d >= (double)0.003F || e >= (double)0.003F) {
                    entity.damage(world.getDamageSources().sweetBerryBush(), 1.0F);
                }
            }

        }
    }

    protected boolean canPathfindThrough(BlockState state, NavigationType type) {
        return false;
    }
}


Заранее спасибо!
 
Назад
Сверху