mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-11-24 15:58:59 +01:00
Fix Bedrock ItemEntity Y position bug (#1636)
Setting motion while on the ground causes visual issues. Additionally, there is an offset difference in the movement of an item entity.
This commit is contained in:
parent
8e274daa75
commit
2a44874458
2 changed files with 16 additions and 3 deletions
|
@ -36,7 +36,20 @@ import org.geysermc.connector.network.translators.item.ItemTranslator;
|
|||
public class ItemEntity extends Entity {
|
||||
|
||||
public ItemEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
||||
super(entityId, geyserId, entityType, position, motion, rotation);
|
||||
super(entityId, geyserId, entityType, position.add(0d, entityType.getOffset(), 0d), motion, rotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMotion(Vector3f motion) {
|
||||
if (isOnGround())
|
||||
motion = Vector3f.from(motion.getX(), 0, motion.getZ());
|
||||
|
||||
super.setMotion(motion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveAbsolute(GeyserSession session, Vector3f position, Vector3f rotation, boolean isOnGround, boolean teleported) {
|
||||
super.moveAbsolute(session, position.add(0d, this.entityType.getOffset(), 0d), rotation, isOnGround, teleported);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,7 +57,7 @@ public class ItemEntity extends Entity {
|
|||
if (entityMetadata.getId() == 7) {
|
||||
AddItemEntityPacket itemPacket = new AddItemEntityPacket();
|
||||
itemPacket.setRuntimeEntityId(geyserId);
|
||||
itemPacket.setPosition(position);
|
||||
itemPacket.setPosition(position.add(0d, this.entityType.getOffset(), 0d));
|
||||
itemPacket.setMotion(motion);
|
||||
itemPacket.setUniqueEntityId(geyserId);
|
||||
itemPacket.setFromFishing(false);
|
||||
|
|
|
@ -100,7 +100,7 @@ public enum EntityType {
|
|||
ARMOR_STAND(ArmorStandEntity.class, 61, 1.975f, 0.5f),
|
||||
TRIPOD_CAMERA(Entity.class, 62, 0f),
|
||||
PLAYER(PlayerEntity.class, 63, 1.8f, 0.6f, 0.6f, 1.62f),
|
||||
ITEM(ItemEntity.class, 64, 0.25f, 0.25f),
|
||||
ITEM(ItemEntity.class, 64, 0.25f, 0.25f, 0.25f, 0.125f),
|
||||
PRIMED_TNT(TNTEntity.class, 65, 0.98f, 0.98f, 0.98f, 0f, "minecraft:tnt"),
|
||||
FALLING_BLOCK(FallingBlockEntity.class, 66, 0.98f, 0.98f),
|
||||
MOVING_BLOCK(Entity.class, 67, 0f),
|
||||
|
|
Loading…
Reference in a new issue