From f2da48c7e3c12fecb6a7a3b3643b2edd636a28b6 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Mon, 5 Sep 2022 21:19:18 +0300 Subject: [PATCH] small changes to armor system + maxstacksize of armor is fixed --- src/material/Item.php | 125 +++++------------- src/material/item/armor/ChainBoots.php | 11 +- src/material/item/armor/ChainChestplate.php | 10 +- src/material/item/armor/ChainHelmet.php | 10 +- src/material/item/armor/ChainLeggings.php | 10 +- src/material/item/armor/DiamondBoots.php | 10 +- src/material/item/armor/DiamondChestplate.php | 10 +- src/material/item/armor/DiamondHelmet.php | 10 +- src/material/item/armor/DiamondLeggings.php | 10 +- src/material/item/armor/GoldenBoots.php | 10 +- src/material/item/armor/GoldenChestplate.php | 10 +- src/material/item/armor/GoldenHelmet.php | 10 +- src/material/item/armor/GoldenLeggings.php | 10 +- src/material/item/armor/IronBoots.php | 10 +- src/material/item/armor/IronChestplate.php | 10 +- src/material/item/armor/IronHelmet.php | 10 +- src/material/item/armor/IronLeggings.php | 10 +- src/material/item/armor/LeatherBoots.php | 10 +- src/material/item/armor/LeatherCap.php | 10 +- src/material/item/armor/LeatherPants.php | 10 +- src/material/item/armor/LeatherTunic.php | 10 +- src/material/item/tool/Bow.php | 4 +- src/material/item/tool/DiamondAxe.php | 3 + src/material/item/tool/DiamondHoe.php | 5 +- src/material/item/tool/DiamondPickaxe.php | 3 + src/material/item/tool/DiamondShovel.php | 3 + src/material/item/tool/DiamondSword.php | 4 +- src/material/item/tool/FlintSteel.php | 4 + src/material/item/tool/GoldenAxe.php | 5 +- src/material/item/tool/GoldenHoe.php | 5 +- src/material/item/tool/GoldenPickaxe.php | 5 +- src/material/item/tool/GoldenShovel.php | 5 +- src/material/item/tool/GoldenSword.php | 4 +- src/material/item/tool/IronAxe.php | 5 +- src/material/item/tool/IronHoe.php | 5 +- src/material/item/tool/IronPickaxe.php | 5 +- src/material/item/tool/IronShovel.php | 5 +- src/material/item/tool/IronSword.php | 4 +- src/material/item/tool/Shears.php | 5 +- src/material/item/tool/StoneAxe.php | 5 +- src/material/item/tool/StoneHoe.php | 5 +- src/material/item/tool/StonePickaxe.php | 5 +- src/material/item/tool/StoneSword.php | 4 +- src/material/item/tool/WoodenAxe.php | 5 +- src/material/item/tool/WoodenHoe.php | 5 +- src/material/item/tool/WoodenPickaxe.php | 5 +- src/material/item/tool/WoodenShovel.php | 5 +- src/material/item/tool/WoodenSword.php | 4 +- 48 files changed, 312 insertions(+), 136 deletions(-) diff --git a/src/material/Item.php b/src/material/Item.php index 3807d04d..e4f542ca 100755 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -1,6 +1,12 @@ -`block = BlockAPI::get($this->id, $this->meta); $this->name = $this->block->getName(); } - if($this->isTool() !== false){ + if($this->isTool() || $this->isArmor()){ $this->maxStackSize = 1; } } - final public function getName(){ + public function getName(){ return $this->name; } - final public function isPlaceable(){ + public function isPlaceable(){ return (($this->block instanceof Block) and $this->block->isPlaceable === true); } - final public function getBlock(){ + public function getBlock(){ if($this->block instanceof Block){ return $this->block; }else{ @@ -160,19 +166,23 @@ class Item{ } } - final public function getID(){ + public function getID(){ return $this->id; } - final public function getMetadata(){ + public function getMetadata(){ return $this->meta; } - final public function getMaxStackSize(){ + public function isArmor(){ + return false; + } + + public function getMaxStackSize(){ return $this->maxStackSize; } - final public function getFuelTime(){ + public function getFuelTime(){ if(!isset(FuelData::$duration[$this->id])){ return false; } @@ -182,7 +192,7 @@ class Item{ return false; } - final public function getSmeltItem(){ + public function getSmeltItem(){ if(!isset(SmeltingData::$product[$this->id])){ return false; } @@ -199,7 +209,7 @@ class Item{ } - public function useOn($object, $force = false){ + public function useOn($object, $force = false){ //move shearing & milking code here? if($this->isTool() or $force === true){ if(($object instanceof Entity) and !$this->isSword()){ $this->meta += 2; @@ -215,15 +225,11 @@ class Item{ return false; } - final public function isTool(){ - return ($this->id === FLINT_STEEL or $this->id === SHEARS or $this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false or $this->isSword() !== false); + public function isTool(){ + return false; } - final public function getMaxDurability(){ - $isArmor = $this->getArmorMaterialDurability(); //can be used any of new methods, both return false if item is not armor - if($isArmor !== false){ - return $this->getArmorMaterialDurability() * $this->getHealthPerArmorSlot(); - } + public function getMaxDurability(){ if(!$this->isTool() and $this->isHoe() === false and $this->id !== BOW){ return false; } @@ -234,9 +240,9 @@ class Item{ 3 => 131, //STONE 4 => 250, //IRON 5 => 1561, //DIAMOND(called EMERALD in disassembled code) - FLINT_STEEL => 65, - SHEARS => 239, - BOW => 385, + FLINT_STEEL => 65, //lets assume it is correct + SHEARS => 239, //x2 + BOW => 385 //x3 ); if(($type = $this->isPickaxe()) === false){ @@ -252,75 +258,8 @@ class Item{ } return $levels[$type]; } - - public function getArmorMaterialDurability(){ - switch($this->id){ - case LEATHER_CAP: - case LEATHER_TUNIC: - case LEATHER_PANTS: - case LEATHER_BOOTS: - return 5; - - case CHAIN_HELMET: - case CHAIN_CHESTPLATE: - case CHAIN_LEGGINGS: - case CHAIN_BOOTS: - return 15; - - case IRON_HELMET: - case IRON_CHESTPLATE: - case IRON_LEGGINGS: - case IRON_BOOTS: - return 15; - - case DIAMOND_HELMET: - case DIAMOND_CHESTPLATE: - case DIAMOND_LEGGINGS: - case DIAMOND_BOOTS: - return 33; - - case GOLD_HELMET: - case GOLD_CHESTPLATE: - case GOLD_LEGGINGS: - case GOLD_BOOTS: - return 7; - default: - return false; - } - } - - public function getHealthPerArmorSlot(){ - switch($this->id){ - case LEATHER_CAP: - case CHAIN_HELMET: - case IRON_HELMET: - case DIAMOND_HELMET: - case GOLD_HELMET: - return 11; - case LEATHER_TUNIC: - case CHAIN_CHESTPLATE: - case IRON_CHESTPLATE: - case DIAMOND_CHESTPLATE: - case GOLD_CHESTPLATE: - return 16; - case LEATHER_PANTS: - case CHAIN_LEGGINGS: - case IRON_LEGGINGS: - case DIAMOND_LEGGINGS: - case GOLD_LEGGINGS: - return 15; - case LEATHER_BOOTS: - case CHAIN_BOOTS: - case IRON_BOOTS: - case DIAMOND_BOOTS: - case GOLD_BOOTS: - return 13; - default: - return false; - } - } - final public function isPickaxe(){ //Returns false or level of the pickaxe + public function isPickaxe(){ //Returns false or level of the pickaxe switch($this->id){ case IRON_PICKAXE: return 4; @@ -337,7 +276,7 @@ class Item{ } } - final public function isAxe(){ + public function isAxe(){ switch($this->id){ case IRON_AXE: return 4; @@ -354,7 +293,7 @@ class Item{ } } - final public function isSword(){ + public function isSword(){ switch($this->id){ case IRON_SWORD: return 4; @@ -371,7 +310,7 @@ class Item{ } } - final public function isShovel(){ + public function isShovel(){ switch($this->id){ case IRON_SHOVEL: return 4; @@ -405,7 +344,7 @@ class Item{ return ($this->id === SHEARS); } - final public function __toString(){ + public function __toString(){ return "Item ". $this->name ." (".$this->id.":".$this->meta.")"; } diff --git a/src/material/item/armor/ChainBoots.php b/src/material/item/armor/ChainBoots.php index 31a35e20..5b191ed6 100644 --- a/src/material/item/armor/ChainBoots.php +++ b/src/material/item/armor/ChainBoots.php @@ -1,8 +1,17 @@