From 61236d2392067d14c101c9f390b21a010883ea93 Mon Sep 17 00:00:00 2001 From: Reider745 <70357814+Reider745@users.noreply.github.com> Date: Wed, 25 Dec 2024 09:38:44 +0300 Subject: [PATCH] Fixed: BlockSource.spawnExpOrbs --- .../reider745/world/BlockSourceMethods.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/reider745/world/BlockSourceMethods.java b/src/main/java/com/reider745/world/BlockSourceMethods.java index 1b9f0684..1b3c723c 100644 --- a/src/main/java/com/reider745/world/BlockSourceMethods.java +++ b/src/main/java/com/reider745/world/BlockSourceMethods.java @@ -27,6 +27,7 @@ import com.zhekasmirnov.innercore.api.NativeItemInstanceExtra; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Random; public class BlockSourceMethods { @@ -285,13 +286,20 @@ public class BlockSourceMethods { } public static long spawnExpOrbs(Level level, float x, float y, float z, int amount) { - Vector3 source = new Vector3(x, y, z); - CompoundTag nbt = Entity.getDefaultNBT(source, new Vector3(0, 0, 0)); - Entity entity = Entity.createEntity("XpOrb", new Position(x, y, z, level), nbt); - if (entity != null) { - entity.spawnToAll(); - return EntityMethod.getIdForEntity(entity); + if(amount > 0) { + final Position source = new Position(x, y, z, level); + final CompoundTag nbt = Entity.getDefaultNBT(source, new Vector3(0, 0, 0)); + + nbt.putShort("Value", amount); + nbt.putShort("PickupDelay", 10); + + final Entity entity = Entity.createEntity("XpOrb", level.getChunk(source.getChunkX(), source.getChunkZ()), nbt); + if (entity != null) { + entity.spawnToAll(); + return EntityMethod.getIdForEntity(entity); + } } + return -1; }