| 1 | package net.minecraft.world.entity.monster.piglin;
|
| 2 |
|
| 3 | import java.util.List;
|
| 4 | import net.minecraft.core.BlockPos;
|
| 5 | import net.minecraft.core.component.DataComponents;
|
| 6 | import net.minecraft.network.syncher.EntityDataAccessor;
|
| 7 | import net.minecraft.network.syncher.EntityDataSerializers;
|
| 8 | import net.minecraft.network.syncher.SynchedEntityData;
|
| 9 | import net.minecraft.resources.Identifier;
|
| 10 | import net.minecraft.server.level.ServerLevel;
|
| 11 | import net.minecraft.sounds.SoundEvent;
|
| 12 | import net.minecraft.sounds.SoundEvents;
|
| 13 | import net.minecraft.tags.ItemTags;
|
| 14 | import net.minecraft.tags.TagKey;
|
| 15 | import net.minecraft.util.RandomSource;
|
| 16 | import net.minecraft.util.VisibleForDebug;
|
| 17 | import net.minecraft.util.profiling.Profiler;
|
| 18 | import net.minecraft.util.profiling.ProfilerFiller;
|
| 19 | import net.minecraft.world.DifficultyInstance;
|
| 20 | import net.minecraft.world.InteractionHand;
|
| 21 | import net.minecraft.world.InteractionResult;
|
| 22 | import net.minecraft.world.SimpleContainer;
|
| 23 | import net.minecraft.world.damagesource.DamageSource;
|
| 24 | import net.minecraft.world.entity.Entity;
|
| 25 | import net.minecraft.world.entity.EntityAttachment;
|
| 26 | import net.minecraft.world.entity.EntityAttachments;
|
| 27 | import net.minecraft.world.entity.EntityDimensions;
|
| 28 | import net.minecraft.world.entity.EntitySpawnReason;
|
| 29 | import net.minecraft.world.entity.EntityType;
|
| 30 | import net.minecraft.world.entity.EntityTypes;
|
| 31 | import net.minecraft.world.entity.EquipmentSlot;
|
| 32 | import net.minecraft.world.entity.LivingEntity;
|
| 33 | import net.minecraft.world.entity.Pose;
|
| 34 | import net.minecraft.world.entity.SlotAccess;
|
| 35 | import net.minecraft.world.entity.SpawnGroupData;
|
| 36 | import net.minecraft.world.entity.ai.Brain;
|
| 37 | import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
| 38 | import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
| 39 | import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
| 40 | import net.minecraft.world.entity.ai.attributes.Attributes;
|
| 41 | import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
| 42 | import net.minecraft.world.entity.ai.sensing.SensorType;
|
| 43 | import net.minecraft.world.entity.item.ItemEntity;
|
| 44 | import net.minecraft.world.entity.monster.CrossbowAttackMob;
|
| 45 | import net.minecraft.world.entity.monster.Monster;
|
| 46 | import net.minecraft.world.entity.npc.InventoryCarrier;
|
| 47 | import net.minecraft.world.entity.player.Player;
|
| 48 | import net.minecraft.world.item.CrossbowItem;
|
| 49 | import net.minecraft.world.item.Item;
|
| 50 | import net.minecraft.world.item.ItemStack;
|
| 51 | import net.minecraft.world.item.Items;
|
| 52 | import net.minecraft.world.item.enchantment.EnchantmentEffectComponents;
|
| 53 | import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
| 54 | import net.minecraft.world.level.Level;
|
| 55 | import net.minecraft.world.level.LevelAccessor;
|
| 56 | import net.minecraft.world.level.ServerLevelAccessor;
|
| 57 | import net.minecraft.world.level.block.Blocks;
|
| 58 | import net.minecraft.world.level.block.state.BlockState;
|
| 59 | import net.minecraft.world.level.gamerules.GameRules;
|
| 60 | import net.minecraft.world.level.storage.ValueInput;
|
| 61 | import net.minecraft.world.level.storage.ValueOutput;
|
| 62 | import org.jspecify.annotations.Nullable;
|
| 63 |
|
| 64 | public class Piglin extends AbstractPiglin implements CrossbowAttackMob, InventoryCarrier {
|
| 65 | private static final EntityDataAccessor<Boolean> DATA_BABY_ID = SynchedEntityData.defineId(Piglin.class, EntityDataSerializers.BOOLEAN);
|
| 66 | private static final EntityDataAccessor<Boolean> DATA_IS_CHARGING_CROSSBOW = SynchedEntityData.defineId(Piglin.class, EntityDataSerializers.BOOLEAN);
|
| 67 | private static final EntityDataAccessor<Boolean> DATA_IS_DANCING = SynchedEntityData.defineId(Piglin.class, EntityDataSerializers.BOOLEAN);
|
| 68 | private static final Identifier SPEED_MODIFIER_BABY_ID = Identifier.withDefaultNamespace("baby");
|
| 69 | private static final AttributeModifier SPEED_MODIFIER_BABY = new AttributeModifier(
|
| 70 | SPEED_MODIFIER_BABY_ID, 0.2F, AttributeModifier.Operation.ADD_MULTIPLIED_BASE
|
| 71 | );
|
| 72 | private static final int MAX_HEALTH = 16;
|
| 73 | private static final float MOVEMENT_SPEED_WHEN_FIGHTING = 0.35F;
|
| 74 | private static final int ATTACK_DAMAGE = 5;
|
| 75 | private static final float CHANCE_OF_WEARING_EACH_ARMOUR_ITEM = 0.1F;
|
| 76 | private static final int MAX_PASSENGERS_ON_ONE_HOGLIN = 3;
|
| 77 | private static final float PROBABILITY_OF_SPAWNING_AS_BABY = 0.2F;
|
| 78 | private static final EntityDimensions BABY_DIMENSIONS = EntityDimensions.scalable(0.49F, 0.98F)
|
| 79 | .withEyeHeight(0.78F)
|
| 80 | .withAttachments(EntityAttachments.builder().attach(EntityAttachment.VEHICLE, 0.0F, 0.1875F, 0.0F));
|
| 81 | private static final double PROBABILITY_OF_SPAWNING_WITH_CROSSBOW_INSTEAD_OF_SWORD = 0.5;
|
| 82 | private static final boolean DEFAULT_IS_BABY = false;
|
| 83 | private static final boolean DEFAULT_CANNOT_HUNT = false;
|
| 84 | private static final int INVENTORY_SLOT_OFFSET = 300;
|
| 85 | private static final int INVENTORY_SIZE = 8;
|
| 86 | private final SimpleContainer inventory = new SimpleContainer(8);
|
| 87 | private boolean cannotHunt = false;
|
| 88 | private static final Brain.Provider<Piglin> BRAIN_PROVIDER = Brain.provider(
|
| 89 | List.of(
|
| 90 | MemoryModuleType.UNIVERSAL_ANGER,
|
| 91 | MemoryModuleType.ATE_RECENTLY,
|
| 92 | MemoryModuleType.SPEAR_FLEEING_TIME,
|
| 93 | MemoryModuleType.SPEAR_FLEEING_POSITION,
|
| 94 | MemoryModuleType.SPEAR_CHARGE_POSITION,
|
| 95 | MemoryModuleType.SPEAR_ENGAGE_TIME
|
| 96 | ),
|
| 97 | List.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR),
|
| 98 | PiglinAi::getActivities
|
| 99 | );
|
| 100 |
|
| 101 | public Piglin(final EntityType<? extends AbstractPiglin> type, final Level level) {
|
| 102 | super(type, level);
|
| 103 | this.xpReward = 5;
|
| 104 | }
|
| 105 |
|
| 106 | @Override
|
| 107 | protected void addAdditionalSaveData(final ValueOutput output) {
|
| 108 | super.addAdditionalSaveData(output);
|
| 109 | output.putBoolean("IsBaby", this.isBaby());
|
| 110 | output.putBoolean("CannotHunt", this.cannotHunt);
|
| 111 | this.writeInventoryToTag(output);
|
| 112 | }
|
| 113 |
|
| 114 | @Override
|
| 115 | protected void readAdditionalSaveData(final ValueInput input) {
|
| 116 | super.readAdditionalSaveData(input);
|
| 117 | this.setBaby(input.getBooleanOr("IsBaby", false));
|
| 118 | this.setCannotHunt(input.getBooleanOr("CannotHunt", false));
|
| 119 | this.readInventoryFromTag(input);
|
| 120 | }
|
| 121 |
|
| 122 | @VisibleForDebug
|
| 123 | @Override
|
| 124 | public SimpleContainer getInventory() {
|
| 125 | return this.inventory;
|
| 126 | }
|
| 127 |
|
| 128 | @Override
|
| 129 | protected void dropCustomDeathLoot(final ServerLevel level, final DamageSource source, final boolean killedByPlayer) {
|
| 130 | super.dropCustomDeathLoot(level, source, killedByPlayer);
|
| 131 | this.inventory.removeAllItems().forEach(itemStack -> this.spawnAtLocation(level, itemStack));
|
| 132 | }
|
| 133 |
|
| 134 | protected ItemStack addToInventory(final ItemStack itemStack) {
|
| 135 | return this.inventory.addItem(itemStack);
|
| 136 | }
|
| 137 |
|
| 138 | protected boolean canAddToInventory(final ItemStack itemStack) {
|
| 139 | return this.inventory.canAddItem(itemStack);
|
| 140 | }
|
| 141 |
|
| 142 | @Override
|
| 143 | public @Nullable SlotAccess getSlot(final int slot) {
|
| 144 | int inventorySlot = slot - 300;
|
| 145 | return inventorySlot >= 0 && inventorySlot < this.inventory.getContainerSize() ? this.inventory.getSlot(inventorySlot) : super.getSlot(slot);
|
| 146 | }
|
| 147 |
|
| 148 | @Override
|
| 149 | protected void defineSynchedData(final SynchedEntityData.Builder entityData) {
|
| 150 | super.defineSynchedData(entityData);
|
| 151 | entityData.define(DATA_BABY_ID, false);
|
| 152 | entityData.define(DATA_IS_CHARGING_CROSSBOW, false);
|
| 153 | entityData.define(DATA_IS_DANCING, false);
|
| 154 | }
|
| 155 |
|
| 156 | @Override
|
| 157 | public void onSyncedDataUpdated(final EntityDataAccessor<?> accessor) {
|
| 158 | super.onSyncedDataUpdated(accessor);
|
| 159 | if (DATA_BABY_ID.equals(accessor)) {
|
| 160 | this.refreshDimensions();
|
| 161 | }
|
| 162 | }
|
| 163 |
|
| 164 | public static AttributeSupplier.Builder createAttributes() {
|
| 165 | return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 16.0).add(Attributes.MOVEMENT_SPEED, 0.35F).add(Attributes.ATTACK_DAMAGE, 5.0);
|
| 166 | }
|
| 167 |
|
| 168 | public static boolean checkPiglinSpawnRules(
|
| 169 | final EntityType<Piglin> type, final LevelAccessor level, final EntitySpawnReason spawnReason, final BlockPos pos, final RandomSource random
|
| 170 | ) {
|
| 171 | return !level.getBlockState(pos.below()).is(Blocks.NETHER_WART_BLOCK);
|
| 172 | }
|
| 173 |
|
| 174 | @Override
|
| 175 | public @Nullable SpawnGroupData finalizeSpawn(
|
| 176 | final ServerLevelAccessor level, final DifficultyInstance difficulty, final EntitySpawnReason spawnReason, final @Nullable SpawnGroupData groupData
|
| 177 | ) {
|
| 178 | RandomSource random = level.getRandom();
|
| 179 | if (spawnReason != EntitySpawnReason.STRUCTURE) {
|
| 180 | if (random.nextFloat() < 0.2F) {
|
| 181 | this.setBaby(true);
|
| 182 | } else if (this.isAdult()) {
|
| 183 | this.setItemSlot(EquipmentSlot.MAINHAND, this.createSpawnWeapon());
|
| 184 | }
|
| 185 | }
|
| 186 |
|
| 187 | PiglinAi.initMemories(this, level.getRandom());
|
| 188 | this.populateDefaultEquipmentSlots(random, difficulty);
|
| 189 | this.populateDefaultEquipmentEnchantments(level, random, difficulty);
|
| 190 | return super.finalizeSpawn(level, difficulty, spawnReason, groupData);
|
| 191 | }
|
| 192 |
|
| 193 | @Override
|
| 194 | protected void populateDefaultEquipmentSlots(final RandomSource random, final DifficultyInstance difficulty) {
|
| 195 | if (this.isAdult()) {
|
| 196 | this.maybeWearArmor(EquipmentSlot.HEAD, new ItemStack(Items.GOLDEN_HELMET), random);
|
| 197 | this.maybeWearArmor(EquipmentSlot.CHEST, new ItemStack(Items.GOLDEN_CHESTPLATE), random);
|
| 198 | this.maybeWearArmor(EquipmentSlot.LEGS, new ItemStack(Items.GOLDEN_LEGGINGS), random);
|
| 199 | this.maybeWearArmor(EquipmentSlot.FEET, new ItemStack(Items.GOLDEN_BOOTS), random);
|
| 200 | }
|
| 201 | }
|
| 202 |
|
| 203 | private void maybeWearArmor(final EquipmentSlot slot, final ItemStack itemStack, final RandomSource random) {
|
| 204 | if (random.nextFloat() < 0.1F) {
|
| 205 | this.setItemSlot(slot, itemStack);
|
| 206 | }
|
| 207 | }
|
| 208 |
|
| 209 | @Override
|
| 210 | protected Brain<Piglin> makeBrain(final Brain.Packed packedBrain) {
|
| 211 | return BRAIN_PROVIDER.makeBrain(this, packedBrain);
|
| 212 | }
|
| 213 |
|
| 214 | @Override
|
| 215 | public Brain<Piglin> getBrain() {
|
| 216 | return super.getBrain();
|
| 217 | }
|
| 218 |
|
| 219 | @Override
|
| 220 | public InteractionResult mobInteract(final Player player, final InteractionHand hand) {
|
| 221 | InteractionResult interactionResult = super.mobInteract(player, hand);
|
| 222 | if (interactionResult.consumesAction()) {
|
| 223 | return interactionResult;
|
| 224 | } else if (this.level() instanceof ServerLevel level) {
|
| 225 | return PiglinAi.mobInteract(level, this, player, hand);
|
| 226 | } else {
|
| 227 | boolean canAdmire = PiglinAi.canAdmire(this, player.getItemInHand(hand)) && this.getArmPose() != PiglinArmPose.ADMIRING_ITEM;
|
| 228 | return canAdmire ? InteractionResult.SUCCESS : InteractionResult.PASS;
|
| 229 | }
|
| 230 | }
|
| 231 |
|
| 232 | @Override
|
| 233 | public EntityDimensions getDefaultDimensions(final Pose pose) {
|
| 234 | return this.isBaby() ? BABY_DIMENSIONS : super.getDefaultDimensions(pose);
|
| 235 | }
|
| 236 |
|
| 237 | @Override
|
| 238 | public void setBaby(final boolean baby) {
|
| 239 | this.getEntityData().set(DATA_BABY_ID, baby);
|
| 240 | if (!this.level().isClientSide()) {
|
| 241 | AttributeInstance speed = this.getAttribute(Attributes.MOVEMENT_SPEED);
|
| 242 | speed.removeModifier(SPEED_MODIFIER_BABY.id());
|
| 243 | if (baby) {
|
| 244 | speed.addTransientModifier(SPEED_MODIFIER_BABY);
|
| 245 | }
|
| 246 | }
|
| 247 | }
|
| 248 |
|
| 249 | @Override
|
| 250 | public boolean isBaby() {
|
| 251 | return this.getEntityData().get(DATA_BABY_ID);
|
| 252 | }
|
| 253 |
|
| 254 | private void setCannotHunt(final boolean cannotHunt) {
|
| 255 | this.cannotHunt = cannotHunt;
|
| 256 | }
|
| 257 |
|
| 258 | @Override
|
| 259 | protected boolean canHunt() {
|
| 260 | return !this.cannotHunt;
|
| 261 | }
|
| 262 |
|
| 263 | @Override
|
| 264 | protected void customServerAiStep(final ServerLevel level) {
|
| 265 | ProfilerFiller profiler = Profiler.get();
|
| 266 | profiler.push("piglinBrain");
|
| 267 | this.getBrain().tick(level, this);
|
| 268 | profiler.pop();
|
| 269 | PiglinAi.updateActivity(this);
|
| 270 | super.customServerAiStep(level);
|
| 271 | }
|
| 272 |
|
| 273 | @Override
|
| 274 | protected int getBaseExperienceReward(final ServerLevel level) {
|
| 275 | return this.xpReward;
|
| 276 | }
|
| 277 |
|
| 278 | @Override
|
| 279 | protected void finishConversion(final ServerLevel level) {
|
| 280 | PiglinAi.cancelAdmiring(level, this);
|
| 281 | this.inventory.removeAllItems().forEach(itemStack -> this.spawnAtLocation(level, itemStack));
|
| 282 | super.finishConversion(level);
|
| 283 | }
|
| 284 |
|
| 285 | private ItemStack createSpawnWeapon() {
|
| 286 | return this.random.nextFloat() < 0.5 ? new ItemStack(Items.CROSSBOW) : new ItemStack(this.random.nextInt(10) == 0 ? Items.GOLDEN_SPEAR : Items.GOLDEN_SWORD);
|
| 287 | }
|
| 288 |
|
| 289 | @Override
|
| 290 | public @Nullable TagKey<Item> getPreferredWeaponType() {
|
| 291 | return this.isBaby() ? null : ItemTags.PIGLIN_PREFERRED_WEAPONS;
|
| 292 | }
|
| 293 |
|
| 294 | private boolean isChargingCrossbow() {
|
| 295 | return this.entityData.get(DATA_IS_CHARGING_CROSSBOW);
|
| 296 | }
|
| 297 |
|
| 298 | @Override
|
| 299 | public void setChargingCrossbow(final boolean isCharging) {
|
| 300 | this.entityData.set(DATA_IS_CHARGING_CROSSBOW, isCharging);
|
| 301 | }
|
| 302 |
|
| 303 | @Override
|
| 304 | public void onCrossbowAttackPerformed() {
|
| 305 | this.noActionTime = 0;
|
| 306 | }
|
| 307 |
|
| 308 | @Override
|
| 309 | public PiglinArmPose getArmPose() {
|
| 310 | if (this.isDancing()) {
|
| 311 | return PiglinArmPose.DANCING;
|
| 312 | } else if (PiglinAi.isLovedItem(this.getOffhandItem())) {
|
| 313 | return PiglinArmPose.ADMIRING_ITEM;
|
| 314 | } else if (this.isAggressive() && this.isHoldingMeleeWeapon()) {
|
| 315 | return PiglinArmPose.ATTACKING_WITH_MELEE_WEAPON;
|
| 316 | } else if (this.isChargingCrossbow()) {
|
| 317 | return PiglinArmPose.CROSSBOW_CHARGE;
|
| 318 | } else {
|
| 319 | return this.isHolding(Items.CROSSBOW) && CrossbowItem.isCharged(this.getWeaponItem()) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT;
|
| 320 | }
|
| 321 | }
|
| 322 |
|
| 323 | public boolean isDancing() {
|
| 324 | return this.entityData.get(DATA_IS_DANCING);
|
| 325 | }
|
| 326 |
|
| 327 | public void setDancing(final boolean dancing) {
|
| 328 | this.entityData.set(DATA_IS_DANCING, dancing);
|
| 329 | }
|
| 330 |
|
| 331 | @Override
|
| 332 | public boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) {
|
| 333 | boolean wasHurt = super.hurtServer(level, source, damage);
|
| 334 | if (wasHurt && source.getEntity() instanceof LivingEntity sourceEntity) {
|
| 335 | PiglinAi.wasHurtBy(level, this, sourceEntity);
|
| 336 | }
|
| 337 |
|
| 338 | return wasHurt;
|
| 339 | }
|
| 340 |
|
| 341 | @Override
|
| 342 | public void performRangedAttack(final LivingEntity target, final float power) {
|
| 343 | this.performCrossbowAttack(this, 1.6F);
|
| 344 | }
|
| 345 |
|
| 346 | @Override
|
| 347 | public boolean canUseNonMeleeWeapon(final ItemStack item) {
|
| 348 | return item.getItem() == Items.CROSSBOW || item.has(DataComponents.KINETIC_WEAPON);
|
| 349 | }
|
| 350 |
|
| 351 | protected void holdInMainHand(final ItemStack itemStack) {
|
| 352 | this.setItemSlotAndDropWhenKilled(EquipmentSlot.MAINHAND, itemStack);
|
| 353 | this.setPersistenceRequired();
|
| 354 | }
|
| 355 |
|
| 356 | protected void holdInOffHand(final ItemStack itemStack) {
|
| 357 | this.setItemSlotAndDropWhenKilled(EquipmentSlot.OFFHAND, itemStack);
|
| 358 | if (!itemStack.is(PiglinAi.BARTERING_ITEM)) {
|
| 359 | this.setPersistenceRequired();
|
| 360 | }
|
| 361 | }
|
| 362 |
|
| 363 | @Override
|
| 364 | public boolean wantsToPickUp(final ServerLevel level, final ItemStack itemStack) {
|
| 365 | return level.getGameRules().get(GameRules.MOB_GRIEFING) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, itemStack);
|
| 366 | }
|
| 367 |
|
| 368 | protected boolean canReplaceCurrentItem(final ItemStack newItemStack) {
|
| 369 | EquipmentSlot slot = this.getEquipmentSlotForItem(newItemStack);
|
| 370 | ItemStack currentItemStackInCorrespondingSlot = this.getItemBySlot(slot);
|
| 371 | return this.canReplaceCurrentItem(newItemStack, currentItemStackInCorrespondingSlot, slot);
|
| 372 | }
|
| 373 |
|
| 374 | @Override
|
| 375 | protected boolean canReplaceCurrentItem(final ItemStack newItemStack, final ItemStack currentItemStack, final EquipmentSlot slot) {
|
| 376 | if (EnchantmentHelper.has(currentItemStack, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE)) {
|
| 377 | return false;
|
| 378 | } else {
|
| 379 | TagKey<Item> preferredWeaponType = this.getPreferredWeaponType();
|
| 380 | boolean newItemWanted = PiglinAi.isLovedItem(newItemStack) || preferredWeaponType != null && newItemStack.is(preferredWeaponType);
|
| 381 | boolean currentItemWanted = PiglinAi.isLovedItem(currentItemStack) || preferredWeaponType != null && currentItemStack.is(preferredWeaponType);
|
| 382 | if (newItemWanted && !currentItemWanted) {
|
| 383 | return true;
|
| 384 | } else {
|
| 385 | return !newItemWanted && currentItemWanted ? false : super.canReplaceCurrentItem(newItemStack, currentItemStack, slot);
|
| 386 | }
|
| 387 | }
|
| 388 | }
|
| 389 |
|
| 390 | @Override
|
| 391 | protected void pickUpItem(final ServerLevel level, final ItemEntity entity) {
|
| 392 | this.onItemPickup(entity);
|
| 393 | PiglinAi.pickUpItem(level, this, entity);
|
| 394 | }
|
| 395 |
|
| 396 | @Override
|
| 397 | public boolean startRiding(Entity entityToRide, final boolean force, final boolean sendEventAndTriggers) {
|
| 398 | if (this.isBaby() && entityToRide.is(EntityTypes.HOGLIN)) {
|
| 399 | entityToRide = this.getTopPassenger(entityToRide, 3);
|
| 400 | }
|
| 401 |
|
| 402 | return super.startRiding(entityToRide, force, sendEventAndTriggers);
|
| 403 | }
|
| 404 |
|
| 405 | private Entity getTopPassenger(final Entity vehicle, final int counter) {
|
| 406 | List<Entity> passengers = vehicle.getPassengers();
|
| 407 | return counter != 1 && !passengers.isEmpty() ? this.getTopPassenger(passengers.getFirst(), counter - 1) : vehicle;
|
| 408 | }
|
| 409 |
|
| 410 | @Override
|
| 411 | protected @Nullable SoundEvent getAmbientSound() {
|
| 412 | return this.level().isClientSide() ? null : PiglinAi.getSoundForCurrentActivity(this).orElse(null);
|
| 413 | }
|
| 414 |
|
| 415 | @Override
|
| 416 | protected SoundEvent getHurtSound(final DamageSource source) {
|
| 417 | return SoundEvents.PIGLIN_HURT;
|
| 418 | }
|
| 419 |
|
| 420 | @Override
|
| 421 | protected SoundEvent getDeathSound() {
|
| 422 | return SoundEvents.PIGLIN_DEATH;
|
| 423 | }
|
| 424 |
|
| 425 | @Override
|
| 426 | protected void playStepSound(final BlockPos pos, final BlockState blockState) {
|
| 427 | this.playSound(SoundEvents.PIGLIN_STEP, 0.15F, 1.0F);
|
| 428 | }
|
| 429 |
|
| 430 | @Override
|
| 431 | protected void playConvertedSound() {
|
| 432 | this.makeSound(SoundEvents.PIGLIN_CONVERTED_TO_ZOMBIFIED);
|
| 433 | }
|
| 434 | }
|
| 435 |
|