只读controlling只读crouching只读entity只读interact只读is只读passenger只读pull只读rider只读seat只读type静态 只读component世界修改Entity that will become the rider of this entity.
True if the rider entity was successfully added.
import { EntityComponentTypes } from '@minecraft/server';
import { Test, register } from '@minecraft/server-gametest';
import { MinecraftBlockTypes, MinecraftEntityTypes } from '@minecraft/vanilla-data';
function minibiomes(test: Test) {
const minecart = test.spawn(MinecraftEntityTypes.Minecart, { x: 9, y: 7, z: 7 });
const pig = test.spawn(MinecraftEntityTypes.Pig, { x: 9, y: 7, z: 7 });
test.setBlockType(MinecraftBlockTypes.Cobblestone, { x: 10, y: 7, z: 7 });
const minecartRideableComp = minecart.getComponent(EntityComponentTypes.Rideable);
minecartRideableComp?.addRider(pig);
test.succeedWhenEntityPresent(MinecraftEntityTypes.Pig, { x: 8, y: 3, z: 1 }, true);
}
register('ChallengeTests', 'minibiomes', minibiomes).structureName('gametests:minibiomes').maxTicks(160);
When added, this component adds the capability that an entity can be ridden by another entity.
示例: minibiomes.ts