Added wither rose

This commit is contained in:
Dylan K. Taylor 2022-07-14 16:07:16 +01:00
parent 3dd4c42fd3
commit 0c7370e564
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
6 changed files with 85 additions and 1 deletions

View File

@ -688,6 +688,7 @@ final class BlockTypeIds{
public const DYED_CANDLE = 10661;
public const CAKE_WITH_CANDLE = 10662;
public const CAKE_WITH_DYED_CANDLE = 10663;
public const WITHER_ROSE = 10664;
public const FIRST_UNUSED_BLOCK_ID = 10664;
public const FIRST_UNUSED_BLOCK_ID = 10665;
}

View File

@ -696,6 +696,7 @@ use function mb_strtolower;
* @method static WeightedPressurePlateLight WEIGHTED_PRESSURE_PLATE_LIGHT()
* @method static Wheat WHEAT()
* @method static Flower WHITE_TULIP()
* @method static WitherRose WITHER_ROSE()
* @method static Wool WOOL()
*/
final class VanillaBlocks{
@ -1356,6 +1357,7 @@ final class VanillaBlocks{
private static function registerBlocksR13() : void{
self::register("light", new Light(new BID(Ids::LIGHT), "Light Block", BreakInfo::indestructible()));
self::register("wither_rose", new WitherRose(new BID(Ids::WITHER_ROSE), "Wither Rose", BreakInfo::instant()));
}
private static function registerBlocksR14() : void{

78
src/block/WitherRose.php Normal file
View File

@ -0,0 +1,78 @@
<?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\entity\effect\EffectInstance;
use pocketmine\entity\effect\VanillaEffects;
use pocketmine\entity\Entity;
use pocketmine\entity\Living;
use pocketmine\item\Item;
use pocketmine\math\Facing;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
class WitherRose extends Flowable{
private function canBeSupportedBy(Block $block) : bool{
return match($block->getTypeId()){
BlockTypeIds::GRASS,
BlockTypeIds::DIRT,
BlockTypeIds::FARMLAND,
BlockTypeIds::MYCELIUM,
BlockTypeIds::PODZOL,
BlockTypeIds::NETHERRACK,
BlockTypeIds::SOUL_SAND,
BlockTypeIds::SOUL_SOIL => true,
//TODO: moss, mud, rooted dirt
default => false
};
}
public function onNearbyBlockChange() : void{
if(!$this->canBeSupportedBy($this->getSide(Facing::DOWN))){
$this->position->getWorld()->useBreakOn($this->position);
}
}
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if(!$this->canBeSupportedBy($blockReplace->getSide(Facing::DOWN))){
return false;
}
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}
public function hasEntityCollision() : bool{ return true; }
public function onEntityInside(Entity $entity) : bool{
if($entity instanceof Living && !$entity->getEffects()->has(VanillaEffects::WITHER())){
$entity->getEffects()->add(new EffectInstance(VanillaEffects::WITHER(), 40));
}
return true;
}
public function getFlameEncouragement() : int{ return 60; }
public function getFlammability() : int{ return 100; }
}

View File

@ -1377,6 +1377,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{
});
$this->map(Blocks::WHEAT(), fn(Wheat $block) => Helper::encodeCrops($block, new Writer(Ids::WHEAT)));
$this->map(Blocks::WHITE_TULIP(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_TULIP_WHITE));
$this->mapSimple(Blocks::WITHER_ROSE(), Ids::WITHER_ROSE);
$this->map(Blocks::WOOL(), function(Wool $block) : Writer{
return Writer::create(Ids::WOOL)
->writeColor($block->getColor());

View File

@ -1273,6 +1273,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
$this->map(Ids::WEB, fn() => Blocks::COBWEB());
$this->map(Ids::WHEAT, fn(Reader $in) => Helper::decodeCrops(Blocks::WHEAT(), $in));
$this->map(Ids::WHITE_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::WHITE(), $in));
$this->map(Ids::WITHER_ROSE, fn() => Blocks::WITHER_ROSE());
$this->map(Ids::WOOD, fn(Reader $in) : Block => Helper::decodeLog(match($woodType = $in->readString(StateNames::WOOD_TYPE)){
StringValues::WOOD_TYPE_ACACIA => Blocks::ACACIA_WOOD(),
StringValues::WOOD_TYPE_BIRCH => Blocks::BIRCH_WOOD(),

View File

@ -1058,6 +1058,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("weighted_pressure_plate_light", fn() => Blocks::WEIGHTED_PRESSURE_PLATE_LIGHT());
$result->registerBlock("wheat_block", fn() => Blocks::WHEAT());
$result->registerBlock("white_tulip", fn() => Blocks::WHITE_TULIP());
$result->registerBlock("wither_rose", fn() => Blocks::WITHER_ROSE());
$result->registerBlock("wither_skeleton_skull", fn() => Blocks::MOB_HEAD()->setSkullType(SkullType::WITHER_SKELETON()));
$result->registerBlock("wood", fn() => Blocks::OAK_LOG()->setStripped(false));
$result->registerBlock("wood2", fn() => Blocks::ACACIA_LOG()->setStripped(false));