feat: Move mobs down when block mined under them
This commit is contained in:
parent
bf5f837c45
commit
8d1414dae0
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -105,7 +105,7 @@ public class CowLogic
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(int playerX, int playerY, Game game, Terminal terminal) {
|
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(),
|
int[] data = ScreenMovingCalculationProvider.calculate(playerX, playerY, terminal.getHeight(),
|
||||||
terminal.getWidth(), game.getWorld()[0].length, game.getWorld().length);
|
terminal.getWidth(), game.getWorld()[0].length, game.getWorld().length);
|
||||||
var world = game.getWorld();
|
var world = game.getWorld();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user