Skip to content

Commit

Permalink
Controllable should use LookAirController for non-LivingEntity NPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Dec 1, 2016
1 parent 1ed5bf6 commit 7cd3e6d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main/src/main/java/net/citizensnpcs/trait/Controllable.java
Expand Up @@ -8,6 +8,7 @@
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -94,8 +95,14 @@ public void load(DataKey key) throws NPCLoadException {

private void loadController() {
EntityType type = npc.getEntity().getType();
if (explicitType != null)
if (explicitType != null) {
type = explicitType;
}
if (!(npc.getEntity() instanceof LivingEntity) && (explicitType == null || explicitType == EntityType.UNKNOWN
|| npc.getEntity().getType() == explicitType)) {
controller = new LookAirController();
return;
}
Class<? extends MovementController> clazz = controllerTypes.get(type);
if (clazz == null) {
controller = new GroundController();
Expand All @@ -112,8 +119,9 @@ private void loadController() {
try {
if (innerConstructor == null) {
controller = clazz.newInstance();
} else
} else {
controller = innerConstructor.newInstance(this);
}
} catch (Exception e) {
e.printStackTrace();
controller = new GroundController();
Expand Down

0 comments on commit 7cd3e6d

Please sign in to comment.