Navigation

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Gui modifiant une Entity

    Sans suite
    1.7.10
    3
    3
    446
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Ciolgaming
      Ciolgaming last edited by

      Bonjour, je souhaiterai faire que quand je clique droit sur un Mob, celui-ci affiche un Gui dans celui là on pourrait y mettre des items(améliorations) qui amélioreraient sa vitesse et sa force

      Pour l’instant j’ai fait celà, je voudrais savoir si celà fonctionne comme les tileentities du tuto customfurnace ??

      Voici le code de mon mob pour le moment :

      package com.mod.ciolmod.entity;
      
      import com.mod.ciolmod.gui.GuiServer;
      import com.mod.ciolmod.init.ItemMod;
      
      import net.minecraft.client.Minecraft;
      import net.minecraft.entity.SharedMonsterAttributes;
      import net.minecraft.entity.ai.EntityAIAttackOnCollide;
      import net.minecraft.entity.ai.EntityAIHurtByTarget;
      import net.minecraft.entity.ai.EntityAILookIdle;
      import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
      import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
      import net.minecraft.entity.ai.EntityAISwimming;
      import net.minecraft.entity.ai.EntityAIWander;
      import net.minecraft.entity.ai.EntityAIWatchClosest;
      import net.minecraft.entity.monster.EntityMob;
      import net.minecraft.entity.passive.EntityVillager;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.init.Items;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemStack;
      import net.minecraft.world.World;
      
      public class EntityGuard extends EntityMob{
      
      public EntityGuard(World p_i1738_1_) {
      super(p_i1738_1_);
             this.getNavigator().setBreakDoors(true);
      
             this.tasks.addTask(0, new EntityAISwimming(this));
             this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 25.0D, false));
             this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
             this.tasks.addTask(7, new EntityAIWander(this, 25.0D));
             this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 16.0F));
             this.tasks.addTask(8, new EntityAILookIdle(this));
             this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
             this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
             this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false));
             this.setSize(0.9F, 0.8F);
      }
      
      public boolean interact(EntityPlayer player)
         {
             ItemStack itemstack = player.inventory.getCurrentItem();
             boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg;
      
             if (!this.worldObj.isRemote)
             {
              Minecraft.getMinecraft().displayGuiScreen(new GuiServer());
      
                 return true;
             }
             else
             {
                 return super.interact(player);
             }
         }
      
         protected void applyEntityAttributes()
         {
             super.applyEntityAttributes();
             this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
             this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.2D);
             this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5.0D);
             this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(5.0D);
         }
      
         protected Item getDropItem()
         {
             return Items.diamond;
         }
      
      }
      

      Merci de votre réponse et bonne journée 🙂

      1 Reply Last reply Reply Quote 0
      • Deleted
        Deleted last edited by

        Salut, il te faudra un container accompagnant le GUI, de manière à rajouter les slots. Puis un packet custom (client -> serveur) pour sync les attributes du mob sera probablement nécessaire.

        1 Reply Last reply Reply Quote 0
        • Superloup10
          Superloup10 Modérateurs last edited by

          Le plus simple est de regarder comment fonctionne les villageois, les ânes et les mules qui portent un coffre, ainsi que les minecarts chest/hopper.

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Design by Woryk
          Contact / Mentions Légales / Faire un don

          MINECRAFT FORGE FRANCE © 2018

          Powered by NodeBB