Added APIs to get a new unique block/item type ID

this centralization is needed to avoid conflicts between different plugins fighting over the same hardcoded IDs.
This commit is contained in:
Dylan K. Taylor 2022-07-24 22:02:47 +01:00
parent 6ba3b39541
commit 79125b8426
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 18 additions and 0 deletions

View File

@ -706,4 +706,13 @@ final class BlockTypeIds{
public const FROGLIGHT = 10679;
public const FIRST_UNUSED_BLOCK_ID = 10680;
private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID;
/**
* Returns a new runtime block type ID, e.g. for use by a custom block.
*/
public static function newId() : int{
return self::$nextDynamicId++;
}
}

View File

@ -298,4 +298,13 @@ final class ItemTypeIds{
public const LINGERING_POTION = 20259;
public const FIRST_UNUSED_ITEM_ID = 20260;
private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;
/**
* Returns a new runtime item type ID, e.g. for use by a custom item.
*/
public static function newId() : int{
return self::$nextDynamicId++;
}
}