Hello, I am trying to replace all blocks from an ID to another one. I get this error Error: "Call to a member function setBlock() on null" PHP: $level = Main::getInstance()->getServer()->getLevelByName("factionmap"); $b = Block::get(Block::CARPET); PHP: $pos = new Vector3($x, $y, $z); and the problematic line PHP: $b->level->setBlock($pos, $block);
How do I give him a level ? Basically I try to make it so example the block 1:0 become 4:0 (this is just an example)
yes that works but what I try to do is to only replace a certain block for another, now it fills up everything in these positions. I was trying to do what they said in this thread https://forums.pmmp.io/threads/replace-block.6762/ but ye..Do you have an idea on how to fix it ?
And there is no way to just loop every blocks from a area ? ( $minX, $maxX, $minY, $maxY, $minZ, $maxZ ), if yes, how could we do that?
Good, last thing, So basically I have to loop chunk and then what? Like I get all blockIDs in a array and detect the ones with example the ID of 1:0 -> 1,1,1 so $id -> $pos and I do $level->setBlock($pos, $block); ? $pos being all the blocks with 1:0 as id in a array of block ids and position
when iterating through area, you already should have "old" block positions. There is no necessity to store any of those values, use them on the fly. Get through frustration and experiment P.S. Use test world if not - Keep backups, don't mess your world up.
factionmap is a test world in my test server so I can just drop the plugins directly in the production on so I don't need to change any code, its a normal world and the production one is the real map. I just don't understand how to say "okay, 1:0 is changed to 2:0 in $position"