-
Notifications
You must be signed in to change notification settings - Fork 68
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
1 parent
dc32f2f
commit fb41d00
Showing
8 changed files
with
55 additions
and
17 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
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
17 changes: 7 additions & 10 deletions
17
.../github/tartaricacid/touhoulittlemaid/compat/tacz/utils/GunNearestLivingEntitySensor.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 |
---|---|---|
@@ -1,40 +1,37 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.compat.tacz.utils; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.compat.tacz.task.TaskGunAttack; | ||
import com.github.tartaricacid.touhoulittlemaid.config.subconfig.MaidConfig; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; | ||
import com.tacz.guns.api.item.IGun; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.ai.Brain; | ||
import net.minecraft.world.entity.ai.memory.MemoryModuleType; | ||
import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities; | ||
import net.minecraft.world.entity.schedule.Activity; | ||
import net.minecraft.world.phys.AABB; | ||
|
||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
public class GunNearestLivingEntitySensor { | ||
private static final int VERTICAL_SEARCH_RANGE = 64; | ||
private static final int RADIUS_SEARCH_RANGE = 128; | ||
|
||
public static boolean isGunTask(EntityMaid maid) { | ||
return maid.getTask().getUid().equals(TaskGunAttack.UID); | ||
return maid.getTask().getUid().equals(TaskGunAttack.UID) && maid.getScheduleDetail() == Activity.WORK && IGun.mainhandHoldGun(maid); | ||
} | ||
|
||
public static void doGunTick(ServerLevel world, EntityMaid maid) { | ||
AABB aabb; | ||
int searchRange = MaidConfig.MAID_GUN_LONG_DISTANCE.get(); | ||
if (maid.hasRestriction()) { | ||
aabb = new AABB(maid.getRestrictCenter()).inflate(RADIUS_SEARCH_RANGE, VERTICAL_SEARCH_RANGE, RADIUS_SEARCH_RANGE); | ||
aabb = new AABB(maid.getRestrictCenter()).inflate(searchRange); | ||
} else { | ||
aabb = maid.getBoundingBox().inflate(RADIUS_SEARCH_RANGE, VERTICAL_SEARCH_RANGE, RADIUS_SEARCH_RANGE); | ||
aabb = maid.getBoundingBox().inflate(searchRange); | ||
} | ||
List<LivingEntity> list = world.getEntitiesOfClass(LivingEntity.class, aabb, (entity) -> entity != maid && entity.isAlive()); | ||
list.sort(Comparator.comparingDouble(maid::distanceToSqr)); | ||
Brain<EntityMaid> brain = maid.getBrain(); | ||
brain.setMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES, list); | ||
brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, new NearestVisibleLivingEntities(maid, list)); | ||
} | ||
|
||
public static int getRadiusSearchRange() { | ||
return RADIUS_SEARCH_RANGE; | ||
} | ||
} |
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
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