forked from FrozenBlock/WilderWild
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0d9e705
commit d5a5a7f
Showing
15 changed files
with
155 additions
and
59 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/main/generated/data/wilderwild/tags/entity_types/crab_hunt_targets.json
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,11 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
"minecraft:squid", | ||
"minecraft:glow_squid", | ||
"minecraft:cod", | ||
"minecraft:salmon", | ||
"minecraft:tropical_fish", | ||
"minecraft:tadpole" | ||
] | ||
} |
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
50 changes: 50 additions & 0 deletions
50
src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabAttackablesSensor.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,50 @@ | ||
/* | ||
* Copyright 2023 FrozenBlock | ||
* This file is part of Wilder Wild. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package net.frozenblock.wilderwild.entity.ai.crab; | ||
|
||
import net.frozenblock.wilderwild.tag.WilderEntityTags; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.ai.memory.MemoryModuleType; | ||
import net.minecraft.world.entity.ai.sensing.NearestVisibleLivingEntitySensor; | ||
import net.minecraft.world.entity.ai.sensing.Sensor; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class CrabAttackablesSensor extends NearestVisibleLivingEntitySensor { | ||
|
||
public CrabAttackablesSensor() { | ||
|
||
} | ||
|
||
protected boolean isMatchingEntity(@NotNull LivingEntity attacker, @NotNull LivingEntity target) { | ||
return this.isClose(attacker, target) && this.isHuntTarget(attacker, target) && Sensor.isEntityAttackable(attacker, target); | ||
} | ||
|
||
private boolean isHuntTarget(@NotNull LivingEntity attacker, LivingEntity target) { | ||
return !attacker.getBrain().hasMemoryValue(MemoryModuleType.HAS_HUNTING_COOLDOWN) && target.getType().is(WilderEntityTags.CRAB_HUNT_TARGETS); | ||
} | ||
|
||
private boolean isClose(LivingEntity attacker, @NotNull LivingEntity target) { | ||
return Math.sqrt(target.distanceToSqr(attacker)) <= 8D; | ||
} | ||
|
||
@NotNull | ||
protected MemoryModuleType<LivingEntity> getMemory() { | ||
return MemoryModuleType.NEAREST_ATTACKABLE; | ||
} | ||
} |
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
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
Oops, something went wrong.