Skip to content

Commit

Permalink
Fix issues with Friendly Villagers
Browse files Browse the repository at this point in the history
  • Loading branch information
MetallicGoat committed Jan 17, 2024
1 parent ad89454 commit c5c5ff5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.metallicgoat</groupId>
<artifactId>MBedwarsTweaks</artifactId>
<version>3.3.2</version>
<version>4.0.0</version>

<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

public class MBedwarsTweaksPlugin extends JavaPlugin {

public static final int MIN_MBEDWARS_API_VER = 25;
public static final String MIN_MBEDWARS_VER_NAME = "5.3.3";
public static final int MIN_MBEDWARS_API_VER = 100;
public static final String MIN_MBEDWARS_VER_NAME = "5.4";

@Getter
private static MBedwarsTweaksPlugin instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,16 @@ private void startLooking() {

if (!visiblePlayers.isEmpty()) {
// Get the closest player
final Player lookAtPlayer = visiblePlayers.stream()
final Optional<Player> optionalLookAtPlayer = visiblePlayers.stream()
.filter(p -> p.getWorld() == world)
.min(Comparator.comparingDouble(p -> p.getLocation().distance(hologramEntity.getLocation())))
.get();
.min(Comparator.comparingDouble(p -> p.getLocation().distance(hologramEntity.getLocation())));

// Final location
final Location moveTo = hologramEntity.getLocation().setDirection(lookAtPlayer.getLocation().subtract(hologramEntity.getLocation()).toVector());
// Rare case, where player has changed worlds or something
if (!optionalLookAtPlayer.isPresent())
continue;

final Player lookAtPlayer = optionalLookAtPlayer.get(); // The player to look at
final Location moveTo = hologramEntity.getLocation().setDirection(lookAtPlayer.getLocation().subtract(hologramEntity.getLocation()).toVector()); // final location
final float currentYaw = hologramEntity.getLocation().getYaw(); // where the villager is currently facing
final float targetYaw = moveTo.getYaw(); // Where we eventually want to end up
final float difference = targetYaw - currentYaw; // How many degrees the npc needs to turn
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: MBedwarsTweaks
version: 3.3.2
version: 4.0.0
author: MetallicGoat
main: me.metallicgoat.tweaksaddon.MBedwarsTweaksPlugin
description: Adds some extra customizability to MBedwars
Expand Down

0 comments on commit c5c5ff5

Please sign in to comment.