mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 03:17:12 +00:00
Coarse is now a state of Dirt, instead of a separate block
This commit is contained in:
parent
df260034cd
commit
24405b63c1
@ -136,9 +136,6 @@ class BlockFactory{
|
||||
$this->register(new Coal(new BID(Ids::COAL_BLOCK, 0), "Coal Block", new BlockBreakInfo(5.0, BlockToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel(), 30.0)));
|
||||
$this->register(new CoalOre(new BID(Ids::COAL_ORE, 0), "Coal Ore", new BlockBreakInfo(3.0, BlockToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel())));
|
||||
|
||||
$dirtBreakInfo = new BlockBreakInfo(0.5, BlockToolType::SHOVEL);
|
||||
$this->register(new CoarseDirt(new BID(Ids::DIRT, Meta::DIRT_COARSE), "Coarse Dirt", $dirtBreakInfo));
|
||||
|
||||
$cobblestoneBreakInfo = new BlockBreakInfo(2.0, BlockToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel(), 30.0);
|
||||
$this->register($cobblestone = new Opaque(new BID(Ids::COBBLESTONE, 0), "Cobblestone", $cobblestoneBreakInfo));
|
||||
$infestedStoneBreakInfo = new BlockBreakInfo(0.75);
|
||||
@ -157,7 +154,7 @@ class BlockFactory{
|
||||
|
||||
$this->register(new Opaque(new BID(Ids::DIAMOND_BLOCK, 0), "Diamond Block", new BlockBreakInfo(5.0, BlockToolType::PICKAXE, ToolTier::IRON()->getHarvestLevel(), 30.0)));
|
||||
$this->register(new DiamondOre(new BID(Ids::DIAMOND_ORE, 0), "Diamond Ore", new BlockBreakInfo(3.0, BlockToolType::PICKAXE, ToolTier::IRON()->getHarvestLevel())));
|
||||
$this->register(new Dirt(new BID(Ids::DIRT, Meta::DIRT_NORMAL), "Dirt", $dirtBreakInfo));
|
||||
$this->register(new Dirt(new BID(Ids::DIRT, 0), "Dirt", new BlockBreakInfo(0.5, BlockToolType::SHOVEL)));
|
||||
$this->register(new DoublePlant(new BID(Ids::DOUBLE_PLANT, Meta::DOUBLE_PLANT_SUNFLOWER), "Sunflower", BlockBreakInfo::instant()));
|
||||
$this->register(new DoublePlant(new BID(Ids::DOUBLE_PLANT, Meta::DOUBLE_PLANT_LILAC), "Lilac", BlockBreakInfo::instant()));
|
||||
$this->register(new DoublePlant(new BID(Ids::DOUBLE_PLANT, Meta::DOUBLE_PLANT_ROSE_BUSH), "Rose Bush", BlockBreakInfo::instant()));
|
||||
|
@ -86,8 +86,7 @@ final class BlockLegacyMetadata{
|
||||
public const CORAL_VARIANT_FIRE = 3;
|
||||
public const CORAL_VARIANT_HORN = 4;
|
||||
|
||||
public const DIRT_NORMAL = 0;
|
||||
public const DIRT_COARSE = 1;
|
||||
public const DIRT_FLAG_COARSE = 0x1;
|
||||
|
||||
public const DOOR_FLAG_TOP = 0x08;
|
||||
public const DOOR_BOTTOM_FLAG_OPEN = 0x04;
|
||||
|
@ -1,43 +0,0 @@
|
||||
<?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\block;
|
||||
|
||||
use pocketmine\item\Hoe;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class CoarseDirt extends Dirt{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($face === Facing::UP and $item instanceof Hoe){
|
||||
$item->applyDamage(1);
|
||||
$this->pos->getWorld()->setBlock($this->pos, VanillaBlocks::DIRT());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -31,10 +31,36 @@ use pocketmine\player\Player;
|
||||
|
||||
class Dirt extends Opaque{
|
||||
|
||||
protected bool $coarse = false;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->coarse = ($stateMeta & BlockLegacyMetadata::DIRT_FLAG_COARSE) !== 0;
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->coarse ? BlockLegacyMetadata::DIRT_FLAG_COARSE : 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1;
|
||||
}
|
||||
|
||||
public function getNonPersistentStateBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function isCoarse() : bool{ return $this->coarse; }
|
||||
|
||||
/** @return $this */
|
||||
public function setCoarse(bool $coarse) : self{
|
||||
$this->coarse = $coarse;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($face === Facing::UP and $item instanceof Hoe){
|
||||
$item->applyDamage(1);
|
||||
$this->pos->getWorld()->setBlock($this->pos, VanillaBlocks::FARMLAND());
|
||||
$this->pos->getWorld()->setBlock($this->pos, $this->coarse ? VanillaBlocks::DIRT() : VanillaBlocks::FARMLAND());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class Grass extends Opaque{
|
||||
$b = $this->pos->getWorld()->getBlockAt($x, $y, $z);
|
||||
if(
|
||||
!($b instanceof Dirt) or
|
||||
$b instanceof CoarseDirt or
|
||||
$b->isCoarse() or
|
||||
$this->pos->getWorld()->getFullLightAt($x, $y + 1, $z) < 4 or
|
||||
$this->pos->getWorld()->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2
|
||||
){
|
||||
|
@ -109,7 +109,6 @@ use function assert;
|
||||
* @method static Clay CLAY()
|
||||
* @method static Coal COAL()
|
||||
* @method static CoalOre COAL_ORE()
|
||||
* @method static CoarseDirt COARSE_DIRT()
|
||||
* @method static Opaque COBBLESTONE()
|
||||
* @method static Slab COBBLESTONE_SLAB()
|
||||
* @method static Stair COBBLESTONE_STAIRS()
|
||||
@ -663,7 +662,6 @@ final class VanillaBlocks{
|
||||
self::register("clay", $factory->get(82, 0));
|
||||
self::register("coal", $factory->get(173, 0));
|
||||
self::register("coal_ore", $factory->get(16, 0));
|
||||
self::register("coarse_dirt", $factory->get(3, 1));
|
||||
self::register("cobblestone", $factory->get(4, 0));
|
||||
self::register("cobblestone_slab", $factory->get(44, 3));
|
||||
self::register("cobblestone_stairs", $factory->get(67, 0));
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user