From 95297e4047a66575ae3815dd04f869f03e030d1e Mon Sep 17 00:00:00 2001 From: AJ Ferguson Date: Tue, 19 May 2020 07:28:33 -0800 Subject: [PATCH] Update villager xp while trading --- .../translators/bedrock/BedrockEntityEventTranslator.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEntityEventTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEntityEventTranslator.java index c7d1ae67..555d1015 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEntityEventTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEntityEventTranslator.java @@ -29,6 +29,7 @@ package org.geysermc.connector.network.translators.bedrock; import com.github.steveice10.mc.protocol.data.game.window.VillagerTrade; import com.github.steveice10.mc.protocol.data.game.window.WindowType; import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientSelectTradePacket; +import com.nukkitx.protocol.bedrock.data.EntityData; import com.nukkitx.protocol.bedrock.packet.EntityEventPacket; import org.geysermc.connector.entity.living.merchant.VillagerEntity; import org.geysermc.connector.inventory.Inventory; @@ -57,9 +58,11 @@ public class BedrockEntityEventTranslator extends PacketTranslator 0 && packet.getData() < villager.getVillagerTrades().length) { + if (packet.getData() >= 0 && packet.getData() < villager.getVillagerTrades().length) { VillagerTrade trade = villager.getVillagerTrades()[packet.getData()]; openInventory.setItem(2, trade.getOutput()); + villager.getMetadata().put(EntityData.TRADE_XP, trade.getXp() + villager.getMetadata().getInt(EntityData.TRADE_XP)); + villager.updateBedrockMetadata(session); } } return;