forked from jzitnik/twodcraft
feat: Implemented milk
This commit is contained in:
parent
0546ad2748
commit
bf5f837c45
@ -374,10 +374,9 @@ public class Game implements Serializable {
|
||||
if (gameStates.dependencies.pickupHandlerProvider.get(inventory.getItemInHand().get().getId()).handle(this,
|
||||
x, y)) {
|
||||
screenRenderer.render(this);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!blocks.stream().allMatch(block -> block.getBlockId().equals("air") || block.isFlowing()
|
||||
|| block.getClass().isAnnotationPresent(BreaksByPlace.class))) {
|
||||
|
@ -6,7 +6,6 @@ import cz.jzitnik.game.Game;
|
||||
import cz.jzitnik.game.entities.items.InventoryItem;
|
||||
import cz.jzitnik.game.entities.items.Item;
|
||||
import cz.jzitnik.game.handlers.rightclick.RightClickHandler;
|
||||
import cz.jzitnik.game.smelting.Smelting;
|
||||
import cz.jzitnik.game.ui.InventoryClickHandler;
|
||||
import cz.jzitnik.game.ui.Window;
|
||||
import cz.jzitnik.tui.ScreenRenderer;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cz.jzitnik.game.generation;
|
||||
|
||||
import cz.jzitnik.game.entities.Block;
|
||||
import cz.jzitnik.game.entities.items.ItemBlockSupplier;
|
||||
import cz.jzitnik.game.Game;
|
||||
import cz.jzitnik.game.SpriteLoader;
|
||||
import cz.jzitnik.game.sprites.Steve;
|
||||
@ -32,6 +33,8 @@ 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("bucket"));
|
||||
}
|
||||
|
||||
private static void initializeWorld(List<Block>[][] world) {
|
||||
|
@ -5,10 +5,30 @@ import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cz.jzitnik.game.Game;
|
||||
import cz.jzitnik.game.annotations.RightClickLogic;
|
||||
import cz.jzitnik.game.entities.items.ItemBlockSupplier;
|
||||
import cz.jzitnik.game.handlers.rightclick.RightClickHandler;
|
||||
import cz.jzitnik.tui.ScreenRenderer;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CowData implements Serializable {
|
||||
@RightClickLogic
|
||||
public class CowData implements Serializable, RightClickHandler {
|
||||
private int lastDirection = 1; // 1 = right, -1 = left
|
||||
private int movementCooldown = 0;
|
||||
private int jumpAttempts = 0;
|
||||
|
||||
@Override
|
||||
public void onBlockRightClick(int x, int y, Game game, ScreenRenderer screenRenderer) {
|
||||
var inv = game.getInventory();
|
||||
var inHand = inv.getItemInHand();
|
||||
|
||||
if (inHand.isEmpty() || !inHand.get().getId().equals("bucket")) {
|
||||
return;
|
||||
}
|
||||
|
||||
inv.decreaseItemInHand();
|
||||
inv.addItem(ItemBlockSupplier.getItem("milk_bucket"));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user