Compare commits

...

7 Commits

Author SHA1 Message Date
rtm516 aa66bfa8dd
Merge 35c57179bb into 6f4c29c834 2024-05-22 12:50:55 +03:00
gecko10000 6f4c29c834
Match Advancement Packet Behavior Towards Java (#4684)
* Send advancement packet regardless of current tab

* Send advancement close packet when single-advancement form closed
2024-05-22 11:26:32 +02:00
Camotoy 96bfda2ed3
Fix #4683 2024-05-21 20:37:18 -04:00
gecko10000 a780eeaae8
Open advancement tab regardless of currently open tab (#4665) 2024-05-20 19:52:41 +02:00
chris 35c57179bb
Merge branch 'master' into fix/deviceos 2024-05-11 01:23:02 +02:00
rtm516 57a9e5efc3
Revert enum name change and add deprecation annotations 2024-04-07 21:00:19 +01:00
rtm516 45e2547e62
Update DeviceOs to latest protocol 2024-04-07 12:44:50 +01:00
3 changed files with 33 additions and 25 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -39,15 +39,19 @@ public enum DeviceOs {
OSX("macOS"),
AMAZON("Amazon"),
GEARVR("Gear VR"),
HOLOLENS("Hololens"),
@Deprecated HOLOLENS("Hololens"),
UWP("Windows"),
WIN32("Windows x86"),
DEDICATED("Dedicated"),
TVOS("Apple TV"),
PS4("PS4"),
@Deprecated TVOS("Apple TV"),
/**
* This is for all PlayStation platforms not just PS4
*/
PS4("PlayStation"),
NX("Switch"),
XBOX("Xbox One"),
WINDOWS_PHONE("Windows Phone");
XBOX("Xbox"),
@Deprecated WINDOWS_PHONE("Windows Phone"),
LINUX("Linux");
private static final DeviceOs[] VALUES = values();

View File

@ -91,15 +91,11 @@ public class AdvancementsCache {
builder.validResultHandler((response) -> {
String id = rootAdvancementIds.get(response.clickedButtonId());
if (!id.equals("")) {
if (id.equals(currentAdvancementCategoryId)) {
// The server thinks we are already on this tab
buildAndShowListForm();
} else {
// Send a packet indicating that we intend to open this particular advancement window
ServerboundSeenAdvancementsPacket packet = new ServerboundSeenAdvancementsPacket(id);
session.sendDownstreamGamePacket(packet);
// Wait for a response there
}
// Send a packet indicating that we are opening this particular advancement window
ServerboundSeenAdvancementsPacket packet = new ServerboundSeenAdvancementsPacket(id);
session.sendDownstreamGamePacket(packet);
currentAdvancementCategoryId = id;
buildAndShowListForm();
}
});
@ -190,6 +186,10 @@ public class AdvancementsCache {
.content(content)
.button(GeyserLocale.getPlayerLocaleString("gui.back", language))
.validResultHandler((response) -> buildAndShowListForm())
.closedResultHandler(() -> {
// Indicate that we have closed the current advancement tab
session.sendDownstreamGamePacket(new ServerboundSeenAdvancementsPacket());
})
);
}

View File

@ -28,7 +28,6 @@ package org.geysermc.geyser.session.cache;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.GlobalPos;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.LodestoneTracker;
@ -53,11 +52,13 @@ public final class LodestoneCache {
private int id = 1;
public void cacheInventoryItem(GeyserItemStack itemStack, LodestoneTracker tracker) {
GlobalPos position = tracker.getPos();
if (!tracker.isTracked()) {
return;
}
GlobalPos position = tracker.getPos();
if (position == null) {
GeyserImpl.getInstance().getLogger().error("Position is null. Find out why.");
Thread.dumpStack();
// As of 1.20.6, position can still be null even if tracking is enabled.
return;
}
int x = position.getX();
@ -84,13 +85,16 @@ public final class LodestoneCache {
}
public int store(LodestoneTracker tracker) {
GlobalPos position = tracker.getPos();
if (position == null) {
GeyserImpl.getInstance().getLogger().error("Position is null. Find out why.");
Thread.dumpStack();
return -1;
if (!tracker.isTracked()) {
// No coordinates; nothing to convert
return 0;
}
GlobalPos position = tracker.getPos();
if (position == null) {
return 0;
}
int x = position.getX();
int y = position.getY();
int z = position.getZ();