From 36cbef81a715960a89c2a47aa47ec3d24a6c0f8c Mon Sep 17 00:00:00 2001 From: fullwall Date: Fri, 24 Jun 2022 12:43:23 +0800 Subject: [PATCH] Fix dropstrait, allow player hurt/death sound to be set --- .../java/net/citizensnpcs/commands/NPCCommands.java | 2 +- .../main/java/net/citizensnpcs/trait/DropsTrait.java | 3 +++ .../nms/v1_10_R1/entity/EntityHumanNPC.java | 11 +++++++++++ .../nms/v1_11_R1/entity/EntityHumanNPC.java | 11 +++++++++++ .../nms/v1_12_R1/entity/EntityHumanNPC.java | 11 +++++++++++ .../nms/v1_13_R2/entity/EntityHumanNPC.java | 11 +++++++++++ .../nms/v1_14_R1/entity/EntityHumanNPC.java | 11 +++++++++++ .../nms/v1_15_R1/entity/EntityHumanNPC.java | 11 +++++++++++ .../nms/v1_16_R3/entity/EntityHumanNPC.java | 11 +++++++++++ .../nms/v1_17_R1/entity/EntityHumanNPC.java | 11 +++++++++++ .../nms/v1_18_R2/entity/EntityHumanNPC.java | 11 +++++++++++ .../nms/v1_19_R1/entity/EntityHumanNPC.java | 11 +++++++++++ .../nms/v1_8_R3/entity/EntityHumanNPC.java | 10 ++++++++++ 13 files changed, 124 insertions(+), 1 deletion(-) diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 9aebae171..428d1b1bf 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -2285,7 +2285,7 @@ public class NPCCommands { min = 1, max = 1, permission = "citizens.npc.sound") - @Requirements(selected = true, ownership = true, livingEntity = true, excludedTypes = { EntityType.PLAYER }) + @Requirements(selected = true, ownership = true, livingEntity = true) public void sound(CommandContext args, CommandSender sender, NPC npc) throws CommandException { String ambientSound = npc.data().get(NPC.AMBIENT_SOUND_METADATA); String deathSound = npc.data().get(NPC.DEATH_SOUND_METADATA); diff --git a/main/src/main/java/net/citizensnpcs/trait/DropsTrait.java b/main/src/main/java/net/citizensnpcs/trait/DropsTrait.java index 17d83b346..7f2dc4eff 100644 --- a/main/src/main/java/net/citizensnpcs/trait/DropsTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/DropsTrait.java @@ -102,6 +102,9 @@ public class DropsTrait extends Trait { @Override public void onClick(InventoryMenuSlot slot, InventoryClickEvent event) { + if (slot.getCurrentItem() != null && slot.getCurrentItem().getType().name().equals("BARRIER")) + return; + event.setCancelled(false); if (event.getAction().name().contains("PICKUP")) { chances.remove(event.getSlot()); } else if (event.getAction().name().contains("PLACE")) { diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java index 73b609759..1a89e41a7 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java @@ -55,6 +55,7 @@ import net.minecraft.server.v1_10_R1.Packet; import net.minecraft.server.v1_10_R1.PacketPlayOutEntityEquipment; import net.minecraft.server.v1_10_R1.PathType; import net.minecraft.server.v1_10_R1.PlayerInteractManager; +import net.minecraft.server.v1_10_R1.SoundEffect; import net.minecraft.server.v1_10_R1.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { @@ -107,6 +108,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable this.bz.put(pathtype, Float.valueOf(f)); } + @Override + protected SoundEffect bV() { + return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA); + } + + @Override + protected SoundEffect bW() { + return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA); + } + @Override public void collide(net.minecraft.server.v1_10_R1.Entity entity) { // this method is called by both the entities involved - cancelling diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java index 9971a2679..50de87842 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java @@ -57,6 +57,7 @@ import net.minecraft.server.v1_11_R1.Packet; import net.minecraft.server.v1_11_R1.PacketPlayOutEntityEquipment; import net.minecraft.server.v1_11_R1.PathType; import net.minecraft.server.v1_11_R1.PlayerInteractManager; +import net.minecraft.server.v1_11_R1.SoundEffect; import net.minecraft.server.v1_11_R1.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { @@ -126,6 +127,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.update(); } + @Override + protected SoundEffect bW() { + return NMSImpl.getSoundEffect(npc, super.bW(), NPC.DEATH_SOUND_METADATA); + } + + @Override + protected SoundEffect bX() { + return NMSImpl.getSoundEffect(npc, super.bX(), NPC.HURT_SOUND_METADATA); + } + @Override public void collide(net.minecraft.server.v1_11_R1.Entity entity) { // this method is called by both the entities involved - cancelling diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java index eb5d1d0f6..a14f8c6a7 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java @@ -61,6 +61,7 @@ import net.minecraft.server.v1_12_R1.Packet; import net.minecraft.server.v1_12_R1.PacketPlayOutEntityEquipment; import net.minecraft.server.v1_12_R1.PathType; import net.minecraft.server.v1_12_R1.PlayerInteractManager; +import net.minecraft.server.v1_12_R1.SoundEffect; import net.minecraft.server.v1_12_R1.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { @@ -139,6 +140,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.update(); } + @Override + protected SoundEffect cf() { + return NMSImpl.getSoundEffect(npc, super.cf(), NPC.DEATH_SOUND_METADATA); + } + @Override public void collide(net.minecraft.server.v1_12_R1.Entity entity) { // this method is called by both the entities involved - cancelling @@ -149,6 +155,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable } } + @Override + protected SoundEffect d(DamageSource damagesource) { + return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA); + } + @Override public boolean damageEntity(DamageSource damagesource, float f) { // knock back velocity is cancelled and sent to client for handling when diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java index f721e145d..650f8b607 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java @@ -61,6 +61,7 @@ import net.minecraft.server.v1_13_R2.Packet; import net.minecraft.server.v1_13_R2.PacketPlayOutEntityEquipment; import net.minecraft.server.v1_13_R2.PathType; import net.minecraft.server.v1_13_R2.PlayerInteractManager; +import net.minecraft.server.v1_13_R2.SoundEffect; import net.minecraft.server.v1_13_R2.WorldServer; public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity { @@ -139,6 +140,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable } } + @Override + protected SoundEffect cs() { + return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA); + } + + @Override + protected SoundEffect d(DamageSource damagesource) { + return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA); + } + @Override public boolean damageEntity(DamageSource damagesource, float f) { // knock back velocity is cancelled and sent to client for handling when diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java index 6d93ffe10..eb784a13c 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java @@ -59,6 +59,7 @@ import net.minecraft.server.v1_14_R1.Packet; import net.minecraft.server.v1_14_R1.PacketPlayOutEntityEquipment; import net.minecraft.server.v1_14_R1.PathType; import net.minecraft.server.v1_14_R1.PlayerInteractManager; +import net.minecraft.server.v1_14_R1.SoundEffect; import net.minecraft.server.v1_14_R1.Vec3D; import net.minecraft.server.v1_14_R1.WorldServer; @@ -246,6 +247,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable return skinTracker; } + @Override + protected SoundEffect getSoundDeath() { + return NMSImpl.getSoundEffect(npc, super.getSoundDeath(), NPC.DEATH_SOUND_METADATA); + } + + @Override + protected SoundEffect getSoundHurt(DamageSource damagesource) { + return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA); + } + @Override public boolean inBlock() { if (npc == null || noclip || isSleeping()) { diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java index 75eced460..ae6f1a7a3 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java @@ -59,6 +59,7 @@ import net.minecraft.server.v1_15_R1.Packet; import net.minecraft.server.v1_15_R1.PacketPlayOutEntityEquipment; import net.minecraft.server.v1_15_R1.PathType; import net.minecraft.server.v1_15_R1.PlayerInteractManager; +import net.minecraft.server.v1_15_R1.SoundEffect; import net.minecraft.server.v1_15_R1.Vec3D; import net.minecraft.server.v1_15_R1.WorldServer; @@ -239,6 +240,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable return skinTracker; } + @Override + protected SoundEffect getSoundDeath() { + return NMSImpl.getSoundEffect(npc, super.getSoundDeath(), NPC.DEATH_SOUND_METADATA); + } + + @Override + protected SoundEffect getSoundHurt(DamageSource damagesource) { + return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA); + } + @Override public void h(double x, double y, double z) { Vector vector = Util.callPushEvent(npc, x, y, z); diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java index be8c70226..2ef98872b 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java @@ -67,6 +67,7 @@ import net.minecraft.server.v1_16_R3.Packet; import net.minecraft.server.v1_16_R3.PacketPlayOutEntityEquipment; import net.minecraft.server.v1_16_R3.PathType; import net.minecraft.server.v1_16_R3.PlayerInteractManager; +import net.minecraft.server.v1_16_R3.SoundEffect; import net.minecraft.server.v1_16_R3.Vec3D; import net.minecraft.server.v1_16_R3.WorldServer; @@ -252,6 +253,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable return skinTracker; } + @Override + protected SoundEffect getSoundDeath() { + return NMSImpl.getSoundEffect(npc, super.getSoundDeath(), NPC.DEATH_SOUND_METADATA); + } + + @Override + protected SoundEffect getSoundHurt(DamageSource damagesource) { + return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA); + } + @Override public void i(double x, double y, double z) { Vector vector = Util.callPushEvent(npc, x, y, z); diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java index 4d9ed3cd1..2f4458b2e 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java @@ -55,6 +55,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; +import net.minecraft.sounds.SoundEvent; import net.minecraft.stats.ServerStatsCounter; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; @@ -217,6 +218,16 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable return controllerJump; } + @Override + protected SoundEvent getDeathSound() { + return NMSImpl.getSoundEffect(npc, super.getDeathSound(), NPC.DEATH_SOUND_METADATA); + } + + @Override + protected SoundEvent getHurtSound(DamageSource damagesource) { + return NMSImpl.getSoundEffect(npc, super.getHurtSound(damagesource), NPC.HURT_SOUND_METADATA); + } + public PlayerMoveControl getMoveControl() { return controllerMove; } diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java index bdbd05a65..d565be55a 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java @@ -56,6 +56,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; +import net.minecraft.sounds.SoundEvent; import net.minecraft.stats.ServerStatsCounter; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; @@ -218,6 +219,16 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable return controllerJump; } + @Override + protected SoundEvent getDeathSound() { + return NMSImpl.getSoundEffect(npc, super.getDeathSound(), NPC.DEATH_SOUND_METADATA); + } + + @Override + protected SoundEvent getHurtSound(DamageSource damagesource) { + return NMSImpl.getSoundEffect(npc, super.getHurtSound(damagesource), NPC.HURT_SOUND_METADATA); + } + public PlayerMoveControl getMoveControl() { return controllerMove; } diff --git a/v1_19_R1/src/main/java/net/citizensnpcs/nms/v1_19_R1/entity/EntityHumanNPC.java b/v1_19_R1/src/main/java/net/citizensnpcs/nms/v1_19_R1/entity/EntityHumanNPC.java index 55e636151..29650c27f 100644 --- a/v1_19_R1/src/main/java/net/citizensnpcs/nms/v1_19_R1/entity/EntityHumanNPC.java +++ b/v1_19_R1/src/main/java/net/citizensnpcs/nms/v1_19_R1/entity/EntityHumanNPC.java @@ -57,6 +57,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; +import net.minecraft.sounds.SoundEvent; import net.minecraft.stats.ServerStatsCounter; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; @@ -220,6 +221,16 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable return controllerJump; } + @Override + protected SoundEvent getDeathSound() { + return NMSImpl.getSoundEffect(npc, super.getDeathSound(), NPC.DEATH_SOUND_METADATA); + } + + @Override + protected SoundEvent getHurtSound(DamageSource damagesource) { + return NMSImpl.getSoundEffect(npc, super.getHurtSound(damagesource), NPC.HURT_SOUND_METADATA); + } + public PlayerMoveControl getMoveControl() { return controllerMove; } diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java index 9f5ebf370..292de4253 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java @@ -103,6 +103,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable : !npc.isProtected(); } + @Override + protected String bo() { + return NMSImpl.getSoundEffect(npc, super.bo(), NPC.HURT_SOUND_METADATA); + } + + @Override + protected String bp() { + return NMSImpl.getSoundEffect(npc, super.bp(), NPC.DEATH_SOUND_METADATA); + } + @Override public void collide(net.minecraft.server.v1_8_R3.Entity entity) { // this method is called by both the entities involved - cancelling