Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MobArmorEquipmentPacket

Comments in 'Plugin Development' started by CookieSteve, Apr 21, 2016.

  1. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    How to Equip a Mob with Armor? i got a mob to hold a stone block for testing but i cant figure out Armor ;)
  2. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    :eek::eek:
    Primus and HotFireyDeath like this.
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    http://minecraft.gamepedia.com/Inventory

    Code:
    Helmet - 0
    Chestplate - 1
    Leggings - 2
    Boots - 3
    
    PHP:
    $armor = [
       
    Item::get(Item::DIAMOND_HELMET),
       
    Item::get(Item::DIAMOND_CHESTPLATE),
       
    Item::get(Item::DIAMOND_LEGGINGS),
       
    Item::get(Item::DIAMOND_BOOTS)
    ];
    foreach(
    $armor as $i => $item)
    {
       
    $pk = new MobArmorEquipmentPacket();
       
    $pk->eid $entity->getId();
       
    $pk->item $item;
       
    $pk->slot $i;
       
    $pk->selectedSlot 5;

       
    $this->getServer()->broadcastPacket($entity->getViewers(), $pk);
    }
    Maby you can test this code? It's better than nothing :confused:
  4. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Bump: Packet changed..
    PHP:
    $players $level->getPlayers();
                
    $player $players[array_rand($players)];

                
    $nbt = new CompoundTag("", [
                        
    "Pos" => new ListTag("Pos", [
                                new 
    DoubleTag(""$player->getX() + mt_rand(-1010)),
                                new 
    DoubleTag(""$player->getY()),
                                new 
    DoubleTag(""$player->getZ() + mt_rand(-1010))
                        ]),
                        
    "Motion" => new ListTag("Motion", [
                                new 
    DoubleTag(""0),
                                new 
    DoubleTag(""0),
                                new 
    DoubleTag(""0)
                        ]),
                        
    "Rotation" => new ListTag("Rotation", [
                                new 
    FloatTag(""lcg_value() * 360),
                                new 
    FloatTag(""0)
                        ]),
                ]);
               
                
    $nbt->CustomName = new StringTag("CustomName""GHOST");
               
                
    $entity Entity::createEntity(Skeleton::NETWORK_ID$player->getLevel()->getChunk($player->>> 4$player->>> 4), $nbt);
                if(
    $entity instanceof Entity){
                    
    $level->addEntity($entity);
                    
    $entity->setDataProperty(15Entity::DATA_TYPE_BYTE1);
                    
    $entity->setDataProperty(5Entity::DATA_TYPE_BYTE1);
                    
    $entity->setDataProperty(23Entity::DATA_TYPE_BYTE1);
                    
    $entity->setDataProperty(14Entity::DATA_TYPE_BYTE1);
                    
    $entity->setDataProperty(15Entity::DATA_TYPE_BYTE1);
                    
    $pk = new MobArmorEquipmentPacket();
                    
    $pk->eid $entity->getId();
                    
    $pk->slots = [=> Item::get(Item::PUMPKIN), => Item::get(0), => Item::get(0), => Item::get(Item::DIAMOND_BOOTS)];
                    
    $this->getServer()->broadcastPacket($entity->getViewers(), $pk);
                    
    // ghost added
                    
    $this->getLogger()->debug("SUCCESS! New Ghast spawned");
                }
            }
    Sadly:doesn't show to client.
    XShockinFireX likes this.
  5. XShockinFireX
    Offline

    XShockinFireX New Member

    Joined:
    Jan 28, 2016
    Posts:
    14
    Minecraft User:
    XShockinFireX
    Add
    PHP:
    $entity->spawnToAll();
    before you send the packet, it worked for me.
    Last edited: Nov 3, 2016
    thebigsmileXD likes this.
  6. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Actually in
    Code:
    (number) => value
    it is not necessary to include the number, php already does it by itself.
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    You're right in this case, but
    What if php starts indexing arrays from '1' automatically?
  8. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    No, it always starts from 0, @thebigsmileXD started from 0, it's not necessary.
  9. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    This worked.
  10. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Nope
    He actually isn't right. First entity is the Player
    And for the items it was a test if i can set in different order

Share This Page

Advertisement