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

Throw gold

Discussion in 'Development' started by #A6543, Jul 19, 2017.

  1. #A6543

    #A6543 Zombie

    Messages:
    267
    Hi. I want to throw gold ingots like a snowball. I only know how to do it for a snowball :/

    PHP:
    $nbt = new CompoundTag("", [
        
    "Pos" => new ListTag("Pos", [
            new 
    DoubleTag(""$player->x),
            new 
    DoubleTag(""$player->$player->getEyeHeight()),
            new 
    DoubleTag(""$player->z)
        ]),
        
    "Motion" => new ListTag("Motion", [
            new 
    DoubleTag(""$aimPos->x),
            new 
    DoubleTag(""$aimPos->y),
            new 
    DoubleTag(""$aimPos->z)
        ]),
        
    "Rotation" => new ListTag("Rotation", [
            new 
    FloatTag(""$player->yaw),
            new 
    FloatTag(""$player->pitch)
        ]),
    ]);
    $projectile Entity::createEntity("Snowball"$player->getLevel()->getChunk($player->getX() >> 4$player->getZ() >> 4), $nbt$player);
    $f 1.5;
    $projectile->setMotion($projectile->getMotion()->multiply($f));
    $projectile->spawnToAll();
     
  2. Jonas

    Jonas Baby Zombie

    Messages:
    192
    A Gold Ingot isnt an entity
     
  3. #A6543

    #A6543 Zombie

    Messages:
    267
    That's the problem. I want to throw it away. And I have no idea how
     
  4. #A6543

    #A6543 Zombie

    Messages:
    267
    Can u give me an example?
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    But what are you trying to do? Using it as a decoration or an arrow or, or..?
     
  6. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
      $aimPos $player->getDirectionVector();
                            
    $nbt = new CompoundTag("", [
                                
    "Pos" => new ListTag("Pos", [
                                    new 
    DoubleTag(""$player->x),
                                    new 
    DoubleTag(""$player->$player->getEyeHeight()),
                                    new 
    DoubleTag(""$player->z)
                                ]),
                                
    "Motion" => new ListTag("Motion", [
                                    new 
    DoubleTag(""$aimPos->x),
                                    new 
    DoubleTag(""$aimPos->y),
                                    new 
    DoubleTag(""$aimPos->z)
                                ]),
                                
    "Rotation" => new ListTag("Rotation", [
                                    new 
    FloatTag(""$player->yaw),
                                    new 
    FloatTag(""$player->pitch)
                                ]),
                               
    "Health" => new ShortTag("Health"5),
                               
    "Item" => new CompoundTag("Item", [
                                   
    "id" => new ShortTag("id"Item::GOLD_INGOT),
                                   
    "Damage" => new ShortTag("Damage"0),
                                   
    "Count" => new ByteTag("Count"1),
                               ]),
                               
    "PickupDelay" => new ShortTag("PickupDelay"0x7F),
                            ]);
                            
    $f 1.5;
                            
    $ing Entity::createEntity("Item"$player->getLevel(), $nbt$player);
                            
    $ing->setMotion($ing->getMotion()->multiply($f));
     
    Last edited: Jul 20, 2017
    Enzotttt67 likes this.
  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.