Strider .java

net.minecraft.world.entity.monster.Strider (class): members: SUFFOCATE_STEERING_MODIFIER, SUFFOCATING_MODIFIER_ID, checkStriderSpawnRules, setSuffocating.

net.minecraft.world.entity.monsterclass532 linescommonextends Animal19.1 KB

Implements

API Surface (42)

boolean checkStriderSpawnRules(final EntityType<Strider> ignoredType, final LevelAccessor level, final EntitySpawnReason ignoredSpawnType, final BlockPos pos, final RandomSource ignoredRandom)
void onSyncedDataUpdated(final EntityDataAccessor<?> accessor)
void defineSynchedData(final SynchedEntityData.Builder entityData)
boolean canUseSlot(final EquipmentSlot slot)
boolean canDispenserEquipIntoSlot(final EquipmentSlot slot)
Holder<SoundEvent> getEquipSound(final EquipmentSlot slot, final ItemStack stack, final Equippable equippable)
void registerGoals()
void setSuffocating(final boolean flag)
boolean isSuffocating()
boolean canStandOnFluid(final FluidState fluid)
EntityDimensions getDefaultDimensions(final Pose pose)
Vec3 getPassengerAttachmentPoint(final Entity passenger, final EntityDimensions dimensions, final float scale)
boolean checkSpawnObstruction(final LevelReader level)
Vec3 getDismountLocationForPassenger(final LivingEntity passenger)
void tickRidden(final Player controller, final Vec3 riddenInput)
Vec3 getRiddenInput(final Player controller, final Vec3 selfInput)
float getRiddenSpeed(final Player controller)
float nextStep()
void playStepSound(final BlockPos pos, final BlockState blockState)
boolean boost()
void checkFallDamage(final double ya, final boolean onGround, final BlockState onState, final BlockPos pos)
void tick()
boolean shouldPassengersInheritMalus()
VoxelShape getLiquidCollisionShape()
AttributeSupplier.Builder createAttributes()
SoundEvent getHurtSound(final DamageSource source)
SoundEvent getDeathSound()
boolean canAddPassenger(final Entity passenger)
boolean isSensitiveToWater()
boolean isOnFire()
PathNavigation createNavigation(final Level level)
float getWalkTargetValue(final BlockPos pos, final LevelReader level)
boolean isFood(final ItemStack itemStack)
InteractionResult mobInteract(final Player player, final InteractionHand hand)
Vec3 getLeashOffset()
BlockPos getMoveToTarget()
boolean canContinueToUse()
boolean canUse()
boolean shouldRecalculatePath()
boolean isValidTarget(final LevelReader level, final BlockPos pos)
PathFinder createPathFinder(final int maxVisitedNodes)
boolean isStableDestination(final BlockPos pos)

Fields & Constants (15)

SUFFOCATING_MODIFIER_ID
SUFFOCATING_MODIFIER
SUFFOCATE_STEERING_MODIFIER
STEERING_MODIFIER
DATA_BOOST_TIME
DATA_SUFFOCATING
BABY_DIMENSIONS
steering
temptGoal
ignoredType
level
ignoredSpawnType
pos
spawnReason
jockey

String literals (1)

"suffocating"

Code Graph: Dependencies (73)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

Strider.java532 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.monster;
2
3
import com.google.common.collect.Sets;
4
import java.util.Set;
5
import net.minecraft.core.BlockPos;
6
import net.minecraft.core.Direction;
7
import net.minecraft.core.Holder;
8
import net.minecraft.network.syncher.EntityDataAccessor;
9
import net.minecraft.network.syncher.EntityDataSerializers;
10
import net.minecraft.network.syncher.SynchedEntityData;
11
import net.minecraft.resources.Identifier;
12
import net.minecraft.server.level.ServerLevel;
13
import net.minecraft.sounds.SoundEvent;
14
import net.minecraft.sounds.SoundEvents;
15
import net.minecraft.tags.BlockTags;
16
import net.minecraft.tags.FluidTags;
17
import net.minecraft.tags.ItemTags;
18
import net.minecraft.util.Mth;
19
import net.minecraft.util.RandomSource;
20
import net.minecraft.world.DifficultyInstance;
21
import net.minecraft.world.InteractionHand;
22
import net.minecraft.world.InteractionResult;
23
import net.minecraft.world.damagesource.DamageSource;
24
import net.minecraft.world.entity.AgeableMob;
25
import net.minecraft.world.entity.Entity;
26
import net.minecraft.world.entity.EntityAttachment;
27
import net.minecraft.world.entity.EntityAttachments;
28
import net.minecraft.world.entity.EntityDimensions;
29
import net.minecraft.world.entity.EntitySpawnReason;
30
import net.minecraft.world.entity.EntityType;
31
import net.minecraft.world.entity.EntityTypes;
32
import net.minecraft.world.entity.EquipmentSlot;
33
import net.minecraft.world.entity.ItemBasedSteering;
34
import net.minecraft.world.entity.ItemSteerable;
35
import net.minecraft.world.entity.LivingEntity;
36
import net.minecraft.world.entity.Mob;
37
import net.minecraft.world.entity.Pose;
38
import net.minecraft.world.entity.SpawnGroupData;
39
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
40
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
41
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
42
import net.minecraft.world.entity.ai.attributes.Attributes;
43
import net.minecraft.world.entity.ai.goal.BreedGoal;
44
import net.minecraft.world.entity.ai.goal.FollowParentGoal;
45
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
46
import net.minecraft.world.entity.ai.goal.MoveToBlockGoal;
47
import net.minecraft.world.entity.ai.goal.PanicGoal;
48
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
49
import net.minecraft.world.entity.ai.goal.RandomStrollGoal;
50
import net.minecraft.world.entity.ai.goal.TemptGoal;
51
import net.minecraft.world.entity.ai.navigation.GroundPathNavigation;
52
import net.minecraft.world.entity.ai.navigation.PathNavigation;
53
import net.minecraft.world.entity.animal.Animal;
54
import net.minecraft.world.entity.monster.zombie.Zombie;
55
import net.minecraft.world.entity.player.Player;
56
import net.minecraft.world.entity.vehicle.DismountHelper;
57
import net.minecraft.world.item.ItemStack;
58
import net.minecraft.world.item.Items;
59
import net.minecraft.world.item.equipment.Equippable;
60
import net.minecraft.world.level.Level;
61
import net.minecraft.world.level.LevelAccessor;
62
import net.minecraft.world.level.LevelReader;
63
import net.minecraft.world.level.ServerLevelAccessor;
64
import net.minecraft.world.level.block.Block;
65
import net.minecraft.world.level.block.Blocks;
66
import net.minecraft.world.level.block.state.BlockState;
67
import net.minecraft.world.level.material.FluidState;
68
import net.minecraft.world.level.pathfinder.PathComputationType;
69
import net.minecraft.world.level.pathfinder.PathFinder;
70
import net.minecraft.world.level.pathfinder.PathType;
71
import net.minecraft.world.level.pathfinder.WalkNodeEvaluator;
72
import net.minecraft.world.phys.AABB;
73
import net.minecraft.world.phys.Vec3;
74
import net.minecraft.world.phys.shapes.CollisionContext;
75
import net.minecraft.world.phys.shapes.VoxelShape;
76
import org.jspecify.annotations.Nullable;
77
78
public class Strider extends Animal implements ItemSteerable {
79
	private static final Identifier SUFFOCATING_MODIFIER_ID = Identifier.withDefaultNamespace("suffocating");
80
	private static final AttributeModifier SUFFOCATING_MODIFIER = new AttributeModifier(
81
		SUFFOCATING_MODIFIER_ID, -0.34F, AttributeModifier.Operation.ADD_MULTIPLIED_BASE
82
	);
83
	private static final float SUFFOCATE_STEERING_MODIFIER = 0.35F;
84
	private static final float STEERING_MODIFIER = 0.55F;
85
	private static final EntityDataAccessor<Integer> DATA_BOOST_TIME = SynchedEntityData.defineId(Strider.class, EntityDataSerializers.INT);
86
	private static final EntityDataAccessor<Boolean> DATA_SUFFOCATING = SynchedEntityData.defineId(Strider.class, EntityDataSerializers.BOOLEAN);
87
	private static final EntityDimensions BABY_DIMENSIONS = EntityDimensions.scalable(0.45F, 0.85F)
88
		.withEyeHeight(0.4375F)
89
		.withAttachments(EntityAttachments.builder().attach(EntityAttachment.PASSENGER, 0.0F, 0.65625F, 0.0F));
90
	private final ItemBasedSteering steering = new ItemBasedSteering(this.entityData, DATA_BOOST_TIME);
91
	private @Nullable TemptGoal temptGoal;
92
93
	public Strider(final EntityType<? extends Strider> strider, final Level level) {
94
		super(strider, level);
95
		this.blocksBuilding = true;
96
		this.setPathfindingMalus(PathType.WATER, -1.0F);
97
		this.setPathfindingMalus(PathType.LAVA, 0.0F);
98
		this.setPathfindingMalus(PathType.FIRE_IN_NEIGHBOR, 0.0F);
99
		this.setPathfindingMalus(PathType.FIRE, 0.0F);
100
	}
101
102
	public static boolean checkStriderSpawnRules(
103
		final EntityType<Strider> ignoredType,
104
		final LevelAccessor level,
105
		final EntitySpawnReason ignoredSpawnType,
106
		final BlockPos pos,
107
		final RandomSource ignoredRandom
108
	) {
109
		BlockPos.MutableBlockPos checkPos = pos.mutable();
110
111
		do {
112
			checkPos.move(Direction.UP);
113
		} while (level.getFluidState(checkPos).is(FluidTags.LAVA));
114
115
		return level.getBlockState(checkPos).isAir();
116
	}
117
118
	@Override
119
	public void onSyncedDataUpdated(final EntityDataAccessor<?> accessor) {
120
		if (DATA_BOOST_TIME.equals(accessor) && this.level().isClientSide()) {
121
			this.steering.onSynced();
122
		}
123
124
		super.onSyncedDataUpdated(accessor);
125
	}
126
127
	@Override
128
	protected void defineSynchedData(final SynchedEntityData.Builder entityData) {
129
		super.defineSynchedData(entityData);
130
		entityData.define(DATA_BOOST_TIME, 0);
131
		entityData.define(DATA_SUFFOCATING, false);
132
	}
133
134
	@Override
135
	public boolean canUseSlot(final EquipmentSlot slot) {
136
		return slot != EquipmentSlot.SADDLE ? super.canUseSlot(slot) : this.isAlive() && !this.isBaby();
137
	}
138
139
	@Override
140
	protected boolean canDispenserEquipIntoSlot(final EquipmentSlot slot) {
141
		return slot == EquipmentSlot.SADDLE || super.canDispenserEquipIntoSlot(slot);
142
	}
143
144
	@Override
145
	protected Holder<SoundEvent> getEquipSound(final EquipmentSlot slot, final ItemStack stack, final Equippable equippable) {
146
		return slot == EquipmentSlot.SADDLE ? SoundEvents.STRIDER_SADDLE : super.getEquipSound(slot, stack, equippable);
147
	}
148
149
	@Override
150
	protected void registerGoals() {
151
		this.goalSelector.addGoal(1, new PanicGoal(this, 1.65));
152
		this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
153
		this.temptGoal = new TemptGoal(this, 1.4, i -> i.is(ItemTags.STRIDER_TEMPT_ITEMS), false);
154
		this.goalSelector.addGoal(3, this.temptGoal);
155
		this.goalSelector.addGoal(4, new Strider.StriderGoToLavaGoal(this, 1.0));
156
		this.goalSelector.addGoal(5, new FollowParentGoal(this, 1.0));
157
		this.goalSelector.addGoal(7, new RandomStrollGoal(this, 1.0, 60));
158
		this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F));
159
		this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
160
		this.goalSelector.addGoal(9, new LookAtPlayerGoal(this, Strider.class, 8.0F));
161
	}
162
163
	public void setSuffocating(final boolean flag) {
164
		this.entityData.set(DATA_SUFFOCATING, flag);
165
		AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED);
166
		if (attribute != null) {
167
			if (flag) {
168
				attribute.addOrUpdateTransientModifier(SUFFOCATING_MODIFIER);
169
			} else {
170
				attribute.removeModifier(SUFFOCATING_MODIFIER_ID);
171
			}
172
		}
173
	}
174
175
	public boolean isSuffocating() {
176
		return this.entityData.get(DATA_SUFFOCATING);
177
	}
178
179
	@Override
180
	public boolean canStandOnFluid(final FluidState fluid) {
181
		return fluid.is(FluidTags.LAVA);
182
	}
183
184
	@Override
185
	public EntityDimensions getDefaultDimensions(final Pose pose) {
186
		return this.isBaby() ? BABY_DIMENSIONS : super.getDefaultDimensions(pose);
187
	}
188
189
	@Override
190
	protected Vec3 getPassengerAttachmentPoint(final Entity passenger, final EntityDimensions dimensions, final float scale) {
191
		if (!this.level().isClientSide()) {
192
			return super.getPassengerAttachmentPoint(passenger, dimensions, scale);
193
		}
194
195
		float animSpeed = Math.min(0.25F, this.walkAnimation.speed());
196
		float animPos = this.walkAnimation.position();
197
		float offset = 0.12F * Mth.cos(animPos * 1.5F) * 2.0F * animSpeed;
198
		return super.getPassengerAttachmentPoint(passenger, dimensions, scale).add(0.0, offset * scale, 0.0);
199
	}
200
201
	@Override
202
	public boolean checkSpawnObstruction(final LevelReader level) {
203
		return level.isUnobstructed(this);
204
	}
205
206
	@Override
207
	public @Nullable LivingEntity getControllingPassenger() {
208
		return this.isSaddled() && this.getFirstPassenger() instanceof Player player && player.isHolding(Items.WARPED_FUNGUS_ON_A_STICK)
209
			? player
210
			: super.getControllingPassenger();
211
	}
212
213
	@Override
214
	public Vec3 getDismountLocationForPassenger(final LivingEntity passenger) {
215
		Vec3[] directions = new Vec3[]{
216
			getCollisionHorizontalEscapeVector(this.getBbWidth(), passenger.getBbWidth(), passenger.getYRot()),
217
			getCollisionHorizontalEscapeVector(this.getBbWidth(), passenger.getBbWidth(), passenger.getYRot() - 22.5F),
218
			getCollisionHorizontalEscapeVector(this.getBbWidth(), passenger.getBbWidth(), passenger.getYRot() + 22.5F),
219
			getCollisionHorizontalEscapeVector(this.getBbWidth(), passenger.getBbWidth(), passenger.getYRot() - 45.0F),
220
			getCollisionHorizontalEscapeVector(this.getBbWidth(), passenger.getBbWidth(), passenger.getYRot() + 45.0F)
221
		};
222
		Set<BlockPos> targetBlockPositions = Sets.newLinkedHashSet();
223
		double colliderTop = this.getBoundingBox().maxY;
224
		double colliderBottom = this.getBoundingBox().minY - 0.5;
225
		BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos();
226
227
		for (Vec3 direction : directions) {
228
			blockPos.set(this.getX() + direction.x, colliderTop, this.getZ() + direction.z);
229
230
			for (double y = colliderTop; y > colliderBottom; y--) {
231
				targetBlockPositions.add(blockPos.immutable());
232
				blockPos.move(Direction.DOWN);
233
			}
234
		}
235
236
		for (BlockPos targetBlockPos : targetBlockPositions) {
237
			if (!this.level().getFluidState(targetBlockPos).is(FluidTags.LAVA)) {
238
				double blockFloorHeight = this.level().getBlockFloorHeight(targetBlockPos);
239
				if (DismountHelper.isBlockFloorValid(blockFloorHeight)) {
240
					Vec3 location = Vec3.upFromBottomCenterOf(targetBlockPos, blockFloorHeight);
241
242
					for (Pose dismountPose : passenger.getDismountPoses()) {
243
						AABB poseCollisionBox = passenger.getLocalBoundsForPose(dismountPose);
244
						if (DismountHelper.canDismountTo(this.level(), passenger, poseCollisionBox.move(location))) {
245
							passenger.setPose(dismountPose);
246
							return location;
247
						}
248
					}
249
				}
250
			}
251
		}
252
253
		return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
254
	}
255
256
	@Override
257
	protected void tickRidden(final Player controller, final Vec3 riddenInput) {
258
		this.setRot(controller.getYRot(), controller.getXRot() * 0.5F);
259
		this.yRotO = this.yBodyRot = this.yHeadRot = this.getYRot();
260
		this.steering.tickBoost();
261
		super.tickRidden(controller, riddenInput);
262
	}
263
264
	@Override
265
	protected Vec3 getRiddenInput(final Player controller, final Vec3 selfInput) {
266
		return new Vec3(0.0, 0.0, 1.0);
267
	}
268
269
	@Override
270
	protected float getRiddenSpeed(final Player controller) {
271
		return (float)(this.getAttributeValue(Attributes.MOVEMENT_SPEED) * (this.isSuffocating() ? 0.35F : 0.55F) * this.steering.boostFactor());
272
	}
273
274
	@Override
275
	protected float nextStep() {
276
		return this.moveDist + 0.6F;
277
	}
278
279
	@Override
280
	protected void playStepSound(final BlockPos pos, final BlockState blockState) {
281
		this.playSound(this.isInLava() ? SoundEvents.STRIDER_STEP_LAVA : SoundEvents.STRIDER_STEP, 1.0F, 1.0F);
282
	}
283
284
	@Override
285
	public boolean boost() {
286
		return this.steering.boost(this.getRandom());
287
	}
288
289
	@Override
290
	protected void checkFallDamage(final double ya, final boolean onGround, final BlockState onState, final BlockPos pos) {
291
		if (this.isInLava()) {
292
			this.resetFallDistance();
293
		} else {
294
			super.checkFallDamage(ya, onGround, onState, pos);
295
		}
296
	}
297
298
	@Override
299
	public void tick() {
300
		if (this.isBeingTempted() && this.random.nextInt(140) == 0) {
301
			this.makeSound(SoundEvents.STRIDER_HAPPY);
302
		} else if (this.isPanicking() && this.random.nextInt(60) == 0) {
303
			this.makeSound(SoundEvents.STRIDER_RETREAT);
304
		}
305
306
		if (!this.isNoAi()) {
307
			BlockState stateInside = this.level().getBlockState(this.blockPosition());
308
			BlockState stateOn = this.getBlockStateOnLegacy();
309
			boolean inWarmBlocks = stateInside.is(BlockTags.STRIDER_WARM_BLOCKS)
310
				|| stateOn.is(BlockTags.STRIDER_WARM_BLOCKS)
311
				|| this.getFluidHeight(FluidTags.LAVA) > 0.0;
312
			boolean onWarmStrider = this.getVehicle() instanceof Strider strider && !strider.isSuffocating();
313
			this.setSuffocating(!inWarmBlocks && !onWarmStrider);
314
		}
315
316
		super.tick();
317
		this.floatStrider();
318
	}
319
320
	private boolean isBeingTempted() {
321
		return this.temptGoal != null && this.temptGoal.isRunning();
322
	}
323
324
	@Override
325
	protected boolean shouldPassengersInheritMalus() {
326
		return true;
327
	}
328
329
	private void floatStrider() {
330
		if (this.isInLava()) {
331
			CollisionContext context = CollisionContext.of(this);
332
			if (context.isAbove(this.getLiquidCollisionShape(), this.blockPosition(), true)
333
				&& !this.level().getFluidState(this.blockPosition().above()).is(FluidTags.LAVA)) {
334
				this.setOnGround(true);
335
			} else {
336
				this.setDeltaMovement(this.getDeltaMovement().scale(0.5).add(0.0, 0.05, 0.0));
337
			}
338
		}
339
	}
340
341
	@Override
342
	public VoxelShape getLiquidCollisionShape() {
343
		return Block.column(16.0, 0.0, 8.0);
344
	}
345
346
	public static AttributeSupplier.Builder createAttributes() {
347
		return Animal.createAnimalAttributes().add(Attributes.MOVEMENT_SPEED, 0.175F);
348
	}
349
350
	@Override
351
	protected @Nullable SoundEvent getAmbientSound() {
352
		return !this.isPanicking() && !this.isBeingTempted() ? SoundEvents.STRIDER_AMBIENT : null;
353
	}
354
355
	@Override
356
	protected SoundEvent getHurtSound(final DamageSource source) {
357
		return SoundEvents.STRIDER_HURT;
358
	}
359
360
	@Override
361
	protected SoundEvent getDeathSound() {
362
		return SoundEvents.STRIDER_DEATH;
363
	}
364
365
	@Override
366
	protected boolean canAddPassenger(final Entity passenger) {
367
		return !this.isVehicle() && !this.isEyeInFluid(FluidTags.LAVA);
368
	}
369
370
	@Override
371
	public boolean isSensitiveToWater() {
372
		return true;
373
	}
374
375
	@Override
376
	public boolean isOnFire() {
377
		return false;
378
	}
379
380
	@Override
381
	protected PathNavigation createNavigation(final Level level) {
382
		return new Strider.StriderPathNavigation(this, level);
383
	}
384
385
	@Override
386
	public float getWalkTargetValue(final BlockPos pos, final LevelReader level) {
387
		if (level.getBlockState(pos).getFluidState().is(FluidTags.LAVA)) {
388
			return 10.0F;
389
		} else {
390
			return this.isInLava() ? Float.NEGATIVE_INFINITY : 0.0F;
391
		}
392
	}
393
394
	public @Nullable Strider getBreedOffspring(final ServerLevel level, final AgeableMob partner) {
395
		return EntityTypes.STRIDER.create(level, EntitySpawnReason.BREEDING);
396
	}
397
398
	@Override
399
	public boolean isFood(final ItemStack itemStack) {
400
		return itemStack.is(ItemTags.STRIDER_FOOD);
401
	}
402
403
	@Override
404
	public InteractionResult mobInteract(final Player player, final InteractionHand hand) {
405
		boolean hasFood = this.isFood(player.getItemInHand(hand));
406
		if (!hasFood && this.isSaddled() && !this.isVehicle() && !player.isSecondaryUseActive()) {
407
			if (!this.level().isClientSide()) {
408
				player.startRiding(this);
409
			}
410
411
			return InteractionResult.SUCCESS;
412
		} else {
413
			InteractionResult interactionResult = super.mobInteract(player, hand);
414
			if (!interactionResult.consumesAction()) {
415
				ItemStack itemStack = player.getItemInHand(hand);
416
				return this.isEquippableInSlot(itemStack, EquipmentSlot.SADDLE) ? itemStack.interactLivingEntity(player, this, hand) : InteractionResult.PASS;
417
			}
418
419
			if (hasFood && !this.isSilent()) {
420
				this.level()
421
					.playSound(
422
						null,
423
						this.getX(),
424
						this.getY(),
425
						this.getZ(),
426
						SoundEvents.STRIDER_EAT,
427
						this.getSoundSource(),
428
						1.0F,
429
						1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F
430
					);
431
			}
432
433
			return interactionResult;
434
		}
435
	}
436
437
	@Override
438
	public Vec3 getLeashOffset() {
439
		return new Vec3(0.0, 0.6F * this.getEyeHeight(), this.getBbWidth() * 0.4F);
440
	}
441
442
	@Override
443
	public @Nullable SpawnGroupData finalizeSpawn(
444
		final ServerLevelAccessor level, final DifficultyInstance difficulty, final EntitySpawnReason spawnReason, @Nullable SpawnGroupData groupData
445
	) {
446
		if (this.isBaby()) {
447
			return super.finalizeSpawn(level, difficulty, spawnReason, groupData);
448
		}
449
450
		RandomSource random = level.getRandom();
451
		if (random.nextInt(30) == 0 && level.getLevel().isSpawningMonsters()) {
452
			Mob jockey = EntityTypes.ZOMBIFIED_PIGLIN.create(level.getLevel(), EntitySpawnReason.JOCKEY);
453
			if (jockey != null) {
454
				groupData = this.spawnJockey(level, difficulty, jockey, new Zombie.ZombieGroupData(Zombie.getSpawnAsBabyOdds(random), false));
455
				jockey.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.WARPED_FUNGUS_ON_A_STICK));
456
				this.setItemSlot(EquipmentSlot.SADDLE, new ItemStack(Items.SADDLE));
457
				this.setGuaranteedDrop(EquipmentSlot.SADDLE);
458
			}
459
		} else if (random.nextInt(10) == 0) {
460
			AgeableMob jockey = EntityTypes.STRIDER.create(level.getLevel(), EntitySpawnReason.JOCKEY);
461
			if (jockey != null) {
462
				jockey.setAge(-24000);
463
				groupData = this.spawnJockey(level, difficulty, jockey, null);
464
			}
465
		} else {
466
			groupData = new AgeableMob.AgeableMobGroupData(0.5F);
467
		}
468
469
		return super.finalizeSpawn(level, difficulty, spawnReason, groupData);
470
	}
471
472
	private SpawnGroupData spawnJockey(
473
		final ServerLevelAccessor level, final DifficultyInstance difficulty, final Mob jockey, final @Nullable SpawnGroupData jockeyGroupData
474
	) {
475
		jockey.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
476
		jockey.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, jockeyGroupData);
477
		jockey.startRiding(this, true, false);
478
		return new AgeableMob.AgeableMobGroupData(0.0F);
479
	}
480
481
	private static class StriderGoToLavaGoal extends MoveToBlockGoal {
482
		private final Strider strider;
483
484
		private StriderGoToLavaGoal(final Strider strider, final double speedModifier) {
485
			super(strider, speedModifier, 8, 2);
486
			this.strider = strider;
487
		}
488
489
		@Override
490
		public BlockPos getMoveToTarget() {
491
			return this.blockPos;
492
		}
493
494
		@Override
495
		public boolean canContinueToUse() {
496
			return !this.strider.isInLava() && this.isValidTarget(this.strider.level(), this.blockPos);
497
		}
498
499
		@Override
500
		public boolean canUse() {
501
			return !this.strider.isInLava() && super.canUse();
502
		}
503
504
		@Override
505
		public boolean shouldRecalculatePath() {
506
			return this.tryTicks % 20 == 0;
507
		}
508
509
		@Override
510
		protected boolean isValidTarget(final LevelReader level, final BlockPos pos) {
511
			return level.getBlockState(pos).is(Blocks.LAVA) && level.getBlockState(pos.above()).isPathfindable(PathComputationType.LAND);
512
		}
513
	}
514
515
	private static class StriderPathNavigation extends GroundPathNavigation {
516
		public StriderPathNavigation(final Strider mob, final Level level) {
517
			super(mob, level);
518
		}
519
520
		@Override
521
		protected PathFinder createPathFinder(final int maxVisitedNodes) {
522
			this.nodeEvaluator = new WalkNodeEvaluator();
523
			return new PathFinder(this.nodeEvaluator, maxVisitedNodes);
524
		}
525
526
		@Override
527
		public boolean isStableDestination(final BlockPos pos) {
528
			return this.level.getBlockState(pos).is(Blocks.LAVA) || super.isStableDestination(pos);
529
		}
530
	}
531
}
532

Decompiled Minecraft 26.3 source of Strider (net/minecraft/world/entity/monster/Strider.java) with Mojang official mappings, stored verbatim on the site.