-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented smithing table functionality #6202
base: minor-next
Are you sure you want to change the base?
Conversation
$this->session->getLogger()->debug("Sending armor trim data"); | ||
$patterns = array_map(fn(ArmorTrimPattern $pattern) => new TrimPattern($pattern->getItemId(), $pattern->value), ArmorTrimPattern::cases()); | ||
$materials = array_map(fn(ArmorTrimMaterial $material) => new TrimMaterial($material->value, $material->getColor(), $material->getItemId()), ArmorTrimMaterial::cases()); | ||
$this->session->sendDataPacket(TrimDataPacket::create($patterns, $materials)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this customizable? If so, why are we using hard enums for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HimmelKreis4865 I don't know about patterns, but colours can be definitely customized. (For example, I can change the amethyst colour from purple to white). What do you think about allowing plugins to customize this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I'm aware of this, and this should be customizable but I did not yet find a solution for this problem that satisfies me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a commit to make this all customizable, please tell me what you think of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it looks good, but I'm not sure about passing type id and serialized item name to the constructor. Wouldn't a better to pass an Item and then serialize it when sending TrimData?
(from ipad54 on discord)
what do you guys think about this?
There's not much more I can do at this point, everthing is fixed except for save ids. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me, one comment.
This comment was marked as off-topic.
This comment was marked as off-topic.
3999602
to
5360b77
Compare
yeah, ready to be reviewed again. |
* @param Item[] $inputs | ||
* @phpstan-param list<Item> $inputs | ||
*/ | ||
public function getResultFor(array $inputs) : ?Item{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sceptical about the fact that it's up to the recipe to find out what the input is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh I don't see a problem here, it also has 2 usages so I don't know how I'd change it smoothly..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this relevant now? If so, please give me some more information on where to move the methods
* @param Item[] $inputs | ||
* @phpstan-param list<Item> $inputs | ||
*/ | ||
public function getResultFor(array $inputs) : ?Item{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
what is still missing? |
nothing. just reviews 😭 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some micro-optimizations which I believe may help the API
public function __construct( | ||
private readonly RecipeIngredient $input, | ||
private readonly RecipeIngredient $addition, | ||
private readonly RecipeIngredient $template){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because these are readonly
values the getter functions are redundant and these variables can be made public
public function __construct( | ||
private string $identifier, | ||
private string $itemName, | ||
private int $typeId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can also be public, making the getters redundant.
private string $identifier, | ||
private string $color, | ||
private string $itemName, | ||
private int $typeId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can also be public, making the getters redundant.
} | ||
|
||
private function registerDefaultMaterials() : void{ | ||
$this->registerMaterial(new ArmorTrimMaterial(ArmorTrimMaterial::AMETHYST, TextFormat::MATERIAL_AMETHYST, Names::AMETHYST_SHARD, Ids::AMETHYST_SHARD)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said in discord, it would be better to pass an Item and then serialise it when sending TrimData instead of passing type id and serialised item name
Introduction
This PR adds working smithing tables to pocketmine.
There are no known issues or problems
Changes
API changes
Amor->setTrim(ArmorTrim)
Armor->getTrim() : ?ArmorTrim
Armor->clearTrim()
SmithingTableInventory->getInput() : Item
SmithingTableInventory->getAddition() : Item
SmithingTableInventory->getTemplate() : Item
The new enums:
ArmorTrimPattern
&ArmorTrimMaterial
(required to constructArmorTrim
)Tests
Tested ingame with the smithing table several times:
Tested the code