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

Mace Implementation #6446

Closed
wants to merge 79 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
44c9a40
Mace Implementation
KnosTx Sep 5, 2024
a1695af
Mace Implementation
KnosTx Sep 5, 2024
93c4768
Mace Implementation
KnosTx Sep 5, 2024
4b48860
Mace Implementation
KnosTx Sep 5, 2024
10d3095
Mace Implementation
KnosTx Sep 5, 2024
f862146
Mace Implementation
KnosTx Sep 5, 2024
fc73e9c
Mace Implementation
KnosTx Sep 5, 2024
c7d8347
Mace Implementation
KnosTx Sep 5, 2024
ea317c3
Mace
KnosTx Sep 5, 2024
8726fc8
Add method getMaxDurability for Mace Implementation
KnosTx Sep 5, 2024
7676651
FIX CS
KnosTx Sep 5, 2024
0378c70
FIX CS
KnosTx Sep 5, 2024
ec57bce
Mace Implementation
KnosTx Sep 5, 2024
6c4a446
Mace Implementation
KnosTx Sep 6, 2024
4719ece
Mace Implementation
KnosTx Sep 6, 2024
f1336b4
Mace Implementation
KnosTx Sep 6, 2024
69d1372
Mace Implementation
KnosTx Sep 6, 2024
636ee95
Mace Implementation
KnosTx Sep 6, 2024
cfd2fac
Mace Implementation
KnosTx Sep 6, 2024
8cc3393
Mace Implementation
KnosTx Sep 6, 2024
d05fac2
FIX CS
KnosTx Sep 6, 2024
b36b6a3
Mace Implementation
KnosTx Sep 6, 2024
1cec376
Mace Implementation
KnosTx Sep 6, 2024
3aebd92
Mace Implementation
KnosTx Sep 6, 2024
8bb204c
FIX CS
KnosTx Sep 6, 2024
d72b439
Mace Implementation
KnosTx Sep 6, 2024
e298cf3
Mace Implementation
KnosTx Sep 6, 2024
9e35107
Mace Implementation
KnosTx Sep 6, 2024
1362ec1
FIX CS
KnosTx Sep 6, 2024
b5cb337
Fix CS
KnosTx Sep 6, 2024
161d989
Mace Implementation
KnosTx Sep 6, 2024
da5b927
Mace Implementation
KnosTx Sep 6, 2024
0135e1b
Mace
KnosTx Sep 6, 2024
99df1d4
Mavewjssj
KnosTx Sep 6, 2024
c46149c
Mace Implementation
KnosTx Sep 6, 2024
a164a48
Rrrrrrrr
KnosTx Sep 6, 2024
8d26fdb
Mace Implementation
KnosTx Sep 6, 2024
7ebc997
Mace Implementation
KnosTx Sep 6, 2024
49e9444
Implemented: MaceSmashAirSound and MaceSmashGround
KnosTx Sep 6, 2024
977cf13
FIX CS
KnosTx Sep 6, 2024
6da11d5
FIX CS
KnosTx Sep 6, 2024
74c8d7f
Mace Implementation
KnosTx Sep 8, 2024
3124d59
Mace Implementation
KnosTx Sep 8, 2024
e815b20
Mace Implementation
KnosTx Sep 8, 2024
8979d1a
FIX CS
KnosTx Sep 8, 2024
53cebdf
Create build.yml
KnosTx Sep 8, 2024
dbf7a68
J
KnosTx Sep 8, 2024
1a8e4b9
Update build.yml
KnosTx Sep 8, 2024
0dcd353
Delete .github/workflows/build.yml
KnosTx Sep 8, 2024
17eb827
Mace Implementation
KnosTx Sep 8, 2024
a242a73
Mace Implementation.
KnosTx Sep 9, 2024
4243f30
FIX CS
KnosTx Sep 9, 2024
d6ae28d
FIX CS
KnosTx Sep 9, 2024
61c4426
FIX CS
KnosTx Sep 9, 2024
fe61117
Merge pull request #1 from KnosTx/KnosTx-patch-1
KnosTx Sep 9, 2024
1369b0b
Mace Implementation
KnosTx Sep 9, 2024
35cb66e
Create php.yml
KnosTx Sep 9, 2024
d31ec28
Wrong branch
KnosTx Sep 9, 2024
eb34491
Update StringToItemParser.php
KnosTx Sep 9, 2024
2911e5b
Mace Implementation
KnosTx Sep 9, 2024
ab3a694
Remove
KnosTx Sep 9, 2024
f2543bd
Mace Implementation
KnosTx Sep 9, 2024
d6f6a62
Mace Implementation
KnosTx Sep 9, 2024
1565004
Mace Implementation
KnosTx Sep 9, 2024
9c3ef6a
Mace Implementation
KnosTx Sep 9, 2024
2d64bb7
Mace Implementation
KnosTx Sep 9, 2024
718a771
Mace Implementation
KnosTx Sep 9, 2024
de7d867
Mace Implementation
KnosTx Sep 9, 2024
598e207
Update Mace.php
KnosTx Sep 9, 2024
6122039
Update Mace.php
KnosTx Sep 9, 2024
bcdb84e
Mace Implementation
KnosTx Sep 9, 2024
ac0ad3e
Update Mace.php
KnosTx Sep 9, 2024
e602634
Update M
KnosTx Sep 9, 2024
3f67625
D
KnosTx Sep 9, 2024
47ce4c1
Update Mace.php
KnosTx Sep 9, 2024
0fca75b
Update Mace.php
KnosTx Sep 9, 2024
d1f3735
Update Mace.php
KnosTx Sep 9, 2024
5756e80
Update Mace.php
KnosTx Sep 9, 2024
ea922db
Mace Implementation
KnosTx Sep 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ private function register1to1ItemMappings() : void{
$this->map1to1Item(Ids::LEATHER_CHESTPLATE, Items::LEATHER_TUNIC());
$this->map1to1Item(Ids::LEATHER_HELMET, Items::LEATHER_CAP());
$this->map1to1Item(Ids::LEATHER_LEGGINGS, Items::LEATHER_PANTS());
$this->map1to1Item(Ids::MACE, Items::MACE());
$this->map1to1Item(Ids::MAGMA_CREAM, Items::MAGMA_CREAM());
$this->map1to1Item(Ids::MANGROVE_BOAT, Items::MANGROVE_BOAT());
$this->map1to1Item(Ids::MANGROVE_SIGN, Items::MANGROVE_SIGN());
Expand Down
3 changes: 2 additions & 1 deletion src/item/ItemTypeIds.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ private function __construct(){
public const SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE = 20285;
public const PITCHER_POD = 20286;
public const NAME_TAG = 20287;
public const MACE = 20288;

public const FIRST_UNUSED_ITEM_ID = 20288;
public const FIRST_UNUSED_ITEM_ID = 20289;

private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;

Expand Down
92 changes: 92 additions & 0 deletions src/item/Mace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

declare(strict_types=1);

namespace pocketmine\item;

use pocketmine\block\Block;
use pocketmine\block\BlockToolType;
use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\math\Vector3;

class Mace extends Tool{

public function getBlockToolType() : int{
return BlockToolType::SWORD;
}

public function getMaxDurability() : int{
return 250;
}

public function getAttackPoints() : int{
return 5;
}

public function getBlockToolHarvestLevel() : int{
return 1;
}

public function getMiningEfficiency(bool $isCorrectTool) : float{
return parent::getMiningEfficiency($isCorrectTool) * 1.5;
}

public function getBaseMiningEfficiency() : float{
return 10;
}

public function onDestroyBlock(Block $block, array &$returnedItems) : bool{
if(!$block->getBreakInfo()->breaksInstantly()){
return $this->applyDamage(2);
}
return false;
}

public function onAttackEntity(EntityDamageByEntityEvent $damager, Entity $victim, array &$returnedItems) : bool{

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Method pocketmine\item\Mace::onAttackEntity() has parameter $returnedItems with no value type specified in iterable type array.

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #1 $damager (pocketmine\event\entity\EntityDamageByEntityEvent) of method pocketmine\item\Mace::onAttackEntity() is not contravariant with parameter #1 $victim (pocketmine\entity\Entity) of method pocketmine\item\Item::onAttackEntity().

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #2 $victim (pocketmine\entity\Entity) of method pocketmine\item\Mace::onAttackEntity() is not contravariant with parameter #2 $returnedItems (array) of method pocketmine\item\Item::onAttackEntity().

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #2 $victim of method pocketmine\item\Mace::onAttackEntity() is not passed by reference but parameter #2 $returnedItems of method pocketmine\item\Item::onAttackEntity() is passed by reference.

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #3 $returnedItems of method pocketmine\item\Mace::onAttackEntity() is not optional.

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Method pocketmine\item\Mace::onAttackEntity() has parameter $returnedItems with no value type specified in iterable type array.

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #1 $damager (pocketmine\event\entity\EntityDamageByEntityEvent) of method pocketmine\item\Mace::onAttackEntity() is not contravariant with parameter #1 $victim (pocketmine\entity\Entity) of method pocketmine\item\Item::onAttackEntity().

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #2 $victim (pocketmine\entity\Entity) of method pocketmine\item\Mace::onAttackEntity() is not contravariant with parameter #2 $returnedItems (array) of method pocketmine\item\Item::onAttackEntity().

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #2 $victim of method pocketmine\item\Mace::onAttackEntity() is not passed by reference but parameter #2 $returnedItems of method pocketmine\item\Item::onAttackEntity() is passed by reference.

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #3 $returnedItems of method pocketmine\item\Mace::onAttackEntity() is not optional.

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Method pocketmine\item\Mace::onAttackEntity() has parameter $returnedItems with no value type specified in iterable type array.

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #1 $damager (pocketmine\event\entity\EntityDamageByEntityEvent) of method pocketmine\item\Mace::onAttackEntity() is not contravariant with parameter #1 $victim (pocketmine\entity\Entity) of method pocketmine\item\Item::onAttackEntity().

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #2 $victim (pocketmine\entity\Entity) of method pocketmine\item\Mace::onAttackEntity() is not contravariant with parameter #2 $returnedItems (array) of method pocketmine\item\Item::onAttackEntity().

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #2 $victim of method pocketmine\item\Mace::onAttackEntity() is not passed by reference but parameter #2 $returnedItems of method pocketmine\item\Item::onAttackEntity() is passed by reference.

Check failure on line 66 in src/item/Mace.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #3 $returnedItems of method pocketmine\item\Mace::onAttackEntity() is not optional.
$damageEvent = $victim->getLastDamageCause();

if($damageEvent instanceof EntityDamageByEntityEvent){

$user = $damageEvent->getDamager();

if($user !== null){
$height = $user->getFallDistance();

if($height >= 2) {
$damage = ($height - 1) * 5;
$victim->setHealth($victim->getHealth() - $damage);

$motion = $user->getMotion();
$user->setMotion(new Vector3($motion->x, 0, $motion->z));

$user->fallDistance = 0;
}
}
}

$this->applyDamage(2);

return true;
}
}
2 changes: 1 addition & 1 deletion src/item/StringToItemParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ private static function registerItems(self $result) : void{
$result->register("leather_leggings", fn() => Items::LEATHER_PANTS());
$result->register("leather_pants", fn() => Items::LEATHER_PANTS());
$result->register("leather_tunic", fn() => Items::LEATHER_TUNIC());
$result->register("magma_cream", fn() => Items::MAGMA_CREAM());
$result->register("mace", fn() => Items::MACE());
$result->register("melon", fn() => Items::MELON());
$result->register("melon_seeds", fn() => Items::MELON_SEEDS());
$result->register("melon_slice", fn() => Items::MELON());
Expand Down
2 changes: 2 additions & 0 deletions src/item/VanillaItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
* @method static Armor LEATHER_CAP()
* @method static Armor LEATHER_PANTS()
* @method static Armor LEATHER_TUNIC()
* @method static Mace MACE()
* @method static Item MAGMA_CREAM()
* @method static Boat MANGROVE_BOAT()
* @method static ItemBlockWallOrFloor MANGROVE_SIGN()
Expand Down Expand Up @@ -633,6 +634,7 @@ private static function registerTierToolItems() : void{
self::register("netherite_sword", new Sword(new IID(Ids::NETHERITE_SWORD), "Netherite Sword", ToolTier::NETHERITE, [EnchantmentTags::SWORD]));
self::register("stone_sword", new Sword(new IID(Ids::STONE_SWORD), "Stone Sword", ToolTier::STONE, [EnchantmentTags::SWORD]));
self::register("wooden_sword", new Sword(new IID(Ids::WOODEN_SWORD), "Wooden Sword", ToolTier::WOOD, [EnchantmentTags::SWORD]));
self::register("mace", new Mace(new IID(Ids::MACE), "Mace", [EnchantmentTags::SWORD]));
}

private static function registerArmorItems() : void{
Expand Down
1 change: 1 addition & 0 deletions src/item/enchantment/ItemEnchantmentTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ final class ItemEnchantmentTags{
public const ELYTRA = "elytra";
public const BRUSH = "brush";
public const WEAPONS = "weapons";
public const MACE = "mace";
}
34 changes: 34 additions & 0 deletions src/world/sound/MaceHeavySmashGroundSound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

declare(strict_types=1);

namespace pocketmine\world\sound;

use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;

final class MaceHeavySmashGroundSound implements Sound{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::MACE_HEAVY_SMASH_GROUND, $pos, false)];
}
}
34 changes: 34 additions & 0 deletions src/world/sound/MaceSmashAirSound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

declare(strict_types=1);

namespace pocketmine\world\sound;

use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;

final class MaceSmashAirSound implements Sound{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::MACE_SMASH_AIR, $pos, false)];
}
}
34 changes: 34 additions & 0 deletions src/world/sound/MaceSmashGroundSound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

declare(strict_types=1);

namespace pocketmine\world\sound;

use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;

final class MaceSmashGroundSound implements Sound{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::MACE_SMASH_GROUND, $pos, false)];
}
}
Loading