Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
More bounding box fixes (#2132)
- Fix decimal formatting error when running Geyser in another region - Fix sneaking bounding box when flying
Dieser Commit ist enthalten in:
Ursprung
120769c7f6
Commit
22c492fda6
@ -380,7 +380,6 @@ public class GeyserSession implements CommandSender {
|
|||||||
/**
|
/**
|
||||||
* If the current player is flying
|
* If the current player is flying
|
||||||
*/
|
*/
|
||||||
@Setter
|
|
||||||
private boolean flying = false;
|
private boolean flying = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -862,11 +861,10 @@ public class GeyserSession implements CommandSender {
|
|||||||
playerEntity.updateBedrockAttributes(this);
|
playerEntity.updateBedrockAttributes(this);
|
||||||
// the server *should* update our pose once it has returned to normal
|
// the server *should* update our pose once it has returned to normal
|
||||||
} else {
|
} else {
|
||||||
this.pose = sneaking ? Pose.SNEAKING : Pose.STANDING;
|
if (!flying) {
|
||||||
playerEntity.getMetadata().put(EntityData.BOUNDING_BOX_HEIGHT, sneaking ? 1.5f : playerEntity.getEntityType().getHeight());
|
// The pose and bounding box should not be updated if the player is flying
|
||||||
playerEntity.getMetadata().getFlags().setFlag(EntityFlag.SNEAKING, sneaking);
|
setSneakingPose(sneaking);
|
||||||
|
}
|
||||||
collisionManager.updatePlayerBoundingBox();
|
|
||||||
collisionManager.updateScaffoldingFlags(false);
|
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) {
|
public void setSwimming(boolean swimming) {
|
||||||
this.pose = swimming ? Pose.SWIMMING : Pose.STANDING;
|
this.pose = swimming ? Pose.SWIMMING : Pose.STANDING;
|
||||||
playerEntity.getMetadata().put(EntityData.BOUNDING_BOX_HEIGHT, swimming ? 0.6f : playerEntity.getEntityType().getHeight());
|
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);
|
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.
|
* Adjusts speed if the player is crawling.
|
||||||
*
|
*
|
||||||
|
@ -39,6 +39,7 @@ public class BedrockAdventureSettingsTranslator extends PacketTranslator<Adventu
|
|||||||
@Override
|
@Override
|
||||||
public void translate(AdventureSettingsPacket packet, GeyserSession session) {
|
public void translate(AdventureSettingsPacket packet, GeyserSession session) {
|
||||||
boolean isFlying = packet.getSettings().contains(AdventureSetting.FLYING);
|
boolean isFlying = packet.getSettings().contains(AdventureSetting.FLYING);
|
||||||
|
session.setFlying(isFlying);
|
||||||
ClientPlayerAbilitiesPacket abilitiesPacket = new ClientPlayerAbilitiesPacket(isFlying);
|
ClientPlayerAbilitiesPacket abilitiesPacket = new ClientPlayerAbilitiesPacket(isFlying);
|
||||||
session.sendDownstreamPacket(abilitiesPacket);
|
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 org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class CollisionManager {
|
public class CollisionManager {
|
||||||
|
|
||||||
@ -71,8 +73,9 @@ public class CollisionManager {
|
|||||||
public static final double COLLISION_TOLERANCE = 0.00001;
|
public static final double COLLISION_TOLERANCE = 0.00001;
|
||||||
/**
|
/**
|
||||||
* Trims Y coordinates when jumping to prevent rounding issues being sent to the server.
|
* 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) {
|
public CollisionManager(GeyserSession session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package org.geysermc.connector.network.translators.java.entity.player;
|
package org.geysermc.connector.network.translators.java.entity.player;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerAbilitiesPacket;
|
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.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.network.translators.Translator;
|
import org.geysermc.connector.network.translators.Translator;
|
||||||
@ -36,10 +35,6 @@ public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ServerPlayer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerPlayerAbilitiesPacket packet, GeyserSession session) {
|
public void translate(ServerPlayerAbilitiesPacket packet, GeyserSession session) {
|
||||||
PlayerEntity entity = session.getPlayerEntity();
|
|
||||||
if (entity == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
session.setCanFly(packet.isCanFly());
|
session.setCanFly(packet.isCanFly());
|
||||||
session.setFlying(packet.isFlying());
|
session.setFlying(packet.isFlying());
|
||||||
session.sendAdventureSettings();
|
session.sendAdventureSettings();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren