Skip to content

Commit

Permalink
Prevent the ball from resetting before being initially hit
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 committed Jul 8, 2024
1 parent 06facb3 commit 0e0b78a
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class VolleyballActivePhase implements PlayerAttackEntityEvent, GameActiv
/**
* The number of ticks since the ball was last hit.
*/
private int inactiveBallTicks = 0;
private int inactiveBallTicks = -1;

public VolleyballActivePhase(ServerWorld world, GameSpace gameSpace, VolleyballMap map, TeamManager teamManager, GlobalWidgets widgets, VolleyballConfig config, Text shortName) {
this.world = world;
Expand Down Expand Up @@ -169,7 +169,10 @@ public void onTick() {
this.resetBall();
this.gameSpace.getPlayers().sendMessage(this.getInactiveBallResetText());
} else {
this.inactiveBallTicks += 1;
if (this.inactiveBallTicks >= 0) {
this.inactiveBallTicks += 1;
}

for (TeamEntry team : this.getTeams()) {
if (team.isBallOnCourt(this.ball)) {
team.getOtherTeam().incrementScore();
Expand Down Expand Up @@ -249,7 +252,7 @@ public TeamEntry getChatTeam(ServerPlayerEntity sender) {

public Entity spawnBall() {
this.ball = this.config.getBallEntityConfig().createEntity(this.world, this.world.getRandom());
this.inactiveBallTicks = 0;
this.inactiveBallTicks = -1;

this.map.spawnAtBall(this.world, this.ball);
this.world.spawnEntity(this.ball);
Expand Down

0 comments on commit 0e0b78a

Please sign in to comment.