万物吸附
在玩家 40 格范围内的所有实体都会滑向最近的实体:包括生物、掉落物、箭矢、矿车、TNT,除其他玩家外的所有东西。
工作原理
- 每个游戏刻(tick),数据包会将每个实体朝向最近玩家的水平速度进行设定。
- 这是真实的移动,而非瞬移:实体仍会与墙壁碰撞,并正常下落和跳跃,因为仅修改了水平速度分量。
- 吸附速度恒定:每游戏刻 0.35 格(即每秒 7 格),与距离无关。
- 当玩家与该实体距离在 2 格以内时,不会施加吸附力。如果没有这个“死区”,生物会不断冲撞玩家并将其推开。
- 处于旁观者模式的玩家不会吸引任何实体。
配置
速度设置在 data/everything_clings/function/pull.mcfunction 中的以下两行:
execute store result entity @s Motion[0] double 0.00035 run scoreboard players get #x everything_clings.calc
execute store result entity @s Motion[2] double 0.00035 run scoreboard players get #z everything_clings.calc
乘数表示每游戏刻的格数除以 1000:0.00035 = 0.35,0.00015 = 0.15。请同时修改这两行。
吸附半径和死区大小设置在 data/everything_clings/function/tick.mcfunction 中:distance=..40 和 distance=..2。
编辑完成后请运行 /reload。
局限性
- 弓、弩、三叉戟、雪球和末影珍珠几乎无法正常工作:投射物最近的玩家通常是投掷者本人,因此它会几乎立即折返。
- 生物自身的 AI 逻辑仍然运行。试图保持距离的骷髅或正在逃跑的动物会与吸附力产生对抗。
- 该数据包会在每个游戏刻处理玩家附近的所有实体。如果某处有大量掉落物,可能会导致服务器性能出现明显下降。
Everything Clings
Every entity within 40 blocks of a player slides toward the nearest one: mobs, dropped items, arrows, minecarts, TNT, everything except other players.
How it works
- Every tick the pack sets the horizontal velocity of each entity toward the nearest player.
- It's real movement, not teleportation: entities collide with walls and keep falling and jumping normally, since only horizontal velocity is touched.
- The pull speed is constant: 0.35 blocks per tick (7 blocks per second), regardless of distance.
- Nothing is pulled while a player is within 2 blocks of it. Without this dead zone, mobs would keep ramming into the player and pushing them around.
- Players in spectator mode don't attract anything.
Configuration
The speed is set in data/everything_clings/function/pull.mcfunction, in two lines:
execute store result entity @s Motion[0] double 0.00035 run scoreboard players get #x everything_clings.calc
execute store result entity @s Motion[2] double 0.00035 run scoreboard players get #z everything_clings.calc
The multiplier is the speed in blocks per tick divided by 1000: 0.00035 = 0.35, 0.00015 = 0.15. Change both lines.
The radius and the dead zone are set in data/everything_clings/function/tick.mcfunction: distance=..40 and distance=..2.
Run /reload after editing.
Limitations
- Bows, crossbows, tridents, snowballs and ender pearls barely work: a projectile's nearest player is usually whoever threw it, so it turns back almost immediately.
- Mobs' own AI still runs. Skeletons trying to keep their distance and fleeing animals fight against the pull.
- The pack touches every entity near players every tick. Hundreds of dropped items in one place can cost noticeable server performance.
评论 0
登录后参与评分
还没有评论,来抢沙发吧