-
-
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
Implement anvil #6418
base: minor-next
Are you sure you want to change the base?
Implement anvil #6418
Conversation
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.
Just a quick overview
/** | ||
* Returns the repair cost of the item. | ||
*/ | ||
public function getRepairCost() : int{ | ||
return $this->repairCost; | ||
} | ||
|
||
/** | ||
* Sets the repair cost of the item. | ||
* | ||
* @return $this | ||
*/ | ||
public function setRepairCost(int $cost) : self{ | ||
$this->repairCost = $cost; | ||
return $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.
This should be placed on Durable class
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.
Any item can have repairCost, e.g EnchantedBook
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.
How do you repair an enchanted book ?
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.
How do you repair an enchanted book ?
it's more like “anvil cost” rather than actual repair cost since it also increases when combining enchantments / renaming.
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.
So should we move away from vanilla and go in the direction of AnvilCost and not RepairCost in the item tags? I personally don't think so.
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.
Consistency within PM is more important, right? I think we can use anvil cost terminology and just document that in vanilla it is called repair cost.
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 but the tag need to stay at RepairCost
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.
Okay, so document and/or name this function properly, when I saw it I thought it was the experience cost of the item to be repaired.
@@ -61,4 +63,8 @@ public function getFuelTime() : int{ | |||
public function isFireProof() : bool{ | |||
return $this->tier === ToolTier::NETHERITE; | |||
} | |||
|
|||
public function isValidRepairMaterial(Item $material) : bool{ |
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 don't like this name, feel that the material terminology doesn't fit, instead i would name it something like canBeRepairedBy or isRepairedBy
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 more like french tbh 😂
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.
This is the name used in the wiki to refer to materials.
But just specifying, canBeRepairedBy
can lead to confusion in thinking that it can be both the materials and the tool/armour itself. Whereas what we're expecting here is just the materials
src/block/utils/AnvilHelper.php
Outdated
use function min; | ||
use function strlen; | ||
|
||
class AnvilHelper{ |
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 would like this class to be divided into actions, for example an AnvilRapairAction, in the actions would define properties such as the cost and process the 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.
Like the idea
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.
implement possibility to set item and not juste get ?
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.
Maybe there's some client side prediction about recipe (I honestly dont know) which may prevent it to work
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.
yep, no posibility for custom recipes :(
|
||
declare(strict_types=1); | ||
|
||
namespace pocketmine\block\anvil; |
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.
Does it need to be placed in block namespace? Wouldn’t be better to move anvil inventory actions logic into the inventory\transaction
namespace since it’s more associated with anvil transactions rather than block itself?
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.
inventory\transaction
namespace is intended for handling player's requested ones, but in this use case what we are actually doing is creating fictitious actions for the use of the anvil.
Introduction
As the title suggests, this PR implements the anvils
Relevant issues
Changes
API changes
Durable::isValidRepairMaterial
enabling everyone to implement their own verification logicrepairMaterials
toArmorMaterial
andToolTier
Item
Behavioural changes
Tests
I tested this PR by doing the following (tick all that apply):
tests/phpunit
folder)https://youtu.be/d3vcwi_45DY