diff --git a/src/main/generated/data/wilderwild/tags/entity_types/crab_hunt_targets.json b/src/main/generated/data/wilderwild/tags/entity_types/crab_hunt_targets.json new file mode 100644 index 0000000000..c85c6a81a3 --- /dev/null +++ b/src/main/generated/data/wilderwild/tags/entity_types/crab_hunt_targets.json @@ -0,0 +1,11 @@ +{ + "replace": false, + "values": [ + "minecraft:squid", + "minecraft:glow_squid", + "minecraft:cod", + "minecraft:salmon", + "minecraft:tropical_fish", + "minecraft:tadpole" + ] +} \ No newline at end of file diff --git a/src/main/java/net/frozenblock/wilderwild/WilderWild.java b/src/main/java/net/frozenblock/wilderwild/WilderWild.java index 5323b1327e..9388b7672f 100644 --- a/src/main/java/net/frozenblock/wilderwild/WilderWild.java +++ b/src/main/java/net/frozenblock/wilderwild/WilderWild.java @@ -65,7 +65,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.util.datafix.schemas.NamespacedSchema; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.quiltmc.qsl.frozenblock.misc.datafixerupper.api.QuiltDataFixerBuilder; import org.quiltmc.qsl.frozenblock.misc.datafixerupper.api.QuiltDataFixes; import org.quiltmc.qsl.frozenblock.misc.datafixerupper.api.SimpleFixes; diff --git a/src/main/java/net/frozenblock/wilderwild/datagen/WWEntityTagProvider.java b/src/main/java/net/frozenblock/wilderwild/datagen/WWEntityTagProvider.java index 48bee2283e..c853c706fc 100644 --- a/src/main/java/net/frozenblock/wilderwild/datagen/WWEntityTagProvider.java +++ b/src/main/java/net/frozenblock/wilderwild/datagen/WWEntityTagProvider.java @@ -24,6 +24,7 @@ import net.frozenblock.wilderwild.registry.RegisterEntities; import net.frozenblock.wilderwild.tag.WilderEntityTags; import net.minecraft.core.HolderLookup; +import net.minecraft.world.entity.EntityType; import org.jetbrains.annotations.NotNull; final class WWEntityTagProvider extends FabricTagProvider.EntityTypeTagProvider { @@ -36,5 +37,13 @@ public WWEntityTagProvider(@NotNull FabricDataOutput output, @NotNull Completabl protected void addTags(@NotNull HolderLookup.Provider arg) { this.getOrCreateTagBuilder(WilderEntityTags.STAYS_IN_MESOGLEA) .add(RegisterEntities.JELLYFISH); + + this.getOrCreateTagBuilder(WilderEntityTags.CRAB_HUNT_TARGETS) + .add(EntityType.SQUID) + .add(EntityType.GLOW_SQUID) + .add(EntityType.COD) + .add(EntityType.SALMON) + .add(EntityType.TROPICAL_FISH) + .add(EntityType.TADPOLE); } } diff --git a/src/main/java/net/frozenblock/wilderwild/entity/Crab.java b/src/main/java/net/frozenblock/wilderwild/entity/Crab.java index 82d6fa7159..589eb2f964 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/Crab.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/Crab.java @@ -21,7 +21,6 @@ import com.mojang.serialization.Dynamic; import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiConsumer; @@ -33,7 +32,6 @@ import net.frozenblock.wilderwild.registry.RegisterEntities; import net.frozenblock.wilderwild.registry.RegisterItems; import net.frozenblock.wilderwild.registry.RegisterMemoryModuleTypes; -import net.frozenblock.wilderwild.registry.RegisterSensorTypes; import net.frozenblock.wilderwild.registry.RegisterSounds; import net.frozenblock.wilderwild.tag.WilderBiomeTags; import net.frozenblock.wilderwild.tag.WilderBlockTags; @@ -83,8 +81,6 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.entity.ai.navigation.WallClimberNavigation; -import net.minecraft.world.entity.ai.sensing.Sensor; -import net.minecraft.world.entity.ai.sensing.SensorType; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.animal.Bucketable; import net.minecraft.world.entity.player.Player; @@ -115,45 +111,6 @@ public class Crab extends Animal implements VibrationSystem, Bucketable { public static final int EMERGE_LENGTH_IN_TICKS = 29; public static final double UNDERGROUND_PLAYER_RANGE = 4; private static final Map CRABS_PER_LEVEL = new HashMap<>(); - protected static final List>> SENSORS = List.of( - SensorType.NEAREST_LIVING_ENTITIES, - SensorType.NEAREST_PLAYERS, - SensorType.NEAREST_ADULT, - SensorType.HURT_BY, - RegisterSensorTypes.CRAB_TEMPTATIONS, - RegisterSensorTypes.CRAB_SPECIFIC_SENSOR, - RegisterSensorTypes.CRAB_NEARBY_PLAYER_SENSOR, - RegisterSensorTypes.CRAB_CAN_DIG_SENSOR - ); - protected static final List> MEMORY_MODULES = List.of( - MemoryModuleType.NEAREST_LIVING_ENTITIES, - MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, - MemoryModuleType.NEAREST_PLAYERS, - MemoryModuleType.NEAREST_VISIBLE_PLAYER, - MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, - RegisterMemoryModuleTypes.IS_PLAYER_NEARBY, - MemoryModuleType.LOOK_TARGET, - MemoryModuleType.WALK_TARGET, - MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, - MemoryModuleType.PATH, - MemoryModuleType.ATTACK_TARGET, - MemoryModuleType.NEAREST_ATTACKABLE, - MemoryModuleType.ATTACK_COOLING_DOWN, - MemoryModuleType.HURT_BY, - MemoryModuleType.HURT_BY_ENTITY, - MemoryModuleType.IS_PANICKING, - MemoryModuleType.IS_EMERGING, - MemoryModuleType.DIG_COOLDOWN, - RegisterMemoryModuleTypes.CAN_DIG, - MemoryModuleType.TEMPTING_PLAYER, - MemoryModuleType.IS_TEMPTED, - MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, - MemoryModuleType.BREED_TARGET, - RegisterMemoryModuleTypes.IS_UNDERGROUND, - RegisterMemoryModuleTypes.NEARBY_CRABS, - RegisterMemoryModuleTypes.HEAL_COOLDOWN_TICKS, - RegisterMemoryModuleTypes.FIRST_BRAIN_TICK - ); private static final int DIG_TICKS_UNTIL_PARTICLES = 17; private static final int DIG_TICKS_UNTIL_STOP_PARTICLES = 82; private static final int EMERGE_TICKS_UNTIL_PARTICLES = 1; @@ -207,7 +164,7 @@ public static AttributeSupplier.Builder addAttributes() { @Override @NotNull protected Brain.Provider brainProvider() { - return Brain.provider(MEMORY_MODULES, SENSORS); + return Brain.provider(CrabAi.MEMORY_MODULES, CrabAi.SENSORS); } @Override @@ -629,6 +586,10 @@ public void saveToBucketTag(@NotNull ItemStack stack) { Bucketable.saveDefaultDataToBucketTag(this, stack); CompoundTag compoundTag = stack.getOrCreateTag(); compoundTag.putInt("Age", this.getAge()); + Brain brain = this.getBrain(); + if (brain.hasMemoryValue(MemoryModuleType.HAS_HUNTING_COOLDOWN)) { + compoundTag.putLong("HuntingCooldown", brain.getTimeUntilExpiry(MemoryModuleType.HAS_HUNTING_COOLDOWN)); + } } @Override @@ -637,6 +598,9 @@ public void loadFromBucketTag(@NotNull CompoundTag tag) { if (tag.contains("Age")) { this.setAge(tag.getInt("Age")); } + if (tag.contains("HuntingCooldown")) { + this.getBrain().setMemoryWithExpiry(MemoryModuleType.HAS_HUNTING_COOLDOWN, true, tag.getLong("HuntingCooldown")); + } } @Override diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabAi.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabAi.java index 896c47252a..3e6110ff1c 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabAi.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabAi.java @@ -27,6 +27,7 @@ import net.frozenblock.wilderwild.entity.Crab; import net.frozenblock.wilderwild.registry.RegisterEntities; import net.frozenblock.wilderwild.registry.RegisterMemoryModuleTypes; +import net.frozenblock.wilderwild.registry.RegisterSensorTypes; import net.frozenblock.wilderwild.tag.WilderItemTags; import net.minecraft.util.Unit; import net.minecraft.util.valueproviders.UniformInt; @@ -56,6 +57,7 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.memory.MemoryStatus; import net.minecraft.world.entity.ai.sensing.Sensor; +import net.minecraft.world.entity.ai.sensing.SensorType; import net.minecraft.world.entity.schedule.Activity; import net.minecraft.world.item.crafting.Ingredient; import org.jetbrains.annotations.NotNull; @@ -69,6 +71,47 @@ public final class CrabAi { private static final int DIGGING_DURATION = Crab.DIG_LENGTH_IN_TICKS; private static final int EMERGE_DURATION = Crab.EMERGE_LENGTH_IN_TICKS; public static final double UNDERGROUND_PLAYER_RANGE = Crab.UNDERGROUND_PLAYER_RANGE; + public static final List>> SENSORS = List.of( + SensorType.NEAREST_LIVING_ENTITIES, + SensorType.NEAREST_PLAYERS, + SensorType.NEAREST_ADULT, + SensorType.HURT_BY, + RegisterSensorTypes.CRAB_ATTACKABLES, + RegisterSensorTypes.CRAB_TEMPTATIONS, + RegisterSensorTypes.CRAB_SPECIFIC_SENSOR, + RegisterSensorTypes.CRAB_NEARBY_PLAYER_SENSOR, + RegisterSensorTypes.CRAB_CAN_DIG_SENSOR + ); + public static final List> MEMORY_MODULES = List.of( + MemoryModuleType.NEAREST_LIVING_ENTITIES, + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, + MemoryModuleType.NEAREST_PLAYERS, + MemoryModuleType.NEAREST_VISIBLE_PLAYER, + MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, + RegisterMemoryModuleTypes.IS_PLAYER_NEARBY, + MemoryModuleType.LOOK_TARGET, + MemoryModuleType.WALK_TARGET, + MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, + MemoryModuleType.PATH, + MemoryModuleType.ATTACK_TARGET, + MemoryModuleType.NEAREST_ATTACKABLE, + MemoryModuleType.HAS_HUNTING_COOLDOWN, + MemoryModuleType.ATTACK_COOLING_DOWN, + MemoryModuleType.HURT_BY, + MemoryModuleType.HURT_BY_ENTITY, + MemoryModuleType.IS_PANICKING, + MemoryModuleType.IS_EMERGING, + MemoryModuleType.DIG_COOLDOWN, + RegisterMemoryModuleTypes.CAN_DIG, + MemoryModuleType.TEMPTING_PLAYER, + MemoryModuleType.IS_TEMPTED, + MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, + MemoryModuleType.BREED_TARGET, + RegisterMemoryModuleTypes.IS_UNDERGROUND, + RegisterMemoryModuleTypes.NEARBY_CRABS, + RegisterMemoryModuleTypes.HEAL_COOLDOWN_TICKS, + RegisterMemoryModuleTypes.FIRST_BRAIN_TICK + ); private static final BehaviorControl DIG_COOLDOWN_SETTER = BehaviorBuilder.create(instance -> instance.group(instance.registered(MemoryModuleType.DIG_COOLDOWN)).apply(instance, memoryAccessor -> (world, crab, l) -> { if (instance.tryGet(memoryAccessor).isPresent()) { @@ -76,9 +119,10 @@ public final class CrabAi { } return true; })); - private static final BehaviorControl EMERGE_COOLDOWN_SETTER = BehaviorBuilder.create(instance -> instance.group(instance.registered(MemoryModuleType.DIG_COOLDOWN)).apply(instance, memoryAccessor -> (world, crab, l) -> { + + private static final BehaviorControl HUNTING_COOLDOWN_SETTER = BehaviorBuilder.create(instance -> instance.group(instance.registered(MemoryModuleType.HAS_HUNTING_COOLDOWN)).apply(instance, memoryAccessor -> (world, crab, l) -> { if (instance.tryGet(memoryAccessor).isPresent()) { - memoryAccessor.setWithExpiry(Unit.INSTANCE, getRandomEmergeCooldown(crab)); + memoryAccessor.setWithExpiry(true, 2400); } return true; })); @@ -195,6 +239,7 @@ private static void addFightActivity(@NotNull Crab crab, @NotNull Brain br 10, ImmutableList.of( DIG_COOLDOWN_SETTER, + HUNTING_COOLDOWN_SETTER, StopAttackingIfTargetInvalid.create( livingEntity -> !crab.canTargetEntity(livingEntity), CrabAi::onTargetInvalid, true ), diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabAttackablesSensor.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabAttackablesSensor.java new file mode 100644 index 0000000000..c07f8088ca --- /dev/null +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabAttackablesSensor.java @@ -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 . + */ + +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 getMemory() { + return MemoryModuleType.NEAREST_ATTACKABLE; + } +} diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabCanDigSensor.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabCanDigSensor.java index 297c4e6502..4a2c05295e 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabCanDigSensor.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabCanDigSensor.java @@ -29,13 +29,15 @@ import org.jetbrains.annotations.NotNull; public class CrabCanDigSensor extends Sensor { + @Override + @NotNull public Set> requires() { return ImmutableSet.of(RegisterMemoryModuleTypes.CAN_DIG); } @Override - protected void doTick(ServerLevel level, @NotNull Crab crab) { + protected void doTick(@NotNull ServerLevel level, @NotNull Crab crab) { Brain brain = crab.getBrain(); if (crab.canHideOnGround()) { brain.setMemory(RegisterMemoryModuleTypes.CAN_DIG, true); diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabDig.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabDig.java index 5523704154..4294819eaf 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabDig.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabDig.java @@ -31,6 +31,7 @@ import org.jetbrains.annotations.NotNull; public class CrabDig extends Behavior { + public CrabDig(int duration) { super( Map.of( @@ -43,12 +44,12 @@ public CrabDig(int duration) { } @Override - protected boolean canStillUse(ServerLevel level, E entity, long gameTime) { + protected boolean canStillUse(@NotNull ServerLevel level, @NotNull E entity, long gameTime) { return true; } @Override - protected void start(ServerLevel level, @NotNull E crab, long gameTime) { + protected void start(@NotNull ServerLevel level, @NotNull E crab, long gameTime) { crab.endNavigation(); crab.setPose(Pose.DIGGING); crab.playSound(RegisterSounds.ENTITY_CRAB_DIG, 0.5F, 1.0F); @@ -56,7 +57,7 @@ protected void start(ServerLevel level, @NotNull E crab, long gameTime) { } @Override - protected void stop(ServerLevel level, @NotNull E crab, long gameTime) { + protected void stop(@NotNull ServerLevel level, @NotNull E crab, long gameTime) { if (crab.hasPose(Pose.DIGGING)) { crab.getBrain().setMemory(RegisterMemoryModuleTypes.IS_UNDERGROUND, true); crab.getBrain().setMemoryWithExpiry(MemoryModuleType.DIG_COOLDOWN, Unit.INSTANCE, CrabAi.getRandomEmergeCooldown(crab)); diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabEmerge.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabEmerge.java index e6c827db84..d52493bb14 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabEmerge.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabEmerge.java @@ -29,24 +29,25 @@ import org.jetbrains.annotations.NotNull; public class CrabEmerge extends Behavior { + public CrabEmerge(int duration) { super(ImmutableMap.of(MemoryModuleType.IS_EMERGING, MemoryStatus.VALUE_PRESENT), duration); } @Override - protected boolean canStillUse(ServerLevel level, E entity, long gameTime) { + protected boolean canStillUse(@NotNull ServerLevel level, @NotNull E entity, long gameTime) { return true; } @Override - protected void start(ServerLevel level, @NotNull E crab, long gameTime) { + protected void start(@NotNull ServerLevel level, @NotNull E crab, long gameTime) { crab.setPose(Pose.EMERGING); crab.playSound(RegisterSounds.ENTITY_CRAB_EMERGE, 0.5F, 1.0F); crab.resetDiggingTicks(); } @Override - protected void stop(ServerLevel level, @NotNull E crab, long gameTime) { + protected void stop(@NotNull ServerLevel level, @NotNull E crab, long gameTime) { if (crab.hasPose(Pose.EMERGING)) { crab.setPose(Pose.STANDING); } diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabHeal.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabHeal.java index 9ce49bc227..3bff519916 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabHeal.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabHeal.java @@ -23,9 +23,13 @@ import net.minecraft.world.entity.ai.behavior.BehaviorControl; import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder; import net.minecraft.world.entity.ai.memory.MemoryModuleType; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; public class CrabHeal { - public static BehaviorControl create() { + + @Contract(" -> new") + public static @NotNull BehaviorControl create() { return BehaviorBuilder.create(instance -> instance.group( instance.present(RegisterMemoryModuleTypes.IS_UNDERGROUND), instance.present(MemoryModuleType.DIG_COOLDOWN), diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabNearbyPlayerSensor.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabNearbyPlayerSensor.java index 8db23e82c3..13e0e4b17a 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabNearbyPlayerSensor.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabNearbyPlayerSensor.java @@ -29,13 +29,15 @@ import org.jetbrains.annotations.NotNull; public class CrabNearbyPlayerSensor extends Sensor { + @Override + @NotNull public Set> requires() { return ImmutableSet.of(MemoryModuleType.NEAREST_PLAYERS, RegisterMemoryModuleTypes.IS_PLAYER_NEARBY); } @Override - protected void doTick(ServerLevel level, @NotNull Crab crab) { + protected void doTick(@NotNull ServerLevel level, @NotNull Crab crab) { Brain brain = crab.getBrain(); if (brain.hasMemoryValue(MemoryModuleType.NEAREST_PLAYERS) && !brain.getMemory(MemoryModuleType.NEAREST_PLAYERS).get().isEmpty()) { brain.setMemory(RegisterMemoryModuleTypes.IS_PLAYER_NEARBY, true); diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabSpecificSensor.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabSpecificSensor.java index 25bfb4cf1f..691facf72c 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabSpecificSensor.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabSpecificSensor.java @@ -34,13 +34,15 @@ import org.jetbrains.annotations.NotNull; public class CrabSpecificSensor extends Sensor { + @Override + @NotNull public Set> requires() { return ImmutableSet.of(RegisterMemoryModuleTypes.NEARBY_CRABS, MemoryModuleType.NEAREST_LIVING_ENTITIES); } @Override - protected void doTick(ServerLevel level, @NotNull LivingEntity entity) { + protected void doTick(@NotNull ServerLevel level, @NotNull LivingEntity entity) { Brain brain = entity.getBrain(); ArrayList crabs = Lists.newArrayList(); List entities = brain.getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).orElse(ImmutableList.of()); @@ -51,5 +53,4 @@ protected void doTick(ServerLevel level, @NotNull LivingEntity entity) { } brain.setMemory(RegisterMemoryModuleTypes.NEARBY_CRABS, crabs); } - } diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabTryToEmerge.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabTryToEmerge.java index 270af9e2bb..940b5795aa 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabTryToEmerge.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/crab/CrabTryToEmerge.java @@ -25,9 +25,13 @@ import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.memory.MemoryStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; public class CrabTryToEmerge { - public static BehaviorControl create() { + + @Contract(" -> new") + public static @NotNull BehaviorControl create() { return BehaviorBuilder.create(instance -> instance.group( instance.registered(MemoryModuleType.IS_EMERGING), instance.present(RegisterMemoryModuleTypes.IS_UNDERGROUND), diff --git a/src/main/java/net/frozenblock/wilderwild/registry/RegisterSensorTypes.java b/src/main/java/net/frozenblock/wilderwild/registry/RegisterSensorTypes.java index 3b70809a70..ef7f001857 100644 --- a/src/main/java/net/frozenblock/wilderwild/registry/RegisterSensorTypes.java +++ b/src/main/java/net/frozenblock/wilderwild/registry/RegisterSensorTypes.java @@ -20,6 +20,7 @@ import java.util.function.Supplier; import net.frozenblock.wilderwild.entity.ai.crab.CrabAi; +import net.frozenblock.wilderwild.entity.ai.crab.CrabAttackablesSensor; import net.frozenblock.wilderwild.entity.ai.crab.CrabCanDigSensor; import net.frozenblock.wilderwild.entity.ai.crab.CrabNearbyPlayerSensor; import net.frozenblock.wilderwild.entity.ai.crab.CrabSpecificSensor; @@ -44,6 +45,7 @@ public static void register() { public static final SensorType CRAB_TEMPTATIONS = register("crab_temptations", () -> new TemptingSensor(CrabAi.getTemptations())); public static final SensorType CRAB_NEARBY_PLAYER_SENSOR = register("crab_nearby_player_sensor", CrabNearbyPlayerSensor::new); public static final SensorType CRAB_CAN_DIG_SENSOR = register("crab_can_dig_sensor", CrabCanDigSensor::new); + public static final SensorType CRAB_ATTACKABLES = register("crab_attackables", CrabAttackablesSensor::new); @NotNull private static > SensorType register(String key, Supplier sensorSupplier) { diff --git a/src/main/java/net/frozenblock/wilderwild/tag/WilderEntityTags.java b/src/main/java/net/frozenblock/wilderwild/tag/WilderEntityTags.java index 8d0d021e9a..0a1b5d0077 100644 --- a/src/main/java/net/frozenblock/wilderwild/tag/WilderEntityTags.java +++ b/src/main/java/net/frozenblock/wilderwild/tag/WilderEntityTags.java @@ -29,6 +29,7 @@ public final class WilderEntityTags { public static final TagKey> STAYS_IN_MESOGLEA = bind("stays_in_mesoglea"); public static final TagKey> ANCIENT_HORN_IMMUNE = bind("ancient_horn_immune"); public static final TagKey> JELLYFISH_CANT_STING = bind("jellyfish_cant_sting"); + public static final TagKey> CRAB_HUNT_TARGETS = bind("crab_hunt_targets"); public static final TagKey> COCONUT_CANT_BONK = bind("coconut_cant_bonk"); public static final TagKey> COCONUT_CANT_SPLIT = bind("coconut_cant_split");