Removed entanglement between chunks and providers. WARNING: BREAKING API CHANGES.

- All entity and tile constructors now require a \pocketmine\level\Level instead of a \pocketmine\level\format\Chunk.
- Chunk->getProvider() and Chunk->setProvider() have been removed.
- Chunk::__construct() has had the $provider parameter removed.
- Chunk->unload() has had the unused $save parameter removed.
- ChunkEvents now take a Level parameter instead of going through the Chunk

API bump to 3.0.0-ALPHA4
This commit is contained in:
Dylan K. Taylor
2017-02-21 17:03:45 +00:00
parent 0a8826b21f
commit c21197ef17
37 changed files with 123 additions and 170 deletions

View File

@ -88,7 +88,7 @@ class BurningFurnace extends Solid{
}
}
Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
Tile::createTile("Furnace", $this->getLevel(), $nbt);
return true;
}
@ -111,7 +111,7 @@ class BurningFurnace extends Solid{
new IntTag("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
$furnace = Tile::createTile("Furnace", $this->getLevel(), $nbt);
}
if(isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof StringTag){

View File

@ -115,7 +115,7 @@ class Chest extends Transparent{
}
}
$tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
$tile = Tile::createTile("Chest", $this->getLevel(), $nbt);
if($chest instanceof TileChest and $tile instanceof TileChest){
$chest->pairWith($tile);
@ -155,7 +155,7 @@ class Chest extends Transparent{
new IntTag("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
$chest = Tile::createTile("Chest", $this->getLevel(), $nbt);
}
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag){

View File

@ -57,7 +57,7 @@ class EnchantingTable extends Transparent{
}
}
Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel(), $nbt);
return true;
}

View File

@ -37,7 +37,7 @@ abstract class Fallable extends Solid{
if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === self::AIR or ($down instanceof Liquid)){
$fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new CompoundTag("", [
$fall = Entity::createEntity("FallingSand", $this->getLevel(), new CompoundTag("", [
"Pos" => new ListTag("Pos", [
new DoubleTag("", $this->x + 0.5),
new DoubleTag("", $this->y),

View File

@ -85,7 +85,7 @@ class FlowerPot extends Flowable{
}
}
Tile::createTile(Tile::FLOWER_POT, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
Tile::createTile(Tile::FLOWER_POT, $this->getLevel(), $nbt);
return true;
}

View File

@ -56,7 +56,7 @@ class ItemFrame extends Flowable{
new FloatTag("ItemDropChance", 1.0),
new ByteTag("ItemRotation", 0)
]);
$tile = Tile::createTile(Tile::ITEM_FRAME, $this->level->getChunk($this->x >> 4, $this->z >> 4), $nbt);
$tile = Tile::createTile(Tile::ITEM_FRAME, $this->getLevel(), $nbt);
}
if($tile->hasItem()){
@ -133,7 +133,7 @@ class ItemFrame extends Flowable{
}
}
Tile::createTile(Tile::ITEM_FRAME, $this->level->getChunk($this->x >> 4, $this->z >> 4), $nbt);
Tile::createTile(Tile::ITEM_FRAME, $this->getLevel(), $nbt);
return true;

View File

@ -81,7 +81,7 @@ class MobHead extends Flowable{
$nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
}
/** @var Spawnable $tile */
Tile::createTile("Skull", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
Tile::createTile("Skull", $this->getLevel(), $nbt);
return true;
}
return false;

View File

@ -87,7 +87,7 @@ class SignPost extends Transparent{
$this->getLevel()->setBlock($block, new WallSign($this->meta), true);
}
Tile::createTile(Tile::SIGN, $this->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt);
Tile::createTile(Tile::SIGN, $this->getLevel(), $nbt);
return true;
}

View File

@ -57,7 +57,7 @@ class TNT extends Solid{
$this->getLevel()->setBlock($this, new Air(), true);
$mot = (new Random())->nextSignedFloat() * M_PI * 2;
$tnt = Entity::createEntity("PrimedTNT", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new CompoundTag("", [
$tnt = Entity::createEntity("PrimedTNT", $this->getLevel(), new CompoundTag("", [
"Pos" => new ListTag("Pos", [
new DoubleTag("", $this->x + 0.5),
new DoubleTag("", $this->y),