added playerrace and updated to version 26.2 #14
+10
-11
@@ -4,26 +4,25 @@ 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.batch.AbsoluteBlockBatch;
|
||||
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() {
|
||||
super(Dimension.THE_END.key, "PlayerRace", new LastWinsScore());
|
||||
this.setGenerator(new PlayerRaceChunkgenerator(64));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||
this.setBlock(0, 100, 0, Block.AMETHYST_BLOCK);
|
||||
this.setGenerator(new PlayerRaceChunkgenerator(this.height));
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.playerRace.obstacles;
|
||||
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.generator.GenerationUnit;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class LadderWall extends Obstacle{
|
||||
@Override
|
||||
public void generate(GenerationUnit unit, Point start) {
|
||||
int y = start.blockY() + 64;
|
||||
int width = 16;
|
||||
int depth = 16;
|
||||
|
||||
for(int x = 0; x < width; x++) {
|
||||
for(int z = 0; z < depth; z++) {
|
||||
unit.modifier().setRelative(x, y, z, Block.LIGHT_BLUE_CONCRETE);
|
||||
}
|
||||
}
|
||||
this.buildWall(unit, y, 4, 4, false);
|
||||
this.buildWall(unit, y,10, 8, true);
|
||||
}
|
||||
|
||||
private void buildWall(GenerationUnit unit, int y, int z, int height, boolean lastRow) {
|
||||
Random random = new Random();
|
||||
y += 1;
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int wy = 0; wy <= height; wy++) {
|
||||
unit.modifier().setRelative(x, y + wy, z, Block.LIGHT_BLUE_CONCRETE);
|
||||
}
|
||||
}
|
||||
|
||||
if(lastRow) {
|
||||
for(int wy = 2; wy <= height; wy++) {
|
||||
|
||||
int[] noLadder = new int[5];
|
||||
for(int i = 0; i < 5; i++) {
|
||||
noLadder[i] = random.nextInt(16);
|
||||
}
|
||||
|
||||
for(int x = 0; x < 16; x++) {
|
||||
if(!this.isInArray(x, noLadder))
|
||||
unit.modifier().setRelative(x, y + wy, z - 1, Block.LADDER);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
for(int wy = 0; wy <= height; wy++) {
|
||||
|
||||
int[] noLadder = new int[5];
|
||||
for(int i = 0; i < 5; i++) {
|
||||
noLadder[i] = random.nextInt(16);
|
||||
}
|
||||
|
||||
for(int x = 0; x < 16; x++) {
|
||||
if(!this.isInArray(x, noLadder))
|
||||
unit.modifier().setRelative(x, y + wy, z - 1, Block.LADDER);
|
||||
}
|
||||
|
||||
for(int x = 7; x < 9; x++) {
|
||||
unit.modifier().setRelative(x, y + wy, z + 1, Block.LADDER.withProperty("facing", "south"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInArray(int number, int[] array) {
|
||||
for(int value : array) if(value == number) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public abstract class Obstacle {
|
||||
@SuppressWarnings("StaticInitializerReferencesSubClass")
|
||||
private static final List<Obstacle> obstacles = List.of(new Mudpit());
|
||||
private static final List<Obstacle> obstacles = List.of(new Mudpit(), new LadderWall());
|
||||
|
||||
public abstract void generate(GenerationUnit unit, Point start);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user