Skip to content

Commit 5d419ba

Browse files
Merge branch 'master' into custom-item-api-v2
2 parents efb79fe + e2a82b3 commit 5d419ba

File tree

53 files changed

+513
-315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+513
-315
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
1515
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!
1616

1717
## Supported Versions
18-
Geyser is currently supporting Minecraft Bedrock 1.21.90 - 1.21.113 and Minecraft Java 1.21.9 - 1.21.10. For more information, please see [here](https://geysermc.org/wiki/geyser/supported-versions/).
18+
Geyser is currently supporting Minecraft Bedrock 1.21.90 - 1.21.114 and Minecraft Java 1.21.9 - 1.21.10. For more information, please see [here](https://geysermc.org/wiki/geyser/supported-versions/).
1919

2020
## Setting Up
2121
Take a look [here](https://geysermc.org/wiki/geyser/setup/) for how to set up Geyser.

bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePlugin.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
package org.geysermc.geyser.platform.bungeecord;
2727

28-
import io.netty.buffer.AdaptiveByteBufAllocator;
29-
import io.netty.buffer.ByteBufAllocator;
3028
import io.netty.channel.Channel;
3129
import net.md_5.bungee.BungeeCord;
3230
import net.md_5.bungee.api.CommandSender;
@@ -84,12 +82,9 @@ public void onLoad() {
8482
public void onGeyserInitialize() {
8583
GeyserLocale.init(this);
8684

87-
// TODO remove when this isn't an issue anymore
88-
boolean adaptiveAllocatorUsed = System.getProperty("io.netty.allocator.type") == null && ByteBufAllocator.DEFAULT instanceof AdaptiveByteBufAllocator;
89-
9085
try {
9186
List<Integer> supportedProtocols = ProtocolConstants.SUPPORTED_VERSION_IDS;
92-
if (!supportedProtocols.contains(GameProtocol.getJavaProtocolVersion()) || adaptiveAllocatorUsed) {
87+
if (!supportedProtocols.contains(GameProtocol.getJavaProtocolVersion())) {
9388
geyserLogger.error(" / \\");
9489
geyserLogger.error(" / \\");
9590
geyserLogger.error(" / | \\");

bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneBootstrap.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ public static void main(String[] args) {
8989
ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED); // Can eat performance
9090
}
9191

92-
// Restore allocator used before Netty 4.2 due to oom issues with the adaptive allocator
93-
if (System.getProperty("io.netty.allocator.type") == null) {
94-
System.setProperty("io.netty.allocator.type", "pooled");
95-
}
96-
9792
System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");
9893
GeyserStandaloneLogger.setupStreams();
9994

bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
import com.velocitypowered.api.plugin.Plugin;
3737
import com.velocitypowered.api.plugin.PluginContainer;
3838
import com.velocitypowered.api.proxy.ProxyServer;
39-
import io.netty.buffer.AdaptiveByteBufAllocator;
40-
import io.netty.buffer.ByteBufAllocator;
4139
import lombok.Getter;
4240
import org.checkerframework.checker.nullness.qual.NonNull;
4341
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -93,10 +91,7 @@ public GeyserVelocityPlugin(ProxyServer server, PluginContainer container, Logge
9391
public void onGeyserInitialize() {
9492
GeyserLocale.init(this);
9593

96-
// TODO remove when this isn't an issue anymore
97-
boolean adaptiveAllocatorUsed = System.getProperty("io.netty.allocator.type") == null && ByteBufAllocator.DEFAULT instanceof AdaptiveByteBufAllocator;
98-
99-
if (!ProtocolVersion.isSupported(GameProtocol.getJavaProtocolVersion()) || adaptiveAllocatorUsed) {
94+
if (!ProtocolVersion.isSupported(GameProtocol.getJavaProtocolVersion())) {
10095
geyserLogger.error(" / \\");
10196
geyserLogger.error(" / \\");
10297
geyserLogger.error(" / | \\");

core/src/main/java/org/geysermc/geyser/entity/GeyserEntityData.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.checkerframework.checker.nullness.qual.NonNull;
3030
import org.checkerframework.checker.nullness.qual.Nullable;
3131
import org.cloudburstmc.protocol.bedrock.packet.EmotePacket;
32+
import org.geysermc.geyser.input.InputLocksFlag;
3233
import org.geysermc.geyser.api.entity.EntityData;
3334
import org.geysermc.geyser.api.entity.type.GeyserEntity;
3435
import org.geysermc.geyser.api.entity.type.player.GeyserPlayerEntity;
@@ -87,7 +88,8 @@ public boolean lockMovement(boolean lock, @NonNull UUID owner) {
8788
movementLockOwners.remove(owner);
8889
}
8990

90-
session.lockInputs(session.camera().isCameraLocked(), isMovementLocked());
91+
session.setLockInput(InputLocksFlag.MOVEMENT, isMovementLocked());
92+
session.updateInputLocks();
9193
return isMovementLocked();
9294
}
9395

core/src/main/java/org/geysermc/geyser/entity/type/Entity.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,14 @@ public void setRiderSeatPosition(Vector3f position) {
614614
protected boolean isShaking() {
615615
return false;
616616
}
617+
/**
618+
* If true, the entity can be dismounted by pressing jump.
619+
*
620+
* @return whether the entity can be dismounted when pressing jump.
621+
*/
622+
public boolean doesJumpDismount() {
623+
return true;
624+
}
617625

618626
/**
619627
* x = Pitch, y = Yaw, z = HeadYaw

core/src/main/java/org/geysermc/geyser/entity/type/TextDisplayEntity.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
@Getter
4444
public class TextDisplayEntity extends DisplayBaseEntity {
4545

46+
/**
47+
* The height offset per line of text in a text display entity when rendered
48+
* as an armor stand nametag on Bedrock Edition.
49+
* <p>
50+
* This value was empirically adjusted to match Java Edition's multi-line text
51+
* centering behavior. Note that this differs from the 0.1414f multiplier used
52+
* in {@link org.geysermc.geyser.util.EntityUtils} for mount offset calculations.
53+
*/
54+
private static final float LINE_HEIGHT_OFFSET = 0.12f;
55+
4656
private int lineCount;
4757

4858
public TextDisplayEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
@@ -54,9 +64,27 @@ public void moveRelative(double relX, double relY, double relZ, float yaw, float
5464
super.moveRelative(relX, relY + definition.offset(), relZ, yaw, pitch, isOnGround);
5565
}
5666

67+
/**
68+
* Calculates the Y offset needed to match Java Edition's text centering
69+
* behavior for multi-line text displays.
70+
* <p>
71+
* In Java Edition, multi-line text displays are centered vertically.
72+
* This value differs from the 0.1414f multiplier used in {@link org.geysermc.geyser.util.EntityUtils}
73+
* for text displays mounted on players, as this handles the base positioning
74+
* rather than mount offset calculations.
75+
*
76+
* @return the Y offset to apply based on the number of lines
77+
*/
78+
private float calculateLineOffset() {
79+
if (lineCount == 0) {
80+
return 0;
81+
}
82+
return LINE_HEIGHT_OFFSET * lineCount;
83+
}
84+
5785
@Override
5886
public void moveAbsolute(Vector3f position, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported) {
59-
super.moveAbsolute(position.add(Vector3f.from(0, definition.offset(), 0)), yaw, pitch, headYaw, isOnGround, teleported);
87+
super.moveAbsolute(position.add(0, calculateLineOffset(), 0), yaw, pitch, headYaw, isOnGround, teleported);
6088
}
6189

6290
@Override
@@ -70,7 +98,14 @@ protected void initializeMetadata() {
7098

7199
public void setText(EntityMetadata<Component, ?> entityMetadata) {
72100
this.dirtyMetadata.put(EntityDataTypes.NAME, MessageTranslator.convertMessage(entityMetadata.getValue(), session.locale()));
101+
102+
int previousLineCount = lineCount;
73103
calculateLineCount(entityMetadata.getValue());
104+
105+
// If the line count changed, update the position to account for the new offset
106+
if (previousLineCount != lineCount) {
107+
moveAbsolute(position, yaw, pitch, headYaw, onGround, false);
108+
}
74109
}
75110

76111
private void calculateLineCount(@Nullable Component text) {

core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/AbstractHorseEntity.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.geysermc.geyser.entity.EntityDefinition;
3838
import org.geysermc.geyser.entity.attribute.GeyserAttributeType;
3939
import org.geysermc.geyser.entity.type.living.animal.AnimalEntity;
40+
import org.geysermc.geyser.input.InputLocksFlag;
4041
import org.geysermc.geyser.inventory.GeyserItemStack;
4142
import org.geysermc.geyser.item.Items;
4243
import org.geysermc.geyser.item.type.Item;
@@ -85,6 +86,17 @@ public void updateSaddled(boolean saddled) {
8586
// Shows the jump meter
8687
setFlag(EntityFlag.CAN_POWER_JUMP, saddled);
8788
super.updateSaddled(saddled);
89+
90+
if (this.passengers.contains(session.getPlayerEntity())) {
91+
// We want to allow player to press jump again if pressing jump doesn't dismount the entity.
92+
this.session.setLockInput(InputLocksFlag.JUMP, this.doesJumpDismount());
93+
this.session.updateInputLocks();
94+
}
95+
}
96+
97+
@Override
98+
public boolean doesJumpDismount() {
99+
return !this.getFlag(EntityFlag.SADDLED);
88100
}
89101

90102
public void setHorseFlags(ByteEntityMetadata entityMetadata) {

core/src/main/java/org/geysermc/geyser/entity/type/player/SessionPlayerEntity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.geysermc.geyser.entity.type.BoatEntity;
4444
import org.geysermc.geyser.entity.type.Entity;
4545
import org.geysermc.geyser.entity.type.LivingEntity;
46+
import org.geysermc.geyser.input.InputLocksFlag;
4647
import org.geysermc.geyser.inventory.GeyserItemStack;
4748
import org.geysermc.geyser.item.Items;
4849
import org.geysermc.geyser.level.block.Blocks;
@@ -476,6 +477,10 @@ public void setVehicle(Entity entity) {
476477
this.vehicle.updateBedrockMetadata();
477478
}
478479

480+
// Bedrock player can dismount by pressing jump while Java cannot, so we need to prevent player from jumping to match vanilla behaviour.
481+
this.session.setLockInput(InputLocksFlag.JUMP, entity != null && entity.doesJumpDismount());
482+
this.session.updateInputLocks();
483+
479484
super.setVehicle(entity);
480485
}
481486

core/src/main/java/org/geysermc/geyser/impl/camera/GeyserCameraData.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.geysermc.geyser.api.bedrock.camera.CameraPosition;
4949
import org.geysermc.geyser.api.bedrock.camera.CameraShake;
5050
import org.geysermc.geyser.api.bedrock.camera.GuiElement;
51+
import org.geysermc.geyser.input.InputLocksFlag;
5152
import org.geysermc.geyser.session.GeyserSession;
5253
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
5354

@@ -251,7 +252,8 @@ public boolean lockCamera(boolean lock, @NonNull UUID owner) {
251252
this.cameraLockOwners.remove(owner);
252253
}
253254

254-
session.lockInputs(isCameraLocked(), session.entities().isMovementLocked());
255+
session.setLockInput(InputLocksFlag.CAMERA, isCameraLocked());
256+
session.updateInputLocks();
255257
return isCameraLocked();
256258
}
257259

0 commit comments

Comments
 (0)