#Warden keeps despawning

18 messages · Page 1 of 1 (latest)

elfin glacier
#

(i am trying to spawn a protective warden that attacks the last hit entity)

elfin glacier
#

it despawns

#

it digs itself into the ground

elfin glacier
#

@chilly owl the code works with husks, but not wardens 😭

chilly owl
chilly owl
#

@elfin glacier I got the warden to not despawn but it doesn't target the lastHit

elfin glacier
#

what does it target instead?

#

@chilly owl

chilly owl
#

@elfin glacier fixed targeting lol

#
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
        ItemStack stack = user.getStackInHand(hand);
        user.setCurrentHand(hand);
        if (world.isClient()) {
            return TypedActionResult.pass(stack);
        }
        this.player = user;
        WardenEntity protector = EntityType.WARDEN.create(world);
        if (lastHit == null || protector == null) {
            world.playSound(null, user.getX(), user.getY(), user.getZ(), SoundEvents.BLOCK_BEACON_DEACTIVATE, SoundCategory.PLAYERS, 1.0f, 1.0f);
            return TypedActionResult.fail(stack);
        }
        protector.refreshPositionAndAngles(user.getBlockPos(), user.getYaw(), user.getPitch());
        protector.setAiDisabled(false);
        protector.getBrain().remember(MemoryModuleType.DIG_COOLDOWN, Unit.INSTANCE, 1200L);
        world.spawnEntity(protector);
        protector.updateAttackTarget(this.lastHit);
        protector.increaseAngerAt(this.lastHit, Angriness.ANGRY.getThreshold() + 20, false);
        user.getItemCooldownManager().set(this, COOLDOWN_TICKS);
        world.playSound(null, user.getX(), user.getY(), user.getZ(), SoundEvents.BLOCK_BEACON_ACTIVATE, SoundCategory.PLAYERS, 1.0f, 1.0f);
        return TypedActionResult.success(user.getStackInHand(hand), true);
    }
#

However it doesn't work on other wardens

#

Warden works differently so try to do setTarget won't actually work

#

Why is why your previous method didn't work
Also you needed to make the warden remember its dig cooldown or it would start digging immediately

elfin glacier
#

let me test it

#

works pretty well!!