重力枪
一款 Minecraft 插件,重现了《半条命 2》中的重力枪工具。右键可用于拾取生物或方块,也可用于丢弃已拾取的物体。左键可用于推动生物,或在已捕获物体的情况下将其发射出去。
| 命令 |
权限 |
描述 |
| help |
|
显示此帮助信息 |
| reload |
gravity-gun.reload |
重新加载插件配置 |
| give [target] |
gravity-gun.give |
将重力枪给予自己或其他玩家 |
| fix [target] |
gravity-gun.fix |
修复因不幸被抓住而导致重力/碰撞异常的玩家 |
| debug place_all_rotation_blocks |
gravity-gun.debug |
放置那些在旋转 90° 后 BlockData 会发生变化的方块类型的样本 |
配置
所有设置均位于 config.yml 中。缺失的选项会从内置默认值中补充,而用户文件会保留所有现有值;该文件会在启动时以及执行 /gg reload 时进行更新。
version - 配置文件格式版本。
debug - 启用关于手持方块显示和还原方块实体的额外日志记录。
language - 插件消息和工具提示的语言代码(en_us, en_gb, ru_ru, uk_ua)。
item.gravity-gun.name - 重力枪物品的自定义名称;若留空则回退到语言文件中的默认名称。
机制:
mechanics.grab.range - 抓取方块或实体的最大距离。
mechanics.grab.cooldown - 两次抓取尝试之间的最小延迟。
mechanics.pull.range - 拉拽的最大距离。
mechanics.pull.force - 拉拽力的强度。
mechanics.hold.max-time - 释放前可持握抓取物体的最长时间;设为 0 则禁用此限制。
mechanics.hold.display-items.enabled - 将掉落物品作为物品显示来持握,并使弹射物保留其原生实体模型。
mechanics.hold.distance.min / mechanics.hold.distance.max / mechanics.hold.distance.step - 持握物体与玩家眼睛之间距离的最小值、最大值和步长。
mechanics.launch.power - 当使用左键发射或释放所持有的物体时应用的发射速度。
mechanics.release.momentum.enabled - 在释放和发射时继承玩家移动和视角转动的动量。
mechanics.release.momentum.multiplier - 继承动量的强度倍数。
mechanics.release.momentum.max-speed - 每刻增加的最大动量(以方块为单位)。
效果:
effects.enabled - 切换重力枪及方块撞击粒子效果。
限制:
limits.entities.allow-grab - 是否允许抓取实体。
limits.entities.allow-grab-players - 是否允许抓取玩家。
limits.entities.list-mode - 适用于 limits.entities.list 的模式:BLACKLIST(黑名单)、WHITELIST(白名单)或 DISABLED(禁用)。
limits.entities.list - 应用于实体抓取列表的实体类型名称。
limits.blocks.allow-grab - 是否允许抓取方块。
limits.blocks.list-mode - 适用于 limits.blocks.list 的模式:BLACKLIST(黑名单)、WHITELIST(白名单)或 DISABLED(禁用)。
limits.blocks.list - 应用于方块抓取列表的方块名称。
效果与释放动量
config.yml 中的 effects.enabled 选项控制重力枪的粒子效果,包括方块撞击粒子。释放动量可通过 mechanics.release.momentum.multiplier 和 mechanics.release.momentum.max-speed 进行调整。
默认启用 mechanics.hold.display-items.enabled 选项。掉落物品作为物品显示被持握,而弹射物则保留并移动其原生实体模型。在持握期间或释放后的半秒内,无法拾取掉落的物品和箭矢;随后会恢复其原始的拾取状态。弹射物沿玩家视角方向瞄准,并在释放时赋予至少配置的发射速度。左键可将捕获的弹射物向前发射;尽管持握的弹射物位于准星下方,但由于使用了手臂摆动事件作为后备方案,因此依然有效。在启动和重载时,插件会填充用户配置中缺失的配置选项,同时保留现有值。
持握的方块显示跟随玩家的准星,并随摄像机平滑旋转;释放时,旋转会 snapped(对齐)到最近的 90°,然后再放置方块。方向性方块和多方块结构会根据从拾取开始以来的玩家水平视角转动进行旋转。门和床会被一起携带和放置。双层箱子故意拆分:被抓取的一半变为单个箱子,地面上剩余的一半也变为单个箱子,但保持其各自的库存不变。床由单个显示表示,栅栏和玻璃板在放置后会更新其连接状态。
方块实体
对于拥有真实 3D 方块模型的方块,方块实体块会使用 BlockDisplay。因此,熔炉、桶、蜂巢、营火、架子、宝库、投掷器、发射器等类似方块在持握时仍保持正常的方块外观。视觉效果仅存在于方块实体渲染器中或其方块模型为空的方块则改用其物品模型显示:箱子(包括铜箱和末影箱)、床、告示牌和悬挂式告示牌、旗帜、头颅、潜影盒、装饰罐、潮涌核心以及铜傀儡雕像。墙上的告示牌、墙上的旗帜、墙上的头颅和墙上悬挂式告示牌则以其站立形态的物品模型显示。
内容和元数据(如箱子库存、告示牌文本、旗帜图案、头颅模型、陶罐碎片、铜傀儡姿势以及自定义名称)会与手持的方块一起存储,并在放置时恢复。仅由方块实体渲染器渲染的细节在手持方块时不可见:例如架子和营火的内容物、保险库动画,以及刷怪笼的动画部分等。由于钟的主体完全由其方块实体渲染器渲染,因此它显示为扁平的物品;如果显示方块模型,则只会显示其挂载部分。
重力枪仅拦截实际的左键和右键点击。物理交互(如在侦测器上行走)会被忽略,因此既不会取消也不会伴随抓取音效。在 config.yml 中设置 debug: true 会记录有关手持方块显示和恢复的方块实体的额外详细信息。
针对资源包
对于资源包,可以通过以下方式将模型和纹理附加到弩上:
{
"model": {
"type": "select",
"property": "custom_model_data",
"fallback": {
"type": "model",
"model": "item/crossbow"
},
"cases": [
{
"when": "gravity-gun",
"model": {
"type": "model",
"model": "item/gravity_gun"
}
},
{
"when": "gravity-gun-blue",
"model": {
"type": "model",
"model": "item/gravity_gun_firework"
}
}
]
}
}
Gravity Gun
A Minecraft plugin that recreates the Gravity Gun tool from Half-Life 2. The right mouse button can be used to pick up a creature or block, or to drop it. The left mouse button can be used to push a creature or launch it if the object is captured.
| Command |
Permission |
Description |
| help |
|
Show this help |
| reload |
gravity-gun.reload |
Reload the plugin configuration |
| give [target] |
gravity-gun.give |
Give the gravity gun to yourself or another player |
| fix [target] |
gravity-gun.fix |
Fix gravity and collision player after unlucky player grabs it |
| debug place_all_rotation_blocks |
gravity-gun.debug |
Place samples of block types whose BlockData changes under a 90° rotation |
Configuration
All settings live in config.yml. Missing options are added from the bundled defaults while the user's file keeps all existing values; the file is updated on startup and on /gg reload.
version - config file format version.
debug - enables extra logging about held block displays and restored block entities.
language - language code for plugin messages and tooltips (en_us, en_gb, ru_ru, uk_ua).
item.gravity-gun.name - custom name of the gravity gun item; an empty value falls back to the default name from the language file.
Mechanics:
mechanics.grab.range - maximum distance to grab a block or entity.
mechanics.grab.cooldown - minimum delay between two grab attempts.
mechanics.pull.range - maximum distance for pull.
mechanics.pull.force - strength of the pull force.
mechanics.hold.max-time - maximum time the grabbed object may be held before it is released; 0 disables this limit.
mechanics.hold.display-items.enabled - holds dropped items as item displays and keeps projectiles on their native entity models.
mechanics.hold.distance.min / mechanics.hold.distance.max / mechanics.hold.distance.step - minimum, maximum and step of the distance between the held object and the player's eye.
mechanics.launch.power - launch speed that is applied when the held object is launched with the left mouse button or released.
mechanics.release.momentum.enabled - inherits player movement and camera-turn momentum on release and launch.
mechanics.release.momentum.multiplier - strength of the inherited momentum.
mechanics.release.momentum.max-speed - maximum added momentum in blocks per tick.
Effects:
effects.enabled - toggles gravity gun and block-impact particle effects.
Limits:
limits.entities.allow-grab - whether entities can be grabbed at all.
limits.entities.allow-grab-players - whether players can be grabbed.
limits.entities.list-mode - BLACKLIST, WHITELIST or DISABLED for limits.entities.list.
limits.entities.list - entity type names to apply the entity grab list to.
limits.blocks.allow-grab - whether blocks can be grabbed at all.
limits.blocks.list-mode - BLACKLIST, WHITELIST or DISABLED for limits.blocks.list.
limits.blocks.list - block names to apply the block grab list to.
Effects and release momentum
The effects.enabled option in config.yml controls the gravity gun's particle effects, including block-impact particles. Release momentum can be adjusted with mechanics.release.momentum.multiplier and mechanics.release.momentum.max-speed.
The mechanics.hold.display-items.enabled option is enabled by default. Dropped items are held as item displays, while projectiles retain and move their native entity models. Dropped items and arrows cannot be picked up while held or for half a second after release; their original pickup state is then restored. Projectiles are aimed along the player's view and given at least the configured launch speed when released. The left mouse button launches a captured projectile forward; it works even though the held projectile sits under the crosshair, because the arm swing event is used as a fallback. On startup and on reload the plugin fills in configuration options that are missing from the user's config while keeping existing values.
Held block displays follow the player's crosshair and rotate smoothly with the camera; on release, the rotation snaps to the nearest 90° before the blocks are placed. Directional blocks and multi-block structures rotate according to the player's horizontal camera turn since pickup. Doors and beds are carried and placed together. Double chests intentionally split: the grabbed half becomes a single chest, and the remaining half on the ground also becomes single while keeping its own inventory intact. Beds are shown by a single display, and fences and panes update their connections after placement.
Block entities
Block-entity blocks use a BlockDisplay whenever the block has a real 3D block model, so furnaces, barrels, beehives, campfires, shelves, vaults, droppers, dispensers, and similar blocks keep their normal block appearance while held. Blocks whose visuals only exist in a block-entity renderer or whose block model is empty are shown with their item model instead: chests (including copper and ender chests), beds, signs and hanging signs, banners, skulls, shulker boxes, decorated pots, conduits, and copper golem statues. Wall signs, wall banners, wall skulls, and wall hanging signs are displayed using their standing item form.
Contents and metadata such as chest inventories, sign text, banner patterns, skull profiles, pot sherds, copper golem poses, and custom names are stored with the held block and restored when it is placed. Details rendered only by a block-entity renderer are not visible while holding a block: shelf and campfire contents, vault animations, and the animated parts of spawners, for example. The bell is shown as a flat item because its body is rendered exclusively by its block-entity renderer; showing the block model would display only the mount.
The gravity gun only intercepts actual left and right clicks. Physical interactions such as walking on a sculk sensor are ignored, so they are neither cancelled nor accompanied by the grab sound. Setting debug: true in config.yml logs extra details about held block displays and restored block entities.
For resource packs
For resource packs, there is the option to attach a model and texture to a crossbow via:
{
"model": {
"type": "select",
"property": "custom_model_data",
"fallback": {
"type": "model",
"model": "item/crossbow"
},
"cases": [
{
"when": "gravity-gun",
"model": {
"type": "model",
"model": "item/gravity_gun"
}
},
{
"when": "gravity-gun-blue",
"model": {
"type": "model",
"model": "item/gravity_gun_firework"
}
}
]
}
}
评论 0
登录后参与评分
还没有评论,来抢沙发吧