Skip to content

Commit

Permalink
Remove debugging code and make vehicle enter blocked for boats/mineca…
Browse files Browse the repository at this point in the history
…rts if Controllable is not enabled
  • Loading branch information
fullwall committed Aug 19, 2016
1 parent b1afe0d commit 73854b8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
4 changes: 3 additions & 1 deletion main/src/main/java/net/citizensnpcs/EventListen.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -490,7 +491,8 @@ public void onVehicleEnter(VehicleEnterEvent event) {
if (!npcRegistry.isNPC(event.getEntered()))
return;
NPC npc = npcRegistry.getNPC(event.getEntered());
if (npc.getEntity().getType() == EntityType.HORSE && !npc.getTrait(Controllable.class).isEnabled()) {
if ((npc.getEntity().getType() == EntityType.HORSE || npc.getEntity().getType() == EntityType.BOAT
|| npc.getEntity() instanceof Minecart) && !npc.getTrait(Controllable.class).isEnabled()) {
event.setCancelled(true);
}
}
Expand Down
3 changes: 0 additions & 3 deletions main/src/main/java/net/citizensnpcs/commands/NPCCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
Expand Down Expand Up @@ -1013,7 +1011,6 @@ public void npc(CommandContext args, CommandSender sender, final NPC npc) {
Messaging.send(sender,
String.format(format, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), loc.getWorld().getName()));
}
((LivingEntity) npc.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1, 10));
Messaging.send(sender, " <a>Traits<e>");
for (Trait trait : npc.getTraits()) {
if (CitizensAPI.getTraitFactory().isInternalTrait(trait))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package net.citizensnpcs.npc.ai;

import java.util.List;

import org.bukkit.util.Vector;

import com.google.common.collect.Lists;

import net.citizensnpcs.api.astar.pathfinder.BlockSource;
import net.citizensnpcs.api.astar.pathfinder.NeighbourGeneratorBlockExaminer;
import net.citizensnpcs.api.astar.pathfinder.PathPoint;

public class EnhancedMovementExaminer implements NeighbourGeneratorBlockExaminer {
@Override
public float getCost(BlockSource source, PathPoint point) {
return 0;
}

@Override
public List<PathPoint> getNeighbours(BlockSource source, PathPoint point) {
Vector location = point.getVector();
List<PathPoint> neighbours = Lists.newArrayList();
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
if (x == 0 && y == 0 && z == 0)
continue;
if (x != 0 && z != 0)
continue;
Vector mod = location.clone().add(new Vector(x, y, z));
if (mod.equals(location))
continue;
neighbours.add(point.createAtOffset(mod));
}
}
}
return null;
}

@Override
public PassableState isPassable(BlockSource source, PathPoint point) {
return null;
}
}

0 comments on commit 73854b8

Please sign in to comment.