forked from jzitnik/twodcraft
29 lines
783 B
Java
29 lines
783 B
Java
package cz.jzitnik.game.handlers.place;
|
|
|
|
import cz.jzitnik.game.Game;
|
|
import cz.jzitnik.game.entities.Block;
|
|
|
|
public class DefaultPlaceHandler implements CustomPlaceHandler {
|
|
@Override
|
|
public boolean place(Game game, int x, int y) {
|
|
var blocks = game.getWorld()[y][x];
|
|
var inventory = game.getInventory();
|
|
|
|
blocks.add(inventory.getItemInHand().get().getBlock().get());
|
|
blocks.removeAll(blocks.stream().filter(Block::isFlowing).toList());
|
|
|
|
inventory.decreaseItemInHand();
|
|
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean mine(Game game, int x, int y) {
|
|
var blocks = game.getWorld()[y][x];
|
|
|
|
blocks.removeAll(blocks.stream().filter(i -> !i.getBlockId().equals("air")).toList());
|
|
|
|
return true;
|
|
}
|
|
}
|