Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/GeyserMC/Geyser into serv…
Browse files Browse the repository at this point in the history
…er-inventory
  • Loading branch information
Camotoy committed Mar 2, 2021
2 parents 6775d88 + 88d4903 commit 61e5784
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 44 deletions.
42 changes: 20 additions & 22 deletions connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

<properties>
<netty.version>4.1.59.Final</netty.version>
<fastutil.version>8.5.2</fastutil.version>
<adventure.version>4.5.0</adventure.version>
</properties>

<dependencies>
Expand All @@ -28,25 +30,21 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.CloudburstMC.Protocol</groupId>
<groupId>com.nukkitx.protocol</groupId>
<artifactId>bedrock-v422</artifactId>
<version>294e7e5</version>
<version>2.6.2-20210228.150048-4</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove</artifactId>
</exclusion>
<exclusion>
<groupId>com.nukkitx.network</groupId>
<artifactId>raknet</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.CloudburstMC.Network</groupId>
<groupId>com.nukkitx.network</groupId>
<artifactId>raknet</artifactId>
<version>a94d2dd</version>
<version>1.6.26-20210217.205834-2</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand All @@ -58,61 +56,61 @@
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-int-int-maps</artifactId>
<version>8.3.1</version>
<version>${fastutil.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-int-float-maps</artifactId>
<version>8.3.1</version>
<version>${fastutil.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-long-long-maps</artifactId>
<version>8.3.1</version>
<version>${fastutil.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-object-long-maps</artifactId>
<version>8.3.1</version>
<version>${fastutil.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-int-byte-maps</artifactId>
<version>8.3.1</version>
<version>${fastutil.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-int-double-maps</artifactId>
<version>8.3.1</version>
<version>${fastutil.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-int-boolean-maps</artifactId>
<version>8.3.1</version>
<version>${fastutil.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-object-int-maps</artifactId>
<version>8.3.1</version>
<version>${fastutil.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-object-byte-maps</artifactId>
<version>8.3.1</version>
<version>${fastutil.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-object-object-maps</artifactId>
<version>8.3.1</version>
<version>${fastutil.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -214,25 +212,25 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.5.0</version>
<version>${adventure.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
<version>4.5.0</version>
<version>${adventure.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-legacy</artifactId>
<version>4.5.0</version>
<version>${adventure.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
<version>4.5.0</version>
<version>${adventure.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,43 +123,38 @@ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession s
isInvisible = (xd & 0x20) == 0x20;
updateSecondEntityStatus(false);
}
} else if (entityMetadata.getId() == 2 || entityMetadata.getId() == 3) {
} else if (entityMetadata.getId() == 2) {
updateSecondEntityStatus(false);
} else if (entityMetadata.getId() == 14 && entityMetadata.getType() == MetadataType.BYTE) {
byte xd = (byte) entityMetadata.getValue();

// isSmall
boolean newIsSmall = (xd & 0x01) == 0x01;
if ((newIsSmall != isSmall) && positionRequiresOffset) {
// Fix new inconsistency with offset
this.position = fixOffsetForSize(position, newIsSmall);
positionUpdateRequired = true;
}
isSmall = newIsSmall;
if (isSmall) {

float scale = metadata.getFloat(EntityData.SCALE);
if (scale != 0.55f && scale != 0.0f) {
metadata.put(EntityData.SCALE, 0.55f);
if (newIsSmall != isSmall) {
if (positionRequiresOffset) {
// Fix new inconsistency with offset
this.position = fixOffsetForSize(position, newIsSmall);
positionUpdateRequired = true;
}

if (metadata.getFloat(EntityData.BOUNDING_BOX_WIDTH) == 0.5f) {
metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.25f);
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.9875f);
isSmall = newIsSmall;
if (!isMarker) {
toggleSmallStatus();
}
} else if (metadata.getFloat(EntityData.BOUNDING_BOX_WIDTH) == 0.25f) {
metadata.put(EntityData.BOUNDING_BOX_WIDTH, entityType.getWidth());
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, entityType.getHeight());
}

// setMarker
boolean oldIsMarker = isMarker;
isMarker = (xd & 0x10) == 0x10;
if (isMarker) {
metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.0f);
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.0f);
}
if (oldIsMarker != isMarker) {
if (isMarker) {
metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.0f);
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.0f);
metadata.put(EntityData.SCALE, 0f);
} else {
toggleSmallStatus();
}

updateSecondEntityStatus(false);
}
}
Expand Down Expand Up @@ -226,6 +221,7 @@ private void updateSecondEntityStatus(boolean sendMetadata) {
if (!primaryEntity) return;
if (!isInvisible || isMarker) {
// It is either impossible to show armor, or the armor stand isn't invisible. We good.
metadata.getFlags().setFlag(EntityFlag.INVISIBLE, false);
updateOffsetRequirement(false);
if (positionUpdateRequired) {
positionUpdateRequired = false;
Expand Down Expand Up @@ -306,6 +302,15 @@ private void updateSecondEntityStatus(boolean sendMetadata) {
}
}

/**
* If this armor stand is not a marker, set its bounding box size and scale.
*/
private void toggleSmallStatus() {
metadata.put(EntityData.BOUNDING_BOX_WIDTH, isSmall ? 0.25f : entityType.getWidth());
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, isSmall ? 0.9875f : entityType.getHeight());
metadata.put(EntityData.SCALE, isSmall ? 0.55f : 1f);
}

/**
* @return the selected position with the position offset applied.
*/
Expand Down

0 comments on commit 61e5784

Please sign in to comment.