Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified forge 1.20.1/gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.ai.navigation.GroundPathNavigation;
import net.minecraft.world.entity.monster.Creeper;
import net.minecraft.world.entity.monster.Enemy;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.*;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
Expand Down Expand Up @@ -83,7 +84,6 @@ public class AbstractHumanCompanionEntity extends TamableAnimal {
public SimpleContainer inventory = new SimpleContainer(27);
public EquipmentSlot[] armorTypes = new EquipmentSlot[]{EquipmentSlot.FEET, EquipmentSlot.LEGS,
EquipmentSlot.CHEST, EquipmentSlot.HEAD};
public List<NearestAttackableTargetGoal> alertMobGoals = new ArrayList<>();
public List<NearestAttackableTargetGoal> huntMobGoals = new ArrayList<>();
public PatrolGoal patrolGoal;
public MoveBackToPatrolGoal moveBackGoal;
Expand All @@ -94,19 +94,20 @@ public class AbstractHumanCompanionEntity extends TamableAnimal {
private final Map<String, Integer> foodRequirements = new HashMap<>(Map.of("", 0));
private String food1 = "";
private String food2 = "";
private final NearestAttackableTargetGoal<LivingEntity> alertHostleGoal; // Store the goal

public AbstractHumanCompanionEntity(EntityType<? extends TamableAnimal> entityType, Level level) {
super(entityType, level);
this.setTame(false);
// this.setCanPickUpLoot(true);
((GroundPathNavigation)this.getNavigation()).setCanOpenDoors(true);
this.getNavigation().setCanFloat(true);
for (int i = 0; i < CompanionData.alertMobs.length; i++) {
alertMobGoals.add(new NearestAttackableTargetGoal(this, CompanionData.alertMobs[i], false));
}
for (int i = 0; i < CompanionData.huntMobs.length; i++) {
huntMobGoals.add(new NearestAttackableTargetGoal(this, CompanionData.huntMobs[i], false));
}
alertHostleGoal = new NearestAttackableTargetGoal<>(this, LivingEntity.class, true,
entity -> entity instanceof Enemy
);
}

@Override
Expand Down Expand Up @@ -757,15 +758,11 @@ public void setFollowing(boolean following) {
}

public void addAlertGoals() {
for (NearestAttackableTargetGoal alertMobGoal : alertMobGoals) {
this.targetSelector.addGoal(4, alertMobGoal);
}
this.targetSelector.addGoal(4, alertHostleGoal);
}

public void removeAlertGoals() {
for (NearestAttackableTargetGoal alertMobGoal : alertMobGoals) {
this.targetSelector.removeGoal(alertMobGoal);
}
this.targetSelector.removeGoal(alertHostleGoal);
}

public void addHuntingGoals() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,6 @@ public class CompanionData {
Component.literal("I want something else now."),
};

public static Class<?>[] alertMobs = new Class<?>[]{
Blaze.class,
EnderMan.class,
Endermite.class,
Ghast.class,
Giant.class,
Guardian.class,
Hoglin.class,
MagmaCube.class,
Phantom.class,
Shulker.class,
Silverfish.class,
Slime.class,
Spider.class,
Vex.class,
AbstractSkeleton.class,
Zoglin.class,
Zombie.class,
Raider.class
};

public static Class<?>[] huntMobs = new Class<?>[]{
Chicken.class,
Cow.class,
Expand Down