Skip to content

Commit

Permalink
Fixes to SneakingTrait, maybe added hearts to ParticlesTrait?
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeebiss committed Mar 22, 2013
1 parent 1db6c9a commit 48355d0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 13 deletions.
34 changes: 24 additions & 10 deletions src/main/java/net/aufdemrand/denizen/CommandHandler.java
Expand Up @@ -392,17 +392,29 @@ public void sitting(CommandContext args, CommandSender sender, NPC npc) throws C
min = 1, max = 3, permission = "npc.stand")
@Requirements(selected = true, ownership = true)
public void standing(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
if (!npc.hasTrait(SittingTrait.class)) npc.addTrait(SittingTrait.class);
SittingTrait trait = npc.getTrait(SittingTrait.class);

if (!trait.isSitting()) {

if (npc.hasTrait(SittingTrait.class)) {
SittingTrait trait = npc.getTrait(SittingTrait.class);
if (!trait.isSitting()) {
npc.removeTrait(SittingTrait.class);
Messaging.send(sender, ChatColor.RED + npc.getName() + " is already standing!");
return;
}
trait.stand();
npc.removeTrait(SittingTrait.class);
Messaging.send(sender, ChatColor.RED + npc.getName() + " is already standing!");
return;
}
} else if (npc.hasTrait(SneakingTrait.class)) {
SneakingTrait trait = npc.getTrait(SneakingTrait.class);
if (!trait.isSneaking()) {
npc.removeTrait(SittingTrait.class);
Messaging.send(sender, ChatColor.RED + npc.getName() + " is already standing!");
return;
}
trait.stand();
npc.removeTrait(SneakingTrait.class);
}


trait.stand();
npc.removeTrait(SittingTrait.class);

}

/*
Expand Down Expand Up @@ -550,6 +562,8 @@ public void playEffect(CommandContext args, CommandSender sender, NPC npc) throw
trait.setEffect("POTBREAK");
} else if (name.equalsIgnoreCase("potion")) {
trait.setEffect("POTION");
} else if (name.equalsIgnoreCase("heart")) {
trait.setEffect("HEART");
} else Messaging.send(sender, ChatColor.RED + "Not a valid effect name!");

} else Messaging.send(sender, ChatColor.RED + "Please specify an effect name!");
Expand All @@ -561,7 +575,7 @@ public void playEffect(CommandContext args, CommandSender sender, NPC npc) throw
*/
@Command(
aliases = { "npc" }, usage = "sneak",
desc = "Makes the NPC crouch.", flags = "", modifiers = { "sneak, coruch" },
desc = "Makes the NPC crouch.", flags = "", modifiers = { "sneak", "crouch" },
min = 1, max = 3, permission = "npc.sneak")
@Requirements(selected = true, ownership = true)
public void sneaking(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
Expand Down
Expand Up @@ -8,13 +8,16 @@
import net.minecraft.server.v1_5_R2.EntityLiving;

import org.bukkit.Effect;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_5_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftLivingEntity;
import org.bukkit.entity.Wolf;

public class ParticlesTrait extends Trait {

public enum EffectType { NONE, SMOKE, FLAME, ENDER, POTBREAK, POTION }
public enum EffectType { NONE, SMOKE, FLAME, ENDER, POTBREAK, HEART, POTION }

//DataWatcher dw;
//EntityLiving el;
Expand All @@ -27,14 +30,17 @@ public enum EffectType { NONE, SMOKE, FLAME, ENDER, POTBREAK, POTION }
int wait = 10;
int counter = 0;
//int c = 0;
//int tempcounter = 0;
int tempcounter = 0;

@Override
public void run() {
if (world == null) {
return;
}

if (tempcounter > 20) {
dB.log("current effect: " + effectType.name());
}
counter++;

switch (effectType) {
Expand Down Expand Up @@ -73,6 +79,14 @@ public void run() {
}
dw.watch(8, Integer.valueOf(c));
*/
break;
case HEART:
if (counter > wait) {
dB.log("...playing heart effect");
playHeartEffect();
counter = 0;
}
break;
}


Expand Down Expand Up @@ -104,6 +118,19 @@ public void playPotionBreakEffect() {
world.playEffect(location, Effect.POTION_BREAK, 0);
}

public void playHeartEffect() {
Location location = npc.getBukkitEntity().getLocation();
Wolf tempWolf = (Wolf) world.spawn(location, Wolf.class);
tempWolf.playEffect(EntityEffect.WOLF_HEARTS);
tempWolf.remove();

//((CraftWorld) world).getHandle().a(
// "heart",
// location.getBlockX(),
// location.getBlockY(),
// location.getBlockZ());
}

public void playSmokeEffect() {
Location location = npc.getBukkitEntity().getLocation();
world.playEffect(location, Effect.SMOKE, 0);
Expand Down
@@ -1,6 +1,7 @@
package net.aufdemrand.denizen.npc.traits;

import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.minecraft.server.v1_5_R2.EntityHuman;
Expand Down Expand Up @@ -42,7 +43,7 @@ public void sneak() {
/**
* Makes the NPC stand
*/
public void stand() {
public void stand() {
DenizenAPI.getDenizenNPC(npc).action("stand", null);

((EntityPlayer) eh).getDataWatcher().watch(0, Byte.valueOf((byte) 0x00));
Expand Down

0 comments on commit 48355d0

Please sign in to comment.