mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Added lightning rods
This commit is contained in:
parent
ad7528e3f3
commit
5e70ae2066
@ -679,6 +679,7 @@ final class BlockTypeIds{
|
||||
public const WARPED_WART_BLOCK = 10652;
|
||||
public const CRYING_OBSIDIAN = 10653;
|
||||
public const GILDED_BLACKSTONE = 10654;
|
||||
public const LIGHTNING_ROD = 10655;
|
||||
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10655;
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10656;
|
||||
}
|
||||
|
55
src/block/LightningRod.php
Normal file
55
src/block/LightningRod.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?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\AnyFacingTrait;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
final class LightningRod extends Transparent{
|
||||
use AnyFacingTrait;
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
$myAxis = Facing::axis($this->facing);
|
||||
|
||||
$result = AxisAlignedBB::one();
|
||||
foreach([Axis::X, Axis::Y, Axis::Z] as $axis){
|
||||
if($axis !== $myAxis){
|
||||
$result->squash($axis, 6 / 16);
|
||||
}
|
||||
}
|
||||
|
||||
return [$result];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->facing = $face;
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
}
|
@ -447,6 +447,7 @@ use function mb_strtolower;
|
||||
* @method static Opaque LEGACY_STONECUTTER()
|
||||
* @method static Lever LEVER()
|
||||
* @method static Light LIGHT()
|
||||
* @method static LightningRod LIGHTNING_ROD()
|
||||
* @method static DoublePlant LILAC()
|
||||
* @method static Flower LILY_OF_THE_VALLEY()
|
||||
* @method static WaterLily LILY_PAD()
|
||||
@ -1449,6 +1450,10 @@ final class VanillaBlocks{
|
||||
self::register("polished_deepslate_wall", new Wall(new BID(Ids::POLISHED_DEEPSLATE_WALL), "Polished Deepslate Wall", $polishedDeepslateBreakInfo));
|
||||
|
||||
self::register("tinted_glass", new TintedGlass(new BID(Ids::TINTED_GLASS), "Tinted Glass", new BreakInfo(0.3)));
|
||||
|
||||
//blast resistance should be 30 if we were matched with java :(
|
||||
$copperBreakInfo = new BreakInfo(3.0, ToolType::PICKAXE, ToolTier::STONE()->getHarvestLevel(), 18.0);
|
||||
self::register("lightning_rod", new LightningRod(new BID(Ids::LIGHTNING_ROD), "Lightning Rod", $copperBreakInfo));
|
||||
}
|
||||
|
||||
private static function registerMudBlocks() : void{
|
||||
|
@ -78,6 +78,7 @@ use pocketmine\block\Leaves;
|
||||
use pocketmine\block\Lectern;
|
||||
use pocketmine\block\Lever;
|
||||
use pocketmine\block\Light;
|
||||
use pocketmine\block\LightningRod;
|
||||
use pocketmine\block\LitPumpkin;
|
||||
use pocketmine\block\Loom;
|
||||
use pocketmine\block\MelonStem;
|
||||
@ -842,6 +843,10 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{
|
||||
return Writer::create(Ids::LIGHT_BLOCK)
|
||||
->writeInt(StateNames::BLOCK_LIGHT_LEVEL, $block->getLightLevel());
|
||||
});
|
||||
$this->map(Blocks::LIGHTNING_ROD(), function(LightningRod $block) : Writer{
|
||||
return Writer::create(Ids::LIGHTNING_ROD)
|
||||
->writeFacingDirection($block->getFacing());
|
||||
});
|
||||
$this->map(Blocks::LILAC(), fn(DoublePlant $block) => Helper::encodeDoublePlant($block, StringValues::DOUBLE_PLANT_TYPE_SYRINGA, Writer::create(Ids::DOUBLE_PLANT)));
|
||||
$this->map(Blocks::LILY_OF_THE_VALLEY(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_LILY_OF_THE_VALLEY));
|
||||
$this->mapSimple(Blocks::LILY_PAD(), Ids::WATERLILY);
|
||||
|
@ -692,6 +692,10 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
|
||||
return Blocks::LIGHT()
|
||||
->setLightLevel($in->readBoundedInt(StateNames::BLOCK_LIGHT_LEVEL, Light::MIN_LIGHT_LEVEL, Light::MAX_LIGHT_LEVEL));
|
||||
});
|
||||
$this->map(Ids::LIGHTNING_ROD, function(Reader $in) : Block{
|
||||
return Blocks::LIGHTNING_ROD()
|
||||
->setFacing($in->readFacingDirection());
|
||||
});
|
||||
$this->map(Ids::LIGHT_BLUE_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::LIGHT_BLUE(), $in));
|
||||
$this->map(Ids::LIGHT_WEIGHTED_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeWeightedPressurePlate(Blocks::WEIGHTED_PRESSURE_PLATE_LIGHT(), $in));
|
||||
$this->map(Ids::LIME_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::LIME(), $in));
|
||||
|
@ -695,6 +695,7 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->registerBlock("light", fn() => Blocks::LIGHT());
|
||||
$result->registerBlock("light_block", fn() => Blocks::LIGHT());
|
||||
$result->registerBlock("light_weighted_pressure_plate", fn() => Blocks::WEIGHTED_PRESSURE_PLATE_LIGHT());
|
||||
$result->registerBlock("lightning_rod", fn() => Blocks::LIGHTNING_ROD());
|
||||
$result->registerBlock("lilac", fn() => Blocks::LILAC());
|
||||
$result->registerBlock("lily_of_the_valley", fn() => Blocks::LILY_OF_THE_VALLEY());
|
||||
$result->registerBlock("lily_pad", fn() => Blocks::LILY_PAD());
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user