added pillars and block battle #10
Reference in New Issue
Block a user
Delete Branch "develop-pillars"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@@ -0,0 +49,4 @@@Overrideprotected void onLoad(@NotNull CompletableFuture<Void> callback) {this.generateWorld();generateWorld wird nur hier aufgerufen, der code von generateWorld kann also direkt hier in onLoad, ohne extra Methode.
@@ -0,0 +126,4 @@@Overrideprotected void onStart() {this.setTeams();this.getPlayers().forEach(player -> {Kann als lambda expression geschrieben werden. Schlägt IntelliJ meistens schon vor.
@@ -0,0 +148,4 @@}}private void generateWorld() {Kann direkt in onLoad rein.
@@ -0,0 +156,4 @@this.generatePlatform(new Pos(-5, 101, -14), Block.RED_STAINED_GLASS, Block.AIR);this.generatePlatform(new Pos(5, 101, 14), Block.BLUE_STAINED_GLASS, Block.AIR);this.setBlock(new Pos(2, 102, -9), Block.RED_STAINED_GLASS);Lieber ein Array pro Block mit Positionen und dann alle durchgehen. So wird "Block.RED_STAINED_GLASS" nicht wiederholt.
@@ -0,0 +164,4 @@this.setBlock(new Pos(3, 102, -12), Block.RED_STAINED_GLASS);this.setBlock(new Pos(5, 101, -15), Block.RED_STAINED_GLASS);this.setBlock(new Pos(-5, 101, 15), Block.BLUE_STAINED_GLASS);... hier das gleiche.
@@ -0,0 +170,4 @@this.setBlock(new Pos(1, 103, 9), Block.BLUE_STAINED_GLASS);this.setBlock(new Pos(2, 104, 6), Block.BLUE_STAINED_GLASS);this.setBlock(new Pos(5, 103, 7), Block.BLUE_STAINED_GLASS);this.setBlock(new Pos(7, 102, 10), Block.BLUE_STAINED_GLASS);Anstatt immer this.setBlock aufzurufen kann man auch AbsoluteBlockBatch benutzen (siehe Tetris Playfield).
Ist aber nicht unbedingt notwendig.
@@ -0,0 +3,4 @@import net.minestom.server.coordinate.Pos;import net.minestom.server.item.Material;public class Team {Könnte ein record sein. IntelliJ schlägt das vermutlich schon vor.
@@ -0,0 +27,4 @@private int spawnPosz = 0;private final int pillarSpacing = 10;private final int pillarRowCount = 5;public Pillars() {Leerzeile davor
@@ -0,0 +71,4 @@@Overrideprotected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {if(this.isBeforeBeginning && Position.hasPositionChanged(playerMoveEvent.getPlayer().getPosition(), playerMoveEvent.getNewPosition()))Eigene Variable für playerMoveEvent.getPlayer(), das wiederholt sich sonst.
@@ -0,0 +90,4 @@.filter(material -> !material.equals(Material.AIR)).toList();this.getPlayers().forEach(player -> {ItemStack item = ItemStack.of(materials.get(new Random().nextInt(Material.values().toArray().length)));new Random() als eigene Variable in Pillars, damit nicht immer ein neues Objekt erstellt wird.
Alternativ geht ThreadLocalRandom.current()
nimm ThreadLocalRandom.current()
@@ -177,0 +181,4 @@;;ns:game_BlockBattle#;;name;Block Battle;Block Kampfdescription;The team that fills the center with their color first wins!;Das Team, welches als erstes die Mitte mit ihrer Farbe gefüllt hat, hat gewonnen!Das Team, welches als erstes die Mitte mit seiner Farbe gefüllt hat, gewinnt!
@@ -0,0 +78,4 @@playerMoveEvent.setCancelled(true);if(playerMoveEvent.getNewPosition().y() < 80) {this.getScore().insertResult(playerMoveEvent.getPlayer());Hier kann auch player anstatt playerMoveEvent.getPlayer() hin.