Commit a5fb3933 by Jonathan Thomas

Wandering Trader no longer despawns if it has chat data

parent 15045b4a
Pipeline #13343 passed with stages
in 2 minutes 17 seconds
...@@ -15,6 +15,7 @@ All notable changes to **CreatureChat** are documented in this file. The format ...@@ -15,6 +15,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Fixed ### Fixed
- Bees no longer forget their chat data when entering/leaving hives (writeNbt & readNbt modified) - Bees no longer forget their chat data when entering/leaving hives (writeNbt & readNbt modified)
- Vexes no longer take damage when chat data exists - Vexes no longer take damage when chat data exists
- Wandering Trader no longer despawns if it has chat data
## [1.3.0] - 2025-01-14 ## [1.3.0] - 2025-01-14
......
package com.owlmaddie.mixin;
import com.owlmaddie.chat.ChatDataManager;
import com.owlmaddie.chat.EntityChatData;
import net.minecraft.entity.passive.WanderingTraderEntity;
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;
/**
* Prevents WanderingTraderEntity from despawning if it has chat data or a character sheet.
*/
@Mixin(WanderingTraderEntity.class)
public abstract class MixinWanderingTrader {
private static final Logger LOGGER = LoggerFactory.getLogger("creaturechat");
@Inject(method = "tickDespawnDelay", at = @At("HEAD"), cancellable = true)
private void preventTraderDespawn(CallbackInfo ci) {
WanderingTraderEntity trader = (WanderingTraderEntity) (Object) this;
// Get chat data for this trader
EntityChatData chatData = ChatDataManager.getServerInstance().getOrCreateChatData(trader.getUuidAsString());
// If the character sheet is not empty, cancel the function to prevent despawning
if (!chatData.characterSheet.isEmpty()) {
ci.cancel();
}
}
}
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"MixinEntityChatData", "MixinEntityChatData",
"MixinWitherEntity", "MixinWitherEntity",
"MixinVexEntity", "MixinVexEntity",
"MixinWanderingTrader",
"MixinVillagerEntity", "MixinVillagerEntity",
"MixinOnChat" "MixinOnChat"
], ],
......
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