Skip to content

Commit

Permalink
- Fixed bug where push action would be cancelled if applied on the sa…
Browse files Browse the repository at this point in the history
…me tick a player is damaged by the boss

Signed-off-by: MagmaGuy <tiagoarnaut@gmail.com>
  • Loading branch information
MagmaGuy committed Jun 18, 2024
1 parent 6818cf5 commit 9eaeb7f
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,19 +429,26 @@ private void runPlaySound(ScriptActionData scriptActionData) {
}

private void runPush(ScriptActionData scriptActionData) {
getTargets(scriptActionData).forEach(targetEntity -> {
if (blueprint.getScriptRelativeVectorBlueprint() != null) {
if (blueprint.getBValue() != null && blueprint.getBValue())
targetEntity.setVelocity(targetEntity.getVelocity().add(new ScriptRelativeVector(blueprint.getScriptRelativeVectorBlueprint(), eliteScript, targetEntity.getLocation()).getVector(scriptActionData)));
else
targetEntity.setVelocity(new ScriptRelativeVector(blueprint.getScriptRelativeVectorBlueprint(), eliteScript, targetEntity.getLocation()).getVector(scriptActionData));
} else if (blueprint.getVValue() != null) {
if (blueprint.getBValue() != null && blueprint.getBValue())
targetEntity.setVelocity(targetEntity.getVelocity().add(blueprint.getVValue()));
else
targetEntity.setVelocity(blueprint.getVValue());
//When players get hit that resets their velocity (by Minecraft) and since this runs before the damage is applied
//any velocity set here would be cancelled if used in a damage event. To bypass it we just run it a tick later.
new BukkitRunnable() {
@Override
public void run() {
getTargets(scriptActionData).forEach(targetEntity -> {
if (blueprint.getScriptRelativeVectorBlueprint() != null) {
if (blueprint.getBValue() != null && blueprint.getBValue())
targetEntity.setVelocity(targetEntity.getVelocity().add(new ScriptRelativeVector(blueprint.getScriptRelativeVectorBlueprint(), eliteScript, targetEntity.getLocation()).getVector(scriptActionData)));
else
targetEntity.setVelocity(new ScriptRelativeVector(blueprint.getScriptRelativeVectorBlueprint(), eliteScript, targetEntity.getLocation()).getVector(scriptActionData));
} else if (blueprint.getVValue() != null) {
if (blueprint.getBValue() != null && blueprint.getBValue())
targetEntity.setVelocity(targetEntity.getVelocity().add(blueprint.getVValue()));
else
targetEntity.setVelocity(blueprint.getVValue());
}
});
}
});
}.runTaskLater(MetadataHandler.PLUGIN, 1);
}

private void runSummonReinforcement(ScriptActionData scriptActionData) {
Expand Down

0 comments on commit 9eaeb7f

Please sign in to comment.