1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to create a New Object

Discussion in 'Development' started by Palente, Feb 15, 2017.

  1. Palente

    Palente Slime

    Messages:
    75
    GitHub:
    palente
    Hey,
    I Want a create a New Object not in Minecraft
    Can I do that?
    Or is it not with plugin can I do that
    I want example create a New block or a new arm
    Can I do that?
    Or is it in Addon or a Mod?
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    You cannot do that with a plugin. I don't know if you can do it with an addon.
     
  3. kaliiks

    kaliiks Zombie

    Messages:
    250
    You can change already existing block
     
  4. Palente

    Palente Slime

    Messages:
    75
    GitHub:
    palente
    How I can do that please?
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Resource packs, which hasn't been implemented yet.
     
  6. Skullex

    Skullex Spider

    Messages:
    13
    GitHub:
    skull3x
    Quoting "Resource packs, which hasn't been implemented yet".
    Although, resource packs have not been implemented yet! You can somewhat create your own custom blocks and items and within a .php file. You can also add different features to these and completely separate them from actual vanilla items and blocks!

    CustomBlock.php

    PHP:
    <?php
    namespace CustomBlock;
    use 
    pocketmine\block\Transparent;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\item\Tool;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\Player;
    use 
    pocketmine\block\Block;
    class 
    CustomBlock extends Transparent{

    protected 
    $id #number // block id

    private $temporalVector null;

        public function 
    __construct(){
            if(
    $this->temporalVector === null){
                
    $this->temporalVector = new Vector3(000);
            }
        }

        public function 
    place(Item $itemBlock $blockBlock $target$face$fx$fy$fzPlayer $player null){
            if(
    $player instanceof Player){
                
    $this->meta $player->getDirection() & 0x01;
            }
            
    $this->getLevel()->setBlock($block$thistruetrue);
            return 
    true;
        }
     
        public function 
    getName() : string{
            return 
    "CustomBlock!";
        }

        public function 
    getHardness() {
            return -
    1;
        }
     
        public function 
    getResistance(){
            return 
    0;
        }
     
        public function 
    getToolType(){
            return 
    Tool::TYPE_PICKAXE// or TYPE_AXE and so on!
        
    }
     
        public function 
    canPassThrough(){
            return 
    true// or false
        
    }
     
        public function 
    hasEntityCollision(){
            return 
    true// or false
        
    }
    }

    Main.php (onEnable)

    PHP:
    public function onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
            
    Block::$list[/* CUSTOM BLOCK ID FROM CUSTOMBLOCK.PHP*/] = CustomBlock::class;
    }
     
    Muqsit likes this.
  7. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    From Block.php, there must be a litter more of an extension..
    PHP:
            /** @var Block::class $class*/
            //Block::$list[$id] = $class;
            
    $block = new $class();
            for(
    $data 0$data 16; ++$data){
                
    Block::$fullList[($id << 4) | $data] = new $class($data);
            }
            
    /** @var Block $block */
            
    Block::$solid[$id] = $block->isSolid();
            
    Block::$transparent[$id] = $block->isTransparent();
            
    Block::$hardness[$id] = $block->getHardness();
            
    Block::$light[$id] = $block->getLightLevel();
            
    Block::$lightFilter[$id] = 1;
     
    Palente and Skullex like this.
  8. Skullex

    Skullex Spider

    Messages:
    13
    GitHub:
    skull3x
    O: Thanks for the extra information!
     
    Muqsit likes this.
  9. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    that's as far as you can go, but soon maybe you can add custom texture to custom blocks
     
    WhoAreMe and Skullex like this.
  10. None

    None Creeper

    Messages:
    5
    Can we add custom texture to custom blocks now? How can I do it?
     
  11. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    resource pack?
     
  12. None

    None Creeper

    Messages:
    5
    i mean create a custom block problem, can we create custom block with custom id (1000,2000,etc...) , traits (solid, transparent,etc...) ,etc... ? and how can we do that in PM4?
     
  13. Rem

    Rem Creeper

    Messages:
    4
    Is it possible to create a custom block with custom texture with api 4 or 5 ?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.