1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Merge remote-tracking branch 'upstream/master' into feature/1.21.120

This commit is contained in:
onebeastchris
2025-10-27 18:45:24 +01:00
8 changed files with 45 additions and 28 deletions

View File

@@ -216,7 +216,11 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
public void initialize() {
// Setup encryption early so we don't start if we can't auth
EncryptionUtils.getMojangPublicKey();
try {
EncryptionUtils.getMojangPublicKey();
} catch (Throwable e) {
throw new RuntimeException("Cannot setup authentication! Are you offline? ", e);
}
long startupTime = System.currentTimeMillis();

View File

@@ -162,7 +162,7 @@ public class BlockInventoryHolder extends InventoryHolder {
* a block to hold the inventory that's wildly out of range.
*/
protected boolean checkInteractionPosition(GeyserSession session) {
return session.getLastInteractionPlayerPosition().equals(session.getPlayerEntity().getPosition());
return session.getLastInteractionPlayerPosition().distance(session.getPlayerEntity().getPosition()) < 2;
}
/**

View File

@@ -165,6 +165,7 @@ public interface ComponentHasher {
} else if (component instanceof NBTComponent<?,?> nbt) {
return NBT_COMPONENT.hash(nbt, encoder);
}
// TODO support object component hashing!
throw new IllegalStateException("Unimplemented component hasher: " + component);
};

View File

@@ -74,7 +74,6 @@ import java.util.function.Function;
*/
// Lots of unchecked casting happens here. It should all be handled properly.
@SuppressWarnings("unchecked")
// TODO only log some things once (like was done in vault translator)
public final class ItemStackParser {
private static final Map<DataComponentType<?>, DataComponentParser<?, ?>> PARSERS = new Reference2ObjectOpenHashMap<>();
@@ -191,9 +190,9 @@ public final class ItemStackParser {
try {
patch.put((DataComponentType<Parsed>) type, parser.parse(session, (Raw) raw));
} catch (ClassCastException exception) {
GeyserImpl.getInstance().getLogger().error("Received incorrect object type for component " + type + "!", exception);
GeyserImpl.getInstance().getLogger().debug("Received incorrect object type for component " + type + "!", exception);
} catch (Exception exception) {
GeyserImpl.getInstance().getLogger().error("Failed to parse component" + type + " from " + raw + "!", exception);
GeyserImpl.getInstance().getLogger().debug("Failed to parse component" + type + " from " + raw + "!", exception);
}
}

View File

@@ -29,7 +29,6 @@ import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.cloudburstmc.nbt.NbtType;
import org.geysermc.geyser.level.WorldManager;
import org.geysermc.geyser.level.block.property.Properties;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.level.block.entity.BedrockChunkWantsBlockEntityTag;
@@ -50,13 +49,9 @@ public class LecternBlock extends Block implements BedrockChunkWantsBlockEntityT
@Override
public void updateBlock(GeyserSession session, BlockState state, Vector3i position) {
WorldManager worldManager = session.getGeyser().getWorldManager();
boolean currentHasBook = state.getValue(Properties.HAS_BOOK);
Boolean previousHasBook = worldManager.blockAt(session, position).getValueNullable(Properties.HAS_BOOK); // Can be null if not a lectern, watch out
if (previousHasBook == null || currentHasBook != previousHasBook) {
BlockEntityUtils.updateBlockEntity(session, getBaseLecternTag(position, currentHasBook), position);
}
super.updateBlock(session, state, position);
boolean hasBook = state.getValue(Properties.HAS_BOOK);
BlockEntityUtils.updateBlockEntity(session, getBaseLecternTag(position, hasBook), position);
}
public static NbtMap getBaseLecternTag(Vector3i position, boolean hasBook) {

View File

@@ -530,10 +530,10 @@ public final class ItemTranslator {
}
if (mapping.getJavaItem().equals(Items.PLAYER_HEAD)) {
/*CustomSkull customSkull = getCustomSkull(itemStack.getComponent(DataComponentTypes.PROFILE));
CustomSkull customSkull = getCustomSkull(itemStack.getComponent(DataComponentTypes.PROFILE));
if (customSkull != null) {
itemDefinition = session.getItemMappings().getCustomBlockItemDefinitions().get(customSkull.getCustomBlockData());
}*/ // TODO
}
}
ItemDefinition definition = CustomItemTranslator.getCustomItem(itemStack.getComponents(), mapping);

View File

@@ -76,7 +76,7 @@ public class WebUtils {
con.setRequestProperty("User-Agent", getUserAgent()); // Otherwise Java 8 fails on checking updates
con.setConnectTimeout(10000);
con.setReadTimeout(10000);
checkResponseCode(con);
return connectionToString(con);
} catch (UnknownHostException e) {
throw new IllegalStateException("Unable to resolve requested url (%s)! Are you offline?".formatted(reqURL), e);
@@ -94,6 +94,7 @@ public class WebUtils {
con.setRequestProperty("User-Agent", getUserAgent());
con.setConnectTimeout(10000);
con.setReadTimeout(10000);
checkResponseCode(con);
return GeyserImpl.JSON_MAPPER.readTree(con.getInputStream());
}
@@ -107,6 +108,7 @@ public class WebUtils {
try {
HttpURLConnection con = (HttpURLConnection) new URL(reqURL).openConnection();
con.setRequestProperty("User-Agent", getUserAgent());
checkResponseCode(con);
InputStream in = con.getInputStream();
Files.copy(in, Paths.get(fileLocation), StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
@@ -270,24 +272,38 @@ public class WebUtils {
}
/**
* Get the string output from the passed {@link HttpURLConnection}
*
* @param con The connection to get the string from
* @return The body of the returned page
* @throws IOException If the request fails
* Gets the string output from the passed {@link HttpURLConnection},
* or logs the error message.
*/
private static String connectionToString(HttpURLConnection con) throws IOException {
checkResponseCode(con);
return inputStreamToString(con.getInputStream(), con::disconnect);
}
/**
* Throws an exception if there is an error stream to avoid further issues
*/
private static void checkResponseCode(HttpURLConnection con) throws IOException {
// Send the request (we dont use this but its required for getErrorStream() to work)
con.getResponseCode();
// Read the error message if there is one if not just read normally
InputStream inputStream = con.getErrorStream();
if (inputStream == null) {
inputStream = con.getInputStream();
InputStream errorStream = con.getErrorStream();
if (errorStream != null) {
throw new IOException(inputStreamToString(errorStream, null));
}
}
/**
* Get the string output from the passed {@link InputStream}
*
* @param stream The input stream to get the string from
* @return The body of the returned page
* @throws IOException If the request fails
*/
private static String inputStreamToString(InputStream stream, @Nullable Runnable onFinish) throws IOException {
StringBuilder content = new StringBuilder();
try (BufferedReader in = new BufferedReader(new InputStreamReader(inputStream))) {
try (BufferedReader in = new BufferedReader(new InputStreamReader(stream))) {
String inputLine;
while ((inputLine = in.readLine()) != null) {
@@ -295,7 +311,9 @@ public class WebUtils {
content.append("\n");
}
con.disconnect();
if (onFinish != null) {
onFinish.run();
}
}
return content.toString();

View File

@@ -14,9 +14,9 @@ protocol-common = "3.0.0.Beta10-20251014.180344-2"
protocol-codec = "3.0.0.Beta10-20251014.180344-2"
raknet = "1.0.0.CR3-20250811.214335-20"
minecraftauth = "4.1.1"
mcprotocollib = "1.21.9-20251020.140136-16"
adventure = "4.24.0"
adventure-platform = "4.3.0"
mcprotocollib = "1.21.9-20251026.124736-17"
adventure = "4.25.0"
adventure-platform = "4.4.1"
junit = "5.9.2"
checkerframework = "3.19.0"
log4j = "2.20.0"