3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 16:12:46 +01:00

Use the inventory name always for villager inventories

Testing not crashing on 1.8 and 1.13.2.
Dieser Commit ist enthalten in:
Camotoy 2021-02-26 19:03:18 -05:00
Ursprung 9788ed4dc6
Commit ab9501da69
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -31,12 +31,11 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerTrade
import com.nukkitx.nbt.NbtMap;
import com.nukkitx.nbt.NbtMapBuilder;
import com.nukkitx.nbt.NbtType;
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
import com.nukkitx.protocol.bedrock.packet.UpdateTradePacket;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.inventory.MerchantContainer;
import org.geysermc.connector.network.session.GeyserSession;
@ -71,16 +70,7 @@ public class JavaTradeListTranslator extends PacketTranslator<ServerTradeListPac
updateTradePacket.setTradeTier(packet.getVillagerLevel() - 1);
updateTradePacket.setContainerId((short) packet.getWindowId());
updateTradePacket.setContainerType(ContainerType.TRADE);
String displayName;
//TODO: verify correct window title behavior
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 = realVillager != null &&
realVillager.getEntityType() == EntityType.WANDERING_TRADER ? "Wandering Trader" : "Villager";
}
updateTradePacket.setDisplayName(displayName);
updateTradePacket.setDisplayName(openInventory.getTitle());
updateTradePacket.setSize(0);
updateTradePacket.setNewTradingUi(true);
updateTradePacket.setUsingEconomyTrade(true);