MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Tête du joueur sur un bloc

    Planifier Épinglé Verrouillé Déplacé Résolu Anciennes versions
    1.6.4
    2 Messages 2 Publieurs 1.1k Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • Fine33F Hors-ligne
      Fine33
      dernière édition par

      Bonjour ! Voilà, tout est dans le titre, je voudrai faire apparaître la tête du joueur sur un bloc, mais je ne trouve pas quel code il faut intégrer dans le .class de mon bloc. Le voici (c’est un bloc type gâteau) :

      package modagriculcraft;
      
      import java.util.Random;
      
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import net.minecraft.block.Block;
      import net.minecraft.block.material.Material;
      import net.minecraft.client.renderer.texture.IconRegister;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.util.AxisAlignedBB;
      import net.minecraft.util.Icon;
      import net.minecraft.world.IBlockAccess;
      import net.minecraft.world.World;
      
      public class Blockfro extends Block
      {
      
      @SideOnly(Side.CLIENT)
      private Icon cakeTopIcon, cakeBottomIcon, cakeInnerIcon;
      
      public Icon getIcon(int icon1, int icon2)
      {
      return icon1 == 1 ? this.cakeTopIcon : (icon1 == 0 ? this.cakeBottomIcon : (icon2 > 0 && icon1 == 4 ? this.cakeInnerIcon : this.blockIcon));
      }
      
      @SideOnly(Side.CLIENT)
      
      public void registerIcons(IconRegister iconregister)
      {
      this.blockIcon = iconregister.registerIcon("ac:cfro_side");
      this.cakeInnerIcon = iconregister.registerIcon("ac:ifro_inner");
      this.cakeTopIcon = iconregister.registerIcon("ac:hfro_top");
      this.cakeBottomIcon = iconregister.registerIcon("ac:hfro_bottom");
      }
      
      public Blockfro(int id)
      {
      super(id, Material.cake);
      this.setTickRandomly(true);
      this.setCreativeTab(Modmain.act);
      
      }
      
      public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int dir012, int dir3, int y)
      {
      int l = par1IBlockAccess.getBlockMetadata(dir012, dir3, y);
      float f = 0.0625F;
      float f1 = (float)(1 + l * 2) / 16.0F;
      float f2 = 0.5F;
      this.setBlockBounds(f1, 0.0F, f, 1.0F - f, f2, 1.0F - f);
      }
      
      public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int dir012, int dir3, int y)
      {
      int l = world.getBlockMetadata(dir012, dir3, y);
      float f = 0.0625F;
      float f1 = (float)(1 + l * 2) / 16.0F;
      float f2 = 0.5F;
      return AxisAlignedBB.getAABBPool().getAABB((double)((float)dir012 + f1), (double)dir3, (double)((float)y + f), (double)((float)(dir012 + 1) - f), (double)((float)dir3 + f2 - f), (double)((float)(y + 1) - f));
      }
      
      @SideOnly(Side.CLIENT)
      public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int dir012, int dir3, int y)
      {
      int l = world.getBlockMetadata(dir012, dir3, y);
      float f = 0.0625F;
      float f1 = (float)(1 + l * 2) / 16.0F;
      float f2 = 0.5F;
      return AxisAlignedBB.getAABBPool().getAABB((double)((float)dir012 + f1), (double)dir3, (double)((float)y + f), (double)((float)(dir012 + 1) - f), (double)((float)dir3 + f2), (double)((float)(y + 1) - f));
      }
      
      public void setBlockBoundsForItemRender()
      {
      float f = 0.0625F;
      float f1 = 0.5F;
      this.setBlockBounds(f, 0.0F, f, 1.0F - f, f1, 1.0F - f);
      }
      
      public boolean renderAsNormalBlock()
      {
      return false;
      }
      
      public boolean isOpaqueCube()
      {
      return false;
      }
      
      public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
      
      {
      
      this.eatCakeSlice(world, x, y, z, par5EntityPlayer);
      
      return true;
      
      }
      
      private void eatCakeSlice(World world, int x, int y, int z, EntityPlayer entityplayer)
      {
      if(entityplayer.canEat(false))
      {
      entityplayer.getFoodStats().addStats(5, 0.1F);
      int l = world.getBlockMetadata(x, y, z) + 1;
      
      if(l >= 6)
      {
      world.setBlockToAir(x, y, z);
      }
      else
      {
      world.setBlockMetadataWithNotify(x, y, z, l, 2);
      }
      }
      }
      
      public boolean canPlaceBlockAt(World world, int x, int y, int z)
      {
      return !super.canPlaceBlockAt(world, x, y, z) ? false : this.canBlockStay(world, x, y, z);
      }
      
      public void onNeighborBlockChange(World world, int x, int y, int z)
      {
      if(!this.canBlockStay(world, x, y, z))
      {
      world.setBlockToAir(x, y, z);
      }
      }
      
      public boolean canBlockStay(World world, int x, int y, int z)
      {
      return world.getBlockMaterial(x, y - 1, z).isSolid();
      }
      
      public int quantityDropped(Random random)
      {
      return 0;
      }
      
      public int idDropped(int id, Random random, int par3)
      {
      return 0;
      }
      
      public int idPicked(World world, int x, int y, int z)
      {
      return Modmain.Blockfro.blockID;
      }
      }
      

      Merci d’avance,

      Fine33.

      Mes mods :

      Agriculcraft

      #L'âge ne fait pas le mod.(L'âge ne fait pas le mod.)

      1 réponse Dernière réponse Répondre Citer 0
      • robin4002R Hors-ligne
        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
        dernière édition par

        Tile entité : http://www.minecraftforgefrance.fr/showthread.php?tid=106
        Rendu TESR : http://www.minecraftforgefrance.fr/showthread.php?tid=127

        Si tu veux un bloc entier, fait un bloc de 1x1, en tout cas il faut un TileEntitySpecialRender pour rendre la tête du joueur.
        Ensuite pour rendre la tête, regarde net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer, dans la fonction func_82393_a, c’est ce code qui rend la tête si le joueur est valide, sinon ça met la tête du mexicain :

        ResourceLocation resourcelocation = AbstractClientPlayer.locationStevePng;
        
        if (par7Str != null && par7Str.length() > 0)
        {
        resourcelocation = AbstractClientPlayer.getLocationSkull(par7Str);
        AbstractClientPlayer.getDownloadImageSkin(resourcelocation, par7Str);
        }
        
        this.bindTexture(resourcelocation);
        
        1 réponse Dernière réponse Répondre Citer 0
        • 1 / 1
        • Premier message
          Dernier message
        Design by Woryk
        ContactMentions Légales

        MINECRAFT FORGE FRANCE © 2024

        Powered by NodeBB