feat: Fixed textures and minor changes
This commit is contained in:
@ -41,14 +41,14 @@ public class SpriteLoader {
|
||||
|
||||
static {
|
||||
SPRITES_MAP.put(SPRITES.AIR, new Air());
|
||||
SPRITES_MAP.put(SPRITES.DIRT, new Dirt());
|
||||
SPRITES_MAP.put(SPRITES.DIRT, new SimpleSprite("dirt.ans"));
|
||||
SPRITES_MAP.put(SPRITES.GRASS, new Grass());
|
||||
SPRITES_MAP.put(SPRITES.STONE, new Stone());
|
||||
SPRITES_MAP.put(SPRITES.STONE, new SimpleSprite("stone.ans"));
|
||||
SPRITES_MAP.put(SPRITES.STEVE, new Steve());
|
||||
SPRITES_MAP.put(SPRITES.BEDROCK, new Bedrock());
|
||||
SPRITES_MAP.put(SPRITES.BEDROCK, new SimpleSprite("bedrock.ans"));
|
||||
SPRITES_MAP.put(SPRITES.BREAKING, new Breaking());
|
||||
SPRITES_MAP.put(SPRITES.OAK_LOG, new OakLog());
|
||||
SPRITES_MAP.put(SPRITES.OAK_LEAF, new OakLeaf());
|
||||
SPRITES_MAP.put(SPRITES.OAK_LOG, new SimpleSprite("oak_log.ans"));
|
||||
SPRITES_MAP.put(SPRITES.OAK_LEAF, new SimpleSprite("oak_leaf.ans"));
|
||||
SPRITES_MAP.put(SPRITES.OAK_PLANKS, new SimpleSprite("oak_planks.ans"));
|
||||
SPRITES_MAP.put(SPRITES.CRAFTING_TABLE, new SimpleSprite("crafting_table.ans"));
|
||||
SPRITES_MAP.put(SPRITES.COBBLESTONE, new SimpleSprite("cobblestone.ans"));
|
||||
|
@ -6,7 +6,7 @@ import cz.jzitnik.game.items.ItemBlockSupplier;
|
||||
import java.util.*;
|
||||
|
||||
public class CraftingRecipeList {
|
||||
private static List<CraftingRecipe> recipes = new ArrayList<>();
|
||||
private static final List<CraftingRecipe> recipes = new ArrayList<>();
|
||||
|
||||
static {
|
||||
// Oak planks
|
||||
|
@ -21,7 +21,7 @@ public class Item {
|
||||
private int stackAmount = 64;
|
||||
private Optional<Block> block = Optional.empty();
|
||||
|
||||
public Item(String id, String name, ItemType type, SpriteLoader.SPRITES sprite, ToolVariant toolVariant, double miningDecrease, int durability) {
|
||||
public Item(String id, String name, ItemType type, SpriteLoader.SPRITES sprite, ToolVariant toolVariant, double miningDecrease, int durability, boolean stackable) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
@ -29,6 +29,7 @@ public class Item {
|
||||
this.toolVariant = Optional.of(toolVariant);
|
||||
this.miningDecrease = miningDecrease;
|
||||
this.durability = durability;
|
||||
this.stackable = stackable;
|
||||
}
|
||||
|
||||
public Item(String id, String name, ItemType type, SpriteLoader.SPRITES sprite, Block block) {
|
||||
|
@ -80,19 +80,19 @@ public class ItemBlockSupplier {
|
||||
return Helper.craftingTable(Blocks.craftingTable());
|
||||
}
|
||||
public static Item woodenPickaxe() {
|
||||
return new Item("wooden_pickaxe", "Wooden pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.WOODEN_PICKAXE, ToolVariant.WOODEN, 12, 59);
|
||||
return new Item("wooden_pickaxe", "Wooden pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.WOODEN_PICKAXE, ToolVariant.WOODEN, 12, 59, false);
|
||||
}
|
||||
public static Item woodenAxe() {
|
||||
return new Item("wooden_axe", "Wooden axe", ItemType.AXE, SpriteLoader.SPRITES.WOODEN_AXE, ToolVariant.WOODEN, 2, 59);
|
||||
return new Item("wooden_axe", "Wooden axe", ItemType.AXE, SpriteLoader.SPRITES.WOODEN_AXE, ToolVariant.WOODEN, 2, 59, false);
|
||||
}
|
||||
public static Item cobblestone() {
|
||||
return Helper.cobblestone(Blocks.cobblestone());
|
||||
}
|
||||
public static Item stonePickaxe() {
|
||||
return new Item("stone_pickaxe", "Stone pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.STONE_PICKAXE, ToolVariant.STONE, 12.5, 132);
|
||||
return new Item("stone_pickaxe", "Stone pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.STONE_PICKAXE, ToolVariant.STONE, 12.5, 132, false);
|
||||
}
|
||||
public static Item stoneAxe() {
|
||||
return new Item("stone_axe", "Stone axe", ItemType.AXE, SpriteLoader.SPRITES.STONE_AXE, ToolVariant.STONE, 3, 132);
|
||||
return new Item("stone_axe", "Stone axe", ItemType.AXE, SpriteLoader.SPRITES.STONE_AXE, ToolVariant.STONE, 3, 132, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ public class Air extends Sprite {
|
||||
public String getSprite() {
|
||||
StringBuilder sprite = new StringBuilder();
|
||||
for (int i = 0; i < 25; i++) {
|
||||
sprite.append("\033[0m ".repeat(50));
|
||||
sprite.append("\033[48;2;121;166;255m ".repeat(50));
|
||||
sprite.append("\n");
|
||||
}
|
||||
return sprite.toString();
|
||||
|
@ -1,14 +0,0 @@
|
||||
package cz.jzitnik.game.sprites;
|
||||
|
||||
import cz.jzitnik.tui.ResourceLoader;
|
||||
import cz.jzitnik.tui.Sprite;
|
||||
|
||||
public class Bedrock extends Sprite {
|
||||
public String getSprite() {
|
||||
return ResourceLoader.loadResource("bedrock.ans");
|
||||
}
|
||||
|
||||
public String getSprite(Enum key) {
|
||||
throw new RuntimeException("Imposible state");
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package cz.jzitnik.game.sprites;
|
||||
|
||||
import cz.jzitnik.tui.ResourceLoader;
|
||||
import cz.jzitnik.tui.Sprite;
|
||||
|
||||
public class Dirt extends Sprite {
|
||||
public String getSprite() {
|
||||
return ResourceLoader.loadResource("dirt.ans");
|
||||
}
|
||||
|
||||
public String getSprite(Enum key) {
|
||||
throw new RuntimeException("Imposible state");
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cz.jzitnik.game.sprites;
|
||||
|
||||
import cz.jzitnik.tui.ResourceLoader;
|
||||
import cz.jzitnik.tui.Sprite;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class OakLeaf extends Sprite {
|
||||
private String fix(String x) {
|
||||
return x.replaceAll("\033\\[38;5;1;48;5;16m", "\033[0m");
|
||||
}
|
||||
|
||||
public String getSprite() {
|
||||
return fix(Objects.requireNonNull(ResourceLoader.loadResource("oak_leaf.ans")));
|
||||
}
|
||||
|
||||
public String getSprite(Enum key) {
|
||||
throw new RuntimeException("Imposible state");
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package cz.jzitnik.game.sprites;
|
||||
|
||||
import cz.jzitnik.tui.ResourceLoader;
|
||||
import cz.jzitnik.tui.Sprite;
|
||||
|
||||
public class OakLog extends Sprite {
|
||||
public String getSprite() {
|
||||
return ResourceLoader.loadResource("oak_log.ans");
|
||||
}
|
||||
|
||||
public String getSprite(Enum key) {
|
||||
throw new RuntimeException("Imposible state");
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ public class SimpleSprite extends Sprite {
|
||||
}
|
||||
|
||||
public String getSprite() {
|
||||
return ResourceLoader.loadResource(resource).replaceAll("\033\\[38;5;1;48;5;16m", "\033[0m");
|
||||
return ResourceLoader.loadResource(resource).replaceAll("\033\\[38;5;1;48;5;16m", "\033[49m");
|
||||
}
|
||||
|
||||
public String getSprite(Enum key) {
|
||||
|
@ -8,7 +8,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Steve extends Sprite {
|
||||
private String fix(String x) {
|
||||
var arr = x.replaceAll("\033\\[38;5;1;48;5;16m", "\033[0m").split("\n");
|
||||
var arr = x.replaceAll("\033\\[38;5;1;48;5;16m", "\033[49m").split("\n");
|
||||
arr = Arrays.copyOf(arr, arr.length - 1); // Remove the last line
|
||||
return ("\033[0m ".repeat(50) + "\n").repeat(3) + Arrays.stream(arr).map(y -> "\033[0m ".repeat(12) + y + " " + "\033[0m ".repeat(12) + "\n").collect(Collectors.joining());
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
package cz.jzitnik.game.sprites;
|
||||
|
||||
import cz.jzitnik.tui.ResourceLoader;
|
||||
import cz.jzitnik.tui.Sprite;
|
||||
|
||||
public class Stone extends Sprite {
|
||||
public String getSprite() {
|
||||
return ResourceLoader.loadResource("stone.ans");
|
||||
}
|
||||
|
||||
public String getSprite(Enum key) {
|
||||
throw new RuntimeException("Imposible state");
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class CraftingTable {
|
||||
private Game game;
|
||||
private final Game game;
|
||||
private static final int ROW_AMOUNT = 3;
|
||||
private static final int COLUMN_AMOUNT = 3;
|
||||
private static final int CELL_WIDTH = 50;
|
||||
|
@ -310,6 +310,10 @@ public class Inventory {
|
||||
return; // Nothing to merge
|
||||
}
|
||||
|
||||
if (!fromItem.getItem().isStackable() || !toItem.getItem().isStackable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fromItem.getItem().equals(toItem.getItem())) {
|
||||
return; // Different items cannot be merged
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class SpriteCombiner {
|
||||
if (pixelIndex2 >= row2.length()) break; // Avoid out-of-bounds
|
||||
char pixel2 = row2.charAt(pixelIndex2);
|
||||
|
||||
if (color2.equals("\033[0m") && pixel2 == ' ') {
|
||||
if (color2.equals("\033[0m") && pixel2 == ' ' || color2.equals("\033[49m") && pixel2 == ' ') {
|
||||
combinedRow.append(color1).append(pixel1);
|
||||
} else {
|
||||
combinedRow.append(color2).append(pixel2);
|
||||
|
Reference in New Issue
Block a user