mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
Change confusing 'type data' and 'state data' terminology for blocks and items
For blocks, we now use 'block-item state' and 'block-only state', which should be much clearer for people implementing custom stuff. 'block-item state', as the name suggests, sticks to the item when the block is acquired as an item. 'block-only state' applies only to the block and is discarded when the block is acquired as an item. 'type data' for items was also renamed, since 'type' is too ambiguous to be anything but super confusing.
This commit is contained in:
@ -103,7 +103,7 @@ class CraftingManager{
|
||||
*/
|
||||
public static function sort(Item $i1, Item $i2) : int{
|
||||
//Use spaceship operator to compare each property, then try the next one if they are equivalent.
|
||||
($retval = $i1->getTypeId() <=> $i2->getTypeId()) === 0 && ($retval = $i1->computeTypeData() <=> $i2->computeTypeData()) === 0 && ($retval = $i1->getCount() <=> $i2->getCount()) === 0;
|
||||
($retval = $i1->getTypeId() <=> $i2->getTypeId()) === 0 && ($retval = $i1->computeStateData() <=> $i2->computeStateData()) === 0 && ($retval = $i1->getCount() <=> $i2->getCount()) === 0;
|
||||
|
||||
return $retval;
|
||||
}
|
||||
@ -142,7 +142,7 @@ class CraftingManager{
|
||||
foreach($outputs as $o){
|
||||
//count is not written because the outputs might be from multiple repetitions of a single recipe
|
||||
//this reduces the accuracy of the hash, but it won't matter in most cases.
|
||||
$result->putVarInt(morton2d_encode($o->getTypeId(), $o->computeTypeData()));
|
||||
$result->putVarInt(morton2d_encode($o->getTypeId(), $o->computeStateData()));
|
||||
$result->put((new LittleEndianNbtSerializer())->write(new TreeRoot($o->getNamedTag())));
|
||||
}
|
||||
|
||||
@ -283,8 +283,8 @@ class CraftingManager{
|
||||
}
|
||||
|
||||
public function matchBrewingRecipe(Item $input, Item $ingredient) : ?BrewingRecipe{
|
||||
$inputHash = morton2d_encode($input->getTypeId(), $input->computeTypeData());
|
||||
$ingredientHash = morton2d_encode($ingredient->getTypeId(), $ingredient->computeTypeData());
|
||||
$inputHash = morton2d_encode($input->getTypeId(), $input->computeStateData());
|
||||
$ingredientHash = morton2d_encode($ingredient->getTypeId(), $ingredient->computeStateData());
|
||||
$cached = $this->brewingRecipeCache[$inputHash][$ingredientHash] ?? null;
|
||||
if($cached !== null){
|
||||
return $cached;
|
||||
|
@ -66,7 +66,7 @@ final class FurnaceRecipeManager{
|
||||
}
|
||||
|
||||
public function match(Item $input) : ?FurnaceRecipe{
|
||||
$index = morton2d_encode($input->getTypeId(), $input->computeTypeData());
|
||||
$index = morton2d_encode($input->getTypeId(), $input->computeStateData());
|
||||
$simpleRecipe = $this->lookupCache[$index] ?? null;
|
||||
if($simpleRecipe !== null){
|
||||
return $simpleRecipe;
|
||||
|
Reference in New Issue
Block a user