Invisible entities

Discussion in 'Plugin Development' started by jeussa, Nov 5, 2014.

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

    jeussa

    Hi dere,

    I've been working on a plugin which can spawn custom entities. So far so good, they've been spawned. Only I encountered a small issue: they're invisible...

    Here's some of the code which should contains the mistake:

    Code:java
    1. /**
    2.   * Spawns an NPC
    3.   * @param vn
    4.   */
    5. public NPC s(VirtualNPC vn){
    6. Location l = vn.getSpawnLocation();
    7. CraftWorld cw = (CraftWorld)l.getWorld();
    8. WorldServer w = cw.getHandle();
    9. EntityInsentient e = null;
    10. Class<? extends EntityInsentient> c = vn.getNpcClass().getNpcClass();
    11.  
    12. /**
    13.   * CHATTY
    14.   */
    15. if(c.equals(cDairyCow.class)){
    16. e = new cDairyCow(w);
    17. }
    18. //Owen
    19. else if(c.equals(Owen_Tutorial01.class)){
    20. e = new Owen_Tutorial01(w);
    21. }
    22. else if(c.equals(Owen_Tutorial02.class)){
    23. e = new Owen_Tutorial02(w);
    24. }
    25. /**
    26.   * MERCHANT
    27.   */
    28. /**
    29.   * MOB
    30.   */
    31.  
    32. if(e == null)return null;
    33.  
    34. //e.spawnIn(w);
    35. e.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
    36. w.addEntity(e, SpawnReason.NATURAL);
    37.  
    38. NPC n = new NPC(vn.getNpcClass(), CraftEntity.getEntity((CraftServer)Bukkit.getServer(), e));
    39. a(n);
    40. return n;
    41. }


    and here's the entity I used for testing:

    Code:java
    1. package net.invasioncraft.rpg.npc.chatty.owen;
    2.  
    3. import java.util.List;
    4.  
    5. import org.bukkit.entity.EntityType;
    6. import org.bukkit.entity.Villager.Profession;
    7. import org.bukkit.event.entity.EntityDamageEvent;
    8. import org.bukkit.event.entity.EntityDeathEvent;
    9. import org.bukkit.event.entity.EntityTargetEvent;
    10. import org.bukkit.event.player.PlayerInteractEntityEvent;
    11.  
    12. import net.minecraft.server.v1_7_R4.*;
    13. import net.invasioncraft.rpg.icRpg;
    14. import net.invasioncraft.rpg.npc.npcManager;
    15. import net.invasioncraft.rpg.npc.chatty.Chatty;
    16. import net.invasioncraft.rpg.npc.chatty.ConversationComponent;
    17.  
    18. public abstract class Owen extends EntityVillager implements Chatty{
    19.  
    20. private static String chatName = "§a[§fOwen§a] §f", customName = "§a[§fOwen§a]";
    21. private static EntityType entityType = EntityType.VILLAGER;
    22. private static Profession profession = Profession.LIBRARIAN;
    23. private ConversationComponent[] conversationComponents;
    24. private int conversationSpeed;
    25.  
    26. @SuppressWarnings("rawtypes")
    27. public Owen(World world, String idSuffix, ConversationComponent[] conversationComponents, int conversationSpeed){
    28. super(world);
    29. this.conversationComponents = conversationComponents;
    30. this.conversationSpeed = conversationSpeed;
    31.  
    32. npcManager m = icRpg.getNpcManager();
    33.  
    34. List goalB = (List)m.g("b", PathfinderGoalSelector.class, goalSelector); goalB.clear();
    35. List goalC = (List)m.g("c", PathfinderGoalSelector.class, goalSelector); goalC.clear();
    36. List targetB = (List)m.g("b", PathfinderGoalSelector.class, targetSelector); targetB.clear();
    37. List targetC = (List)m.g("c", PathfinderGoalSelector.class, targetSelector); targetC.clear();
    38.  
    39. this.goalSelector.a(0, new PathfinderGoalFloat(this));
    40. this.goalSelector.a(1, new PathfinderGoalRandomStroll(this, 1.0D));
    41. this.goalSelector.a(2, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
    42. this.goalSelector.a(3, new PathfinderGoalRandomLookaround(this));
    43. }
    44.  
    45. @Override
    46. @SuppressWarnings("deprecation")
    47. public int getProfession(){
    48. return profession.getId();
    49. }
    50.  
    51. public Profession getBukkitProfession(){
    52. return profession;
    53. }
    54.  
    55. public String getCustomName(){
    56. return customName;
    57. }
    58.  
    59. public String getChatName(){
    60. return chatName;
    61. }
    62.  
    63. public EntityType getEntityType(){
    64. return entityType;
    65. }
    66.  
    67. public ConversationComponent[] getConversation(){
    68. return conversationComponents;
    69. }
    70.  
    71. public int getConversationSpeed(){
    72. return conversationSpeed;
    73. }
    74.  
    75. public void onEvent(EntityDamageEvent event){
    76. event.setCancelled(true);
    77. }
    78. public void onEvent(PlayerInteractEntityEvent event){
    79.  
    80. }
    81. public void onEvent(EntityDeathEvent event){
    82. return;
    83. }
    84. public void onEvent(EntityTargetEvent event){
    85. event.setCancelled(true);
    86. }
    87. }
    88.  


    Thanks for your time :)
     
  2. Offline

    Europia79

    jeussa

    Here's a project I did that also has custom Entities:
    https://github.com/Europia79/Extraction

    Here's a good tutorial:
    http://forums.bukkit.org/threads/nms-tutorial-how-to-override-default-minecraft-mobs.216788/

    Here's one of the custom entities:
    https://github.com/Europia79/Extrac...euro/extraction/nms/v1_7_R4/CraftHostage.java

    Here is the class that spawns it:
    https://github.com/Europia79/Extrac...pi/src/mc/euro/extraction/nms/NPCFactory.java

    My code is working. So if you look over it and the tutorial, it might give you some ideas on how to fix yours.
     
  3. Offline

    jeussa

    I've tried recoding the part of my plugin where I create and spawn custom entities about 3 times (the final time with your code), and I'm still getting the same result: I can hear entities walk, idle, even bukkit knows it's there (because I'm selecting the nearest entity to a commandSender after spawning it)
    However still no textures, not even if I try to relog. Even though my actions are the same as yours :/

    I also tried spawning normal entities to see if any plugin is blocking them from spawning. However the entities were able to spawn so no plugin should be interferring.
     
  4. Offline

    jeussa

    I've been doing some testing with spawning a normal EntityCow and an empty class extending EntityWolf only containing public TestWolf(World world)
    The cow has spawned, the dog however hasnt't. So I think something is going wrong with registering the custom enity. Which seems quite odd because I even tried a copy of the source provided by Europia79
     
    Europia79 likes this.
  5. Offline

    jeussa

    Could still use some help :p
     
Thread Status:
Not open for further replies.

Share This Page