Skip to content

Commit

Permalink
fix: fix the network offset of item entity. Its visual position shoul…
Browse files Browse the repository at this point in the history
…d now be normal. Changed the gravity of item and xp orb entity to 0.04f to better match vanilla behavior
  • Loading branch information
smartcmd committed Jan 16, 2025
1 parent 2cc3643 commit 7be51c4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Unless otherwise specified, any version comparison below is the comparison of se
- Changed `enableGui` to `enable-gui` in `server-settings.yml`
- Disabled packet limit only in dev build.
- Optimized the performance of physics calculation when there are a lot of entities.
- Changed the gravity of item and xp orb entity to 0.04f to better match vanilla behavior.

### Fixed

Expand All @@ -102,6 +103,7 @@ Unless otherwise specified, any version comparison below is the comparison of se
- Fixed the bug that player's pos sometimes get frozen after teleport. This is caused by the issue that sometimes client doesn't send
back teleport ack after server sends teleport packet to client.
- Fixed the bug that flint and steel durability reduced in creative mode.
- Fixed the network offset of item entity. Its visual position should now be normal.

## [0.1.2](https://github.com/AllayMC/Allay/releases/tag/0.1.2) (API 0.3.0) - 2024-12-31

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ default void dropItemInPlayerPos(ItemStack itemStack) {
var dimension = playerLoc.dimension();
dimension.dropItem(
itemStack,
playerLoc.add(0, this.getEyeHeight() - 0.25f, 0, new Vector3f()),
MathUtils.getDirectionVector(playerLoc.yaw(), playerLoc.pitch()).mul(0.5f),
playerLoc.add(0, this.getEyeHeight() - 0.4f, 0, new Vector3f()),
MathUtils.getDirectionVector(playerLoc.yaw(), playerLoc.pitch()).mul(0.4f),
40
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public void onCollideWith(Entity other) {
public NbtMap saveNBT() {
var builder = super.saveNBT().toBuilder();

if (itemStack != null)
if (itemStack != null) {
builder.putCompound("Item", itemStack.saveNBT()).build();
}

return builder.build();
}
Expand All @@ -73,6 +74,11 @@ public AABBfc getAABB() {
return new AABBf(-0.125f, 0.0f, -0.125f, 0.125f, 0.25f, 0.125f);
}

@Override
public float getNetworkOffset() {
return 0.125f;
}

@Override
public BedrockPacket createSpawnPacket() {
var packet = new AddItemEntityPacket();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public void tick(long currentTick) {

if (age != -1) {
age++;
if (age >= MAX_AGE) despawn();
if (age >= MAX_AGE) {
despawn();
return;
}
}

if (pickupDelay > 0) pickupDelay--;
Expand Down Expand Up @@ -63,4 +66,9 @@ public NbtMap saveNBT() {
public boolean computeBlockCollisionMotion() {
return true;
}

@Override
public float getGravity() {
return 0.04f;
}
}

0 comments on commit 7be51c4

Please sign in to comment.