Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.shadowducky.minestranding.common.mob.entity;
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
- import com.shadowducky.minestranding.common.MineStranding;
- import net.minecraft.world.entity.Entity;
- import net.minecraft.world.entity.EntityType;
- import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
- import net.minecraft.world.entity.ai.attributes.Attributes;
- import net.minecraft.world.entity.ai.goal.FloatGoal;
- import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
- import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
- import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
- import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
- import net.minecraft.world.entity.monster.Monster;
- import net.minecraft.world.entity.player.Player;
- import net.minecraft.world.level.Level;
- public class BTGazer extends Monster {
- public static final Logger LOGGER = LogManager.getLogger(MineStranding.MODID);
- private Entity lastTarget;
- public BTGazer(EntityType<? extends BTGazer> entityType, Level level) {
- super(entityType, level);
- lastTarget = null;
- }
- @Override
- protected void registerGoals() {
- super.registerGoals();
- this.goalSelector.addGoal(0, new FloatGoal(this));
- this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0D, false));
- this.goalSelector.addGoal(2, new LookAtPlayerGoal(this, Player.class, 6.0F));
- this.goalSelector.addGoal(3, new RandomLookAroundGoal(this));
- this.targetSelector.addGoal(0, new NearestAttackableTargetGoal<>(this, Player.class, true));
- }
- public static AttributeSupplier.Builder createAttributes() {
- return Monster.createMonsterAttributes().add(Attributes.FOLLOW_RANGE, 5.0D).add(Attributes.MOVEMENT_SPEED, 0.1D)
- .add(Attributes.MAX_HEALTH, 30.0D).add(Attributes.ATTACK_DAMAGE, 1.0D);
- }
- public boolean targetIsNear() {
- if (lastTarget != null) {
- return this.distanceTo(lastTarget) <= 7;
- } else {
- return false;
- }
- }
- public void tick() {
- super.tick();
- Entity tempTarget = this.getTarget();
- if (tempTarget != null) {
- lastTarget = tempTarget;
- }
- System.out.println(lastTarget);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment