3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-08 17:20:20 +01:00

Micro-optimizations in player entity code

Dieser Commit ist enthalten in:
Camotoy 2021-07-06 18:09:01 -04:00
Ursprung 9eec08b9dc
Commit e162cd526c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 5 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -55,10 +55,7 @@ import org.geysermc.connector.scoreboard.Team;
import org.geysermc.connector.utils.AttributeUtils; import org.geysermc.connector.utils.AttributeUtils;
import org.geysermc.connector.network.translators.chat.MessageTranslator; import org.geysermc.connector.network.translators.chat.MessageTranslator;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@Getter @Setter @Getter @Setter
@ -95,7 +92,7 @@ public class PlayerEntity extends LivingEntity {
addPlayerPacket.setUsername(username); addPlayerPacket.setUsername(username);
addPlayerPacket.setRuntimeEntityId(geyserId); addPlayerPacket.setRuntimeEntityId(geyserId);
addPlayerPacket.setUniqueEntityId(geyserId); addPlayerPacket.setUniqueEntityId(geyserId);
addPlayerPacket.setPosition(position.clone().sub(0, EntityType.PLAYER.getOffset(), 0)); addPlayerPacket.setPosition(position.sub(0, EntityType.PLAYER.getOffset(), 0));
addPlayerPacket.setRotation(getBedrockRotation()); addPlayerPacket.setRotation(getBedrockRotation());
addPlayerPacket.setMotion(motion); addPlayerPacket.setMotion(motion);
addPlayerPacket.setHand(hand); addPlayerPacket.setHand(hand);
@ -277,10 +274,9 @@ public class PlayerEntity extends LivingEntity {
if (entityMetadata.getId() == 15) { if (entityMetadata.getId() == 15) {
UpdateAttributesPacket attributesPacket = new UpdateAttributesPacket(); UpdateAttributesPacket attributesPacket = new UpdateAttributesPacket();
attributesPacket.setRuntimeEntityId(geyserId); attributesPacket.setRuntimeEntityId(geyserId);
List<AttributeData> attributes = new ArrayList<>();
// Setting to a higher maximum since plugins/datapacks can probably extend the Bedrock soft limit // Setting to a higher maximum since plugins/datapacks can probably extend the Bedrock soft limit
attributes.add(new AttributeData("minecraft:absorption", 0.0f, 1024f, (float) entityMetadata.getValue(), 0.0f)); attributesPacket.setAttributes(Collections.singletonList(
attributesPacket.setAttributes(attributes); new AttributeData("minecraft:absorption", 0.0f, 1024f, (float) entityMetadata.getValue(), 0.0f)));
session.sendUpstreamPacket(attributesPacket); session.sendUpstreamPacket(attributesPacket);
} }

Datei anzeigen

@ -75,7 +75,7 @@ public class SkullPlayerEntity extends PlayerEntity {
addPlayerPacket.setUsername(getUsername()); addPlayerPacket.setUsername(getUsername());
addPlayerPacket.setRuntimeEntityId(geyserId); addPlayerPacket.setRuntimeEntityId(geyserId);
addPlayerPacket.setUniqueEntityId(geyserId); addPlayerPacket.setUniqueEntityId(geyserId);
addPlayerPacket.setPosition(position.clone().sub(0, EntityType.PLAYER.getOffset(), 0)); addPlayerPacket.setPosition(position.sub(0, EntityType.PLAYER.getOffset(), 0));
addPlayerPacket.setRotation(getBedrockRotation()); addPlayerPacket.setRotation(getBedrockRotation());
addPlayerPacket.setMotion(motion); addPlayerPacket.setMotion(motion);
addPlayerPacket.setHand(hand); addPlayerPacket.setHand(hand);