Commit ccb3655c by Jonathan Thomas

Death messages skip tamed creatures and players, to prevent duplicate death messages

parent 5a46f890
......@@ -8,7 +8,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Added
- New automated deployments for Modrinth and CurseForge (GitLab CI Pipeline)
- Death messages added for all named creatures (RIP)
- Death messages added for all named creatures except players and tamed ones (RIP)
### Fixed
- Parse OpenAI JSON error messages, to display a more readable error message
......
......@@ -7,6 +7,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
......@@ -70,6 +71,15 @@ public class MixinLivingEntity implements LivingEntityInterface {
World world = entity.getWorld();
if (!world.isClient() && entity.hasCustomName()) {
// Skip tamed entities and players
if (entity instanceof TameableEntity && ((TameableEntity) entity).isTamed()) {
return;
}
if (entity instanceof PlayerEntity) {
return;
}
// Get the original death message
Text deathMessage = entity.getDamageTracker().getDeathMessage();
// Broadcast the death message to all players in the world
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment