fix: Infinite water source

This commit is contained in:
Jakub Žitník 2025-03-08 13:39:24 +01:00
parent cfe402ce43
commit 3aa486bede
Signed by: jzitnik
GPG Key ID: C577A802A6AF4EF3
2 changed files with 2 additions and 7 deletions

View File

@ -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) {

View File

@ -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();