finished boat race
This commit is contained in:
@@ -1,24 +1,29 @@
|
|||||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.boatRace;
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.boatRace;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.Resource;
|
||||||
|
import eu.mhsl.minenet.minigames.handler.global.PlayerLoginHandler;
|
||||||
import eu.mhsl.minenet.minigames.instance.Dimension;
|
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||||
import eu.mhsl.minenet.minigames.score.FirstWinsScore;
|
import eu.mhsl.minenet.minigames.score.FirstWinsScore;
|
||||||
|
import eu.mhsl.minenet.minigames.util.CommonProperties;
|
||||||
import net.minestom.server.MinecraftServer;
|
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.EntityType;
|
||||||
|
import net.minestom.server.entity.GameMode;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
|
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||||
|
import net.minestom.server.instance.anvil.AnvilLoader;
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
||||||
public class BoatRace extends StatelessGame {
|
public class BoatRace extends StatelessGame {
|
||||||
public BoatRace() {
|
public BoatRace() {
|
||||||
super(Dimension.OVERWORLD.key, "boatRace", new FirstWinsScore());
|
super(Dimension.OVERWORLD.key, "boatRace", new FirstWinsScore());
|
||||||
|
this.setChunkLoader(new AnvilLoader(Resource.GAME_MAP.getPath().resolve("boatRace/woodlandMansion")));
|
||||||
this.setGenerator(generationUnit -> generationUnit.modifier().fill(
|
|
||||||
generationUnit.absoluteStart(),
|
|
||||||
generationUnit.absoluteEnd().withY(0),
|
|
||||||
Block.BLUE_ICE
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -26,12 +31,45 @@ public class BoatRace extends StatelessGame {
|
|||||||
Entity boat = new Entity(EntityType.OAK_BOAT);
|
Entity boat = new Entity(EntityType.OAK_BOAT);
|
||||||
boat.setInstance(this, this.getSpawn());
|
boat.setInstance(this, this.getSpawn());
|
||||||
boat.setSynchronizationTicks(100000);
|
boat.setSynchronizationTicks(100000);
|
||||||
|
PlayerLoginHandler.globalTeam.addMember(boat.getUuid().toString());
|
||||||
MinecraftServer.getSchedulerManager().scheduleNextTick(() -> boat.addPassenger(p));
|
MinecraftServer.getSchedulerManager().scheduleNextTick(() -> boat.addPassenger(p));
|
||||||
return super.onPlayerJoin(p);
|
return super.onPlayerJoin(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||||
|
for(int z = 9; z <= 32; z++) {
|
||||||
|
this.setBlock(31, 235, z, Block.CHERRY_FENCE.withProperties(CommonProperties.fenceNorthSouth));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
for(int z = 9; z <= 32; z++) {
|
||||||
|
this.setBlock(31, 235, z, Block.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
||||||
|
if (this.isBeforeBeginning) return;
|
||||||
|
|
||||||
|
if(event.getNewPosition().z() > 469) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
this.getScore().insertResult(player);
|
||||||
|
|
||||||
|
Entity vehicle = player.getVehicle();
|
||||||
|
if(vehicle != null) {
|
||||||
|
vehicle.removePassenger(player);
|
||||||
|
player.teleport(player.getPosition().withY(y -> y + 3));
|
||||||
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
|
vehicle.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pos getSpawn() {
|
public Pos getSpawn() {
|
||||||
return new Pos(0, 1, 0);
|
return new Pos(20, 236, 20, -90, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
|
|||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option;
|
||||||
import eu.mhsl.minenet.minigames.instance.room.Room;
|
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
|
import net.minestom.server.item.Material;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -14,6 +15,11 @@ public class BoatRaceFactory implements GameFactory {
|
|||||||
return TranslatedComponent.byId("game_BoatRace#name");
|
return TranslatedComponent.byId("game_BoatRace#name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material symbol() {
|
||||||
|
return Material.OAK_BOAT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
||||||
return new BoatRace().setParent(parent);
|
return new BoatRace().setParent(parent);
|
||||||
|
|||||||
@@ -10,4 +10,11 @@ public class CommonProperties {
|
|||||||
this.put("east", "true");
|
this.put("east", "true");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static Map<String, String> fenceNorthSouth = new HashMap<>() {
|
||||||
|
{
|
||||||
|
this.put("north", "true");
|
||||||
|
this.put("south", "true");
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user