Coder Social home page Coder Social logo

fuyutsuki / extendedblocks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from javierleon9966/extendedblocks

0.0 0.0 0.0 634 KB

This plugins adds the ability to add extended blocks in PocketMine 3.0.0+ API.

License: GNU General Public License v3.0

PHP 100.00%

extendedblocks's Introduction

ExtendedBlocks Poggit-CI

This plugin adds the compatibility to add more blocks above the 255 ID in Pocketmine API 3.0.0+

Warning: If you remove this plugin after some blocks has been placed it may transform into a Reserved6 block and can't be reversible. Also this plugin is a temporary solution until PM 4 is fully released so don't except this to work or any updates.

Note: This plugin may affect your server performance if too many blocks are in your world. Use this plugin at your own risk!

To update this plugin safely you must stop your server and install the updated version, then you can start the server again.

How the plugins works

This plugin uses a Tile Entity which saves the registered blocks from another plugin and a Placeholder block which replaces the Reserved6 that makes instance with the block you want that uses PlaceholderTrait and gives info to the server.

It checks when a LevelChunkPacket is sent and finds every tile within the chunk that is a Placeholder block and sends the block to the player.

How to use the plugin

For now you would need to use another plugin that register the blocks itself.

For the blocks to be able to register correctly you must add this trait in the block class:

use JavierLeon9966\ExtendedBlocks\block\PlaceholderTrait;

Soon It'll be able to add new blocks in a configuration, but for now it's just like a API plugin.

It's recommended to use this methods when the plugin starts loading:

use pocketmine\block\BlockFactory;
use pocketmine\item\ItemBlock;
use pocketmine\plugin\PluginBase;
use JavierLeon9966\ExtendedBlocks\item\ItemFactory;
class Plugin extends PluginBase{
  public function onLoad(){
    BlockFactory::registerBlock($block);
    ItemFactory::addCreativeItem(ItemFactory::get(255 - $block->getId())); //Usually most blocks
  }
  ...
}

Format you must use

This is a example of how your class must look for it to work properly

use pocketmine\block\Block; //You can extend any class but be a Block
use JavierLeon9966\ExtendedBlocks\block\PlaceholderTrait;
class Sample extends Block{
  use PlaceholderTrait;
  protected $id = 526; //The id of the block must be positive
  public function __construct(int $meta = 0){ //Optional
    $this->meta = $meta;
  }
  ...
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.