Hello forums, I am trying to set a beacon that shoots a beam of light into the sky, and change the color depending on a condition, here is my code: (note) this is a task running every 20 ticks PHP: foreach($this->plugin->config->get("key") as $name => $val){ $level = $this->plugin->getServer()->getLevelByName(explode(":", $val["pos1"])[3]); if($level == null) continue; $beaconXyz = $this->plugin->getBeaconVector($val["pos1"], $val["pos2"]); if($beaconXyz == null) continue; if($this->plugin->isActivated($name)){ if($level->getBlockDataAt($beaconXyz->getX(), $beaconXyz->getY() + 1, $beaconXyz->getX()) !== 13){ $level->setBlock($beaconXyz->add(0, 1), Block::get(Block::STAINED_GLASS, 13), false, false); } }else{ if($level->getBlockDataAt($beaconXyz->getX(), $beaconXyz->getY() + 1, $beaconXyz->getX()) !== 14){ $level->setBlock($beaconXyz->add(0, 1), Block::get(Block::STAINED_GLASS, 14), false, false); } } if($level->getBlockIdAt($beaconXyz->getX(), $beaconXyz->getY(), $beaconXyz->getZ()) !== Block::BEACON){ $level->setBlock($beaconXyz, Block::get(Block::BEACON), false, false); Tile::createTile("Beacon", $level, Beacon::createNBT($beaconXyz)); } for($x = $beaconXyz->getX() - 1; $x <= $beaconXyz->getX() + 1; $x++){ for($z = $beaconXyz->getZ() - 1; $z <= $beaconXyz->getZ() + 1; $z++){ if($level->getBlockIdAt($x, $beaconXyz->getY() - 1, $z) == Block::EMERALD_BLOCK) continue; $level->setBlock(new Vector3($x, $beaconXyz->getY() - 1, $z), Block::get(Block::EMERALD_BLOCK), false, false); } }} the issue: when I break the beacon, it does not re appear, and everything I do to the world does not edit / save unless I add $level->save(true), and even then, it does not fix that the beacon does not re appear let me explain some of my functions and or code: $val is an array which contains the key "pos1" with the value of "0:0:0:Spawn" getBeaconVector() returns a new Vector3 instance isActivated() returns a bool if you have any idea of why this is or have a lead, please do reply
note, the beacon tile is implemented by TeaSpoon, so if you want to look at the source code of it you can go to the GitHub repo
(FIX) DO NOT START THE TASK RIGHT AFTER THE LEVEL IS LOADED Make a delayed repeating task with the minimum delay of 20 * 10 ticks let the 3rd and 4th parameter of setBlock() be default check if the level is corrupted, use another level and test it
Well, consequences. So the tile wasn't registered when you called Tile::createTile() outside the task.