mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
More bounding box fixes (#2132)
- Fix decimal formatting error when running Geyser in another region - Fix sneaking bounding box when flying
This commit is contained in:
parent
120769c7f6
commit
22c492fda6
4 changed files with 27 additions and 12 deletions
|
@ -380,7 +380,6 @@ public class GeyserSession implements CommandSender {
|
|||
/**
|
||||
* If the current player is flying
|
||||
*/
|
||||
@Setter
|
||||
private boolean flying = false;
|
||||
|
||||
/**
|
||||
|
@ -862,11 +861,10 @@ public class GeyserSession implements CommandSender {
|
|||
playerEntity.updateBedrockAttributes(this);
|
||||
// the server *should* update our pose once it has returned to normal
|
||||
} else {
|
||||
this.pose = sneaking ? Pose.SNEAKING : Pose.STANDING;
|
||||
playerEntity.getMetadata().put(EntityData.BOUNDING_BOX_HEIGHT, sneaking ? 1.5f : playerEntity.getEntityType().getHeight());
|
||||
playerEntity.getMetadata().getFlags().setFlag(EntityFlag.SNEAKING, sneaking);
|
||||
|
||||
collisionManager.updatePlayerBoundingBox();
|
||||
if (!flying) {
|
||||
// The pose and bounding box should not be updated if the player is flying
|
||||
setSneakingPose(sneaking);
|
||||
}
|
||||
collisionManager.updateScaffoldingFlags(false);
|
||||
}
|
||||
|
||||
|
@ -878,6 +876,14 @@ public class GeyserSession implements CommandSender {
|
|||
}
|
||||
}
|
||||
|
||||
private void setSneakingPose(boolean sneaking) {
|
||||
this.pose = sneaking ? Pose.SNEAKING : Pose.STANDING;
|
||||
playerEntity.getMetadata().put(EntityData.BOUNDING_BOX_HEIGHT, sneaking ? 1.5f : playerEntity.getEntityType().getHeight());
|
||||
playerEntity.getMetadata().getFlags().setFlag(EntityFlag.SNEAKING, sneaking);
|
||||
|
||||
collisionManager.updatePlayerBoundingBox();
|
||||
}
|
||||
|
||||
public void setSwimming(boolean swimming) {
|
||||
this.pose = swimming ? Pose.SWIMMING : Pose.STANDING;
|
||||
playerEntity.getMetadata().put(EntityData.BOUNDING_BOX_HEIGHT, swimming ? 0.6f : playerEntity.getEntityType().getHeight());
|
||||
|
@ -885,6 +891,16 @@ public class GeyserSession implements CommandSender {
|
|||
playerEntity.updateBedrockMetadata(this);
|
||||
}
|
||||
|
||||
public void setFlying(boolean flying) {
|
||||
this.flying = flying;
|
||||
|
||||
if (sneaking) {
|
||||
// update bounding box as it is not reduced when flying
|
||||
setSneakingPose(!flying);
|
||||
playerEntity.updateBedrockMetadata(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts speed if the player is crawling.
|
||||
*
|
||||
|
|
|
@ -39,6 +39,7 @@ public class BedrockAdventureSettingsTranslator extends PacketTranslator<Adventu
|
|||
@Override
|
||||
public void translate(AdventureSettingsPacket packet, GeyserSession session) {
|
||||
boolean isFlying = packet.getSettings().contains(AdventureSetting.FLYING);
|
||||
session.setFlying(isFlying);
|
||||
ClientPlayerAbilitiesPacket abilitiesPacket = new ClientPlayerAbilitiesPacket(isFlying);
|
||||
session.sendDownstreamPacket(abilitiesPacket);
|
||||
|
||||
|
|
|
@ -42,8 +42,10 @@ import org.geysermc.connector.network.translators.collision.translators.BlockCol
|
|||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class CollisionManager {
|
||||
|
||||
|
@ -71,8 +73,9 @@ public class CollisionManager {
|
|||
public static final double COLLISION_TOLERANCE = 0.00001;
|
||||
/**
|
||||
* Trims Y coordinates when jumping to prevent rounding issues being sent to the server.
|
||||
* The locale used is necessary so other regions don't use <code>,</code> as their decimal separator.
|
||||
*/
|
||||
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.#####");
|
||||
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.#####", new DecimalFormatSymbols(Locale.ENGLISH));
|
||||
|
||||
public CollisionManager(GeyserSession session) {
|
||||
this.session = session;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
package org.geysermc.connector.network.translators.java.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerAbilitiesPacket;
|
||||
import org.geysermc.connector.entity.player.PlayerEntity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
@ -36,10 +35,6 @@ public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ServerPlayer
|
|||
|
||||
@Override
|
||||
public void translate(ServerPlayerAbilitiesPacket packet, GeyserSession session) {
|
||||
PlayerEntity entity = session.getPlayerEntity();
|
||||
if (entity == null)
|
||||
return;
|
||||
|
||||
session.setCanFly(packet.isCanFly());
|
||||
session.setFlying(packet.isFlying());
|
||||
session.sendAdventureSettings();
|
||||
|
|
Loading…
Reference in a new issue