Added spore blossoms

I got tired of the flood of warning messages every time someone joined the dev server...
This commit is contained in:
Dylan K. Taylor 2022-07-19 20:28:09 +01:00
parent de3bbb71fa
commit fa201b081c
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
9 changed files with 115 additions and 2 deletions

View File

@ -693,6 +693,7 @@ final class BlockTypeIds{
public const CARTOGRAPHY_TABLE = 10666;
public const SMITHING_TABLE = 10667;
public const NETHERITE = 10668;
public const SPORE_BLOSSOM = 10669;
public const FIRST_UNUSED_BLOCK_ID = 10669;
public const FIRST_UNUSED_BLOCK_ID = 10670;
}

View File

@ -0,0 +1,56 @@
<?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\block\utils\SupportType;
use pocketmine\item\Item;
use pocketmine\math\Facing;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
final class SporeBlossom extends Flowable{
private function canBeSupportedBy(Block $block) : bool{
return $block->getSupportType(Facing::DOWN)->equals(SupportType::FULL());
}
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::UP))){
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 getDropsForCompatibleTool(Item $item) : array{
return [];
}
}

View File

@ -636,6 +636,7 @@ use function mb_strtolower;
* @method static Opaque SOUL_SOIL()
* @method static Torch SOUL_TORCH()
* @method static Sponge SPONGE()
* @method static SporeBlossom SPORE_BLOSSOM()
* @method static WoodenButton SPRUCE_BUTTON()
* @method static WoodenDoor SPRUCE_DOOR()
* @method static WoodenFence SPRUCE_FENCE()
@ -1159,6 +1160,7 @@ final class VanillaBlocks{
self::registerBlocksR14();
self::registerBlocksR16();
self::registerBlocksR17();
self::registerBlocksR18();
self::registerMudBlocks();
self::registerCraftingTables();
@ -1498,6 +1500,10 @@ final class VanillaBlocks{
self::register("hanging_roots", new HangingRoots(new BID(Ids::HANGING_ROOTS), "Hanging Roots", BreakInfo::instant(ToolType::SHEARS, 1)));
}
private static function registerBlocksR18() : void{
self::register("spore_blossom", new SporeBlossom(new BID(Ids::SPORE_BLOSSOM), "Spore Blossom", BreakInfo::instant()));
}
private static function registerMudBlocks() : void{
$mudBricksBreakInfo = new BreakInfo(2.0, ToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel(), 30.0);

View File

@ -0,0 +1,46 @@
<?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\tile;
use pocketmine\nbt\NbtDataException;
use pocketmine\nbt\tag\CompoundTag;
/**
* This exists to force the client to update the spore blossom every tick, which is necessary for it to generate
* particles.
*/
final class SporeBlossom extends Spawnable{
protected function addAdditionalSpawnData(CompoundTag $nbt) : void{
//NOOP
}
public function readSaveData(CompoundTag $nbt) : void{
//NOOP
}
protected function writeSaveData(CompoundTag $nbt) : void{
//NOOP
}
}

View File

@ -73,6 +73,7 @@ final class TileFactory{
$this->register(ShulkerBox::class, ["ShulkerBox", "minecraft:shulker_box"]);
$this->register(Sign::class, ["Sign", "minecraft:sign"]);
$this->register(Smoker::class, ["Smoker", "minecraft:smoker"]);
$this->register(SporeBlossom::class, ["SporeBlossom", "minecraft:spore_blossom"]);
$this->register(Skull::class, ["Skull", "minecraft:skull"]);
//TODO: Campfire

View File

@ -532,6 +532,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{
$this->mapSimple(Blocks::SNOW(), Ids::SNOW);
$this->mapSimple(Blocks::SOUL_SAND(), Ids::SOUL_SAND);
$this->mapSimple(Blocks::SOUL_SOIL(), Ids::SOUL_SOIL);
$this->mapSimple(Blocks::SPORE_BLOSSOM(), Ids::SPORE_BLOSSOM);
$this->mapSimple(Blocks::TINTED_GLASS(), Ids::TINTED_GLASS);
$this->mapSimple(Blocks::TUFF(), Ids::TUFF);
$this->mapSimple(Blocks::WARPED_FENCE(), Ids::WARPED_FENCE);

View File

@ -371,6 +371,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
$this->map(Ids::SNOW, fn() => Blocks::SNOW());
$this->map(Ids::SOUL_SAND, fn() => Blocks::SOUL_SAND());
$this->map(Ids::SOUL_SOIL, fn() => Blocks::SOUL_SOIL());
$this->map(Ids::SPORE_BLOSSOM, fn() => Blocks::SPORE_BLOSSOM());
$this->map(Ids::STONECUTTER, fn() => Blocks::LEGACY_STONECUTTER());
$this->map(Ids::TINTED_GLASS, fn() => Blocks::TINTED_GLASS());
$this->map(Ids::TUFF, fn() => Blocks::TUFF());

View File

@ -944,6 +944,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("soul_soil", fn() => Blocks::SOUL_SOIL());
$result->registerBlock("soul_torch", fn() => Blocks::SOUL_TORCH());
$result->registerBlock("sponge", fn() => Blocks::SPONGE());
$result->registerBlock("spore_blossom", fn() => Blocks::SPORE_BLOSSOM());
$result->registerBlock("spruce_button", fn() => Blocks::SPRUCE_BUTTON());
$result->registerBlock("spruce_door", fn() => Blocks::SPRUCE_DOOR());
$result->registerBlock("spruce_door_block", fn() => Blocks::SPRUCE_DOOR());

File diff suppressed because one or more lines are too long