forked from jzitnik/twodcraft
fix: Infinite water source
This commit is contained in:
parent
cfe402ce43
commit
3aa486bede
@ -34,8 +34,6 @@ public class Generation {
|
||||
// Spawn player at a valid starting point
|
||||
world[terrainHeight[256] - 1][256].add(steveBlock2);
|
||||
world[terrainHeight[256] - 2][256].add(steveBlock);
|
||||
|
||||
game.getInventory().addItem(ItemBlockSupplier.getItem("oak_sapling"));
|
||||
}
|
||||
|
||||
private static void initializeWorld(List<Block>[][] world) {
|
||||
|
@ -5,6 +5,7 @@ import cz.jzitnik.game.annotations.PickupHandler;
|
||||
import cz.jzitnik.game.entities.Block;
|
||||
import cz.jzitnik.game.entities.items.ItemBlockSupplier;
|
||||
import cz.jzitnik.game.handlers.pickup.CustomPickupHandler;
|
||||
import cz.jzitnik.game.logic.services.flowing.FlowingData;
|
||||
|
||||
@PickupHandler("water_bucket,lava_bucket")
|
||||
public class FullBuckerPickupHandler implements CustomPickupHandler {
|
||||
@ -14,14 +15,10 @@ public class FullBuckerPickupHandler implements CustomPickupHandler {
|
||||
var world = game.getWorld();
|
||||
var inventory = game.getInventory();
|
||||
|
||||
if (world[y][x].stream().anyMatch(block -> !block.getBlockId().equals("air"))) {
|
||||
if (world[y][x].stream().anyMatch(block -> !block.getBlockId().equals("air") && (block.isFlowing() && ((FlowingData) block.getData()).isSource()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world[y][x].stream().anyMatch(Block::isFlowing)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
world[y][x].add(inventory.getItemInHand().get().getBlock().get());
|
||||
|
||||
inventory.decreaseItemInHand();
|
||||
|
Loading…
x
Reference in New Issue
Block a user