-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
149 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/org/vivecraft/entities/CustomEndermanFreezeWhenLookedAt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.vivecraft.entities; | ||
|
||
import java.util.EnumSet; | ||
|
||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.ai.goal.Goal; | ||
import net.minecraft.world.entity.monster.EnderMan; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class CustomEndermanFreezeWhenLookedAt extends Goal { | ||
private final EnderMan enderman; | ||
private LivingEntity target; | ||
|
||
public CustomEndermanFreezeWhenLookedAt(EnderMan entityenderman) { | ||
this.enderman = entityenderman; | ||
this.setFlags(EnumSet.of(Flag.JUMP, Flag.MOVE)); | ||
} | ||
|
||
public boolean canUse() { | ||
this.target = this.enderman.getTarget(); | ||
if (!(this.target instanceof Player)) { | ||
return false; | ||
} else { | ||
double d0 = this.target.distanceToSqr(this.enderman); | ||
return d0 > 256.0 ? false : EndermanUtils.isLookingAtMe((Player)this.target, this.enderman); | ||
} | ||
} | ||
|
||
public void start() { | ||
this.enderman.getNavigation().stop(); | ||
} | ||
|
||
public void tick() { | ||
this.enderman.getLookControl().setLookAt(this.target.getX(), this.target.getEyeY(), this.target.getZ()); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
src/org/vivecraft/entities/CustomEndermanLookForPlayerGoal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package org.vivecraft.entities; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; | ||
import net.minecraft.world.entity.ai.targeting.TargetingConditions; | ||
import net.minecraft.world.entity.monster.EnderMan; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class CustomEndermanLookForPlayerGoal extends NearestAttackableTargetGoal<Player> { | ||
private final EnderMan enderman; | ||
private Player pendingTarget; | ||
private int aggroTime; | ||
private int teleportTime; | ||
private final TargetingConditions startAggroTargetConditions; | ||
private final TargetingConditions continueAggroTargetConditions = TargetingConditions.forCombat().ignoreLineOfSight(); | ||
private final Predicate<LivingEntity> isAngerInducing; | ||
|
||
public CustomEndermanLookForPlayerGoal(EnderMan entityenderman, Predicate<LivingEntity> p) { | ||
super(entityenderman, Player.class, 10, false, false, p); | ||
this.enderman = entityenderman; | ||
this.isAngerInducing = (entityliving) -> { | ||
return (EndermanUtils.isLookingAtMe((Player)entityliving, this.enderman) || entityenderman.isAngryAt((LivingEntity) entityliving)) && !entityenderman.hasIndirectPassenger((Entity) entityliving); | ||
}; | ||
this.startAggroTargetConditions = TargetingConditions.forCombat().range(this.getFollowDistance()).selector(this.isAngerInducing); | ||
} | ||
|
||
public boolean canUse() { | ||
this.pendingTarget = this.enderman.level().getNearestPlayer(this.startAggroTargetConditions, this.enderman); | ||
return this.pendingTarget != null; | ||
} | ||
|
||
public void start() { | ||
this.aggroTime = this.adjustedTickDelay(5); | ||
this.teleportTime = 0; | ||
this.enderman.setBeingStaredAt(); | ||
} | ||
|
||
public void stop() { | ||
this.pendingTarget = null; | ||
super.stop(); | ||
} | ||
|
||
public boolean canContinueToUse() { | ||
if (this.pendingTarget != null) { | ||
if (!this.isAngerInducing.test(this.pendingTarget)) { | ||
return false; | ||
} else { | ||
this.enderman.lookAt(this.pendingTarget, 10.0F, 10.0F); | ||
return true; | ||
} | ||
} else { | ||
if (this.target != null) { | ||
if (this.enderman.hasIndirectPassenger(this.target)) { | ||
return false; | ||
} | ||
|
||
if (this.continueAggroTargetConditions.test(this.enderman, this.target)) { | ||
return true; | ||
} | ||
} | ||
|
||
return super.canContinueToUse(); | ||
} | ||
} | ||
|
||
public void tick() { | ||
if (this.enderman.getTarget() == null) { | ||
super.setTarget((LivingEntity)null); | ||
} | ||
|
||
if (this.pendingTarget != null) { | ||
if (--this.aggroTime <= 0) { | ||
this.target = this.pendingTarget; | ||
this.pendingTarget = null; | ||
super.start(); | ||
} | ||
} else { | ||
if (this.target != null && !this.enderman.isPassenger()) { | ||
if (EndermanUtils.isLookingAtMe((Player)this.target, this.enderman)) { | ||
if (this.target.distanceToSqr(this.enderman) < 16.0) { | ||
this.enderman.teleport(); | ||
} | ||
|
||
this.teleportTime = 0; | ||
} else if (this.target.distanceToSqr(this.enderman) > 256.0 && this.teleportTime++ >= this.adjustedTickDelay(30) && this.enderman.teleportTowards(this.target)) { | ||
this.teleportTime = 0; | ||
} | ||
} | ||
|
||
super.tick(); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
|
163 changes: 0 additions & 163 deletions
163
src/org/vivecraft/entities/CustomPathFinderGoalPlayerWhoLookedAtTarget.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.