Compare commits
10 Commits
develop-st
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 325fba2a53 | |||
| e760cdb2c6 | |||
| c111c027ff | |||
| 73ab137ae4 | |||
| 9a9e646288 | |||
| 728dc92fc8 | |||
| 2f8ff36e5e | |||
| 5cb71c5c32 | |||
| 5ab42fde4b | |||
| d5c2f06409 |
@@ -133,7 +133,7 @@ public class ElytraRace extends StatelessGame {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.playerCheckpoints.putIfAbsent(player, new CheckPointData(this.ringSpacing, this.ringSpacing * 2));
|
this.playerCheckpoints.putIfAbsent(player, new CheckPointData(0, this.ringSpacing));
|
||||||
|
|
||||||
if(newPos.z() > this.generatedUntil - this.ringSpacing) {
|
if(newPos.z() > this.generatedUntil - this.ringSpacing) {
|
||||||
this.generateRing(this.generatedUntil + this.ringSpacing);
|
this.generateRing(this.generatedUntil + this.ringSpacing);
|
||||||
@@ -224,7 +224,9 @@ public class ElytraRace extends StatelessGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void toCheckpoint(Player p) {
|
private void toCheckpoint(Player p) {
|
||||||
|
CheckPointData data = this.playerCheckpoints.get(p);
|
||||||
Point checkpointPos = this.getRingPositionAtZ(this.playerCheckpoints.get(p).currentCheckpoint);
|
Point checkpointPos = this.getRingPositionAtZ(this.playerCheckpoints.get(p).currentCheckpoint);
|
||||||
|
if(data.currentCheckpoint == 0) checkpointPos = this.getSpawn().add(0, 3, 0);
|
||||||
p.setVelocity(Vec.ZERO);
|
p.setVelocity(Vec.ZERO);
|
||||||
p.setFlyingWithElytra(false);
|
p.setFlyingWithElytra(false);
|
||||||
p.teleport(Pos.fromPoint(checkpointPos).add(0.5, 0, 0.5));
|
p.teleport(Pos.fromPoint(checkpointPos).add(0.5, 0, 0.5));
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ public class StickFightFactory implements GameFactory {
|
|||||||
@Override
|
@Override
|
||||||
public ConfigManager configuration() {
|
public ConfigManager configuration() {
|
||||||
return new ConfigManager()
|
return new ConfigManager()
|
||||||
.addOption(new NumericOption("length", Material.SANDSTONE, TranslatedComponent.byId("optionCommon#length"), 7, 10, 13, 16, 19));
|
.addOption(new NumericOption("length", Material.SANDSTONE, TranslatedComponent.byId("optionCommon#length"), 7, 10, 13, 16, 19))
|
||||||
|
.addOption(new NumericOption("seconds", Material.CLOCK, TranslatedComponent.byId("optionCommon#seconds"), 30, 60, 90, 120));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,7 +41,7 @@ public class StickFightFactory implements GameFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Game manufacture(Room parent, Map<String, Option<?>> configuration) {
|
public Game manufacture(Room parent, Map<String, Option<?>> configuration) {
|
||||||
return new Stickfight(configuration.get("length").getAsInt()).setParent(parent);
|
return new Stickfight(configuration.get("length").getAsInt(), configuration.get("seconds").getAsInt()).setParent(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ public class Stickfight extends StatelessGame {
|
|||||||
private final WeakHashMap<Player, Pos> spawnPoints = new WeakHashMap<>();
|
private final WeakHashMap<Player, Pos> spawnPoints = new WeakHashMap<>();
|
||||||
private final Map<Player, Integer> scoreMap = new WeakHashMap<>();
|
private final Map<Player, Integer> scoreMap = new WeakHashMap<>();
|
||||||
private boolean countdownStarted = false;
|
private boolean countdownStarted = false;
|
||||||
|
private final int seconds;
|
||||||
|
|
||||||
public Stickfight(int length) {
|
public Stickfight(int length, int seconds) {
|
||||||
super(Dimension.OVERWORLD.key, "Stickfight", new LowestPointsWinScore());
|
super(Dimension.OVERWORLD.key, "Stickfight", new LowestPointsWinScore());
|
||||||
this.radius = length;
|
this.radius = length;
|
||||||
|
this.seconds = seconds;
|
||||||
|
|
||||||
this.eventNode().addChild(
|
this.eventNode().addChild(
|
||||||
CombatFeatures.empty()
|
CombatFeatures.empty()
|
||||||
@@ -88,6 +90,11 @@ public class Stickfight extends StatelessGame {
|
|||||||
super.start();
|
super.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
this.setTimeLimit(this.seconds);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
this.scoreMap.forEach((player, score) -> this.getScore().insertResult(player, score));
|
this.scoreMap.forEach((player, score) -> this.getScore().insertResult(player, score));
|
||||||
@@ -122,6 +129,7 @@ public class Stickfight extends StatelessGame {
|
|||||||
player.teleport(this.spawnPoints.get(player));
|
player.teleport(this.spawnPoints.get(player));
|
||||||
this.scoreMap.putIfAbsent(player, 0);
|
this.scoreMap.putIfAbsent(player, 0);
|
||||||
this.scoreMap.put(player, this.scoreMap.get(player) + 1);
|
this.scoreMap.put(player, this.scoreMap.get(player) + 1);
|
||||||
|
player.setLevel(this.scoreMap.get(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,18 +6,20 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.types.tetris.game.Tetri
|
|||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.tetris.game.Tetromino;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.tetris.game.Tetromino;
|
||||||
import eu.mhsl.minenet.minigames.score.PointsWinScore;
|
import eu.mhsl.minenet.minigames.score.PointsWinScore;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.entity.Entity;
|
import net.minestom.server.entity.Entity;
|
||||||
|
import net.minestom.server.entity.EntityType;
|
||||||
import net.minestom.server.entity.GameMode;
|
import net.minestom.server.entity.GameMode;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
|
import net.minestom.server.entity.metadata.display.BlockDisplayMeta;
|
||||||
import net.minestom.server.event.player.PlayerHandAnimationEvent;
|
import net.minestom.server.event.player.PlayerHandAnimationEvent;
|
||||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
|
||||||
import net.minestom.server.event.player.PlayerTickEvent;
|
import net.minestom.server.event.player.PlayerTickEvent;
|
||||||
import net.minestom.server.event.player.PlayerUseItemEvent;
|
import net.minestom.server.event.player.PlayerUseItemEvent;
|
||||||
|
import net.minestom.server.instance.block.Block;
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
import net.minestom.server.item.Material;
|
import net.minestom.server.item.Material;
|
||||||
import net.minestom.server.potion.Potion;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
import net.minestom.server.potion.PotionEffect;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -78,18 +80,24 @@ class Tetris extends StatelessGame {
|
|||||||
p.setGameMode(GameMode.SURVIVAL);
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void onPlayerInteract(@NotNull PlayerUseItemEvent event) {
|
||||||
protected void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
event.setItemUseTime(0);
|
||||||
|
this.tetrisGames.get(event.getPlayer()).pressedButton(TetrisGame.Button.mouseRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onPlayerAttack(@NotNull PlayerHandAnimationEvent event) {
|
||||||
|
this.tetrisGames.get(event.getPlayer()).pressedButton(TetrisGame.Button.mouseLeft);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onPlayerTick(PlayerTickEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Pos currentPosition = event.getNewPosition();
|
|
||||||
|
|
||||||
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
||||||
|
if(tetrisGame == null) return;
|
||||||
if(tetrisGame == null) {
|
if(tetrisGame.lost) {
|
||||||
event.setCancelled(true);
|
this.letPlayerLoose(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(tetrisGame.lost) return;
|
|
||||||
if(player.getGameMode() == GameMode.SPECTATOR) return;
|
if(player.getGameMode() == GameMode.SPECTATOR) return;
|
||||||
|
|
||||||
if(player.inputs().forward()) tetrisGame.pressedButton(TetrisGame.Button.W);
|
if(player.inputs().forward()) tetrisGame.pressedButton(TetrisGame.Button.W);
|
||||||
@@ -97,26 +105,6 @@ class Tetris extends StatelessGame {
|
|||||||
if(player.inputs().right()) tetrisGame.pressedButton(TetrisGame.Button.D);
|
if(player.inputs().right()) tetrisGame.pressedButton(TetrisGame.Button.D);
|
||||||
if(player.inputs().left()) tetrisGame.pressedButton(TetrisGame.Button.A);
|
if(player.inputs().left()) tetrisGame.pressedButton(TetrisGame.Button.A);
|
||||||
if(player.inputs().jump()) tetrisGame.pressedButton(TetrisGame.Button.space);
|
if(player.inputs().jump()) tetrisGame.pressedButton(TetrisGame.Button.space);
|
||||||
|
|
||||||
event.setNewPosition(tetrisGame.getPlayerSpawnPosition().withView(currentPosition));
|
|
||||||
player.setSprinting(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onPlayerInteract(@NotNull PlayerUseItemEvent event) {
|
|
||||||
this.tetrisGames.get(event.getPlayer()).pressedButton(TetrisGame.Button.mouseRight);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onPlayerAttack(@NotNull PlayerHandAnimationEvent event) {
|
|
||||||
this.tetrisGames.get(event.getPlayer()).pressedButton(TetrisGame.Button.mouseLeft);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onPlayerTick(PlayerTickEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
|
||||||
if(tetrisGame == null) return;
|
|
||||||
if(tetrisGame.lost && player.getGameMode() != GameMode.SPECTATOR) {
|
|
||||||
this.letPlayerLoose(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void letPlayerLoose(Player player) {
|
private void letPlayerLoose(Player player) {
|
||||||
@@ -124,6 +112,7 @@ class Tetris extends StatelessGame {
|
|||||||
if(!this.getScore().hasResult(player)) {
|
if(!this.getScore().hasResult(player)) {
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
player.setInvisible(true);
|
player.setInvisible(true);
|
||||||
|
if(player.getVehicle() != null) player.getVehicle().removePassenger(player);
|
||||||
this.getScore().insertResult(player, tetrisGame.getScore());
|
this.getScore().insertResult(player, tetrisGame.getScore());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +149,16 @@ class Tetris extends StatelessGame {
|
|||||||
|
|
||||||
p.teleport(tetrisGame.getPlayerSpawnPosition());
|
p.teleport(tetrisGame.getPlayerSpawnPosition());
|
||||||
tetrisGame.sidebar.addViewer(p);
|
tetrisGame.sidebar.addViewer(p);
|
||||||
p.addEffect(new Potion(PotionEffect.SLOWNESS, 4, Potion.INFINITE_DURATION));
|
|
||||||
|
MinecraftServer.getSchedulerManager().scheduleTask(() -> {
|
||||||
|
Entity ghostBlock = new Entity(EntityType.BLOCK_DISPLAY);
|
||||||
|
((BlockDisplayMeta) ghostBlock.getEntityMeta()).setBlockState(Block.AIR);
|
||||||
|
ghostBlock.setNoGravity(true);
|
||||||
|
ghostBlock.setInstance(this, tetrisGame.getPlayerSpawnPosition());
|
||||||
|
ghostBlock.addPassenger(p);
|
||||||
|
return TaskSchedule.stop();
|
||||||
|
}, TaskSchedule.nextTick());
|
||||||
|
|
||||||
|
|
||||||
return super.onPlayerJoin(p);
|
return super.onPlayerJoin(p);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user