Skip to content

pm-pl/selection-visualize-utils

 
 

Repository files navigation

Poggit CI Stars License


Logo

selection-visualize-utils

Provides utils for display block selection to player!

View in Poggit · Report a bug · Request a feature

About The Project

✔️ Provides Selection class for display block selection to player
✔️ Provides BlockPreview class for temporary block previews (NORMAL + LIQUID layer)

  • kim\present\utils\selectionvisualize\Selection
  • kim\present\utils\selectionvisualize\BlockPreview

Installation

See Official Poggit Virion Documentation


How to use?

Basic example

use kim\present\utils\selectionvisualize\Selection;
use pocketmine\math\Vector3;
use pocketmine\player\Player;

/** @var Player $player */
$pos1 = new Vector3(0, 64, 0);
$pos2 = new Vector3(10, 70, 10);

$selection = new Selection($pos1, $pos2);
$selection->sendTo($player);

// Later, when you want to restore the original block:
$selection->restoreFrom($player);
// or restore for every viewer:
// $selection->restoreFromAll();

Block preview example

use kim\present\utils\selectionvisualize\BlockPreview;
use kim\present\utils\selectionvisualize\PreviewEntry;
use pocketmine\block\VanillaBlocks;
use pocketmine\player\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\world\Position;

/** @var PluginBase $plugin */
/** @var Player $player */

$preview = new BlockPreview($plugin);

$world = $player->getWorld();
$pos1 = new Position(0, 64, 0, $world);
$pos2 = new Position(1, 64, 0, $world);
$block = VanillaBlocks::STONE();
$tintBlock = VanillaBlocks::RED_STAINED_GLASS();

// Basic preview: stone on normal layer, tinted glass on liquid layer
$preview->show($player,
    new PreviewEntry($pos1, $block, $tintBlock),
    new PreviewEntry($pos2, $block, $tintBlock),
);

// Later, when you want to clear the preview:
$preview->clear($player);

Preview

Below is a test video of the plugin in the example/SelectionVisualizeUtilsTest

selection-visualize-utils.test.mp4

License

Distributed under the MIT. See LICENSE for more information

About

Provides utils for display block selection to player!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%