Hi im just testing/messing around with different things, I wanted to add my own method to the PocketMine block class...how would I go about do this. This is so I can do something like $event->getBlock->iSInArena() (example). Should I just create a new 'CustomBlock' which extends 'Block'?
You can register a new block by extending the old block class you want to replace. or you can create a new block altogether as long as you have all the necessary functions. PHP: namespace jasonwynn10\CustomBlockClass { use pocketmine\block\BlockFactory; use pocketmine\block\Dirt; use pocketmine\event\Listener; use pocketmine\plugin\PluginBase; class Main extends PluginBase implements Listener { public function onEnable() { BlockFactory::registerBlock(new CustomBlock(), true); } } class CustomBlock extends Dirt { public function isInArena() : bool { return true; // or whatever code you have } }} Note: this does not add the function to all block classes. you need to check if the block from the event is an instance of your registered class before attempting to use your function.
Thanks for the help, much appreciated, I had done that before but it hadn't occurred to me that I had to check if the block was an instance of the custom block, nonetheless thanks