NMS No such method error net.minecraft.server.1.8.3.world

Discussion in 'Plugin Development' started by Lucasnonime, Apr 26, 2017.

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

    Lucasnonime

    Hello there, i am making 30 custom entities for my server and i have a problem. The fact is that i observed that when i load a chunk with my custom entity it throw this error

    [​IMG]

    And again and again. Here it's the class (a inner class):

    Code:
    public class HunterFangieuxArmorStandEntity extends EntityArmorStand {
    
            public HunterFangieuxArmorStandEntity(World world) {
                super(world);
                this.world = world;
                ((CraftLivingEntity) this.getBukkitEntity()).getEquipment().setHelmet(helmet);
                this.setInvisible(true);
            }
    
            public int index;
    
            @Override
            public void m(){
                setPosition(getEntity().getLocation().getX(), getEntity().getLocation().getY()-(0.62*index), getEntity().getLocation().getZ());
                setYawPitch(getEntity().getLocation().getYaw(), getEntity().getLocation().getPitch());
            }
    
            @Override
            public boolean damageEntity(DamageSource damagesource, float f){
                if(!damagesource.translationIndex.equals("inWall"))
                return ((CraftEntity) getEntity()).getHandle().damageEntity(damagesource, f);
                return false;
            }
    
        }
    And finally the CustomEntityType line :

    Code:
     FANGIEUXARMORSTAND("FangieuxArmorStand", EntityType.ARMOR_STAND, EntityArmorStand.class, HunterFangieux.HunterFangieuxArmorStandEntity.class),  
    Yes i am registering it in onEnable and i have other entities that work but those dont :( If someone can help me, thanks ^^

    EDIT: Maybe it is because of it's a anonymous class, all the entities that are working in my enum are "classic" classes and i dont the other differences with this class u_u
     
  2. Offline

    Caderape2

    @Lucasnonime You don't have the good object World
    You need the craftWorld i think for armorstand
     
    Last edited: Apr 26, 2017
  3. Offline

    Zombie_Striker

  4. Offline

    Lucasnonime

    I have the good world. And go in other version is not an option (i want it but the half on the staff and the players don't so..)
     
    Last edited: Apr 26, 2017
  5. Offline

    Caderape2

    @Lucasnonime you need to cast your actual world to a craftworld
     
  6. Offline

    Lucasnonime

    @Caderape2 I have the right world ! net.minecraft.server.1.8R3.world this is not the problem lol
     
  7. Offline

    Caderape2

    @Lucasnonime org.bukkit.craftbukkit.version.CraftWorld
    it's what you need
     
  8. Offline

    Lucasnonime

    @Caderape2 just look at the error message but yes if you want i'll try it this evening

    I just cant cast it in CraftWorld the super needs a NMS world..

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Apr 27, 2017
  9. Offline

    Caderape2

    @Lucasnonime Use 'org.bukkit.World' then super( ((CraftWorld)world).getHandle() );

    edit: And if you look the error message, it says :
    Constructor(net.minecraft.server.1.8R3.world world) does not exist
     
    Last edited: Apr 27, 2017
    Zombie_Striker likes this.
  10. Offline

    Lucasnonime

  11. Offline

    Caderape2

    @Lucasnonime Weird, that works for me.
    You can show your updated code and import ?
     
  12. Offline

    Lucasnonime

    I made others entities that are working but some of the new i am doing are not...
    Its just insane i have entities that are not registered in the enum but still working, others that are registered and use the NMS world in constructor and are working and those entitities..


    Code:
    package fr.poudlardrp.api.game.jobs.hunterEntities;
    
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    
    import org.bukkit.Location;
    import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
    import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
    import org.bukkit.metadata.FixedMetadataValue;
    
    import fr.poudlardrp.api.BukkitInjector;
    import fr.poudlardrp.api.game.jobs.JobRecipe;
    import fr.poudlardrp.api.game.jobs.hunter.HunterEntity;
    import fr.poudlardrp.api.game.jobs.hunter.HunterLoot;
    import fr.poudlardrp.api.game.jobs.hunter.HunterLoot.LootType;
    import fr.poudlardrp.api.game.jobs.hunterEntities.behaviors.HunterPassiveBehavior;
    import net.minecraft.server.v1_8_R3.DamageSource;
    import net.minecraft.server.v1_8_R3.Entity;
    import net.minecraft.server.v1_8_R3.EntityRabbit;
    import net.minecraft.server.v1_8_R3.World;
    
    public class HunterJackalope extends HunterEntity {
    
        public static List<HunterLoot> loots = new ArrayList<>(Arrays.asList(new HunterLoot(JobRecipe.jackalopeHunterRecipe, LootType.HUNTER), new HunterLoot(JobRecipe.jackalopeHunterRecipe2, LootType.HUNTER), new HunterLoot(JobRecipe.jackalopeCommonRecipe,  LootType.COMMON)));
    
        public HunterJackalope() {
            super(loots);
        }
    
    
        @Override
        public void spawn(Location l) {
            location = l;
            Entity entity = new HunterJackalopeEntity(((CraftWorld) location.getWorld()));
            entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
            ((CraftWorld) location.getWorld()).getHandle().addEntity(entity, SpawnReason.CUSTOM);
            entity.getBukkitEntity().setMetadata("hunter", new FixedMetadataValue(BukkitInjector.getInstance(), this));
    
            entity.getBukkitEntity().setCustomName("ยง7Jackalope");
    
            activeEntity = entity.getBukkitEntity();
        }
    
        @Override
        public void approach(Player p) {
            hasBeenApproached = true;
            setTarget(p);
        }
    
        public class HunterJackalopeEntity extends EntityRabbit{
    
            public HunterJackalopeEntity(org.bukkit.World world) {
                super(((CraftWorld) world).getHandle());
                setBehavior(new HunterPassiveBehavior(getObject()));
            }
    
            @Override
            public void m(){
    
                super.m();
    
                getBehavior().doTick(this);
    
                if(((HunterPassiveBehavior)getBehavior()).attackTick >= 30){
                    if(getBukkitEntity().getLocation().getWorld().equals(getTarget().getLocation().getWorld())){
                        if(getBukkitEntity().getLocation().distance(getTarget().getLocation()) <= 2 && ((CraftPlayer) getTarget()).getHandle().hasLineOfSight(getBukkitEntity().getHandle())){
                            ((CraftPlayer) getTarget()).getHandle().damageEntity(DamageSource.mobAttack(this), 2);
                            ((HunterPassiveBehavior)getBehavior()).attackTick = 0;
                        }
                    }
                }
    
            }
    
        }
    
    }
    
    Here it is @Caderape2
    EDIT: And by the way it works """"better"""" when i put the NMS world in the constructor
     
    Last edited: Apr 28, 2017
  13. Offline

    Caderape2

    @Lucasnonime and the class HunterFangieuxArmorStandEntity works now ?
     
  14. Offline

    Lucasnonime

    @Caderape2 no, i just took a random class soz ^^

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Apr 29, 2017
Thread Status:
Not open for further replies.

Share This Page