diff --git a/src/client/java/minicraft/entity/mob/Player.java b/src/client/java/minicraft/entity/mob/Player.java index fc4261dee..096539c67 100644 --- a/src/client/java/minicraft/entity/mob/Player.java +++ b/src/client/java/minicraft/entity/mob/Player.java @@ -137,7 +137,6 @@ public class Player extends Mob implements ItemHolder, ClientTickable { public int shirtColor = Color.get(1, 51, 51, 0); // Player shirt color. - public boolean isRiding = false; public boolean isFishing = false; public int maxFishingTicks = 120; public int fishingTicks = maxFishingTicks; @@ -999,7 +998,7 @@ public void render(Screen screen) { int yo = y - 11; // Vertical // Renders swimming - if (isSwimming() && onFallDelay <= 0 && !isRiding) { + if (isSwimming() && onFallDelay <= 0) { yo += 4; // y offset is moved up by 4 if (level.getTile(x >> 4, y >> 4) == Tiles.get("water")) { @@ -1050,16 +1049,19 @@ public void render(Screen screen) { } else { curSprite = spriteSet[dir.getDir()][(walkDist >> 3) & 1]; // Gets the correct sprite to render. // Render each corner of the sprite - if (isSwimming() && !isRiding) { // Don't render the bottom half if swimming. + if (isSwimming()) { // Don't render the bottom half if swimming. Sprite sprite = curSprite.getSprite(); screen.render(xo, yo, sprite.spritePixels[0][0], shirtColor); screen.render(xo + 8, yo, sprite.spritePixels[0][1], shirtColor); - } else if (isRiding && (dir.equals(Direction.LEFT)||dir.equals(Direction.RIGHT))) { // If we are riding an entity - Sprite sprite = curSprite.getSprite(); - screen.render(xo, yo + 2, sprite.spritePixels[0][0], shirtColor); - screen.render(xo + 8, yo + 2, sprite.spritePixels[0][1], shirtColor); - } else if (isRiding && (dir.equals(Direction.UP)||dir.equals(Direction.DOWN))) { // If we are riding an entity - screen.render(xo, yo, curSprite.setColor(shirtColor)); + } else if (ride != null) { // If we are riding an entity + if (dir.getX() != 0) { // if direction is x-axis (left/right) + Sprite sprite = curSprite.getSprite(); + screen.render(xo, yo + 2, sprite.spritePixels[0][0], shirtColor); + screen.render(xo + 8, yo + 2, sprite.spritePixels[0][1], shirtColor); + } else if (dir.getY() != 0) { // if direction is y-axis (up/down) + screen.render(xo, yo, curSprite.setColor(shirtColor)); + } else // Other direction is invalid + throw new UnsupportedOperationException("dir should not be NONE"); } else { screen.render(xo, yo - 4 * onFallDelay, curSprite.setColor(shirtColor)); } @@ -1123,12 +1125,12 @@ public void render(Screen screen) { // Renders the furniture if the player is holding one. if (activeItem instanceof FurnitureItem) { - Furniture furniture = ((FurnitureItem) activeItem).furniture; - furniture.x = x; - furniture.y = yo - 4; - furniture.render(screen); - } + Furniture furniture = ((FurnitureItem) activeItem).furniture; + furniture.x = x; + furniture.y = yo - 4; + furniture.render(screen); } + } /** What happens when the player interacts with a itemEntity */ public void pickupItem(ItemEntity itemEntity) { diff --git a/src/client/java/minicraft/entity/vehicle/Boat.java b/src/client/java/minicraft/entity/vehicle/Boat.java index f5fd88bac..e94815084 100644 --- a/src/client/java/minicraft/entity/vehicle/Boat.java +++ b/src/client/java/minicraft/entity/vehicle/Boat.java @@ -41,7 +41,7 @@ public void render(Screen screen) { int xo = x - 8; // Horizontal int yo = y - 8; // Vertical - if (Game.player.equals(passenger)) { + if (passenger != null) { switch (((Player) passenger).dir) { case UP: // if currently riding upwards... screen.render(xo - 4, yo - 4, boatSprites[0][((((Player) passenger).walkDist >> 3) & 1) + 2].getSprite()); @@ -133,7 +133,7 @@ public boolean rideTick(Player passenger, Vector2 vec) { int yd = (int) (vec.y * MOVE_SPEED); dir = Direction.getDirection(xd, yd); if (move(xd, yd)) { - walkDist += 1; + if (Updater.tickCount % 2 != 0) walkDist++; // Slower the animation syncPassengerState(passenger); } @@ -145,7 +145,6 @@ public boolean startRiding(Player player) { if (passenger == null) { passenger = player; syncPassengerState(passenger); - Game.player.isRiding = true; return true; } else return false; @@ -154,7 +153,6 @@ public boolean startRiding(Player player) { @Override public void stopRiding(Player player) { if (passenger == player) { - Game.player.isRiding = false; passenger = null; } } diff --git a/src/client/java/minicraft/item/FurnitureItem.java b/src/client/java/minicraft/item/FurnitureItem.java index f724d83b7..780edc594 100644 --- a/src/client/java/minicraft/item/FurnitureItem.java +++ b/src/client/java/minicraft/item/FurnitureItem.java @@ -83,7 +83,7 @@ public boolean canAttack() { * What happens when you press the "Attack" key with the furniture in your hands */ public boolean interactOn(Tile tile, Level level, int xt, int yt, Player player, Direction attackDir) { - if (tile.mayPass(level, xt, yt, furniture)) { // IsRideable is looked at first to prevent unnecessary checking for if a boat can swim; If the furniture can go on the tile + if (tile.mayPass(level, xt, yt, furniture)) { // If the furniture can go on the tile Sound.play("craft"); // Placed furniture's X and Y positions diff --git a/src/client/java/minicraft/saveload/Load.java b/src/client/java/minicraft/saveload/Load.java index 3aafed30e..c2f2b6fa4 100644 --- a/src/client/java/minicraft/saveload/Load.java +++ b/src/client/java/minicraft/saveload/Load.java @@ -1269,8 +1269,8 @@ private static Entity getEntity(String string, int mobLevel) { return new KnightStatue(0); case "ObsidianKnight": return new ObsidianKnight(0); - case "Boat": - return new Boat(Direction.getDirection(0)); + case "Boat": + return new Boat(Direction.NONE); default: Logging.SAVELOAD.error("LOAD ERROR: Unknown or outdated entity requested: " + string); return null;