-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Crimson Nylium and Warped Nylium blocks #6481
base: stable
Are you sure you want to change the base?
Changes from all commits
6ee53f2
8cdfd65
36d2208
316156f
5925f53
115f364
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?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\BlockEventHelper; | ||
use pocketmine\item\Item; | ||
|
||
class GrassNylium extends Opaque{ | ||
|
||
public function getDropsForCompatibleTool(Item $item) : array{ | ||
return [ | ||
VanillaBlocks::NETHERRACK()->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){ | ||
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to use |
||
BlockEventHelper::spread($this, VanillaBlocks::NETHERRACK(), $this); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 || | ||
Comment on lines
+38
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to create a new Nylium tag for that is think |
||
$supportBlock->getTypeId() === BlockTypeIds::SOUL_SOIL; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apply only minimal change, this is unrelated to the PR "add Crimson Nylium". Open an other PR if you want to change that. |
||
|
||
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; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)))); | ||
Comment on lines
+937
to
+938
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be good to store in an variable the break info |
||
|
||
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)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same again here |
||
$this->mapSimple(Blocks::WARPED_ROOTS(), Ids::WARPED_ROOTS); | ||
$this->mapSimple(Blocks::WITHER_ROSE(), Ids::WITHER_ROSE); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alphabetical order please |
||
$this->mapSimple(Ids::WARPED_ROOTS, fn() => Blocks::WARPED_ROOTS()); | ||
$this->mapSimple(Ids::WATERLILY, fn() => Blocks::LILY_PAD()); | ||
$this->mapSimple(Ids::WEB, fn() => Blocks::COBWEB()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nylium
orNetherNylium
would be better.