Skip to content
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

Open
wants to merge 12 commits into
base: minor-next
Choose a base branch
from
Open

Implement anvil #6418

wants to merge 12 commits into from

Conversation

ShockedPlot7560
Copy link
Member

Introduction

As the title suggests, this PR implements the anvils

Relevant issues

Changes

API changes

  • Introduce a new Durable::isValidRepairMaterial enabling everyone to implement their own verification logic
  • Add repairMaterials to ArmorMaterial and ToolTier
  • Add repairCost functions in Item

Behavioural changes

  • Anvil works

Tests

I tested this PR by doing the following (tick all that apply):

  • Writing PHPUnit tests (commit these in the tests/phpunit folder)
  • Playtesting using a Minecraft client (provide screenshots or a video)
  • Writing a test plugin (provide the code and sample output)
  • Other (provide details)

https://youtu.be/d3vcwi_45DY

@ShockedPlot7560 ShockedPlot7560 added Category: Gameplay Related to Minecraft gameplay experience Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Aug 10, 2024
Copy link
Member

@IvanCraft623 IvanCraft623 left a 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

src/block/utils/AnvilHelper.php Outdated Show resolved Hide resolved
Comment on lines 287 to 303
/**
* 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;
}

Copy link
Member

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

Copy link
Member Author

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

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 ?

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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{
Copy link
Member

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

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 😂

Copy link
Member Author

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 Show resolved Hide resolved
github-actions[bot]
github-actions bot previously approved these changes Aug 19, 2024
github-actions[bot]
github-actions bot previously approved these changes Aug 19, 2024
github-actions[bot]
github-actions bot previously approved these changes Aug 19, 2024

declare(strict_types=1);

namespace pocketmine\block\anvil;
Copy link
Member

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?

Copy link
Member

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.

@ShockedPlot7560 ShockedPlot7560 requested a review from a team as a code owner November 18, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Gameplay Related to Minecraft gameplay experience Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants