Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke100000 committed Feb 19, 2023
1 parent c2590bd commit c4b5ce2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ public void setLastPhrase(MutableText questionText, boolean silent) {
MutableText text;
if (!silent) {
text = villager.sendChatMessage(questionText, player);
SpeechManager.INSTANCE.onChatMessage(text, villager.asEntity().getUuid());
} else {
text = villager.transformMessage(questionText);
}
Expand Down
9 changes: 4 additions & 5 deletions common/src/main/java/net/mca/entity/ai/Messenger.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.mca.network.s2c.VillagerMessage;
import net.mca.resources.API;
import net.mca.server.world.data.PlayerSaveData;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ai.TargetPredicate;
import net.minecraft.entity.player.PlayerEntity;
Expand Down Expand Up @@ -108,16 +107,16 @@ default MutableText transformMessage(MutableText message) {
}

default MutableText sendChatMessage(MutableText message, Entity receiver) {
message = transformMessage(message);
message = transformMessage(message);

MutableText textToSend = Text.literal(Config.getInstance().villagerChatPrefix).append(asEntity().getDisplayName()).append(": ").append(message);

//use custom packet to have access to sender UUID, and maybe future extra information
VillagerMessage msg = new VillagerMessage(textToSend, asEntity().getUuid());
if (receiver instanceof ClientPlayerEntity) {
ClientProxy.getNetworkHandler().handleVillagerMessage(msg);
} else if (receiver instanceof ServerPlayerEntity serverPlayer) {
if (receiver instanceof ServerPlayerEntity serverPlayer) {
NetworkHandler.sendToPlayer(msg, serverPlayer);
} else {
ClientProxy.getNetworkHandler().handleVillagerMessage(msg);
}

playSpeechEffect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ public void handleConfigResponse(ConfigResponse message) {
@Override
public void handleVillagerMessage(VillagerMessage message) {
MutableText msg = message.getMessage();
SpeechManager.INSTANCE.onChatMessage(msg, message.getUuid());
//noinspection ResultOfMethodCallIgnored
msg.toString();
client.getMessageHandler().onGameMessage(msg, false);
SpeechManager.INSTANCE.onChatMessage(msg, message.getUuid());
}
}

0 comments on commit c4b5ce2

Please sign in to comment.