Skip to content

Commit

Permalink
Fix slime movement
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Dec 9, 2014
1 parent dfb2999 commit 8ec41f1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/main/java/net/citizensnpcs/commands/NPCCommands.java
Expand Up @@ -268,7 +268,7 @@ public void copy(CommandContext args, CommandSender sender, NPC npc) throws Comm
}

CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy)
: new CommandSenderCreateNPCEvent(sender, copy);
: new CommandSenderCreateNPCEvent(sender, copy);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
event.getNPC().destroy();
Expand Down Expand Up @@ -344,7 +344,7 @@ public void create(CommandContext args, CommandSender sender, NPC npc) throws Co
spawnLoc = args.getSenderLocation();
}
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc)
: new CommandSenderCreateNPCEvent(sender, npc);
: new CommandSenderCreateNPCEvent(sender, npc);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
npc.destroy();
Expand Down Expand Up @@ -1021,7 +1021,7 @@ public void pose(CommandContext args, CommandSender sender, NPC npc) throws Comm
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
public void power(CommandContext args, CommandSender sender, NPC npc) {
Messaging
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
}

@Command(
Expand All @@ -1044,7 +1044,7 @@ public void profession(CommandContext args, CommandSender sender, NPC npc) throw
}

@Command(aliases = { "npc" }, usage = "remove|rem (all|id|name)", desc = "Remove a NPC", modifiers = { "remove",
"rem" }, min = 1, max = 2)
"rem" }, min = 1, max = 2)
@Requirements
public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
if (args.argsLength() == 2) {
Expand Down Expand Up @@ -1191,7 +1191,7 @@ public void skeletonType(CommandContext args, CommandSender sender, NPC npc) thr
min = 1,
max = 2,
permission = "citizens.npc.skin")
@Requirements(types = EntityType.PLAYER)
@Requirements(types = EntityType.PLAYER, selected = true, ownership = true)
public void skin(final CommandContext args, final CommandSender sender, final NPC npc) throws CommandException {
String skinName = npc.getName();
if (args.hasFlag('c')) {
Expand Down
21 changes: 19 additions & 2 deletions src/main/java/net/citizensnpcs/npc/entity/SlimeController.java
Expand Up @@ -9,6 +9,8 @@
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R1.Block;
import net.minecraft.server.v1_8_R1.BlockPosition;
import net.minecraft.server.v1_8_R1.ControllerMove;
import net.minecraft.server.v1_8_R1.EntityHuman;
import net.minecraft.server.v1_8_R1.EntitySlime;
import net.minecraft.server.v1_8_R1.NBTTagCompound;
import net.minecraft.server.v1_8_R1.World;
Expand Down Expand Up @@ -44,6 +46,7 @@ public EntitySlimeNPC(World world, NPC npc) {
if (npc != null) {
setSize(3);
NMS.clearGoals(goalSelector, targetSelector);
this.moveController = new ControllerMove(this);
}
}

Expand Down Expand Up @@ -77,13 +80,26 @@ public boolean cb() {
return false; // shouldLeash
}

@Override
public void cf() {

}

@Override
public void collide(net.minecraft.server.v1_8_R1.Entity entity) {
// this method is called by both the entities involved - cancelling
// it will not stop the NPC from moving.
super.collide(entity);
if (npc != null)
if (npc != null) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
}

@Override
public void d(EntityHuman human) {
if (npc == null) {
super.d(human);
}
}

@Override
Expand All @@ -101,8 +117,9 @@ protected void D() {
@Override
public void doTick() {
super.doTick();
if (npc != null)
if (npc != null) {
npc.update();
}
}

@Override
Expand Down

0 comments on commit 8ec41f1

Please sign in to comment.