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

    Unsolved [1.12.2] Lever les bras d'une entité comme les Zombies

    Sans suite
    1.12.2
    1
    1
    116
    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.
    • LaNonne
      LaNonne last edited by LaNonne

      Bonjour,

      J’aimerais que mon entité Mommie lève les bras, comme un Zombie. Mais je n’y arrive pas.
      J’ai copier/coller le modèle du Zombie dans ma classe modèle pour la mommie mais toujours rien.

      package fr.hugo.hostile.models;
      
      import fr.hugo.hostile.entity.EntityMummy;
      import net.minecraft.client.model.ModelBiped;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.monster.EntityZombie;
      import net.minecraft.util.math.MathHelper;
      import net.minecraftforge.fml.relauncher.Side;
      import net.minecraftforge.fml.relauncher.SideOnly;
      
      @SideOnly(Side.CLIENT)
      public class ModelMummy extends ModelBiped
      {
          public ModelMummy()
          {
              this(0.0F, false);
          }
      
          public ModelMummy(float modelSize, boolean p_i1168_2_)
          {
              super(modelSize, 0.0F, 64, p_i1168_2_ ? 32 : 64);
          }
      
          /**
           * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
           * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
           * "far" arms and legs can swing at most.
           */
          public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
          {
              super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
              boolean flag = entityIn instanceof EntityMummy && ((EntityMummy)entityIn).isArmsRaised();
              float f = MathHelper.sin(this.swingProgress * (float)Math.PI);
              float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float)Math.PI);
              this.bipedRightArm.rotateAngleZ = 0.0F;
              this.bipedLeftArm.rotateAngleZ = 0.0F;
              this.bipedRightArm.rotateAngleY = -(0.1F - f * 0.6F);
              this.bipedLeftArm.rotateAngleY = 0.1F - f * 0.6F;
              float f2 = -(float)Math.PI / (flag ? 1.5F : 2.25F);
              this.bipedRightArm.rotateAngleX = f2;
              this.bipedLeftArm.rotateAngleX = f2;
              this.bipedRightArm.rotateAngleX += f * 1.2F - f1 * 0.4F;
              this.bipedLeftArm.rotateAngleX += f * 1.2F - f1 * 0.4F;
              this.bipedRightArm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
              this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
              this.bipedRightArm.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
              this.bipedLeftArm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
          }
      }
      
      
      

      J’ai lu le code et j’ai remarqué qu’il y a ARM_RAISED. J’ai donc implémenté un code dans la classe EntityMummy.

      private static final DataParameter<Boolean> ARMS_RAISED = EntityDataManager.<Boolean>createKey(EntityZombie.class, DataSerializers.BOOLEAN);
      
      @SideOnly(Side.CLIENT)
          public boolean isArmsRaised()
          {
              return ((Boolean)this.getDataManager().get(ARMS_RAISED)).booleanValue();
          }
      

      Et voici la classe RenderMummy, je me suis inspiré des classes Zombies et PigZombies.

      package fr.hugo.hostile.renders;
      
      import fr.hugo.hostile.Reference;
      import fr.hugo.hostile.entity.EntityAssassin;
      import fr.hugo.hostile.entity.EntityBabyMummy;
      import fr.hugo.hostile.entity.EntityMummy;
      import fr.hugo.hostile.models.ModelAssassin;
      import fr.hugo.hostile.models.ModelBabyMummy;
      import fr.hugo.hostile.models.ModelMummy;
      import net.minecraft.client.model.ModelBiped;
      import net.minecraft.client.model.ModelZombie;
      import net.minecraft.client.renderer.entity.RenderBiped;
      import net.minecraft.client.renderer.entity.RenderLiving;
      import net.minecraft.client.renderer.entity.RenderManager;
      import net.minecraft.client.renderer.entity.layers.LayerBipedArmor;
      import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.passive.EntityOcelot;
      import net.minecraft.entity.passive.EntityParrot;
      import net.minecraft.util.ResourceLocation;
      import net.minecraftforge.fml.relauncher.SideOnly;
      
      
      public class RenderMummy extends RenderBiped<EntityMummy>
      
      {
      
      	public static final ResourceLocation[] MUMMIES_TEXTURES = new ResourceLocation[] {new ResourceLocation(Reference.MOD_ID + ":textures/humans/mummy.png"), 
      			new ResourceLocation(Reference.MOD_ID + ":textures/humans/mummy1.png"), new ResourceLocation(Reference.MOD_ID + ":textures/humans/mummy2.png"), 
      			new ResourceLocation(Reference.MOD_ID + ":textures/humans/mummy3.png")};
      
      
      	public RenderMummy(RenderManager renderManagerIn)
          {
              super(renderManagerIn, new ModelZombie(), 0.5F);
              this.addLayer(new LayerBipedArmor(this)
              {
                  protected void initArmor()
                  {
                      this.modelLeggings = new ModelZombie(0.5F, true);
                      this.modelArmor = new ModelZombie(1.0F, true);
                  }
              });
          }
      
      	
      	
      	protected ResourceLocation getEntityTexture(EntityMummy entity)
          {
              return MUMMIES_TEXTURES[entity.getVariant()];
          }
      	
      
      
      }
      

      A la fin, j’obtiens ceci: text alternatif

      Voila, si quelqu’un sait comment faire lever les bras de mon entité, je suis preneur 🙂

      Merci!

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

      MINECRAFT FORGE FRANCE © 2018

      Powered by NodeBB