Remove unused variables; fix opening double chests quickly

This commit is contained in:
Camotoy 2021-03-04 12:26:16 -05:00
parent 7e773c9970
commit ca3f9550dd
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
5 changed files with 7 additions and 14 deletions

View file

@ -250,12 +250,6 @@ public class GeyserSession implements CommandSender {
@Setter
private Entity ridingVehicleEntity;
@Setter
private long lastWindowCloseTime = 0;
@Setter
private long lastInteractedVillagerEid;
@Setter
private Int2ObjectMap<Recipe> craftingRecipes;
private final Set<String> unlockedRecipes;

View file

@ -40,7 +40,6 @@ public class BedrockContainerCloseTranslator extends PacketTranslator<ContainerC
@Override
public void translate(ContainerClosePacket packet, GeyserSession session) {
session.addInventoryTask(() -> {
session.setLastWindowCloseTime(0);
byte windowId = packet.getId();
//Client wants close confirmation

View file

@ -327,10 +327,6 @@ 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
if (entity.getEntityType() == EntityType.ENDER_DRAGON) {

View file

@ -77,7 +77,8 @@ public class JavaTradeListTranslator extends PacketTranslator<ServerTradeListPac
updateTradePacket.setPlayerUniqueEntityId(session.getPlayerEntity().getGeyserId());
updateTradePacket.setTraderUniqueEntityId(villager.getGeyserId());
NbtMapBuilder builder = NbtMap.builder();
List<NbtMap> tags = new ArrayList<>();
boolean addExtraTrade = packet.isRegularVillager() && packet.getVillagerLevel() < 5;
List<NbtMap> tags = new ArrayList<>(addExtraTrade ? packet.getTrades().length + 1 : packet.getTrades().length);
for (int i = 0; i < packet.getTrades().length; i++) {
VillagerTrade trade = packet.getTrades()[i];
NbtMapBuilder recipe = NbtMap.builder();
@ -101,7 +102,7 @@ public class JavaTradeListTranslator extends PacketTranslator<ServerTradeListPac
}
//Hidden trade to fix visual experience bug
if (packet.isRegularVillager() && packet.getVillagerLevel() < 5) {
if (addExtraTrade) {
tags.add(NbtMap.builder()
.putInt("maxUses", 0)
.putInt("traderExp", 0)
@ -117,7 +118,7 @@ public class JavaTradeListTranslator extends PacketTranslator<ServerTradeListPac
}
builder.putList("Recipes", NbtType.COMPOUND, tags);
List<NbtMap> expTags = new ArrayList<>();
List<NbtMap> expTags = new ArrayList<>(5);
expTags.add(NbtMap.builder().putInt("0", 0).build());
expTags.add(NbtMap.builder().putInt("1", 10).build());
expTags.add(NbtMap.builder().putInt("2", 70).build());

View file

@ -79,6 +79,9 @@ public class InventoryUtils {
if (openInv != null && openInv.getId() == inventory.getId()) {
translator.openInventory(session, inventory);
translator.updateInventory(session, inventory);
} else if (openInv != null && openInv.isPending()) {
// Presumably, this inventory is no longer relevant, and the client doesn't care about it
displayInventory(session, openInv);
}
}), 200, TimeUnit.MILLISECONDS);
} else {