Skip to content

Commit

Permalink
fix: getExperienceOrbValue
Browse files Browse the repository at this point in the history
- исправлен getExperienceOrbValue
  • Loading branch information
Reider745 committed Dec 17, 2023
1 parent b510449 commit a17a126
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/reider745/entity/EntityMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cn.nukkit.entity.EntityHuman;
import cn.nukkit.entity.EntityRideable;
import cn.nukkit.entity.item.EntityItem;
import cn.nukkit.entity.item.EntityXPOrb;
import cn.nukkit.entity.projectile.EntityProjectile;
import cn.nukkit.event.entity.EntityDamageEvent;
import cn.nukkit.item.Item;
Expand Down Expand Up @@ -389,4 +390,11 @@ public static void transferToDimension(long unwrapEntity, int dimension) {
if(entity != null)
entity.teleport(Location.fromObject(entity.getPosition(), BlockSourceMethods.getLevelForDimension(dimension)));
}

public static int getExperienceOrbValue(long unwrapEntity) {
Entity entity = getEntityToLong(unwrapEntity);
if(entity instanceof EntityXPOrb xp)
return xp.getExp();
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public static ItemStack getDroppedItem(long entity) {
}

public static int getExperienceOrbValue(long entity) {
CompoundTag tag = EntityMethod.getEntityCompoundTag(entity);
return tag != null ? new NativeCompoundTag(tag).getInt("experience value") : 0;
return EntityMethod.getExperienceOrbValue(entity);
}


Expand Down

0 comments on commit a17a126

Please sign in to comment.