mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Split Mushroom Stem away from other mushroom variants
mushroom stem (and all-sided stem) are unique blocks, which don't drop anything and which don't stack with other shroom variants when block-picked. They also get mapped to the same block when placed, and there's no distinction between red mushroom stem and brown mushroom stem.
This commit is contained in:
parent
edfe9ae745
commit
e80c1a0ce9
@ -123,7 +123,6 @@ class BlockFactory{
|
||||
$this->register(new Opaque(new BID(Ids::BRICK_BLOCK), "Bricks", $bricksBreakInfo));
|
||||
|
||||
$this->register(new BrownMushroom(new BID(Ids::BROWN_MUSHROOM), "Brown Mushroom"));
|
||||
$this->register(new BrownMushroomBlock(new BID(Ids::BROWN_MUSHROOM_BLOCK), "Brown Mushroom Block"));
|
||||
$this->register(new Cactus(new BID(Ids::CACTUS), "Cactus"));
|
||||
$this->register(new Cake(new BID(Ids::CAKE_BLOCK, 0, ItemIds::CAKE), "Cake"));
|
||||
$this->register(new Carrot(new BID(Ids::CARROTS), "Carrot Block"));
|
||||
@ -279,7 +278,6 @@ class BlockFactory{
|
||||
|
||||
$this->register(new Rail(new BID(Ids::RAIL), "Rail"));
|
||||
$this->register(new RedMushroom(new BID(Ids::RED_MUSHROOM), "Red Mushroom"));
|
||||
$this->register(new RedMushroomBlock(new BID(Ids::RED_MUSHROOM_BLOCK), "Red Mushroom Block"));
|
||||
$this->register(new Redstone(new BID(Ids::REDSTONE_BLOCK), "Redstone Block"));
|
||||
$this->register(new RedstoneComparator(new BIDFlattened(Ids::UNPOWERED_COMPARATOR, Ids::POWERED_COMPARATOR, 0, ItemIds::COMPARATOR, TileComparator::class), "Redstone Comparator"));
|
||||
$this->register(new RedstoneLamp(new BIDFlattened(Ids::REDSTONE_LAMP, Ids::LIT_REDSTONE_LAMP), "Redstone Lamp"));
|
||||
@ -478,6 +476,9 @@ class BlockFactory{
|
||||
$this->register(new ChemistryTable(new BID(Ids::CHEMISTRY_TABLE, Meta::CHEMISTRY_MATERIAL_REDUCER), "Material Reducer", $chemistryTableBreakInfo));
|
||||
|
||||
$this->register(new ChemicalHeat(new BID(Ids::CHEMICAL_HEAT), "Heat Block", $chemistryTableBreakInfo));
|
||||
|
||||
$this->registerMushroomBlocks();
|
||||
|
||||
//region --- auto-generated TODOs for bedrock-1.11.0 ---
|
||||
//TODO: minecraft:bell
|
||||
//TODO: minecraft:blast_furnace
|
||||
@ -638,6 +639,53 @@ class BlockFactory{
|
||||
//endregion
|
||||
}
|
||||
|
||||
private function registerMushroomBlocks() : void{
|
||||
//shrooms have to be handled one by one because some metas are variants and others aren't, and they can't be
|
||||
//separated by a bitmask
|
||||
|
||||
$mushroomBlockBreakInfo = new BlockBreakInfo(0.2, BlockToolType::AXE);
|
||||
|
||||
$mushroomBlocks = [
|
||||
new BrownMushroomBlock(new BID(Ids::BROWN_MUSHROOM_BLOCK), "Brown Mushroom Block", $mushroomBlockBreakInfo),
|
||||
new RedMushroomBlock(new BID(Ids::RED_MUSHROOM_BLOCK), "Red Mushroom Block", $mushroomBlockBreakInfo)
|
||||
];
|
||||
|
||||
//caps
|
||||
foreach([
|
||||
Meta::MUSHROOM_BLOCK_ALL_PORES,
|
||||
Meta::MUSHROOM_BLOCK_CAP_NORTHWEST_CORNER,
|
||||
Meta::MUSHROOM_BLOCK_CAP_NORTH_SIDE,
|
||||
Meta::MUSHROOM_BLOCK_CAP_NORTHEAST_CORNER,
|
||||
Meta::MUSHROOM_BLOCK_CAP_WEST_SIDE,
|
||||
Meta::MUSHROOM_BLOCK_CAP_TOP_ONLY,
|
||||
Meta::MUSHROOM_BLOCK_CAP_EAST_SIDE,
|
||||
Meta::MUSHROOM_BLOCK_CAP_SOUTHWEST_CORNER,
|
||||
Meta::MUSHROOM_BLOCK_CAP_SOUTH_SIDE,
|
||||
Meta::MUSHROOM_BLOCK_CAP_SOUTHEAST_CORNER,
|
||||
Meta::MUSHROOM_BLOCK_ALL_CAP,
|
||||
] as $meta){
|
||||
foreach($mushroomBlocks as $block){
|
||||
$block->readStateFromData($block->getId(), $meta);
|
||||
$this->remap($block->getId(), $meta, clone $block);
|
||||
}
|
||||
}
|
||||
|
||||
//and the invalid states
|
||||
for($meta = 11; $meta <= 13; ++$meta){
|
||||
foreach($mushroomBlocks as $block){
|
||||
$this->remap($block->getId(), $meta, clone $block);
|
||||
}
|
||||
}
|
||||
|
||||
//finally, the stems
|
||||
$mushroomStem = new MushroomStem(new BID(Ids::BROWN_MUSHROOM_BLOCK, Meta::MUSHROOM_BLOCK_STEM), "Mushroom Stem", $mushroomBlockBreakInfo);
|
||||
$this->remap(Ids::BROWN_MUSHROOM_BLOCK, Meta::MUSHROOM_BLOCK_STEM, $mushroomStem);
|
||||
$this->remap(Ids::RED_MUSHROOM_BLOCK, Meta::MUSHROOM_BLOCK_STEM, $mushroomStem);
|
||||
$allSidedMushroomStem = new MushroomStem(new BID(Ids::BROWN_MUSHROOM_BLOCK, Meta::MUSHROOM_BLOCK_ALL_STEM), "All Sided Mushroom Stem", $mushroomBlockBreakInfo);
|
||||
$this->remap(Ids::BROWN_MUSHROOM_BLOCK, Meta::MUSHROOM_BLOCK_ALL_STEM, $allSidedMushroomStem);
|
||||
$this->remap(Ids::RED_MUSHROOM_BLOCK, Meta::MUSHROOM_BLOCK_ALL_STEM, $allSidedMushroomStem);
|
||||
}
|
||||
|
||||
private function registerElements() : void{
|
||||
$instaBreak = BlockBreakInfo::instant();
|
||||
$this->register(new Opaque(new BID(Ids::ELEMENT_0), "???", $instaBreak));
|
||||
|
33
src/block/MushroomStem.php
Normal file
33
src/block/MushroomStem.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?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\Item;
|
||||
|
||||
final class MushroomStem extends Opaque{
|
||||
|
||||
public function getDrops(Item $item) : array{ return []; }
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{ return true; }
|
||||
}
|
@ -37,10 +37,6 @@ class RedMushroomBlock extends Opaque{
|
||||
*/
|
||||
protected $rotationData = 0;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.2, BlockToolType::AXE));
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->rotationData;
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ use function assert;
|
||||
* @method static Wood ACACIA_WOOD()
|
||||
* @method static ActivatorRail ACTIVATOR_RAIL()
|
||||
* @method static Air AIR()
|
||||
* @method static MushroomStem ALL_SIDED_MUSHROOM_STEM()
|
||||
* @method static Flower ALLIUM()
|
||||
* @method static Opaque ANDESITE()
|
||||
* @method static Slab ANDESITE_SLAB()
|
||||
@ -443,6 +444,7 @@ use function assert;
|
||||
* @method static Stair MOSSY_STONE_BRICK_STAIRS()
|
||||
* @method static Wall MOSSY_STONE_BRICK_WALL()
|
||||
* @method static Opaque MOSSY_STONE_BRICKS()
|
||||
* @method static MushroomStem MUSHROOM_STEM()
|
||||
* @method static Mycelium MYCELIUM()
|
||||
* @method static Fence NETHER_BRICK_FENCE()
|
||||
* @method static Slab NETHER_BRICK_SLAB()
|
||||
@ -665,6 +667,7 @@ final class VanillaBlocks{
|
||||
self::register("acacia_wood", $factory->get(467, 4));
|
||||
self::register("activator_rail", $factory->get(126, 0));
|
||||
self::register("air", $factory->get(0, 0));
|
||||
self::register("all_sided_mushroom_stem", $factory->get(99, 15));
|
||||
self::register("allium", $factory->get(38, 2));
|
||||
self::register("andesite", $factory->get(1, 5));
|
||||
self::register("andesite_slab", $factory->get(417, 3));
|
||||
@ -1060,6 +1063,7 @@ final class VanillaBlocks{
|
||||
self::register("mossy_stone_brick_stairs", $factory->get(430, 0));
|
||||
self::register("mossy_stone_brick_wall", $factory->get(139, 8));
|
||||
self::register("mossy_stone_bricks", $factory->get(98, 1));
|
||||
self::register("mushroom_stem", $factory->get(99, 10));
|
||||
self::register("mycelium", $factory->get(110, 0));
|
||||
self::register("nether_brick_fence", $factory->get(113, 0));
|
||||
self::register("nether_brick_slab", $factory->get(44, 7));
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user