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

Implemented smithing table functionality #6202

Open
wants to merge 27 commits into
base: minor-next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ae13dc9
add basic smithing table requirements
HimmelKreis4865 Dec 17, 2023
16de186
Merge branch 'pmmp:stable' into smithing-table
HimmelKreis4865 Dec 17, 2023
fc5e5eb
fixed remaining problems
HimmelKreis4865 Dec 18, 2023
c3ea0ba
phpstan stop crying
HimmelKreis4865 Dec 18, 2023
2a56e41
why are headers missing?
HimmelKreis4865 Dec 18, 2023
4da34c3
updated version with all fixes except for save ids - they must be fixed
HimmelKreis4865 Jan 21, 2024
6dce15d
oops (save ids still not working)
HimmelKreis4865 Jan 21, 2024
b82de65
oops
HimmelKreis4865 Jan 22, 2024
93db5ef
fixes all big remaining issues
HimmelKreis4865 Mar 22, 2024
1ad80e9
Merge remote-tracking branch 'origin/minor-next' into working-smithing
HimmelKreis4865 Mar 22, 2024
5360b77
cs style fixes
HimmelKreis4865 Mar 22, 2024
7433655
resolved some more problems
HimmelKreis4865 Mar 23, 2024
d987a65
made materials & patterns customizable
HimmelKreis4865 Mar 24, 2024
d818686
Merge branch 'minor-next' of https://github.com/pmmp/PocketMine-MP in…
ipad54 Nov 30, 2024
849f9b1
Code overhaul
ipad54 Nov 30, 2024
348a211
Update src/inventory/transaction/SmithingTransaction.php
ipad54 Nov 30, 2024
2294a6f
CS
ipad54 Nov 30, 2024
e19d0d7
Make trim constants private
ipad54 Nov 30, 2024
671a578
Merge branch 'smithing-table' of https://github.com/HimmelKreis4865/P…
ipad54 Nov 30, 2024
30a4edb
Don't use match
ipad54 Dec 1, 2024
d88960e
Use readonly where possible
ipad54 Dec 1, 2024
f479d66
Fix CS
ipad54 Dec 1, 2024
1deacda
Revert "Don't use match"
ipad54 Dec 1, 2024
b8da323
Fix tests
ipad54 Dec 1, 2024
c41cf15
Changes for review
ipad54 Dec 1, 2024
780b373
Declare all offset constants together
ipad54 Dec 1, 2024
a68323a
Merge branch 'minor-next' of https://github.com/pmmp/PocketMine-MP in…
ipad54 Dec 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/crafting/SmithingTrimRecipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
class SmithingTrimRecipe implements SmithingRecipe{

public function __construct(
private RecipeIngredient $input,
private RecipeIngredient $addition,
private RecipeIngredient $template
private readonly RecipeIngredient $input,
private readonly RecipeIngredient $addition,
private readonly RecipeIngredient $template
){}

public function getInput() : RecipeIngredient{
Expand Down
25 changes: 10 additions & 15 deletions src/data/bedrock/ArmorTrimMaterialTypeIdMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,16 @@ final class ArmorTrimMaterialTypeIdMap{
private array $materialToId = [];

public function __construct(){
foreach(Materials::getAll() as $material){
$this->register(match($material){
Materials::AMETHYST() => Ids::AMETHYST,
Materials::COPPER() => Ids::COPPER,
Materials::DIAMOND() => Ids::DIAMOND,
Materials::EMERALD() => Ids::EMERALD,
Materials::GOLD() => Ids::GOLD,
Materials::IRON() => Ids::IRON,
Materials::LAPIS() => Ids::LAPIS,
Materials::NETHERITE() => Ids::NETHERITE,
Materials::QUARTZ() => Ids::QUARTZ,
Materials::REDSTONE() => Ids::REDSTONE,
default => throw new AssumptionFailedError("Unhandled armor trim material type")
}, $material);
}
$this->register(Ids::AMETHYST, Materials::AMETHYST());
$this->register(Ids::COPPER, Materials::COPPER());
$this->register(Ids::DIAMOND, Materials::DIAMOND());
$this->register(Ids::EMERALD, Materials::EMERALD());
$this->register(Ids::GOLD, Materials::GOLD());
$this->register(Ids::IRON, Materials::IRON());
$this->register(Ids::LAPIS, Materials::LAPIS());
$this->register(Ids::NETHERITE, Materials::NETHERITE());
$this->register(Ids::QUARTZ, Materials::QUARTZ());
$this->register(Ids::REDSTONE, Materials::REDSTONE());
ipad54 marked this conversation as resolved.
Show resolved Hide resolved
}

public function register(string $stringId, ArmorTrimMaterial $material) : void{
Expand Down
37 changes: 16 additions & 21 deletions src/data/bedrock/ArmorTrimPatternTypeIdMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,22 @@ final class ArmorTrimPatternTypeIdMap{
private array $patternToId = [];

public function __construct(){
foreach(Patterns::getAll() as $pattern){
$this->register(match($pattern){
Patterns::COAST() => Ids::COAST,
Patterns::DUNE() => Ids::DUNE,
Patterns::EYE() => Ids::EYE,
Patterns::HOST() => Ids::HOST,
Patterns::RAISER() => Ids::RAISER,
Patterns::RIB() => Ids::RIB,
Patterns::SENTRY() => Ids::SENTRY,
Patterns::SHAPER() => Ids::SHAPER,
Patterns::SILENCE() => Ids::SILENCE,
Patterns::SNOUT() => Ids::SNOUT,
Patterns::SPIRE() => Ids::SPIRE,
Patterns::TIDE() => Ids::TIDE,
Patterns::VEX() => Ids::VEX,
Patterns::WARD() => Ids::WARD,
Patterns::WAYFINDER() => Ids::WAYFINDER,
Patterns::WILD() => Ids::WILD,
default => throw new AssumptionFailedError("Unhandled armor trim pattern type")
}, $pattern);
}
$this->register(Ids::COAST, Patterns::COAST());
$this->register(Ids::DUNE, Patterns::DUNE());
$this->register(Ids::EYE, Patterns::EYE());
$this->register(Ids::HOST, Patterns::HOST());
$this->register(Ids::RAISER, Patterns::RAISER());
$this->register(Ids::RIB, Patterns::RIB());
$this->register(Ids::SENTRY, Patterns::SENTRY());
$this->register(Ids::SHAPER, Patterns::SHAPER());
$this->register(Ids::SILENCE, Patterns::SILENCE());
$this->register(Ids::SNOUT, Patterns::SNOUT());
$this->register(Ids::SPIRE, Patterns::SPIRE());
$this->register(Ids::TIDE, Patterns::TIDE());
$this->register(Ids::VEX, Patterns::VEX());
$this->register(Ids::WARD, Patterns::WARD());
$this->register(Ids::WAYFINDER, Patterns::WAYFINDER());
$this->register(Ids::WILD, Patterns::WILD());
}

public function register(string $stringId, ArmorTrimPattern $pattern) : void{
Expand Down
2 changes: 1 addition & 1 deletion src/inventory/transaction/SmithingTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SmithingTransaction extends InventoryTransaction{

public function __construct(
Player $source,
private SmithingRecipe $recipe,
private readonly SmithingRecipe $recipe,
array $actions = []
){
parent::__construct($source, $actions);
Expand Down
4 changes: 2 additions & 2 deletions src/item/ArmorTrim.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
class ArmorTrim{

public function __construct(
private ArmorTrimMaterial $material,
private ArmorTrimPattern $pattern
private readonly ArmorTrimMaterial $material,
private readonly ArmorTrimPattern $pattern
HimmelKreis4865 marked this conversation as resolved.
Show resolved Hide resolved
){}

public function getMaterial() : ArmorTrimMaterial{
Expand Down
2 changes: 1 addition & 1 deletion src/item/ArmorTrimMaterial.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ArmorTrimMaterial{
*/
public function __construct(
Item $item,
private string $color
private readonly string $color
){
$this->item = clone $item;
}
Expand Down
Loading