Skip to content

Commit

Permalink
Bugs and corrections
Browse files Browse the repository at this point in the history
Changes:
* Added more tile colors to the Map Book
* Much of the code was optimized (although the FPS is somewhat unstable)
* Optimized the way background music plays randomly
* Renamed the "texture packs" folder to "texturepacks" to avoid problems
* Smoothed the way text moves on the credits screen
* Removed invalid trades on villagers

Bug fixes:
- Fixed arrow counter positioning in HUD
- Partially fixed the bug where some dynamic texts such as the loading screen tend to wobble
- Fixed a bug where trees did not drop apples
- Fixed a bug where the Air Wizard could get stuck in Holy Rock
  • Loading branch information
TheBigEye committed Feb 27, 2024
1 parent c18c9c7 commit 775fbe0
Show file tree
Hide file tree
Showing 42 changed files with 331 additions and 408 deletions.
52 changes: 26 additions & 26 deletions src/main/java/minicraft/core/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ private static void renderLevel() {
if (yScroll > ((level.h << 4) - Screen.h)) yScroll = ((level.h << 4) - Screen.h); // ...bottom border.

if (currentLevel > 3) { // If the current level is higher than 3 (which only the sky level (and dungeon) is)
for (int y = 0; y < 56; y++) {
for (int x = 0; x < 96; x++) {
for (int y = 0; y < 37; y++) {
for (int x = 0; x < 55; x++) {
// Creates the background for the sky (and dungeon) level:
screen.render(x * 8 - ((xScroll >> 2) & 7), y * 8 - ((yScroll >> 2) & 7), 3 + 23 * 32, 0, 1); // for rain
screen.render((x << 3) - ((xScroll >> 2) & 7), (y << 3) - ((yScroll >> 2) & 7), 3 + (23 << 5), 0, 1);
}
}
}
Expand Down Expand Up @@ -257,11 +257,11 @@ private static void renderGui() {
if (isMode("Creative") || arrowsCount >= 10000) {
Font.draw(" x" + "∞", screen, 184 - tool.arrowOffset, Screen.h - 24);
} else {
Font.draw(" x" + arrowsCount, screen, 184 - tool.arrowOffset, Screen.h - 24);
Font.draw(" x" + arrowsCount, screen, 180 - tool.arrowOffset, Screen.h - 24);
}

// Displays the arrow icon
screen.render(20 * 8 + 20 - player.activeItem.arrowOffset, Screen.h - 24, 5 + 3 * 32, 0, 3);
screen.render((20 << 3) + 20 - player.activeItem.arrowOffset, Screen.h - 24, 5 + (3 << 5), 0, 3);
}

// TOOL DURABILITY STATUS
Expand Down Expand Up @@ -369,7 +369,7 @@ private static void renderGui() {

// Title background
for (int j = 0; j < title.length(); j++) {
screen.render(311 + (j * 8) - 1, 9, 3 + 21 * 32, 0, 3);
screen.render(311 + (j << 3) - 1, 9, 3 + (21 << 5), 0, 3);
}
Font.draw(title, screen, 310, 9, Color.YELLOW);

Expand All @@ -395,16 +395,16 @@ private static void renderGui() {
// wobbling hearts if the player health is less than 5
if (player.health < 5) {
int blinking = (random.nextInt(2) - random.nextInt(2));
screen.render(2 + i * 8, Screen.h - (18 + blinking), 0 + 2 * 32, 0, 3);
screen.render(2 + (i << 3), Screen.h - (18 + blinking), 0 + (2 << 5), 0, 3);
} else { // normal hearts if more than 4
screen.render(2 + i * 8, Screen.h - 18, 0 + 2 * 32, 0, 3);
screen.render(2 + (i << 3), Screen.h - 18, 0 + (2 << 5), 0, 3);
}
} else { // hearts cotainer
if (player.health < 5) {
int blinking = (random.nextInt(2) - random.nextInt(2));
screen.render(2 + i * 8, Screen.h - (18 + blinking), 0 + 3 * 32, 0, 3); // wobbling hearts cotainer
screen.render(2 + (i << 3), Screen.h - (18 + blinking), 0 + (3 << 5), 0, 3); // wobbling hearts cotainer
} else {
screen.render(2 + i * 8, Screen.h - 18 , 0 + 3 * 32, 0, 3); // nomral hearts container
screen.render(2 + (i << 3), Screen.h - 18 , 0 + (3 << 5), 0, 3); // nomral hearts container
}
}

Expand All @@ -414,50 +414,50 @@ private static void renderGui() {
if (i < player.health) {
if (player.health < 6) {
int blinking = (random.nextInt(2) - random.nextInt(2));
screen.render(2 + i * 8, Screen.h - (18 + blinking), 7 + 2 * 32, 0, 3);
screen.render(2 + (i << 3), Screen.h - (18 + blinking), 7 + (2 << 5), 0, 3);
} else {
screen.render(2 + i * 8, Screen.h - 18, 7 + 2 * 32, 0, 3);
screen.render(2 + (i << 3), Screen.h - 18, 7 + (2 << 5), 0, 3);
}

} else { // hearts cotainer
if (player.health < 5) {
int blinking = (random.nextInt(2) - random.nextInt(2));
screen.render(2 + i * 8, Screen.h - (18 + blinking), 7 + 3 * 32, 0, 3); // wobbling hearts cotainer
screen.render(2 + (i << 3), Screen.h - (18 + blinking), 7 + (3 << 5), 0, 3); // wobbling hearts cotainer
} else {
screen.render(2 + i * 8, Screen.h - 18 , 7 + 3 * 32, 7, 3); // nomral hearts container
screen.render(2 + (i << 3), Screen.h - 18 , 7 + (3 << 5), 7, 3); // nomral hearts container
}
}
}

if (player.staminaRechargeDelay > 0) {
// Creates the white/gray blinking effect when you run out of stamina.
if (player.staminaRechargeDelay / 4 % 2 == 0) {
screen.render(2 + i * 8, Screen.h - 9, 1 + 4 * 32, 0, 3);
screen.render(2 + (i << 3), Screen.h - 9, 1 + (4 << 5), 0, 3);
} else {
screen.render(2 + i * 8, Screen.h - 9, 1 + 3 * 32, 0, 3);
screen.render(2 + (i << 3), Screen.h - 9, 1 + (3 << 5), 0, 3);
}
} else {
// Renders your current stamina, and uncharged gray stamina.
if (i < player.stamina) {
screen.render(2 + i * 8, Screen.h - 9, 1 + 2 * 32, 0, 3);
screen.render(2 + (i << 3), Screen.h - 9, 1 + (2 << 5), 0, 3);
} else {
screen.render(2 + i * 8, Screen.h - 9, 1 + 3 * 32, 0, 3);
screen.render(2 + (i << 3), Screen.h - 9, 1 + (3 << 5), 0, 3);
}
}

// Renders hunger icons
if (i < player.hunger) {
screen.render(i * 8 + (Screen.w - 82), Screen.h - 18, 2 + 2 * 32, 0, 3);
screen.render((i << 3) + (Screen.w - 82), Screen.h - 18, 2 + (2 << 5), 0, 3);
} else {
screen.render(i * 8 + (Screen.w - 82), Screen.h - 18, 2 + 3 * 32, 0, 3);
screen.render((i << 3) + (Screen.w - 82), Screen.h - 18, 2 + (3 << 5), 0, 3);
}

// Renders armor icons
int armor = player.armor * Player.maxStat / Player.maxArmor;
if (i <= armor && player.currentArmor != null) {
screen.render(i * 8 + (Screen.w - 82), Screen.h - 9, (player.currentArmor.level - 1) + 9 * 32, 0, 0);
screen.render((i << 3) + (Screen.w - 82), Screen.h - 9, (player.currentArmor.level - 1) + (9 << 5), 0, 0);
} else {
screen.render(i * 8 + (Screen.w - 82), Screen.h - 9, 8 + 2 * 32, 0, 3);
screen.render((i << 3) + (Screen.w - 82), Screen.h - 9, 8 + (2 << 5), 0, 3);
}

}
Expand Down Expand Up @@ -512,17 +512,17 @@ public static void renderBossbar(int barLength, int bossHealth, String title) {
int maxBarLength = 100;

if (bossHealth > 1) {
screen.render(x + (maxBarLength * 2) , y , 0 + 24 * 32, 1, 3); // left corner
screen.render(x + (maxBarLength * 2) , y , 0 + (24 << 5), 1, 3); // left corner

// The middle
for (int bx = 0; bx < maxBarLength; bx++) {
screen.render(x + (bx * 2), y, 1 + 24 * 32, 0, 3);
screen.render(x + (bx * 2), y, 1 + (24 << 5), 0, 3);
}

screen.render(x - 5 , y , 0 + 25 * 32, 0, 3); // right corner
screen.render(x - 5 , y , 0 + (25 << 5), 0, 3); // right corner

for (int bx = 0; bx < barLength; bx++) {
screen.render(x + (bx * 2), y, 1 + 25 * 32, 0, 3);
screen.render(x + (bx * 2), y, 1 + (25 << 5), 0, 3);
}

FontStyle style = new FontStyle(Color.WHITE).setShadowType(Color.BLACK, true).setYPos(2);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/minicraft/entity/Arrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ public void render(Screen screen) {
if (dir == Direction.UP) xt = 2;
if (dir == Direction.DOWN) xt = 3;

if (Settings.get("shadows").equals(true)) { // Shadow
screen.render(x - 4, y + 2, xt + yt * 32, 0, 0, -1, false, Color.BLACK);
if (Settings.get("shadows").equals(true)) {
screen.render(x - 4, y + 2, xt + (yt << 5), 0, 0, -1, false, Color.BLACK);
}

// Sprite
screen.render(x - 4, y - 4, xt + yt * 32, 0, 0);
screen.render(x - 4, y - 4, xt + (yt << 5), 0, 0);
}
}
4 changes: 2 additions & 2 deletions src/main/java/minicraft/entity/Spark.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ public void render(Screen screen) {
}

if (Settings.getBoolean("shadows")) {
screen.render(x - 4, y - 4 + 2, 0 + 62 * 32, randmirror, 2, -1, false, Color.get(-1, 555)); // renders the shadow on the ground
screen.render(x - 4, y - 4 + 2, 0 + (62 << 5), randmirror, 2, -1, false, Color.get(-1, 555)); // renders the shadow on the ground
}
screen.render(x - 4, y - 4 - 2, 0 + 62 * 32, randmirror, 2); // renders the spark
screen.render(x - 4, y - 4 - 2, 0 + (62 << 5), randmirror, 2); // renders the spark
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/entity/mob/AirWizard.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void render(Screen screen) {

// Bossbar on the the Air wizard
if (Settings.get("bossbar").equals("On entity")) {
Font.drawBar(screen, (x - Screen.w / 12 + 26), y - 24, length, "testificate");
Font.drawBar(screen, (x - Screen.w / 12 + 26), y - 24, length);
}

// Bossbar percent
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/entity/mob/EyeQueen.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public void render(Screen screen) {

// Bossbar on the the Air wizard
if (Settings.get("bossbar").equals("On entity")) {
Font.drawBar(screen, (x - Screen.w / 12 + 16), y - 24, length, "testificate");
Font.drawBar(screen, (x - Screen.w / 12 + 16), y - 24, length);
}

// Bossbar percent
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/minicraft/entity/mob/Firefly.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import minicraft.core.Updater.Time;
import minicraft.entity.Entity;
import minicraft.graphic.MobSprite;
import minicraft.graphic.Screen;
import minicraft.level.tile.Tile;
import minicraft.level.tile.Tiles;

Expand All @@ -24,7 +25,7 @@ public void tick() {
Tile tile = level.getTile(x >> 4, y >> 4);

if (Updater.getTime() == Time.Night) {
if (random.nextInt(1000) == 0 && (tile.id == Tiles.get("Oak tree").id || tile.id == Tiles.get("Birch tree").id)) {
if (tickTime % 100 == 0 && (tile.id == Tiles.get("Oak tree").id || tile.id == Tiles.get("Birch tree").id)) {
remove();
return;
}
Expand Down Expand Up @@ -60,13 +61,19 @@ public void tick() {

@Override
public int getLightRadius() {
if (random.nextInt(10) == 0) {
if (tickTime % 50 == 0) {
return 1;
} else if (tickTime % 25 == 0) {
return 2;
} else {
return 3;
}
if (random.nextInt(100) == 0) {
return 3;
}
return 2;
}


@Override
public void render(Screen screen) {
super.render(screen);
}


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/entity/mob/Keeper.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void render(Screen screen) {

// Bossbar on the the Air wizard
if (Settings.get("bossbar").equals("On entity")) {
Font.drawBar(screen, (x - Screen.w / 12 + 16), y - 24, length, "testificate");
Font.drawBar(screen, (x - Screen.w / 12 + 16), y - 24, length);
}

// Bossbar percent
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/minicraft/entity/mob/Librarian.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ public class Librarian extends VillagerMob {
static {
librarianTrades.add(new Recipe("Book_1", new String[] { "Apple_5" }));
librarianTrades.add(new Recipe("Paper_3", new String[] { "Leaf_5" }));
librarianTrades.add(new Recipe("Protection I_1", new String[] { "iron_20", "Book_1" }));
librarianTrades.add(new Recipe("Protection II_1", new String[] { "iron_30", "Book_2" }));
librarianTrades.add(new Recipe("Protection III_1", new String[] { "gold_20", "Book_3" }));
librarianTrades.add(new Recipe("Sharp I_1", new String[] { "iron_20", "Book_1" }));
librarianTrades.add(new Recipe("Sharp II_1", new String[] { "iron_30", "Book_2" }));
librarianTrades.add(new Recipe("Sharp III_1", new String[] { "gold_30", "Book_3" }));
}

public Librarian() {
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/minicraft/entity/mob/Mob.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ private boolean move(int xa, int ya, boolean changeDir) { // knockback shouldn't
return false; // stopped because there's no level to move in!
}

@SuppressWarnings("unused")
int oldxt = x >> 4;

@SuppressWarnings("unused")
int oldyt = y >> 4;

// These should return true because the mob is still technically moving; these are just to make it move *slower*.
if (tickTime % 2 == 0 && (isSwimming() || (!(this instanceof Player) && isWooling()))) {
return true;
Expand Down

0 comments on commit 775fbe0

Please sign in to comment.