Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
CreatureChat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Public
CreatureChat
Commits
5a46f890
Commit
5a46f890
authored
May 24, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Death messages added for all named creatures (RIP)
parent
0a403a5f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
CHANGELOG.md
CHANGELOG.md
+1
-0
MixinLivingEntity.java
src/main/java/com/owlmaddie/mixin/MixinLivingEntity.java
+16
-0
ServerPackets.java
src/main/java/com/owlmaddie/network/ServerPackets.java
+7
-0
No files found.
CHANGELOG.md
View file @
5a46f890
...
...
@@ -8,6 +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)
### Fixed
-
Parse OpenAI JSON error messages, to display a more readable error message
...
...
src/main/java/com/owlmaddie/mixin/MixinLivingEntity.java
View file @
5a46f890
...
...
@@ -10,9 +10,12 @@ import net.minecraft.entity.mob.MobEntity;
import
net.minecraft.entity.player.PlayerEntity
;
import
net.minecraft.item.ItemStack
;
import
net.minecraft.server.network.ServerPlayerEntity
;
import
net.minecraft.text.Text
;
import
net.minecraft.world.World
;
import
org.spongepowered.asm.mixin.Mixin
;
import
org.spongepowered.asm.mixin.injection.At
;
import
org.spongepowered.asm.mixin.injection.Inject
;
import
org.spongepowered.asm.mixin.injection.callback.CallbackInfo
;
import
org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
;
...
...
@@ -61,6 +64,19 @@ public class MixinLivingEntity implements LivingEntityInterface {
}
}
@Inject
(
method
=
"onDeath"
,
at
=
@At
(
"HEAD"
))
private
void
onDeath
(
DamageSource
source
,
CallbackInfo
info
)
{
LivingEntity
entity
=
(
LivingEntity
)
(
Object
)
this
;
World
world
=
entity
.
getWorld
();
if
(!
world
.
isClient
()
&&
entity
.
hasCustomName
())
{
// Get the original death message
Text
deathMessage
=
entity
.
getDamageTracker
().
getDeathMessage
();
// Broadcast the death message to all players in the world
ServerPackets
.
BroadcastMessage
(
deathMessage
);
}
}
@Override
public
void
setCanTargetPlayers
(
boolean
canTarget
)
{
this
.
canTargetPlayers
=
canTarget
;
...
...
src/main/java/com/owlmaddie/network/ServerPackets.java
View file @
5a46f890
...
...
@@ -316,6 +316,13 @@ public class ServerPackets {
}
}
// Send a chat message to all players (i.e. death message)
public
static
void
BroadcastMessage
(
Text
message
)
{
for
(
ServerPlayerEntity
serverPlayer
:
serverInstance
.
getPlayerManager
().
getPlayerList
())
{
serverPlayer
.
sendMessage
(
message
,
false
);
};
}
// Send a chat message to a player which is clickable (for error messages with a link for help)
public
static
void
SendClickableError
(
PlayerEntity
player
,
String
message
,
String
url
)
{
MutableText
text
=
Text
.
literal
(
message
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment