DashAPI
DashAPI 添加了 dash() 功能:以方块为单位(而非向量)设置实体的速度。
使用指南
首先,在你的项目中引入 DashAPI。然后,在 "plugin.yml" 文件中将其添加为依赖项。
depend: [DashAPI]
要获取此 API 的实例以便使用,请通过 DashAPI.getInstance() 定义一个 "DashFunctions" 对象:
DashAPI api;
@Override
public void onEnable() {
api = DashAPI.getInstance();
}
示例 #1(基础函数):
@EventHandler
public void onClick(PlayerInteractEntityEvent event) {
api.dash(event.getRightClicked(), 10, 10, -10);
}
当玩家与实体交互时,该实体将分别沿 Minecraft 的 x、y 和 z 轴向前冲刺 10 个方块、向上冲刺 10 个方块以及向左冲刺 10 个方块。
示例 #2(调整参数):
@EventHandler
public void onCrouch(PlayerToggleSneakEvent event) {
api.dash(event.getPlayer(), 10, 100, 0, true, true, true);
}
当玩家蹲下或起身时,由于 "adjustHorizontal" 为 true,他们将相对于其朝向进行水平冲刺;由于 "additive" 为 true,玩家当前的速度将被累加到冲刺效果中。此外,实体垂直方向上可被冲刺的最大方块数为 60(水平方向为 43),因此插件会将数值 100 缩减至 60,并将玩家向上冲刺 60 个方块(假设无重力影响,例如玩家处于飞行状态)。最后,因为 "adjustVertical" 设置为 true,玩家的抬头或低头角度会影响冲刺的 y 轴值。
示例 #3(int 和 Double 输入):
@EventHandler
public void bounceClick(PlayerInteractEntityEvent event) {
api.dash(event.getPlayer(), 0, event.getPlayer().getLocation().getDirection().getY() * -4, 0);
}
距离方块的 int 值和表示速度的 Double 值可以任意组合使用,在本例中即为 (int, Double, int)。在此示例中,当玩家与实体交互时,该玩家朝向方向的 y 值乘以 -4,这意味着如果玩家向下看以点击实体,他们将以较高的正 y 轴速度被冲刺出去。
示例 #4(乘数):
@EventHandler
public void pushAndPull(PlayerInteractEntityEvent event) {
api.dash(event.getRightClicked(), event.getPlayer().getLocation().getDirection());
api.dash(event.getPlayer(), event.getRightClicked().getVelocity(), 0.5, 0.5, 0.5);
}
第一次冲刺应用于玩家交互的实体,基于玩家面向的方向,从而产生击退效果。第二次冲刺应用于玩家,基于被点击实体的速度,从而产生牵引效果。此外,x、y 和 z 乘数使牵引效果减半,这意味着如果重复执行,交互的实体最终会离玩家太远而无法再次交互。
DashAPI
DashAPI adds "dash()": set the velocity of entities in terms of blocks instead of a vector.
Walkthrough
First, include DashAPI in your project. Then, add this as a dependency in your "plugin.yml" file.
depend: [DashAPI]
To get an instance of this API for use, define a "DashFunctions" object with "DashAPI.getInstance()":
DashAPI api;
@Override
public void onEnable() {
api = DashAPI.getInstance();
}
Example #1 (base function):
@EventHandler
public void onClick(PlayerInteractEntityEvent event) {
api.dash(event.getRightClicked(), 10, 10, -10);
}
When a player interacts with an entity, the entity will be dashed 10 blocks forward, 10 blocks up, and 10 blocks left on Minecraft's x, y, and z axes, respectively.
Example #2 (adjustments):
@EventHandler
public void onCrouch(PlayerToggleSneakEvent event) {
api.dash(event.getPlayer(), 10, 100, 0, true, true, true);
}
When a player crouches or uncrouches, they will be dashed forward relative to their looking direction due to "adjustHorizontal" being true, and the player's current velocity will be added to the dash due to "additive" being true. Additionally, as the maximum number of blocks an entity can be dashed vertically is 60 (43 horizontally), the plugin reduces the value 100 to 60 and dashes the player up 60 blocks, assuming no gravity (ex. player in flight). Finally, because "adjustVertical" is set to true, the player's looking up or down affects the y of the dash.
Example #3 (int and Double inputs):
@EventHandler
public void bounceClick(PlayerInteractEntityEvent event) {
api.dash(event.getPlayer(), 0, event.getPlayer().getLocation().getDirection().getY() * -4, 0);
}
Int values for block distance and Double values for velocity can be used in any combination, and in this example it is (int, Double, int). In this example, when a player interacts with an entity, the y value of that player's looking direction is multiplied by -4, which means that if a player looks down to click an entity, they will be dashed with a high positive y velocity.
Example #4 (multipliers):
@EventHandler
public void pushAndPull(PlayerInteractEntityEvent event) {
api.dash(event.getRightClicked(), event.getPlayer().getLocation().getDirection());
api.dash(event.getPlayer(), event.getRightClicked().getVelocity(), 0.5, 0.5, 0.5);
}
The first dash is applied to the entity interacted by the player, based off of the direction the player is facing, creating a knockback effect. The second dash is applied to the player, based off of the velocity of the clicked entity, creating a pull effect. Additionally, the pull effect is halved with the x, y, and z multiplers, meaning that, if repeated, the interacted entity will eventually be too far away for the player to interact with.
评论 0
登录后参与评分
还没有评论,来抢沙发吧