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
b2450841
Commit
b2450841
authored
May 15, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bucketable' into 'develop'
Fixing Bucketable Entities w/ ChatData See merge request
!4
parents
c602f2cd
c165ed73
Pipeline
#12212
passed with stage
in 1 minute 51 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
2 deletions
+68
-2
CHANGELOG.md
CHANGELOG.md
+2
-0
ChatDataManager.java
src/main/java/com/owlmaddie/chat/ChatDataManager.java
+15
-0
MixinBucketable.java
src/main/java/com/owlmaddie/mixin/MixinBucketable.java
+47
-0
MixinMobEntity.java
src/main/java/com/owlmaddie/mixin/MixinMobEntity.java
+2
-1
creaturechat.mixins.json
src/main/resources/creaturechat.mixins.json
+2
-1
No files found.
CHANGELOG.md
View file @
b2450841
...
@@ -12,11 +12,13 @@ All notable changes to **CreatureChat** are documented in this file. The format
...
@@ -12,11 +12,13 @@ All notable changes to **CreatureChat** are documented in this file. The format
-
Added support for commands to use different data types (
`String`
,
`Integer`
)
-
Added support for commands to use different data types (
`String`
,
`Integer`
)
### Changed
### Changed
-
Water bucket is now ignored for item-giving detection (since the entity is despawned immediately)
-
Updated error messages to
`RED`
color for maximum attention
-
Updated error messages to
`RED`
color for maximum attention
-
Updated
`/creaturechat help`
output
-
Updated
`/creaturechat help`
output
-
Updated
`README.md`
with new command documentation
-
Updated
`README.md`
with new command documentation
### Fixed
### Fixed
-
Bucketing a creature now maintains chat history when respawned
-
Chats broken when OS locale is non-English language (i.e.
`assistant to ass\u0131stant`
)
-
Chats broken when OS locale is non-English language (i.e.
`assistant to ass\u0131stant`
)
## [1.0.3] - 2024-05-10
## [1.0.3] - 2024-05-10
...
...
src/main/java/com/owlmaddie/chat/ChatDataManager.java
View file @
b2450841
...
@@ -429,6 +429,21 @@ public class ChatDataManager {
...
@@ -429,6 +429,21 @@ public class ChatDataManager {
return
entityChatDataMap
.
computeIfAbsent
(
entityId
,
k
->
new
EntityChatData
(
entityId
,
""
));
return
entityChatDataMap
.
computeIfAbsent
(
entityId
,
k
->
new
EntityChatData
(
entityId
,
""
));
}
}
// Update the UUID in the map (i.e. bucketed entity and then released, changes their UUID)
public
void
updateUUID
(
String
oldUUID
,
String
newUUID
)
{
EntityChatData
data
=
entityChatDataMap
.
remove
(
oldUUID
);
if
(
data
!=
null
)
{
data
.
entityId
=
newUUID
;
entityChatDataMap
.
put
(
newUUID
,
data
);
LOGGER
.
info
(
"Updated chat data from UUID ("
+
oldUUID
+
") to UUID ("
+
newUUID
+
")"
);
// Broadcast to all players
ServerPackets
.
BroadcastPacketMessage
(
data
);
}
else
{
LOGGER
.
info
(
"Unable to update chat data, UUID not found: "
+
oldUUID
);
}
}
// Generate quest data for this server session
// Generate quest data for this server session
public
void
generateQuest
()
{
public
void
generateQuest
()
{
// Get items needed for Quest prompt
// Get items needed for Quest prompt
...
...
src/main/java/com/owlmaddie/mixin/MixinBucketable.java
0 → 100644
View file @
b2450841
package
com
.
owlmaddie
.
mixin
;
import
com.owlmaddie.chat.ChatDataManager
;
import
net.minecraft.entity.Bucketable
;
import
net.minecraft.entity.mob.MobEntity
;
import
net.minecraft.item.ItemStack
;
import
net.minecraft.nbt.NbtCompound
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
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
java.util.UUID
;
/**
* The {@code MixinBucketable} mixin class handles entities that are placed into a bucket, despawned, respawned
* and updates our chat history for the newly spawned entity.
*/
@Mixin
(
Bucketable
.
class
)
public
interface
MixinBucketable
{
//
@Inject
(
method
=
"copyDataToStack(Lnet/minecraft/entity/mob/MobEntity;Lnet/minecraft/item/ItemStack;)V"
,
at
=
@At
(
"TAIL"
))
private
static
void
addCCUUIDToStack
(
MobEntity
entity
,
ItemStack
stack
,
CallbackInfo
ci
)
{
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
"creaturechat"
);
UUID
originalUUID
=
entity
.
getUuid
();
LOGGER
.
info
(
"Saving original UUID of bucketed entity: "
+
originalUUID
);
// Add the original UUID to the ItemStack NBT as "CCUUID"
NbtCompound
nbt
=
stack
.
getOrCreateNbt
();
nbt
.
putUuid
(
"CCUUID"
,
originalUUID
);
}
// New method to read CCUUID from NBT
@Inject
(
method
=
"copyDataFromNbt(Lnet/minecraft/entity/mob/MobEntity;Lnet/minecraft/nbt/NbtCompound;)V"
,
at
=
@At
(
"TAIL"
))
private
static
void
readCCUUIDFromNbt
(
MobEntity
entity
,
NbtCompound
nbt
,
CallbackInfo
ci
)
{
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
"creaturechat"
);
UUID
newUUID
=
entity
.
getUuid
();
if
(
nbt
.
contains
(
"CCUUID"
))
{
UUID
originalUUID
=
nbt
.
getUuid
(
"CCUUID"
);
LOGGER
.
info
(
"Duplicating bucketed chat data for original UUID ("
+
originalUUID
+
") to cloned entity: ("
+
newUUID
+
")"
);
ChatDataManager
.
getServerInstance
().
updateUUID
(
originalUUID
.
toString
(),
newUUID
.
toString
());
}
}
}
\ No newline at end of file
src/main/java/com/owlmaddie/mixin/MixinMobEntity.java
View file @
b2450841
...
@@ -5,6 +5,7 @@ import com.owlmaddie.network.ServerPackets;
...
@@ -5,6 +5,7 @@ import com.owlmaddie.network.ServerPackets;
import
net.minecraft.entity.mob.MobEntity
;
import
net.minecraft.entity.mob.MobEntity
;
import
net.minecraft.entity.player.PlayerEntity
;
import
net.minecraft.entity.player.PlayerEntity
;
import
net.minecraft.item.ItemStack
;
import
net.minecraft.item.ItemStack
;
import
net.minecraft.item.Items
;
import
net.minecraft.server.network.ServerPlayerEntity
;
import
net.minecraft.server.network.ServerPlayerEntity
;
import
net.minecraft.util.ActionResult
;
import
net.minecraft.util.ActionResult
;
import
net.minecraft.util.Hand
;
import
net.minecraft.util.Hand
;
...
@@ -25,7 +26,7 @@ public class MixinMobEntity {
...
@@ -25,7 +26,7 @@ public class MixinMobEntity {
MobEntity
thisEntity
=
(
MobEntity
)
(
Object
)
this
;
MobEntity
thisEntity
=
(
MobEntity
)
(
Object
)
this
;
// Check if the player successfully interacts with an item
// Check if the player successfully interacts with an item
if
(!
itemStack
.
isEmpty
()
&&
player
instanceof
ServerPlayerEntity
)
{
if
(!
itemStack
.
isEmpty
()
&&
player
instanceof
ServerPlayerEntity
&&
itemStack
.
getItem
()
!=
Items
.
WATER_BUCKET
)
{
ServerPlayerEntity
serverPlayer
=
(
ServerPlayerEntity
)
player
;
ServerPlayerEntity
serverPlayer
=
(
ServerPlayerEntity
)
player
;
String
itemName
=
itemStack
.
getItem
().
toString
();
String
itemName
=
itemStack
.
getItem
().
toString
();
int
itemCount
=
itemStack
.
getCount
();
int
itemCount
=
itemStack
.
getCount
();
...
...
src/main/resources/creaturechat.mixins.json
View file @
b2450841
...
@@ -5,7 +5,8 @@
...
@@ -5,7 +5,8 @@
"mixins"
:
[
"mixins"
:
[
"MixinMobEntity"
,
"MixinMobEntity"
,
"MixinMobEntityAccessor"
,
"MixinMobEntityAccessor"
,
"MixinLivingEntity"
"MixinLivingEntity"
,
"MixinBucketable"
],
],
"injectors"
:
{
"injectors"
:
{
"defaultRequire"
:
1
"defaultRequire"
:
1
...
...
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