Fix some bugs with sounds

This commit is contained in:
fullwall 2014-05-22 09:11:44 +08:00
parent 7a12d26a8e
commit 355b46e573
30 changed files with 47 additions and 34 deletions

View File

@ -1252,9 +1252,21 @@ public class NPCCommands {
hurtSound = args.getFlag("hurt").equals("d") ? null : NMS.getSound(args.getFlag("hurt"));
}
}
npc.data().setPersistent(NPC.DEATH_SOUND_METADATA, deathSound);
npc.data().setPersistent(NPC.HURT_SOUND_METADATA, hurtSound);
npc.data().setPersistent(NPC.AMBIENT_SOUND_METADATA, ambientSound);
if (deathSound == null) {
npc.data().remove(NPC.DEATH_SOUND_METADATA);
} else {
npc.data().setPersistent(NPC.DEATH_SOUND_METADATA, deathSound);
}
if (hurtSound == null) {
npc.data().remove(NPC.HURT_SOUND_METADATA);
} else {
npc.data().setPersistent(NPC.HURT_SOUND_METADATA, hurtSound);
}
if (ambientSound == null) {
npc.data().remove(ambientSound);
} else {
npc.data().setPersistent(NPC.AMBIENT_SOUND_METADATA, ambientSound);
}
Messaging.sendTr(sender, Messages.SOUND_SET, npc.getName(), ambientSound, hurtSound, deathSound);
}

View File

@ -59,12 +59,13 @@ public class BatController extends MobEntityController {
@Override
protected String aS() {
return npc == null ? super.aS() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aS());
return npc == null || !npc.data().has(NPC.HURT_SOUND_METADATA) ? super.aS() : npc.data().get(
NPC.HURT_SOUND_METADATA, super.aS());
}
@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aT());
return npc == null || !npc.data().has(NPC.DEATH_SOUND_METADATA) ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aT());
}
@Override
@ -148,7 +149,7 @@ public class BatController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -135,7 +135,7 @@ public class BlazeController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -177,7 +177,7 @@ public class CaveSpiderController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -174,7 +174,7 @@ public class ChickenController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -177,7 +177,7 @@ public class CowController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -176,7 +176,7 @@ public class CreeperController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -156,7 +156,7 @@ public class EnderDragonController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -192,7 +192,7 @@ public class EndermanController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
private void updateAIWithMovement() {

View File

@ -118,7 +118,7 @@ public class GhastController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -152,7 +152,7 @@ public class GiantController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -175,7 +175,7 @@ public class HorseController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
private void updateAIWithMovement() {

View File

@ -149,7 +149,7 @@ public class IronGolemController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -160,7 +160,7 @@ public class MagmaCubeController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -161,7 +161,7 @@ public class MushroomCowController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -160,7 +160,7 @@ public class OcelotController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -167,7 +167,7 @@ public class PigController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -160,7 +160,7 @@ public class PigZombieController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -160,7 +160,7 @@ public class SheepController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -159,7 +159,7 @@ public class SilverfishController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -150,7 +150,7 @@ public class SkeletonController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -161,7 +161,7 @@ public class SlimeController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -149,7 +149,7 @@ public class SnowmanController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -159,7 +159,7 @@ public class SpiderController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -150,7 +150,7 @@ public class SquidController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -178,7 +178,7 @@ public class VillagerController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -149,7 +149,7 @@ public class WitchController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -128,7 +128,7 @@ public class WitherController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
private void updateAIWithMovement() {

View File

@ -162,7 +162,7 @@ public class WolfController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override

View File

@ -150,7 +150,7 @@ public class ZombieController extends MobEntityController {
@Override
protected String t() {
return npc == null ? super.aS() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override