Skip to content

Commit

Permalink
Attempt at fixing #218
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Dec 1, 2020
1 parent 1976f16 commit 4de1f21
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
@@ -0,0 +1,19 @@
package com.teammetallurgy.atum.entity.ai.controller;

import net.minecraft.entity.Entity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.controller.LookController;

public class AssassinLookController extends LookController {

public AssassinLookController(MobEntity mob) {
super(mob);
}

@Override
public void setLookPositionWithEntity(Entity entity, float deltaYaw, float deltaPitch) {
if (entity != null) {
super.setLookPositionWithEntity(entity, deltaYaw, deltaPitch);
}
}
}
@@ -1,11 +1,13 @@
package com.teammetallurgy.atum.entity.bandit;

import com.teammetallurgy.atum.entity.ai.controller.AssassinLookController;
import com.teammetallurgy.atum.entity.ai.goal.OpenAnyDoorGoal;
import com.teammetallurgy.atum.entity.ai.pathfinding.ClimberGroundPathNavigator;
import com.teammetallurgy.atum.entity.undead.UndeadBaseEntity;
import com.teammetallurgy.atum.init.AtumItems;
import net.minecraft.block.BlockState;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.controller.LookController;
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
Expand Down Expand Up @@ -55,7 +57,13 @@ protected void registerGoals() {
super.registerGoals();
this.goalSelector.addGoal(1, new MarkedForDeathGoal(this, this.markedTarget));
this.goalSelector.addGoal(3, new OpenAnyDoorGoal(this, false));
this.goalSelector.addGoal(4, new AssassinMeleeAttackGoal(this, 1.2D, true));
this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.2D, true));
}

@Override
@Nonnull
public LookController getLookController() {
return new AssassinLookController(this);
}

@Override
Expand Down Expand Up @@ -228,23 +236,4 @@ public void resetTask() {
((AssassinEntity) this.goalOwner).markedTarget = null;
}
}

public static class AssassinMeleeAttackGoal extends MeleeAttackGoal {

public AssassinMeleeAttackGoal(CreatureEntity creature, double speedIn, boolean useLongMemory) {
super(creature, speedIn, useLongMemory);
}

@Override
public boolean shouldExecute() {
return this.attacker != null && super.shouldExecute();
}

@Override
public void tick() {
if (this.attacker != null && this.attacker.getLookController() != null) {
super.tick();
}
}
}
}

0 comments on commit 4de1f21

Please sign in to comment.