AbstractMinecart 5.46.0
Extends Entity
Implements DetectorRailActivator
Base of all minecarts: rail physics, damage, activator rails, pushing and the network data shared by every cart.
The rail physics are vanilla's (Java OldMinecartBehavior, the default movement, which Bedrock carts also follow): carts snap onto the rail line, slide down slopes, keep 99.7% (ridden) or 96% (empty) of their speed per tick, powered rails accelerate them by 0.06 per tick (and kick stopped carts away from a solid block), unpowered powered rails brake them, and the top speed is 0.4 blocks per tick (8 m/s), 0.2 in water. Off rails they fall like other entities and keep half of their speed on the ground.
Hits add 10 x the damage to an accumulated "damage" value that decays by 1 per tick: the cart breaks above 40 (a few quick punches), at once when hit by a creative player (without drops).
Constants
BOARDING_COOLDOWN_TICKS
public const BOARDING_COOLDOWN_TICKS = 60Ticks a passenger ejected by an activator rail can't be picked up again.
BREAK_DAMAGE
public const BREAK_DAMAGE = 40.0Accumulated damage above which the cart breaks.
MAX_SPEED
public const MAX_SPEED = 0.4MAX_SPEED_IN_WATER
public const MAX_SPEED_IN_WATER = 0.2NETWORK_Y_OFFSET
public const NETWORK_Y_OFFSET = 0.35Network position of a cart: Bedrock clients place minecarts by their middle, 0.35 above the bottom.
POWERED_RAIL_BOOST
public const POWERED_RAIL_BOOST = 0.06Acceleration of a powered rail on a moving cart, per tick.
POWERED_RAIL_START_SPEED
public const POWERED_RAIL_START_SPEED = 0.02Speed a powered rail gives a stopped cart next to a solid block.
RESYNC_DISTANCE
public const RESYNC_DISTANCE = 8.0Distance of the players for which a standing cart resyncs its position.
RESYNC_INTERVAL
public const RESYNC_INTERVAL = 40Ticks between two position resyncs of a standing cart with a player close to it.
SLOPE_ACCELERATION
public const SLOPE_ACCELERATION = 0.0078125Speed added down a slope per tick.
TAG_DISPLAY_OFFSET
public const TAG_DISPLAY_OFFSET = "DisplayOffset"TAG_DISPLAY_STATE
public const TAG_DISPLAY_STATE = "DisplayState"TAG_FLIPPED
public const TAG_FLIPPED = "FlippedRotation"Properties
$customDisplayBlock protected
protected ?\pocketmine\block\Block $customDisplayBlock$customDisplayOffset protected
protected ?int $customDisplayOffset$damage protected
protected float $damage$flipped protected
protected bool $flipped$hurtDirection protected
protected int $hurtDirection$hurtTime protected
protected int $hurtTime$onRails protected
protected bool $onRailsMethods
animateHurt() protected
protected function animateHurt() : voidShakes the cart like a hit does (vanilla hurt animation).
attack()
public function attack(\pocketmine\event\entity\EntityDamageEvent $source) : voidblockArea()
public static function blockArea(int $x, int $y, int $z) : \pocketmine\math\AxisAlignedBBArea used to find the cart in a block space (hoppers, detector rails).
breakCart()
public function breakCart(bool $drops) : voidBreaks the cart: drops its items (if $drops) and removes it. Container contents are dropped by AbstractMinecart::onDeath() in any case.
canPickUp() protected
protected function canPickUp(\pocketmine\entity\Entity $entity) : boolWhether the entity gets in this cart when they bump into each other.
comeOffTrack() protected
protected function comeOffTrack() : voidMovement without rails (vanilla comeOffTrack()).
create()
public static function create(\pocketmine\entity\vehicle\MinecartType $type, \pocketmine\entity\Location $location) : \pocketmine\entity\vehicle\AbstractMinecartCreates a minecart of the given type (not spawned).
createMovementPacket() protected
protected function createMovementPacket() : \pocketmine\network\mcpe\protocol\MoveActorAbsolutePacketgetCartDrops()
public function getCartDrops() : arrayReturns the items this cart drops when broken by a survival player (Bedrock drops the minecart and the block separately). Container contents are dropped separately.
getCurrentRailPos()
public function getCurrentRailPos() : arrayBlock position of the rail the cart is on: the block at its feet, or the one below if that is a rail.
getCustomDisplayBlock()
public function getCustomDisplayBlock() : ?\pocketmine\block\BlockReturns the custom block shown inside the cart (vanilla DisplayState), or null for the default look.
getCustomDisplayOffset()
public function getCustomDisplayOffset() : ?intHeight of the display block in sixteenths of a block (vanilla default 6), or null for the default.
getDamage()
public function getDamage() : floatReturns the accumulated damage (the cart breaks above AbstractMinecart::BREAK_DAMAGE).
getDetectorRailComparatorOutput()
public function getDetectorRailComparatorOutput() : intgetHeadYaw()
public function getHeadYaw() : floatgetHurtDirection()
public function getHurtDirection() : intgetHurtTime()
public function getHurtTime() : intgetInitialDragMultiplier() protected
protected function getInitialDragMultiplier() : floatgetInitialGravity() protected
protected function getInitialGravity() : floatgetInitialSizeInfo() protected
protected function getInitialSizeInfo() : \pocketmine\entity\EntitySizeInfogetMaxSpeed()
public function getMaxSpeed() : floatgetMinecartType()
abstract public function getMinecartType() : \pocketmine\entity\vehicle\MinecartTypeReturns the type of this cart.
getOffsetPosition()
public function getOffsetPosition(\pocketmine\math\Vector3 $vector3) : \pocketmine\math\Vector3getPassengerPosition()
public function getPassengerPosition(\pocketmine\entity\Entity $passenger) : \pocketmine\math\Vector3getPickedItem()
public function getPickedItem() : ?\pocketmine\item\ItemgetPlacementPosition()
public static function getPlacementPosition(\pocketmine\block\Block $rail) : ?\pocketmine\math\Vector3Creates the cart at the position of a rail block, like a minecart item used on it (vanilla MinecartItem.useOn()): in the middle of the block, just above the rail (half a block higher on slopes).
getRailPoint()
public function getRailPoint(float $x, float $y, float $z) : ?\pocketmine\math\Vector3Point of the rail line under the given position (vanilla OldMinecartBehavior.getPos()), or null if there is no rail there.
getRailShape()
public static function getRailShape(\pocketmine\block\Block $block) : ?intReturns the rail shape (BlockLegacyMetadata::RAIL_*) of a rail block, or null if the block isn't a rail.
getRailYaw()
public static function getRailYaw(\pocketmine\block\Block $rail) : floatYaw of a cart standing on the given rail: along the rail (carts face along X at yaw 0, like vanilla).
getSlowdownFactor() protected
protected function getSlowdownFactor(bool $inWater) : floatFraction of the horizontal speed kept per tick on rails (vanilla applyNaturalSlowdown()).
handleRiderInput()
public function handleRiderInput(\pocketmine\player\Player $rider, \pocketmine\entity\riding\RiderInput $input) : voidCalled every tick with the input of the player riding this cart.
hasMovementUpdate()
public function hasMovementUpdate() : boolinitEntity() protected
protected function initEntity(\pocketmine\nbt\tag\CompoundTag $nbt) : voidisBroken()
public function isBroken() : boolisFlipped()
public function isFlipped() : boolisInWater()
public function isInWater() : boolReturns whether the cart is in water (slower, lower top speed).
isOnRails()
public function isOnRails() : boolisRideable()
public function isRideable() : boolWhether entities can get in this cart (plain minecarts).
isSlope()
public static function isSlope(int $shape) : boolReturns whether the rail shape is a slope.
move() protected
protected function move(float $dx, float $dy, float $dz) : voidCarts move themselves in AbstractMinecart::tryChangeMovement(); the generic movement step of Entity::onUpdate() is skipped.
moveAlongTrack() protected
protected function moveAlongTrack(int $bx, int $by, int $bz, \pocketmine\block\Block $block, int $shape, bool $inWater) : voidVanilla OldMinecartBehavior.moveAlongTrack().
onActivatorRail() protected
protected function onActivatorRail(bool $powered) : voidCalled every tick the cart is on an activator rail (vanilla activateMinecart()).
onDamaged() protected
protected function onDamaged(\pocketmine\event\entity\EntityDamageEvent $source) : boolCalled with an uncancelled damage before it is applied. Returns true if the damage was fully handled (e.g. a TNT minecart exploding).
onDeathUpdate() protected
protected function onDeathUpdate(int $tickDiff) : boolonPassengerRemoved() protected
protected function onPassengerRemoved(\pocketmine\entity\Entity $passenger) : voidpushAndPickupEntities() protected
protected function pushAndPickupEntities() : voidVanilla pushAndPickupEntities(), with the Bedrock "pull_in_entities" of the rideable minecart: mobs walking into an empty cart get in.
pushBy()
public function pushBy(\pocketmine\entity\Entity $entity) : voidPushes this cart away from the entity (vanilla AbstractMinecart.push(Entity)): carts push each other along their rails, other entities get a quarter of the push.
saveNBT()
public function saveNBT() : \pocketmine\nbt\tag\CompoundTagsetBoardingCooldown()
public function setBoardingCooldown(\pocketmine\entity\Entity $entity, int $ticks = self::BOARDING_COOLDOWN_TICKS) : voidPrevents the entity from being picked up by this cart for the given number of ticks.
setCustomDisplayBlock()
public function setCustomDisplayBlock(?\pocketmine\block\Block $block) : voidsetCustomDisplayOffset()
public function setCustomDisplayOffset(?int $offset) : voidsetDamage()
public function setDamage(float $damage) : voidshouldSourceDestroy() protected
protected function shouldSourceDestroy(\pocketmine\event\entity\EntityDamageEvent $source) : boolWhether the damage destroys the cart whatever its accumulated damage.
syncNetworkData() protected
protected function syncNetworkData(\pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection $properties) : voidtickMinecart() protected
protected function tickMinecart() : voidOne tick of vanilla minecart physics (AbstractMinecart.tick() + OldMinecartBehavior.tick()).
tryChangeMovement() protected
protected function tryChangeMovement() : voidupdateMovement() protected
protected function updateMovement(bool $teleport = false) : void