lint: Linting and formatting

This commit is contained in:
Jakub Žitník 2025-03-07 11:36:43 +01:00
parent 05e76bd0d0
commit ee12ccb6d7
Signed by: jzitnik
GPG Key ID: C577A802A6AF4EF3
162 changed files with 1252 additions and 1138 deletions

34
pom.xml
View File

@ -16,6 +16,22 @@
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.25.0</version>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
<configuration>
<configFile>${basedir}/checkstyle.xml</configFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
@ -70,6 +86,24 @@
<classpathScope>compile</classpathScope> <!-- This ensures the compiled classes are included --> <classpathScope>compile</classpathScope> <!-- This ensures the compiled classes are included -->
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<configLocation>src/main/resources/config/checkstyle/checkstyle.xml</configLocation>
<failsOnError>true</failsOnError> <!-- Fail build if there are style violations -->
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal> <!-- Run Checkstyle in the validate phase -->
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>

View File

@ -30,7 +30,7 @@ public class Main {
var screenRenderer = new ScreenRenderer(spriteList, terminal); var screenRenderer = new ScreenRenderer(spriteList, terminal);
var game = new Game(); var game = new Game();
final boolean[] isRunning = {true}; final boolean[] isRunning = { true };
Thread inputHandlerThread = new InputHandlerThread(game, terminal, screenRenderer, isRunning); Thread inputHandlerThread = new InputHandlerThread(game, terminal, screenRenderer, isRunning);
Thread healingThread = new HealthRegenerationThread(game.getPlayer()); Thread healingThread = new HealthRegenerationThread(game.getPlayer());
@ -51,9 +51,10 @@ public class Main {
} }
try { try {
customLogicProvider.update(game); customLogicProvider.update(game);
} catch (Exception _) {} } catch (Exception _) {
}
if (game.getWindow() == Window.WORLD) { if ( game.getWindow() == Window.WORLD) {
screenRenderer.render(game); screenRenderer.render(game);
} }

View File

@ -49,8 +49,9 @@ public class Game {
for (int i = 0; i < world.length; i++) { for (int i = 0; i < world.length; i++) {
for (int j = 0; j < world[i].length; j++) { for (int j = 0; j < world[i].length; j++) {
for (Block block : world[i][j]) { for (Block block : world[i][j]) {
if (block.getBlockId().equals("steve") && block.getSpriteState().isPresent() && block.getSpriteState().get() == Steve.SteveState.SECOND) { if (block.getBlockId().equals("steve") && block.getSpriteState().isPresent()
return new int[]{j, i}; && block.getSpriteState().get() == Steve.SteveState.SECOND) {
return new int[] { j, i };
} }
} }
} }
@ -70,8 +71,8 @@ public class Game {
world[cords[1]][cords[0] + 1].add(player.getPlayerBlock2()); world[cords[1]][cords[0] + 1].add(player.getPlayerBlock2());
world[cords[1]][cords[0]].remove(player.getPlayerBlock2()); world[cords[1]][cords[0]].remove(player.getPlayerBlock2());
world[cords[1]-1][cords[0] + 1].add(player.getPlayerBlock1()); world[cords[1] - 1][cords[0] + 1].add(player.getPlayerBlock1());
world[cords[1]-1][cords[0]].remove(player.getPlayerBlock1()); world[cords[1] - 1][cords[0]].remove(player.getPlayerBlock1());
screenRenderer.render(this); screenRenderer.render(this);
entitySpawnProvider.update(this, terminal); entitySpawnProvider.update(this, terminal);
@ -91,8 +92,8 @@ public class Game {
world[cords[1]][cords[0] - 1].add(player.getPlayerBlock2()); world[cords[1]][cords[0] - 1].add(player.getPlayerBlock2());
world[cords[1]][cords[0]].remove(player.getPlayerBlock2()); world[cords[1]][cords[0]].remove(player.getPlayerBlock2());
world[cords[1]-1][cords[0] - 1].add(player.getPlayerBlock1()); world[cords[1] - 1][cords[0] - 1].add(player.getPlayerBlock1());
world[cords[1]-1][cords[0]].remove(player.getPlayerBlock1()); world[cords[1] - 1][cords[0]].remove(player.getPlayerBlock1());
screenRenderer.render(this); screenRenderer.render(this);
entitySpawnProvider.update(this, terminal); entitySpawnProvider.update(this, terminal);
@ -141,7 +142,8 @@ public class Game {
world[y][x].remove(mob); world[y][x].remove(mob);
} else { } else {
mob.decreaseHp(dealDamage); mob.decreaseHp(dealDamage);
mob.setSpriteState(gameStates.dependencies.entityHurtAnimation.get(mob.getBlockId()).setHurtAnimation(true, mob.getSpriteState().get())); mob.setSpriteState(gameStates.dependencies.entityHurtAnimation.get(mob.getBlockId())
.setHurtAnimation(true, mob.getSpriteState().get()));
} }
} }
screenRenderer.render(this); screenRenderer.render(this);
@ -154,7 +156,8 @@ public class Game {
} }
for (Block mob : mobs) { for (Block mob : mobs) {
mob.setSpriteState(gameStates.dependencies.entityHurtAnimation.get(mob.getBlockId()).setHurtAnimation(false, mob.getSpriteState().get())); mob.setSpriteState(gameStates.dependencies.entityHurtAnimation.get(mob.getBlockId())
.setHurtAnimation(false, mob.getSpriteState().get()));
} }
screenRenderer.render(this); screenRenderer.render(this);
}).start(); }).start();
@ -169,7 +172,8 @@ public class Game {
world[y][x].add(breakingBlock); world[y][x].add(breakingBlock);
screenRenderer.render(this); screenRenderer.render(this);
double hardness = world[y][x].stream().filter(block -> !block.isGhost()).toList().getFirst().calculateHardness(inventory); double hardness = world[y][x].stream().filter(block -> !block.isGhost()).toList().getFirst()
.calculateHardness(inventory);
this.mining = true; this.mining = true;
@ -200,7 +204,7 @@ public class Game {
var blocks = world[y][x]; var blocks = world[y][x];
for (Block block : blocks) { for (Block block : blocks) {
if (!block.isMineable()) { if (!block.isMineable()) {
continue; continue;
} }
@ -211,7 +215,10 @@ public class Game {
} }
var toolVariants = block.getToolVariants(); var toolVariants = block.getToolVariants();
if (inventory.getItemInHand().isPresent() && inventory.getItemInHand().get().getToolVariant().isPresent() && block.getTool().isPresent() && block.getTool().get().equals(inventory.getItemInHand().get().getType()) && toolVariants.contains(inventory.getItemInHand().get().getToolVariant().get())) { if (inventory.getItemInHand().isPresent()
&& inventory.getItemInHand().get().getToolVariant().isPresent() && block.getTool().isPresent()
&& block.getTool().get().equals(inventory.getItemInHand().get().getType())
&& toolVariants.contains(inventory.getItemInHand().get().getToolVariant().get())) {
block.getDrops().forEach(inventory::addItem); block.getDrops().forEach(inventory::addItem);
} }
} }
@ -224,7 +231,8 @@ public class Game {
} }
} }
CustomPlaceHandler customPlaceHandler = gameStates.dependencies.placeHandler.get(blocks.stream().filter(Block::isMineable).toList().getFirst().getBlockId()); CustomPlaceHandler customPlaceHandler = gameStates.dependencies.placeHandler
.get(blocks.stream().filter(Block::isMineable).toList().getFirst().getBlockId());
customPlaceHandler.mine(this, x, y); customPlaceHandler.mine(this, x, y);
inventory.getItemInHand().ifPresent(Item::use); inventory.getItemInHand().ifPresent(Item::use);
@ -245,18 +253,16 @@ public class Game {
int distanceX = Math.abs(playerX - x); int distanceX = Math.abs(playerX - x);
int distanceY = Math.abs(playerY - y); int distanceY = Math.abs(playerY - y);
int[] data = ScreenMovingCalculationProvider.calculate(playerX, playerY, terminal.getHeight(), terminal.getWidth(), world[0].length, world.length); int[] data = ScreenMovingCalculationProvider.calculate(playerX, playerY, terminal.getHeight(),
terminal.getWidth(), world[0].length, world.length);
int startX = data[0]; int startX = data[0];
int endX = data[1]; int endX = data[1];
int startY = data[2]; int startY = data[2];
int endY = data[3]; int endY = data[3];
return return y >= startY && y < endY - 1 && x >= startX && x < endX - 1 && distanceX <= 5 && distanceY <= 5
y >= startY && y < endY - 1 && x >= startX && x < endX - 1 && !(playerX == x && playerY == y) && !(playerX == x && playerY - 1 == y)
&& distanceX <= 5 && distanceY <= 5
&& !(playerX == x && playerY == y)
&& !(playerX == x && playerY - 1 == y)
&& blocks.stream().anyMatch(Block::isMineable); && blocks.stream().anyMatch(Block::isMineable);
} }
@ -271,18 +277,16 @@ public class Game {
int distanceX = Math.abs(playerX - x); int distanceX = Math.abs(playerX - x);
int distanceY = Math.abs(playerY - y); int distanceY = Math.abs(playerY - y);
int[] data = ScreenMovingCalculationProvider.calculate(playerX, playerY, terminal.getHeight(), terminal.getWidth(), world[0].length, world.length); int[] data = ScreenMovingCalculationProvider.calculate(playerX, playerY, terminal.getHeight(),
terminal.getWidth(), world[0].length, world.length);
int startX = data[0]; int startX = data[0];
int endX = data[1]; int endX = data[1];
int startY = data[2]; int startY = data[2];
int endY = data[3]; int endY = data[3];
return return y >= startY && y < endY - 1 && x >= startX && x < endX - 1 && distanceX <= 5 && distanceY <= 5
y >= startY && y < endY - 1 && x >= startX && x < endX - 1 && !(playerX == x && playerY == y) && !(playerX == x && playerY - 1 == y)
&& distanceX <= 5 && distanceY <= 5
&& !(playerX == x && playerY == y)
&& !(playerX == x && playerY - 1 == y)
&& blocks.stream().anyMatch(Block::isMob); && blocks.stream().anyMatch(Block::isMob);
} }
@ -340,9 +344,11 @@ public class Game {
} }
if (inventory.getItemInHand().isPresent() && inventory.getItemInHand().get().getType() == ItemType.PICKUPER) { if (inventory.getItemInHand().isPresent() && inventory.getItemInHand().get().getType() == ItemType.PICKUPER) {
if (gameStates.dependencies.pickupHandlerProvider.get(inventory.getItemInHand().get().getId()).handle(this, x, y)) { if (gameStates.dependencies.pickupHandlerProvider.get(inventory.getItemInHand().get().getId()).handle(this,
x, y)) {
screenRenderer.render(this); screenRenderer.render(this);
}; }
;
return; return;
} }

View File

@ -12,127 +12,54 @@ public class SpriteLoader {
// BLOCKS // BLOCKS
// Blocks // Blocks
AIR, AIR, WATER, LAVA, DIRT, GRASS, STONE, BEDROCK, COBBLESTONE, WOOL, OAK_LOG, OAK_LEAF, OAK_PLANKS, OAK_DOOR,
WATER,
LAVA,
DIRT,
GRASS,
STONE,
BEDROCK,
COBBLESTONE,
WOOL,
OAK_LOG,
OAK_LEAF,
OAK_PLANKS,
OAK_DOOR,
// Ores // Ores
COAL_ORE, COAL_ORE, IRON_ORE, GOLD_ORE, DIAMOND_ORE,
IRON_ORE,
GOLD_ORE,
DIAMOND_ORE,
COAL_BLOCK, COAL_BLOCK, IRON_BLOCK, GOLD_BLOCK, DIAMOND_BLOCK,
IRON_BLOCK,
GOLD_BLOCK,
DIAMOND_BLOCK,
// Work // Work
FURNACE, FURNACE, CHEST, CRAFTING_TABLE, BED,
CHEST,
CRAFTING_TABLE,
BED,
// ENTITIES // ENTITIES
STEVE, STEVE, PIG, SHEEP, COW,
PIG,
SHEEP,
COW,
// UI // UI
BREAKING, BREAKING, HEART, HUNGER,
HEART,
HUNGER,
// ITEMS // ITEMS
// Items // Items
ITEM_STICK, ITEM_STICK, ITEM_LEATHER,
ITEM_LEATHER,
// Block Items // Block Items
ITEM_DIRT, ITEM_DIRT, ITEM_OAK_LOG, ITEM_OAK_PLANKS, ITEM_COBBLESTONE, ITEM_STONE, ITEM_OAK_DOOR, ITEM_WOOL,
ITEM_OAK_LOG,
ITEM_OAK_PLANKS,
ITEM_COBBLESTONE,
ITEM_STONE,
ITEM_OAK_DOOR,
ITEM_WOOL,
// Ore Items // Ore Items
ITEM_COAL_ORE, ITEM_COAL_ORE, ITEM_IRON_ORE, ITEM_GOLD_ORE, ITEM_DIAMOND_ORE,
ITEM_IRON_ORE,
ITEM_GOLD_ORE,
ITEM_DIAMOND_ORE,
ITEM_COAL_BLOCK, ITEM_COAL_BLOCK, ITEM_IRON_BLOCK, ITEM_GOLD_BLOCK, ITEM_DIAMOND_BLOCK,
ITEM_IRON_BLOCK,
ITEM_GOLD_BLOCK,
ITEM_DIAMOND_BLOCK,
COAL, COAL, ITEM_IRON_INGOT, ITEM_GOLD_INGOT, DIAMOND,
ITEM_IRON_INGOT,
ITEM_GOLD_INGOT,
DIAMOND,
// Work Items // Work Items
ITEM_CRAFTING_TABLE, ITEM_CRAFTING_TABLE, ITEM_CHEST, ITEM_FURNACE, ITEM_BED,
ITEM_CHEST,
ITEM_FURNACE,
ITEM_BED,
// Tools // Tools
WOODEN_SWORD, WOODEN_SWORD, WOODEN_PICKAXE, WOODEN_AXE, WOODEN_SHOVEL, WOODEN_HOE,
WOODEN_PICKAXE,
WOODEN_AXE,
WOODEN_SHOVEL,
WOODEN_HOE,
STONE_SWORD, STONE_SWORD, STONE_PICKAXE, STONE_AXE, STONE_SHOVEL, STONE_HOE,
STONE_PICKAXE,
STONE_AXE,
STONE_SHOVEL,
STONE_HOE,
IRON_SWORD, IRON_SWORD, IRON_PICKAXE, IRON_AXE, IRON_SHOVEL, IRON_HOE,
IRON_PICKAXE,
IRON_AXE,
IRON_SHOVEL,
IRON_HOE,
GOLDEN_SWORD, GOLDEN_SWORD, GOLDEN_PICKAXE, GOLDEN_AXE, GOLDEN_SHOVEL, GOLDEN_HOE,
GOLDEN_PICKAXE,
GOLDEN_AXE,
GOLDEN_SHOVEL,
GOLDEN_HOE,
DIAMOND_SWORD, DIAMOND_SWORD, DIAMOND_PICKAXE, DIAMOND_AXE, DIAMOND_SHOVEL, DIAMOND_HOE,
DIAMOND_PICKAXE,
DIAMOND_AXE,
DIAMOND_SHOVEL,
DIAMOND_HOE,
BUCKET, BUCKET, WATER_BUCKET, LAVA_BUCKET, MILK_BUCKET,
WATER_BUCKET,
LAVA_BUCKET,
MILK_BUCKET,
// Food // Food
ITEM_PORKCHOP, ITEM_PORKCHOP, ITEM_COOKED_PORKCHOP, ITEM_MUTTON, ITEM_COOKED_MUTTON, ITEM_BEEF, ITEM_STEAK,
ITEM_COOKED_PORKCHOP,
ITEM_MUTTON,
ITEM_COOKED_MUTTON,
ITEM_BEEF,
ITEM_STEAK,
} }
public static final HashMap<SPRITES, Sprite> SPRITES_MAP = new HashMap<>(); public static final HashMap<SPRITES, Sprite> SPRITES_MAP = new HashMap<>();
@ -164,7 +91,7 @@ public class SpriteLoader {
SPRITES_MAP.put(SPRITES.COAL_BLOCK, new SimpleSprite("coal_block.ans")); SPRITES_MAP.put(SPRITES.COAL_BLOCK, new SimpleSprite("coal_block.ans"));
SPRITES_MAP.put(SPRITES.IRON_BLOCK, new SimpleSprite("iron_block.ans")); SPRITES_MAP.put(SPRITES.IRON_BLOCK, new SimpleSprite("iron_block.ans"));
SPRITES_MAP.put(SPRITES.GOLD_BLOCK, new SimpleSprite("gold_block.ans")); SPRITES_MAP.put(SPRITES.GOLD_BLOCK, new SimpleSprite("gold_block.ans"));
SPRITES_MAP.put(SPRITES.DIAMOND_BLOCK, new SimpleSprite("diamond_block.ans")); //NEWW SPRITES_MAP.put(SPRITES.DIAMOND_BLOCK, new SimpleSprite("diamond_block.ans")); // NEWW
// Work // Work
SPRITES_MAP.put(SPRITES.CRAFTING_TABLE, new SimpleSprite("crafting_table.ans")); SPRITES_MAP.put(SPRITES.CRAFTING_TABLE, new SimpleSprite("crafting_table.ans"));

View File

@ -9,5 +9,6 @@ import java.lang.annotation.ElementType;
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
public @interface BlockRegistry { public @interface BlockRegistry {
String value(); String value();
String drops() default ""; String drops() default "";
} }

View File

@ -6,7 +6,10 @@ import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface CraftingRecipeRegistry { public @interface CraftingRecipeRegistry {
String[] recipe(); String[] recipe();
String result(); String result();
int amount(); int amount();
boolean usingRegex() default false; boolean usingRegex() default false;
} }

View File

@ -9,5 +9,6 @@ import java.lang.annotation.ElementType;
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
public @interface ItemRegistry { public @interface ItemRegistry {
String value(); String value();
String block() default ""; String block() default "";
} }

View File

@ -70,13 +70,16 @@ public class Chest implements RightClickHandler {
int heightPixels = ROW_AMOUNT * (CELL_HEIGHT) - 10; int heightPixels = ROW_AMOUNT * (CELL_HEIGHT) - 10;
int moveLeft = Math.max(0, (terminal.getWidth() / 2) - (widthPixels / 2)); int moveLeft = Math.max(0, (terminal.getWidth() / 2) - (widthPixels / 2));
if (x > moveLeft && x <= moveLeft + widthPixels && y > 0 && y <= heightPixels && mouseEvent.getType() == MouseEvent.Type.Pressed) { if (x > moveLeft && x <= moveLeft + widthPixels && y > 0 && y <= heightPixels
if (mouseEvent.getType() != MouseEvent.Type.Pressed) return; && mouseEvent.getType() == MouseEvent.Type.Pressed) {
if (mouseEvent.getType() != MouseEvent.Type.Pressed)
return;
int blockX = (x - moveLeft) / 52; int blockX = (x - moveLeft) / 52;
int blockY = y / 26; int blockY = y / 26;
InventoryClickHandler.handleItemClick(mouseEvent, game.getInventory(), items, blockY * COLUMN_AMOUNT + blockX, 50, Optional.of(items)); InventoryClickHandler.handleItemClick(mouseEvent, game.getInventory(), items,
blockY * COLUMN_AMOUNT + blockX, 50, Optional.of(items));
screenRenderer.render(game); screenRenderer.render(game);
@ -84,7 +87,8 @@ public class Chest implements RightClickHandler {
} }
// TODO: Why I need to add 20 here. Like wtf // TODO: Why I need to add 20 here. Like wtf
InventoryClickHandler.click(mouseEvent, terminal, screenRenderer, game, Optional.of(size + 20), Optional.of(items)); InventoryClickHandler.click(mouseEvent, terminal, screenRenderer, game, Optional.of(size + 20),
Optional.of(items));
} }
public void breakBlock(Game game) { public void breakBlock(Game game) {

View File

@ -43,12 +43,13 @@ public class Furnace implements RightClickHandler {
List<String> sprites = game.getInventory().getSprites(items, spriteList, inventory.getSelectedItemInv() - 50); List<String> sprites = game.getInventory().getSprites(items, spriteList, inventory.getSelectedItemInv() - 50);
String[] outputSprite = outputItem == null ? null : SpriteCombiner.combineTwoSprites( String[] outputSprite = outputItem == null ? null
outputItem.getItem().getFirst().getSpriteState().isPresent() ? : SpriteCombiner.combineTwoSprites(
spriteList.getSprite(outputItem.getItem().getFirst().getSprite()).getSprite(outputItem.getItem().getFirst().getSpriteState().get()) : outputItem.getItem().getFirst().getSpriteState().isPresent()
spriteList.getSprite(outputItem.getItem().getFirst().getSprite()).getSprite() , ? spriteList.getSprite(outputItem.getItem().getFirst().getSprite())
Numbers.getNumberSprite(outputItem.getAmount()) .getSprite(outputItem.getItem().getFirst().getSpriteState().get())
).split("\n"); : spriteList.getSprite(outputItem.getItem().getFirst().getSprite()).getSprite(),
Numbers.getNumberSprite(outputItem.getAmount())).split("\n");
for (int j = 0; j < CELL_HEIGHT; j++) { for (int j = 0; j < CELL_HEIGHT; j++) {
buffer.append("\033[0m").append(" ".repeat(moveLeft)); buffer.append("\033[0m").append(" ".repeat(moveLeft));
@ -122,7 +123,8 @@ public class Furnace implements RightClickHandler {
int widthPixels = COLUMN_AMOUNT * (CELL_WIDTH + BORDER_SIZE) + BORDER_SIZE; int widthPixels = COLUMN_AMOUNT * (CELL_WIDTH + BORDER_SIZE) + BORDER_SIZE;
int moveLeft = Math.max(0, (terminal.getWidth() / 2) - (widthPixels / 2)); int moveLeft = Math.max(0, (terminal.getWidth() / 2) - (widthPixels / 2));
if (x > moveLeft && x <= moveLeft + CELL_WIDTH + BORDER_SIZE && y > 0 && y < CELL_HEIGHT && mouseEvent.getType() == MouseEvent.Type.Pressed) { if (x > moveLeft && x <= moveLeft + CELL_WIDTH + BORDER_SIZE && y > 0 && y < CELL_HEIGHT
&& mouseEvent.getType() == MouseEvent.Type.Pressed) {
InventoryItem selectedItem = game.getInventory().getSelectedItemNo(Optional.of(items)); InventoryItem selectedItem = game.getInventory().getSelectedItemNo(Optional.of(items));
if (selectedItem != null && !Smelting.smeltingList.containsKey(selectedItem.getItem().getFirst().getId())) { if (selectedItem != null && !Smelting.smeltingList.containsKey(selectedItem.getItem().getFirst().getId())) {
return; return;
@ -132,10 +134,13 @@ public class Furnace implements RightClickHandler {
screenRenderer.render(game); screenRenderer.render(game);
checkSmelt(game, screenRenderer); checkSmelt(game, screenRenderer);
} else if (x > moveLeft + (2 * (2 * BORDER_SIZE + CELL_WIDTH)) && x <= moveLeft + (3 * (2 * BORDER_SIZE + CELL_WIDTH)) && y > CELL_HEIGHT && y <= 2*CELL_HEIGHT && mouseEvent.getType() == MouseEvent.Type.Pressed) { } else if (x > moveLeft + (2 * (2 * BORDER_SIZE + CELL_WIDTH))
&& x <= moveLeft + (3 * (2 * BORDER_SIZE + CELL_WIDTH)) && y > CELL_HEIGHT && y <= 2 * CELL_HEIGHT
&& mouseEvent.getType() == MouseEvent.Type.Pressed) {
pickup(game); pickup(game);
screenRenderer.render(game); screenRenderer.render(game);
} else if (x > moveLeft && x <= moveLeft + CELL_WIDTH + BORDER_SIZE && y > 2 * CELL_HEIGHT && y < 3 * CELL_HEIGHT && mouseEvent.getType() == MouseEvent.Type.Pressed) { } else if (x > moveLeft && x <= moveLeft + CELL_WIDTH + BORDER_SIZE && y > 2 * CELL_HEIGHT
&& y < 3 * CELL_HEIGHT && mouseEvent.getType() == MouseEvent.Type.Pressed) {
InventoryItem selectedItem = game.getInventory().getSelectedItemNo(Optional.of(items)); InventoryItem selectedItem = game.getInventory().getSelectedItemNo(Optional.of(items));
if (selectedItem != null && !Smelting.fuelList.containsKey(selectedItem.getItem().getFirst().getId())) { if (selectedItem != null && !Smelting.fuelList.containsKey(selectedItem.getItem().getFirst().getId())) {
return; return;
@ -146,13 +151,15 @@ public class Furnace implements RightClickHandler {
screenRenderer.render(game); screenRenderer.render(game);
checkSmelt(game, screenRenderer); checkSmelt(game, screenRenderer);
} else { } else {
InventoryClickHandler.click(mouseEvent, terminal, screenRenderer, game, Optional.of(size + 20), Optional.of(items)); InventoryClickHandler.click(mouseEvent, terminal, screenRenderer, game, Optional.of(size + 20),
Optional.of(items));
} }
} }
public void setSmelting(boolean smelting) { public void setSmelting(boolean smelting) {
this.smelting = smelting; this.smelting = smelting;
this.block.setSpriteState(smelting ? cz.jzitnik.game.sprites.Furnace.FurnaceState.ON : cz.jzitnik.game.sprites.Furnace.FurnaceState.OFF); this.block.setSpriteState(smelting ? cz.jzitnik.game.sprites.Furnace.FurnaceState.ON
: cz.jzitnik.game.sprites.Furnace.FurnaceState.OFF);
} }
public void checkSmelt(Game game, ScreenRenderer screenRenderer) { public void checkSmelt(Game game, ScreenRenderer screenRenderer) {

View File

@ -30,15 +30,14 @@ public class OakDoorData implements RightClickHandler {
var blocks = game.getWorld()[y][x]; var blocks = game.getWorld()[y][x];
var door = blocks.stream().filter(block -> block.getBlockId().equals("oak_door")).toList().getFirst(); var door = blocks.stream().filter(block -> block.getBlockId().equals("oak_door")).toList().getFirst();
switch (door.getSpriteState().get()) { switch (door.getSpriteState().get()) {
case OakDoor.OakDoorState.TOP, OakDoor.OakDoorState.TOPCLOSED -> { case OakDoor.OakDoorState.TOP, OakDoor.OakDoorState.TOPCLOSED -> {
var blocks2 = game.getWorld()[y+1][x]; var blocks2 = game.getWorld()[y + 1][x];
var door2 = blocks2.stream().filter(block -> block.getBlockId().equals("oak_door")).toList().getFirst(); var door2 = blocks2.stream().filter(block -> block.getBlockId().equals("oak_door")).toList().getFirst();
change(door2); change(door2);
} }
case OakDoor.OakDoorState.BOTTOM, OakDoor.OakDoorState.BOTTOMCLOSED -> { case OakDoor.OakDoorState.BOTTOM, OakDoor.OakDoorState.BOTTOMCLOSED -> {
var blocks2 = game.getWorld()[y-1][x]; var blocks2 = game.getWorld()[y - 1][x];
var door2 = blocks2.stream().filter(block -> block.getBlockId().equals("oak_door")).toList().getFirst(); var door2 = blocks2.stream().filter(block -> block.getBlockId().equals("oak_door")).toList().getFirst();
change(door2); change(door2);
} }

View File

@ -24,7 +24,8 @@ public class CraftingRecipeList {
String[][] recipeGrid = convertTo2DGrid(annotation.recipe()); String[][] recipeGrid = convertTo2DGrid(annotation.recipe());
recipes.add(new CraftingRecipe(recipeGrid, recipes.add(new CraftingRecipe(recipeGrid,
() -> new InventoryItem(annotation.amount(), ItemBlockSupplier.getItem(annotation.result())), annotation.usingRegex())); () -> new InventoryItem(annotation.amount(), ItemBlockSupplier.getItem(annotation.result())),
annotation.usingRegex()));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -104,7 +105,8 @@ public class CraftingRecipeList {
if (array1[i][j] == null && array2[i][j] != null) { if (array1[i][j] == null && array2[i][j] != null) {
return false; return false;
} }
if (array1[i][j] != null && (usingRegex ? !array2[i][j].matches(array1[i][j]) : !array1[i][j].equals(array2[i][j])) ) { if (array1[i][j] != null
&& (usingRegex ? !array2[i][j].matches(array1[i][j]) : !array1[i][j].equals(array2[i][j]))) {
return false; return false;
} }
} }

View File

@ -2,14 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "^.*_wool$", "^.*_wool$", "^.*_wool$", "^oak_planks$", "^oak_planks$",
recipe = { "^oak_planks$", "_", "_", "_" }, result = "bed", amount = 1, usingRegex = true)
"^.*_wool$", "^.*_wool$", "^.*_wool$", public class BedRecipe {
"^oak_planks$", "^oak_planks$", "^oak_planks$", }
"_", "_", "_"
},
result = "bed",
amount = 1,
usingRegex = true
)
public class BedRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "iron_ingot", "_", "iron_ingot", "_", "iron_ingot", "_", "_", "_",
recipe = { "_" }, result = "bucket", amount = 1)
"iron_ingot", "_", "iron_ingot", public class BucketRecipe {
"_", "iron_ingot", "_", }
"_", "_", "_"
},
result = "bucket",
amount = 1
)
public class BucketRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "oak_planks", "oak_planks", "oak_planks", "oak_planks", "_", "oak_planks",
recipe = { "oak_planks", "oak_planks", "oak_planks" }, result = "chest", amount = 1)
"oak_planks", "oak_planks", "oak_planks", public class ChestRecipe {
"oak_planks", "_", "oak_planks", }
"oak_planks", "oak_planks", "oak_planks"
},
result = "chest",
amount = 1
)
public class ChestRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "coal", "coal", "coal", "coal", "coal", "coal", "coal", "coal",
recipe = { "coal" }, result = "coal_block", amount = 1)
"coal", "coal", "coal", public class CoalBlockRecipe {
"coal", "coal", "coal", }
"coal", "coal", "coal"
},
result = "coal_block",
amount = 1
)
public class CoalBlockRecipe {}

View File

@ -2,13 +2,6 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "coal_block", "_", "_", "_", "_", "_", "_", "_", "_" }, result = "coal", amount = 9)
recipe = { public class CoalRecipe {
"coal_block", "_", "_", }
"_", "_", "_",
"_", "_", "_"
},
result = "coal",
amount = 9
)
public class CoalRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "oak_planks", "oak_planks", "_", "oak_planks", "oak_planks", "_", "_", "_",
recipe = { "_" }, result = "crafting_table", amount = 1)
"oak_planks", "oak_planks", "_", public class CraftingTableRecipe {
"oak_planks", "oak_planks", "_", }
"_", "_", "_"
},
result = "crafting_table",
amount = 1
)
public class CraftingTableRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "diamond", "diamond", "_", "stick", "diamond", "_", "stick",
recipe = { "_" }, result = "diamond_axe", amount = 1)
"_", "diamond", "diamond", public class DiamondAxe2Recipe {
"_", "stick", "diamond", }
"_", "stick", "_"
},
result = "diamond_axe",
amount = 1
)
public class DiamondAxe2Recipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "diamond", "diamond", "_", "diamond", "stick", "_", "_", "stick",
recipe = { "_" }, result = "diamond_axe", amount = 1)
"diamond", "diamond", "_", public class DiamondAxeRecipe {
"diamond", "stick", "_", }
"_", "stick", "_"
},
result = "diamond_axe",
amount = 1
)
public class DiamondAxeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "diamond", "diamond", "diamond", "diamond", "diamond", "diamond", "diamond",
recipe = { "diamond", "diamond" }, result = "diamond_block", amount = 1)
"diamond", "diamond", "diamond", public class DiamondBlockRecipe {
"diamond", "diamond", "diamond", }
"diamond", "diamond", "diamond"
},
result = "diamond_block",
amount = 1
)
public class DiamondBlockRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "diamond", "diamond", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "diamond_hoe", amount = 1)
"_", "diamond", "diamond", public class DiamondHoe2Recipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "diamond_hoe",
amount = 1
)
public class DiamondHoe2Recipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "diamond", "diamond", "_", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "diamond_hoe", amount = 1)
"diamond", "diamond", "_", public class DiamondHoeRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "diamond_hoe",
amount = 1
)
public class DiamondHoeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "diamond", "diamond", "diamond", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "diamond_pickaxe", amount = 1)
"diamond", "diamond", "diamond", public class DiamondPickaxeRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "diamond_pickaxe",
amount = 1
)
public class DiamondPickaxeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "diamond_block", "_", "_", "_", "_", "_", "_", "_",
recipe = { "_" }, result = "diamond", amount = 9)
"diamond_block", "_", "_", public class DiamondRecipe {
"_", "_", "_", }
"_", "_", "_"
},
result = "diamond",
amount = 9
)
public class DiamondRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "diamond", "_", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "diamond_shovel", amount = 1)
"_", "diamond", "_", public class DiamondShovelRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "diamond_shovel",
amount = 1
)
public class DiamondShovelRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "diamond", "_", "_", "diamond", "_", "_", "stick",
recipe = { "_" }, result = "diamond_sword", amount = 1)
"_", "diamond", "_", public class DiamondSwordRecipe {
"_", "diamond", "_", }
"_", "stick", "_"
},
result = "diamond_sword",
amount = 1
)
public class DiamondSwordRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "cobblestone", "cobblestone", "cobblestone", "cobblestone", "_", "cobblestone",
recipe = { "cobblestone", "cobblestone", "cobblestone" }, result = "furnace", amount = 1)
"cobblestone", "cobblestone", "cobblestone", public class FurnaceRecipe {
"cobblestone", "_", "cobblestone", }
"cobblestone", "cobblestone", "cobblestone"
},
result = "furnace",
amount = 1
)
public class FurnaceRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "gold_ingot", "gold_ingot", "gold_ingot", "gold_ingot", "gold_ingot", "gold_ingot",
recipe = { "gold_ingot", "gold_ingot", "gold_ingot" }, result = "gold_block", amount = 1)
"gold_ingot", "gold_ingot", "gold_ingot", public class GoldBlockRecipe {
"gold_ingot", "gold_ingot", "gold_ingot", }
"gold_ingot", "gold_ingot", "gold_ingot"
},
result = "gold_block",
amount = 1
)
public class GoldBlockRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "gold_block", "_", "_", "_", "_", "_", "_", "_",
recipe = { "_" }, result = "gold_ingot", amount = 9)
"gold_block", "_", "_", public class GoldIngotRecipe {
"_", "_", "_", }
"_", "_", "_"
},
result = "gold_ingot",
amount = 9
)
public class GoldIngotRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "gold_ingot", "gold_ingot", "_", "stick", "gold_ingot", "_", "stick",
recipe = { "_" }, result = "golden_axe", amount = 1)
"_", "gold_ingot", "gold_ingot", public class GoldenAxe2Recipe {
"_", "stick", "gold_ingot", }
"_", "stick", "_"
},
result = "golden_axe",
amount = 1
)
public class GoldenAxe2Recipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "gold_ingot", "gold_ingot", "_", "gold_ingot", "stick", "_", "_", "stick",
recipe = { "_" }, result = "golden_axe", amount = 1)
"gold_ingot", "gold_ingot", "_", public class GoldenAxeRecipe {
"gold_ingot", "stick", "_", }
"_", "stick", "_"
},
result = "golden_axe",
amount = 1
)
public class GoldenAxeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "gold_ingot", "gold_ingot", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "golden_hoe", amount = 1)
"_", "gold_ingot", "gold_ingot", public class GoldenHoe2Recipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "golden_hoe",
amount = 1
)
public class GoldenHoe2Recipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "gold_ingot", "gold_ingot", "_", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "golden_hoe", amount = 1)
"gold_ingot", "gold_ingot", "_", public class GoldenHoeRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "golden_hoe",
amount = 1
)
public class GoldenHoeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "gold_ingot", "gold_ingot", "gold_ingot", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "golden_pickaxe", amount = 1)
"gold_ingot", "gold_ingot", "gold_ingot", public class GoldenPickaxeRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "golden_pickaxe",
amount = 1
)
public class GoldenPickaxeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "gold_ingot", "_", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "golden_shovel", amount = 1)
"_", "gold_ingot", "_", public class GoldenShovelRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "golden_shovel",
amount = 1
)
public class GoldenShovelRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "gold_ingot", "_", "_", "gold_ingot", "_", "_", "stick",
recipe = { "_" }, result = "golden_sword", amount = 1)
"_", "gold_ingot", "_", public class GoldenSwordRecipe {
"_", "gold_ingot", "_", }
"_", "stick", "_"
},
result = "golden_sword",
amount = 1
)
public class GoldenSwordRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "iron_ingot", "iron_ingot", "_", "stick", "iron_ingot", "_", "stick",
recipe = { "_" }, result = "iron_axe", amount = 1)
"_", "iron_ingot", "iron_ingot", public class IronAxe2Recipe {
"_", "stick", "iron_ingot", }
"_", "stick", "_"
},
result = "iron_axe",
amount = 1
)
public class IronAxe2Recipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "iron_ingot", "iron_ingot", "_", "iron_ingot", "stick", "_", "_", "stick",
recipe = { "_" }, result = "iron_axe", amount = 1)
"iron_ingot", "iron_ingot", "_", public class IronAxeRecipe {
"iron_ingot", "stick", "_", }
"_", "stick", "_"
},
result = "iron_axe",
amount = 1
)
public class IronAxeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "iron_ingot", "iron_ingot", "iron_ingot", "iron_ingot", "iron_ingot", "iron_ingot",
recipe = { "iron_ingot", "iron_ingot", "iron_ingot" }, result = "iron_block", amount = 1)
"iron_ingot", "iron_ingot", "iron_ingot", public class IronBlockRecipe {
"iron_ingot", "iron_ingot", "iron_ingot", }
"iron_ingot", "iron_ingot", "iron_ingot"
},
result = "iron_block",
amount = 1
)
public class IronBlockRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "iron_ingot", "iron_ingot", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "iron_hoe", amount = 1)
"_", "iron_ingot", "iron_ingot", public class IronHoe2Recipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "iron_hoe",
amount = 1
)
public class IronHoe2Recipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "iron_ingot", "iron_ingot", "_", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "iron_hoe", amount = 1)
"iron_ingot", "iron_ingot", "_", public class IronHoeRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "iron_hoe",
amount = 1
)
public class IronHoeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "iron_block", "_", "_", "_", "_", "_", "_", "_",
recipe = { "_" }, result = "iron_ingot", amount = 9)
"iron_block", "_", "_", public class IronIngotRecipe {
"_", "_", "_", }
"_", "_", "_"
},
result = "iron_ingot",
amount = 9
)
public class IronIngotRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "iron_ingot", "iron_ingot", "iron_ingot", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "iron_pickaxe", amount = 1)
"iron_ingot", "iron_ingot", "iron_ingot", public class IronPickaxeRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "iron_pickaxe",
amount = 1
)
public class IronPickaxeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "iron_shovel", "_", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "iron_shovel", amount = 1)
"_", "iron_shovel", "_", public class IronShovelRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "iron_shovel",
amount = 1
)
public class IronShovelRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "iron_ingot", "_", "_", "iron_ingot", "_", "_", "stick",
recipe = { "_" }, result = "iron_sword", amount = 1)
"_", "iron_ingot", "_", public class IronSwordRecipe {
"_", "iron_ingot", "_", }
"_", "stick", "_"
},
result = "iron_sword",
amount = 1
)
public class IronSwordRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "oak_planks", "oak_planks", "_", "oak_planks", "oak_planks", "_", "oak_planks",
recipe = { "oak_planks", "_" }, result = "oak_door", amount = 3)
"oak_planks", "oak_planks", "_", public class OakDoorRecipe {
"oak_planks", "oak_planks", "_", }
"oak_planks", "oak_planks", "_"
},
result = "oak_door",
amount = 3
)
public class OakDoorRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "oak_log", "_", "_", "_", "_", "_", "_", "_",
recipe = { "_" }, result = "oak_planks", amount = 4)
"oak_log", "_", "_", public class OakPlanksRecipe {
"_", "_", "_", }
"_", "_", "_"
},
result = "oak_planks",
amount = 4
)
public class OakPlanksRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "oak_planks", "_", "_", "oak_planks", "_", "_", "_", "_",
recipe = { "_" }, result = "stick", amount = 4)
"oak_planks", "_", "_", public class StickRecipe {
"oak_planks", "_", "_", }
"_", "_", "_"
},
result = "stick",
amount = 4
)
public class StickRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "cobblestone", "cobblestone", "_", "stick", "cobblestone", "_", "stick",
recipe = { "_" }, result = "stone_pickaxe", amount = 1)
"_", "cobblestone", "cobblestone", public class StoneAxe2Recipe {
"_", "stick", "cobblestone", }
"_", "stick", "_"
},
result = "stone_pickaxe",
amount = 1
)
public class StoneAxe2Recipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "cobblestone", "cobblestone", "_", "cobblestone", "stick", "_", "_", "stick",
recipe = { "_" }, result = "stone_pickaxe", amount = 1)
"cobblestone", "cobblestone", "_", public class StoneAxeRecipe {
"cobblestone", "stick", "_", }
"_", "stick", "_"
},
result = "stone_pickaxe",
amount = 1
)
public class StoneAxeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "stone", "stone", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "stone_hoe", amount = 1)
"_", "stone", "stone", public class StoneHoe2Recipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "stone_hoe",
amount = 1
)
public class StoneHoe2Recipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "stone", "stone", "_", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "stone_hoe", amount = 1)
"stone", "stone", "_", public class StoneHoeRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "stone_hoe",
amount = 1
)
public class StoneHoeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "cobblestone", "cobblestone", "cobblestone", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "stone_pickaxe", amount = 1)
"cobblestone", "cobblestone", "cobblestone", public class StonePickaxeRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "stone_pickaxe",
amount = 1
)
public class StonePickaxeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "cobblestone", "_", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "stone_shovel", amount = 1)
"_", "cobblestone", "_", public class StoneShovelRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "stone_shovel",
amount = 1
)
public class StoneShovelRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "cobblestone", "_", "_", "cobblestone", "_", "_", "stick",
recipe = { "_" }, result = "stone_sword", amount = 1)
"_", "cobblestone", "_", public class StoneSwordRecipe {
"_", "cobblestone", "_", }
"_", "stick", "_"
},
result = "stone_sword",
amount = 1
)
public class StoneSwordRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "oak_planks", "oak_planks", "_", "stick", "oak_planks", "_", "stick",
recipe = { "_" }, result = "wooden_axe", amount = 1)
"_", "oak_planks", "oak_planks", public class WoodenAxe2Recipe {
"_", "stick", "oak_planks", }
"_", "stick", "_"
},
result = "wooden_axe",
amount = 1
)
public class WoodenAxe2Recipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "oak_planks", "oak_planks", "_", "oak_planks", "stick", "_", "_", "stick",
recipe = { "_" }, result = "wooden_axe", amount = 1)
"oak_planks", "oak_planks", "_", public class WoodenAxeRecipe {
"oak_planks", "stick", "_", }
"_", "stick", "_"
},
result = "wooden_axe",
amount = 1
)
public class WoodenAxeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "oak_planks", "oak_planks", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "wooden_hoe", amount = 1)
"_", "oak_planks", "oak_planks", public class WoodenHoe2Recipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "wooden_hoe",
amount = 1
)
public class WoodenHoe2Recipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "oak_planks", "oak_planks", "_", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "wooden_hoe", amount = 1)
"oak_planks", "oak_planks", "_", public class WoodenHoeRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "wooden_hoe",
amount = 1
)
public class WoodenHoeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "oak_planks", "oak_planks", "oak_planks", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "wooden_pickaxe", amount = 1)
"oak_planks", "oak_planks", "oak_planks", public class WoodenPickaxeRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "wooden_pickaxe",
amount = 1
)
public class WoodenPickaxeRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "oak_planks", "_", "_", "stick", "_", "_", "stick",
recipe = { "_" }, result = "wooden_shovel", amount = 1)
"_", "oak_planks", "_", public class WoodenShovelRecipe {
"_", "stick", "_", }
"_", "stick", "_"
},
result = "wooden_shovel",
amount = 1
)
public class WoodenShovelRecipe {}

View File

@ -2,13 +2,7 @@ package cz.jzitnik.game.crafting.recipes;
import cz.jzitnik.game.annotations.CraftingRecipeRegistry; import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
@CraftingRecipeRegistry( @CraftingRecipeRegistry(recipe = { "_", "oak_planks", "_", "_", "oak_planks", "_", "_", "stick",
recipe = { "_" }, result = "wooden_sword", amount = 1)
"_", "oak_planks", "_", public class WoodenSwordRecipe {
"_", "oak_planks", "_", }
"_", "stick", "_"
},
result = "wooden_sword",
amount = 1
)
public class WoodenSwordRecipe {}

View File

@ -47,7 +47,8 @@ public class Block {
this.hardness = hardness; this.hardness = hardness;
} }
public Block(String blockId, SpriteLoader.SPRITES sprite, int hardness, ItemType tool, List<ToolVariant> toolVariants) { public Block(String blockId, SpriteLoader.SPRITES sprite, int hardness, ItemType tool,
List<ToolVariant> toolVariants) {
this.blockId = blockId; this.blockId = blockId;
this.sprite = sprite; this.sprite = sprite;
this.hardness = hardness; this.hardness = hardness;
@ -55,7 +56,8 @@ public class Block {
this.toolVariants = toolVariants; this.toolVariants = toolVariants;
} }
public Block(String blockId, SpriteLoader.SPRITES sprite, int hardness, ItemType tool, List<ToolVariant> toolVariants, Object data) { public Block(String blockId, SpriteLoader.SPRITES sprite, int hardness, ItemType tool,
List<ToolVariant> toolVariants, Object data) {
this.blockId = blockId; this.blockId = blockId;
this.sprite = sprite; this.sprite = sprite;
this.hardness = hardness; this.hardness = hardness;
@ -70,7 +72,8 @@ public class Block {
public double calculateHardness(Inventory inventory) { public double calculateHardness(Inventory inventory) {
double holdingDecrease = 0; double holdingDecrease = 0;
if (inventory.getItemInHand().isPresent() && tool.isPresent() && inventory.getItemInHand().get().getType().equals(tool.get())) { if (inventory.getItemInHand().isPresent() && tool.isPresent()
&& inventory.getItemInHand().get().getType().equals(tool.get())) {
holdingDecrease = inventory.getItemInHand().get().getMiningDecrease(); holdingDecrease = inventory.getItemInHand().get().getMiningDecrease();
} }

View File

@ -26,7 +26,8 @@ public class Item {
private int dealDamage = 1; private int dealDamage = 1;
private Optional<Block> block = Optional.empty(); private Optional<Block> block = Optional.empty();
public Item(String id, String name, ItemType type, SpriteLoader.SPRITES sprite, ToolVariant toolVariant, int durability, boolean stackable, int dealDamage) { public Item(String id, String name, ItemType type, SpriteLoader.SPRITES sprite, ToolVariant toolVariant,
int durability, boolean stackable, int dealDamage) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.type = type; this.type = type;
@ -37,7 +38,8 @@ public class Item {
this.dealDamage = dealDamage; this.dealDamage = dealDamage;
} }
public Item(String id, String name, ItemType type, SpriteLoader.SPRITES sprite, ToolVariant toolVariant, double miningDecrease, int durability, boolean stackable) { public Item(String id, String name, ItemType type, SpriteLoader.SPRITES sprite, ToolVariant toolVariant,
double miningDecrease, int durability, boolean stackable) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.type = type; this.type = type;
@ -77,8 +79,10 @@ public class Item {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o)
if (o == null || getClass() != o.getClass()) return false; return true;
if (o == null || getClass() != o.getClass())
return false;
Item item = (Item) o; Item item = (Item) o;
return name.equals(item.name); return name.equals(item.name);

View File

@ -66,7 +66,8 @@ public class ItemBlockSupplier {
ItemRegistry annotation = clazz.getAnnotation(ItemRegistry.class); ItemRegistry annotation = clazz.getAnnotation(ItemRegistry.class);
registeredItems.put(annotation.value(), itemInstance); registeredItems.put(annotation.value(), itemInstance);
blockList.put(annotation.value(), annotation.block().isEmpty() ? annotation.value() : annotation.block()); blockList.put(annotation.value(),
annotation.block().isEmpty() ? annotation.value() : annotation.block());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -1,14 +1,5 @@
package cz.jzitnik.game.entities.items; package cz.jzitnik.game.entities.items;
public enum ItemType { public enum ItemType {
PICKAXE, PICKAXE, SHOVEL, AXE, SHEARS, BLOCK, FOOD, USELESS_ITEM, HOE, SWORD, PICKUPER
SHOVEL,
AXE,
SHEARS,
BLOCK,
FOOD,
USELESS_ITEM,
HOE,
SWORD,
PICKUPER
} }

View File

@ -1,9 +1,5 @@
package cz.jzitnik.game.entities.items; package cz.jzitnik.game.entities.items;
public enum ToolVariant { public enum ToolVariant {
WOODEN, WOODEN, STONE, IRON, GOLDEN, DIAMOND,
STONE,
IRON,
GOLDEN,
DIAMOND,
} }

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
@BlockRegistry("coal_block") @BlockRegistry("coal_block")
public class CoalBlock extends Block { public class CoalBlock extends Block {
public CoalBlock() { public CoalBlock() {
super("coal_block", SpriteLoader.SPRITES.COAL_BLOCK, 15, ItemType.PICKAXE, Arrays.stream(ToolVariant.values()).toList()); super("coal_block", SpriteLoader.SPRITES.COAL_BLOCK, 15, ItemType.PICKAXE,
Arrays.stream(ToolVariant.values()).toList());
} }
} }

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
@BlockRegistry("coal_ore") @BlockRegistry("coal_ore")
public class CoalOreBlock extends Block { public class CoalOreBlock extends Block {
public CoalOreBlock() { public CoalOreBlock() {
super("coal_ore", SpriteLoader.SPRITES.COAL_ORE, 15, ItemType.PICKAXE, Arrays.stream(ToolVariant.values()).toList()); super("coal_ore", SpriteLoader.SPRITES.COAL_ORE, 15, ItemType.PICKAXE,
Arrays.stream(ToolVariant.values()).toList());
} }
} }

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
@BlockRegistry("cobblestone") @BlockRegistry("cobblestone")
public class CobblestoneBlock extends Block { public class CobblestoneBlock extends Block {
public CobblestoneBlock() { public CobblestoneBlock() {
super("cobblestone", SpriteLoader.SPRITES.COBBLESTONE, 15, ItemType.PICKAXE, Arrays.stream(ToolVariant.values()).toList()); super("cobblestone", SpriteLoader.SPRITES.COBBLESTONE, 15, ItemType.PICKAXE,
Arrays.stream(ToolVariant.values()).toList());
} }
} }

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
@BlockRegistry("diamond_block") @BlockRegistry("diamond_block")
public class DiamondBlock extends Block { public class DiamondBlock extends Block {
public DiamondBlock() { public DiamondBlock() {
super("diamond_block", SpriteLoader.SPRITES.DIAMOND_BLOCK, 15, ItemType.PICKAXE, Arrays.stream(ToolVariant.values()).toList()); super("diamond_block", SpriteLoader.SPRITES.DIAMOND_BLOCK, 15, ItemType.PICKAXE,
Arrays.stream(ToolVariant.values()).toList());
} }
} }

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
@BlockRegistry("diamond_ore") @BlockRegistry("diamond_ore")
public class DiamondOreBlock extends Block { public class DiamondOreBlock extends Block {
public DiamondOreBlock() { public DiamondOreBlock() {
super("diamond_ore", SpriteLoader.SPRITES.DIAMOND_ORE, 15, ItemType.PICKAXE, Arrays.stream(ToolVariant.values()).toList()); super("diamond_ore", SpriteLoader.SPRITES.DIAMOND_ORE, 15, ItemType.PICKAXE,
Arrays.stream(ToolVariant.values()).toList());
} }
} }

View File

@ -12,7 +12,8 @@ import java.util.Arrays;
@BlockRegistry("furnace") @BlockRegistry("furnace")
public class FurnaceBlock extends Block { public class FurnaceBlock extends Block {
public FurnaceBlock() { public FurnaceBlock() {
super("furnace", SpriteLoader.SPRITES.FURNACE, 15, ItemType.PICKAXE, Arrays.stream(ToolVariant.values()).toList()); super("furnace", SpriteLoader.SPRITES.FURNACE, 15, ItemType.PICKAXE,
Arrays.stream(ToolVariant.values()).toList());
setData(new Furnace(this)); setData(new Furnace(this));
} }
} }

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
@BlockRegistry("gold_block") @BlockRegistry("gold_block")
public class GoldBlock extends Block { public class GoldBlock extends Block {
public GoldBlock() { public GoldBlock() {
super("gold_block", SpriteLoader.SPRITES.GOLD_BLOCK, 15, ItemType.PICKAXE, Arrays.stream(ToolVariant.values()).toList()); super("gold_block", SpriteLoader.SPRITES.GOLD_BLOCK, 15, ItemType.PICKAXE,
Arrays.stream(ToolVariant.values()).toList());
} }
} }

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
@BlockRegistry("gold_ore") @BlockRegistry("gold_ore")
public class GoldOreBlock extends Block { public class GoldOreBlock extends Block {
public GoldOreBlock() { public GoldOreBlock() {
super("gold_ore", SpriteLoader.SPRITES.GOLD_BLOCK, 15, ItemType.PICKAXE, Arrays.stream(ToolVariant.values()).toList()); super("gold_ore", SpriteLoader.SPRITES.GOLD_BLOCK, 15, ItemType.PICKAXE,
Arrays.stream(ToolVariant.values()).toList());
} }
} }

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
@BlockRegistry("iron_block") @BlockRegistry("iron_block")
public class IronBlock extends Block { public class IronBlock extends Block {
public IronBlock() { public IronBlock() {
super("iron_block", SpriteLoader.SPRITES.IRON_BLOCK, 15, ItemType.PICKAXE, Arrays.stream(ToolVariant.values()).toList()); super("iron_block", SpriteLoader.SPRITES.IRON_BLOCK, 15, ItemType.PICKAXE,
Arrays.stream(ToolVariant.values()).toList());
} }
} }

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
@BlockRegistry("iron_ore") @BlockRegistry("iron_ore")
public class IronOreBlock extends Block { public class IronOreBlock extends Block {
public IronOreBlock() { public IronOreBlock() {
super("iron_ore", SpriteLoader.SPRITES.IRON_ORE, 15, ItemType.PICKAXE, Arrays.stream(ToolVariant.values()).toList()); super("iron_ore", SpriteLoader.SPRITES.IRON_ORE, 15, ItemType.PICKAXE,
Arrays.stream(ToolVariant.values()).toList());
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("diamond_axe") @ItemRegistry("diamond_axe")
public class DiamondAxe extends Item { public class DiamondAxe extends Item {
public DiamondAxe() { public DiamondAxe() {
super("diamond_axe", "Diamond axe", ItemType.AXE, SpriteLoader.SPRITES.DIAMOND_AXE, ToolVariant.DIAMOND, 2, 1561, false); super("diamond_axe", "Diamond axe", ItemType.AXE, SpriteLoader.SPRITES.DIAMOND_AXE, ToolVariant.DIAMOND, 2,
1561, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("diamond_hoe") @ItemRegistry("diamond_hoe")
public class DiamondHoe extends Item { public class DiamondHoe extends Item {
public DiamondHoe() { public DiamondHoe() {
super("diamond_hoe", "Diamond hoe", ItemType.HOE, SpriteLoader.SPRITES.DIAMOND_HOE, ToolVariant.DIAMOND, 0, 1561, false); super("diamond_hoe", "Diamond hoe", ItemType.HOE, SpriteLoader.SPRITES.DIAMOND_HOE, ToolVariant.DIAMOND, 0,
1561, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("diamond_pickaxe") @ItemRegistry("diamond_pickaxe")
public class DiamondPickaxe extends Item { public class DiamondPickaxe extends Item {
public DiamondPickaxe() { public DiamondPickaxe() {
super("diamond_pickaxe", "Diamond pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.DIAMOND_PICKAXE, ToolVariant.DIAMOND, 14, 1561, false); super("diamond_pickaxe", "Diamond pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.DIAMOND_PICKAXE,
ToolVariant.DIAMOND, 14, 1561, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("diamond_shovel") @ItemRegistry("diamond_shovel")
public class DiamondShovel extends Item { public class DiamondShovel extends Item {
public DiamondShovel() { public DiamondShovel() {
super("diamond_shovel", "Diamond shovel", ItemType.SHOVEL, SpriteLoader.SPRITES.DIAMOND_SHOVEL, ToolVariant.DIAMOND, 0.5, 1561, false); super("diamond_shovel", "Diamond shovel", ItemType.SHOVEL, SpriteLoader.SPRITES.DIAMOND_SHOVEL,
ToolVariant.DIAMOND, 0.5, 1561, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("diamond_sword") @ItemRegistry("diamond_sword")
public class DiamondSword extends Item { public class DiamondSword extends Item {
public DiamondSword() { public DiamondSword() {
super("diamond_sword", "Diamond sword", ItemType.SWORD, SpriteLoader.SPRITES.DIAMOND_SWORD, ToolVariant.DIAMOND, 1562, false, 4); super("diamond_sword", "Diamond sword", ItemType.SWORD, SpriteLoader.SPRITES.DIAMOND_SWORD, ToolVariant.DIAMOND,
1562, false, 4);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("golden_axe") @ItemRegistry("golden_axe")
public class GoldenAxe extends Item { public class GoldenAxe extends Item {
public GoldenAxe() { public GoldenAxe() {
super("golden_axe", "Golden axe", ItemType.AXE, SpriteLoader.SPRITES.GOLDEN_AXE, ToolVariant.GOLDEN, 2.25, 32, false); super("golden_axe", "Golden axe", ItemType.AXE, SpriteLoader.SPRITES.GOLDEN_AXE, ToolVariant.GOLDEN, 2.25, 32,
false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("golden_hoe") @ItemRegistry("golden_hoe")
public class GoldenHoe extends Item { public class GoldenHoe extends Item {
public GoldenHoe() { public GoldenHoe() {
super("golden_hoe", "Golden hoe", ItemType.HOE, SpriteLoader.SPRITES.GOLDEN_HOE, ToolVariant.GOLDEN, 0, 32, false); super("golden_hoe", "Golden hoe", ItemType.HOE, SpriteLoader.SPRITES.GOLDEN_HOE, ToolVariant.GOLDEN, 0, 32,
false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("golden_pickaxe") @ItemRegistry("golden_pickaxe")
public class GoldenPickaxe extends Item { public class GoldenPickaxe extends Item {
public GoldenPickaxe() { public GoldenPickaxe() {
super("golden_pickaxe", "Golden pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.GOLDEN_PICKAXE, ToolVariant.GOLDEN, 14.5, 32, false); super("golden_pickaxe", "Golden pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.GOLDEN_PICKAXE,
ToolVariant.GOLDEN, 14.5, 32, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("golden_shovel") @ItemRegistry("golden_shovel")
public class GoldenShovel extends Item { public class GoldenShovel extends Item {
public GoldenShovel() { public GoldenShovel() {
super("golden_shovel", "Golden shovel", ItemType.SHOVEL, SpriteLoader.SPRITES.GOLDEN_SHOVEL, ToolVariant.GOLDEN, 0.625, 32, false); super("golden_shovel", "Golden shovel", ItemType.SHOVEL, SpriteLoader.SPRITES.GOLDEN_SHOVEL, ToolVariant.GOLDEN,
0.625, 32, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("golden_sword") @ItemRegistry("golden_sword")
public class GoldenSword extends Item { public class GoldenSword extends Item {
public GoldenSword() { public GoldenSword() {
super("golden_sword", "Golden sword", ItemType.SWORD, SpriteLoader.SPRITES.GOLDEN_SWORD, ToolVariant.GOLDEN, 32, false, 2); super("golden_sword", "Golden sword", ItemType.SWORD, SpriteLoader.SPRITES.GOLDEN_SWORD, ToolVariant.GOLDEN, 32,
false, 2);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("iron_pickaxe") @ItemRegistry("iron_pickaxe")
public class IronPickaxe extends Item { public class IronPickaxe extends Item {
public IronPickaxe() { public IronPickaxe() {
super("iron_pickaxe", "Iron pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.IRON_PICKAXE, ToolVariant.IRON, 13.5, 250, false); super("iron_pickaxe", "Iron pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.IRON_PICKAXE, ToolVariant.IRON,
13.5, 250, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("iron_shovel") @ItemRegistry("iron_shovel")
public class IronShovel extends Item { public class IronShovel extends Item {
public IronShovel() { public IronShovel() {
super("iron_shovel", "Iron shovel", ItemType.SHOVEL, SpriteLoader.SPRITES.IRON_SHOVEL, ToolVariant.IRON, 0.375, 250, false); super("iron_shovel", "Iron shovel", ItemType.SHOVEL, SpriteLoader.SPRITES.IRON_SHOVEL, ToolVariant.IRON, 0.375,
250, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("iron_sword") @ItemRegistry("iron_sword")
public class IronSword extends Item { public class IronSword extends Item {
public IronSword() { public IronSword() {
super("iron_sword", "Iron sword", ItemType.SWORD, SpriteLoader.SPRITES.IRON_SWORD, ToolVariant.IRON, 250, false, 3); super("iron_sword", "Iron sword", ItemType.SWORD, SpriteLoader.SPRITES.IRON_SWORD, ToolVariant.IRON, 250, false,
3);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("stone_pickaxe") @ItemRegistry("stone_pickaxe")
public class StonePickaxeItem extends Item { public class StonePickaxeItem extends Item {
public StonePickaxeItem() { public StonePickaxeItem() {
super("stone_pickaxe", "Stone pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.STONE_PICKAXE, ToolVariant.STONE, 12.5, 132, false); super("stone_pickaxe", "Stone pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.STONE_PICKAXE, ToolVariant.STONE,
12.5, 132, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("stone_shovel") @ItemRegistry("stone_shovel")
public class StoneShovelItem extends Item { public class StoneShovelItem extends Item {
public StoneShovelItem() { public StoneShovelItem() {
super("stone_shovel", "Stone shovel", ItemType.SHOVEL, SpriteLoader.SPRITES.STONE_SHOVEL, ToolVariant.STONE, 0.5, 132, false); super("stone_shovel", "Stone shovel", ItemType.SHOVEL, SpriteLoader.SPRITES.STONE_SHOVEL, ToolVariant.STONE,
0.5, 132, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("stone_sword") @ItemRegistry("stone_sword")
public class StoneSword extends Item { public class StoneSword extends Item {
public StoneSword() { public StoneSword() {
super("stone_sword", "Stone sword", ItemType.SWORD, SpriteLoader.SPRITES.STONE_SWORD, ToolVariant.STONE, 131, false, 3); super("stone_sword", "Stone sword", ItemType.SWORD, SpriteLoader.SPRITES.STONE_SWORD, ToolVariant.STONE, 131,
false, 3);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("wooden_axe") @ItemRegistry("wooden_axe")
public class WoodenAxeItem extends Item { public class WoodenAxeItem extends Item {
public WoodenAxeItem() { public WoodenAxeItem() {
super("wooden_axe", "Wooden axe", ItemType.AXE, SpriteLoader.SPRITES.WOODEN_AXE, ToolVariant.WOODEN, 0.5, 59, false); super("wooden_axe", "Wooden axe", ItemType.AXE, SpriteLoader.SPRITES.WOODEN_AXE, ToolVariant.WOODEN, 0.5, 59,
false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("wooden_hoe") @ItemRegistry("wooden_hoe")
public class WoodenHoe extends Item { public class WoodenHoe extends Item {
public WoodenHoe() { public WoodenHoe() {
super("wooden_hoe", "Wooden hoe", ItemType.HOE, SpriteLoader.SPRITES.WOODEN_HOE, ToolVariant.WOODEN, 0, 59, false); super("wooden_hoe", "Wooden hoe", ItemType.HOE, SpriteLoader.SPRITES.WOODEN_HOE, ToolVariant.WOODEN, 0, 59,
false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("wooden_pickaxe") @ItemRegistry("wooden_pickaxe")
public class WoodenPickaxeItem extends Item { public class WoodenPickaxeItem extends Item {
public WoodenPickaxeItem() { public WoodenPickaxeItem() {
super("wooden_pickaxe", "Wooden pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.WOODEN_PICKAXE, ToolVariant.WOODEN, 12, 59, false); super("wooden_pickaxe", "Wooden pickaxe", ItemType.PICKAXE, SpriteLoader.SPRITES.WOODEN_PICKAXE,
ToolVariant.WOODEN, 12, 59, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("wooden_shovel") @ItemRegistry("wooden_shovel")
public class WoodenShovelItem extends Item { public class WoodenShovelItem extends Item {
public WoodenShovelItem() { public WoodenShovelItem() {
super("wooden_shovel", "Wooden shovel", ItemType.SHOVEL, SpriteLoader.SPRITES.WOODEN_SHOVEL, ToolVariant.WOODEN, 0.3, 59, false); super("wooden_shovel", "Wooden shovel", ItemType.SHOVEL, SpriteLoader.SPRITES.WOODEN_SHOVEL, ToolVariant.WOODEN,
0.3, 59, false);
} }
} }

View File

@ -9,6 +9,7 @@ import cz.jzitnik.game.entities.items.ToolVariant;
@ItemRegistry("wooden_sword") @ItemRegistry("wooden_sword")
public class WoodenSword extends Item { public class WoodenSword extends Item {
public WoodenSword() { public WoodenSword() {
super("wooden_sword", "Wooden sword", ItemType.SWORD, SpriteLoader.SPRITES.WOODEN_SWORD, ToolVariant.WOODEN, 59, false, 2); super("wooden_sword", "Wooden sword", ItemType.SWORD, SpriteLoader.SPRITES.WOODEN_SWORD, ToolVariant.WOODEN, 59,
false, 2);
} }
} }

View File

@ -8,7 +8,7 @@ import cz.jzitnik.game.mobs.services.pig.PigData;
// Yes, pig is a block. Cry about it. // Yes, pig is a block. Cry about it.
@EntityRegistry("pig") @EntityRegistry("pig")
public class Pig extends Block { public class Pig extends Block {
public Pig () { public Pig() {
super("pig", SpriteLoader.SPRITES.PIG); super("pig", SpriteLoader.SPRITES.PIG);
setMob(true); setMob(true);
setGhost(true); setGhost(true);

View File

@ -95,7 +95,8 @@ public class Generation {
for (int i = 10; i < 502; i += random.nextInt(20) + 20) { for (int i = 10; i < 502; i += random.nextInt(20) + 20) {
int treeBase = terrainHeight[i]; int treeBase = terrainHeight[i];
if (treeBase - 3 < 0) continue; if (treeBase - 3 < 0)
continue;
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
if (treeBase - j >= 0) { if (treeBase - j >= 0) {
@ -112,7 +113,8 @@ public class Generation {
for (int dx = -size / 2; dx <= size / 2; dx++) { for (int dx = -size / 2; dx <= size / 2; dx++) {
for (int dy = -size / 2; dy <= size / 2; dy++) { for (int dy = -size / 2; dy <= size / 2; dy++) {
if (i + dx >= 0 && i + dx < world[0].length && offsetY >= 0) { if (i + dx >= 0 && i + dx < world[0].length && offsetY >= 0) {
world[offsetY][i + dx].add(new Block("oak_leaves", SpriteLoader.SPRITES.OAK_LEAF, 1, ItemType.SHEARS, new ArrayList<>())); world[offsetY][i + dx].add(new Block("oak_leaves", SpriteLoader.SPRITES.OAK_LEAF, 1,
ItemType.SHEARS, new ArrayList<>()));
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More