MFF

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

    TESR qui rend mal, et qui n'a pas une jolie Hitbox

    Planifier Épinglé Verrouillé Déplacé Résolu Anciennes versions
    1.6.x
    25 Messages 4 Publieurs 5.6k 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.
    • Nolan-XXN Hors-ligne
      Nolan-XX
      dernière édition par

      Voila ma classe actuellement, elle ne veut toujours pas s’orienter.

      package assets.city01.Blocks;
      
      import net.minecraft.block.BlockContainer;
      import net.minecraft.block.material.Material;
      import net.minecraft.client.renderer.texture.IconRegister;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.item.ItemStack;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.util.AxisAlignedBB;
      import net.minecraft.util.Icon;
      import net.minecraft.util.MathHelper;
      import net.minecraft.world.IBlockAccess;
      import net.minecraft.world.World;
      import assets.city01.Data.ClientProxy;
      import assets.city01.Data.HL2;
      import assets.city01.TileEntity.TileEntityPanneau;
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      
      public class B_Panneau extends BlockContainer {
      private Icon icontop, iconbottom, iconfront;
      private Icon[] Icon1 = new Icon[6];
      private Icon[] Icon2 = new Icon[5];
      private Icon[] Icon3 = new Icon[4];
      private Icon[] Icon4 = new Icon[3];
      private Icon[] Icon5 = new Icon[2];
      private Icon[] Icon6 = new Icon[2];
      private Icon Icon7, Icon8;
      
      public B_Panneau(int par1) {
      super(par1, Material.wood);
      this.setCreativeTab(HL2.Tab);
      
      }
      
      /*
      * public void registerIcons(IconRegister iconRegister) { blockIcon =
      * iconRegister.registerIcon("city01:nope"); iconfront =
      * iconRegister.registerIcon("city01:a"); icontop =
      * iconRegister.registerIcon("city01:b"); iconbottom =
      * iconRegister.registerIcon("city01:c"); }
      */
      
      public void registerIcons(IconRegister iconregister) {
      Icon1[0] = iconregister.registerIcon("city01:nope");
      Icon1[1] = iconregister.registerIcon("city01:nope");
      Icon1[2] = iconregister.registerIcon("city01:nope");
      Icon1[3] = iconregister.registerIcon("city01:a");
      Icon1[4] = iconregister.registerIcon("city01:a");
      Icon1[5] = iconregister.registerIcon("city01:a");
      
      Icon2[0] = iconregister.registerIcon("city01:nope");
      Icon2[1] = iconregister.registerIcon("city01:nope");
      Icon2[2] = iconregister.registerIcon("city01:nope");
      Icon2[3] = iconregister.registerIcon("city01:a");
      Icon2[4] = iconregister.registerIcon("city01:a");
      
      Icon3[0] = iconregister.registerIcon("city01:nope");
      Icon3[1] = iconregister.registerIcon("city01:nope");
      Icon3[2] = iconregister.registerIcon("city01:a");
      Icon3[3] = iconregister.registerIcon("city01:a");
      
      Icon4[0] = iconregister.registerIcon("city01:nope");
      Icon4[1] = iconregister.registerIcon("city01:nope");
      Icon4[2] = iconregister.registerIcon("city01:a");
      
      Icon5[0] = iconregister.registerIcon("city01:nope");
      Icon5[1] = iconregister.registerIcon("city01:a");
      
      Icon6[0] = iconregister.registerIcon("city01:nope");
      Icon6[1] = iconregister.registerIcon("city01:a");
      
      Icon7 = iconregister.registerIcon("city01:nope");
      Icon8 = iconregister.registerIcon("city01:a");
      }
      
      public void onBlockPlacedBy(World world, int x, int y, int z,
      EntityLivingBase living, ItemStack stack) {
      int direction = MathHelper
      .floor_double((double) (living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
      TileEntity te = world.getBlockTileEntity(x, y, z);
      if (te != null && stack.getItemDamage() == 2
      && te instanceof TileEntityPanneau) {
      ((TileEntityPanneau) te).setDirection((byte) direction);
      world.markBlockForUpdate(x, y, z);
      }
      }
      
      @SideOnly(Side.CLIENT)
      public Icon getIcon(int side, int metadata) {
      /*
      * return side == 1 ? this.icontop : (side == 0 ? this.iconbottom :
      * (metadata == 2 && side == 2 ? this.iconfront : (metadata == 3 && side
      * == 5 ? this.iconfront : (metadata == 0 && side == 3 ? this.iconfront
      * : (metadata == 1 && side == 4 ? this.iconfront : this.blockIcon)))));
      */
      
      switch (metadata) {
      case 0:
      return Icon1[side];
      case 1:
      return side > 1 ? Icon2[side - 1] : Icon2[0];
      case 2:
      return side < 4 ? Icon3[side] : Icon3[3];
      case 3:
      return side < 3 ? Icon4[side] : Icon4[2];
      case 4:
      return side < 2 ? Icon5[0] : Icon5[1];
      case 5:
      return side == 1 ? Icon6[0] : Icon6[1];
      case 6:
      return Icon7;
      case 7:
      return Icon8;
      default:
      return blockIcon;
      }
      }
      
      @Override
      public TileEntity createNewTileEntity(World world) {
      return new TileEntityPanneau();
      }
      
      public boolean renderAsNormalBlock() {
      return false;
      }
      
      public boolean isOpaqueCube() {
      return false;
      }
      
      @SideOnly(Side.CLIENT)
      public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x,
      int y, int z) {
      return AxisAlignedBB.getAABBPool().getAABB(
      (double) x + this.minX + 0.0D, (double) y + this.minY,
      (double) z + this.minZ + 0.6D, (double) x + this.maxX + 1.0D,
      (double) y + this.maxY + 1.0D, (double) z + this.maxZ - 0.6D);
      }
      
      public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x,
      int y, int z) {
      return AxisAlignedBB.getAABBPool().getAABB(
      (double) x + this.minX + 0.0D, (double) y + this.minY,
      (double) z + this.minZ + 0.6D, (double) x + this.maxX + 2.0D,
      (double) y + this.maxY + 1.0D, (double) z + this.maxZ - 0.6D);
      }
      
      @SideOnly(Side.CLIENT)
      public int getRenderType() {
      return ClientProxy.renderInventoryTESRId;
      }
      
      @SideOnly(Side.CLIENT)
      public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z,
      int side) {
      TileEntity te = blockAccess.getBlockTileEntity(x, y, z);
      if (te != null && te instanceof TileEntityPanneau) {
      TileEntityPanneau panneau = (TileEntityPanneau) te;
      int direction = panneau.getDirection();
      return side == 1 ? Icon3[0] : (side == 0 ? Icon3[1]
      : (direction == 2 && side == 2 ? Icon3[2] : (direction == 3
      && side == 5 ? Icon3[2] : (direction == 0
      && side == 3 ? Icon3[2] : (direction == 1
      && side == 4 ? Icon3[2] : Icon3[3])))));
      }
      return this.getIcon(side, blockAccess.getBlockMetadata(x, y, z));
      }
      
      }
      
      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

        Mais mais, pourquoi utiliser les icônes ? Les icônes ne servent que pour un bloc avec un rendu normal.
        @‘robin4002’:

        Et pas besoin de faire plusieurs icon dans ton bloc, le TileEntitySpecial rendu s’occupe de tout.

        Ton problème d’orientation vient de la :

        public void renderTileEntityTileEntityPanneauAt(TileEntityPanneau te, double x, double y, double z, float tick)
        {
        GL11.glPushMatrix();
        GL11.glTranslated(x + 1.05F, y + 1.5F, z + 0.5F);
        this.bindTexture(textureLocation);
        GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
        this.model.render(0.0625F);
        if(te != null)
        {
        GL11.glRotatef(90F * te.getDirection(), 0.0F, 1.0F, 0.0F);
        }
        GL11.glPopMatrix();
        }
        

        Cela devrait être :

        public void renderTileEntityTileEntityPanneauAt(TileEntityPanneau te, double x, double y, double z, float tick)
        {
        GL11.glPushMatrix();
        GL11.glTranslated(x + 1.05F, y + 1.5F, z + 0.5F);
        this.bindTexture(textureLocation);
        GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
        if(te != null)
        {
        GL11.glRotatef(90F * te.getDirection(), 0.0F, 1.0F, 0.0F);
        }
        this.model.render(0.0625F);
        GL11.glPopMatrix();
        }
        

        Le this.model.render doit être en dernier.

        1 réponse Dernière réponse Répondre Citer 0
        • Nolan-XXN Hors-ligne
          Nolan-XX
          dernière édition par

          ça ne change toujours rien.

          1 réponse Dernière réponse Répondre Citer 0
          • Nolan-XXN Hors-ligne
            Nolan-XX
            dernière édition par

            Bon, étant donné que ces blocks ne seront pas usés par les joueurs, je vais faire en sorte qu’ils tournent en clique droit dessus.
            Donc j’ai mis ce code dans TileEntityPanneauSpecialRender.java, mais aucun changements.

            public boolean interact(EntityPlayer player)
            {
            GL11.glPushMatrix();
            GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);
            GL11.glPopMatrix();
            return false;
            }
            
            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

              Problème trouvé. Dans la classe de ton bloc, dans la fonction onBlockPlacedBy :

              if(te != null && stack.getItemDamage() == 2 && te instanceof TileEntityPanneau)
              {
              ((TileEntityPanneau)te).setDirection((byte)direction);
              world.markBlockForUpdate(x, y, z);
              }
              

              enlève le stack.getItemDamage() == 2 &&, je l’ai mit dans mon tutoriel car j’ai expliqué que j’orientais que le bloc de metadata 2.

              1 réponse Dernière réponse Répondre Citer 0
              • Nolan-XXN Hors-ligne
                Nolan-XX
                dernière édition par

                Parfait, sauf que j’ai quelques légers problèmes :

                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

                  Ha oui, comme tu as centré le modèle avec la direction par défaut, ça fail pour les autres directions.
                  Dans le if(te != null) de ta fonction renderTileEntityTileEntityPanneauAt dans ta classe TileEntitySpecialRender, il faut que tu ajoute une condition qui check la direction, et tu fais des gl11.translate par rapport à la direction.

                  1 réponse Dernière réponse Répondre Citer 0
                  • Nolan-XXN Hors-ligne
                    Nolan-XX
                    dernière édition par

                    Euh, le block bouge en même temps que moi Oo

                    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

                      What x) ?
                      Envoie ton code.

                      1 réponse Dernière réponse Répondre Citer 0
                      • Nolan-XXN Hors-ligne
                        Nolan-XX
                        dernière édition par

                        
                        public void renderTileEntityTileEntityPanneauAt(TileEntityPanneau te,
                        double x, double y, double z, float tick) {
                        GL11.glPushMatrix();
                        GL11.glTranslated(x + 1.05F, y + 1.5F, z + 0.5F);
                        this.bindTexture(textureLocation);
                        GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
                        if (te != null)
                        {
                        GL11.glRotatef(90F * te.getDirection(), 0.0F, 1.0F, 0.0F);
                        if (te.direction == 1)
                        {
                        // GL11.glTranslated(x + 1.05F, y + 1.5F, z + 0.5F);
                        }
                        
                        if (te.direction == 2)
                        {
                        GL11.glTranslated(x + 0.2F, y + 0.0F, z + 0.0F);
                        }
                        
                        if (te.direction == 3)
                        {
                        // GL11.glTranslated(x + 1.05F, y + 1.5F, z + 0.5F);
                        }
                        
                        if (te.direction == 0)
                        {
                        //base, pas besoin de modifier
                        }
                        System.out.println("La direction est " + te.direction);
                        
                        }
                        this.model.render(0.0625F);
                        GL11.glPopMatrix();
                        }
                        
                        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

                          Ne mets pas les x, y et z dans les translates qui ajuste en fonction de la direction.

                          1 réponse Dernière réponse Répondre Citer 0
                          • Nolan-XXN Hors-ligne
                            Nolan-XX
                            dernière édition par

                            Je mets quoi alors ?

                            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

                              GL11.glTranslated(0.2F, 0.0F, 0.0F);
                              Tout simplement.
                              Le premier GL11.glTranlate déplace déjà le bloc au coord x, y, z.

                              1 réponse Dernière réponse Répondre Citer 0
                              • Nolan-XXN Hors-ligne
                                Nolan-XX
                                dernière édition par

                                Parfait !

                                et peut-tu me passer le lien du lampadaire de Nanotech City, pour que je voie pour les blocs fantômes ?

                                1 réponse Dernière réponse Répondre Citer 0
                                • GuguG Hors-ligne
                                  Gugu
                                  dernière édition par

                                  https://github.com/FFMT/nanotech_mod/blob/master/common/fr/mcnanotech/kevin_68/nanotechmod/city/blocks/BlockLamp.java

                                  C’est lui normalement ^^

                                  Pour les rendus dans l’inventaire, pense a GL11.glScale

                                  "If you have a comprehensive explanation for everything then it decreases uncertainty and anxiety and reduces your cognitive load. And if you can use that simplifying algorithm to put yourself on the side of moral virtue then you’re constantly a good person with a minimum of effort."
                                  ― Jordan B. Peterson

                                  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

                                    L’item bloc est aussi différent : https://github.com/FFMT/nanotech_mod/blob/master/common/fr/mcnanotech/kevin_68/nanotechmod/city/blocks/ItemBlockLamp.java#L39-L69

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • 1
                                    • 2
                                    • 1 / 2
                                    • Premier message
                                      Dernier message
                                    Design by Woryk
                                    ContactMentions Légales

                                    MINECRAFT FORGE FRANCE © 2024

                                    Powered by NodeBB