Solved Summon giant holding stone sword

Discussion in 'Plugin Development' started by CraterHater, Jul 28, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    CraterHater

    How do I give him a stone sword I already got this:
    Code:
              Location a = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ());
                    Entity Sword = p.getWorld().spawnEntity(a, EntityType.GIANT);
                    ((LivingEntity)Sword).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY,200, 200), true);
    Thanks in advance
     
  2. Offline

    _Error

    Code:
    Location a = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ());
    Giant g = (Giant) p.getWorld().spawnEntity(a, EntityType.GIANT);
    ((LivingEntity)g).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY,200, 200), true);
    g.getEquipment().getItemInHand().setType(Material.STONE_SWORD);
    Not sure about anything, Just try it xD
     
  3. Offline

    CraterHater

    @_Error that only summons the zombie with the effect but without the sword Any other ideas?
     
  4. Offline

    _Error

    Code:
    if(g.getEquipment().getItemInHand().equals(null)){
    g.getEquipment().getItemInHand().setType(Material.STONE_SWORD);
    }
    I'm not sure why, Maybe try this?
     
  5. Offline

    mine-care

    @_Error May i ask why you are spoonfeeding? and even worse, code that isnt gonna work.
    Code:
    Object one = null;
    if(one.equals(null)) -> NPE, one is null, you cant use any methods from it! 
    
     
  6. Offline

    _Error

    Is spoonfeeding illegal? I'm spoonfeeding cause I can, And I'm not too familiar with mobs.
     
  7. Offline

    AndersonEpic

    Get the equipment of the giant, and use #setItemItemInHand() to set the ItemInHand to a stone sword.
     
    mine-care likes this.
  8. Offline

    mine-care

    @_Error It isnt illegual thats for sure.
    The thing is that these forums here are ment to help people, by just sending the code pre-made to the asker will most of the time result in a copy-paste without even reading it or gaining any knowledge. Then the next day the same guy who asks wants to do something different with the same piece of code but has no idea how it was done in the first place, and therefore cannot do the changes needed, then they are back here with a new questions. The problem isnt the ammount of questions, it is the essense! Its them coding afterall, if it was just to give out the code why not making the plugin and spreading them to other people to put on their names/signatures and pass them as theirs.

    From my experience in theese forums (infact it was very recently, like yersterday or two days ago) someone asked how he could do an X operaition and someone just threw a piece of code to them, the response was "i copy - pasted your code and it didnt work."
    Finally, concerning the piece of code above it is Java not Mobs :p. I cant force you to stop spoon feeding, but i can recomend you to, and giving a reason (or a few reasons) for my recomendation.

    P.S. found it!
    http://bukkit.org/threads/saving-a-complex-hashmap-to-a-file.375680/#post-3179084
     
    _Error and bwfcwalshy like this.
  9. Offline

    CraterHater

    I solved it, thanks still. It was done using:
    Code:
    EntityEquipment ee = g.getEquipment();
    ee.setItemInHand(new ItemStack(Material.STONE_SWORD, 1));
    To explain it: You get the entity equipment and name it "ee" then you set ee to a new ItemStack, makes sense to me.
     
  10. Offline

    _Error

    Thanks for convincing me, I'll try to lower them as much as I can, My explaining is not the best in any way of sort.
     
    mine-care likes this.
  11. Offline

    mine-care

    @_Error :D you are pretty much the first or second guy to ever listen to me :D
    Thanks!!
     
    _Error likes this.
  12. Offline

    BurnerDiamond

    Sorry to jump in but I unfortunately don't completely agree with this, I think that code should sometimes be given to be analysed / studied. If the user tries to copy and paste, he only does more trouble for himself, but seeing how it can be done and sometimes spoon-feeding him the answers, can solve the solution and help him not have the same problem. I was once spoon-fed a constructor method for Teams and now I'm able to do anything with it, whether it being arenas, or a completely Bukkit non-related things. In conclusion I personally think that spoon-feeding isn't good but it definitely isn't that bad, when used the appropriate way.
     
    _Error likes this.
  13. Offline

    _Error

    Thanks

    my dad told me im special too
     
  14. Offline

    mine-care

    @BurnerDiamond
    Well, we avoid it exacly because these years we have noticed that when it occurs people just copy-paste it despite all the efforts to explain what miece does what. Unfortunately not all users are like you :- )

    But still
     
Thread Status:
Not open for further replies.

Share This Page