mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 20:49:43 +00:00
better break time checks, added block materials
This commit is contained in:
parent
71da620aa3
commit
625e9ca71f
143 changed files with 496 additions and 54 deletions
|
|
@ -7,7 +7,7 @@ class ChainBootsItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::CHAIN;
|
||||
return ArmorMaterial::CHAIN;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class ChainChestplateItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::CHAIN;
|
||||
return ArmorMaterial::CHAIN;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class ChainHelmetItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::CHAIN;
|
||||
return ArmorMaterial::CHAIN;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class ChainLeggingsItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::CHAIN;
|
||||
return ArmorMaterial::CHAIN;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class DiamondBootsItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::DIAMOND;
|
||||
return ArmorMaterial::DIAMOND;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class DiamondChestplateItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::DIAMOND;
|
||||
return ArmorMaterial::DIAMOND;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class DiamondHelmetItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::DIAMOND;
|
||||
return ArmorMaterial::DIAMOND;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class DiamondLeggingsItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::DIAMOND;
|
||||
return ArmorMaterial::DIAMOND;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class GoldenBootsItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::GOLD;
|
||||
return ArmorMaterial::GOLD;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class GoldenChestplateItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::GOLD;
|
||||
return ArmorMaterial::GOLD;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class GoldenHelmetItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::GOLD;
|
||||
return ArmorMaterial::GOLD;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class GoldenLeggingsItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::GOLD;
|
||||
return ArmorMaterial::GOLD;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class IronBootsItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::IRON;
|
||||
return ArmorMaterial::IRON;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class IronChestplateItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::IRON;
|
||||
return ArmorMaterial::IRON;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class IronHelmetItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::IRON;
|
||||
return ArmorMaterial::IRON;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class IronLeggingsItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::IRON;
|
||||
return ArmorMaterial::IRON;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class LeatherBootsItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::LEATHER;
|
||||
return ArmorMaterial::LEATHER;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class LeatherCapItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::LEATHER;
|
||||
return ArmorMaterial::LEATHER;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class LeatherPantsItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::LEATHER;
|
||||
return ArmorMaterial::LEATHER;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class LeatherTunicItem extends ArmorItem{
|
|||
}
|
||||
|
||||
public function getMaterialDurability(){
|
||||
return Material::LEATHER;
|
||||
return ArmorMaterial::LEATHER;
|
||||
}
|
||||
|
||||
public function getBaseDurability(){
|
||||
|
|
|
|||
|
|
@ -16,5 +16,12 @@ abstract class ItemAxe extends ItemTool
|
|||
default => false,
|
||||
};
|
||||
}
|
||||
public function getDestroySpeed($id, $meta){
|
||||
$effMult = ItemTool::TIER_EFFICIENCY_MULTIPLIER[$this->getLevel()] ?? ItemTool::TIER_EFFICIENCY_MULTIPLIER[0];
|
||||
|
||||
$mat = StaticBlock::getMaterial($id);
|
||||
if($mat == Material::$wood) return $effMult;
|
||||
return parent::getDestroySpeed($id, $meta);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,5 +21,24 @@ abstract class ItemPickaxe extends ItemTool
|
|||
default => false,
|
||||
};
|
||||
}
|
||||
|
||||
public function canDestroySpecial($id, $meta){
|
||||
$level = ItemTool::TIER_MINING_LEVEL[$this->getLevel()] ?? 0;
|
||||
$mat = StaticBlock::getMaterial($id);
|
||||
if($id == OBSIDIAN || $id == GLOWING_OBSIDIAN) return $level == 3;
|
||||
if($id == DIAMOND_BLOCK || $id == DIAMOND_ORE || $id == GOLD_BLOCK || $id == GOLD_ORE || $id == REDSTONE_ORE || $id == GLOWING_REDSTONE_ORE) return $level > 1;
|
||||
if($id == IRON_BLOCK || $id == IRON_ORE || $id == LAPIS_BLOCK || $id == LAPIS_ORE) return $level > 0;
|
||||
if($mat == Material::$stone) return true;
|
||||
return $mat == Material::$metal;
|
||||
|
||||
}
|
||||
|
||||
public function getDestroySpeed($id, $meta){
|
||||
$effMult = ItemTool::TIER_EFFICIENCY_MULTIPLIER[$this->getLevel()] ?? ItemTool::TIER_EFFICIENCY_MULTIPLIER[0];
|
||||
|
||||
$mat = StaticBlock::getMaterial($id);
|
||||
if($mat == Material::$metal || $mat == Material::$stone) return $effMult;
|
||||
return parent::getDestroySpeed($id, $meta);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,5 +16,15 @@ class ItemShovel extends ItemTool
|
|||
default => false,
|
||||
};
|
||||
}
|
||||
|
||||
public function canDestroySpecial($id, $meta){
|
||||
return $id == SNOW_LAYER || $id == SNOW_BLOCK;
|
||||
}
|
||||
public function getDestroySpeed($id, $meta){
|
||||
$effMult = ItemTool::TIER_EFFICIENCY_MULTIPLIER[$this->getLevel()] ?? ItemTool::TIER_EFFICIENCY_MULTIPLIER[0];
|
||||
|
||||
if($id == GRASS || $id == DIRT || $id == SAND || $id == GRAVEL || $id == SNOW_LAYER || $id == SNOW || $id == CLAY || $id == FARMLAND) return $effMult;
|
||||
return parent::getDestroySpeed($id, $meta);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,13 @@ abstract class ItemSword extends ItemTool
|
|||
};
|
||||
}
|
||||
|
||||
public function canDestroySpecial($id, $meta){
|
||||
return $id == COBWEB;
|
||||
}
|
||||
public function getDestroySpeed($id, $meta){
|
||||
if($id == COBWEB) return 15;
|
||||
return 1.5; //in 0.8.1 it is faster than other items
|
||||
}
|
||||
public function hurtEnemy(Entity $target, Player $attacker){
|
||||
$this->hurtAndBreak(1, $attacker);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,21 @@ abstract class ItemTool extends Item
|
|||
const IRON_LEVEL = 4;
|
||||
const DIAMOND_LEVEL = 5;
|
||||
|
||||
public const TIER_MINING_LEVEL = [
|
||||
1 => 0, //wooden
|
||||
2 => 0, //golden
|
||||
3 => 1, //stone
|
||||
4 => 2, //iron
|
||||
5 => 3, //diamond
|
||||
];
|
||||
public const TIER_EFFICIENCY_MULTIPLIER = [
|
||||
1 => 2.0, //wooden
|
||||
2 => 12.0, //golden
|
||||
3 => 4.0, //stone
|
||||
4 => 6.0, //iron
|
||||
5 => 8.0, //diamond
|
||||
];
|
||||
|
||||
public function isTool(){
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,4 +12,13 @@ class ShearsItem extends ItemTool{
|
|||
}
|
||||
return parent::mineBlock($block, $player);
|
||||
}
|
||||
|
||||
public function canDestroySpecial($id, $meta){
|
||||
return $id == COBWEB;
|
||||
}
|
||||
public function getDestroySpeed($id, $meta){
|
||||
if($id == COBWEB || $id == LEAVES) return 15;
|
||||
if($id == WOOL) return 5;
|
||||
return parent::getDestroySpeed($id, $meta);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue