diff --git a/src/block/BlockTypeIds.php b/src/block/BlockTypeIds.php index 3914a4b74a..ff5d8adfca 100644 --- a/src/block/BlockTypeIds.php +++ b/src/block/BlockTypeIds.php @@ -765,8 +765,10 @@ private function __construct(){ public const COPPER_TRAPDOOR = 10735; public const CHISELED_COPPER = 10736; public const COPPER_GRATE = 10737; + public const CRIMSON_NYLIUM = 10738; + public const WARPED_NYLIUM = 10739; - public const FIRST_UNUSED_BLOCK_ID = 10738; + public const FIRST_UNUSED_BLOCK_ID = 10740; private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID; diff --git a/src/block/GrassNylium.php b/src/block/GrassNylium.php new file mode 100644 index 0000000000..4ffd974a14 --- /dev/null +++ b/src/block/GrassNylium.php @@ -0,0 +1,48 @@ +asItem() + ]; + } + + public function ticksRandomly() : bool{ + return true; + } + + public function onRandomTick() : void{ + $world = $this->position->getWorld(); + $lightAbove = $world->getFullLightAt((int) $this->position->x, (int) $this->position->y + 1, (int) $this->position->z); + if($lightAbove < 4 && $world->getBlockAt((int) $this->position->x, (int) $this->position->y + 1, (int) $this->position->z)->getLightFilter() >= 2){ + BlockEventHelper::spread($this, VanillaBlocks::NETHERRACK(), $this); + } + } +} diff --git a/src/block/NetherRoots.php b/src/block/NetherRoots.php index 0b08d1b180..d2572b4769 100644 --- a/src/block/NetherRoots.php +++ b/src/block/NetherRoots.php @@ -30,11 +30,13 @@ final class NetherRoots extends Flowable{ use StaticSupportTrait; private function canBeSupportedAt(Block $block) : bool{ - //TODO: nylium, moss + //TODO: moss $supportBlock = $block->getSide(Facing::DOWN); return $supportBlock->hasTypeTag(BlockTypeTags::DIRT) || $supportBlock->hasTypeTag(BlockTypeTags::MUD) || + $supportBlock->getTypeId() === BlockTypeIds::CRIMSON_NYLIUM || + $supportBlock->getTypeId() === BlockTypeIds::WARPED_NYLIUM || $supportBlock->getTypeId() === BlockTypeIds::SOUL_SOIL; } } diff --git a/src/block/RedMushroom.php b/src/block/RedMushroom.php index 81ab940f53..8d547bfd7c 100644 --- a/src/block/RedMushroom.php +++ b/src/block/RedMushroom.php @@ -23,13 +23,11 @@ namespace pocketmine\block; -use pocketmine\item\Item; +use pocketmine\block\utils\StaticSupportTrait; use pocketmine\math\Facing; -use pocketmine\math\Vector3; -use pocketmine\player\Player; -use pocketmine\world\BlockTransaction; class RedMushroom extends Flowable{ + use StaticSupportTrait; public function ticksRandomly() : bool{ return true; @@ -41,16 +39,11 @@ public function onNearbyBlockChange() : void{ } } - public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - $down = $this->getSide(Facing::DOWN); + private function canBeSupportedAt(Block $block) : bool{ + $supportBlock = $block->getSide(Facing::DOWN); $position = $this->position; $lightLevel = $position->getWorld()->getFullLightAt($position->x, $position->y, $position->z); - $downId = $down->getTypeId(); - //TODO: nylium support - if(($lightLevel <= 12 && !$down->isTransparent()) || $downId === BlockTypeIds::MYCELIUM || $downId === BlockTypeIds::PODZOL){ - return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); - } - - return false; + $supportBlockId = $supportBlock->getTypeId(); + return ($lightLevel <= 12 && !$supportBlock->isTransparent()) || $supportBlockId === BlockTypeIds::MYCELIUM || $supportBlockId === BlockTypeIds::WARPED_NYLIUM || $supportBlockId === BlockTypeIds::CRIMSON_NYLIUM || $supportBlockId === BlockTypeIds::PODZOL; } } diff --git a/src/block/VanillaBlocks.php b/src/block/VanillaBlocks.php index 60540dfb83..35a5cd80dd 100644 --- a/src/block/VanillaBlocks.php +++ b/src/block/VanillaBlocks.php @@ -230,6 +230,7 @@ * @method static WoodenFence CRIMSON_FENCE() * @method static FenceGate CRIMSON_FENCE_GATE() * @method static Wood CRIMSON_HYPHAE() + * @method static GrassNylium CRIMSON_NYLIUM() * @method static Planks CRIMSON_PLANKS() * @method static WoodenPressurePlate CRIMSON_PRESSURE_PLATE() * @method static NetherRoots CRIMSON_ROOTS() @@ -766,6 +767,7 @@ * @method static WoodenFence WARPED_FENCE() * @method static FenceGate WARPED_FENCE_GATE() * @method static Wood WARPED_HYPHAE() + * @method static GrassNylium WARPED_NYLIUM() * @method static Planks WARPED_PLANKS() * @method static WoodenPressurePlate WARPED_PRESSURE_PLATE() * @method static NetherRoots WARPED_ROOTS() @@ -932,6 +934,9 @@ public function getBreakTime(Item $item) : float{ $grassBreakInfo = BreakInfo::shovel(0.6); self::register("grass", new Grass(new BID(Ids::GRASS), "Grass", new Info($grassBreakInfo, [Tags::DIRT]))); self::register("grass_path", new GrassPath(new BID(Ids::GRASS_PATH), "Grass Path", new Info($grassBreakInfo))); + self::register("crimson_nylium", new GrassNylium(new BID(Ids::CRIMSON_NYLIUM), "Crimson Nylium", new Info(BreakInfo::pickaxe(0.4)))); + self::register("warped_nylium", new GrassNylium(new BID(Ids::WARPED_NYLIUM), "Warped Nylium", new Info(BreakInfo::pickaxe(0.4)))); + self::register("gravel", new Gravel(new BID(Ids::GRAVEL), "Gravel", new Info(BreakInfo::shovel(0.6)))); $hardenedClayBreakInfo = new Info(BreakInfo::pickaxe(1.25, ToolTier::WOOD, 21.0)); diff --git a/src/data/bedrock/block/convert/BlockObjectToStateSerializer.php b/src/data/bedrock/block/convert/BlockObjectToStateSerializer.php index aebfd67ffa..cae0b828ab 100644 --- a/src/data/bedrock/block/convert/BlockObjectToStateSerializer.php +++ b/src/data/bedrock/block/convert/BlockObjectToStateSerializer.php @@ -813,6 +813,7 @@ private function registerSimpleSerializers() : void{ $this->mapSimple(Blocks::CRACKED_POLISHED_BLACKSTONE_BRICKS(), Ids::CRACKED_POLISHED_BLACKSTONE_BRICKS); $this->mapSimple(Blocks::CRACKED_STONE_BRICKS(), Ids::CRACKED_STONE_BRICKS); $this->mapSimple(Blocks::CRAFTING_TABLE(), Ids::CRAFTING_TABLE); + $this->mapSimple(Blocks::CRIMSON_NYLIUM(), Ids::CRIMSON_NYLIUM); $this->mapSimple(Blocks::CRIMSON_ROOTS(), Ids::CRIMSON_ROOTS); $this->mapSimple(Blocks::CRYING_OBSIDIAN(), Ids::CRYING_OBSIDIAN); $this->mapSimple(Blocks::DANDELION(), Ids::DANDELION); @@ -1060,6 +1061,7 @@ private function registerSimpleSerializers() : void{ $this->mapSimple(Blocks::TUFF(), Ids::TUFF); $this->mapSimple(Blocks::TUFF_BRICKS(), Ids::TUFF_BRICKS); $this->mapSimple(Blocks::WARPED_WART_BLOCK(), Ids::WARPED_WART_BLOCK); + $this->mapSimple(Blocks::WARPED_NYLIUM(), Ids::WARPED_NYLIUM); $this->mapSimple(Blocks::WARPED_ROOTS(), Ids::WARPED_ROOTS); $this->mapSimple(Blocks::WITHER_ROSE(), Ids::WITHER_ROSE); diff --git a/src/data/bedrock/block/convert/BlockStateToObjectDeserializer.php b/src/data/bedrock/block/convert/BlockStateToObjectDeserializer.php index 5c0a427cc7..e1467f5810 100644 --- a/src/data/bedrock/block/convert/BlockStateToObjectDeserializer.php +++ b/src/data/bedrock/block/convert/BlockStateToObjectDeserializer.php @@ -737,6 +737,7 @@ private function registerSimpleDeserializers() : void{ $this->mapSimple(Ids::CRACKED_POLISHED_BLACKSTONE_BRICKS, fn() => Blocks::CRACKED_POLISHED_BLACKSTONE_BRICKS()); $this->mapSimple(Ids::CRACKED_STONE_BRICKS, fn() => Blocks::CRACKED_STONE_BRICKS()); $this->mapSimple(Ids::CRAFTING_TABLE, fn() => Blocks::CRAFTING_TABLE()); + $this->mapSimple(Ids::CRIMSON_NYLIUM, fn() => Blocks::CRIMSON_NYLIUM()); $this->mapSimple(Ids::CRIMSON_ROOTS, fn() => Blocks::CRIMSON_ROOTS()); $this->mapSimple(Ids::CRYING_OBSIDIAN, fn() => Blocks::CRYING_OBSIDIAN()); $this->mapSimple(Ids::CUT_RED_SANDSTONE, fn() => Blocks::CUT_RED_SANDSTONE()); @@ -983,6 +984,7 @@ private function registerSimpleDeserializers() : void{ $this->mapSimple(Ids::TUFF_BRICKS, fn() => Blocks::TUFF_BRICKS()); $this->mapSimple(Ids::UNDYED_SHULKER_BOX, fn() => Blocks::SHULKER_BOX()); $this->mapSimple(Ids::WARPED_WART_BLOCK, fn() => Blocks::WARPED_WART_BLOCK()); + $this->mapSimple(Ids::WARPED_NYLIUM, fn() => Blocks::WARPED_NYLIUM()); $this->mapSimple(Ids::WARPED_ROOTS, fn() => Blocks::WARPED_ROOTS()); $this->mapSimple(Ids::WATERLILY, fn() => Blocks::LILY_PAD()); $this->mapSimple(Ids::WEB, fn() => Blocks::COBWEB()); diff --git a/src/item/StringToItemParser.php b/src/item/StringToItemParser.php index ee0f1f5c52..a166009397 100644 --- a/src/item/StringToItemParser.php +++ b/src/item/StringToItemParser.php @@ -298,6 +298,7 @@ private static function registerBlocks(self $result) : void{ $result->registerBlock("crimson_fence", fn() => Blocks::CRIMSON_FENCE()); $result->registerBlock("crimson_fence_gate", fn() => Blocks::CRIMSON_FENCE_GATE()); $result->registerBlock("crimson_hyphae", fn() => Blocks::CRIMSON_HYPHAE()->setStripped(false)); + $result->registerBlock("crimson_nylium", fn() => Blocks::CRIMSON_NYLIUM()); $result->registerBlock("crimson_planks", fn() => Blocks::CRIMSON_PLANKS()); $result->registerBlock("crimson_pressure_plate", fn() => Blocks::CRIMSON_PRESSURE_PLATE()); $result->registerBlock("crimson_roots", fn() => Blocks::CRIMSON_ROOTS()); @@ -1136,6 +1137,7 @@ private static function registerBlocks(self $result) : void{ $result->registerBlock("warped_fence", fn() => Blocks::WARPED_FENCE()); $result->registerBlock("warped_fence_gate", fn() => Blocks::WARPED_FENCE_GATE()); $result->registerBlock("warped_hyphae", fn() => Blocks::WARPED_HYPHAE()->setStripped(false)); + $result->registerBlock("warped_nylium", fn() => Blocks::WARPED_NYLIUM()); $result->registerBlock("warped_planks", fn() => Blocks::WARPED_PLANKS()); $result->registerBlock("warped_pressure_plate", fn() => Blocks::WARPED_PRESSURE_PLATE()); $result->registerBlock("warped_roots", fn() => Blocks::WARPED_ROOTS()); diff --git a/tests/phpunit/block/block_factory_consistency_check.json b/tests/phpunit/block/block_factory_consistency_check.json index 79804d8cbd..e4a9044f03 100644 --- a/tests/phpunit/block/block_factory_consistency_check.json +++ b/tests/phpunit/block/block_factory_consistency_check.json @@ -154,6 +154,7 @@ "CRIMSON_FENCE": 1, "CRIMSON_FENCE_GATE": 16, "CRIMSON_HYPHAE": 6, + "CRIMSON_NYLIUM": 1, "CRIMSON_PLANKS": 1, "CRIMSON_PRESSURE_PLATE": 2, "CRIMSON_ROOTS": 1, @@ -690,6 +691,7 @@ "WARPED_FENCE": 1, "WARPED_FENCE_GATE": 16, "WARPED_HYPHAE": 6, + "WARPED_NYLIUM": 1, "WARPED_PLANKS": 1, "WARPED_PRESSURE_PLATE": 2, "WARPED_ROOTS": 1,