Skip to content

Commit

Permalink
some penguin progress
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Jan 9, 2025
1 parent 3300c7c commit bb2aa9f
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"minecraft:squid",
"minecraft:glow_squid"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"minecraft:ink_sac",
"minecraft:glow_ink_sac"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ protected void addTags(@NotNull HolderLookup.Provider arg) {
this.getOrCreateTagBuilder(WWItemTags.OSTRICH_FOOD)
.add(WWBlocks.BUSH.asItem());

this.getOrCreateTagBuilder(WWItemTags.PENGUIN_FOOD)
.add(Items.INK_SAC)
.add(Items.GLOW_INK_SAC);

this.getOrCreateTagBuilder(ItemTags.BOATS)
.add(WWItems.BAOBAB_BOAT)
.add(WWItems.CYPRESS_BOAT)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/frozenblock/wilderwild/entity/Penguin.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.mojang.serialization.Dynamic;
import net.frozenblock.wilderwild.entity.ai.penguin.PenguinAi;
import net.frozenblock.wilderwild.registry.WWEntityTypes;
import net.frozenblock.wilderwild.tag.WWItemTags;
import net.minecraft.core.BlockPos;
import net.minecraft.network.protocol.game.DebugPackets;
import net.minecraft.network.syncher.EntityDataAccessor;
Expand Down Expand Up @@ -126,8 +127,7 @@ public boolean isTouchingWaterOrSwimming() {

@Override
public boolean isFood(@NotNull ItemStack itemStack) {
// TODO: use a tag
return itemStack.getItem() == Items.COD || itemStack.getItem() == Items.SALMON;
return itemStack.is(WWItemTags.PENGUIN_FOOD);
}

public boolean hasAttackTarget() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private boolean isHuntTarget(@NotNull LivingEntity attacker, LivingEntity target
}

private boolean isClose(LivingEntity attacker, @NotNull LivingEntity target) {
return target.distanceToSqr(attacker) <= 64.0D;
return target.distanceToSqr(attacker) <= 64D;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.frozenblock.wilderwild.registry.WWEntityTypes;
import net.frozenblock.wilderwild.registry.WWMemoryModuleTypes;
import net.frozenblock.wilderwild.registry.WWSensorTypes;
import net.frozenblock.wilderwild.tag.WWItemTags;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand All @@ -53,6 +54,7 @@
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;
import org.jetbrains.annotations.Nullable;

Expand All @@ -69,6 +71,8 @@ public class PenguinAi {
SensorType.NEAREST_ADULT,
SensorType.NEAREST_PLAYERS,
WWSensorTypes.PENGUIN_SPECIFIC_SENSOR,
WWSensorTypes.PENGUIN_TEMPTATIONS,
WWSensorTypes.PENGUIN_ATTACKABLES,
SensorType.IS_IN_WATER,
WWSensorTypes.LAND_POS_SENSOR
);
Expand Down Expand Up @@ -103,6 +107,7 @@ public class PenguinAi {
MemoryModuleType.IS_IN_WATER,
WWMemoryModuleTypes.IDLE_TIME,
WWMemoryModuleTypes.DIVE_TICKS,
MemoryModuleType.HAS_HUNTING_COOLDOWN,
WWMemoryModuleTypes.LAYING_DOWN,
WWMemoryModuleTypes.SEARCHING_FOR_WATER,
WWMemoryModuleTypes.WANTS_TO_LAUNCH,
Expand Down Expand Up @@ -302,10 +307,9 @@ private static float getSpeedModifierChasing(@Nullable LivingEntity livingEntity
return SPEED_MULTIPLIER_WHEN_ATTACKING;
}

/*
@NotNull
public static Ingredient getTemptations() {
return Penguin.TEMPTATION_ITEM;
return Ingredient.of(WWItemTags.PENGUIN_FOOD);
}
*/

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2023-2025 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.penguin;

import net.frozenblock.wilderwild.tag.WWEntityTags;
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 PenguinAttackablesSensor extends NearestVisibleLivingEntitySensor {

public PenguinAttackablesSensor() {
}

@Override
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(WWEntityTags.PENGUIN_HUNT_TARGETS);
}

private boolean isClose(LivingEntity attacker, @NotNull LivingEntity target) {
return target.distanceToSqr(attacker) <= 64D;
}

@Override
@NotNull
protected MemoryModuleType<LivingEntity> getMemory() {
return MemoryModuleType.NEAREST_ATTACKABLE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import net.frozenblock.wilderwild.entity.ai.firefly.FireflySpecificSensor;
import net.frozenblock.wilderwild.entity.ai.ostrich.OstrichAi;
import net.frozenblock.wilderwild.entity.ai.ostrich.OstrichSpecificSensor;
import net.frozenblock.wilderwild.entity.ai.penguin.PenguinAi;
import net.frozenblock.wilderwild.entity.ai.penguin.PenguinAttackablesSensor;
import net.frozenblock.wilderwild.entity.ai.penguin.PenguinLandPosSensor;
import net.frozenblock.wilderwild.entity.ai.penguin.PenguinSpecificSensor;
import net.frozenblock.wilderwild.entity.ai.penguin.PenguinWaterPosSensor;
Expand Down Expand Up @@ -58,6 +60,8 @@ public static void register() {
public static final SensorType<OstrichSpecificSensor> OSTRICH_SPECIFIC_SENSOR = register("ostrich_specific_sensor", OstrichSpecificSensor::new);
public static final SensorType<TemptingSensor> OSTRICH_TEMPTATIONS = register("ostrich_temptations", () -> new TemptingSensor(OstrichAi.getTemptations()));
public static final SensorType<PenguinSpecificSensor> PENGUIN_SPECIFIC_SENSOR = register("penguin_specific_sensor", PenguinSpecificSensor::new);
public static final SensorType<TemptingSensor> PENGUIN_TEMPTATIONS = register("penguin_temptations", () -> new TemptingSensor(PenguinAi.getTemptations()));
public static final SensorType<PenguinAttackablesSensor> PENGUIN_ATTACKABLES = register("penguin_attackables", PenguinAttackablesSensor::new);
public static final SensorType<PenguinLandPosSensor> LAND_POS_SENSOR = register("land_pos_sensor", PenguinLandPosSensor::new);
public static final SensorType<PenguinWaterPosSensor> WATER_POS_SENSOR = register("water_pos_sensor", PenguinWaterPosSensor::new);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public final class WWItemTags {
public static final TagKey<Item> PEARLESCENT_JELLYFISH_FOOD = bind("pearlescent_jellyfish_food");
public static final TagKey<Item> CRAB_FOOD = bind("crab_food");
public static final TagKey<Item> OSTRICH_FOOD = bind("ostrich_food");
public static final TagKey<Item> PENGUIN_FOOD = bind("penguin_food");
public static final TagKey<Item> MESOGLEA = bind("mesoglea");
public static final TagKey<Item> NEMATOCYSTS = bind("nematocysts");
public static final TagKey<Item> PEARLESCENT_NEMATOCYSTS = bind("pearlescent_nematocysts");
Expand Down

0 comments on commit bb2aa9f

Please sign in to comment.