public function addExperienceOrb(Vector3 $pos, $exp = 2) { if ($exp > 0) { $nbt = new CompoundTag("", ["Pos" => new EnumTag("Pos", [new DoubleTag("", $pos->getX()), new DoubleTag("", $pos->getY() + 0.5), new DoubleTag("", $pos->getZ())]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)]), "Experience" => new LongTag("Experience", $exp)]); $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false); $expOrb = new ExperienceOrb($chunk, $nbt); //$expBall->setExperience($exp); $expOrb->spawnToAll(); return $expOrb; } return false; }
public function spawnExperienceOrb(Vector3 $pos, $exp = 1) { $ExpPerBall = mt_rand(1, 5); while ($exp >= $ExpPerBall) { $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $pos->getX() + mt_rand(-1, 1) + mt_rand(100, 999) / 1000), new Double("", $pos->getY()), new Double("", $pos->getZ() + mt_rand(-1, 1) + mt_rand(100, 999) / 1000)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Experience" => new Long("Experience", $exp)]); $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false); $expOrb = new ExperienceOrb($chunk, $nbt); $expOrb->spawnToAll(); $exp -= $ExpPerBall; $ExpPerBall = mt_rand(1, 5); } if ($exp > 0) { $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $pos->getX() + mt_rand(-1, 1) + mt_rand(100, 999) / 1000), new Double("", $pos->getY()), new Double("", $pos->getZ() + mt_rand(-1, 1) + mt_rand(100, 999) / 1000)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Experience" => new Long("Experience", $exp)]); $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false); $expOrb = new ExperienceOrb($chunk, $nbt); $expOrb->spawnToAll(); } }
public function addExperienceOrb(Vector3 $pos, $exp = 2) { $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $pos->getX()), new Double("", $pos->getY()), new Double("", $pos->getZ())]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Experience" => new Long("Experience", $exp)]); $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false); $expBall = new ExperienceOrb($chunk, $nbt); //$expBall->setExperience($exp); $expBall->spawnToAll(); }