added LadderWall2 and added checkpoints
This commit is contained in:
+16
-1
@@ -4,20 +4,30 @@ 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.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerRace extends StatelessGame {
|
||||
private final int height = 64;
|
||||
private double zLine = 32;
|
||||
private double zSpawnPoint = 14.5;
|
||||
|
||||
public PlayerRace(int obstacleCount) {
|
||||
super(Dimension.THE_END.key, "PlayerRace", new LastWinsScore());
|
||||
this.setGenerator(new PlayerRaceChunkgenerator(this.height, obstacleCount));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onPlayerJoin(Player p) {
|
||||
p.setGameMode(GameMode.ADVENTURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pos getSpawn() {
|
||||
return new Pos(8, this.height + 1.5, 8);
|
||||
return new Pos(8, this.height + 1.5, this.zSpawnPoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,5 +35,10 @@ public class PlayerRace extends StatelessGame {
|
||||
var player = playerMoveEvent.getPlayer();
|
||||
if(playerMoveEvent.getNewPosition().y() < this.height - 5)
|
||||
player.teleport(this.getSpawn());
|
||||
|
||||
if(playerMoveEvent.getNewPosition().z() >= this.zLine) {
|
||||
this.zLine += 19;
|
||||
this.zSpawnPoint += 19;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.playerRace.obstacles;
|
||||
|
||||
import eu.mhsl.minenet.minigames.world.BlockPallet;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.generator.GenerationUnit;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class LadderWall2 extends Obstacle{
|
||||
@Override
|
||||
public void generate(GenerationUnit unit, Point start) {
|
||||
forEachColumn(start, point ->
|
||||
unit.modifier().setBlock(point.withY(start.blockY()), BlockPallet.STREET.rnd()));
|
||||
|
||||
this.buildWall(unit, start,4, 4, false);
|
||||
this.buildWall(unit, start,10, 8, true);
|
||||
}
|
||||
|
||||
private void buildWall(GenerationUnit unit, Point start, int z, int height, boolean lastRow) {
|
||||
Random random = new Random();
|
||||
int y = 1;
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int wy = 0; wy <= height; wy++) {
|
||||
unit.modifier().setBlock(start.add(x, y + wy, z), BlockPallet.STONE.rnd());
|
||||
}
|
||||
}
|
||||
|
||||
for(int wy = lastRow ? 2 : 0; wy <= height; wy++) {
|
||||
|
||||
Set<Integer> noLadder = new HashSet<>();
|
||||
for(int i = 0; i < 5; i++) {
|
||||
noLadder.add(random.nextInt(16));
|
||||
}
|
||||
|
||||
for(int x = 0; x < 16; x++) {
|
||||
if(!noLadder.contains(x))
|
||||
unit.modifier().setBlock(start.add(x, y + wy, z - 1), Block.LADDER);
|
||||
}
|
||||
|
||||
if(!lastRow) {
|
||||
for(int x = 7; x < 9; x++) {
|
||||
unit.modifier().setBlock(start.add(x, y + wy, z + 1), Block.LADDER.withProperty("facing", "south"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -32,6 +32,7 @@ public abstract class Obstacle {
|
||||
new MushroomRoofs(),
|
||||
new SandDunes(),
|
||||
new LadderWall(),
|
||||
new LadderWall2(),
|
||||
new GlassPaneWeave(),
|
||||
new BoulderTrench(),
|
||||
new BambooThicket()
|
||||
|
||||
Reference in New Issue
Block a user