Skip to content

Commit

Permalink
Lastest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBigEye committed Dec 7, 2021
1 parent 76c4ca0 commit 125997e
Show file tree
Hide file tree
Showing 44 changed files with 2,559 additions and 2,550 deletions.
Binary file modified assets/resources/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion assets/resources/localization/english_en-us.mcpl
Original file line number Diff line number Diff line change
Expand Up @@ -1264,11 +1264,15 @@ Yes
No
No

# PlayerInvMenu.java
# PlayerInvDisplay.java

Inventory
Inventory

to search.
to search.


# TitleMenu.java

Singleplayer
Expand Down
Binary file modified assets/resources/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/resources/textures/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/resources/textures/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/resources/textures/legacy/gui_legacy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/resources/textures/legacy/items_legacy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/resources/textures/legacy/tiles_legacy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/resources/textures/tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Minicraft_Splash_Screen_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Minicraft_Splash_Screen_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Minicraft_Splash_Screen_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/minicraft/core/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ private static void renderGui() {
}

if (isMode("creative") || ac >= 10000) {
Font.drawCompleteBackground(" x" + "∞", screen, 184 - player.activeItem.arrAdjusted, Screen.h - 24);
Font.drawTransparentBackground(" x" + "∞", screen, 184 - player.activeItem.arrAdjusted, Screen.h - 24);
} else {
Font.drawCompleteBackground(" x" + ac, screen, 184 - player.activeItem.arrAdjusted, Screen.h - 24);
Font.drawTransparentBackground(" x" + ac, screen, 184 - player.activeItem.arrAdjusted, Screen.h - 24);
}

// Displays the arrow icon
Expand Down Expand Up @@ -286,7 +286,7 @@ private static void renderGui() {
screen.render(xx + x * 8, yy, 3 + 21 * 32, 0, 3);
}

Font.drawCompleteBackground(dura + "%", screen, 220 + player.activeItem.durAdjusted, Screen.h - 24, Color.get(1, 255 - green, green, 0));
Font.drawTransparentBackground(dura + "%", screen, 220 + player.activeItem.durAdjusted, Screen.h - 24, Color.get(1, 255 - green, green, 0));
}

// This draws the black square where the selected item would be if you were holding it
Expand Down
7 changes: 6 additions & 1 deletion src/minicraft/core/io/Localization.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ private static String[] getLanguagesFromDirectoryUsingIDE() {
DirectoryStream<Path> dir = Files.newDirectoryStream(folderPath);
for (Path p : dir) {
String filename = p.getFileName().toString();
languages.add(filename.replace(".mcpl", ""));
String data = filename.replace(".mcpl", "");
String lang = data.substring(0, data.indexOf('_'));

languages.add(lang);
localizationFiles.put(lang, "/resources/localization/"+filename);
locales.put(lang, Locale.forLanguageTag(data.substring(data.indexOf('_') + 1)));
}
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
Expand Down
62 changes: 0 additions & 62 deletions src/minicraft/core/io/SoundOGG.java

This file was deleted.

27 changes: 14 additions & 13 deletions src/minicraft/entity/furniture/DeathChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,20 @@ public boolean use(Player player) {
public void take(Player player) {
} // can't grab a death chest.

@Override
public void touchedBy(Entity other) {
if (other instanceof Player) {
if (!Game.ISONLINE) {
((Player) other).getInventory().addAll(getInventory());
remove();
Game.notifications.add("Death chest retrieved!");
} else if (Game.isValidClient()) {
Game.client.touchDeathChest((Player) other, this);
remove();
}
}
}
@Override
public void touchedBy(Entity other) {
if(other instanceof Player) {
if(!Game.ISONLINE) {
((Player)other).getInventory().addAll(getInventory());
remove();
Game.notifications.add("Death chest retrieved!");
}
else if(Game.isValidClient()) {
Game.client.touchDeathChest(this);
remove();
}
}
}

@Override
protected String getUpdateString() {
Expand Down
27 changes: 13 additions & 14 deletions src/minicraft/entity/furniture/Furniture.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,19 @@ public boolean interact(Player player, @Nullable Item item, Direction attackDir)
return false;
}

/**
* Tries to let the player push this furniture.
*
* @param player The player doing the pushing.
*/
public void tryPush(Player player) {
if (pushTime == 0) {
pushDir = player.dir; // set pushDir to the player's dir.
pushTime = multiPushTime = 10; // set pushTime to 10.

if (Game.isConnectedClient())
Game.client.pushFurniture(this, pushDir);
}
}
/**
* Tries to let the player push this furniture.
* @param player The player doing the pushing.
*/
public void tryPush(Player player) {
if (pushTime == 0) {
pushDir = player.dir; // Set pushDir to the player's dir.
pushTime = multiPushTime = 10; // Set pushTime to 10.

if (Game.isConnectedClient())
Game.client.pushFurniture(this);
}
}

@Override
public boolean canWool() {
Expand Down
22 changes: 17 additions & 5 deletions src/minicraft/entity/furniture/Tnt.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import minicraft.gfx.Sprite;
import minicraft.item.Item;
import minicraft.level.Level;
import minicraft.level.tile.Tile;
import minicraft.level.tile.Tiles;

public class Tnt extends Furniture implements ActionListener {
Expand All @@ -29,7 +30,7 @@ public class Tnt extends Furniture implements ActionListener {
private Timer explodeTimer;
private Level levelSave;

private String[] explosionBlacklist = new String[] { "hard rock", "obsidian wall", "hard obsidian" };
private final String[] explosionBlacklist = new String[] { "hard rock", "obsidian wall", "hard obsidian", "stairs up", "stairs down" };

/**
* Creates a new tnt furniture.
Expand Down Expand Up @@ -58,7 +59,9 @@ public void tick() {
float dist = (float) Math.hypot(e.x - x, e.y - y);
int dmg = (int) (BLAST_DAMAGE * (1 - (dist / BLAST_RADIUS))) + 1;
if (e instanceof Mob)
((Mob) e).hurt(this, dmg);
((Mob)e).onExploded(this, dmg);

// Ignite other bombs in range.
if (e instanceof Tnt) {
Tnt tnt = (Tnt) e;
if (!tnt.fuseLit) {
Expand All @@ -69,6 +72,18 @@ public void tick() {
}
}

int xt = x >> 4;
int yt = (y - 2) >> 4;

// Get the tiles that have been exploded.
Tile[] affectedTiles = level.getAreaTiles(xt, yt, 1);

// Call the onExplode() event.
for (int i = 0; i < affectedTiles.length; i++) {
// This assumes that range is 1.
affectedTiles[i].onExplode(level, xt + i % 3 - 1, yt + i / 3 - 1);
}

// Random explode sound
switch (random.nextInt(4)) {

Expand Down Expand Up @@ -98,9 +113,6 @@ public void tick() {

}

int xt = x >> 4;
int yt = (y - 2) >> 4;

level.setAreaTiles(xt, yt, 1, Tiles.get("explode"), 0, explosionBlacklist);

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

String txt = "";
int w = Font.textWidth(txt) / 2;
Font.drawCompleteBackground(txt, screen, x - w, y - 45 - Font.textHeight());
Font.drawTransparentBackground(txt, screen, x - w, y - 45 - Font.textHeight());
}

public boolean canSwim() {
Expand Down
11 changes: 8 additions & 3 deletions src/minicraft/entity/mob/Mob.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,14 @@ public void hurt(Mob mob, int damage, Direction attackDir) { // Hurt the mob, wh
doHurt(damage, attackDir); // Call the method that actually performs damage, and use our provided attackDir
}

public void hurt(Tnt tnt, int dmg) {
doHurt(dmg, getAttackDir(tnt, this));
}
/**
* Executed when a TNT bomb explodes near this mob.
* @param tnt The TNT exploding.
* @param dmg The amount of damage the explosion does.
*/
public void onExploded(Tnt tnt, int dmg) {
doHurt(dmg, getAttackDir(tnt, this));
}

protected void doHurt(int damage, Direction attackDir) { // Actually hurt the mob, based on only damage and a
// direction
Expand Down
9 changes: 7 additions & 2 deletions src/minicraft/entity/mob/MobAi.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import minicraft.core.Game;
import minicraft.core.io.Sound;
import minicraft.entity.Direction;
import minicraft.entity.Entity;
import minicraft.entity.particle.TextParticle;
import minicraft.gfx.Color;
import minicraft.gfx.MobSprite;
Expand Down Expand Up @@ -62,8 +63,12 @@ public void tick() {
if (lifetime > 0) {
age++;
if (age > lifetime) {
remove();
return;
boolean playerClose = getLevel().entityNearPlayer((Entity) this);

if (!playerClose) {
remove();
return;
}
}
}

Expand Down
53 changes: 35 additions & 18 deletions src/minicraft/entity/mob/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -1280,22 +1280,39 @@ public void findStartPos(Level level, boolean setSpawn) {
this.y = spawnPos.y * 16 + 8;
}

/**
* Finds a location where the player can respawn in a given level.
*
* @param level The level.
* @return true
*/
public boolean respawn(Level level) {
if (!level.getTile(spawnx, spawny).maySpawn())
findStartPos(level); // If there's no bed to spawn from, and the stored coordinates don't point to a
// grass tile, then find a new point.

// Move the player to the spawnpoint
this.x = spawnx * 16 + 8;
this.y = spawny * 16 + 8;
return true; // Again, why the "return true"'s for methods that never return false?
}
/**
* Finds a location where the player can respawn in a given level.
*
* @param level The level.
* @return true
*/
public void respawn(Level level) {
if (!level.getTile(spawnx, spawny).maySpawn()) {
findStartPos(level); // If there's no bed to spawn from, and the stored coordinates don't point to a grass tile, then find a new point.

int x = spawnx;
int y = spawny;

x = (Math.random() > .5) ? -80 : 80;
y = (Math.random() > .5) ? -80 : 80;

for (int i = 0; i < 20; i++) // Iterate through diagonal line for possible random spawn.
{
if (!level.getTile(spawnx, spawny).maySpawn()) {
x += 4 * (x / -x);
y += 4 * (-y / y);
} else {
spawnx = x;
spawny = y;
break;
}
}

}
// Move the player to the spawnpoint
this.x = spawnx * 16 + 8;
this.y = spawny * 16 + 8;
}

/**
* Uses an amount of stamina to do an action.
Expand Down Expand Up @@ -1366,8 +1383,8 @@ else if (Game.isConnectedClient())
}

@Override
public void hurt(Tnt tnt, int dmg) {
super.hurt(tnt, dmg);
public void onExploded(Tnt tnt, int dmg) {
super.onExploded(tnt, dmg);
payStamina(dmg * 2);
}

Expand Down
6 changes: 3 additions & 3 deletions src/minicraft/gfx/Font.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public static void drawBackground(String msg, Screen screen, int x, int y, int w
}
}

public static void drawCompleteBackground(String msg, Screen screen, int x, int y) {
drawCompleteBackground(msg, screen, x, y, -1);
public static void drawTransparentBackground(String msg, Screen screen, int x, int y) {
drawTransparentBackground(msg, screen, x, y, -1);
}

public static void drawCompleteBackground(String msg, Screen screen, int x, int y, int whiteTint) {
public static void drawTransparentBackground(String msg, Screen screen, int x, int y, int whiteTint) {
msg = msg.toUpperCase(Localization.getSelectedLocale());

for (int i = 0; i < msg.length(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/minicraft/item/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void renderHUD(Screen screen, int x, int y, int fontColor) {
sprite.render(screen, xx, yy);

// Item name
Font.drawCompleteBackground(dispName, screen, xx + 8, yy, fontColor);
Font.drawTransparentBackground(dispName, screen, xx + 8, yy, fontColor);

}

Expand Down
Loading

0 comments on commit 125997e

Please sign in to comment.