Polished and finalized spleef gamemode
This commit is contained in:
		| @@ -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,21 +37,13 @@ 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); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         for(int x = -20; x <= 20; x++) { | ||||
|             for(int z = -20; z <= 20; z++) { | ||||
|                 circle.setBlock(x, 30, z, Block.SNOW_BLOCK); | ||||
|                     circle.setBlock(x, totalElevation + (level * heightPerLevel), z, BlockPallet.WINTER.rnd()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -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); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user