feat: Added sheeps
This commit is contained in:
@ -52,9 +52,13 @@ public class SpriteLoader {
|
||||
HUNGER,
|
||||
|
||||
PIG,
|
||||
SHEEP,
|
||||
|
||||
ITEM_PORKCHOP,
|
||||
ITEM_COOKED_PORKCHOP,
|
||||
|
||||
ITEM_MUTTON,
|
||||
ITEM_COOKED_MUTTON,
|
||||
}
|
||||
|
||||
public static final HashMap<SPRITES, Sprite> SPRITES_MAP = new HashMap<>();
|
||||
@ -96,10 +100,15 @@ public class SpriteLoader {
|
||||
SPRITES_MAP.put(SPRITES.ITEM_PORKCHOP, new SimpleSprite("items/porkchop.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_COOKED_PORKCHOP, new SimpleSprite("items/cooked_porkchop.ans"));
|
||||
|
||||
SPRITES_MAP.put(SPRITES.ITEM_MUTTON, new SimpleSprite("items/mutton.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_COOKED_MUTTON, new SimpleSprite("items/cooked_mutton.ans"));
|
||||
|
||||
SPRITES_MAP.put(SPRITES.HEART, new Heart());
|
||||
SPRITES_MAP.put(SPRITES.HUNGER, new Hunger());
|
||||
|
||||
SPRITES_MAP.put(SPRITES.PIG, new Pig());
|
||||
SPRITES_MAP.put(SPRITES.SHEEP, new Sheep());
|
||||
|
||||
}
|
||||
|
||||
public static SpriteList<SPRITES> load() {
|
||||
|
12
src/main/java/cz/jzitnik/game/annotations/BlockRegistry.java
Normal file
12
src/main/java/cz/jzitnik/game/annotations/BlockRegistry.java
Normal file
@ -0,0 +1,12 @@
|
||||
package cz.jzitnik.game.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface BlockRegistry {
|
||||
String value();
|
||||
}
|
12
src/main/java/cz/jzitnik/game/annotations/ItemRegistry.java
Normal file
12
src/main/java/cz/jzitnik/game/annotations/ItemRegistry.java
Normal file
@ -0,0 +1,12 @@
|
||||
package cz.jzitnik.game.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface ItemRegistry {
|
||||
String value();
|
||||
}
|
@ -6,7 +6,9 @@ import cz.jzitnik.game.entities.Block;
|
||||
import cz.jzitnik.game.blocks.Chest;
|
||||
import cz.jzitnik.game.blocks.Furnace;
|
||||
import cz.jzitnik.game.mobs.services.pig.PigData;
|
||||
import cz.jzitnik.game.mobs.services.sheep.SheepData;
|
||||
import cz.jzitnik.game.sprites.Pig;
|
||||
import cz.jzitnik.game.sprites.Sheep;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -149,14 +151,18 @@ public class ItemBlockSupplier {
|
||||
public static Item oakDoor() {
|
||||
return Helper.oakDoor(Blocks.oakDoor());
|
||||
}
|
||||
|
||||
public static Item porkchop() {
|
||||
return new Item("porkchop", "Porkchop", ItemType.FOOD, SpriteLoader.SPRITES.ITEM_PORKCHOP, 3);
|
||||
}
|
||||
|
||||
public static Item cookedPorkchop() {
|
||||
return new Item("cooked_porkchop", "Cooked porkchop", ItemType.FOOD, SpriteLoader.SPRITES.ITEM_COOKED_PORKCHOP, 4);
|
||||
}
|
||||
public static Item mutton() {
|
||||
return new Item("mutton", "Mutton", ItemType.FOOD, SpriteLoader.SPRITES.ITEM_MUTTON, 2);
|
||||
}
|
||||
public static Item cookedMutton() {
|
||||
return new Item("cooked_mutton", "Cooked mutton", ItemType.FOOD, SpriteLoader.SPRITES.ITEM_COOKED_MUTTON, 6);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Mobs {
|
||||
@ -168,7 +174,17 @@ public class ItemBlockSupplier {
|
||||
block.setSpriteState(Pig.PigState.RIGHT);
|
||||
block.setMineable(false);
|
||||
block.setData(new PigData());
|
||||
block.setHp(3);
|
||||
block.setHp(10);
|
||||
return block;
|
||||
}
|
||||
public static Block sheep(Sheep.SheepState sheepState) {
|
||||
var block = new Block("sheep", SpriteLoader.SPRITES.SHEEP);
|
||||
block.setMob(true);
|
||||
block.setGhost(true);
|
||||
block.setSpriteState(sheepState);
|
||||
block.setMineable(false);
|
||||
block.setData(new SheepData());
|
||||
block.setHp(8);
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
package cz.jzitnik.game.entities.items;
|
||||
|
||||
import cz.jzitnik.game.annotations.BlockRegistry;
|
||||
import cz.jzitnik.game.annotations.ItemRegistry;
|
||||
import cz.jzitnik.game.entities.Block;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemBlockSupplierNew {
|
||||
private static final HashMap<String, Block> registeredBlocks = new HashMap<>();
|
||||
private static final HashMap<String, Item> registeredItems = new HashMap<>();
|
||||
|
||||
static {
|
||||
registerBlocks();
|
||||
registerItems();
|
||||
}
|
||||
|
||||
private static void registerBlocks() {
|
||||
Reflections reflections = new Reflections("cz.jzitnik.game.entities.items.registry");
|
||||
Set<Class<?>> blockClasses = reflections.getTypesAnnotatedWith(BlockRegistry.class);
|
||||
|
||||
for (Class<?> clazz : blockClasses) {
|
||||
try {
|
||||
Block blockInstance = (Block) clazz.getDeclaredConstructor().newInstance();
|
||||
BlockRegistry annotation = clazz.getAnnotation(BlockRegistry.class);
|
||||
registeredBlocks.put(annotation.value(), blockInstance);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerItems() {
|
||||
Reflections reflections = new Reflections("cz.jzitnik.game.entities.items.registry");
|
||||
Set<Class<?>> itemClasses = reflections.getTypesAnnotatedWith(ItemRegistry.class);
|
||||
|
||||
for (Class<?> clazz : itemClasses) {
|
||||
try {
|
||||
Item itemInstance = (Item) clazz.getDeclaredConstructor().newInstance();
|
||||
ItemRegistry annotation = clazz.getAnnotation(ItemRegistry.class);
|
||||
registeredItems.put(annotation.value(), itemInstance);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Block getBlock(String id) {
|
||||
return registeredBlocks.get(id);
|
||||
}
|
||||
|
||||
public static Item getItem(String id) {
|
||||
return registeredItems.get(id);
|
||||
}
|
||||
}
|
@ -200,8 +200,8 @@ public class PigLogic implements EntityLogicInterface, EntitySpawnInterface, Ent
|
||||
|
||||
@Override
|
||||
public void killed(Game game, Block mob) {
|
||||
int amount = random.nextInt(3) + 1;
|
||||
InventoryItem inventoryItem = new InventoryItem(amount, ItemBlockSupplier.Items.porkchop());
|
||||
int amount = random.nextInt(2) + 1;
|
||||
InventoryItem inventoryItem = new InventoryItem(amount, ItemBlockSupplier.Items.mutton());
|
||||
game.getInventory().addItem(inventoryItem);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package cz.jzitnik.game.mobs.services.sheep;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SheepData {
|
||||
private int lastDirection = 1; // 1 = right, -1 = left
|
||||
private int movementCooldown = 0;
|
||||
private int jumpAttempts = 0;
|
||||
}
|
@ -0,0 +1,278 @@
|
||||
package cz.jzitnik.game.mobs.services.sheep;
|
||||
|
||||
import cz.jzitnik.game.Game;
|
||||
import cz.jzitnik.game.annotations.EntityHurtAnimationHandler;
|
||||
import cz.jzitnik.game.annotations.EntityKillHandler;
|
||||
import cz.jzitnik.game.annotations.EntityLogic;
|
||||
import cz.jzitnik.game.annotations.EntitySpawn;
|
||||
import cz.jzitnik.game.entities.Block;
|
||||
import cz.jzitnik.game.entities.items.InventoryItem;
|
||||
import cz.jzitnik.game.entities.items.ItemBlockSupplier;
|
||||
import cz.jzitnik.game.mobs.*;
|
||||
import cz.jzitnik.game.sprites.Sheep;
|
||||
import cz.jzitnik.tui.ScreenMovingCalculationProvider;
|
||||
import org.jline.terminal.Terminal;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static cz.jzitnik.game.sprites.Sheep.SheepState.*;
|
||||
|
||||
@EntitySpawn
|
||||
@EntityLogic("sheep")
|
||||
@EntityHurtAnimationHandler("sheep")
|
||||
@EntityKillHandler("sheep")
|
||||
public class SheepLogic implements EntityLogicInterface, EntitySpawnInterface, EntityHurtAnimationChanger, EntityKillInterface {
|
||||
private final Random random = new Random();
|
||||
|
||||
@Override
|
||||
public void nextIteration(EntityLogicProvider.EntityLogicMobDTO entityLogicMobDTO) {
|
||||
int sheepX = entityLogicMobDTO.getX();
|
||||
int sheepY = entityLogicMobDTO.getY();
|
||||
var game = entityLogicMobDTO.getGame();
|
||||
var sheep = entityLogicMobDTO.getMob();
|
||||
var world = game.getWorld();
|
||||
var sheepData = (SheepData) sheep.getData();
|
||||
|
||||
boolean updated = false;
|
||||
int newSheepX = sheepX;
|
||||
int newSheepY = sheepY;
|
||||
|
||||
if (sheepData.getMovementCooldown() > 0) {
|
||||
sheepData.setMovementCooldown(sheepData.getMovementCooldown() - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
int direction = sheepData.getLastDirection();
|
||||
if (random.nextInt(10) < 1) { // 10% chance to change direction
|
||||
direction = -direction;
|
||||
}
|
||||
sheepData.setLastDirection(direction);
|
||||
|
||||
boolean isHurt = sheep.getSpriteState().get().name().endsWith("_HURT");
|
||||
Sheep.SheepState newState = switch (sheep.getSpriteState().get()) {
|
||||
case WHITE_LEFT, WHITE_RIGHT, WHITE_LEFT_HURT, WHITE_RIGHT_HURT ->
|
||||
isHurt ? (direction == 1 ? WHITE_RIGHT_HURT : WHITE_LEFT_HURT)
|
||||
: (direction == 1 ? WHITE_RIGHT : WHITE_LEFT);
|
||||
|
||||
case LIGHT_GRAY_LEFT, LIGHT_GRAY_RIGHT, LIGHT_GRAY_LEFT_HURT, LIGHT_GRAY_RIGHT_HURT ->
|
||||
isHurt ? (direction == 1 ? LIGHT_GRAY_RIGHT_HURT : LIGHT_GRAY_LEFT_HURT)
|
||||
: (direction == 1 ? LIGHT_GRAY_RIGHT : LIGHT_GRAY_LEFT);
|
||||
|
||||
case GRAY_LEFT, GRAY_RIGHT, GRAY_LEFT_HURT, GRAY_RIGHT_HURT ->
|
||||
isHurt ? (direction == 1 ? GRAY_RIGHT_HURT : GRAY_LEFT_HURT)
|
||||
: (direction == 1 ? GRAY_RIGHT : GRAY_LEFT);
|
||||
|
||||
case BLACK_LEFT, BLACK_RIGHT, BLACK_LEFT_HURT, BLACK_RIGHT_HURT ->
|
||||
isHurt ? (direction == 1 ? BLACK_RIGHT_HURT : BLACK_LEFT_HURT)
|
||||
: (direction == 1 ? BLACK_RIGHT : BLACK_LEFT);
|
||||
|
||||
case BROWN_LEFT, BROWN_RIGHT, BROWN_LEFT_HURT, BROWN_RIGHT_HURT ->
|
||||
isHurt ? (direction == 1 ? BROWN_RIGHT_HURT : BROWN_LEFT_HURT)
|
||||
: (direction == 1 ? BROWN_RIGHT : BROWN_LEFT);
|
||||
|
||||
case PINK_LEFT, PINK_RIGHT, PINK_LEFT_HURT, PINK_RIGHT_HURT ->
|
||||
isHurt ? (direction == 1 ? PINK_RIGHT_HURT : PINK_LEFT_HURT)
|
||||
: (direction == 1 ? PINK_RIGHT : PINK_LEFT);
|
||||
default -> throw new IllegalStateException("Unexpected value: " + sheep.getSpriteState().get());
|
||||
};
|
||||
sheep.setSpriteState(newState);
|
||||
|
||||
|
||||
List<Block> blocksAhead = world[sheepY][sheepX + direction];
|
||||
if (!game.isSolid(blocksAhead)) {
|
||||
world[sheepY][sheepX].remove(sheep);
|
||||
world[sheepY][sheepX + direction].add(sheep);
|
||||
newSheepX = sheepX + direction;
|
||||
updated = true;
|
||||
sheepData.setJumpAttempts(0);
|
||||
} else {
|
||||
List<Block> blocksAboveAhead = world[sheepY - 1][sheepX + direction];
|
||||
List<Block> blocksTwoAboveAhead = world[sheepY - 2][sheepX + direction];
|
||||
|
||||
if (!game.isSolid(blocksAboveAhead) && game.isSolid(blocksAhead) && !game.isSolid(blocksTwoAboveAhead)) {
|
||||
if (sheepData.getJumpAttempts() < 2) {
|
||||
world[sheepY][sheepX].remove(sheep);
|
||||
world[sheepY - 1][sheepX + direction].add(sheep);
|
||||
newSheepX = sheepX + direction;
|
||||
newSheepY = sheepY - 1;
|
||||
updated = true;
|
||||
sheepData.setJumpAttempts(sheepData.getJumpAttempts() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (updated) {
|
||||
if (!game.isSolid(world[newSheepY + 1][newSheepX])) {
|
||||
if (newSheepY - sheepY < 3) {
|
||||
world[newSheepY][newSheepX].remove(sheep);
|
||||
world[newSheepY + 1][newSheepX].add(sheep);
|
||||
newSheepY++;
|
||||
} else {
|
||||
updated = false;
|
||||
}
|
||||
} else {
|
||||
updated = false;
|
||||
}
|
||||
}
|
||||
|
||||
sheepData.setMovementCooldown(random.nextInt(3) + 1); // 1-3 iterations cooldown
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawn(int playerX, int playerY, Game game, Terminal terminal) {
|
||||
// Cordinates where player can see
|
||||
int[] data = ScreenMovingCalculationProvider.calculate(playerX, playerY, terminal.getHeight(), terminal.getWidth(), game.getWorld()[0].length, game.getWorld().length);
|
||||
var world = game.getWorld();
|
||||
int startX = data[0];
|
||||
int endX = data[1];
|
||||
|
||||
// Left side
|
||||
int lstartX = startX - 20;
|
||||
int lendX = startX - 5;
|
||||
int lstartY = playerY - 15;
|
||||
int lendY = playerY + 15;
|
||||
|
||||
if (countSheep(lstartX, lendX, lstartY, lendY, game) < 3 && random.nextInt(100) < 2) {
|
||||
var spawnLocations = sheepCanSpawn(lstartX, lendX, playerY, game);
|
||||
if (!spawnLocations.isEmpty()) {
|
||||
System.out.println(spawnLocations.size());
|
||||
for (int i = 0; i < Math.min(4, spawnLocations.size()); i++) {
|
||||
var randomLocation = getRandomEntry(spawnLocations);
|
||||
int x = randomLocation.getKey();
|
||||
int y = randomLocation.getValue();
|
||||
|
||||
world[y][x].add(getSheep());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Right side
|
||||
int rstartX = endX + 5;
|
||||
int rendX = endX + 20;
|
||||
int rstartY = playerY - 15;
|
||||
int rendY = playerY + 15;
|
||||
|
||||
if (countSheep(rstartX, rendX, rstartY, rendY, game) < 3 && random.nextInt(100) < 2) {
|
||||
var spawnLocations = sheepCanSpawn(rstartX, rendX, playerY, game);
|
||||
if (!spawnLocations.isEmpty()) {
|
||||
System.out.println(spawnLocations.size());
|
||||
for (int i = 0; i < Math.min(random.nextInt(3) + 2, spawnLocations.size()); i++) {
|
||||
var randomLocation = getRandomEntry(spawnLocations);
|
||||
int x = randomLocation.getKey();
|
||||
int y = randomLocation.getValue();
|
||||
|
||||
world[y][x].add(getSheep());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static <K, V> Map.Entry<K, V> getRandomEntry(HashMap<K, V> map) {
|
||||
List<Map.Entry<K, V>> entryList = new ArrayList<>(map.entrySet());
|
||||
Random random = new Random();
|
||||
return entryList.get(random.nextInt(entryList.size()));
|
||||
}
|
||||
|
||||
private HashMap<Integer, Integer> sheepCanSpawn(int startX, int endX, int playerY, Game game) {
|
||||
var map = new HashMap<Integer, Integer>();
|
||||
var world = game.getWorld();
|
||||
for (int x = startX; x <= endX; x++) {
|
||||
for (int y = Math.max(0, playerY - 30); y < Math.min(world.length, playerY + 30); y++) {
|
||||
if (world[y][x].stream().anyMatch(i -> i.getBlockId().equals("grass"))) {
|
||||
map.put(x, y - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
private long countSheep(int startX, int endX, int startY, int endY, Game game) {
|
||||
long sheepAmount = 0;
|
||||
for (int y = startY; y <= endY; y++) {
|
||||
for (int x = startX; x <= endX; x++) {
|
||||
sheepAmount += game.getWorld()[y][x].stream().filter(i -> i.getBlockId().equals("sheep")).count();
|
||||
}
|
||||
}
|
||||
|
||||
return sheepAmount;
|
||||
}
|
||||
|
||||
private Block getSheep() {
|
||||
int num = random.nextInt(100);
|
||||
|
||||
if (num < 1) {
|
||||
return ItemBlockSupplier.Mobs.sheep(PINK_RIGHT);
|
||||
}
|
||||
|
||||
if (num < 4) {
|
||||
return ItemBlockSupplier.Mobs.sheep(BROWN_RIGHT);
|
||||
}
|
||||
|
||||
if (num < 15) {
|
||||
int num1 = random.nextInt(3);
|
||||
return switch (num1) {
|
||||
case 0 -> ItemBlockSupplier.Mobs.sheep(LIGHT_GRAY_RIGHT);
|
||||
case 1 -> ItemBlockSupplier.Mobs.sheep(GRAY_RIGHT);
|
||||
case 2 -> ItemBlockSupplier.Mobs.sheep(BLACK_RIGHT);
|
||||
default -> throw new IllegalStateException("Unexpected value: " + num1);
|
||||
};
|
||||
}
|
||||
|
||||
return ItemBlockSupplier.Mobs.sheep(WHITE_RIGHT);
|
||||
}
|
||||
|
||||
public Sheep.SheepState setHurtAnimation(boolean hurt, Enum current) {
|
||||
if (hurt) {
|
||||
return switch (current) {
|
||||
case WHITE_LEFT, WHITE_LEFT_HURT -> WHITE_LEFT_HURT;
|
||||
case WHITE_RIGHT, WHITE_RIGHT_HURT -> WHITE_RIGHT_HURT;
|
||||
|
||||
case LIGHT_GRAY_LEFT, LIGHT_GRAY_LEFT_HURT -> LIGHT_GRAY_LEFT_HURT;
|
||||
case LIGHT_GRAY_RIGHT, LIGHT_GRAY_RIGHT_HURT -> LIGHT_GRAY_RIGHT_HURT;
|
||||
|
||||
case GRAY_LEFT, GRAY_LEFT_HURT -> GRAY_LEFT_HURT;
|
||||
case GRAY_RIGHT, GRAY_RIGHT_HURT -> GRAY_RIGHT_HURT;
|
||||
|
||||
case BLACK_LEFT, BLACK_LEFT_HURT -> BLACK_LEFT_HURT;
|
||||
case BLACK_RIGHT, BLACK_RIGHT_HURT -> BLACK_RIGHT_HURT;
|
||||
|
||||
case BROWN_LEFT, BROWN_LEFT_HURT -> BROWN_LEFT_HURT;
|
||||
case BROWN_RIGHT, BROWN_RIGHT_HURT -> BROWN_RIGHT_HURT;
|
||||
|
||||
case PINK_LEFT, PINK_LEFT_HURT -> PINK_LEFT_HURT;
|
||||
case PINK_RIGHT, PINK_RIGHT_HURT -> PINK_RIGHT_HURT;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + current);
|
||||
};
|
||||
} else {
|
||||
return switch (current) {
|
||||
case WHITE_LEFT, WHITE_LEFT_HURT -> WHITE_LEFT;
|
||||
case WHITE_RIGHT, WHITE_RIGHT_HURT -> WHITE_RIGHT;
|
||||
|
||||
case LIGHT_GRAY_LEFT, LIGHT_GRAY_LEFT_HURT -> LIGHT_GRAY_LEFT;
|
||||
case LIGHT_GRAY_RIGHT, LIGHT_GRAY_RIGHT_HURT -> LIGHT_GRAY_RIGHT;
|
||||
|
||||
case GRAY_LEFT, GRAY_LEFT_HURT -> GRAY_LEFT;
|
||||
case GRAY_RIGHT, GRAY_RIGHT_HURT -> GRAY_RIGHT;
|
||||
|
||||
case BLACK_LEFT, BLACK_LEFT_HURT -> BLACK_LEFT;
|
||||
case BLACK_RIGHT, BLACK_RIGHT_HURT -> BLACK_RIGHT;
|
||||
|
||||
case BROWN_LEFT, BROWN_LEFT_HURT -> BROWN_LEFT;
|
||||
case BROWN_RIGHT, BROWN_RIGHT_HURT -> BROWN_RIGHT;
|
||||
|
||||
case PINK_LEFT, PINK_LEFT_HURT -> PINK_LEFT;
|
||||
case PINK_RIGHT, PINK_RIGHT_HURT -> PINK_RIGHT;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + current);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void killed(Game game, Block mob) {
|
||||
int amount = random.nextInt(3) + 1;
|
||||
InventoryItem inventoryItem = new InventoryItem(amount, ItemBlockSupplier.Items.porkchop());
|
||||
game.getInventory().addItem(inventoryItem);
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ public class Smelting {
|
||||
static {
|
||||
smeltingList.put("cobblestone", ItemBlockSupplier.Items::stone);
|
||||
smeltingList.put("porkchop", ItemBlockSupplier.Items::cookedPorkchop);
|
||||
smeltingList.put("mutton", ItemBlockSupplier.Items::cookedMutton);
|
||||
}
|
||||
|
||||
public static final HashMap<String, Double> fuelList = new HashMap<>();
|
||||
|
80
src/main/java/cz/jzitnik/game/sprites/Sheep.java
Normal file
80
src/main/java/cz/jzitnik/game/sprites/Sheep.java
Normal file
@ -0,0 +1,80 @@
|
||||
package cz.jzitnik.game.sprites;
|
||||
|
||||
import cz.jzitnik.tui.ResourceLoader;
|
||||
import cz.jzitnik.tui.Sprite;
|
||||
|
||||
public class Sheep extends Sprite {
|
||||
public enum SheepState {
|
||||
WHITE_LEFT,
|
||||
WHITE_RIGHT,
|
||||
WHITE_LEFT_HURT,
|
||||
WHITE_RIGHT_HURT,
|
||||
|
||||
LIGHT_GRAY_LEFT,
|
||||
LIGHT_GRAY_RIGHT,
|
||||
LIGHT_GRAY_LEFT_HURT,
|
||||
LIGHT_GRAY_RIGHT_HURT,
|
||||
|
||||
GRAY_LEFT,
|
||||
GRAY_RIGHT,
|
||||
GRAY_LEFT_HURT,
|
||||
GRAY_RIGHT_HURT,
|
||||
|
||||
BLACK_LEFT,
|
||||
BLACK_RIGHT,
|
||||
BLACK_LEFT_HURT,
|
||||
BLACK_RIGHT_HURT,
|
||||
|
||||
BROWN_LEFT,
|
||||
BROWN_RIGHT,
|
||||
BROWN_LEFT_HURT,
|
||||
BROWN_RIGHT_HURT,
|
||||
|
||||
PINK_LEFT,
|
||||
PINK_RIGHT,
|
||||
PINK_LEFT_HURT,
|
||||
PINK_RIGHT_HURT,
|
||||
}
|
||||
|
||||
public String getSprite() {
|
||||
return getSprite(SheepState.WHITE_RIGHT);
|
||||
}
|
||||
|
||||
public String getSprite(Enum e) {
|
||||
return ResourceLoader.loadResource(
|
||||
switch (e) {
|
||||
case SheepState.WHITE_LEFT -> "mobs/sheep/white/left.ans";
|
||||
case SheepState.WHITE_RIGHT -> "mobs/sheep/white/right.ans";
|
||||
case SheepState.WHITE_LEFT_HURT -> "mobs/sheep/white/lefthurt.ans";
|
||||
case SheepState.WHITE_RIGHT_HURT -> "mobs/sheep/white/righthurt.ans";
|
||||
|
||||
case SheepState.LIGHT_GRAY_LEFT -> "mobs/sheep/light_gray/left.ans";
|
||||
case SheepState.LIGHT_GRAY_RIGHT -> "mobs/sheep/light_gray/right.ans";
|
||||
case SheepState.LIGHT_GRAY_LEFT_HURT -> "mobs/sheep/light_gray/lefthurt.ans";
|
||||
case SheepState.LIGHT_GRAY_RIGHT_HURT -> "mobs/sheep/light_gray/righthurt.ans";
|
||||
|
||||
case SheepState.GRAY_LEFT -> "mobs/sheep/gray/left.ans";
|
||||
case SheepState.GRAY_RIGHT -> "mobs/sheep/gray/right.ans";
|
||||
case SheepState.GRAY_LEFT_HURT -> "mobs/sheep/gray/lefthurt.ans";
|
||||
case SheepState.GRAY_RIGHT_HURT -> "mobs/sheep/gray/righthurt.ans";
|
||||
|
||||
case SheepState.BLACK_LEFT -> "mobs/sheep/black/left.ans";
|
||||
case SheepState.BLACK_RIGHT -> "mobs/sheep/black/right.ans";
|
||||
case SheepState.BLACK_LEFT_HURT -> "mobs/sheep/black/lefthurt.ans";
|
||||
case SheepState.BLACK_RIGHT_HURT -> "mobs/sheep/black/righthurt.ans";
|
||||
|
||||
case SheepState.BROWN_LEFT -> "mobs/sheep/brown/left.ans";
|
||||
case SheepState.BROWN_RIGHT -> "mobs/sheep/brown/right.ans";
|
||||
case SheepState.BROWN_LEFT_HURT -> "mobs/sheep/brown/lefthurt.ans";
|
||||
case SheepState.BROWN_RIGHT_HURT -> "mobs/sheep/brown/righthurt.ans";
|
||||
|
||||
case SheepState.PINK_LEFT -> "mobs/sheep/pink/left.ans";
|
||||
case SheepState.PINK_RIGHT -> "mobs/sheep/pink/right.ans";
|
||||
case SheepState.PINK_LEFT_HURT -> "mobs/sheep/pink/lefthurt.ans";
|
||||
case SheepState.PINK_RIGHT_HURT -> "mobs/sheep/pink/righthurt.ans";
|
||||
|
||||
default -> throw new IllegalStateException("Unexpected value: " + e);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user