diff --git a/src/block/BlockTypeIds.php b/src/block/BlockTypeIds.php index 955d43dd1..5197b672f 100644 --- a/src/block/BlockTypeIds.php +++ b/src/block/BlockTypeIds.php @@ -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; } diff --git a/src/block/VanillaBlocks.php b/src/block/VanillaBlocks.php index 7fdaa4663..377b5a962 100644 --- a/src/block/VanillaBlocks.php +++ b/src/block/VanillaBlocks.php @@ -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{ diff --git a/src/block/WitherRose.php b/src/block/WitherRose.php new file mode 100644 index 000000000..a5c64592f --- /dev/null +++ b/src/block/WitherRose.php @@ -0,0 +1,78 @@ +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; } +} diff --git a/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php b/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php index c69537b41..9ea1939ef 100644 --- a/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php +++ b/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php @@ -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()); diff --git a/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php b/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php index f3ea9ce4e..49901a2f2 100644 --- a/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php +++ b/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php @@ -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(), diff --git a/src/item/StringToItemParser.php b/src/item/StringToItemParser.php index 5c72f1fc1..465257a07 100644 --- a/src/item/StringToItemParser.php +++ b/src/item/StringToItemParser.php @@ -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));