use of gg.projecteden.nexus.features.minigolf.models.blocks.ModifierBlock in project Nexus by ProjectEdenGG.
the class MiniGolf method miniGolfTask.
private void miniGolfTask() {
Tasks.repeat(0, TickTime.TICK, () -> {
if (golfBalls.isEmpty())
return;
for (GolfBall golfBall : new ArrayList<>(golfBalls)) {
Snowball ball = golfBall.getSnowball();
if (ball == null)
continue;
if (!ball.isValid()) {
golfBall.remove();
continue;
}
// Location location = ball.getLocation();
// if (golfBall.getLastLocation().equals(location))
// continue;
MiniGolfBallMoveEvent ballMoveEvent = new MiniGolfBallMoveEvent(golfBall, golfBall.getLastLocation(), ball.getLocation());
if (!ballMoveEvent.callEvent()) {
ball.teleportAsync(golfBall.getLastLocation());
ball.setVelocity(ball.getVelocity());
}
Block below = golfBall.getBlockBelow();
Material belowType = below.getType();
for (ModifierBlockType modifierBlockType : ModifierBlockType.values()) {
ModifierBlock modifierBlock = modifierBlockType.getModifierBlock();
if (modifierBlockType.equals(ModifierBlockType.DEFAULT) || modifierBlock.getMaterials().contains(belowType)) {
MiniGolfBallModifierBlockEvent modifierBlockEvent = new MiniGolfBallModifierBlockEvent(golfBall, modifierBlockType);
if (modifierBlockEvent.callEvent()) {
modifierBlock.handleRoll(golfBall);
break;
}
}
}
}
});
}
Aggregations