Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 12:32:53 +02:00
Show villager display name
Dieser Commit ist enthalten in:
Ursprung
4c5d80e2e9
Commit
afb12e923b
@ -30,7 +30,6 @@ import com.github.steveice10.mc.auth.exception.request.InvalidCredentialsExcepti
|
||||
import com.github.steveice10.mc.auth.exception.request.RequestException;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.SubProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.VillagerTrade;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
||||
@ -173,6 +172,8 @@ public class GeyserSession implements CommandSender {
|
||||
|
||||
@Setter
|
||||
private VillagerTrade[] villagerTrades;
|
||||
@Setter
|
||||
private long lastInteractedVillagerEid;
|
||||
|
||||
private MinecraftProtocol protocol;
|
||||
|
||||
|
@ -45,6 +45,7 @@ import com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket;
|
||||
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.ItemFrameEntity;
|
||||
import org.geysermc.connector.entity.living.merchant.AbstractMerchantEntity;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
@ -198,6 +199,10 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
session.sendDownstreamPacket(interactAtPacket);
|
||||
|
||||
EntitySoundInteractionHandler.handleEntityInteraction(session, vector, entity);
|
||||
|
||||
if (entity instanceof AbstractMerchantEntity) {
|
||||
session.setLastInteractedVillagerEid(packet.getRuntimeEntityId());
|
||||
}
|
||||
break;
|
||||
case 1: //Attack
|
||||
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
|
@ -93,6 +93,7 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator {
|
||||
|
||||
@Override
|
||||
public void closeInventory(GeyserSession session, Inventory inventory) {
|
||||
session.setLastInteractedVillagerEid(-1);
|
||||
session.setVillagerTrades(null);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,14 @@ public class JavaTradeListTranslator extends PacketTranslator<ServerTradeListPac
|
||||
updateTradePacket.setTradeTier(packet.getVillagerLevel() - 1);
|
||||
updateTradePacket.setWindowId((short) packet.getWindowId());
|
||||
updateTradePacket.setWindowType((short) ContainerType.TRADING.id());
|
||||
updateTradePacket.setDisplayName("Villager");
|
||||
String displayName;
|
||||
Entity realVillager = session.getEntityCache().getEntityByGeyserId(session.getLastInteractedVillagerEid());
|
||||
if (realVillager != null && realVillager.getMetadata().containsKey(EntityData.NAMETAG) && realVillager.getMetadata().getString(EntityData.NAMETAG) != null) {
|
||||
displayName = realVillager.getMetadata().getString(EntityData.NAMETAG);
|
||||
} else {
|
||||
displayName = packet.isRegularVillager() ? "Villager" : "Wandering Trader";
|
||||
}
|
||||
updateTradePacket.setDisplayName(displayName);
|
||||
updateTradePacket.setUnknownInt(0);
|
||||
updateTradePacket.setScreen2(true);
|
||||
updateTradePacket.setWilling(true);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren