added playerrace and updated to version 26.2 #14

Merged
jannis merged 17 commits from develop-jannis into develop 2026-07-31 20:04:16 +00:00
2 changed files with 17 additions and 12 deletions
Showing only changes of commit 14f6a38212 - Show all commits
@@ -4,25 +4,26 @@ import eu.mhsl.minenet.minigames.instance.Dimension;
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
import eu.mhsl.minenet.minigames.score.LastWinsScore;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.instance.block.Block;
import net.minestom.server.event.player.PlayerMoveEvent;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.CompletableFuture;
public class PlayerRace extends StatelessGame {
private final int height = 64;
public PlayerRace(int obstacleCount) {
super(Dimension.THE_END.key, "PlayerRace", new LastWinsScore());
this.setGenerator(new PlayerRaceChunkgenerator(64, obstacleCount));
}
@Override
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
this.setBlock(0, 100, 0, Block.AMETHYST_BLOCK);
this.setGenerator(new PlayerRaceChunkgenerator(this.height, obstacleCount));
}
@Override
public Pos getSpawn() {
return new Pos(0.5, 101.5, 0.5);
return new Pos(8, this.height + 1.5, 8);
}
@Override
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
var player = playerMoveEvent.getPlayer();
if(playerMoveEvent.getNewPosition().y() < this.height - 5)
player.teleport(this.getSpawn());
}
}
@@ -9,7 +9,8 @@ import java.util.Random;
/**
* Alte Festungsmauer quer über die Strecke: Drei Blöcke hoch, zu hoch zum
* Springen — auf beiden Seiten hängen Leitern zum Drüberklettern.
* Springen — nur an manchen Säulen hängen Leitern, den Aufstieg muss man
* erst finden. Auf der Rückseite geht es überall hinunter.
*/
class LadderWall extends Obstacle {
@Override
@@ -20,12 +21,15 @@ class LadderWall extends Obstacle {
unit.modifier().setBlock(point.withY(start.blockY()), BlockPallet.STONE.rnd()));
for(int x = 0; x < 16; x++) {
boolean hasLadder = rnd.nextInt(3) != 0;
for(int y = 1; y <= 3; y++) {
for(int z = 7; z <= 8; z++) {
Block block = rnd.nextInt(3) == 0 ? Block.MOSSY_STONE_BRICKS : Block.STONE_BRICKS;
unit.modifier().setBlock(start.add(x, y, z), block);
}
if(hasLadder) {
unit.modifier().setBlock(start.add(x, y, 6), Block.LADDER.withProperty("facing", "north"));
}
unit.modifier().setBlock(start.add(x, y, 9), Block.LADDER.withProperty("facing", "south"));
}