Skip to content

Commit

Permalink
switch firework mechanic to location-based scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
CJCrafter committed Jun 13, 2024
1 parent 1adb579 commit 67a6677
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ public Mechanic serialize(@NotNull SerializeData data) throws SerializerExceptio
@Override
public void playFor(CastData cast, List<Player> viewers) {

FakeEntity fakeEntity = CompatibilityAPI.getCompatibility().getEntityCompatibility().generateFakeEntity(cast.getTargetLocation(), FIREWORK_ENTITY, fireworkItem);
Location targetLoc = cast.getTargetLocation();
FakeEntity fakeEntity = CompatibilityAPI.getCompatibility().getEntityCompatibility().generateFakeEntity(targetLoc, FIREWORK_ENTITY, fireworkItem);
if (flightTime > 1)
fakeEntity.setMotion(0.001, 0.3, -0.001);

Expand All @@ -229,7 +230,7 @@ public void playFor(CastData cast, List<Player> viewers) {
}

// Schedule a task to explode the firework later.
MechanicsCore.getPlugin().getFoliaScheduler().runNextTick((ignore) -> {
MechanicsCore.getPlugin().getFoliaScheduler().runAtLocation(targetLoc, (ignore) -> {
fakeEntity.playEffect(EntityEffect.FIREWORK_EXPLODE);
fakeEntity.remove();
});
Expand Down

0 comments on commit 67a6677

Please sign in to comment.