Polished and finalized spleef gamemode
This commit is contained in:
parent
95750701f2
commit
8304b6a105
Binary file not shown.
@ -137,6 +137,10 @@ public abstract class Game extends MineNetInstance implements Spawnable {
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
public Pos getSpawn() {
|
||||
return new Pos(0,50,0);
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.spleef;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||
import eu.mhsl.minenet.minigames.score.LastWinsScore;
|
||||
import eu.mhsl.minenet.minigames.util.BatchUtil;
|
||||
import eu.mhsl.minenet.minigames.world.generator.BlockPallet;
|
||||
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularTerrainGenerator;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
@ -11,14 +14,21 @@ import net.minestom.server.event.player.PlayerStartDiggingEvent;
|
||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.item.*;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class Spleef extends StatelessGame {
|
||||
int size = 30;
|
||||
int stackCount = 3;
|
||||
|
||||
final int heightPerLevel = 20;
|
||||
final int totalElevation = 50;
|
||||
|
||||
public Spleef() {
|
||||
super(DimensionType.OVERWORLD, "Spleef", new LastWinsScore());
|
||||
super(Dimension.OVERWORLD.DIMENSION, "Spleef", new LastWinsScore(1));
|
||||
|
||||
setGenerator(new CircularTerrainGenerator(50, false));
|
||||
|
||||
eventNode().addListener(PlayerStartDiggingEvent.class, this::destroyBlock);
|
||||
}
|
||||
@ -27,22 +37,14 @@ public class Spleef extends StatelessGame {
|
||||
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||
AbsoluteBlockBatch circle = new AbsoluteBlockBatch();
|
||||
|
||||
for(int x = -20; x <= 20; x++) {
|
||||
for(int z = -20; z <= 20; z++) {
|
||||
circle.setBlock(x, 10, z, Block.SNOW_BLOCK);
|
||||
}
|
||||
}
|
||||
for (int level = 0; level < stackCount; level++) {
|
||||
for(int x = -size; x <= size; x++) {
|
||||
for(int z = -size; z <= size; z++) {
|
||||
if(new Pos(x, 0, z).distance(new Pos(0, 0, 0)) > size) continue;
|
||||
|
||||
for(int x = -20; x <= 20; x++) {
|
||||
for(int z = -20; z <= 20; z++) {
|
||||
circle.setBlock(x, 20, z, Block.SNOW_BLOCK);
|
||||
circle.setBlock(x, totalElevation + (level * heightPerLevel), z, BlockPallet.WINTER.rnd());
|
||||
}
|
||||
}
|
||||
|
||||
for(int x = -20; x <= 20; x++) {
|
||||
for(int z = -20; z <= 20; z++) {
|
||||
circle.setBlock(x, 30, z, Block.SNOW_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
BatchUtil.loadAndApplyBatch(circle, this, () -> callback.complete(null));
|
||||
@ -70,7 +72,7 @@ public class Spleef extends StatelessGame {
|
||||
|
||||
@Override
|
||||
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||
if(playerMoveEvent.getNewPosition().y() < 9) {
|
||||
if(playerMoveEvent.getNewPosition().y() < totalElevation) {
|
||||
playerMoveEvent.getPlayer().setGameMode(GameMode.SPECTATOR);
|
||||
playerMoveEvent.getPlayer().getInventory().clear();
|
||||
getScore().addResult(playerMoveEvent.getPlayer());
|
||||
@ -83,6 +85,6 @@ public class Spleef extends StatelessGame {
|
||||
|
||||
@Override
|
||||
public Pos getSpawn() {
|
||||
return new Pos(0, 33, 0);
|
||||
return new Pos(0, totalElevation + heightPerLevel * (stackCount-1) + 1, 0);
|
||||
}
|
||||
}
|
||||
|
@ -17,15 +17,17 @@ public class LastWinsScore extends Score {
|
||||
this.ignoreLastPlayers = ignoreLastPlayers;
|
||||
}
|
||||
|
||||
public void setIgnoreLastPlayers(int ignoreLastPlayers) {
|
||||
this.ignoreLastPlayers = ignoreLastPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkGameEnd() {
|
||||
if(this.isDone()) return;
|
||||
if(!instance.isRunning()) return;
|
||||
if(instance.getPlayers().isEmpty()) return;
|
||||
if(scores.size() >= instance.getPlayers().size() - ignoreLastPlayers) setDone();
|
||||
if(scores.size() >= instance.getPlayers().size() - ignoreLastPlayers) {
|
||||
if(ignoreLastPlayers > 0) {
|
||||
instance.getPlayers().stream().filter(player -> !scores.contains(player)).forEach(this::addResult);
|
||||
}
|
||||
setDone();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ public enum BlockPallet {
|
||||
GROUND(new Block[] {Block.GRAVEL, Block.STONE, Block.DIRT, Block.GRASS_BLOCK, Block.COARSE_DIRT, Block.ROOTED_DIRT}),
|
||||
WOOD(new Block[] {Block.ACACIA_WOOD, Block.BIRCH_WOOD, Block.JUNGLE_WOOD, Block.OAK_WOOD, Block.DARK_OAK_WOOD, Block.SPRUCE_WOOD}),
|
||||
STONE(new Block[] {Block.CHISELED_STONE_BRICKS, Block.STONE_BRICKS, Block.POLISHED_ANDESITE, Block.POLISHED_BLACKSTONE, Block.POLISHED_DIORITE}),
|
||||
WINTER(new Block[] {Block.SNOW_BLOCK, Block.ICE, Block.PACKED_ICE, Block.BLUE_CONCRETE, Block.SEA_LANTERN}),
|
||||
|
||||
PRESSURE_PLATES(new Block[] {Block.ACACIA_PRESSURE_PLATE, Block.BIRCH_PRESSURE_PLATE, Block.CRIMSON_PRESSURE_PLATE, Block.JUNGLE_PRESSURE_PLATE, Block.OAK_PRESSURE_PLATE, Block.DARK_OAK_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.POLISHED_BLACKSTONE_PRESSURE_PLATE, Block.SPRUCE_PRESSURE_PLATE, Block.STONE_PRESSURE_PLATE, Block.WARPED_PRESSURE_PLATE});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user