mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 00:55:14 +00:00
Assign new IDs to every block
This commit is contained in:
@ -41,7 +41,7 @@ class BlockTest extends TestCase{
|
||||
* Test registering a block which would overwrite another block, without forcing it
|
||||
*/
|
||||
public function testAccidentalOverrideBlock() : void{
|
||||
$block = new MyCustomBlock(new BlockIdentifier(BlockLegacyIds::COBBLESTONE, 0), "Cobblestone", BlockBreakInfo::instant());
|
||||
$block = new MyCustomBlock(new BlockIdentifier(BlockTypeIds::COBBLESTONE, BlockLegacyIds::COBBLESTONE, 0), "Cobblestone", BlockBreakInfo::instant());
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->blockFactory->register($block);
|
||||
}
|
||||
@ -50,7 +50,7 @@ class BlockTest extends TestCase{
|
||||
* Test registering a block deliberately overwriting another block works as expected
|
||||
*/
|
||||
public function testDeliberateOverrideBlock() : void{
|
||||
$block = new MyCustomBlock(new BlockIdentifier(BlockLegacyIds::COBBLESTONE, 0), "Cobblestone", BlockBreakInfo::instant());
|
||||
$block = new MyCustomBlock(new BlockIdentifier(BlockTypeIds::COBBLESTONE, BlockLegacyIds::COBBLESTONE, 0), "Cobblestone", BlockBreakInfo::instant());
|
||||
$this->blockFactory->register($block, true);
|
||||
self::assertInstanceOf(MyCustomBlock::class, $this->blockFactory->get($block->getId(), 0));
|
||||
}
|
||||
@ -61,7 +61,7 @@ class BlockTest extends TestCase{
|
||||
public function testRegisterNewBlock() : void{
|
||||
for($i = 0; $i < 256; ++$i){
|
||||
if(!$this->blockFactory->isRegistered($i)){
|
||||
$b = new StrangeNewBlock(new BlockIdentifier($i, 0), "Strange New Block", BlockBreakInfo::instant());
|
||||
$b = new StrangeNewBlock(new BlockIdentifier(BlockTypeIds::FIRST_UNUSED_BLOCK_ID, $i, 0), "Strange New Block", BlockBreakInfo::instant());
|
||||
$this->blockFactory->register($b);
|
||||
self::assertInstanceOf(StrangeNewBlock::class, $this->blockFactory->get($b->getId(), 0));
|
||||
return;
|
||||
@ -76,7 +76,7 @@ class BlockTest extends TestCase{
|
||||
*/
|
||||
public function testRegisterIdTooSmall() : void{
|
||||
self::expectException(\InvalidArgumentException::class);
|
||||
$this->blockFactory->register(new OutOfBoundsBlock(new BlockIdentifier(-1, 0), "Out Of Bounds Block", BlockBreakInfo::instant()));
|
||||
$this->blockFactory->register(new OutOfBoundsBlock(new BlockIdentifier(-1, -1, 0), "Out Of Bounds Block", BlockBreakInfo::instant()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,7 +119,7 @@ class BlockTest extends TestCase{
|
||||
public function testBlockIds() : void{
|
||||
for($i = 0; $i < 256; ++$i){
|
||||
$b = $this->blockFactory->get($i, 0);
|
||||
self::assertContains($i, $b->getIdInfo()->getAllBlockIds());
|
||||
self::assertContains($i, $b->getIdInfo()->getAllLegacyBlockIds());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user