mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Added hanging roots
This commit is contained in:
parent
323d31005f
commit
d321094081
@ -689,6 +689,7 @@ final class BlockTypeIds{
|
||||
public const CAKE_WITH_CANDLE = 10662;
|
||||
public const CAKE_WITH_DYED_CANDLE = 10663;
|
||||
public const WITHER_ROSE = 10664;
|
||||
public const HANGING_ROOTS = 10665;
|
||||
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10665;
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10666;
|
||||
}
|
||||
|
58
src/block/HangingRoots.php
Normal file
58
src/block/HangingRoots.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?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\enchantment\VanillaEnchantments;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
final class HangingRoots extends Flowable{
|
||||
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
return $block->isSolid(); //TODO: not sure if this is the correct logic
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$blockReplace->getSide(Facing::UP)->isSolid()){
|
||||
return false;
|
||||
}
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->canBeSupportedBy($this->getSide(Facing::UP))){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDropsForIncompatibleTool(Item $item) : array{
|
||||
if($item->hasEnchantment(VanillaEnchantments::SILK_TOUCH())){
|
||||
return $this->getDropsForCompatibleTool($item);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
@ -406,6 +406,7 @@ use function mb_strtolower;
|
||||
* @method static GrassPath GRASS_PATH()
|
||||
* @method static Gravel GRAVEL()
|
||||
* @method static Torch GREEN_TORCH()
|
||||
* @method static HangingRoots HANGING_ROOTS()
|
||||
* @method static HardenedClay HARDENED_CLAY()
|
||||
* @method static HardenedGlass HARDENED_GLASS()
|
||||
* @method static HardenedGlassPane HARDENED_GLASS_PANE()
|
||||
@ -1478,6 +1479,8 @@ final class VanillaBlocks{
|
||||
$cakeBreakInfo = new BreakInfo(0.5);
|
||||
self::register("cake_with_candle", new CakeWithCandle(new BID(Ids::CAKE_WITH_CANDLE), "Cake With Candle", $cakeBreakInfo));
|
||||
self::register("cake_with_dyed_candle", new CakeWithDyedCandle(new BID(Ids::CAKE_WITH_DYED_CANDLE), "Cake With Dyed Candle", $cakeBreakInfo));
|
||||
|
||||
self::register("hanging_roots", new HangingRoots(new BID(Ids::HANGING_ROOTS), "Hanging Roots", BreakInfo::instant(ToolType::SHEARS, 1)));
|
||||
}
|
||||
|
||||
private static function registerMudBlocks() : void{
|
||||
|
@ -872,6 +872,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{
|
||||
$this->mapSimple(Blocks::GRASS_PATH(), Ids::GRASS_PATH);
|
||||
$this->mapSimple(Blocks::GRAVEL(), Ids::GRAVEL);
|
||||
$this->map(Blocks::GREEN_TORCH(), fn(Torch $block) => Helper::encodeColoredTorch($block, true, Writer::create(Ids::COLORED_TORCH_RG)));
|
||||
$this->mapSimple(Blocks::HANGING_ROOTS(), Ids::HANGING_ROOTS);
|
||||
$this->mapSimple(Blocks::HARDENED_CLAY(), Ids::HARDENED_CLAY);
|
||||
$this->mapSimple(Blocks::HARDENED_GLASS(), Ids::HARD_GLASS);
|
||||
$this->mapSimple(Blocks::HARDENED_GLASS_PANE(), Ids::HARD_GLASS_PANE);
|
||||
|
@ -643,6 +643,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
|
||||
$this->map(Ids::GRAVEL, fn() => Blocks::GRAVEL());
|
||||
$this->map(Ids::GRAY_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::GRAY(), $in));
|
||||
$this->map(Ids::GREEN_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::GREEN(), $in));
|
||||
$this->map(Ids::HANGING_ROOTS, fn() => Blocks::HANGING_ROOTS());
|
||||
$this->map(Ids::HARD_GLASS, fn() => Blocks::HARDENED_GLASS());
|
||||
$this->map(Ids::HARD_GLASS_PANE, fn() => Blocks::HARDENED_GLASS_PANE());
|
||||
$this->map(Ids::HARD_STAINED_GLASS, function(Reader $in) : Block{
|
||||
|
@ -634,6 +634,7 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->registerBlock("grass_path", fn() => Blocks::GRASS_PATH());
|
||||
$result->registerBlock("gravel", fn() => Blocks::GRAVEL());
|
||||
$result->registerBlock("green_torch", fn() => Blocks::GREEN_TORCH());
|
||||
$result->registerBlock("hanging_roots", fn() => Blocks::HANGING_ROOTS());
|
||||
$result->registerBlock("hard_glass", fn() => Blocks::HARDENED_GLASS());
|
||||
$result->registerBlock("hard_glass_pane", fn() => Blocks::HARDENED_GLASS_PANE());
|
||||
$result->registerBlock("hard_stained_glass", fn() => Blocks::STAINED_HARDENED_GLASS());
|
||||
|
Loading…
x
Reference in New Issue
Block a user