feat: Move mobs down when block mined under them

This commit is contained in:
Jakub Žitník 2025-03-14 16:26:53 +01:00
parent bf5f837c45
commit 8d1414dae0
Signed by: jzitnik
GPG Key ID: C577A802A6AF4EF3
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,16 @@
package cz.jzitnik.game.handlers.events.handlers.mobs;
import cz.jzitnik.game.Game;
import cz.jzitnik.game.annotations.MineEventHandler;
import cz.jzitnik.tui.ScreenRenderer;
public class MobMineHandler {
@MineEventHandler
public void handle(ScreenRenderer screenRenderer, Game game, int x, int y) {
var world = game.getWorld();
var mobs = world[y-1][x].stream().filter(block -> block.isMob() && !block.getBlockId().equals("steve")).toList();
world[y-1][x].removeAll(mobs);
world[y][x].addAll(mobs);
}
}

View File

@ -105,7 +105,7 @@ public class CowLogic
@Override
public void spawn(int playerX, int playerY, Game game, Terminal terminal) {
// Cordinates where player can see
// Coordinates where player can see
int[] data = ScreenMovingCalculationProvider.calculate(playerX, playerY, terminal.getHeight(),
terminal.getWidth(), game.getWorld()[0].length, game.getWorld().length);
var world = game.getWorld();