Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
Fixed TextDisplay's offsets
Dieser Commit ist enthalten in:
Ursprung
bdaa595a7d
Commit
5b6823b5fb
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
|
* Copyright (c) 2024 GeyserMC. http://geysermc.org
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -31,6 +31,7 @@ import org.cloudburstmc.math.vector.Vector3f;
|
|||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.util.EntityUtils;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
import org.jetbrains.annotations.Async;
|
import org.jetbrains.annotations.Async;
|
||||||
@ -38,9 +39,6 @@ import org.jetbrains.annotations.Async;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static org.geysermc.geyser.util.EntityUtils.getMountOffset;
|
|
||||||
|
|
||||||
// Note: 1.19.4 requires that the billboard is set to something in order to show, on Java Edition
|
|
||||||
public class DisplayBaseEntity extends Entity {
|
public class DisplayBaseEntity extends Entity {
|
||||||
|
|
||||||
public Vector3f baseTranslation;
|
public Vector3f baseTranslation;
|
||||||
@ -73,7 +71,7 @@ public class DisplayBaseEntity extends Entity {
|
|||||||
this.setRiderSeatPosition(this.baseTranslation);
|
this.setRiderSeatPosition(this.baseTranslation);
|
||||||
this.moveRelative(0, this.baseTranslation.getY(), 0, yaw, pitch, headYaw, false);
|
this.moveRelative(0, this.baseTranslation.getY(), 0, yaw, pitch, headYaw, false);
|
||||||
} else {
|
} else {
|
||||||
this.setRiderSeatPosition(this.baseTranslation.add(getMountOffset(this, this.vehicle)));
|
EntityUtils.updateMountOffset(this, this.vehicle, true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
|
* Copyright (c) 2024 GeyserMC. http://geysermc.org
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
* Copyright (c) 2024 GeyserMC. http://geysermc.org
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -154,12 +154,9 @@ public final class EntityUtils {
|
|||||||
* Adjust an entity's height if they have mounted/dismounted an entity.
|
* Adjust an entity's height if they have mounted/dismounted an entity.
|
||||||
*/
|
*/
|
||||||
public static void updateMountOffset(Entity passenger, Entity mount, boolean rider, boolean riding, boolean moreThanOneEntity) {
|
public static void updateMountOffset(Entity passenger, Entity mount, boolean rider, boolean riding, boolean moreThanOneEntity) {
|
||||||
if(passenger instanceof TextDisplayEntity) {
|
if(passenger instanceof TextDisplayEntity textDisplay
|
||||||
TextDisplayEntity d = (TextDisplayEntity) passenger;
|
&& textDisplay.baseTranslation == null ) return;
|
||||||
if(d.baseTranslation == null) return; // still no meta
|
|
||||||
d.setRiderSeatPosition(d.baseTranslation.add(getMountOffset(passenger, mount)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
passenger.setFlag(EntityFlag.RIDING, riding);
|
passenger.setFlag(EntityFlag.RIDING, riding);
|
||||||
if (riding) {
|
if (riding) {
|
||||||
// Without the Y offset, Bedrock players will find themselves in the floor when mounting
|
// Without the Y offset, Bedrock players will find themselves in the floor when mounting
|
||||||
@ -173,11 +170,7 @@ public final class EntityUtils {
|
|||||||
case BOAT -> {
|
case BOAT -> {
|
||||||
// Without the X offset, more than one entity on a boat is stacked on top of each other
|
// Without the X offset, more than one entity on a boat is stacked on top of each other
|
||||||
if (moreThanOneEntity) {
|
if (moreThanOneEntity) {
|
||||||
if (rider) {
|
xOffset = rider ? 0.2f : -0.6f;
|
||||||
xOffset = 0.2f;
|
|
||||||
} else {
|
|
||||||
xOffset = -0.6f;
|
|
||||||
}
|
|
||||||
if (passenger instanceof AnimalEntity) {
|
if (passenger instanceof AnimalEntity) {
|
||||||
xOffset += 0.2f;
|
xOffset += 0.2f;
|
||||||
}
|
}
|
||||||
@ -230,60 +223,12 @@ public final class EntityUtils {
|
|||||||
yOffset -= armorStand.getYOffset();
|
yOffset -= armorStand.getYOffset();
|
||||||
}
|
}
|
||||||
Vector3f offset = Vector3f.from(xOffset, yOffset, zOffset);
|
Vector3f offset = Vector3f.from(xOffset, yOffset, zOffset);
|
||||||
passenger.setRiderSeatPosition(offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector3f getMountOffset(Entity passenger, Entity mount) {
|
passenger.setRiderSeatPosition( passenger instanceof TextDisplayEntity textDisplay ?
|
||||||
// Without the Y offset, Bedrock players will find themselves in the floor when mounting
|
textDisplay.baseTranslation.add(offset) : offset
|
||||||
float mountedHeightOffset = getMountedHeightOffset(mount);
|
);
|
||||||
float heightOffset = getHeightOffset(passenger);
|
|
||||||
|
|
||||||
float xOffset = 0;
|
|
||||||
float yOffset = mountedHeightOffset + heightOffset;
|
|
||||||
float zOffset = 0;
|
|
||||||
switch (mount.getDefinition().entityType()) {
|
|
||||||
case CAMEL -> {
|
|
||||||
zOffset = 0.5f;
|
|
||||||
if (mount.getFlag(EntityFlag.SITTING)) {
|
|
||||||
if (mount.getFlag(EntityFlag.BABY)) {
|
|
||||||
yOffset += CamelEntity.SITTING_HEIGHT_DIFFERENCE * 0.5f;
|
|
||||||
} else {
|
|
||||||
yOffset += CamelEntity.SITTING_HEIGHT_DIFFERENCE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
case CHEST_BOAT -> xOffset = 0.15F;
|
|
||||||
case CHICKEN -> zOffset = -0.1f;
|
|
||||||
case TRADER_LLAMA, LLAMA -> zOffset = -0.3f;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Bedrock Differences
|
|
||||||
* Zoglin & Hoglin seem to be taller in Bedrock edition
|
|
||||||
* Horses are tinier
|
|
||||||
* Players, Minecarts, and Boats have different origins
|
|
||||||
*/
|
|
||||||
if (mount.getDefinition().entityType() == EntityType.PLAYER) {
|
|
||||||
yOffset -= EntityDefinitions.PLAYER.offset();
|
|
||||||
}
|
|
||||||
if (passenger.getDefinition().entityType() == EntityType.PLAYER) {
|
|
||||||
yOffset += EntityDefinitions.PLAYER.offset();
|
|
||||||
}
|
|
||||||
switch (mount.getDefinition().entityType()) {
|
|
||||||
case MINECART, HOPPER_MINECART, TNT_MINECART, CHEST_MINECART, FURNACE_MINECART, SPAWNER_MINECART,
|
|
||||||
COMMAND_BLOCK_MINECART, BOAT, CHEST_BOAT -> yOffset -= mount.getDefinition().height() * 0.5f;
|
|
||||||
}
|
|
||||||
switch (passenger.getDefinition().entityType()) {
|
|
||||||
case MINECART, HOPPER_MINECART, TNT_MINECART, CHEST_MINECART, FURNACE_MINECART, SPAWNER_MINECART,
|
|
||||||
COMMAND_BLOCK_MINECART, BOAT, CHEST_BOAT -> yOffset += passenger.getDefinition().height() * 0.5f;
|
|
||||||
case FALLING_BLOCK -> yOffset += 0.5f;
|
|
||||||
}
|
|
||||||
if (mount instanceof ArmorStandEntity armorStand) {
|
|
||||||
yOffset -= armorStand.getYOffset();
|
|
||||||
}
|
|
||||||
return Vector3f.from(xOffset, yOffset, zOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void updateRiderRotationLock(Entity passenger, Entity mount, boolean isRiding) {
|
public static void updateRiderRotationLock(Entity passenger, Entity mount, boolean isRiding) {
|
||||||
if (isRiding && mount instanceof BoatEntity) {
|
if (isRiding && mount instanceof BoatEntity) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren