Skip to content

Commit 9eaeb7f

Browse files
author
MagmaGuy
committed
- Fixed bug where push action would be cancelled if applied on the same tick a player is damaged by the boss
Signed-off-by: MagmaGuy <tiagoarnaut@gmail.com>
1 parent 6818cf5 commit 9eaeb7f

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/main/java/com/magmaguy/elitemobs/powers/scripts/ScriptAction.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -429,19 +429,26 @@ private void runPlaySound(ScriptActionData scriptActionData) {
429429
}
430430

431431
private void runPush(ScriptActionData scriptActionData) {
432-
getTargets(scriptActionData).forEach(targetEntity -> {
433-
if (blueprint.getScriptRelativeVectorBlueprint() != null) {
434-
if (blueprint.getBValue() != null && blueprint.getBValue())
435-
targetEntity.setVelocity(targetEntity.getVelocity().add(new ScriptRelativeVector(blueprint.getScriptRelativeVectorBlueprint(), eliteScript, targetEntity.getLocation()).getVector(scriptActionData)));
436-
else
437-
targetEntity.setVelocity(new ScriptRelativeVector(blueprint.getScriptRelativeVectorBlueprint(), eliteScript, targetEntity.getLocation()).getVector(scriptActionData));
438-
} else if (blueprint.getVValue() != null) {
439-
if (blueprint.getBValue() != null && blueprint.getBValue())
440-
targetEntity.setVelocity(targetEntity.getVelocity().add(blueprint.getVValue()));
441-
else
442-
targetEntity.setVelocity(blueprint.getVValue());
432+
//When players get hit that resets their velocity (by Minecraft) and since this runs before the damage is applied
433+
//any velocity set here would be cancelled if used in a damage event. To bypass it we just run it a tick later.
434+
new BukkitRunnable() {
435+
@Override
436+
public void run() {
437+
getTargets(scriptActionData).forEach(targetEntity -> {
438+
if (blueprint.getScriptRelativeVectorBlueprint() != null) {
439+
if (blueprint.getBValue() != null && blueprint.getBValue())
440+
targetEntity.setVelocity(targetEntity.getVelocity().add(new ScriptRelativeVector(blueprint.getScriptRelativeVectorBlueprint(), eliteScript, targetEntity.getLocation()).getVector(scriptActionData)));
441+
else
442+
targetEntity.setVelocity(new ScriptRelativeVector(blueprint.getScriptRelativeVectorBlueprint(), eliteScript, targetEntity.getLocation()).getVector(scriptActionData));
443+
} else if (blueprint.getVValue() != null) {
444+
if (blueprint.getBValue() != null && blueprint.getBValue())
445+
targetEntity.setVelocity(targetEntity.getVelocity().add(blueprint.getVValue()));
446+
else
447+
targetEntity.setVelocity(blueprint.getVValue());
448+
}
449+
});
443450
}
444-
});
451+
}.runTaskLater(MetadataHandler.PLUGIN, 1);
445452
}
446453

447454
private void runSummonReinforcement(ScriptActionData scriptActionData) {

0 commit comments

Comments
 (0)